Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CUI_Frame Class Reference

The base class for UI elements. More...

#include <CUI_Frame.h>

Inheritance diagram for CUI_Frame:

CUI_Control CUI_DraggableFrame CUI_DraggableViewFrame CUI_Widget CUI_ComboBox CUI_Console CUI_ListBox CUI_MessageBox CUI_RadioGroup CUI_ScrollableFrame CUI_ScrollableTextBox CUI_TextField CUI_Button CUI_ProgressBar CUI_TextBox List of all members.

Public Types

typedef bool(* callbackfunc )(int id, int numparam, void *param)
 callback function type

enum  animation_t { UI_NONE, UI_FADELINE, UI_FADESIN }
 supported types of animation


Public Member Functions

 CUI_Frame (CUI_UI *ui=NULL, float x=0, float y=0, float x2=1, float y2=1, CUI_Frame *parent=NULL, IUI_Shader *shader=NULL, IUI_Shader *cursor=NULL, CUI_CoordSys *coordsys=NULL)
 constructor

virtual ~CUI_Frame ()
 destructor

virtual bool SetUI (CUI_UI *ui)
 Set the UI that this frame exists in.

virtual bool AddChild (CUI_Frame *frame, bool back=false)
 add a child to this frame

virtual bool DeleteChild (CUI_Frame *frame)
 delete a child from this frame

virtual bool SetParent (CUI_Frame *frame)
 set the parent for this frame

virtual CUI_FrameGetParent (void)
 get the parent for this frame

virtual bool SetCursor (IUI_Shader *cursor)
 set cursor for this frame

virtual bool SetShader (IUI_Shader *shader)
 set shader for this frame

virtual bool SetCoordSys (CUI_CoordSys *coordsys)
 set coordinate system for this frame

virtual CUI_CoordSysGetCoordSys (void)
 get coordinate system for this frame

virtual bool SetBorder (IUI_Border *border)
 set the border (frames don't have borders)

virtual IUI_BorderGetBorder (void)
 get the border (frames don't have borders)

virtual bool SetFont (IUI_Font *font)
 set the font (frames don't have fonts)

virtual IUI_FontGetFont (void)
 get the font (frames don't have fonts)

virtual bool Move (float x, float y, float x2, float y2)
 set the position and size of this frame (in its parent's coordinate system)

virtual bool Move (float x, float y)
 Move the frame, but don't resize it.

virtual void GetRect (v4_f rect)
 get the current position and size

virtual bool Convert (float &x, float &y)
 convert a coordinate into this coordinate system

virtual bool ConvertFromGlobal (float &x, float &y)
 convert a coordinate from global to local coordinates

virtual bool Save (char *filename)
 Save this frame to a new file.

virtual bool Save (FILE *file)
 Save this frame to an already opened file.

virtual bool SetToRange (IUI_Renderer *renderer)
 set view area if coordinate system requires it

virtual bool Render (double dtime, IUI_Renderer *renderer)
 render this frame in the current viewport

virtual bool RenderStart (double dtime, IUI_Renderer *renderer)
 begin rendering

virtual bool RenderBackground (double dtime, IUI_Renderer *renderer)
 render background quad

virtual bool RenderChildren (double dtime, IUI_Renderer *renderer)
 render children - should be the last render call made

virtual bool Animate (double dtime, IUI_Renderer *renderer)
 Do any necessary animation before rendering.

virtual CUI_FrameTestHit (float x, float y)
 test if the given point is within this frame

virtual bool BringToFront (void)
 move this frame to the front of its parent's list

virtual IUI_ShaderGetShader (void)
 Get the shader for this frame.

virtual IUI_ShaderGetCursor (void)
 Get the most specific cursor for this frame.

virtual bool SetFrameID (unsigned long id)
 set this frame's ID

virtual unsigned long GetFrameID (void)
 get this frame's ID

virtual bool SetFlag (unsigned long flag, bool set)
 generic flag handling

virtual bool GetFlag (unsigned long flag)
 generic flag handling

virtual bool Activate (bool active=true)
 activate/deactivate this frame

virtual bool Enable (bool enable=true)
 enable/disable this frame

virtual bool AddClickableToList (void *voidlist)
 add frames with a certain flag(s) to a list

virtual bool IsClickable ()
 is this frame clickable

virtual bool Click (int &id, int &numparam, void **param)
 Call this function when clicked on.

virtual bool IsDraggable ()
 is this frame draggable

virtual bool Drag (float x, float y, float dx, float dy, int &id, int &numparam, void **param)
 Update the cursor's position as this is being dragged (in global space).

virtual void DeleteParam (void *param)
 Delete a parameter allocated by this frame.

virtual bool ProcessKey (unsigned long key)
 Process an incoming key.

virtual bool SetFrameCallback (callbackfunc func)
 set callback function

virtual bool CallbackFunc (int id, int numparam, void *param)
 Wrapper to m_callbackFunc to check for NULL and present a simple interface.

virtual bool IsControl ()
 is this frame a control?

virtual bool SetText (const char *text)
 Set Text - frames have no text, but needs to be here as virtual.

virtual bool SetToolTipText (char *text)
 Set text to display as a tooltip.

virtual bool SetToolTipFrame (CUI_Frame *frame)
 Set the frame to display as a tooltip.

virtual CUI_FrameGetToolTipFrame ()
 Get a pointer to the frame to use as a tooltip.

virtual char * GetToolTipText ()
 Get the tooltip text.

virtual bool ResetCounter (bool count)
 Reset the animation counter.

virtual double GetCounter ()
 Get the value of the animation counter.

virtual bool SetAnimation (animation_t anim)
 Set Animation type.

virtual animation_t GetAnimation ()
 get the animation counter

virtual void SetOwnedByUI ()
 Set this frame as owned by the UI.

virtual bool IsOwnedByUI ()
 Is this frame owned by the UI.


Protected Attributes

CUI_UIm_ui
 pointer to the ui that owns this frame

unsigned long m_frameID
 this frame's ID - the app should define this!

callbackfunc m_callbackFunc
 callback function

IUI_Shaderm_cursor
 the cursor for this frame (NULL means the default)

IUI_Shaderm_shader
 the shader for this frame (NULL means the default)

CUI_CoordSysm_coordsys
 the coordinate system for this frame (NULL means the default)

CUI_Framem_parent
 this frame's parent

std::list< CUI_Frame * > m_frames
 list of children.

float m_x
 minimum X for bounding box of this frame

float m_y
 minimum Y for bounding box of this frame

float m_x2
 maximum X for bounding box of this frame

float m_y2
 maximum Y for bounding box of this frame

unsigned int m_flags
 generic flags

char * m_toolTipText
 Text to display as a tooltip.

CUI_Framem_toolTipFrame
 Frame to display as a tooltip.

double m_counter
 Animation counter (counts in ms).

bool m_count
 Enable/disable animation counter.

animation_t m_animation
 what kind of animation should it be doing?

float m_oldFade
 previous fade value

bool m_ownedByUI
 True if created by the UI - used for memory management.


Detailed Description

The base class for UI elements.

Frames are always rectangles, they can not have a complex border.

Frames by themselves can be used as containers for other elements, or as a way to display an image or icon.

Recognized flags:
UI_DISABLED
UI_INACTIVE


Member Function Documentation

bool CUI_Frame::AddChild CUI_Frame frame,
bool  back = false
[virtual]
 

add a child to this frame

Parameters:
frame the frame to be added
back true if push to the back (should really only need to be used during UI building from file

Reimplemented in CUI_ScrollableFrame.

bool CUI_Frame::Animate double  dtime,
IUI_Renderer renderer
[virtual]
 

Do any necessary animation before rendering.

Can be overloaded in a new class for fancier animation.

bool CUI_Frame::CallbackFunc int  id,
int  numparam,
void *  param
[virtual]
 

Wrapper to m_callbackFunc to check for NULL and present a simple interface.

Returns:
false if the global callback needs to be called as well

Reimplemented in CUI_ComboBox, CUI_Console, CUI_ListBox, CUI_Menu, CUI_MessageBox, CUI_RadioGroup, CUI_ScrollableFrame, CUI_ScrollableTextBox, and CUI_TextField.

virtual bool CUI_Frame::Click int &  id,
int &  numparam,
void **  param
[inline, virtual]
 

Call this function when clicked on.

Default, doesn't care

Reimplemented in CUI_Button, CUI_DraggableFrame, CUI_DraggableViewFrame, CUI_EditableTextBox, CUI_MultipleStateButton, and CUI_SliderBar.

bool CUI_Frame::Convert float &  x,
float &  y
[virtual]
 

convert a coordinate into this coordinate system

Parameters:
x modified X position
y modified Y position

bool CUI_Frame::ConvertFromGlobal float &  x,
float &  y
[virtual]
 

convert a coordinate from global to local coordinates

Parameters:
x modified X position
y modified Y position Expensive. Don't do it unless absolutely necessary

bool CUI_Frame::DeleteChild CUI_Frame frame  )  [virtual]
 

delete a child from this frame

Parameters:
frame the frame to be deleted

Reimplemented in CUI_Control.

virtual void CUI_Frame::DeleteParam void *  param  )  [inline, virtual]
 

Delete a parameter allocated by this frame.

All frames that can return parameters MUST implement this function

Reimplemented in CUI_Button, CUI_DraggableFrame, CUI_DraggableViewFrame, CUI_EditableTextBox, CUI_MultipleStateButton, and CUI_SliderBar.

virtual bool CUI_Frame::Drag float  x,
float  y,
float  dx,
float  dy,
int &  id,
int &  numparam,
void **  param
[inline, virtual]
 

Update the cursor's position as this is being dragged (in global space).

Default, doesn't care

Reimplemented in CUI_DraggableFrame, CUI_DraggableViewFrame, CUI_EditableTextBox, CUI_ResizeButton, and CUI_SliderBar.

void CUI_Frame::GetRect v4_f  rect  )  [virtual]
 

get the current position and size

Parameters:
rect pointer to a 4 float vector (minx, miny, maxx, maxy)

virtual CUI_Frame* CUI_Frame::GetToolTipFrame  )  [inline, virtual]
 

Get a pointer to the frame to use as a tooltip.

Either comes from this frame's pointer, or this frame inserts its tooltip text into the ui's global tooltip frame.

virtual bool CUI_Frame::IsControl  )  [inline, virtual]
 

is this frame a control?

This is necessary for a few things:
Control's callback hack - need to call a parent control's callback before own or global
Selection - cannot select children of a control. Select the control and it will handle things under it/

Reimplemented in CUI_Control.

bool CUI_Frame::Move float  x,
float  y
[virtual]
 

Move the frame, but don't resize it.

Parameters:
x the upper left X position (local space)
y the upper left Y position (local space)

bool CUI_Frame::Move float  x,
float  y,
float  x2,
float  y2
[virtual]
 

set the position and size of this frame (in its parent's coordinate system)

Parameters:
x the upper left X position (local space)
y the lower left Y position (local space)
x2 the lower right X position (local space)
y2 the upper right Y position (local space)

virtual bool CUI_Frame::ProcessKey unsigned long  key  )  [inline, virtual]
 

Process an incoming key.

Returns:
false if this frame did not use the key

Reimplemented in CUI_ComboBox, CUI_Console, CUI_DraggableViewFrame, CUI_EditableTextBox, CUI_ListBox, CUI_Menu, CUI_MessageBox, CUI_RadioGroup, CUI_ScrollableFrame, CUI_ScrollableTextBox, CUI_SliderBar, and CUI_TextField.

virtual bool CUI_Frame::ResetCounter bool  count  )  [inline, virtual]
 

Reset the animation counter.

Parameters:
count if true, start counting

virtual bool CUI_Frame::SetFrameCallback callbackfunc  func  )  [inline, virtual]
 

set callback function

This is the callback function for this particular frame. Depending on what the function returns, the global callback will or will not be called.

virtual void CUI_Frame::SetOwnedByUI  )  [inline, virtual]
 

Set this frame as owned by the UI.

No code outside of the library should call this function. Doing so will definitely cause a crash when the registry is flushed.

bool CUI_Frame::SetParent CUI_Frame frame  )  [virtual]
 

set the parent for this frame

Parameters:
frame the frame's parent

bool CUI_Frame::SetToRange IUI_Renderer renderer  )  [virtual]
 

set view area if coordinate system requires it

Will tell the renderer to restrict rendering to that area

CUI_Frame * CUI_Frame::TestHit float  x,
float  y
[virtual]
 

test if the given point is within this frame

Returns:
the most specific frame

Reimplemented in CUI_Widget.


Member Data Documentation

callbackfunc CUI_Frame::m_callbackFunc [protected]
 

callback function

Designed primarily for internal UI usage. So Controls can handle more functionality without requiring a lot of extra code from the application.

unsigned long CUI_Frame::m_frameID [protected]
 

this frame's ID - the app should define this!

If this is not set (value is zero), it is assumed that this is a static control and that the app does not care about getting callbacks from it. Therefore, the app should not use 0 as a valid frame ID.


The documentation for this class was generated from the following files:
Generated on Mon Sep 29 23:07:03 2003 for glGUI by doxygen 1.3.4