Sleeping Wombat GUI  0.100
swGUI
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
sw::gui::GUISystem Class Referenceabstract

Main GUI application class. More...

#include <GUISystem.h>

Inheritance diagram for sw::gui::GUISystem:
Application sw::gui::TestFramework

Public Member Functions

 GUISystem (int argc, char **argv, INativeGUI *gui)
 
virtual ~GUISystem ()
 
Size GetMemorySize ()
 
int NumCommandLineArgs ()
 Gets number of commnad line arguments. More...
 
const char * CommandLineArg (int num)
 Returns command line argument. 0 is first argument not program name. More...
 
const char * ProgramPath ()
 Returns program name retrived from 0 command line argument. More...
 
void OnFocusChanged (INativeWindow *window, bool value)
 Changes focused window. More...
 
void OnResized (INativeWindow *window, uint16 newWidth, uint16 newHeight)
 
void OnMaximized (INativeWindow *window)
 
void OnMinimized (INativeWindow *window)
 
HostWindowCreateNativeHostWindow (uint16 width, uint16 height, const std::string &windowTitle)
 Calls CreateNativeHostWindow with default values. More...
 
HostWindowCreateNativeHostWindow (NativeWindowDescriptor &windowDesc)
 Creates host window based on native window. Window will be added to windows list. More...
 
Main functions
void Init ()
 Invoke this function in application entry point (main). More...
 
int MainLoop ()
 Application main loop. More...
 
bool MainLoopCore ()
 One step of main loop. More...
 
void HandleEvents ()
 Processes messages and passes them to focused window. More...
 

Static Public Member Functions

static GUISystemGet ()
 

Protected Member Functions

User overrides
virtual void Initialize ()
 GUI subsystems initialization. More...
 
virtual void OnInitialized ()=0
 
virtual void OnClosing ()=0
 
virtual void OnIdle ()=0
 
Default initialization functions
void DefaultInitWithoutWindow ()
 Makes initialization but leaves window creation for user. More...
 
void DefaultInit (uint16 width, uint16 height, const std::string &windowTitle)
 Default GUI system initialization function. More...
 
bool DefaultInitNativeGUI ()
 Default native GUI initialization. More...
 
bool DefaultInitGraphicAPI ()
 Default graphic api initialization. More...
 
bool DefaultInitRenderingSystem ()
 Initializes rendering system. More...
 

Protected Attributes

IGraphicAPIInitializerm_graphicApi
 Contains object responsible for dealing with specifics graphic apis. More...
 
INativeGUIm_nativeGUI
 Native window system used to display main application window. More...
 
input::IInputm_input
 Input processor. More...
 
ResourceManagerm_resourceManager
 Resources. More...
 
RenderingSystemOPtr m_renderingSystem
 All rendering connceted functionalities. More...
 
std::vector< HostWindow * > m_windows
 
HostWindowm_focusedWindow
 Only one window can have focus and only this will be processed. More...
 
CommandLineArgs m_cmdArgs
 

Static Private Attributes

static GUISystemm_instance = nullptr
 

Friends

class GUISystemTester
 

Detailed Description

Main GUI application class.

Use example of GUI:

#include "Application.h"
int main( int argc, char** argv )
{
Application app( argc, argv, GUI::WinAPIGUI::Create() );
app.Init();
return app.MainLoop();
}

You don't have to write main function. Instead use project templates for different platforms. To use gui implement Application class.

Todo:
Supply project templates.

Constructor & Destructor Documentation

sw::gui::GUISystem::GUISystem ( int  argc,
char **  argv,
INativeGUI gui 
)
explicit
sw::gui::GUISystem::~GUISystem ( )
virtual

Member Function Documentation

const char * sw::gui::GUISystem::CommandLineArg ( int  num)

Returns command line argument. 0 is first argument not program name.

HostWindow * sw::gui::GUISystem::CreateNativeHostWindow ( uint16  width,
uint16  height,
const std::string &  windowTitle 
)

Calls CreateNativeHostWindow with default values.

See also
GUISystem::CreateNativeHostWindow
HostWindow * sw::gui::GUISystem::CreateNativeHostWindow ( NativeWindowDescriptor windowDesc)

Creates host window based on native window. Window will be added to windows list.

Note
windowDesc can change. For instance: if you set AdjustSize to true, function will return real window size.
void sw::gui::GUISystem::DefaultInit ( uint16  width,
uint16  height,
const std::string &  windowTitle 
)
protected

Default GUI system initialization function.

bool sw::gui::GUISystem::DefaultInitGraphicAPI ( )
protected

Default graphic api initialization.

bool sw::gui::GUISystem::DefaultInitNativeGUI ( )
protected

Default native GUI initialization.

Native GUI object is set in constructor. Here we initialize it. Function creates native input object.

bool sw::gui::GUISystem::DefaultInitRenderingSystem ( )
protected

Initializes rendering system.

Note
m_resourceManager and m_graphicApi must be already initialized;
void sw::gui::GUISystem::DefaultInitWithoutWindow ( )
protected

Makes initialization but leaves window creation for user.

GUISystem & sw::gui::GUISystem::Get ( )
static
Size sw::gui::GUISystem::GetMemorySize ( )

Zwraca ilość pamięci zajmowanej przez obiekt. Implementacje w klasach potomnych powinny też doliczać rekurencyjnie pamięć zajmowaną przez obiekty, których właścicielem jest ten obiekt.

void sw::gui::GUISystem::HandleEvents ( )

Processes messages and passes them to focused window.

void sw::gui::GUISystem::Init ( )

Invoke this function in application entry point (main).

void sw::gui::GUISystem::Initialize ( )
protectedvirtual

GUI subsystems initialization.

If you need specific gui initialization in your application override this function. You can set different GraphicApi or input api.

Reimplemented in sw::gui::TestFramework, and Application.

int sw::gui::GUISystem::MainLoop ( )

Application main loop.

See also
Application
bool sw::gui::GUISystem::MainLoopCore ( )

One step of main loop.

Todo:
Consider making this function virtual in future.
Returns
Returns true if application should end. Otherwise returns false.
int sw::gui::GUISystem::NumCommandLineArgs ( )

Gets number of commnad line arguments.

Function doesn't take program nameinto account .

virtual void sw::gui::GUISystem::OnClosing ( )
protectedpure virtual

Implemented in sw::gui::TestFramework, and Application.

void sw::gui::GUISystem::OnFocusChanged ( INativeWindow window,
bool  value 
)

Changes focused window.

Delegate for native GUI.

virtual void sw::gui::GUISystem::OnIdle ( )
protectedpure virtual

Implemented in sw::gui::TestFramework, and Application.

virtual void sw::gui::GUISystem::OnInitialized ( )
protectedpure virtual

Implemented in sw::gui::TestFramework, and Application.

void sw::gui::GUISystem::OnMaximized ( INativeWindow window)
void sw::gui::GUISystem::OnMinimized ( INativeWindow window)
void sw::gui::GUISystem::OnResized ( INativeWindow window,
uint16  newWidth,
uint16  newHeight 
)
const char * sw::gui::GUISystem::ProgramPath ( )

Returns program name retrived from 0 command line argument.

Friends And Related Function Documentation

friend class GUISystemTester
friend

Member Data Documentation

CommandLineArgs sw::gui::GUISystem::m_cmdArgs
protected
HostWindow* sw::gui::GUISystem::m_focusedWindow
protected

Only one window can have focus and only this will be processed.

IGraphicAPIInitializer* sw::gui::GUISystem::m_graphicApi
protected

Contains object responsible for dealing with specifics graphic apis.

input::IInput* sw::gui::GUISystem::m_input
protected

Input processor.

GUISystem * sw::gui::GUISystem::m_instance = nullptr
staticprivate
INativeGUI* sw::gui::GUISystem::m_nativeGUI
protected

Native window system used to display main application window.

RenderingSystemOPtr sw::gui::GUISystem::m_renderingSystem
protected

All rendering connceted functionalities.

ResourceManager* sw::gui::GUISystem::m_resourceManager
protected

Resources.

std::vector< HostWindow* > sw::gui::GUISystem::m_windows
protected

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