GG: GG::SDLGUI Class Reference

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Member Functions | Protected Member Functions | List of all members
GG::SDLGUI Class Referenceabstract

`#include <SDLGUI.h>`

Inheritance diagram for GG::SDLGUI:

## Static Public Member Functions
static SDLGUI * | GetGUI ()
static GG::Key | GGKeyFromSDLKey (const SDL_keysym &key)
Static Public Member Functions inherited from GG::GUI
static GUI * | GetGUI ()
static void | RenderWindow (Wnd *wnd)

## Protected Member Functions
virtual void | SDLInit ()
virtual void | GLInit ()
virtual void | Initialize ()=0
virtual void | HandleSystemEvents ()
virtual void | HandleNonGGEvent (const SDL_Event &event)
virtual void | RenderBegin ()
virtual void | RenderEnd ()
virtual void | FinalCleanup ()
virtual void | SDLQuit ()
virtual void | Run ()
Protected Member Functions inherited from GG::GUI
| GUI (const std::string &app_name)
void | ProcessBrowseInfo ()
virtual void | Render ()
void | SetFPS (double FPS)
void | SetDeltaT (unsigned int delta_t)

## Structors
| SDLGUI (int w=1024, int h=768, bool calc_FPS=false, const std::string &app_name="GG")
virtual | ~SDLGUI ()

## Accessors
virtual X | AppWidth () const
virtual Y | AppHeight () const
virtual unsigned int | Ticks () const

## Mutators
void | operator() ()
virtual void | Exit (int code)
virtual void | Enter2DMode ()=0
virtual void | Exit2DMode ()=0

## Additional Inherited Members
Public Types inherited from GG::GUI
enum | EventType { IDLE, KEYPRESS, KEYRELEASE, LPRESS, MPRESS, RPRESS, LRELEASE, MRELEASE, RRELEASE, MOUSEMOVE, MOUSEWHEEL }
typedef std::set< std::pair < Key, Flags< ModKey > > >::iterator | accel_iterator
typedef std::set< std::pair < Key, Flags< ModKey > > >::const_iterator | const_accel_iterator
typedef boost::signal< bool(), OrCombiner > | AcceleratorSignalType
Public Member Functions inherited from GG::GUI
virtual | ~GUI ()
const std::string & | AppName () const
Wnd * | FocusWnd () const
Wnd * | GetWindowUnder (const Pt &pt) const
unsigned int | DeltaT () const
bool | RenderingDragDropWnds () const
bool | FPSEnabled () const
double | FPS () const
std::string | FPSString () const
double | MaxFPS () const
unsigned int | ButtonDownRepeatDelay () const
unsigned int | ButtonDownRepeatInterval () const
unsigned int | DoubleClickInterval () const
unsigned int | MinDragTime () const
unsigned int | MinDragDistance () const
bool | DragDropWnd (const Wnd *wnd) const
bool | AcceptedDragDropWnd (const Wnd *wnd) const
bool | MouseButtonDown (unsigned int bn) const
Pt | MousePosition () const
Pt | MouseMovement () const
Flags< ModKey > | ModKeys () const
bool | MouseLRSwapped () const
const std::map< Key, Key > & | KeyMap () const
virtual std::set< std::pair < CPSize, CPSize > > | FindWords (const std::string &str) const
const boost::shared_ptr < StyleFactory > & | GetStyleFactory () const
bool | RenderCursor () const
const boost::shared_ptr< Cursor > & | GetCursor () const
const_accel_iterator | accel_begin () const
const_accel_iterator | accel_end () const
AcceleratorSignalType & | AcceleratorSignal (Key key, Flags< ModKey > mod_keys=MOD_KEY_NONE) const
void | SaveWndAsPNG (const Wnd *wnd, const std::string &filename) const
void | operator() ()
void | HandleGGEvent (EventType event, Key key, boost::uint32_t key_code_point, Flags< ModKey > mod_keys, const Pt &pos, const Pt &rel)
void | SetFocusWnd (Wnd *wnd)
virtual void | Wait (unsigned int ms)
void | Register (Wnd *wnd)
void | RegisterModal (Wnd *wnd)
void | Remove (Wnd *wnd)
void | WndDying (Wnd *wnd)
void | MoveUp (Wnd *wnd)
void | MoveDown (Wnd *wnd)
virtual boost::shared_ptr < ModalEventPump > | CreateModalEventPump (bool &done)
void | RegisterDragDropWnd (Wnd *wnd, const Pt &offset, Wnd *originating_wnd)
void | CancelDragDrop ()
void | RegisterTimer (Timer &timer)
void | RemoveTimer (Timer &timer)
void | EnableFPS (bool b=true)
void | SetMaxFPS (double max)
void | EnableMouseButtonDownRepeat (unsigned int delay, unsigned int interval)
void | SetDoubleClickInterval (unsigned int interval)
void | SetMinDragTime (unsigned int time)
void | SetMinDragDistance (unsigned int distance)
accel_iterator | accel_begin ()
accel_iterator | accel_end ()
void | SetAccelerator (Key key, Flags< ModKey > mod_keys=MOD_KEY_NONE)
void | RemoveAccelerator (Key key, Flags< ModKey > mod_keys=MOD_KEY_NONE)
void | RemoveAccelerator (accel_iterator it)
void | SetMouseLRSwapped (bool swapped=true)
void | SetKeyMap (const std::map< Key, Key > &key_map)
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts)
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, const std::vector< unsigned char > &file_contents)
template<class CharSetIter >
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, CharSetIter first, CharSetIter last)
template<class CharSetIter >
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, const std::vector< unsigned char > &file_contents, CharSetIter first, CharSetIter last)
boost::shared_ptr< Font > | GetFont (const boost::shared_ptr< Font > &font, unsigned int pts)
void | FreeFont (const std::string &font_filename, unsigned int pts)
boost::shared_ptr< Texture > | StoreTexture (Texture *texture, const std::string &texture_name)
boost::shared_ptr< Texture > | StoreTexture (const boost::shared_ptr< Texture > &texture, const std::string &texture_name)
boost::shared_ptr< Texture > | GetTexture (const std::string &name, bool mipmap=false)
void | FreeTexture (const std::string &name)
void | SetStyleFactory (const boost::shared_ptr< StyleFactory > &factory)
void | RenderCursor (bool render)
void | SetCursor (const boost::shared_ptr< Cursor > &cursor)
| GG_ABSTRACT_EXCEPTION (Exception)
| GG_CONCRETE_EXCEPTION (BadFunctionPointer, GG::GUI, Exception)

## Detailed Description

This is an abstract singleton class that represents the GUI framework of an SDL OpenGL application.

Usage:

Any application including an object of this class should declare that object as a local variable in main(). The name of this variable will herein be assumed to be "gui". It should be allocated on the stack; if it is created dynamically a leak may occur. SDLGUI is designed so the main() of the application can consist of just the one line "gui();".

To do this, the user needs only to override the Initialize() and FinalCleanup() methods, and ensure that the program does not terminate abnormally; this ensures FinalCleanup() is called when gui's destructor is invoked. Exit() can also perform cleanup and terminate the application cleanly.

Most of the member methods of SDLGUI have been declared virtual, to give the user great control when subclassing. The virtual function calls are usually not a performance issue, since none of the methods is called repeatedly, except HandleEvent(); if this is a problem, just create a new function in your subclass and call that from within Run() instead of HandleEvent(). Note that though the bulk of the program execution takes place within Run(), Run() itself is also only called once.

SDLGUI takes a two-tiered approach to event handling. The event pump calls HandleSystemEvents(), which polls for SDL events and handles them by first determining whether the event is GG-related, or some other non-GG event, such as SDL_QUIT, etc. GG events and non-GG events are passed to HandleGGEvent() and HandleNonGGEvent(), respectively. For most uses, there should be no need to override the behavior of HandleSDLEvents(). However, the HandleNonGGEvent() default implementation only responds to SDL_QUIT events, and so should be overridden in most cases.

Definition at line 82 of file SDLGUI.h.

## Member Function Documentation

virtual void GG::SDLGUI::HandleSystemEvents | ( |  | ) |
| protectedvirtual

Handles all waiting system events (from SDL, DirectInput, etc.). This function should only be called from custom EventPump event handlers.

Implements GG::GUI.

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

- SDLGUI.h