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

PG_Application Class Reference

Inheritance diagram for PG_Application:

Inheritance graph
[legend]
Collaboration diagram for PG_Application:

Collaboration graph
[legend]
List of all members.

Detailed Description

Examples:

dblbuffer.cpp, paratest.cpp, and sigc.cpp.


Public Types

enum  CursorMode { QUERY, NONE, HARDWARE, SOFTWARE }
 Cursor mode. More...

enum  { IDAPPLICATION = PG_WIDGETID_INTERNAL + 100 }

Public Member Functions

 PG_Application ()
 ~PG_Application ()
bool InitScreen (int w, int h, int depth=0, Uint32 flags=SDL_SWSURFACE|SDL_HWPALETTE)
 Initialize the screen.

PG_ThemeLoadTheme (const char *xmltheme, bool asDefault=true, const char *searchpath=NULL)
 Load a widget theme.

SDL_Thread * Run (bool threaded=false)
 Run the applications main eventloop.

void Quit ()
 Exit the main eventloop.

SDL_Surface * SetScreen (SDL_Surface *screen)
 Set a custom screen surface.

bool SetBackground (const char *filename, int mode=BKMODE_TILE)
 Set the application's background image.

bool SetBackground (SDL_Surface *surface, int mode=BKMODE_TILE)
 Set the application's background image.

void SetEmergencyQuit (bool esc)
 Enable / disable the emergency quit key ("ESC").

void PrintVideoTest ()
 Outputs some information about the current video target (only with DEBUG enabled).

void EnableBackground (bool enable=true)
void DeleteBackground ()
void EnableAppIdleCalls (bool enable=true)
 Set AppIdleCalls.

void SetIcon (const char *filename)
 Set application`s window-manager icon.

void SetCaption (const char *title, const char *icon)
 Set application`s window-manager title and icon name.

void GetCaption (char **title, char **icon)
 Get application`s window-manager title and icon name.

int Iconify (void)
 Iconify/Minimise the window-manager window.


Static Public Member Functions

int RunEventLoop (void *data)
 Run the modal message pump.

SDL_Surface * GetScreen ()
 Get the current screen surface.

bool LockScreen ()
 Set a lock on the screen surface (to avoid concurrent drawing operations).

bool UnlockScreen ()
 Unlock the screen surface.

void RedrawBackground (const PG_Rect &rect)
 Redraw the application background.

void SetApplicationPath (const char *path)
 Add an application search path.

const char * GetApplicationPath ()
 Return the current application path.

const char * GetRelativePath (const char *file)
 Tries to find a specifies file.

int GetScreenHeight ()
 Get the current screen (or window) height.

int GetScreenWidth ()
 Get the current screen (or window) width.

void FlipPage ()
 Do a page flip (only for double buffered screens).

PG_ThemeGetTheme ()
 Get the current default widgettheme.

bool GetBulkMode ()
 Check if the application is currently in bulk mode.

void SetBulkMode (bool bulk=true)
 Set the bulk mode.

bool GetGLMode ()
bool LoadLayout (const char *name)
 Load layout from the XML file.

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

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

PG_WidgetGetWidgetByName (const char *Name)
 Get widget by name.

template<class T> T * GetWidget (const char *Name)
template<class T> T * GetWidget (int id)
PG_WidgetGetWidgetById (int id)
 Get widget by id.

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

void SetFontAlpha (int Alpha)
 Set default font transparency (!!!).

void SetFontStyle (PG_Font::Style Style)
 Set default font style.

void SetFontSize (int Size)
 Set default font size.

void SetFontIndex (int Index)
 Set default font index.

void SetFontName (const char *Name)
 Set default font name.

void SetCursor (SDL_Surface *image)
 Set a graphical mouse cursor.

void DrawCursor (bool update=true)
 Update the graphical mouse cursor.

CursorMode ShowCursor (CursorMode mode)
 Set or query the type of mouse cursor to use.

void DisableDirtyUpdates (bool disable)
 Disable dirty widget updates.

bool GetDirtyUpdatesDisabled ()
 Check if the 'dirty update' mode is disabled globally.

PG_ApplicationGetApp ()
bool GetAppIdleCallsEnabled ()
 Get the behaviour concerning empty queues (see EnableAppIdleCalls()).

void FlushEventQueue ()
 Flush the event queue.

void ClearOldMousePosition ()
 If software cursors are enabled and you move the mouse, the old location has to be refreshed somehow with the underlying graphics.


Public Attributes

SignalQuit sigQuit
SignalVideoResize sigVideoResize
SignalXMLTag sigXMLTag

Static Public Attributes

PG_FontDefaultFont

Protected Member Functions

void Shutdown ()
 Cleanup the application data.

bool eventKeyUp (const SDL_KeyboardEvent *key)
 Overridable Eventhandler for a SDL_KeyboardEvent message.

bool eventKeyDown (const SDL_KeyboardEvent *key)
 Overridable Eventhandler for a SDL_KeyboardEvent message.

bool eventQuit (int id, PG_MessageObject *widget, unsigned long data)
 Overridable Eventhandler for a SDL_QuitEvent message.

bool eventResize (const SDL_ResizeEvent *event)
 Overridable Eventhandler for a SDL_ResizeEvent message.

virtual void eventInit ()


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
IDAPPLICATION 

enum PG_Application::CursorMode
 

Cursor mode.

Enumeration values:
QUERY  Used to query the current mode.
NONE  Show no cursor at all.
HARDWARE  Use hardware (standard SDL) cursor.
SOFTWARE  Use ParaGUI software cursor (when possible).


Constructor & Destructor Documentation

PG_Application::PG_Application  ) 
 

PG_Application::~PG_Application  ) 
 


Member Function Documentation

void PG_Application::ClearOldMousePosition  )  [static]
 

If software cursors are enabled and you move the mouse, the old location has to be refreshed somehow with the underlying graphics.

This is done by this function. Note that bulkmode has to be disabled for this function to be called.

void PG_Application::DeleteBackground  ) 
 

void PG_Application::DisableDirtyUpdates bool  disable  )  [static]
 

Disable dirty widget updates.

This function is used to disable dirty widget updates globally. Dirty updates are usually used to speed up blitting. However, it can cause problems with 'semitransparent' widgets.

Parameters:
disable disable ditry updates
Note:
All widgets created after this call wont use the dirty update anymore. Widgets created before will still use this mode if enabled.

void PG_Application::DrawCursor bool  update = true  )  [static]
 

Update the graphical mouse cursor.

This will redraw the graphical curser pointer, if enabled. You might need to call this if you stop the normal event loop from running.

Parameters:
update true if you want to "Update" the screen content immediately.

void PG_Application::EnableAppIdleCalls bool  enable = true  ) 
 

Set AppIdleCalls.

Parameters:
enable whether to enable or disable AppIdleCalls If you enable AppIdleCalls, the PGApplication object will emit a sigAppIdle signal whenever no events are in the queue and sleep for a short interval (this is the behaviour inherited from PG_MessageObject). However, if you disable it, the object will just call SDL_WaitEvent(). Enable this if you know something to do in idle periods and don't forget to connect the sigAppIdle signal then.

void PG_Application::EnableBackground bool  enable = true  ) 
 

virtual void PG_Application::eventInit  )  [protected, virtual]
 

bool PG_Application::eventKeyDown const SDL_KeyboardEvent *  key  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_KeyboardEvent message.

This handler is called when a key changed it's state from unpressed to pressed. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
key SDL_KeyboardEvent 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.

bool PG_Application::eventKeyUp const SDL_KeyboardEvent *  key  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_KeyboardEvent message.

This handler is called when a key changed it's state from pressed to unpressed. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
key SDL_KeyboardEvent 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.

bool PG_Application::eventQuit int  id,
PG_MessageObject widget,
unsigned long  data
[protected, virtual]
 

Overridable Eventhandler for a SDL_QuitEvent message.

The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
id id of the sending widget
widget pointer to the widget
data event specific data
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.

bool PG_Application::eventResize const SDL_ResizeEvent *  event  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_ResizeEvent message.

The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
event SDL_ResizeEvent 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.

void PG_Application::FlipPage  )  [static]
 

Do a page flip (only for double buffered screens).

void PG_Application::FlushEventQueue  )  [static]
 

Flush the event queue.

PG_Application* PG_Application::GetApp  )  [static]
 

bool PG_Application::GetAppIdleCallsEnabled  )  [static]
 

Get the behaviour concerning empty queues (see EnableAppIdleCalls()).

Returns:
the current behaviour of the application object

const char* PG_Application::GetApplicationPath  )  [static]
 

Return the current application path.

Returns:
the current path

bool PG_Application::GetBulkMode  )  [static]
 

Check if the application is currently in bulk mode.

Returns:
true / false Bulkmode means that all widget are always blitted at once.

void PG_Application::GetCaption char **  title,
char **  icon
 

Get application`s window-manager title and icon name.

Parameters:
title return place for title name pointer
icon return place for icon name pointer Set pointers to the window title and icon name.

bool PG_Application::GetDirtyUpdatesDisabled  )  [static]
 

Check if the 'dirty update' mode is disabled globally.

Returns:
true - if the 'dirty update' mode is disabled globally

bool PG_Application::GetGLMode  )  [static]
 

const char* PG_Application::GetRelativePath const char *  file  )  [static]
 

Tries to find a specifies file.

Parameters:
file file to look for
Returns:
path where the file was found (or NULL if not found)

SDL_Surface* PG_Application::GetScreen  )  [inline, static]
 

Get the current screen surface.

Returns:
pointer the screen surface
Examples:
dblbuffer.cpp.

int PG_Application::GetScreenHeight  )  [static]
 

Get the current screen (or window) height.

Returns:
height in pixels

int PG_Application::GetScreenWidth  )  [static]
 

Get the current screen (or window) width.

Returns:
width in pixels

PG_Theme* PG_Application::GetTheme  )  [static]
 

Get the current default widgettheme.

Returns:
pointer to PG_Theme definition
Examples:
dblbuffer.cpp, and paratest.cpp.

template<class T>
T* PG_Application::GetWidget int  id  )  [inline, static]
 

template<class T>
T* PG_Application::GetWidget const char *  Name  )  [inline, static]
 

Examples:
dblbuffer.cpp.

PG_Widget* PG_Application::GetWidgetById int  id  )  [static]
 

Get widget by id.

Parameters:
id id of the widget
Returns:
pointer to the requested widget or 0 if failed
Examples:
paratest.cpp.

PG_Widget* PG_Application::GetWidgetByName const char *  Name  )  [static]
 

Get widget by name.

Parameters:
Name name of the widget
Returns:
pointer to the requested widget or null if failed
Examples:
paratest.cpp.

int PG_Application::Iconify void   ) 
 

Iconify/Minimise the window-manager window.

Returns:
returns non-zero on success or 0 if iconification is not support or was refused by the window manager. If the application is running in a window managed environment Iconify attempts to iconify/minimise it.=20

bool PG_Application::InitScreen int  w,
int  h,
int  depth = 0,
Uint32  flags = SDL_SWSURFACE|SDL_HWPALETTE
 

Initialize the screen.

Parameters:
w screenwidth in pixels
h screenheight in pixels
depth screendepth in bits per pixel
flags PG_ screen initialization flags
Examples:
dblbuffer.cpp, paratest.cpp, and sigc.cpp.

bool PG_Application::LoadLayout const char *  name,
void(*  WorkCallback)(int now, int max),
void *  UserSpace
[static]
 

Load layout from the XML file.

Parameters:
name name of the xml file
WorkCallback address of the progress callback function
UserSpace address of user data with are returned by Processing instruction etc.
Returns:
returns non-zero on success or 0 if not succes

bool PG_Application::LoadLayout const char *  name,
void(*  WorkCallback)(int now, int max)
[static]
 

Load layout from the XML file.

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

bool PG_Application::LoadLayout const char *  name  )  [static]
 

Load layout from the XML file.

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

PG_Theme* PG_Application::LoadTheme const char *  xmltheme,
bool  asDefault = true,
const char *  searchpath = NULL
 

Load a widget theme.

Parameters:
xmltheme name of the theme (e.g. default)
asDefault apply the theme as default widgettheme
searchpath path where the themefile is located
Examples:
dblbuffer.cpp, paratest.cpp, and sigc.cpp.

bool PG_Application::LockScreen  )  [inline, static]
 

Set a lock on the screen surface (to avoid concurrent drawing operations).

Returns:
true - the lock was established successfully

void PG_Application::PrintVideoTest  ) 
 

Outputs some information about the current video target (only with DEBUG enabled).

void PG_Application::Quit  ) 
 

Exit the main eventloop.

Examples:
paratest.cpp.

void PG_Application::RedrawBackground const PG_Rect rect  )  [static]
 

Redraw the application background.

Parameters:
rect the part of the screen to be redrawn

SDL_Thread* PG_Application::Run bool  threaded = false  ) 
 

Run the applications main eventloop.

Parameters:
threaded run the eventloop in a separate thread
Returns:
pointer to event thread If theaded is false this function will exit when the eventloop quits (MSG_QUIT). If threaded is true it will return immediately and a thread processing events is started. CAUTION: Threaded eventloops are unsuported under Win32 (windows specific behavior)
Examples:
paratest.cpp, and sigc.cpp.

int PG_Application::RunEventLoop void *  data  )  [static]
 

Run the modal message pump.

This function will exit when the main window was closed.

void PG_Application::SetApplicationPath const char *  path  )  [static]
 

Add an application search path.

Parameters:
path the application will search for file (images,...) in this path, as well as in all pathes previously added.

bool PG_Application::SetBackground SDL_Surface *  surface,
int  mode = BKMODE_TILE
 

Set the application's background image.

Parameters:
surface pointer to a background surface
mode background mode (BKMODE_TILE | BKMODE_STRETCH)
Returns:
true - background image was altered successfully

bool PG_Application::SetBackground const char *  filename,
int  mode = BKMODE_TILE
 

Set the application's background image.

Parameters:
filename path to a bitmap file
mode background mode (BKMODE_TILE | BKMODE_STRETCH)
Returns:
true - background image was altered successfully

void PG_Application::SetBulkMode bool  bulk = true  )  [static]
 

Set the bulk mode.

Parameters:
bulk whether or not enable bulk mode If bulk mode is enabled, all widgets are blitted at once. I.e. paragui will not draw the mouse pointer if the mouse is moved. Note however, that YOU have to care for the drawing process then. You need to call PG_Widget::BulkUpdate() every now and then to redraw the screen. See dblbuf.cpp for an example.
Examples:
dblbuffer.cpp.

void PG_Application::SetCaption const char *  title,
const char *  icon
 

Set application`s window-manager title and icon name.

Parameters:
title title name
icon icon name Sets the title-bar and icon name of the display window.

void PG_Application::SetCursor SDL_Surface *  image  )  [static]
 

Set a graphical mouse cursor.

This function makes the cursor use software rendering with the image specified. Note that this can be slow and result in sluggish mouse performance. Note that calling this function doesn't enable software rendering. An additional call to PG_ShowCursor is required.

Note:
The image will receive an additional reference and should be freed by the caller using SDL_FreeSurface when the caller is done using it.

If image is zero, the hardware cursor will be restored. Note however that the cursor mode will remain at PG_CURSOR_SOFTWARE, so any subsequent calls to this function will reenable the software cursor automatically.

Parameters:
image the new cursor
See also:
PG_ShowCursor, PG_DrawCursor
Examples:
dblbuffer.cpp, and paratest.cpp.

void PG_Application::SetEmergencyQuit bool  esc  ) 
 

Enable / disable the emergency quit key ("ESC").

Parameters:
esc true - "ESC" key actiavted
Examples:
sigc.cpp.

void PG_Application::SetFontAlpha int  Alpha  )  [static]
 

Set default font transparency (!!!).

Parameters:
Alpha Value 0 - 255 (0 = invisible, 255 = fully visible)
Returns:
0 when OK

void PG_Application::SetFontColor const PG_Color Color  )  [static]
 

Set default font color.

Parameters:
Color PG_Color class contains color information (RGB)
Returns:
0 when OK

void PG_Application::SetFontIndex int  Index  )  [static]
 

Set default font index.

Parameters:
Index Index of the desired font face in the font file (usually 0)
Returns:
0 when OK

void PG_Application::SetFontName const char *  Name  )  [static]
 

Set default font name.

Parameters:
Name Filename of the font (this function don`t load the font - or check presention of the file !!!)
Returns:
0 when OK

void PG_Application::SetFontSize int  Size  )  [static]
 

Set default font size.

Parameters:
Size size of the font
Returns:
0 when OK

void PG_Application::SetFontStyle PG_Font::Style  Style  )  [static]
 

Set default font style.

Parameters:
Style Binary combination (OR) of PG_FSTYLE_NORMAL, PG_FSTYLE_BOLD, PG_FSTYLE_ITALIC and PG_FSTYLE_UNDERLINE
Returns:
0 when OK

void PG_Application::SetIcon const char *  filename  ) 
 

Set application`s window-manager icon.

Parameters:
filename image file to load Set icon for application`s window-manager window. You must use bitmap with sizes dividable by 8 transparent color with palete. Transparent color is the color of first up-left pixel. THIS FUNCTION MUST BE PROCESSED BEFORE PG_Application::InitScreen()

SDL_Surface* PG_Application::SetScreen SDL_Surface *  screen  ) 
 

Set a custom screen surface.

Parameters:
screen pointer to a surface
Returns:
pointer the new screen surface

CursorMode PG_Application::ShowCursor CursorMode  mode  )  [static]
 

Set or query the type of mouse cursor to use.

This function is used to set or query the type of mouse cursor used. See the documentation for PG_CURSOR_MODE for more details.

Parameters:
mode the new mode for the request
Returns:
the previous cursor mode
Examples:
dblbuffer.cpp, and paratest.cpp.

void PG_Application::Shutdown  )  [protected]
 

Cleanup the application data.

bool PG_Application::UnlockScreen  )  [inline, static]
 

Unlock the screen surface.

Returns:
true - the unlock operation was successful


Member Data Documentation

PG_Font* PG_Application::DefaultFont [static]
 

SignalQuit PG_Application::sigQuit
 

SignalVideoResize PG_Application::sigVideoResize
 

SignalXMLTag PG_Application::sigXMLTag
 



The ParaGUI Project - Alexander Pipelka