#include <LgiClasses.h>
Inherits GAppI, and OsApplication.
Public Member Functions | |
bool | IsOk () |
Returns true if the GApp object initialized correctly. | |
OsProcessId | GetProcessId () |
Returns this processes ID. | |
OsThreadId | GetGuiThread () |
Returns the thread currently running the active message loop. | |
GApp (const char *MimeType, OsAppArguments &AppArgs, GAppArguments *ObjArgs=0) | |
Construct the object. | |
virtual | ~GApp () |
Destroys the object. | |
char * | GetName () |
void | SetName (const char *Name) |
const char * | GetLgiVersion () |
Returns the version of Lgi used. String returned is in the form '#.#.#'. | |
void | SetAppArgs (OsAppArguments &AppArgs) |
Resets the arguments. | |
OsAppArguments * | GetAppArgs () |
Returns the arguemnts. | |
char * | GetArgumentAt (int n) |
Returns the n'th argument as a heap string. Free with DeleteArray(...). | |
bool | Run (bool Loop=true, OnIdleProc IdleCallback=NULL, void *IdleParam=NULL) |
Enters the message loop. | |
void | OnCommandLine () |
Event called to process the command line. | |
void | OnReceiveFiles (GArray< char * > &Files) |
Event called to process files dropped on the application. | |
void | Exit (int Code=0) |
Exits the event loop with the code specified. | |
bool | GetOption (const char *Option, GAutoString &Buf) |
Parses the command line for a switch. | |
bool | GetOption (const char *Option, char *Dst=0, int DstSize=0) |
Parses the command line for a switch. | |
GXmlTag * | GetConfig (const char *Tag) |
Gets the application conf stored in lgi.conf. | |
void | SetConfig (GXmlTag *Tag) |
Sets a single tag in the config. (Not written to disk). | |
GViewI * | GetFocus () |
Gets the control with the keyboard focus. | |
GAutoString | GetFileMimeType (const char *File) |
bool | GetAppsForMimeType (char *Mime, GArray< GAppInfo * > &Apps) |
Gets the applications that can handle a file of a certain mime type. | |
int32 | GetMetric (int Metric) |
Get a system metric. | |
GMouseHook * | GetMouseHook () |
Get the mouse hook instance. | |
class GSymLookup * | GetSymLookup () |
Gets the singleton symbol lookup class. | |
Static Public Member Functions | |
static GApp * | ObjInstance () |
Use 'LgiApp' to return a pointer to the GApp object. | |
Public Attributes | |
GFont * | SystemNormal |
The system font. | |
GFont * | SystemBold |
The system font in bold. | |
GWindow * | AppWnd |
Pointer to the applications main window. | |
Friends | |
class | GView |
class | GMouseHook |
This should be the first class you create, passing in the arguments from the operating system. And once your initialization is complete the 'Run' method is called to enter the main application loop that processes messages for the life time of the application.
GApp::GApp | ( | const char * | MimeType, | |
OsAppArguments & | AppArgs, | |||
GAppArguments * | ObjArgs = 0 | |||
) |
Construct the object.
MimeType | The application's mime type. Typically 'application/x-[appname]'. This is mostly ignored on Win32 and Linux, but is useful on BeOS. |
AppArgs | The arguments passed in by the OS. |
ObjArgs | Optional args |
References AppWnd, GTypeFace::Bold(), GFont::Create(), GFontType::Create(), GetOption(), GFontType::GetSystemFont(), MB_OK, SetAppArgs(), SystemBold, SystemNormal, and GTypeFace::Transparent().
char * GApp::GetName | ( | ) |
Gets the application name, by default it will be generated from the mime type, but can also be set by calling GApp::SetName
References DIR_CHAR.
void GApp::SetName | ( | const char * | Name | ) |
Set the application name. This is currently used to generate the leaf folder for LSP_APP_ROOT
bool GApp::Run | ( | bool | Loop = true , |
|
OnIdleProc | IdleCallback = NULL , |
|||
void * | IdleParam = NULL | |||
) |
Enters the message loop.
Loop | If true this function will return when the application exits (with LgiCloseApp()). Otherwise if false only pending events will be processed and then the function returns. |
IdleCallback | Idle callback |
IdleParam | Param for IdleCallback |
void GApp::Exit | ( | int | Code = 0 |
) |
Exits the event loop with the code specified.
Code | The application exit code. |
bool GApp::GetOption | ( | const char * | Option, | |
GAutoString & | Buf | |||
) |
Parses the command line for a switch.
Option | The option to look for. |
Buf | The buffer to receive the value. |
References IsOk().
Referenced by GApp(), and GetOption().
bool GApp::GetOption | ( | const char * | Option, | |
char * | Dst = 0 , |
|||
int | DstSize = 0 | |||
) |
Parses the command line for a switch.
Option | The option to look for. |
Dst | The buffer to receive the value of the command line parameter or NULL if you don't care. |
DstSize | The buffer size in bytes |
References GetOption().
GAutoString GApp::GetFileMimeType | ( | const char * | File | ) |
Gets the MIME type of a file
File | The file to identify |
References GArray< Type >::Length(), LGI_PATH_SEPARATOR, GStringPipe::NewStr(), and GProcess::Run().
int32 GApp::GetMetric | ( | int | Metric | ) |
Get a system metric.
Metric | One of LGI_MET_DECOR_X, LGI_MET_DECOR_Y |
References LGI_MET_DECOR_CAPTION, LGI_MET_DECOR_X, and LGI_MET_DECOR_Y.