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

Top level frame window. More...

#include <FrameWindow.hpp>

Inheritance diagram for nocl::FrameWindow:
Collaboration diagram for nocl::FrameWindow:

Public Member Functions

virtual ~FrameWindow (void)
 Destructor. More...
 
 FrameWindow (void)
 Default (empty) constructor which does not fully construct a frame window. More...
 
 FrameWindow (nocl::Application &app, const std::string &title_text)
 This constructor is the same as calling the empty constructor immediately followed by a call to nocl::FrameWindow::initialize(). More...
 
virtual operator GtkApplicationWindow * (void) const
 Convert this object to GtkApplicationWindow*. More...
 
virtual FrameWindow & initialize (nocl::Application &app, const std::string &title_text)
 Complete the creation of a frame window. More...
 
virtual operator GtkWindow * (void) const
 Convert this object to GtkWindow*. More...
 
virtual Window & resize (const Size &s)
 Resizes a window. More...
 
virtual Window & resize (const int width, const int height)
 Resizes a window. More...
 
virtual Window & resizable (const bool toggle=true)
 Give the window a resizable border. More...
 
virtual bool is_resizable (void) const
 Determine whether or not the window can be resized by dragging the border. More...
 
virtual std::string title (void) const
 Get the titlebar text. More...
 
virtual Window & title (const std::string &title_text)
 Set the text displayed in the titlebar. More...
 
virtual operator GtkContainer * (void) const
 Convert an instance of Container to GtkContainer*. More...
 
virtual Container & add_child (GUIComponent &child)
 Add a child component to this container. More...
 
virtual Container & remove_child (GUIComponent &child)
 Remove a child component from this container. More...
 
virtual operator GtkWidget * (void) const
 Convert an instance of GUIComponent to GtkWidget*. More...
 
virtual GUIComponent & move_to (const Point &p)
 Move to the specified coordinates. More...
 
virtual Size natural_size (void)
 Get the natural size of a widget. More...
 
virtual Size minimum_size (void)
 Get the minimum size of a widget. More...
 
virtual GUIComponent & minimum_size (const Size &s)
 Set the minimum size of a widget. More...
 
virtual GUIComponent & minimum_size (const int width, const int height)
 Set the minimum size of a widget. More...
 
virtual GUIComponent & show (const bool toggle=true)
 Make the immediate component visible. More...
 
virtual GUIComponent & show_all (const bool toggle=true)
 Make the component and all child components visible. More...
 
virtual GUIComponent & hide (void)
 Hide a single component. More...
 
virtual bool is_visible (void) const
 Determine if the widget is shown. More...
 

Static Public Member Functions

static WidgetToGUIComponentMap & widget_to_gui_component_map (void)
 There are times when we have a pointer to a Gtk+ widget, and we need to map it back to the corresponding NOCL GUI component. More...
 

Public Attributes

std::set< GUIComponent * > children
 Keep track of all children that have been added to this container. More...
 
Container * parent
 Pointer to the parent to which we've been added. Will be nullptr if this object hasn't been added to a parent container. More...
 
GtkWidget * gtk_widget
 Pointer to the underlying GTK framework. More...
 

Detailed Description

Top level frame window.

This corresponds to GtkApplicationWindow. Applications normally have at least one of these windows.

Example:

FrameWindow.png
#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();
}
See also
https://developer.gnome.org/gtk3/stable/GtkApplicationWindow.html

Constructor & Destructor Documentation

◆ ~FrameWindow()

nocl::FrameWindow::~FrameWindow ( void  )
virtual

Destructor.

◆ FrameWindow() [1/2]

nocl::FrameWindow::FrameWindow ( void  )

Default (empty) constructor which does not fully construct a frame window.

Note that this constructor leaves the frame window object in a semi-constructed state. From a C++ point of view the object is fully constructed, but the internal Gtk+ frame window pointer is still nullptr. The actual GUI frame window component is only instantiated once nocl::FrameWindow::initialize() is called. This constructor is provided to alleviate a chicken-and-egg problem between nocl::Application and nocl::FrameWindow.

Warning
A FrameWindow object created using this constructor does not actually have a corresponding GUI frame window until nocl::FrameWindow::initialize() has been called! Do not attempt to use the frame window object until nocl::FrameWindow::initialize() has completed the object initialization. In normal situations, this is done in nocl::Application::initialize().
See also
nocl::Application::initialize()
nocl::FrameWindow::initialize()

◆ FrameWindow() [2/2]

nocl::FrameWindow::FrameWindow ( nocl::Application &  app,
const std::string &  title_text 
)

This constructor is the same as calling the empty constructor immediately followed by a call to nocl::FrameWindow::initialize().

Do not call nocl::FrameWindow::initialize() on FrameWindow objects that use this constructor.

References initialize().

Here is the call graph for this function:

Member Function Documentation

◆ operator GtkApplicationWindow *()

nocl::FrameWindow::operator GtkApplicationWindow * ( void  ) const
virtual

Convert this object to GtkApplicationWindow*.

This will return nullptr if the frame window hasn't been fully constructed.

See also
initialize()
Exceptions
nocl::ExceptionObject was not created correctly and cannot be converted to GtkApplicationWindow*.

References nocl::GUIComponent::gtk_widget, and NOCL_WHERE.

◆ initialize()

nocl::FrameWindow & nocl::FrameWindow::initialize ( nocl::Application &  app,
const std::string &  title_text 
)
virtual

Complete the creation of a frame window.

This only needs to be called if the default empty constructor for FrameWindow was used.

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();
}
Warning
If the constructor used is the one that takes a reference to Application and a title, then do not call initialize()!
Exceptions
nocl::ExceptionThrows if initialize() is called twice.
nocl::ExceptionThrows if Gtk+ fails to create a new application window.

References nocl::GUIComponent::gtk_widget, NOCL_WHERE, and nocl::Window::title().

Referenced by FrameWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator GtkWindow *()

nocl::Window::operator GtkWindow * ( void  ) const
virtualinherited

Convert this object to GtkWindow*.

Exceptions
nocl::ExceptionThrows if the Gtk+ widget is not a GtkWindow.

References nocl::GUIComponent::gtk_widget, and NOCL_WHERE.

◆ resize() [1/2]

nocl::Window & nocl::Window::resize ( const Size &  s)
virtualinherited

Resizes a window.

References nocl::Size::height, and nocl::Size::width.

◆ resize() [2/2]

nocl::Window & nocl::Window::resize ( const int  width,
const int  height 
)
virtualinherited

Resizes a window.

◆ resizable()

nocl::Window & nocl::Window::resizable ( const bool  toggle = true)
virtualinherited

Give the window a resizable border.

Parameters
[in]toggleWhen set to false, the window cannot be resized by the user. The default window border is resizable.

References nocl::GUIComponent::gtk_widget.

◆ is_resizable()

bool nocl::Window::is_resizable ( void  ) const
virtualinherited

Determine whether or not the window can be resized by dragging the border.

References nocl::GUIComponent::gtk_widget.

◆ title() [1/2]

std::string nocl::Window::title ( void  ) const
virtualinherited

Get the titlebar text.

Referenced by initialize().

Here is the caller graph for this function:

◆ title() [2/2]

nocl::Window & nocl::Window::title ( const std::string &  title_text)
virtualinherited

Set the text displayed in the titlebar.

◆ operator GtkContainer *()

nocl::Container::operator GtkContainer * ( void  ) const
virtualinherited

Convert an instance of Container to GtkContainer*.

Exceptions
nocl::ExceptionObject was not created correctly and cannot be converted to GtkContainer*.

References nocl::GUIComponent::gtk_widget, and NOCL_WHERE.

◆ add_child()

nocl::Container & nocl::Container::add_child ( GUIComponent &  child)
virtualinherited

Add a child component to this container.

Exceptions
nocl::ExceptionChild-parent hierarchy doesn't make sense.

Reimplemented in nocl::Grid, nocl::Fixed, and nocl::Layout.

References nocl::Container::children, NOCL_WHERE, nocl::GUIComponent::parent, and nocl::Container::remove_child().

Here is the call graph for this function:

◆ remove_child()

nocl::Container & nocl::Container::remove_child ( GUIComponent &  child)
virtualinherited

Remove a child component from this container.

References nocl::Container::children, and nocl::GUIComponent::parent.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::~Container(), and nocl::GUIComponent::~GUIComponent().

Here is the caller graph for this function:

◆ operator GtkWidget *()

nocl::GUIComponent::operator GtkWidget * ( void  ) const
virtualinherited

Convert an instance of GUIComponent to GtkWidget*.

References nocl::GUIComponent::gtk_widget.

◆ move_to()

nocl::GUIComponent & nocl::GUIComponent::move_to ( const Point &  p)
virtualinherited

Move to the specified coordinates.

Todo:

◆ natural_size()

nocl::Size nocl::GUIComponent::natural_size ( void  )
virtualinherited

Get the natural size of a widget.

References nocl::GUIComponent::minimum_size().

Referenced by nocl::GUIComponent::minimum_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimum_size() [1/3]

nocl::Size nocl::GUIComponent::minimum_size ( void  )
virtualinherited

Get the minimum size of a widget.

References nocl::GUIComponent::natural_size().

Referenced by nocl::GUIComponent::minimum_size(), and nocl::GUIComponent::natural_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimum_size() [2/3]

nocl::GUIComponent & nocl::GUIComponent::minimum_size ( const Size &  s)
virtualinherited

Set the minimum size of a widget.

References nocl::Size::height, nocl::GUIComponent::minimum_size(), and nocl::Size::width.

Here is the call graph for this function:

◆ minimum_size() [3/3]

nocl::GUIComponent & nocl::GUIComponent::minimum_size ( const int  width,
const int  height 
)
virtualinherited

Set the minimum size of a widget.

◆ show()

nocl::GUIComponent & nocl::GUIComponent::show ( const bool  toggle = true)
virtualinherited

Make the immediate component visible.

Parameters
[in]toggleSet to true to show the widget, or to false to hide the widget.
See also
hide()
show_all()
is_visible()

References nocl::GUIComponent::gtk_widget, and nocl::GUIComponent::hide().

Here is the call graph for this function:

◆ show_all()

nocl::GUIComponent & nocl::GUIComponent::show_all ( const bool  toggle = true)
virtualinherited

Make the component and all child components visible.

Parameters
[in]toggleSet to true to show the widget and all children, or to false to hide the widget.
See also
show()
hide()
is_visible()

References nocl::GUIComponent::gtk_widget, and nocl::GUIComponent::hide().

Here is the call graph for this function:

◆ hide()

nocl::GUIComponent & nocl::GUIComponent::hide ( void  )
virtualinherited

Hide a single component.

See also
show()
show_all()
is_visible()

References nocl::GUIComponent::gtk_widget.

Referenced by nocl::GUIComponent::show(), and nocl::GUIComponent::show_all().

Here is the caller graph for this function:

◆ is_visible()

bool nocl::GUIComponent::is_visible ( void  ) const
virtualinherited

Determine if the widget is shown.

See also
show()
show_all()
hide()

References nocl::GUIComponent::gtk_widget.

◆ widget_to_gui_component_map()

nocl::WidgetToGUIComponentMap & nocl::GUIComponent::widget_to_gui_component_map ( void  )
staticinherited

There are times when we have a pointer to a Gtk+ widget, and we need to map it back to the corresponding NOCL GUI component.

For example, during event handling, Gtk+ tells us which Gtk+ widget generated the event, but we need the corresponding NOCL object so we can call the event handler with a reference to the correct object.

Note
This is not intended for end-users to access directly!

Referenced by nocl::ButtonHandler::handle_button_events_for(), and nocl::GUIComponent::~GUIComponent().

Here is the caller graph for this function:

Member Data Documentation

◆ children

std::set<GUIComponent*> nocl::Container::children
inherited

Keep track of all children that have been added to this container.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::remove_child(), and nocl::Container::~Container().

◆ parent

Container* nocl::GUIComponent::parent
inherited

Pointer to the parent to which we've been added. Will be nullptr if this object hasn't been added to a parent container.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::remove_child(), and nocl::GUIComponent::~GUIComponent().

◆ gtk_widget


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