dbp::gui_application Class Reference

GUI (Graphical User Interface) application class. More...

#include <gui_application.h>

Inheritance diagram for dbp::gui_application:
Inheritance graph
[legend]
Collaboration diagram for dbp::gui_application:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void set_name (const std::string &app_name)
 Set application name.
virtual void set_description (const std::string &description)
 Set application description.
virtual void register_cmdline_parameter (const cmdline_parameter &param, application_int::cmdline_parameter_handler handler)
 Register the application command line parameter.
virtual void on_execute (on_execute_handler handler)
 Register the application main execute cycle handler.
virtual void on_exception (on_exception_handler handler)
 Register the exception handler.
virtual int run (int argc, char *argv[])
 Execute the application.
widget_factoryfactory ()
 Reference to the widget factory.

Friends

class singleton< gui_application >

Detailed Description

GUI (Graphical User Interface) application class.

This is a platform-independed GUI application class. It is needed to create applications with graphical interface, for example:

/*
 * Classic "Hello, world!" example application with graphical user interface.
 *
 * This example shows how to write "skeleton" of the application with
 * DCL framework using dbp::application class.
 *
 * As the result, the simple GUI application will be produced.
 */

#include <iostream>
#include <string>

// include all classes from dclbase library
#include <dcl/dclbase.h>
#include <dcl/gui_application.h>

// use the DCL default namespace by default
using namespace dbp;

// declare our own application class
class hello_world_app {
public:
        // the constructor of the hello_world_app class initializes the
        // console application by obtaining a link to the dbp::application class
        // via its instance() method call.
        hello_world_app(): app(gui_application::instance()) {
                // set the application name
                app.set_name(_("Hello World GUI Application"));
                // set the application description
                app.set_description(_("Prints a classic greeting"));
                // register the execute event handler
                app.on_execute(create_delegate(this, &hello_world_app::on_execute));
        }
        // the reference to the console application class
        gui_application &app;
private:
        // execute event handler
        int on_execute() {
                widget_factory::message_box_ptr m =
                  app.factory().create_message_box(("Hello"), _("Hello, world!"),
                  message_type::info);
                return m->execute();
        };
};

// initialize and run the application via provided macros
IMPLEMENT_APP(hello_world_app().app);

Member Function Documentation

widget_factory& dbp::gui_application::factory (  )  [inline]

Reference to the widget factory.

You can obtain a reference to the GUI widget factory class to create any widgets supported by the DCL.

Returns:
the reference to the widget factory.
virtual void dbp::gui_application::on_execute ( on_execute_handler  handler  )  [inline, virtual]

Register the application main execute cycle handler.

You need to register your own application execution handler with application logic.

See the 'examples/hello_world/console_application' directory for the sample code.

Parameters:
handler an execute command delegate.

Implements dbp::application_int.

virtual void dbp::gui_application::register_cmdline_parameter ( const cmdline_parameter param,
application_int::cmdline_parameter_handler  handler 
) [inline, virtual]

Register the application command line parameter.

You can register one or more command line parameters supported by your application. When application starts, it checks of command line parameters passed for registered ones. If none is found, it reports about invalid command line parameter; if registered one is found, on_cmdline_parameter handler is called.

See the 'examples/hello_world/console_application' directory for the sample code using this method.

Parameters:
param the command line parameter to register.
handler a command line parameter delegate.

Implements dbp::application_int.

virtual void dbp::gui_application::set_description ( const std::string &  description  )  [inline, virtual]

Set application description.

Parameters:
description a brief application description for displaying purposes.

Implements dbp::application_int.

virtual void dbp::gui_application::set_name ( const std::string &  name  )  [inline, virtual]

Set application name.

The application name is used for displaying purposes. The internationalization (i18n) resources path (catalog) is also initialized from the application name.

Parameters:
name the name of the application.

Implements dbp::application_int.


The documentation for this class was generated from the following file:

 
Support This Project
SourceForge.net Logo