IMS2
Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
|
The GUI manager is a GUIentity with enhanced functionality to embedd a GUI in an orbiter vessel. More...
Public Member Functions | |
GUImanager (IMS2 *_vessel) | |
void | RegisterGUISurface (GUI_Surface *surf, int _id, RECT surfacePos) |
Registers a GUI_Surface with the GUI manager, BUT NOT YET WITH ORBITER! More... | |
void | RegisterSurfaceWithOrbiter (GUI_Surface *surf, PANELHANDLE hpanel, SURFHANDLE tgt) |
This function has to be called from clbkLoadPanel2d to register the GUI_Surface to the orbiter SURFHANDLE. More... | |
int | GetCurPanelId () |
void | SetCurPanelId (int _curPanelId) |
Notifies the GUImanager that the currently visible panel has changed. More... | |
void | RedrawCurrentPanel () |
Triggers a redraw of the whole currently active panel. | |
void | RedrawGUISurface (int surfId) |
triggers a redraw of the panel area associated with a GUIsurface More... | |
GUI_MOUSE_EVENT | GetEvent (int _event) |
generates events for the GUI based on events it receives from orbiter. More... | |
GUI_BaseElement * | GetElementById (int _id) |
Looks for a GUI_Element with the passed id. More... | |
bool | Update () |
checks if any children had an update NOT triggered by user input. More... | |
Public Member Functions inherited from GUIentity | |
void | RegisterGuiElement (GUI_BaseElement *_element, int _parentId) |
Registers a GUI element that has not been created by this GUIentity. More... | |
int | GetDynamicUID () |
GUI_Page * | CreatePage (RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_DEFAULT, bool drawbackground=false) |
Creates a new GUI_Page element. More... | |
GUI_Label * | CreateLabel (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_HEADING) |
Creates a new GUI_Label element. More... | |
GUI_LabelValuePair * | CreateLabelValuePair (string label, string value, RECT _rect, int parent, int id=-1, GUI_STYLE styleId=STYLE_HEADING, GUI_FONT valueFontId=GUI_NO_FONT) |
Creates a new GUI_LabelValuePair. More... | |
GUI_ListBox * | CreateListBox (RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_LISTBOX, GUI_STYLE scrollbar_styleId=STYLE_LISTBOX, bool _multiselect=false, bool _noSelect=false) |
Creates a new GUI_ListBox. More... | |
GUI_StaticButton * | CreateStaticButton (RECT _rect, int srcX, int srcY, SURFHANDLE _src, int parent, int _id=-1) |
Creates a new GUI_StaticButton. More... | |
GUI_DynamicButton * | CreateDynamicButton (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_BUTTON) |
Creates a new GUI_DynamicButton. More... | |
GUI_CheckBox * | CreateCheckBox (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_CHECKBOX) |
Creates a new GUI_CheckBox. More... | |
GUI_RadioButton * | CreateRadioButton (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_CHECKBOX) |
Creates a new GUI_RadioButton. More... | |
GUI_StatusBar * | CreateStatusBar (RECT _rect, int parent, int _id=-1, GUI_STYLE styleid=STYLE_STATUSBAR) |
void | SetStyleSet (string _styleset) |
Sets the styleset this GUIentity uses. More... | |
GUI_ElementStyle * | GetStyle (GUI_STYLE _styleId=STYLE_DEFAULT) |
GUI_font * | GetFont (GUI_FONT _fontid) |
Static Public Member Functions | |
static bool | CheckSynchronisedInterval (int interval_in_miliseconds) |
checks whether a certain interval of time has been filled, using a synchronised clock for the whole simulation. More... | |
static void | Alert (string text, GUI_BaseElement *parent, RECT rect=_R(0, 0, 0, 0), GUI_STYLE styleid=STYLE_ERROR_ALERT) |
Pops up an alert with an ok prompt in the designated parent element. More... | |
static void | ListDialog (string title, vector< string > &items, GUI_BaseElement *parent, bool(*callback)(int, void *), void *usrdata=NULL, RECT rect=_R(0, 0, 0, 0)) |
static void | ClearPopup (GUIpopup *popup=NULL) |
Clear a temporary plugin (Popup-dialogue). More... | |
Private Member Functions | |
bool | AddChildToParent (GUI_BaseElement *child, int parentId) |
Adds an element to the child list of another element. More... | |
bool | SurfaceIsRegistered (int _id) |
Checks if a GUI_surface is registered with Orbiter. More... | |
GUI_Surface * | GetSurfaceById (int _id) |
Static Private Member Functions | |
static void | registerPreStep () |
registeres GUImanagers that have completed their prestep operations More... | |
Private Attributes | |
IMS2 * | vessel |
The vessel containing this GUImanager. | |
vector< GUI_Surface * > | surfaces |
stores pointers to all GUIsurfaces | |
int | curPanelId |
Stores the id of currently active panel. | |
GUI_MOUSE_EVENT | curEvent |
The event currently being propagated through the children of this GUImanager. | |
Static Private Attributes | |
static unsigned long | lastclock = 0 |
Remembers the time of the last frame. | |
static UINT | managerinstances = 0 |
Keeps track of how many managerinstances are alive. | |
static map< GUIplugin *, GUI_BaseElement * > | temporaryplugins |
Stores temporary GUI plugins (popups) and their parents during their lifetime. | |
Additional Inherited Members | |
Protected Attributes inherited from GUIentity | |
map< int, GUI_BaseElement * > | elements |
a searchtree containing all GUI_Elements of this entity | |
UINT | newuid = GUI_UID_DOMAIN |
Variable used to pass out dynamic UIDs for GUI elements. | |
FontsAndStyles * | fontsandstyles |
Pointer to the global FontsAndStyles instance. | |
string | styleset = "default" |
Identifier of the defualt styleset of this entity. | |
The GUI manager is a GUIentity with enhanced functionality to embedd a GUI in an orbiter vessel.
Every vessel using the GUI does so by carrying an instance of GUImanager. The GUImanager provides functionality to register a GUIsurface with an Orbiter Panel Area, making it capable of sending mouse events from orbiter to its children, and triggering panel redraws if necessary.
GUImanager::GUImanager | ( | IMS2 * | _vessel | ) |
_vessel | The vessel containing this GUImanager |
|
privatevirtual |
Adds an element to the child list of another element.
Contrary to the base call in GUIentity, the GUImanager needs to discriminate if a UID belongs to a GUI_BaseElement or a GUI_Surface
child | The element to be added |
parentId | The localy unique identifier of the parent |
Implements GUIentity.
|
static |
Pops up an alert with an ok prompt in the designated parent element.
text | The text to be displayed in the alert |
parent | The element the alert should appear in |
rect | Drawing rectangle relative to the parent. pass 0,0,0,0 to let the function choose a sensible size depending on parent and text |
styleid | Identifier for the style the alert should be drawn in, if different than normal |
|
static |
checks whether a certain interval of time has been filled, using a synchronised clock for the whole simulation.
Panel redraws are expensive. As such, it makes sense that elements in the panel that update at the same interval update at the same time. For example, two elements that update every second should do so in the same frame, not half a second appart from each other, because it saves resources. Check your intervals with this function to facilitate that synchronicity.
interval_in_miliseconds | The interval you wish to check |
|
static |
Clear a temporary plugin (Popup-dialogue).
Do not call by yourself! The alert will call this function by itself when it is closed! this will register the alert for deletion. The function is also called from GUImanager::prestep() with a NULL argument. If an alert has been registered for cleanup during the last frame, it will be deleted at this call.
int GUImanager::GetCurPanelId | ( | ) |
|
virtual |
Looks for a GUI_Element with the passed id.
_id | The locally unique identifier of the GUI_BaseElement you are looking for |
Reimplemented from GUIentity.
GUI_MOUSE_EVENT GUImanager::GetEvent | ( | int | _event | ) |
generates events for the GUI based on events it receives from orbiter.
this is necessary because orbiter frequently misses the MouseDown event, immediately generating a MousePressed event instead.
_event | an Identifier for the GUI_event to generate (Not to be confused with the other kind of events!) |
|
private |
_id | The localy unique identifier of the GUI_surface you want to retrieve |
void GUImanager::RedrawGUISurface | ( | int | surfId | ) |
triggers a redraw of the panel area associated with a GUIsurface
surfId | the uid of the GUIsurface to be redrawn |
void GUImanager::RegisterGUISurface | ( | GUI_Surface * | surf, |
int | _id, | ||
RECT | surfacePos | ||
) |
Registers a GUI_Surface with the GUI manager, BUT NOT YET WITH ORBITER!
the reason for this is that at the time of creation, the orbiter 2dpanel does not yet exist. Use RegisterSurfaceWithOrbiter() to register a GUI_Surface with an orbiter panel area as soon as the panel gets created!
surf | The GUI_Surface to be registered |
_id | a unique identifer for the surface that will also serve to identify the panel area in orbiter |
surfacePos | The absolute position this surface (and the panel area) will occupy on the panel |
|
staticprivate |
registeres GUImanagers that have completed their prestep operations
Should be called by every manager AFTER they complete processing the prestep operations. When all managers have called in, the frame is complete and the gui-clock is updated to the new sim-time.
void GUImanager::RegisterSurfaceWithOrbiter | ( | GUI_Surface * | surf, |
PANELHANDLE | hpanel, | ||
SURFHANDLE | tgt | ||
) |
This function has to be called from clbkLoadPanel2d to register the GUI_Surface to the orbiter SURFHANDLE.
surf | The GUI_Surface object to register |
hpanel | PANELHANDLE to the orbiter panel this surface should be a part of |
tgt | The SURFHANDLE from which this surface will receive input and redraw events |
void GUImanager::SetCurPanelId | ( | int | _curPanelId | ) |
Notifies the GUImanager that the currently visible panel has changed.
_curPanelId | The id of the now active panel |
|
private |
Checks if a GUI_surface is registered with Orbiter.
_id | The localy unique identifier of the GUI_Surface you want to know about |
|
virtual |
checks if any children had an update NOT triggered by user input.
redraws the panel area if one did. should be called every frame. Exact behavior depends on Implementation
Implements GUIentity.