IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
GUImanager Class Reference

The GUI manager is a GUIentity with enhanced functionality to embedd a GUI in an orbiter vessel. More...

Inheritance diagram for GUImanager:
GUIentity

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_BaseElementGetElementById (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_PageCreatePage (RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_DEFAULT, bool drawbackground=false)
 Creates a new GUI_Page element. More...
 
GUI_LabelCreateLabel (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_ListBoxCreateListBox (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_StaticButtonCreateStaticButton (RECT _rect, int srcX, int srcY, SURFHANDLE _src, int parent, int _id=-1)
 Creates a new GUI_StaticButton. More...
 
GUI_DynamicButtonCreateDynamicButton (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_BUTTON)
 Creates a new GUI_DynamicButton. More...
 
GUI_CheckBoxCreateCheckBox (string text, RECT _rect, int parent, int _id=-1, GUI_STYLE styleId=STYLE_CHECKBOX)
 Creates a new GUI_CheckBox. More...
 
GUI_RadioButtonCreateRadioButton (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_ElementStyleGetStyle (GUI_STYLE _styleId=STYLE_DEFAULT)
 
GUI_fontGetFont (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_SurfaceGetSurfaceById (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.
 
FontsAndStylesfontsandstyles
 Pointer to the global FontsAndStyles instance.
 
string styleset = "default"
 Identifier of the defualt styleset of this entity.
 

Detailed Description

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.

Constructor & Destructor Documentation

GUImanager::GUImanager ( IMS2 *  _vessel)
Parameters
_vesselThe vessel containing this GUImanager

Member Function Documentation

bool GUImanager::AddChildToParent ( GUI_BaseElement child,
int  parentId 
)
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

Parameters
childThe element to be added
parentIdThe localy unique identifier of the parent
Returns
True if successful, false if the parent could not be located.

Implements GUIentity.

void GUImanager::Alert ( string  text,
GUI_BaseElement parent,
RECT  rect = _R(0,0,0,0),
GUI_STYLE  styleid = STYLE_ERROR_ALERT 
)
static

Pops up an alert with an ok prompt in the designated parent element.

Parameters
textThe text to be displayed in the alert
parentThe element the alert should appear in
rectDrawing rectangle relative to the parent. pass 0,0,0,0 to let the function choose a sensible size depending on parent and text
styleidIdentifier for the style the alert should be drawn in, if different than normal
bool GUImanager::CheckSynchronisedInterval ( int  interval_in_miliseconds)
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.

Parameters
interval_in_milisecondsThe interval you wish to check
Returns
True if the interval_in_miliseconds has passed, relative to the synchronised clock.
void GUImanager::ClearPopup ( GUIpopup popup = NULL)
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 ( )
Returns
The id of the currently active orbiter panel (the panel active in the cockpit of the vessel)
GUI_BaseElement * GUImanager::GetElementById ( int  _id)
virtual

Looks for a GUI_Element with the passed id.

Parameters
_idThe locally unique identifier of the GUI_BaseElement you are looking for
Returns
A Pointer to the GUI-element with a matching id, or NULL if no match was found.

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.

Parameters
_eventan Identifier for the GUI_event to generate (Not to be confused with the other kind of events!)
GUI_Surface * GUImanager::GetSurfaceById ( int  _id)
private
Parameters
_idThe localy unique identifier of the GUI_surface you want to retrieve
Returns
A pointer to the requested GUIsurface
void GUImanager::RedrawGUISurface ( int  surfId)

triggers a redraw of the panel area associated with a GUIsurface

Parameters
surfIdthe 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!

Parameters
surfThe GUI_Surface to be registered
_ida unique identifer for the surface that will also serve to identify the panel area in orbiter
surfacePosThe absolute position this surface (and the panel area) will occupy on the panel
See also
RegisterSurfaceWithOrbiter()
void GUImanager::registerPreStep ( )
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.

Parameters
surfThe GUI_Surface object to register
hpanelPANELHANDLE to the orbiter panel this surface should be a part of
tgtThe 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.

Parameters
_curPanelIdThe id of the now active panel
Note
Do not try to use this to switch the panel! This function is purely reactionary, taking note that the panel in Orbiter has ALREADY been switched!
bool GUImanager::SurfaceIsRegistered ( int  _id)
private

Checks if a GUI_surface is registered with Orbiter.

Parameters
_idThe localy unique identifier of the GUI_Surface you want to know about
Returns
True if the GUI_surface with the passed id is already registered, false if it isn't, or could not be located
bool GUImanager::Update ( )
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

Returns
True if any o the elments in this entity have requested a redraw, false otherwise

Implements GUIentity.


The documentation for this class was generated from the following files: