Contents User Forum Source Index APIs by Task APIs by Level Data


G3D::GuiWindow Class Reference

Retained-mode graphical user interface window. More...

#include <GuiWindow.h>

Inherits G3D::Widget.

Inherited by G3D::CameraControlWindow, and G3D::DeveloperWindow.

List of all members.

Public Types

enum  CloseAction { NO_CLOSE, IGNORE_CLOSE, HIDE_ON_CLOSE, REMOVE_ON_CLOSE }
typedef ReferenceCountedPointer<
GuiWindow
Ref
enum  Style { NORMAL_FRAME_STYLE, TOOL_FRAME_STYLE, DIALOG_FRAME_STYLE, NO_FRAME_STYLE }

Public Member Functions

virtual GuiDraweraddDrawer (const GuiCaption &caption="", GuiDrawer::Side side=GuiDrawer::RIGHT_SIDE)
const Rect2DclientRect () const
virtual void fireEvent (const GEvent &event)
bool focused () const
bool morphing () const
void morphTo (const Rect2D &r)
void moveToCenter ()
virtual bool onEvent (const GEvent &event)
virtual void onLogic ()
virtual void onNetwork ()
virtual void onPose (Array< PosedModel::Ref > &posedArray, Array< PosedModel2DRef > &posed2DArray)=0
virtual void onPose (Array< PosedModelRef > &posedArray, Array< PosedModel2DRef > &posed2DArray)
virtual void onSimulation (RealTime rdt, SimTime sdt, SimTime idt)
virtual void onUserInput (UserInput *ui)
void pack ()
GuiPanepane ()
const Rect2Drect () const
void ReferenceCountedObject_zeroWeakPointers ()
virtual void setManager (WidgetManager *m)
virtual void setRect (const Rect2D &r)
void setVisible (bool v)
void showModal (GuiWindow::Ref parent)
void showModal (GWindow *osWindow)
GuiSkinRef skin () const
bool visible () const
virtual GWindowwindow () const
 ~GuiWindow ()

Static Public Member Functions

static Ref create (const GuiCaption &windowTitle, const GuiSkinRef &skin, const Rect2D &rect=Rect2D::xywh(100, 100, 100, 50), Style style=NORMAL_FRAME_STYLE, CloseAction=NO_CLOSE)

Public Attributes

AtomicInt32 ReferenceCountedObject_refCount
_WeakPtrLinkedListReferenceCountedObject_weakPointer

Protected Member Functions

 GuiWindow (const GuiCaption &text, GuiSkinRef skin, const Rect2D &rect, Style style, CloseAction closeAction)

Protected Attributes

WidgetManagerm_manager

Friends

class _GuiSliderBase
class GuiButton
class GuiControl
class GuiDropDownList
class GuiPane
class GuiRadioButton
class GuiTextBox

Classes

class  ControlButton
class  Modal
 State for managing modal dialogs.
class  Posed
 Used for rendering the UI.


Detailed Description

Retained-mode graphical user interface window.

G3D Guis (Graphical User Interfaces) are "skinnable", meaning that the appearance is controled by data files. G3D provides already made skins in the data/gui directory of the installation. See GuiSkin for information on how to draw your own.

The Gui API connects existing variables and methods directly to controls. Except for GuiButton, you don't have to write event handlers like in other APIs. Just pass a pointer to the variable that you want to receive the value of the control when the control is created. An example of creating a dialog is shown below:

        GuiSkinRef skin = GuiSkin::fromFile(dataDir + "gui/osx.skn", app->debugFont);
        GuiWindow::Ref window = GuiWindow::create("Person", skin);

        GuiPane* pane = window->pane();
        pane->addCheckBox("Likes cats", &player.likesCats);
        pane->addCheckBox("Is my friend", &player, &Person::getIsMyFriend, &Person::setIsMyFriend);
        pane->addRadioButton("Male", Person::MALE, &player.gender);
        pane->addRadioButton("Female", Person::FEMALE, &player.gender);
        player.height = 1.5;
        pane->addSlider("Height", &player.height, 1.0f, 2.2f);
        GuiButton* invite = pane->addButton("Invite");

        addWidget(window);
   

Note that in the example, one check-box is connected to a field of "player" and another to methods to get and set a value. To process the button click, extend the GApp (or another Widget's) GApp::onEvent method as follows:

   bool App::onEvent(const GEvent& e) {
       if (e.type == GEventType::GUI_ACTION) {
           if (e.gui.control == invite) {
               ... handle the invite action here ...
               return true;
           }
       }
       return false;
   }
   

It is not necessary to subclass GuiWindow to create a user interface. Just instantiate GuiWindow and add controls to its pane. If you do choose to subclass GuiWindow, be sure to call the superclass methods for those that you override.


Member Typedef Documentation


Member Enumeration Documentation

Controls the behavior when the close button is pressed (if there is one).

NO_CLOSE - Do not show the close button IGNORE_CLOSE - Fire G3D::GEvent::GUI_CLOSE event but take no further action HIDE_ON_CLOSE - Set the window visibility to false and fire G3D::GEvent::GUI_CLOSE REMOVE_ON_CLOSE - Remove this GuiWindow from its containing WidgetManager and fire G3D::GEvent::GUI_CLOSE with a NULL window argument (since the window may be garbage collected before the event is received).

Enumerator:
NO_CLOSE 
IGNORE_CLOSE 
HIDE_ON_CLOSE 
REMOVE_ON_CLOSE 

Controls the appearance of the window's borders and background.

NORMAL_FRAME_STYLE - regular border and title TOOL_FRAME_STYLE - small title, thin border DIALOG_FRAME_STYLE - thicker border NO_FRAME_STYLE - do not render any background at all

Enumerator:
NORMAL_FRAME_STYLE 
TOOL_FRAME_STYLE 
DIALOG_FRAME_STYLE 
NO_FRAME_STYLE 


Constructor & Destructor Documentation

G3D::GuiWindow::GuiWindow ( const GuiCaption text,
GuiSkinRef  skin,
const Rect2D rect,
Style  style,
CloseAction  closeAction 
) [protected]

G3D::GuiWindow::~GuiWindow (  ) 


Member Function Documentation

virtual GuiDrawer* G3D::GuiWindow::addDrawer ( const GuiCaption caption = "",
GuiDrawer::Side  side = GuiDrawer::RIGHT_SIDE 
) [inline, virtual]

Drawers are like windows that slide out of the side of another GuiWindow.

Drawers are initially sized based on the side of the window that they slide out of, but they can be explicitly sized. Multiple drawers can be attached to the same side, however it is up to the caller to ensure that they do not overlap.

Parameters:
side Side that the drawer sticks out of

const Rect2D& G3D::GuiWindow::clientRect (  )  const [inline]

Interior bounds of the window, absolute on the GWindow.

static Ref G3D::GuiWindow::create ( const GuiCaption windowTitle,
const GuiSkinRef skin,
const Rect2D rect = Rect2D::xywh(100, 100, 100, 50),
Style  style = NORMAL_FRAME_STYLE,
CloseAction  = NO_CLOSE 
) [static]

As controls are added, the window will automatically grow to contain them as needed.

virtual void G3D::Widget::fireEvent ( const GEvent event  )  [virtual, inherited]

Fire an event on the containing window.

Reimplemented in G3D::WidgetManager.

bool G3D::GuiWindow::focused (  )  const [inline]

Is this window in focus on the WidgetManager?

bool G3D::GuiWindow::morphing (  )  const [inline]

Returns true while a morph is in progress.

void G3D::GuiWindow::morphTo ( const Rect2D r  ) 

Causes the window to change shape and/or position to meet the specified location.

The window will not respond to drag events while it is morphing.

void G3D::GuiWindow::moveToCenter (  ) 

Move to the center of the screen.

virtual bool G3D::GuiWindow::onEvent ( const GEvent event  )  [virtual]

Returning true consumes the event and prevents other GModules from seeing it.

Motion events (GEventType::MOUSEMOTION, GEventType::JOYHATMOTION, JGEventType::OYBALLMOTION, and GEventType::JOYAXISMOTION) cannot be cancelled.

Implements G3D::Widget.

Reimplemented in G3D::CameraControlWindow, and G3D::DeveloperWindow.

virtual void G3D::GuiWindow::onLogic (  )  [inline, virtual]

Implements G3D::Widget.

virtual void G3D::GuiWindow::onNetwork (  )  [inline, virtual]

Implements G3D::Widget.

virtual void G3D::Widget::onPose ( Array< PosedModel::Ref > &  posedArray,
Array< PosedModel2DRef > &  posed2DArray 
) [pure virtual, inherited]

Appends a posed model for this object to the array, if it has a graphic representation.

The posed model appended is allowed to reference the agent and is allowed to mutate if the agent is mutated.

Implemented in G3D::FirstPersonManipulator, G3D::GConsole, G3D::ThirdPersonManipulator, and G3D::WidgetManager.

virtual void G3D::GuiWindow::onPose ( Array< PosedModelRef > &  posedArray,
Array< PosedModel2DRef > &  posed2DArray 
) [virtual]

virtual void G3D::GuiWindow::onSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
) [inline, virtual]

Implements G3D::Widget.

virtual void G3D::GuiWindow::onUserInput ( UserInput ui  )  [virtual]

Implements G3D::Widget.

Reimplemented in G3D::CameraControlWindow.

void G3D::GuiWindow::pack (  ) 

Resize the pane so that all of its controls are visible and so that there is no wasted space, then resize the window around the pane.

See also:
G3D::GuiPane::pack

GuiPane* G3D::GuiWindow::pane (  )  [inline]

const Rect2D& G3D::GuiWindow::rect (  )  const [inline]

Window bounds, including shadow and glow, absolute on the GWindow.

void G3D::ReferenceCountedObject::ReferenceCountedObject_zeroWeakPointers (  )  [inline, inherited]

Automatically called immediately before the object is deleted.

This is not called from the destructor because it needs to be invoked before the subclass destructor.

virtual void G3D::Widget::setManager ( WidgetManager m  )  [inline, virtual, inherited]

Called by the WidgetManager when this module is added to it.

The argument may be NULL

Reimplemented in G3D::DeveloperWindow.

virtual void G3D::GuiWindow::setRect ( const Rect2D r  )  [virtual]

Set the border bounds relative to the GWindow.

The window may render outside the bounds because of drop shadows and glows.

Reimplemented in G3D::CameraControlWindow.

void G3D::GuiWindow::setVisible ( bool  v  )  [inline]

Hide this entire window.

The window cannot have focus if it is not visible.

Removing the GuiWindow from the WidgetManager is more efficient than making it invisible.

void G3D::GuiWindow::showModal ( GuiWindow::Ref  parent  ) 

void G3D::GuiWindow::showModal ( GWindow osWindow  ) 

Blocks until the dialog is closed (visible = false).

Do not call between RenderDevice::beginFrame and RenderDevice::endFrame.

GuiSkinRef G3D::GuiWindow::skin (  )  const [inline]

bool G3D::GuiWindow::visible (  )  const [inline]

virtual GWindow* G3D::Widget::window (  )  const [virtual, inherited]

Returns the operating system window that is currently rendering this Widget.

Reimplemented in G3D::WidgetManager.


Friends And Related Function Documentation

friend class _GuiSliderBase [friend]

friend class GuiButton [friend]

friend class GuiControl [friend]

friend class GuiDropDownList [friend]

friend class GuiPane [friend]

friend class GuiRadioButton [friend]

friend class GuiTextBox [friend]


Member Data Documentation

WidgetManager* G3D::Widget::m_manager [protected, inherited]

The manager, set by setManager().

This cannot be a reference counted pointer because that would create a cycle between the Widget and its manager.

The long name is to keep this from accidentally conflicting with a subclass's variable name.

Do not use or explicitly manipulate this value--its type may change in the future and is not part of the supported API.

Linked list of all weak pointers that reference this (some may be on the stack!).

Do not use or explicitly manipulate this value.


The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:46 2007 for G3D by doxygen 1.5.2
Hosted by SourceForge.net Logo