#include <wg_application.h>
Inheritance diagram for wGui::CApplication:
CApplication is a singleton (only one instance of it should ever exist) This handles all global level stuff like initializing SDL and creating a MessageServer CApplication also takes care of turning SDL events into wGui messages
Definition at line 68 of file wg_application.h.
wGui::CApplication::CApplication | ( | int | argc, | |
char ** | argv, | |||
std::wstring | sFontFileName = L"Vera.ttf" , |
|||
bool | bHandleExceptionsInternally = true | |||
) |
Standard constructor
argc | The argument count from the command line | |
argv | The argument array from the command line | |
sFontFileName | The font to use for controls, defaults to Arial | |
bHandleExceptionsInternally | If this is true, wGui will handle most exceptions itself, if false, all exceptions will be returned to the user (defaults to true) |
Definition at line 89 of file wg_application.cpp.
References wUtil::CLog::AddLogEntry(), wGui::APP_LOG_INFO, m_AppLog, m_pInstance, m_pSystemDefaultCursor, and stdex::ToWString().
static CApplication* wGui::CApplication::Instance | ( | void | ) | [inline, static] |
Gets the single instance of the CApplication object
Definition at line 83 of file wg_application.h.
References m_pInstance.
Referenced by wGui::CButton::CButton(), wGui::CEditBox::CEditBox(), wGui::CFontEngine::CFontEngine(), wGui::CFrame::CFrame(), wGui::CGroupBox::CGroupBox(), wGui::CLabel::CLabel(), wGui::CListBox::CListBox(), wGui::CMenuBase::CMenuBase(), wGui::CScrollBar::CScrollBar(), wGui::CTextBox::CTextBox(), wGui::CToolTip::CToolTip(), wGui::CView::CView(), wGui::CwgBitmapResourceHandle::CwgBitmapResourceHandle(), wGui::CwgCursorResourceHandle::CwgCursorResourceHandle(), wGui::CwgStringResourceHandle::CwgStringResourceHandle(), wGui::CWindow::CWindow(), wGui::CTextBox::Draw(), wGui::CListBox::Draw(), wGui::CEditBox::Draw(), wGui::CView::HandleMessage(), wGui::CTextBox::HandleMessage(), wGui::CEditBox::HandleMessage(), HandleSDLEvent(), wGui::CTextBox::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonDown(), wGui::CEditBox::OnMouseButtonDown(), wGui::CWindow::RegisterChildWindow(), wGui::CMessageServer::RegisterMessageClient(), wGui::CFrame::SetModal(), wGui::CWindow::SetVisible(), wGui::CWindow::SetWindowRect(), and wGui::CView::SetWindowRect().
virtual const std::wstring& wGui::CApplication::GetDefaultFontFileName | ( | void | ) | const [inline, virtual] |
Gets the default font file name (which is set via the wgui.conf file)
Definition at line 87 of file wg_application.h.
References m_sFontFileName.
virtual int wGui::CApplication::ExitCode | ( | void | ) | const [inline, virtual] |
Gets the current exit code of the application
Definition at line 91 of file wg_application.h.
References m_iExitCode.
virtual bool wGui::CApplication::IsRunning | ( | void | ) | const [inline, virtual] |
Indicates if the application is currently "running" or not
Definition at line 95 of file wg_application.h.
References m_bRunning.
virtual bool wGui::CApplication::HandleExceptions | ( | void | ) | const [inline, virtual] |
Indicates if the application will be attempting to handle it's own exceptions (set in the CApplication constructor)
Definition at line 99 of file wg_application.h.
References m_bHandleExceptionsInternally.
virtual bool wGui::CApplication::IsInitialized | ( | void | ) | const [inline, virtual] |
Indicates if the CApplication object has been properly initialized
Definition at line 103 of file wg_application.h.
References m_bInited.
void wGui::CApplication::SetKeyFocus | ( | CWindow * | pWindow | ) | [virtual] |
This is for setting/getting the window that has the current keyboard focus Any KEYBOARD messages will have this window as their destination
pWindow | A pointer to the window that should get focus |
Definition at line 150 of file wg_application.cpp.
References wGui::CMessage::CTRL_GAININGKEYFOCUS, wGui::CMessage::CTRL_LOSINGKEYFOCUS, wGui::CMessageServer::Instance(), m_pKeyFocusWindow, and wGui::CMessageServer::QueueMessage().
Referenced by wGui::CTextBox::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonDown(), wGui::CEditBox::OnMouseButtonDown(), wGui::CFrame::SetModal(), and wGui::CWindow::SetVisible().
virtual CWindow* wGui::CApplication::GetKeyFocus | ( | void | ) | const [inline, virtual] |
Gets the current keyboard focus for the application
Definition at line 112 of file wg_application.h.
References m_pKeyFocusWindow.
Referenced by HandleSDLEvent(), and wGui::CListBox::OnMouseButtonDown().
void wGui::CApplication::SetMouseFocus | ( | CWindow * | pWindow | ) | [virtual] |
This is for setting/getting the window that has the current mouse focus Any subsequent MOUSE messages will have this window as their destination
pWindow | A pointer to the window that should get focus ( grab ) |
Definition at line 165 of file wg_application.cpp.
References wGui::CMessage::CTRL_GAININGMOUSEFOCUS, wGui::CMessage::CTRL_LOSINGMOUSEFOCUS, wGui::CMessageServer::Instance(), m_pMouseFocusWindow, and wGui::CMessageServer::QueueMessage().
Referenced by wGui::CFrame::SetModal().
virtual CWindow* wGui::CApplication::GetMouseFocus | ( | void | ) | const [inline, virtual] |
Gets the current mouse focus for the application
Definition at line 121 of file wg_application.h.
References m_pMouseFocusWindow.
Referenced by HandleSDLEvent().
void wGui::CApplication::Init | ( | void | ) | [virtual] |
Init() must be called before Exec() Takes care of initializing SDL and other important stuff
Definition at line 181 of file wg_application.cpp.
References wUtil::CLog::AddLogEntry(), wGui::CMessage::APP_EXIT, wGui::APP_LOG_INFO, wGui::APP_LOG_WARNING, wUtil::CConfigStore::EntryExists(), GetFontEngine(), wUtil::CConfigStore::GetLongIntEntry(), wUtil::CConfigStore::GetStringEntry(), wGui::CMessageServer::Instance(), m_AppLog, m_bInited, m_DefaultBackgroundColor, m_DefaultForegroundColor, m_DefaultSelectionColor, m_GlobalConfig, m_pDefaultFontEngine, wGui::CMessageServer::PRIORITY_LAST, wUtil::CConfigStore::ReadFromFile(), and wGui::CMessageServer::RegisterMessageClient().
void wGui::CApplication::ApplicationExit | ( | int | iExitCode = EXIT_SUCCESS |
) | [virtual] |
This is called just before the application exits
iExitCode | The exit code to return, defaults to EXIT_SUCCESS |
Definition at line 337 of file wg_application.cpp.
References m_bRunning, m_iExitCode, and wUtil::TraceIf().
Referenced by HandleMessage().
CFontEngine * wGui::CApplication::GetFontEngine | ( | std::wstring | sFontFileName, | |
unsigned char | iFontSize = 12 | |||
) | [virtual] |
Creates a font engine A seperate font engine is created for each font file and font size
sFontFileName | The font to use | |
iFontSize | The size (in points) of the font, defaults to 12 |
Definition at line 353 of file wg_application.cpp.
References wUtil::CLog::AddLogEntry(), wGui::APP_LOG_ERROR, stdex::DetokenizeString(), wUtil::CConfigStore::GetStringEntry(), m_AppLog, m_bHandleExceptionsInternally, m_FontEngines, m_GlobalConfig, wGui::Wg_Ex_Base::std_what(), and stdex::ToMbString().
Referenced by Init().
virtual void wGui::CApplication::SetDefaultFontEngine | ( | CFontEngine * | pFontEngine | ) | [inline, virtual] |
Sets the default font engine If a default font engine is not set, a valid font engine must be passed to any controls that display text
Definition at line 143 of file wg_application.h.
References m_pDefaultFontEngine.
virtual CFontEngine* wGui::CApplication::GetDefaultFontEngine | ( | void | ) | const [inline, virtual] |
Gets the default font engine (set in the wgui.conf file)
Definition at line 147 of file wg_application.h.
References m_pDefaultFontEngine.
Referenced by wGui::CButton::CButton(), wGui::CEditBox::CEditBox(), wGui::CFrame::CFrame(), wGui::CGroupBox::CGroupBox(), wGui::CLabel::CLabel(), wGui::CListBox::CListBox(), wGui::CMenuBase::CMenuBase(), wGui::CTextBox::CTextBox(), and wGui::CToolTip::CToolTip().
virtual int wGui::CApplication::GetBitsPerPixel | ( | void | ) | const [inline, virtual] |
Gets the color depth (in bits per pixel) of the app
Definition at line 151 of file wg_application.h.
References m_iBitsPerPixel.
Referenced by wGui::CView::HandleMessage(), wGui::CWindow::SetWindowRect(), and wGui::CView::SetWindowRect().
virtual CRGBColor wGui::CApplication::GetDefaultBackgroundColor | ( | void | ) | const [inline, virtual] |
Gets the default background color (set in the wgui.conf file)
Definition at line 155 of file wg_application.h.
References m_DefaultBackgroundColor.
Referenced by wGui::CGroupBox::CGroupBox(), wGui::CLabel::CLabel(), and wGui::CWindow::CWindow().
virtual CRGBColor wGui::CApplication::GetDefaultForegroundColor | ( | void | ) | const [inline, virtual] |
Gets the default foreground color (set in the wgui.conf file)
Definition at line 159 of file wg_application.h.
References m_DefaultForegroundColor.
Referenced by wGui::CButton::CButton(), and wGui::CScrollBar::CScrollBar().
virtual CRGBColor wGui::CApplication::GetDefaultSelectionColor | ( | void | ) | const [inline, virtual] |
Gets the default selection color (set in the wgui.conf file)
Definition at line 163 of file wg_application.h.
References m_DefaultSelectionColor.
Referenced by wGui::CMenuBase::CMenuBase(), and wGui::CListBox::Draw().
void wGui::CApplication::EnableResourcePool | ( | bool | bEnable | ) | [virtual] |
The resource pool is used to keep wGui provided resources around even when there are no other handles begin kept by the user The internal wGui resources are automatically added to the pool if this is enabled when they are created The pool is enabled by default
bEnable | If set to false, it will clear any current resource handles from the pool, and will disable the pool |
Definition at line 419 of file wg_application.cpp.
References m_bResourcePoolEnabled, and m_ResourceHandlePool.
bool wGui::CApplication::AddToResourcePool | ( | CResourceHandle & | ResourceHandle | ) | [virtual] |
Adds a resource handle to the resource pool if the pool is enabled Once a resource is added, the only way to remove it, is to disabled the resource pool (via EnableResourcePool() ) which will empty the pool of all resources
ResourceHandle | The resource handle to copy into the pool |
Definition at line 429 of file wg_application.cpp.
References m_bResourcePoolEnabled, and m_ResourceHandlePool.
Referenced by wGui::CwgBitmapResourceHandle::CwgBitmapResourceHandle(), wGui::CwgCursorResourceHandle::CwgCursorResourceHandle(), and wGui::CwgStringResourceHandle::CwgStringResourceHandle().
void wGui::CApplication::SetMouseCursor | ( | CCursorResourceHandle * | pCursorResourceHandle = 0 |
) | [virtual] |
Changes the mouse cursor
pCursorResourceHandle | A pointer to the cursor resource handle, if no cursor is specified, the cursor will revert to the system default |
Definition at line 443 of file wg_application.cpp.
References m_pCurrentCursorResourceHandle, and m_pSystemDefaultCursor.
Referenced by wGui::CTextBox::HandleMessage(), and wGui::CEditBox::HandleMessage().
virtual void wGui::CApplication::SetMousePosition | ( | const CPoint & | Point | ) | [inline, virtual] |
Changes the mouse position When this is called a new SDL_MOUSEMOTION event is triggered
Point | the position where the mouse pointer should be warped |
Definition at line 184 of file wg_application.h.
References wGui::CPoint::XPos(), and wGui::CPoint::YPos().
virtual void wGui::CApplication::SetMouseVisibility | ( | bool | bVisible | ) | [inline, virtual] |
Changes the visibility of the mouse
bVisible | if the mouse has to be drawn or not |
Definition at line 189 of file wg_application.h.
virtual const wUtil::CConfigStore& wGui::CApplication::GetGlobalConfig | ( | void | ) | [inline, virtual] |
Returns the Global Configuration, which is read in from the wGui.conf file This Global config is read-only. Any changes should be made to the wGui.conf file outside of the app wGui will search directories for the wGui.conf file in the following order, and will include the settings from each:
Definition at line 200 of file wg_application.h.
References m_GlobalConfig.
virtual wUtil::CLog& wGui::CApplication::GetApplicationLog | ( | void | ) | [inline, virtual] |
Returns the application log, which is output to wGui.log on application exit
Definition at line 204 of file wg_application.h.
References m_AppLog.
Referenced by wGui::CFontEngine::CFontEngine(), wGui::CView::CView(), wGui::CWindow::RegisterChildWindow(), wGui::CMessageServer::RegisterMessageClient(), and wGui::CWindow::SetWindowRect().
bool wGui::CApplication::HandleMessage | ( | CMessage * | pMessage | ) | [virtual] |
CApplication will handle the APP_EXIT message, and will close the application on it's reciept
pMessage | A pointer the the message to handle |
Implements wGui::CMessageClient.
Definition at line 468 of file wg_application.cpp.
References wGui::CMessage::APP_EXIT, ApplicationExit(), and wGui::CMessage::MessageType().
void wGui::CApplication::HandleSDLEvent | ( | SDL_Event | event | ) | [protected, virtual] |
For internal use only
Definition at line 40 of file wg_application.cpp.
References wGui::CMessage::APP_EXIT, wGui::CMessage::CTRL_RESIZE, GetKeyFocus(), GetMouseFocus(), Instance(), wGui::CMessageServer::Instance(), wGui::CMessage::KEYBOARD_KEYDOWN, wGui::CMessage::KEYBOARD_KEYUP, wGui::CMessage::MOUSE_BUTTONDOWN, wGui::CMessage::MOUSE_BUTTONUP, wGui::CMessage::MOUSE_MOVE, wGui::CMessageServer::QueueMessage(), wGui::CMessage::SDL, wGui::CMouseMessage::TranslateSDLButton(), and wGui::CMouseMessage::TranslateSDLButtonState().
Referenced by Exec().