Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

PG_Widget Class Reference

Inheritance diagram for PG_Widget:

Inheritance graph
[legend]
Collaboration diagram for PG_Widget:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class of all widgets.

Author:
Alexander Pipelka

Provides graphics context and message handling functionality.

Theme support

This class provides themeing capabilities only for subclassed widgets.

widget type: none (managed through subclass)
object name: none (managed through subclass)

Theme sample:

    <widget>
        <type value="xxx"/>
            <object>
            <name value="xxx"/>
            <property color="textcolor" value="0x00FFFFFF"/>
            <property color="bordercolor0" value="0x00202020"/>
            <property color="bordercolor1" value="0x00E0E0E0"/>
        </object>
    </widget>

Code:

Examples:

paratest.cpp, and sigc.cpp.


Public Types

enum  KeyAction {
  ACT_ACTIVATE, ACT_DEACTIVATE, ACT_OK, ACT_CANCEL,
  ACT_LEFT, ACT_RIGHT, ACT_UP, ACT_DOWN
}
 Keyevent actions. More...


Public Member Functions

 PG_Widget (PG_Widget *parent, const PG_Rect &rect=PG_Rect::null, bool bObjectSurface=false)
 Creates a PG_Widget with an internal object surface.

virtual ~PG_Widget ()
 Destroys a PG_Widget.

void LoadThemeStyle (const char *widgettype)
 Load a style from the theme definition.

virtual void LoadThemeStyle (const char *widgettype, const char *objectname)
 Load a style from the theme definition.

void StartWidgetDrag ()
 Start to drag a widget.

void WidgetDrag (int x, int y)
 Drag the widget to a given position (in screen coordinates).

void EndWidgetDrag (int x, int y)
 Finishes a drag operation.

bool MoveWidget (int x, int y, bool update=true)
 Move a widget.

bool MoveWidget (const PG_Rect &r, bool update=true)
 Move and resize widget.

virtual bool SizeWidget (Uint16 w, Uint16 h, bool update=true)
 Resize a widget.

PG_Point ClientToScreen (int x, int y)
 Convert a client (widget) coordinate to a screen position.

PG_Point ScreenToClient (int x, int y)
 Convert a screen position to a client (widget) coordinate.

SDL_Surface * GetWidgetSurface ()
 Return the pointer to the widget's drawing surface.

bool IsVisible ()
 Check if the object is visible.

PG_WidgetGetParent ()
 Get the parentwidget of a widget.

virtual void AddChild (PG_Widget *child)
 Add a clientwidget (which will be embedded into this widget).

virtual bool ProcessEvent (const SDL_Event *event, bool bModal=false)
 Process a native PG_ event.

void SetID (int id)
 Set the widgetid.

int GetID ()
 Return the widgetid.

PG_WidgetFindChild (int id)
 Find a child that is identified by the given ID.

PG_WidgetFindChild (const char *name)
 Find a child that is identified by the given name.

bool IsMouseInside ()
 Check if the mousepointer is currently inside the widget.

bool Redraw (bool update=true)
 Redraw the widget and all embedded child widgets.

virtual void Blit (bool recursive=true, bool restore=true)
 Blit the widget to the screen.

void Update (bool doBlit=true)
 Update the widget's screen area.

void Show (bool fade=false)
 Make a widget visible.

void Hide (bool fade=false)
 Hide a widget.

bool IsInFrontOf (PG_Widget *)
 Check if the widget is in front of another one.

void SendToBack ()
 Send the widget back to the end of the list.

void BringToFront ()
 Reorder the widget in front of all others.

PG_WidgetGetToplevelWidget ()
 Get the toplevel widget.

void RecalcClipRect ()
virtual bool RestoreBackground (PG_Rect *clip=NULL, bool force=false)
 Restore the background (all widgets behind this one).

void SetVisible (bool visible)
 Set the visiblility of a widget with updating the screen contents.

void SetFadeSteps (int steps)
 Set the number of steps for fading in/out widgets.

void SetChildTransparency (Uint8 t)
 Set the transparency of all child widgets.

PG_RectListGetChildList ()
 Get a list of child widgets.

int GetChildCount ()
 Get the number of childwidgets.

void MoveRect (int x, int y)
virtual bool Action (KeyAction action)
void SetName (const char *name)
 Set the name for the widget.

const char * GetName ()
 Get the name for the widget.

bool LoadLayout (const char *name)
 Load layout from the XML file to the current widget.

bool LoadLayout (const char *name, void(*WorkCallback)(int now, int max))
 Load layout from the XML file to the current widget.

bool LoadLayout (const char *name, void(*WorkCallback)(int now, int max), void *UserSpace)
 Load layout from the XML file to the current widget.

void RemoveAllChilds ()
 Removes all childs.

void SetUserData (void *userdata, int size)
 Sets user data to the widget (malloc inside).

virtual int GetUserDataSize ()
 Sets user data to the widget (malloc inside).

virtual void GetUserData (void *userdata)
 Gets user data from the widget.

void ReleaseUserData ()
 Releases user data.

virtual bool RemoveChild (PG_Widget *child)
virtual void SetText (const char *text)
 Sets text.

void AddText (const char *text, bool update=false)
 Adds text.

virtual void SetTextFormat (const char *text,...)
 Sets formated text.

virtual const char * GetText ()
 Returns text.

void GetTextSize (Uint16 &w, Uint16 &h, const char *text=NULL)
int GetTextWidth ()
int GetTextHeight ()
int GetFontAscender ()
int GetFontHeight ()
PG_Color GetFontColor ()
 Return the current text color.

void SetFontColor (const PG_Color &Color)
 Set font color.

void SetFontAlpha (int Alpha, bool bRecursive=false)
 Set font transparency (!!!).

void SetFontStyle (PG_Font::Style Style, bool bRecursive=false)
 Set font style.

void SetFontSize (int Size, bool bRecursive=false)
 Set font size.

void SetFontIndex (int Index, bool bRecursive=false)
 Set font index.

void SetFontName (const char *Name, bool bRecursive=false)
 Set font name.

void SetSizeByText (int Width=0, int Height=0, const char *Text=NULL)
 Set widget size by size of text (should be used before Show() or AddWidget()).

int GetFontSize ()
 Get the size of the font.

PG_FontGetFont ()
 Get the current font parameters.

void SetFont (PG_Font *font)
 Set the current font parameters.

void DrawText (const PG_Rect &rect, const char *text)
 Render text inside the widget.

void DrawText (int x, int y, const char *text)
 Render text inside the widget.

void DrawText (int x, int y, const char *text, const PG_Rect &cliprect)
 Render text inside the widget and clip to a given clipping rectangle.

void DrawText (const PG_Rect &rect, const char *text, const PG_Color &c)
 Render text inside the widget and set the font color.

void DrawText (int x, int y, const char *text, const PG_Color &c)
 Render text inside the widget and set the font color.

void DrawBorder (const PG_Rect &r, int size, bool up=true)
virtual void SetTransparency (Uint8 t, bool bRecursive=false)
 Set the transparency of the drawing object.

Uint8 GetTransparency ()
 Get the transparency of the drawing object.

void SetClipRect (PG_Rect &r)
 Set the clipping rectangle for the object.

PG_RectGetClipRect ()
 Get the current clipping rectangle.

bool IsClippingEnabled ()
 Check if there is a clipping rectangle assigned to the object.

void GetClipRects (PG_Rect &src, PG_Rect &dst)
void GetClipRects (PG_Rect &src, PG_Rect &dst, const PG_Rect &displayrect)
void SetPixel (int x, int y, const PG_Color &c)
void DrawHLine (int x, int y, int w, const PG_Color &c)
void DrawVLine (int x, int y, int h, const PG_Color &c)
void DrawRectWH (int x, int y, int w, int h, const PG_Color &c)
void DrawLine (Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color &color, Uint8 width=1)
virtual void RunModal ()
 Enter modal mode.

void QuitModal ()
 Quit modal mode.

bool WillQuitModal ()
void StopQuitModal ()
void SetDirtyUpdate (bool bDirtyUpdate)
 Set the dirty update mode.

bool GetDirtyUpdate ()
 return if the dirty update mode is enabled

virtual void eventMouseLeave ()
 eventhandler for mouse movements.

virtual void eventMouseEnter ()
 eventhandler for mouse movements.

void SetHidden (bool hidden)
bool IsHidden ()

Static Public Member Functions

void UpdateRect (const PG_Rect &r)
 Update a screen area.

void UpdateScreen ()
 Update (render) the whole application screen.

void HideAll ()
 Hide all widgets of an application.

PG_WidgetFindWidgetFromPos (int x, int y)
void BulkUpdate ()
void BulkBlit ()
PG_RectListGetWidgetList ()
 Get a list of all toplevel widgets.

void GetTextSize (Uint16 &w, Uint16 &h, const char *text, PG_Font *font)

Protected Member Functions

virtual void eventMoveWidget (int x, int y)
 Callback for the MoveWidget event.

virtual void eventSizeWidget (Uint16 w, Uint16 h)
 Callback for the SizeWidget event.

virtual void eventDraw (SDL_Surface *surface, const PG_Rect &rect)
 overridable eventhandler to draw the object surface

virtual void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
 overridable eventhandler to blit the widget contents to the screen

virtual void eventShow ()
 overridable eventhandler called whenever the widget gets shown.

virtual void eventHide ()
 overridable eventhandler called whenever the widget gets hidden.

virtual bool eventQuitModal (int id, PG_MessageObject *widget, unsigned long data)
 overridable eventhandler called when leaving a modal eventloop

void SetParent (PG_Widget *parent)
void FadeOut ()
void FadeIn ()
bool AcceptEvent (const SDL_Event *event)
 Overridable message filter function.

void RemoveFromWidgetList ()
void AddToWidgetList ()

Protected Attributes

SDL_Surface * my_srfObject
 pointer to the widgets drawing surface or NULL

string my_text
 text attached to the widget

PG_Color my_colorBorder [2][2]
 array of border colors


Member Enumeration Documentation

enum PG_Widget::KeyAction
 

Keyevent actions.

Enumeration values:
ACT_ACTIVATE  Widget got the input focus.
ACT_DEACTIVATE  Widget has lost the input focus.
ACT_OK  Widget action event (e.g. button press on a PG_Button object).
ACT_CANCEL  Widget cancel-action.
ACT_LEFT  Cursor left was pressed.
ACT_RIGHT  Cursor right was pressed.
ACT_UP  Cursor up was pressed.
ACT_DOWN  Cursor down was pressed.


Constructor & Destructor Documentation

PG_Widget::PG_Widget PG_Widget parent,
const PG_Rect rect = PG_Rect::null,
bool  bObjectSurface = false
 

Creates a PG_Widget with an internal object surface.

Parameters:
parent the parentobject for the new widget or NULL if it is a toplevel widget
rect initial position for the widget
bObjectSurface flag if a surface for the object should be created

virtual PG_Widget::~PG_Widget  )  [virtual]
 

Destroys a PG_Widget.

This is the destructor for the PG_Widget class


Member Function Documentation

bool PG_Widget::AcceptEvent const SDL_Event *  event  )  [protected, virtual]
 

Overridable message filter function.

Derivated classes can filter special events. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
event SDL_Event message
Returns:
Notifies the message pump if this message is processed by this object or it should be routed to the next message receiver.

Reimplemented from PG_MessageObject.

virtual bool PG_Widget::Action KeyAction  action  )  [virtual]
 

Reimplemented in PG_LineEdit.

virtual void PG_Widget::AddChild PG_Widget child  )  [virtual]
 

Add a clientwidget (which will be embedded into this widget).

Parameters:
child the widget to add

Reimplemented in PG_DropDown, PG_ListBox, PG_RichEdit, PG_ScrollArea, PG_ScrollWidget, and PG_WidgetList.

void PG_Widget::AddText const char *  text,
bool  update = false
 

Adds text.

Parameters:
text Add text to the widget text
update Do the update

void PG_Widget::AddToWidgetList  )  [protected]
 

virtual void PG_Widget::Blit bool  recursive = true,
bool  restore = true
[virtual]
 

Blit the widget to the screen.

Parameters:
recursive if true all embedded widget will also be blitted to screen
restore restore the background before blitting if true This function only performs a SDL_BlitSurface() the screen content will NOT be updated

void PG_Widget::BringToFront  ) 
 

Reorder the widget in front of all others.

void PG_Widget::BulkBlit  )  [static]
 

Examples:
dblbuffer.cpp.

void PG_Widget::BulkUpdate  )  [static]
 

PG_Point PG_Widget::ClientToScreen int  x,
int  y
 

Convert a client (widget) coordinate to a screen position.

Parameters:
x x - widgetcoordinate
y y - widgetcoordinate
Returns:
PG_Point structure with the screen position

void PG_Widget::DrawBorder const PG_Rect r,
int  size,
bool  up = true
 

void PG_Widget::DrawHLine int  x,
int  y,
int  w,
const PG_Color c
 

void PG_Widget::DrawLine Uint32  x0,
Uint32  y0,
Uint32  x1,
Uint32  y1,
const PG_Color color,
Uint8  width = 1
 

void PG_Widget::DrawRectWH int  x,
int  y,
int  w,
int  h,
const PG_Color c
 

void PG_Widget::DrawText int  x,
int  y,
const char *  text,
const PG_Color c
 

Render text inside the widget and set the font color.

Parameters:
x x-position where the text should appear
y y-position where the text should appear
text pointer to text string
c color of the rendered text

void PG_Widget::DrawText const PG_Rect rect,
const char *  text,
const PG_Color c
 

Render text inside the widget and set the font color.

Parameters:
rect rectangle where the text should appear
text pointer to text string
c color of the rendered text

void PG_Widget::DrawText int  x,
int  y,
const char *  text,
const PG_Rect cliprect
 

Render text inside the widget and clip to a given clipping rectangle.

Parameters:
x x-position where the text should appear
y y-position where the text should appear
text pointer to text string
cliprect text bounding rectangle

void PG_Widget::DrawText int  x,
int  y,
const char *  text
 

Render text inside the widget.

Parameters:
x x-position where the text should appear
y y-position where the text should appear
text pointer to text string

void PG_Widget::DrawText const PG_Rect rect,
const char *  text
 

Render text inside the widget.

Parameters:
rect rectangle where the text should appear
text pointer to text string

void PG_Widget::DrawVLine int  x,
int  y,
int  h,
const PG_Color c
 

void PG_Widget::EndWidgetDrag int  x,
int  y
 

Finishes a drag operation.

Parameters:
x x endposition
y y endposition

virtual void PG_Widget::eventBlit SDL_Surface *  surface,
const PG_Rect src,
const PG_Rect dst
[protected, virtual]
 

overridable eventhandler to blit the widget contents to the screen

Parameters:
surface pointer to SDL_Surface to be blitted
src source rectangle (client coordinates)
dst destination rectangle (screen coordinates) Override this eventhandler to perform custom blitting behaviour (without drawing onto the widget surface).

Reimplemented in PG_Button, PG_ColumnItem, PG_Image, PG_Label, PG_LineEdit, PG_ListBoxItem, PG_PopupMenu, PG_ProgressBar, PG_RichEdit, PG_ThemeWidget, and PG_Window.

virtual void PG_Widget::eventDraw SDL_Surface *  surface,
const PG_Rect rect
[protected, virtual]
 

overridable eventhandler to draw the object surface

Parameters:
surface the widgets drawing surface.
rect rectangle to draw within. This eventhandler is called whenevener the widget contents should be redrawn.
Note:
Only widgets with drawing surfaces (see the constructor) will call this eventhandler.

Reimplemented in PG_Image, PG_Label, and PG_ThemeWidget.

virtual void PG_Widget::eventHide  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets hidden.

Reimplemented in PG_DropDown, PG_LineEdit, PG_ListBoxBaseItem, and PG_PopupMenu.

virtual void PG_Widget::eventMouseEnter  )  [virtual]
 

eventhandler for mouse movements.

This overrideable handler is called everytime the mouse cursor is entering the widget area.

Reimplemented in PG_Button, PG_ListBoxBaseItem, PG_PopupMenu, and PG_RadioButton.

virtual void PG_Widget::eventMouseLeave  )  [virtual]
 

eventhandler for mouse movements.

This overrideable handler is called everytime the mouse cursor is leaving the widget area.

Reimplemented in PG_Button, PG_ListBoxBaseItem, PG_PopupMenu, and PG_RadioButton.

virtual void PG_Widget::eventMoveWidget int  x,
int  y
[protected, virtual]
 

Callback for the MoveWidget event.

Parameters:
x new x position
y new y position This virtual function can be used to implement custom behavior for MoveWidget events.

Reimplemented in PG_DropDown, and PG_PopupMenu.

virtual bool PG_Widget::eventQuitModal int  id,
PG_MessageObject widget,
unsigned long  data
[protected, virtual]
 

overridable eventhandler called when leaving a modal eventloop

Parameters:
id id of the widget that send the quit signal
widget pointer to the widget
data event specific data
Returns:
true if the message was processed

Reimplemented from PG_MessageObject.

virtual void PG_Widget::eventShow  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets shown.

Reimplemented in PG_DropDown, PG_PopupMenu, and PG_Window.

virtual void PG_Widget::eventSizeWidget Uint16  w,
Uint16  h
[protected, virtual]
 

Callback for the SizeWidget event.

Parameters:
w new width
h new height This virtual function can be used to implement custom behavior for SizeWidget events.

Reimplemented in PG_Button, PG_DropDown, PG_ListBoxBaseItem, PG_ListBoxItem, PG_ScrollBar, PG_ScrollWidget, PG_ThemeWidget, and PG_Window.

void PG_Widget::FadeIn  )  [protected]
 

void PG_Widget::FadeOut  )  [protected]
 

PG_Widget* PG_Widget::FindChild const char *  name  ) 
 

Find a child that is identified by the given name.

Parameters:
name the name of the child to return
Returns:
A pointer to the child with the given name or 0 if no such child exists.

PG_Widget* PG_Widget::FindChild int  id  ) 
 

Find a child that is identified by the given ID.

Parameters:
id the id of the child to return
Returns:
A pointer to the child with the given ID or 0 if no such child exists.

PG_Widget* PG_Widget::FindWidgetFromPos int  x,
int  y
[static]
 

int PG_Widget::GetChildCount  ) 
 

Get the number of childwidgets.

Returns:
number of childwidgets

PG_RectList* PG_Widget::GetChildList  ) 
 

Get a list of child widgets.

Returns:
pointer to childlist
Examples:
paratest.cpp.

PG_Rect* PG_Widget::GetClipRect  ) 
 

Get the current clipping rectangle.

Returns:
the clipping rectangle

void PG_Widget::GetClipRects PG_Rect src,
PG_Rect dst,
const PG_Rect displayrect
 

void PG_Widget::GetClipRects PG_Rect src,
PG_Rect dst
 

bool PG_Widget::GetDirtyUpdate  ) 
 

return if the dirty update mode is enabled

Returns:
true - dirty updates enabled

PG_Font* PG_Widget::GetFont  ) 
 

Get the current font parameters.

Returns:
pointer to the PG_Font object

int PG_Widget::GetFontAscender  ) 
 

PG_Color PG_Widget::GetFontColor  ) 
 

Return the current text color.

Returns:
PG_Color

int PG_Widget::GetFontHeight  ) 
 

int PG_Widget::GetFontSize  ) 
 

Get the size of the font.

int PG_Widget::GetID  ) 
 

Return the widgetid.

Returns:
id of the widget
Examples:
paratest.cpp.

const char* PG_Widget::GetName  ) 
 

Get the name for the widget.

Returns:
name of the widget
Examples:
paratest.cpp.

PG_Widget* PG_Widget::GetParent  ) 
 

Get the parentwidget of a widget.

Returns:
a pointer to the parentwidget or NULL if there is no parentwidget

Reimplemented in PG_ListBoxBaseItem.

virtual const char* PG_Widget::GetText  )  [virtual]
 

Returns text.

Returns:
Pointer to the text of the widget (read-only)

Reimplemented in PG_DropDown, and PG_RadioButton.

int PG_Widget::GetTextHeight  ) 
 

void PG_Widget::GetTextSize Uint16 &  w,
Uint16 &  h,
const char *  text,
PG_Font font
[static]
 

void PG_Widget::GetTextSize Uint16 &  w,
Uint16 &  h,
const char *  text = NULL
 

int PG_Widget::GetTextWidth  ) 
 

PG_Widget* PG_Widget::GetToplevelWidget  ) 
 

Get the toplevel widget.

Uint8 PG_Widget::GetTransparency  ) 
 

Get the transparency of the drawing object.

Returns:
transparency (0 - opaque / 255 - fully transparent)

virtual void PG_Widget::GetUserData void *  userdata  )  [virtual]
 

Gets user data from the widget.

Parameters:
userdata where to write data (must be allocated space with size from GetUserDataSize())

virtual int PG_Widget::GetUserDataSize  )  [virtual]
 

Sets user data to the widget (malloc inside).

Returns:
size of stored user data (0 = no data stored in)

PG_RectList* PG_Widget::GetWidgetList  )  [static]
 

Get a list of all toplevel widgets.

Returns:
pointer to a PG_RectList object

SDL_Surface* PG_Widget::GetWidgetSurface  ) 
 

Return the pointer to the widget's drawing surface.

Returns:
SDL_Surface pointer to the drawing surface

void PG_Widget::Hide bool  fade = false  ) 
 

Hide a widget.

Parameters:
fade do a smooth fade out if true
Examples:
paratest.cpp.

void PG_Widget::HideAll  )  [static]
 

Hide all widgets of an application.

bool PG_Widget::IsClippingEnabled  ) 
 

Check if there is a clipping rectangle assigned to the object.

Returns:
true / false

bool PG_Widget::IsHidden  ) 
 

bool PG_Widget::IsInFrontOf PG_Widget  ) 
 

Check if the widget is in front of another one.

bool PG_Widget::IsMouseInside  ) 
 

Check if the mousepointer is currently inside the widget.

Returns:
true if the mousepointer is inside

bool PG_Widget::IsVisible  ) 
 

Check if the object is visible.

Returns:
true if object is visible

bool PG_Widget::LoadLayout const char *  name,
void(*  WorkCallback)(int now, int max),
void *  UserSpace
 

Load layout from the XML file to the current widget.

Parameters:
name name of the xml file
WorkCallback address of function to show progress of loading layout
UserSpace address of user data witch are passed to Processing Instruction handler etc.
Returns:
returns non-zero on success or 0 if not succes

bool PG_Widget::LoadLayout const char *  name,
void(*  WorkCallback)(int now, int max)
 

Load layout from the XML file to the current widget.

Parameters:
name name of the xml file
WorkCallback address of function to show progress of loading layout
Returns:
returns non-zero on success or 0 if not succes

bool PG_Widget::LoadLayout const char *  name  ) 
 

Load layout from the XML file to the current widget.

Parameters:
name name of the xml file
Returns:
returns non-zero on success or 0 if not succes

virtual void PG_Widget::LoadThemeStyle const char *  widgettype,
const char *  objectname
[virtual]
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
objectname name of the object
Loads the defined style of a given widgettype and objectname.

Reimplemented in PG_Button, PG_Label, PG_LineEdit, PG_ListBoxItem, PG_PopupMenu, and PG_ThemeWidget.

void PG_Widget::LoadThemeStyle const char *  widgettype  ) 
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
Loads the defined style for a given widgettype

Reimplemented in PG_Button, PG_DropDown, PG_Label, PG_LineEdit, PG_MessageBox, PG_PopupMenu, PG_ProgressBar, PG_RadioButton, PG_ScrollBar, PG_ScrollWidget, PG_Slider, PG_ThemeWidget, and PG_Window.

void PG_Widget::MoveRect int  x,
int  y
 

bool PG_Widget::MoveWidget const PG_Rect r,
bool  update = true
 

Move and resize widget.

Parameters:
r new widget rectangle (client coordinates)
Returns:
function succeeded
This function moves and resizes the widget to fit the given rectangle.

bool PG_Widget::MoveWidget int  x,
int  y,
bool  update = true
 

Move a widget.

Parameters:
x new x-position (in parent context)
y new y-position (in parent context)
update true - update screen content / false - no screen update
Returns:
function succeeded
This function moves the widget

virtual bool PG_Widget::ProcessEvent const SDL_Event *  event,
bool  bModal = false
[virtual]
 

Process a native PG_ event.

Parameters:
event PG_ event to process
bModal set to true if processing takes place in a modal loop
Returns:
true if the event was sucessfully processed
ProcessEvent asks the widget to process a given event.

Reimplemented in PG_DropDown.

void PG_Widget::QuitModal  ) 
 

Quit modal mode.

void PG_Widget::RecalcClipRect  ) 
 

bool PG_Widget::Redraw bool  update = true  ) 
 

Redraw the widget and all embedded child widgets.

Parameters:
update if true Update() is called after the redraw
Returns:
true if the redraw operation succeeded

void PG_Widget::ReleaseUserData  ) 
 

Releases user data.

void PG_Widget::RemoveAllChilds  ) 
 

Removes all childs.

virtual bool PG_Widget::RemoveChild PG_Widget child  )  [virtual]
 

Reimplemented in PG_RichEdit, and PG_ScrollArea.

void PG_Widget::RemoveFromWidgetList  )  [protected]
 

virtual bool PG_Widget::RestoreBackground PG_Rect clip = NULL,
bool  force = false
[virtual]
 

Restore the background (all widgets behind this one).

Parameters:
clip clipping rectangle
force force to redraw the background even if dirty updates are enabled.

virtual void PG_Widget::RunModal  )  [virtual]
 

Enter modal mode.

PG_Point PG_Widget::ScreenToClient int  x,
int  y
 

Convert a screen position to a client (widget) coordinate.

Parameters:
x x - screenposition
y y - screenposition
Returns:
PG_Point structure with the client position

void PG_Widget::SendToBack  ) 
 

Send the widget back to the end of the list.

void PG_Widget::SetChildTransparency Uint8  t  ) 
 

Set the transparency of all child widgets.

Parameters:
t transparency 0 - opaque / 255 - full transparent

void PG_Widget::SetClipRect PG_Rect r  ) 
 

Set the clipping rectangle for the object.

Parameters:
r clipping rectangle

void PG_Widget::SetDirtyUpdate bool  bDirtyUpdate  ) 
 

Set the dirty update mode.

Parameters:
bDirtyUpdate true - enable / false - disable This function sets the dirty update mode of a widget. This greatly improves the rendering speed because the underlying widgets are not redrawn if the widgets transparency is equal to 0. It will cause render failures wrong if there is an alpha channel in the widget's drawing surface. If you encounter problems with activated dirty updates simple disable it.

void PG_Widget::SetFadeSteps int  steps  ) 
 

Set the number of steps for fading in/out widgets.

Parameters:
steps number of steps

void PG_Widget::SetFont PG_Font font  ) 
 

Set the current font parameters.

Parameters:
font pointer to PG_Font object

void PG_Widget::SetFontAlpha int  Alpha,
bool  bRecursive = false
 

Set font transparency (!!!).

Parameters:
Alpha Value 0 - 255 (0 = invisible, 255 = fully visible)
bRecursive alter all child widgets

void PG_Widget::SetFontColor const PG_Color Color  ) 
 

Set font color.

Parameters:
Color PG_Color class contains color information (RGB)

Reimplemented in PG_RadioButton.

void PG_Widget::SetFontIndex int  Index,
bool  bRecursive = false
 

Set font index.

Parameters:
Index Index of the desired font face in the font file (usualy 0)
bRecursive alter all child widgets

void PG_Widget::SetFontName const char *  Name,
bool  bRecursive = false
 

Set font name.

Parameters:
Name Filename of the font (this function don`t load the font - or check presention of the file !!!)
bRecursive alter all child widgets

void PG_Widget::SetFontSize int  Size,
bool  bRecursive = false
 

Set font size.

Parameters:
Size size of the font
bRecursive alter all child widgets

void PG_Widget::SetFontStyle PG_Font::Style  Style,
bool  bRecursive = false
 

Set font style.

Parameters:
Style Binary combination (OR) of PG_FSTYLE_NORMAL, PG_FSTYLE_BOLD, PG_FSTYLE_ITALIC and PG_FSTYLE_UNDERLINE
bRecursive alter all child widgets

void PG_Widget::SetHidden bool  hidden  ) 
 

void PG_Widget::SetID int  id  ) 
 

Set the widgetid.

Parameters:
id a number which can be used to identify the widget
This id can be used in callbacks or eventhandlers to identify the widget. It can also be used to find a child within the group of children.
Examples:
paratest.cpp.

void PG_Widget::SetName const char *  name  ) 
 

Set the name for the widget.

Parameters:
name Name of the widget - size of the name is defined in PG_NAMESIZE

void PG_Widget::SetParent PG_Widget parent  )  [protected]
 

void PG_Widget::SetPixel int  x,
int  y,
const PG_Color c
 

void PG_Widget::SetSizeByText int  Width = 0,
int  Height = 0,
const char *  Text = NULL
 

Set widget size by size of text (should be used before Show() or AddWidget()).

Parameters:
Width Value witch is added to text width (default = 0)
Height Value witch is added to text height (default = 0)
Text Text to get size from, if NULL my_text is used

Reimplemented in PG_RadioButton.

virtual void PG_Widget::SetText const char *  text  )  [virtual]
 

Sets text.

Parameters:
text Set the widget text and update widget

Reimplemented in PG_DropDown, PG_LineEdit, PG_MaskEdit, PG_RadioButton, and PG_RichEdit.

virtual void PG_Widget::SetTextFormat const char *  text,
... 
[virtual]
 

Sets formated text.

Parameters:
text Set the widget text (like printf) and update widget
Examples:
dblbuffer.cpp, and paratest.cpp.

virtual void PG_Widget::SetTransparency Uint8  t,
bool  bRecursive = false
[virtual]
 

Set the transparency of the drawing object.

Parameters:
t transparency (0 - opaque / 255 - fully transparent)

Reimplemented in PG_Button, and PG_ThemeWidget.

void PG_Widget::SetUserData void *  userdata,
int  size
 

Sets user data to the widget (malloc inside).

Parameters:
userdata points to data to copy in
size size of data

void PG_Widget::SetVisible bool  visible  ) 
 

Set the visiblility of a widget with updating the screen contents.

Parameters:
visible true - visible / false - invisible

void PG_Widget::Show bool  fade = false  ) 
 

Make a widget visible.

Parameters:
fade do a smooth fade in if true
Examples:
paratest.cpp.

virtual bool PG_Widget::SizeWidget Uint16  w,
Uint16  h,
bool  update = true
[virtual]
 

Resize a widget.

Parameters:
w new widget-width
h new widget-height
update true - update widget after resizing / false - do not display changes
Returns:
function succeeded
This function resizes the widget

void PG_Widget::StartWidgetDrag  ) 
 

Start to drag a widget.

StartWidgetDrag prepares to widget to be dragged.

void PG_Widget::StopQuitModal  ) 
 

void PG_Widget::Update bool  doBlit = true  ) 
 

Update the widget's screen area.

Parameters:
doBlit if true a Blit() operation is done before the update
Examples:
paratest.cpp.

void PG_Widget::UpdateRect const PG_Rect r  )  [static]
 

Update a screen area.

Parameters:
r update rectangle

void PG_Widget::UpdateScreen  )  [static]
 

Update (render) the whole application screen.

Examples:
paratest.cpp.

void PG_Widget::WidgetDrag int  x,
int  y
 

Drag the widget to a given position (in screen coordinates).

Parameters:
x x-position
y y-position

bool PG_Widget::WillQuitModal  ) 
 


Member Data Documentation

PG_Color PG_Widget::my_colorBorder[2][2] [protected]
 

array of border colors

SDL_Surface* PG_Widget::my_srfObject [protected]
 

pointer to the widgets drawing surface or NULL

string PG_Widget::my_text [protected]
 

text attached to the widget



The ParaGUI Project - Alexander Pipelka