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

fgl::FGApp Class Reference

#include <fastgl.h>

Inheritance diagram for fgl::FGApp:

Inheritance graph
[legend]
Collaboration diagram for fgl::FGApp:

Collaboration graph
[legend]
List of all members.

Detailed Description

The instance of this class encapsulates the application. You have to declare this construct at the start of your program. See the "Hello World" example.
Examples:

alpha.cpp, bgroup.cpp, bitmap.cpp, buttons.cpp, calc.cpp, cdialog.cpp, connect.cpp, cursor.cpp, double.cpp, editor.cpp, events.cpp, fdialog.cpp, fgcolor.cpp, font.cpp, fontsel.cpp, gears16.cpp, geartrain.cpp, gif.cpp, gradient.cpp, hello.cpp, listbox.cpp, mandel.cpp, modal.cpp, morph3d.cpp, pane.cpp, radio.cpp, regress.cpp, tabpage.cpp, timer.cpp, ttf.cpp, updown.cpp, and widget.cpp.


Public Member Functions

int RemoveMousePointer (void)
void ShowMousePointer (void)
int get_key (void)
void SetDelayProc (void(*fnc)(void))
void UpdateMousePointer (void)
 FGApp (int m, int &argc, char **&argv, int bck, int appFlags=APP_ENABLEALTX)
virtual ~FGApp ()
void __fastcall Run (MainHwnd hwnd=0)
void __fastcall FGYield (void)
void SetTimerProc (TimerProc p, int t=1000)
MODAL_RETURN __fastcall RunModal (FGWindow *which)
const FGMouseCursorCursorLoad (const FGMouseCursor *cur)
int EnableBuffering (int mode)
int Flip (void)
void DisableBuffering (void)
ENUM_OS GetOS (void)
void ResetInputDevice (void)
void LockInput (void)
void UnlockInput (void)
virtual void OnKeyPress (int)
virtual void OnMouseMove (int, int)
virtual void OnClick (int, int)
virtual void OnDoubleClick (int, int)
virtual void OnMiddleButton (int, int)
virtual void OnContextPopup (int, int)
virtual void OnWheel (int x, int y, int delta)
virtual void OnStartDrag (int, int, int)
virtual void OnEndDrag (int, int, int, int, int)
virtual void OnCursorOut (int)
virtual bool OnIdle (void)
virtual void OnTimer (int secs)
virtual void OnTabSwitch (const char *)

Static Public Member Functions

static FGWindowGetCurrentWindow (void)
static void SaveScreen (void)
static void DisableCtrlBreak (void)
static void SetWindowMoveStyle (int a)
static void __fastcall SendToApp (FGEvent *x)
static void AppDone (void)
static void AppClose (void)
static FGWindowGetRootWindow (void)
static int GetMouseX (void)
static int GetMouseY (void)
static bool IsShift (void)
static bool IsCtrl (void)
static bool IsAlt (void)
static void set_mmx (void)
static void reset_mmx (void)
static int test_mmx (void)
static void SetCaption (char *new_name)
static void GetDragVector (int &x, int &y, int &w, int &h)
static void SetDragShape (void(*a)(int, int, int, int)=0)
static void SetRepeatDelay (int c1, int c2)
static void SetInputDevice (FGInputDevice *idev)

Static Public Attributes

static const FGMouseCursor__fg_cursor = idc_normal
static int flags
static int video
static int background
static int Argc
static char ** Argv
static char * name
static char * homedir = 0
static char currdir [pathsize]
static int ttf_support = 0

Static Protected Member Functions

static void SetCurrentWindow (FGWindow *novy)
static void RemoveIterator (FGWindow *wnd)
static FGWindowIterator GetIterator (FGWindow *Colise)
static FGWindowRIterator GetRIterator (FGWindow *Colise)
static FGWindowWindowFind (FGEvent *e)
static FGWindowGetLastWindow (void)
static FGWindowWindowFind (int idw)
static void __fastcall intersect (FGWindow *This, int, int, int, int)
static __fastcall int _over (int, int, int, int, int xx, int yy, int ww, int hh)
static FGWindowOverSprite (FGWindowRIterator This, FGWindowRIterator _od, int x, int y, int w, int h)
static FGWindow *__fastcall OdkryteOkno (FGWindowRIterator This, FGWindowRIterator pokial, int x, int y, int w, int h)
static void __fastcall DestroyWindow (void)
static int NumberOfWindow (void)
static void AddWindowToList (FGWindow *wnd, int where)


Constructor & Destructor Documentation

fgl::FGApp::FGApp int  m,
int &  argc,
char **&  argv,
int  bck,
int  appFlags = APP_ENABLEALTX
 

Construct the instance of applicaton object. There is allowed only one instantion per process only. The following steps are executed at the constructor time:

  • if possible, the window database is accessed. This contains last sizes and positions for registered windows
  • if possible, the application configuration is loaded from appname.rc file
  • command line parameters are parsed, and arguments from the list of system parameters are extracted (consult the "reserved parameters" chapter for details)
  • test for the availability of MMX processor and type of graphics card is performed
  • the screen is switched to graphics mode
  • if 8-bit colors are compiled/used, the color palette management is initialized
  • screen is cleared
  • mouse is checked and, if present, it is passed to the system
  • call to SetColorFuzzy() is performed
  • the ROOTWINDOW is created if needed
  • reset the Timer and FGClock() routines
  • release the root UID on LINUX or Solaris
  • global variables cApp and cCfg are set.
  • load the default mouse cursor
  • init TrueType font system (if enabled in compile time)

AppFlags values - should be OR-ed together:

  • APP_WINDOWDATABASE - enable saving the size and position to the window database
  • APP_CFG - enable configuration file management
  • APP_MAGNIFIER - enable mouse drags with rubber-band rectangle selection
  • APP_ROOTWINDOW - enable drawing to the root window - the whole screen
  • APP_ENABLEALTX - enable termination by <ALT+X> key press
  • APP_LOCALDIR - all Config files will be placed in current directory instead in the HOMEDIR

Parameters:
m number of the graphics mode (valid mode number values are described bellow). Look for graph_set_mode function.
argv parameter is standard "C" command line parameter
argc parameter is standard "C" command line parameter
bck defines the initial color of the screen background.
appFlags set of a bit flags that defines the behaviour of your application. The the meaning of bit flags is described in the table below.

fgl::FGApp::~FGApp  )  [virtual]
 

This is called when the application terminates. It performs the following steps:

  • resets the app timer
  • resets color palette
  • closes windows database
  • closes config file
  • resets the windowing system
  • call system's 'sync()' to flus all disk operations


Member Function Documentation

void fgl::FGApp::AddWindowToList FGWindow wnd,
int  where
[static, protected]
 

add Window to the list, where = { FRONT, BACK }

static void fgl::FGApp::AppClose void   )  [inline, static]
 

Close the inner most FGApp loop only.

static void fgl::FGApp::AppDone void   )  [inline, static]
 

Call this methods, for example, from menu item "EXIT". When it is once called, it will causes jump out of the main application loop - return from Run().

Examples:
bgroup.cpp, bitmap.cpp, buttons.cpp, gears16.cpp, geartrain.cpp, gradient.cpp, newapi.cpp, timer.cpp, and updown.cpp.

const FGMouseCursor * fgl::FGApp::CursorLoad const FGMouseCursor cur  ) 
 

Load & set the new mouse pointer.

void __fastcall fgl::FGApp::DestroyWindow void   )  [static, protected]
 

internal

void fgl::FGApp::DisableBuffering void   ) 
 

Disable video buffering and release the used video memory.

static void fgl::FGApp::DisableCtrlBreak void   )  [inline, static]
 

By default, after <CTRL+C> hitting application normally shutdowns. You can switch this behaviour on/off by single calling this method.

int fgl::FGApp::EnableBuffering int  mode  ) 
 

Enable drawing into the off-screen video RAM. This feature is intended for flickerless full screen animation. Parameter mode is one of these predefined:

enum { FG_DOUBLEBUFFER, FG_TRIPLEBUFFER, FG_QUADBUFFER };

More buffers may help for speed but is X-times memory hungry and not the all videocards supports it. On exit, return number of true allocated buffers (0 if error). You can still use BUFFERING mode when function fail but screen will flicker - all drawing goes to the visible screen.

void __fastcall fgl::FGApp::FGYield void   ) 
 

Peeks the user input, translate to EVENT if any and push this EVENT to the event list. You can use this procedure to allowing mouse move when system is busy in your code and don't respond to user. By example, when some progressbar is running.

int fgl::FGApp::Flip void   ) 
 

Call this routine when all objects of the scene are drawn. The buffer will be showed at the next screen vertical retrace. Return 0 if fail - no buffering is allowed/initialized.

int fgl::FGApp::get_key void   ) 
 

Test keyboard immediately. Try peek any KEY from the INPUT and return 0 if none, or its keycode.

FGWindow * fgl::FGApp::GetCurrentWindow void   )  [static]
 

Returns current focussed FGWindow if any.

Examples:
rad_prj.cpp.

void fgl::FGApp::GetDragVector int &  x,
int &  y,
int &  w,
int &  h
[static]
 

Set variables with actual data. It is dependent on the app flag APP_MAGNIFIFIER.

Parameters:
x position of top left corner
y position of top left corner
w the width of selected rectangle that is showed when you drag mouse with button hold-down.
h the height of selected rectangle that is showed when you drag mouse with button hold-down.
Examples:
fgv.cpp.

static int fgl::FGApp::GetMouseX void   )  [inline, static]
 

Returns current mouse coordinate in X axis.

Examples:
mandel.cpp.

static int fgl::FGApp::GetMouseY void   )  [inline, static]
 

Returns current mouse coordinate in Y axis.

Examples:
mandel.cpp.

ENUM_OS fgl::FGApp::GetOS void   ) 
 

Return current Operating system code. Code is one from these OS types.

static FGWindow* fgl::FGApp::GetRootWindow void   )  [inline, static]
 

Returns pointer to the ROOT window or 0 if one is not initialized. Be sure before using this function, that you add switch APP_ROOTWINDOW to the FGApp constructor else program will be aborted. You can draw using this pointer with standard window stuff (WindowLine (), WindowText () etc.) NOTE: You can't use any Controls into this window, it is only for drawing! You can initialize one in FGApp constructor time by passing APP_ROOTWINDOW as flags.

Returns:
pointer to whole screen window ROOT.
Examples:
alpha.cpp, fgcolor.cpp, font.cpp, fontsel.cpp, and gif.cpp.

void __fastcall fgl::FGApp::intersect FGWindow This,
int  ,
int  ,
int  ,
int 
[static, protected]
 

params are real size & position of cleared window

bool fgl::FGApp::IsAlt void   )  [static]
 

Returns:
true if the key is pressed at the time.

bool fgl::FGApp::IsCtrl void   )  [static]
 

Returns:
true if the key is pressed at the time.

bool fgl::FGApp::IsShift void   )  [static]
 

Returns:
true if the key is pressed at the time.

FGWindow *__fastcall fgl::FGApp::OdkryteOkno FGWindowRIterator  This,
FGWindowRIterator  pokial,
int  x,
int  y,
int  w,
int  h
[static, protected]
 

Called from WindowRepaint() for the window overlap testing.

virtual void fgl::FGApp::OnClick int  ,
int 
[inline, virtual]
 

overload this member when you want catch the click on left mouse's button event.

virtual void fgl::FGApp::OnContextPopup int  ,
int 
[inline, virtual]
 

overload this member when you want catch the click on right mouse's button event.

virtual void fgl::FGApp::OnCursorOut int   )  [inline, virtual]
 

overload this member when you want catch the cursor arrives screen boundary.

virtual void fgl::FGApp::OnDoubleClick int  ,
int 
[inline, virtual]
 

overload this member when you want catch the double click on left mouse's button event.

virtual void fgl::FGApp::OnEndDrag int  ,
int  ,
int  ,
int  ,
int 
[inline, virtual]
 

overload this member when you want catch the end of mouse drag.

virtual bool fgl::FGApp::OnIdle void   )  [inline, virtual]
 

The wrapper for an application idle proc.

Returns:
If you override this on in your class and you call some code from it you must return true from this callback to know that the system will not wait. Elsewhere your system may go slowdown.
Note:
if call SetDelayProc() with non-null argument then this callback will not be called!
See also:
SetDelayProc()

virtual void fgl::FGApp::OnKeyPress int   )  [inline, virtual]
 

overload this member when you want catch any keypress event.

virtual void fgl::FGApp::OnMiddleButton int  ,
int 
[inline, virtual]
 

overload this member when you want catch the click on middle mouse's button event.

virtual void fgl::FGApp::OnMouseMove int  ,
int 
[inline, virtual]
 

overload this member when you want catch any mousemove event.

virtual void fgl::FGApp::OnStartDrag int  ,
int  ,
int 
[inline, virtual]
 

overload this member when you want catch the start of mouse drag.

virtual void fgl::FGApp::OnTabSwitch const char *   )  [inline, virtual]
 

override this member when you want to handle the TabPage switch

virtual void fgl::FGApp::OnTimer int  secs  )  [inline, virtual]
 

The wrapper for application timer proc.

Note:
if call SetTimerProc() with non-null first argument then this callback will not be called! The default time slice is 1000 msec. You can change this by call SetTimerProc() fith first argument null and second with number of msecs for a new timeslice.
Parameters:
secs in secs from the start of app.
See also:
SetTimerProc()

virtual void fgl::FGApp::OnWheel int  x,
int  y,
int  delta
[inline, virtual]
 

overload this member when you want catch the mouses wheel spin.

FGWindow * fgl::FGApp::OverSprite FGWindowRIterator  This,
FGWindowRIterator  _od,
int  x,
int  y,
int  w,
int  h
[static, protected]
 

Test overlaping window, called from OdkryteOkno only.

int fgl::FGApp::RemoveMousePointer void   ) 
 

Hide mouse pointer if needed.

void __fastcall fgl::FGApp::Run MainHwnd  hwnd = 0  ) 
 

When you create the instance of the FGApp class and you sets callback for "DelayProc" , it is a right time to call the main application loop. System starts processing the user input (keyboard & mouse) until you call AppDone(). The mouse's movements are automatically convert to move its pointer at the screen and you don't care about it. When you press left button at the FGControl (by example FGPushButton), system detects it, and sends right event to the appropriate window. When you press button on an empty area of the window, this one will get event CLICKLEFTEVENT. This events are send to the application procedure, when one is defined.

Parameters:
hwnd the pointer at this mysterious procedure.
Examples:
ttf.cpp, and updown.cpp.

MODAL_RETURN __fastcall fgl::FGApp::RunModal FGWindow which  ) 
 

Run modal this FGWindow until closed or any FGControl.

Parameters:
which your FGWindow with the 'OK' and 'Cancel' buttons by example.
Returns:
one of predefined values (mrClose, mrQuit or mrNone)

void fgl::FGApp::SaveScreen void   )  [static]
 

Save the whole screen to the image file in the current directory, name is created as current time in HEX form. This function is called by application automagically when you press PRINT_SCREEN key.

void __fastcall fgl::FGApp::SendToApp FGEvent x  )  [static]
 

When you define the application procedure also, you can send to this procedure any event by this method.

void fgl::FGApp::SetCaption char *  new_name  )  [static]
 

Set caption when application running in windowed mode (X11 or WIN32 GDI).

void fgl::FGApp::SetDelayProc void(*)(void)  fnc  )  [inline]
 

Set the procedure that will be call many times per second when application will be idle. When the system is waiting to user input, it waits into inner loop. Because this time, I add to the library little hack. You can define some very little bit of code, procedure that will be called many times per second. Call with parameter 0 to switch this feature off.

Parameters:
fnc your callback procedure of type void (*fnc)(void).

void fgl::FGApp::SetDragShape void(*)(int, int, int, int)  a = 0  )  [static]
 

Set procedure that will be called when you drag&drop to draw out dragging object. This procedures has four argument x,y for position in the current window and offset_y, offset_x are current offset from [x,y]. To restore default, use with argument 0. For more see the RAD project - source rad_prj.cpp.

void fgl::FGApp::SetRepeatDelay int  c1,
int  c2
[static]
 

Use this for fine calibration for HOLD_EVENT event.

void fgl::FGApp::SetTimerProc TimerProc  p,
int  t = 1000
[inline]
 

This is another call-back procedure that will be call per each 't' msec. Your user-defined procedure expects one int parameter - number of second from the start of your program. Call with parameter 0 switch this feature off. NOTE! resolution is cca. 20ms

Parameters:
p the callback routine
t number of milisec. between two calls the callback (default is 1 sec.)

static void fgl::FGApp::SetWindowMoveStyle int  a  )  [inline, static]
 

To change window drawing when WindowMove event is performed.

Parameters:
a true for opaque, false for window frame drawing only (fast).

void fgl::FGApp::ShowMousePointer void   ) 
 

Redraw mouse pointer unconditionally.

int fgl::FGApp::test_mmx void   )  [static]
 

try support of MMX for your CPU

void fgl::FGApp::UpdateMousePointer void   ) 
 

Redraw mouse pointer if needed.

FGWindow * fgl::FGApp::WindowFind int  idw  )  [static, protected]
 

Finds the FGWindow by ID.

FGWindow * fgl::FGApp::WindowFind FGEvent e  )  [static, protected]
 

Returns the FGWindow for that the events has been emited.


Member Data Documentation

int fgl::FGApp::Argc [static]
 

Standard C 'argc' on startup.

char ** fgl::FGApp::Argv [static]
 

Standard C 'argv' on startup.

int fgl::FGApp::background [static]
 

The color of application background.

char fgl::FGApp::currdir [static]
 

The application's starts directory.

int fgl::FGApp::flags [static]
 

Internal flags.

char * fgl::FGApp::homedir = 0 [static]
 

Home directory (e.g. '/home/user' or '/root' ).

char * fgl::FGApp::name [static]
 

Name of the application exefile.

int fgl::FGApp::ttf_support = 0 [static]
 

true/false if TrueType fonts are supported.

int fgl::FGApp::video [static]
 

Videomode number that is used for application.


Generated on Wed Feb 9 11:31:48 2005 for OpenGUI by  doxygen 1.4.0