Application Context (must be created first). More...
Public Member Functions | |
GApp (int argc, const char **argv) | |
Inits the application context; must be called before creating any other object. | |
int | start (GWindow &main_window) |
Starts the event loop This function is blocking and must be called last. | |
Static Public Member Functions | |
static int | status () |
Returns the value given as an argument to exit(). | |
static bool | hasArg (GString const &name) |
Searches if one of the arguments of the command line is name. More... | |
static bool | hasArg (GString const &name, GString &value, GString const &assign="=") |
Searches if one of the arguments of the command line is name or name=value. More... | |
static GDim | screenSize () |
Returns the size of the main screen. | |
static GWindow * | mainWindow () |
Returns the Main Window. More... | |
static Gadget * | currentFocus () |
Returns the gadget having the focus (null otherwise). | |
static void | updateAll () |
Requests all gadgets to be repainted. More... | |
static void | paintAll () |
Immediately repaints all gadgets. More... | |
static void | exec (GFunction const &fun) |
Executes a function in the main thread. More... | |
static void | sleep (GTime milliseconds) |
Makes the thread where this function is called to sleep for the specified value (in milliseconds). More... | |
static void | error (GString const &where, GString const &message, GObject const *={}) |
Prints an error message. More... | |
static void | onError (std::function< void(GString const &where, GString const &message, GObject const *object)> fun) |
Changes the function that manages errors. More... | |
static void | onException (std::function< void(GString const &type, GString const &message, bool isGFatalError)> fun) |
Changes the function that manages exceptions. More... | |
static class GInspector & | inspector () |
Allows inspecting gadgets. More... | |
static void | showInspector () |
Shows gadget inspector. | |
static void | close () |
Closes or quits the application. More... | |
static GStrings const & | resourceDirs () |
Directories where files (CSS, icons, etc.) are searched by default. | |
static GString const & | guitDir () |
Returns the user's Guit directory. More... | |
static GString const & | appDir () |
Returns guitDir()/execName() The ! magic character refers to this directory. More... | |
static GString | execName () |
Returns the name and the path of the executable. More... | |
static int | argc () |
Returns the arguments of the command line. More... | |
static bool | addCssFile (GString const &css_file) |
Adds CSS. | |
Application Context (must be created first).
The app context must be created before creating any Guit object, as in the example below:
CSSs should be loaded before creating the gadgets.
Files (CSSs, icons, etc.) that do not start with / \ . and magic characters ~ : ! are searched in the application resource directory (MacOSX only), then in guit-dir/exec-name where guit-dir is the Guit directory of the user, and exec-name the name of the executable. guit-dir is located here:
Magic characters must be the first character of a file name:
start() starts the event loop and blocks until the application is terminated. start() returns a status which is usually 0 (see quit() and exit()). Its argument must derive from GWindow and should be created in the heap (i.e. using new). This window will be the main window of the application. By default, the application is terminated when this window is closed. This can be changed by adding a GQuitDialog to it or on::done callbacks (see GWindow).
Example:
A CSS class (.mypanel) and/or ID (#mywin) can be given as an argument to the gadget constructors. They can be followed by text that will be the title or value of the gadget (eg the title of a GWindow/GBox, the text of a GButton/GItem/GTextField, the value of a GSlider/GChartItem)
VBox(), TextField(), Button(), etc. are shortcut functions that instantiate the corresponding class. For instance, Button("Click me") is equivalent to: * new GButton("Click Me"). Note that classes start with a 'G', contrary to shortcut functions.
Guit relies on TrueType fonts. A font list cache is created in the users' Guit directory the first type a Guit application is launched. It should be removed when new fonts are added to the system, so that it can be built again.
|
static |
Closes or quits the application.
|
static |
Returns the user's Guit directory.
Returns:
|
static |
Returns guitDir()/execName() The ! magic character refers to this directory.
|
static |
Returns the name and the path of the executable.
execPath() returns argv[0] and execName() its basename().
|
static |
Returns the arguments of the command line.
|
static |
Searches if one of the arguments of the command line is name.
Note that arvg(0) is ignored.
|
static |
Searches if one of the arguments of the command line is name or name=value.
|
static |
Returns the Main Window.
The main window is the argument that was provided to start().
|
static |
Requests all gadgets to be repainted.
repaintAll().
|
static |
Immediately repaints all gadgets.
|
static |
Executes a function in the main thread.
calls gexec().
|
static |
Makes the thread where this function is called to sleep for the specified value (in milliseconds).
calls gsleep().
|
static |
Prints an error message.
calls gerror(). By default, errors are printed on std::cerr. onError() changes how errors are managed.
|
static |
Changes the function that manages errors.
|
static |
Changes the function that manages exceptions.
|
static |
Allows inspecting gadgets.
A Meta-click or a Cmd-click (depending on the OS) on a gedget will open the inspector.