TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Application::ApplicationHandlerInterface Class Referenceabstract

Handle events from the application/window and actions from the user of your application by deriving an an object from ApplicationHandlerInterface. More...

#include <tb_application_handler_interface.hpp>

Public Member Functions

virtual ~ApplicationHandlerInterface (void)=0
virtual void OnWindowOpen (void)
virtual void OnWindowClose (void)
virtual bool OnWindowRequestClose (void)
virtual bool CanWindowResize (void) const
virtual void OnWindowResize (tbCore::uint16 &windowWidth, tbCore::uint16 &windowHeight)
virtual void OnBecomeActive (void)
virtual void OnBecomeInactive (void)
virtual void OnRealtimeUpdate (void)
virtual void OnMenuAction (const MenuIdentifier &menu, const MenuItemIdentifier &menuItem)
virtual void OnDialogAction (const DialogIdentifier &dialog, const DialogControlIdentifier &dialogControl)
virtual void CollectWindowProperties (WindowProperties &windowProperties)
virtual void OnCreateGraphicsContext (void)
virtual void OnDestroyGraphicsContext (void)
virtual void SetApplication (RealtimeApplication *application)

Detailed Description

The RealtimeApplication takes an ApplicationHandlerInterface object that will handle window events and changes including actions the user of your application takes with menus and dialogs. This is similar to the AppDelegate object in Cocoa or WndProc function in Win32.

Most classes in the Application area are up for a complete redesign of the public facing interface.

Constructor & Destructor Documentation

virtual TurtleBrains::Application::ApplicationHandlerInterface::~ApplicationHandlerInterface ( void  )
pure virtual

Destroys the ApplicationHandlerInterface object and cleans up any resources created or used during the lifetime of the object.

Member Function Documentation

virtual bool TurtleBrains::Application::ApplicationHandlerInterface::CanWindowResize ( void  ) const

Should return true if the application will let the user resize the window and false if the window size should not be changed. Default implementation returns true.

Unless there are very specific needs to keeping the window size constrained, this should always return true. Consider that some Linux window managers suck and force the window to specific sizes that don't match desired.
virtual void TurtleBrains::Application::ApplicationHandlerInterface::CollectWindowProperties ( WindowProperties windowProperties)

Invoked to retrieve the size, and properties of the Real-time OpenGL window during the creation of the window.

windowPropertiesA reference to the properties of the window, filled out by you. The default settings are initialized beforehand, so if you want a default sized window, there is no need to do anything!
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnBecomeActive ( void  )

Invoked each time the window gains or regains focus.

virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnBecomeInactive ( void  )

Invoked each time the window loses focus to another application.

virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnCreateGraphicsContext ( void  )
the name may change, not finalized.
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnDestroyGraphicsContext ( void  )
the name may change, not finalized.
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnDialogAction ( const DialogIdentifier dialog,
const DialogControlIdentifier dialogControl 

Invoked each time the user interacts with a dialog control of an active dialog object. For more information about how this is invoked, see documentation on the ApplicationDialog functions that add a dialog control.

See also
ApplicationDialog::AddButtonControl(), ApplicationDialog::AddCheckboxControl(), ApplicationDialog::AddDropdownControl(), ApplicationDialog::AddTextControl()
dialogThe identifier of the dialog object that was interacted with to be distinguished between one dialog and the next within your application.
dialogControlThe dialog control that was interacted with, this action usually means the user clicked on the control (button, checkbox) but in some cases the action is reported when the user navigates to a different control (text) or selected a new option (dropdown).
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnMenuAction ( const MenuIdentifier menu,
const MenuItemIdentifier menuItem 

Invoked each time the user clicks a menu item from a Window Menu or Context menu.

menuThe identifier of the menu object that was interacted with to be distinguished between one menu and the next within your application.
menuItemThe menu item that was clicked by the user for the given menu.
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnRealtimeUpdate ( void  )

Invoked once for each frame of a real-time application. This is invoked very often and generally as quickly as possible.

virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnWindowClose ( void  )

Invoked only once just before the window is destroyed, there is no way to cancel the window from closing once this is called.

virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnWindowOpen ( void  )

Invoked only once while the window is being created, just before it is shown so that a window menu, status bar, or other portions can be setup and added to the window.

virtual bool TurtleBrains::Application::ApplicationHandlerInterface::OnWindowRequestClose ( void  )

This is invoked as soon as the user pressed 'X' to close the window, or any other type of terminate/close/quit event. Return true to proceed with the close, or false to continue normal running. Do try to close immediate (default behavior).

This was added to allow the GameApplication to perform a normal shutdown process that invoked OnClose() on the current scene before closing. The GameApplication handler will return false to this and then proceed it's normal shutdown.
virtual void TurtleBrains::Application::ApplicationHandlerInterface::OnWindowResize ( tbCore::uint16 windowWidth,
tbCore::uint16 windowHeight 

Invoked when the window size is changing, particularly when the user is dragging the frame.

virtual void TurtleBrains::Application::ApplicationHandlerInterface::SetApplication ( RealtimeApplication application)
This will be called with a nullptr when the application handler is being detached from application.