[[#wd Lookup TitleRecipe30 ]]

Overview

Usually new Pages are derived from existing ones by configuration - i.e. without writing any C++ code. However simple configuration may not work for all cases. Therefore you can always add code for any Page by writing a respective C++ class (as a subclass of Page).

And there are several sound reasons why to write code for a new Page...

Preconditions

All the usual configuration settings are needed whether C++ code for a Page is added or not, i.e. C++ code for a Page may be easily added after the general application structure (Roles, Pages, etc) has been setup.

Reminders: You need to register any Page that you want to use in the UI of your application in the Pages section of Config.any.

If the Page is to be used directly, there must be a respective configuration file 'ExamplePage.any' (unless your page does without any configuration):

Steps to do:

  1. Create the necessary configuration files (see as well other recipes):

  2. Create a new class by subclassing Page (or one of its descendants):
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"class MyNewPage : public Page {"
    		"public:"
    		"	MyNewPage();"
    		"	IFAObject *Clone() const;"
    		"};"
    		" "
    		" "
    		"RegisterPage(MyNewPage);"
    		" "
    		"MyNewPage::MyNewPage() : Page("MyNewPage")"
    		"{"
    		"}"
    		" "
    		"IFAObject *MyNewPage::Clone() const"
    		"{"
    		"	// The New() method needs to be overridden so that other"
    		"	// Pages - that might be derived from MyNewPage purely by"
    		"	// configuration - can share the code of MyNewPage"
    		" "
    		"	return new MyNewPage;"
    		"}"
    	}
    }]]
    
    Caution: The C++ code for a Page is always registered with the name of the class (using the RegisterPage macro in the *.cpp file):
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"RegisterPage(MyNewPage);"
    	}
    }]]
    
    Whereas the name defined in the Page's C++ class default constructor defines the name that is used for identifying the Page at runtime and for retrieving the Page's configuration file. To work properly, the name used in the default constructor MUST match the name of the Page class:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"MyNewPage::MyNewPage() : Page("MyNewPage")"
    		"{"
    		"}"
    	}
    }]]
    
  3. Add the methods that you want to override:

    By overriding either Render() or one of the minor methods Header(), Title(), Body(), Footer() the general rendering strategy of a Page may be modified.

Remarks

Glossary

Related Topics