#include <Window.h>
Inheritance diagram for OglGui::Window:
Public Member Functions | |
Window (int x, int y, int width, int height, bool is2d=true) | |
create a top level window | |
Window (Window *parent, int width, int height, bool is2d=true) | |
create a child window | |
Window (Window *parent, int x, int y, int width, int height, bool is2d=true) | |
create a child window | |
Window (OGLWND *oglWnd, bool is2d=true) | |
Window (OGLWND *oglWnd, int width, int height, bool is2d=true) | |
Window (OGLWND *parent, int x, int y, int width, int height, bool is2d=true) | |
virtual | ~Window () |
Window * | GetParent () const |
void | OffsetXY (Window *someParent, int &x, int &y) |
bool | Is2d () const |
void | SetIs2d (bool flag) |
void | RemoveViewports () const |
virtual void | RepositionViewers () |
virtual void | RepositionViewports () |
void | SetReposChildren (bool mode, bool recursive) |
void | ScaleChildren (int mode=0, bool recursive=0) |
void | SetWindowListener (WindowListener *listener, void *listenerData=0) |
add behaviour | |
void | SetWindowListener (WindowListener *listener, int listenerData) |
WindowListener * | GetWindowListener (void *&userData) |
void | SetDisableOGLViewKeys (bool flag) |
bool | GetDisableOGLViewKeys () const |
void | SetDisableOGLViewMouse (bool flag) |
bool | GetDisableOGLViewMouse () const |
void | SetDisableGlobalKeyListener (bool flag) |
bool | GetDisableGlobalKeyListener () const |
void | SetAllowReposition (bool mode=true) |
bool | GetAllowReposition () const |
void | SetAllowScaling (bool mode) |
bool | GetAllowScaling () const |
void | SetAllowChildScaling (bool mode) |
bool | GetAllowChildScaling () const |
void | SetForeground (ULONG col) |
ULONG | GetForeground () const |
virtual int | SetState (int nState) |
int | GetState () const |
void | SetDoStateFeedback (bool on) |
void | SetStateFeedbackColor (ULONG col) |
bool | GetDoStateFeedback () const |
void | SetExternWindowReference (Window *refWnd) |
Window * | GetExternWindowReference () const |
void | SetWindowText (char *txt) |
virtual void | MapKeysTo (Window *wnd) |
void | GuiGeneralName (std::string name) |
std::string | GuiGeneralName () |
void | GuiName (std::string name) |
std::string | GuiName () |
virtual void | InitFunc () |
virtual void | InitDisplayFunc () |
virtual void | DisplayFunc () |
virtual void | MouseFunc (int msg, int but, int state, int x, int y) |
This function is called by the event handling system everytime the user has moved or clicked the mouse. | |
virtual void | KeyboardFunc (int c, int state) |
virtual void | ViewportFunc (int width, int height) |
virtual void | ReshapeFunc (int width, int height) |
Static Public Member Functions | |
static Window * | CastToWindow (OglWindow *oWnd) |
static void | SetGlobalKeyListener (KeyListener *listener) |
static void | GlobalKeyListeningDisabled (bool flag) |
static bool | GlobalKeyListeningDisabled () |
Protected Member Functions | |
virtual void | WindowAdded (Window *wnd) |
Protected Attributes | |
bool | mDoStateFeedback |
ULONG | mStateFeedbackColor |
ULONG | mForeGroundColor |
Window * | mMapKeysTarget |
bool | mIs2d |
bool | mAllowReposition |
bool | mAllowScaling |
bool | mAllowChildScaling |
std::string | mGuiName |
std::string | mGuiGeneralName |
Static Protected Attributes | |
static std::string | mClipboardString |
Private Member Functions | |
void | Init (bool is2d) |
Private Attributes | |
bool | mDisableGlobalKeyListener |
Window * | mExternWindowReference |
WindowListener * | mWindowListener |
void * | mListenerData |
int | mState |
ULONG | mOldBorderBackground |
CxRectZTiler | mViewportTiler |
bool | mDisableOGLViewKeys |
bool | mDisableOGLViewMouse |
Static Private Attributes | |
static KeyListener * | sGlobalKeyListener |
static bool | sGlobalKeyListeningDisabled |
This class encapsulates an OGLWND of the OGL library (you don't need to know the details of OGLWND but if you want to, see the OGL documentation) The class is tremendously similar to OglGui::OglWindow, in fact they may be merged in the near future to this class. Another class that is very similar is Visualisation::Window. That class implements some functionality for automatic creation of Views. A OglGui::View is used to display images.
There are 2 uses for this class: 1. a window in the operating system. 2. a subdivision of a type 1 window. What kind of window an instance of this class is is defined by the constructor by which it was ceated.
In the OglGui system there are roughly 3kinds of objects: 1. windows (all controls are windows: buttons, scrollbars, textboxes, etc...) 2. views; which only exists within a window 3. helper classes; which help windows and classes function ('listeners' for example) are derived wrom windows. Images are shown in Views.
To get started one first creates a top level window by calling the first constructor: OglWindow(int x, int y, int width, int height, bool is2d=true). After that one can add widgets/child wondows with their constructors. When all gui components are added to the window, Window::Start() should be called to initialise it. When Window::Start() returns the window is displayed on the screen but doesn't react to events (such as redraw) yet. To get a window to react to mouse or to redraw one has to call OglGui::Sys::WindowManage() (which returns true when the window is closed) By default a window does not detect whether it should redraw, that's why we tell window to always redraw (here always means every time OglGui::Sys::WindowManage() is called).
This sample code should get the job done:
OglGui::Window* wnd = new OglGui::Window(20, 20, 800, 800); // window 800 pixels wide and high wnd->SetBackground(0xcccccc); // gray background wnd->GetOGLWND()->alwaysDraw = 1; // force redraw new OglGui::Button(wnd, 80, 16, "simple button"); wnd->Start(); // initialisation while(1) { if(OglGui::Sys::Instance().WindowManage()) // handle events break; // window is closed Sleep(50); // give the cpu a break will ya! }
Please note that the documentation of OglGui describes another way to handle the events. There OglEventLoop() is called, which basically loops and calls WindowManage() itself. Which one to use is depends on how one wnats to control the application. With the method proposed here the programmer has more control which can be nice for programs that do a lot of computation because the application doesn't have to wait for an action of the user before it can do something.
Definition at line 93 of file Window.h.