Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Class Members

Wnd Class Reference
[Windowing]

#include <lvt/Wnd.h>

List of all members.


Detailed Description

A toplevel window.

To handle window messages, derive an object from Wnd, and override the appropriate On*() member function.

Create() must be called before any other member functions or drawing commands are issued.


Public Member Functions

void AdjustCamera (Camera *cam)
 Adjusts the aspect ratio of cam to match that of the window.
bool Create (const std::string &title, PixelFormat pixelFormat=PF_DEFAULT, WindowStyle style=STYLE_NORMAL)
 Creates a new window.
void Destroy ()
 Destroys the window.
int GetHeight () const
 Returns the height of the window, in screen coordinates.
Menu GetMenu () const
 Returns the window's current menu.
int GetWidth () const
 Returns the width of the window, in screen coordinates.
bool IsCreated () const
 Returns true if the window has been created.
bool IsVisible () const
 Returns true if the window is currently visible.
MessageBoxResult MessageBox (const std::string &msg, const std::string &title, MessageBoxButtons buttons=MBB_OK)
 Displays a message box.
MessageBoxResult MessageBox (const std::string &msg, MessageBoxButtons buttons=MBB_OK)
 Displays a message box.
void Redraw ()
 Redraws the window.
void SetInputHandler (InputHandler *handler)
 Sets the window's current input handler.
bool SetMenu (const Menu &menu)
 Sets the window's current menu.
void SetPosition (int x, int y)
 Sets the position of the window, in screen coordinates.
void SetSize (int width, int height)
 Sets the size of the window, in screen coordinates.
bool Show (WindowState showCmd=STATE_NORMAL)
 Shows the window with the given WindowState.
void ShowScene (Node *newScene)
 Causes the window to display a scenegraph when it is painted.

Protected Member Functions

Message Handlers
Override these member functions in your Wnd-derived class to handle window messages.

virtual bool OnCreate ()
 The window is being created.
virtual void OnDestroy ()
 The window has been destroyed.
virtual void OnLButtonDblClk (int x, int y)
 The left mouse button has been double-clicked.
virtual void OnLButtonDown (int x, int y)
 The left mouse button has been pressed.
virtual void OnLButtonUp (int x, int y)
 The left mouse button has been released.
virtual void OnMButtonDblClk (int x, int y)
 The middle mouse button has been double-clicked.
virtual void OnMButtonDown (int x, int y)
 The middle mouse button has been pressed.
virtual void OnMButtonUp (int x, int y)
 The middle mouse button has been released.
virtual void OnMenuCommand (int id)
 The user has activated a menu item.
virtual void OnMouseMove (int x, int y)
 The mouse has been moved.
virtual void OnMouseWheel (int x, int y, int zDelta)
 The mouse wheel has been moved.
virtual void OnMove (int x, int y)
 The window has been moved.
virtual void OnPaint ()
 The window needs to be repainted.
virtual void OnRButtonDblClk (int x, int y)
 The right mouse button has been double-clicked.
virtual void OnRButtonDown (int x, int y)
 The right mouse button has been pressed.
virtual void OnRButtonUp (int x, int y)
 The right mouse button has been released.
virtual void OnSize (WindowState state, int width, int height)
 The window has been resized.


Member Function Documentation

void AdjustCamera Camera cam  ) 
 

Adjusts the aspect ratio of cam to match that of the window.

When a window is resized, its aspect ratio might not match the aspect ratio of any cameras in the window's scenegraph, causing distortion when the scene is rendered. AdjustCamera will change the aspect ratio of cam to match the window's whenever the window is resized.

The Wnd object creates a list internally of all the cameras attached to it via AdjustCamera and increments their reference count when added.

bool Create const std::string &  title,
PixelFormat  pixelFormat = PF_DEFAULT,
WindowStyle  style = STYLE_NORMAL
 

Creates a new window.

Parameters:
title The window's title
pixelFormat the PixelFormat of the new window
style the WindowStyle of the new window
Creates a new window and initializes OpenGL for that window. Create() must be the first function called on a Wnd object. Any other method will fail if Create() has not yet been called.

Returns:
true if creation was successful, false otherwise.

void Destroy  ) 
 

Destroys the window.

Signals the operating/windowing system that the window should be destroyed. Causes the OnDestroy() member function to be called.

int GetHeight  )  const
 

Returns the height of the window, in screen coordinates.

Menu GetMenu  )  const [inline]
 

Returns the window's current menu.

The Menu object returned by GetMenu is a copy of the window's current menu. Modifications to the menu will not take effect unless SetMenu() is called.

int GetWidth  )  const
 

Returns the width of the window, in screen coordinates.

bool IsCreated  )  const
 

Returns true if the window has been created.

bool IsVisible  )  const
 

Returns true if the window is currently visible.

MessageBoxResult MessageBox const std::string &  msg,
const std::string &  title,
MessageBoxButtons  buttons = MBB_OK
 

Displays a message box.

Parameters:
msg Message to display
title Message box title
buttons a MessageBoxButtons value describing the buttons in the message box

MessageBoxResult MessageBox const std::string &  msg,
MessageBoxButtons  buttons = MBB_OK
 

Displays a message box.

Parameters:
msg Message to display
buttons a MessageBoxButtons value describing the buttons in the message box

virtual bool OnCreate  )  [protected, virtual]
 

The window is being created.

Use this function to do any additional setup and initialization for your window class, such as adding menus, or initializing resources. The OpenGL context is created and active when this method is called, so drawing operations are permitted.

Return true from this function to allow creation of the window to proceed. Return false to prevent window creation, and to cause the Create() method to fail.

The default implementation does nothing and returns true.

virtual void OnDestroy  )  [protected, virtual]
 

The window has been destroyed.

This method is called after the operating system has destroyed the window. It is acceptable for a Wnd to commit suicide (delete this;) in the OnDestroy method.

The default implementation does nothing.

virtual void OnLButtonDblClk int  x,
int  y
[protected, virtual]
 

The left mouse button has been double-clicked.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnLButtonDown int  x,
int  y
[protected, virtual]
 

The left mouse button has been pressed.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnLButtonUp int  x,
int  y
[protected, virtual]
 

The left mouse button has been released.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnMButtonDblClk int  x,
int  y
[protected, virtual]
 

The middle mouse button has been double-clicked.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnMButtonDown int  x,
int  y
[protected, virtual]
 

The middle mouse button has been pressed.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnMButtonUp int  x,
int  y
[protected, virtual]
 

The middle mouse button has been released.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnMenuCommand int  id  )  [protected, virtual]
 

The user has activated a menu item.

Parameters:
id Identifier of the menu item.

virtual void OnMouseMove int  x,
int  y
[protected, virtual]
 

The mouse has been moved.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnMouseWheel int  x,
int  y,
int  zDelta
[protected, virtual]
 

The mouse wheel has been moved.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.
zDelta The change in the mouse wheel position.

virtual void OnMove int  x,
int  y
[protected, virtual]
 

The window has been moved.

Parameters:
x X coordinate of the window's upper-left corner.
y Y coordinate of the window's upper-left corner.

virtual void OnPaint  )  [protected, virtual]
 

The window needs to be repainted.

Called as a result of a portion of the window being uncovered or exposed. You should do any drawing that your window requires in response to this message.

The default implementation clears the framebuffer and draws the scenegraph attached via ShowScene, if any.

virtual void OnRButtonDblClk int  x,
int  y
[protected, virtual]
 

The right mouse button has been double-clicked.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnRButtonDown int  x,
int  y
[protected, virtual]
 

The right mouse button has been pressed.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnRButtonUp int  x,
int  y
[protected, virtual]
 

The right mouse button has been released.

Parameters:
x Mouse cursor position x coordinate.
y Mouse cursor position y coordinate.

virtual void OnSize WindowState  state,
int  width,
int  height
[protected, virtual]
 

The window has been resized.

Parameters:
state The new state of the window.
width The new width of the window.
height The new height of the window.
The default implementation adjusts the aspect ratios of any cameras attached to the window via AdjustCamera to match the aspect ratio of the window.

void Redraw  ) 
 

Redraws the window.

Notifies the operating/windowing system that the window needs to be redrawn. Causes the OnPaint() method to be called.

void SetInputHandler InputHandler handler  ) 
 

Sets the window's current input handler.

The default implementation of the On* mouse message handlers is to pass the message onto the current InputHandler, if any.

A typical use of an input handler is adjust the orientation of a camera or other scene graph node in response to input (See the Examiner class).

NOTE: In a future release of LVT, a Wnd will keep a chain of InputHandlers and pass the message onto each item in the chain successively until one of the handlers accepts the message.

bool SetMenu const Menu menu  ) 
 

Sets the window's current menu.

void SetPosition int  x,
int  y
 

Sets the position of the window, in screen coordinates.

void SetSize int  width,
int  height
 

Sets the size of the window, in screen coordinates.

bool Show WindowState  showCmd = STATE_NORMAL  ) 
 

Shows the window with the given WindowState.

void ShowScene Node newScene  ) 
 

Causes the window to display a scenegraph when it is painted.

ShowScene increments the reference count of the Node pointed to by scene. If the window was already displaying a scenegraph, that Node's reference count will be decremented.


Generated on Thu Feb 17 09:45:48 2005 for liblvt by  doxygen 1.4.1