NOCL  v0.1.0-2524
Modern C++ Class Library for GUI Projects
nocl::Application Class Referenceabstract

Application-level control. More...

#include <Application.hpp>

Inheritance diagram for nocl::Application:
Collaboration diagram for nocl::Application:

Public Member Functions

virtual ~Application (void)
 Destructor. More...
 
 Application (int argc=0, char **argv=nullptr)
 Constructor. More...
 
 Application (const Application &rhs)=delete
 Cannot copy Application. More...
 
Applicationoperator= (const Application &rhs)=delete
 Cannot assign Application. More...
 
virtual operator GApplication * (void) const
 Convert to GApplication*. More...
 
virtual operator GtkApplication * (void) const
 Convert to GtkApplication*. More...
 
virtual VStr argv (void) const
 Get a vector of all the command line parameters (argv). More...
 
virtual Applicationinitialize (void)=0
 This callback is made on startup once it is safe to create windows and controls. More...
 
virtual int run_message_loop (void)
 Run the message loop. This will only return once the last FrameWindow has been closed. More...
 

Static Public Member Functions

static GtkApplication * gtk_app (void)
 Return the underlying GtkApplication*. More...
 

Static Protected Attributes

static int saved_argc = 0
 Value of argc normally passed into main(). More...
 
static char ** saved_argv = nullptr
 Value of argv normally passed into main(). More...
 
static GtkApplication * gtk_application = nullptr
 Pointer to single GTK+ application. More...
 

Detailed Description

Application-level control.

Constructor & Destructor Documentation

◆ ~Application()

nocl::Application::~Application ( void  )
virtual

Destructor.

References gtk_application.

◆ Application() [1/2]

nocl::Application::Application ( int  argc = 0,
char **  argv = nullptr 
)

Constructor.

Only one of these objects may be constructed. You should have a class that inherits from Application, and then override methods such as initialize().

The argc and argv parameters are provided for convenience, to gain easy access to the command line arguments from anywhere in the application. But neither NOCL nor GTK+ require specific startup parameters, so if you don't need the arguments they can be left empty.

Exceptions
nocl::ExceptionThrows if the application object has already been constructed.
nocl::ExceptionThrows if the GTK+ application cannot be created.

References argv(), gtk_application, initialize(), NOCL_WHERE, saved_argc, and saved_argv.

Here is the call graph for this function:

◆ Application() [2/2]

nocl::Application::Application ( const Application rhs)
delete

Cannot copy Application.

Member Function Documentation

◆ operator=()

Application& nocl::Application::operator= ( const Application rhs)
delete

Cannot assign Application.

◆ operator GApplication *()

nocl::Application::operator GApplication * ( void  ) const
virtual

Convert to GApplication*.

References gtk_application.

◆ operator GtkApplication *()

nocl::Application::operator GtkApplication * ( void  ) const
virtual

Convert to GtkApplication*.

References gtk_application.

◆ argv()

nocl::VStr nocl::Application::argv ( void  ) const
virtual

Get a vector of all the command line parameters (argv).

This will return an empty vector unless argc and argv were provided in the constructor.

References saved_argc, and saved_argv.

Referenced by Application().

Here is the caller graph for this function:

◆ initialize()

nocl::Application & nocl::Application::initialize ( void  )
pure virtual

This callback is made on startup once it is safe to create windows and controls.

One of your classes should inherit from nocl::Application and override nocl::Application::initialize(), possibly to initialize a FrameWindow and other GUI controls that it will need.

Example:

#include <nocl/nocl.hpp>
/* A simple class that inherits from nocl::Application and which has a single
* nocl::FrameWindow as a member. This shows both how to start an application
* and display a top-level frame window to the user.
*/
class MyApp : public nocl::Application
{
public:
/* This callback, which we've inherited from nocl::Application, is
* called once Gtk+ has been fully initialized. This is the place
* to create the necessary GUI controls to show to the user.
*/
virtual MyApp & initialize(void) override
{
frame_window.initialize(*this, "Testing");
frame_window.show();
return *this;
}
nocl::FrameWindow frame_window;
};
int main()
{
MyApp app;
return app.run_message_loop();
}

Referenced by Application().

Here is the caller graph for this function:

◆ run_message_loop()

int nocl::Application::run_message_loop ( void  )
virtual

Run the message loop. This will only return once the last FrameWindow has been closed.

References nocl::Exception::details(), saved_argc, and saved_argv.

Here is the call graph for this function:

◆ gtk_app()

GtkApplication * nocl::Application::gtk_app ( void  )
static

Return the underlying GtkApplication*.

Warning
This will return nullptr if an instance of Application has not yet been created.

References gtk_application.

Member Data Documentation

◆ saved_argc

int nocl::Application::saved_argc = 0
staticprotected

Value of argc normally passed into main().

See also
argv()

Referenced by Application(), argv(), and run_message_loop().

◆ saved_argv

char ** nocl::Application::saved_argv = nullptr
staticprotected

Value of argv normally passed into main().

See also
argv()

Referenced by Application(), argv(), and run_message_loop().

◆ gtk_application

GtkApplication * nocl::Application::gtk_application = nullptr
staticprotected

Pointer to single GTK+ application.

See also
gtk_app()

Referenced by Application(), gtk_app(), operator GApplication *(), operator GtkApplication *(), and ~Application().


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