GUIManager

The main role of GUIManager is to allow you create an GUI Controls (such as Labels, Panels or Buttons).

There are two main ways of creating Controls:

  • loading group of them together from pair of HTML/CSS files,
  • creating them separately with appropriate GUIManager methods.

Controls_from_HTML/CSS_"> Loading Controls from HTML/CSS

To load Controls directly from HTML/CSS files use (learn more about CSS Support in FeyGamesFramework):

void GUIManager::loadFromFiles(std::wstring feyHTMLFileName, std::wstring feyCSSFileName)

It generates an error when e.g. the files have not been found.

GUIManager will look under the PATH_GUI_STRUCTURE for HTML file and under PATH_GUI_STYLES for CSS file (learn more about Paths).

TODO

  • HTML/CSS Special requirements, ID etc.

GUI_Control_without_HTML/CSS_"> Creating GUI Control without HTML/CSS

You can also create Controls one by one with one of those GUIManager methods:

GUIComponent * createComponent(std::wstring ID, std::wstring type, const Styles::CSSPosition &cssPosition,
Styles::Style * style = 0, GUI::GUIContainer * parent = 0);
_X_ * create_X_(const std::wstring &ID, const Styles::CSSPosition &cssPosition, _COMPONENT-SPECIFIC_PARAMETERS_,
Styles::Style * style = 0, GUI::GUIContainer * parent = 0);

Where _X_ is the GUI Control type (e.g. Label) and _COMPONENT-SPECIFIC_PARAMETERS_ are the parameters that are specific for that type (e.g. Label has const std::wstring &content parameter).

If you use the first method, pass the Control type as literal std::wstring (as second parameter), e.g.:

guiManager->createComponent(L"myLabel", L"Label", myCSSPosition, L"Sample content", myStyle, myPanel);

It's up to you which of those methods will you use.

TODO

  • ID - use Identifiable.

GUI_Control_"> Accessing the GUI Control

Of course, you can assign the pointer (returned by createComponent/create_X_ method of GUIManager) to an variable and use it from that point. But you don't have such option when you are loading the GUI from HTML/CSS.

Fortunately, you can always get an Control of any type based on it's ID (and by definition, ID is guaranteed to be unique):

_X_ * GUIManager::get_X_(std::wstring ID);

Where _X_ is the GUI Control type.

GUI_Control_"> Destroying GUI Control

To destroy the Control use one of those two methods:

void GUIManager::destroyControl(GUI Control * component);
void GUIManager::destroyCoontrol(std::wstring ID);

Both of them will generate an error if the GUI Control could not been destroyed (e.g. it does not exists).

IDs_"> Working with IDs

When you decide to use the versions of methods that use ID, take in account that they are a bit slower. It's because GUIManager has to perform additional search among its components.

If you know that you will be using some GUI Control a lot, consider calling _X_ * GUIManager::get_X_(...) once to get and store the pointer in the variable. Then you can operate on that saved pointer instead of calling _X_ * GUIManager::get_X_(...) again and again.

TODO

  • Update the craete methods - they've changed.