KSD_EXPORT_CLASSclass TApplication

A class that encapsulates the application.

Inheritance:


Public Fields

[more]SigC::Signal0<void> OnQuit
Called after everything else has been shutdown.

Public Methods

[more]void Run(int argc, char* argv[])
Called by main.
[more]virtual void Init() = 0
Override to provide start-up behavior.
[more]virtual void Shutdown()
Override to provide a shutdown procedure.
[more]void CreateScreen(std::string backend, int width, int height, int bpp = 0, unsigned int screen_flags = TScreen::DEFAULT, void* extra = NULL)
Create a screen from a particular backend, for libksd to draw it self to.
[more]void CreateScreen(int width, int height, int bpp = 0, unsigned int screen_flags = TScreen::DEFAULT)
Creates a screen for libksd, using the default backend
[more]bool IsBackendSupported(const std::string& backend)
Returns true if the given backend string is supported by the current configuration
[more]std::string GetCurrentBackend() const
Returns the name of the currently running backends
[more]virtual bool Draw(TCanvas*, DrawType dt)
Override to perform raw drawing to the screen.
[more]virtual void Cycle()
Override to perform decoupled data updates.
[more]TSurface* GetScreen()
Returns a pointer to the screen surface
[more]std::string GetCaption() const
Returns the window caption
[more]int GetWidth() const
Returns the screen width
[more]int GetHeight() const
Return the screen height
[more]TPoint2D GetPosition() const
Returns the position of the screen.
[more]PaintType GetPaintType() const
Return the current paint type used by the application
[more]void Resize(int x, int y)
Resize the screen
[more]void SetFocus(TWidget* w)
Sets the Keyboard and Joystick focus to the widget passed.
[more]void SetKeyboardFocus(TWidget* w)
Sets the Keyboard focus.
[more]void SetJoystickFocus(TWidget* w)
Sets the Joystick focus.
[more]void SetCaption(const std::string&)
Sets the window caption.
[more]void SetDecoupled(bool enable)
Used to Enable/Disable a decoupled game loop.
[more]void SetPaintType(PaintType _type)
Sets the updating policy of the application.

Public Members

[more]enum PaintType
The way the screen is updated

Protected Methods

[more]char** GetArgList()
Returns a list of char pointers, containing the command line arguments
[more]char* GetArg(unsigned int index)
Returns a specific argument
[more]int GetArgCount()
Returns the number of arguments on the command line


Inherited from TWidget:

Public Fields

Widget event signals

Public Methods

Do-Event Functions

oTWidget* GetParent()

void SetPosition(...)

obool IsInside(int X, int Y)
obool IsInsideLocal(int X, int Y)
ovoid MakeLocal(int& X, int& Y)
ovoid MakeGlobal(int& X, int& Y)
ovirtual TPoint2D GetChildPosition(TWidget* child) const

Public widget flag "sets"

Widget flags "gets"

ovirtual TSurface* GetSurface()
ovirtual TSurface* GetClientSurface()
ovirtual bool IsClientWidget() const

Widget Attribute "Sets"

Widget Attribute "Gets"

ovoid Show()
ovoid Hide()
ovoid SetVisible(bool v)
obool IsVisible() const
ovoid MoveUp()
ovoid MoveToFront()
ovoid SetEnabled(bool _enable)
ovoid Enable()
ovoid Disable()
obool IsEnabled() const
ovoid NeedsRepaint()
ovoid NeedsUpdate()
ovoid MarkAsChanged()
ovoid MarkAllAsChanged()
ovoid ResetChanged()
obool GetChanged() const
ovirtual bool CanAcceptInput() const
ovirtual bool CanAcceptMouseInput(int X, int Y) const

Protected Methods

obool GrabKeyboardFocus()
obool GrabJoystickFocus()
ovoid ClearBuffer()
ovoid RecreateAllBuffers()

Widget Implementation Functions

ovoid SetAllowChildren(bool _ac)
ovoid SetDrawOnDemand(bool _dod)

Built-in Event Functions

Protected Members

oenum DrawType


Documentation

A class that encapsulates the application. Each libksd program must contain a class derived from TApplication, and it must override Init(). This class is then passed to the KSD_MAIN macro inorder to create a valid TApplication at startup. By deriving a class from TApplication, you can provide start-up and shutdown behavior.

TApplication is a widget, and can be thought of as the root widget. Its drawing area takes up the entire ``screen" and all widgets must (directly or indirectly) be ``children" of it.

oSigC::Signal0<void> OnQuit
Called after everything else has been shutdown. Can be used for clean-up if needed. It is used by internal library functions to provide shutdown mechanisms.

ovoid Run(int argc, char* argv[])
Called by main. Users should never have to deal with this function, unless you need to create a custom main function (NOT RECOMMENDED).
See Also:
KSD_MAIN

ovirtual void Init() = 0
Override to provide start-up behavior. Called only once, on start-up right after everything as been initialized. Init() is the only function the TApplication derived classes have to define, and is a logical replacement for the main function. All application start code should go here. DO NOT put any vital start up code (with the exception of simple variable assignments) in the constructor, since the system won't be initialized until after the constructor has returned.

ovirtual void Shutdown()
Override to provide a shutdown procedure. Shutdown is called after the event sub-system and drawing cycle is stopped but before anything else is shutdown.

ovoid CreateScreen(std::string backend, int width, int height, int bpp = 0, unsigned int screen_flags = TScreen::DEFAULT, void* extra = NULL)
Create a screen from a particular backend, for libksd to draw it self to. Can be used to select the currently running backend by calling CreateScreen multiple times.

As of libksd 0.0.4, two backends are supported:

Parameters:
backend - The name of the backend to use.
width - The width of the screen to create.
height - The height of the screen to create.
bpp - The number of bits-per-pixel resolution. Set to zero to use the bpp of the current display.
screen_flags - Requested attributes for the screen. See TScreen.
extra - Extra information used to initialize the backend.

ovoid CreateScreen(int width, int height, int bpp = 0, unsigned int screen_flags = TScreen::DEFAULT)
Creates a screen for libksd, using the default backend

obool IsBackendSupported(const std::string& backend)
Returns true if the given backend string is supported by the current configuration

ostd::string GetCurrentBackend() const
Returns the name of the currently running backends

ovirtual bool Draw(TCanvas*, DrawType dt)
Override to perform raw drawing to the screen. Usually, this isn't used, because the screen needs to be broken up into several visual and input areas which can easily be done through the use of widgets.
See Also:
TWidget::Draw

ovirtual void Cycle()
Override to perform decoupled data updates.
See Also:
TWidget::Cycle

oenum PaintType
The way the screen is updated

o PartialUpdate
Only update areas of the screen that report dirty rectangles

o FullUpdate
Update the whole screen every draw cycle

oTSurface* GetScreen()
Returns a pointer to the screen surface

ostd::string GetCaption() const
Returns the window caption

oint GetWidth() const
Returns the screen width

oint GetHeight() const
Return the screen height

oTPoint2D GetPosition() const
Returns the position of the screen. This will always be point (0, 0).

oPaintType GetPaintType() const
Return the current paint type used by the application

ovoid Resize(int x, int y)
Resize the screen

ovoid SetFocus(TWidget* w)
Sets the Keyboard and Joystick focus to the widget passed.
See Also:
SetKeyboardFocus, SetJoystickFocus

ovoid SetKeyboardFocus(TWidget* w)
Sets the Keyboard focus. The widget with keyboard focus recieves all keyboard input. Keyboard focus is also automatically passed from widget to widget by clicking on one, unless the widget doesn't wish to accept keyboard focus
Parameters:
w - The widget that will possess keyboard focus.

ovoid SetJoystickFocus(TWidget* w)
Sets the Joystick focus. The widget with joystick focus recieves all joystick input. There is currently no method of automatically passing joystick focus.
Parameters:
w - The widget that will possess joystick focus.

ovoid SetCaption(const std::string&)
Sets the window caption. Only applies in windowed environments, such as X or MS Windows.

ovoid SetDecoupled(bool enable)
Used to Enable/Disable a decoupled game loop. Causes the immediate creation or destruction of the second thread in order to run decoupled.
See Also:
Game Loop

ovoid SetPaintType(PaintType _type)
Sets the updating policy of the application.
See Also:
PaintType

ochar** GetArgList()
Returns a list of char pointers, containing the command line arguments

ochar* GetArg(unsigned int index)
Returns a specific argument

oint GetArgCount()
Returns the number of arguments on the command line


This class has no child classes.
Friends:
class EventThread
void ksd::Quit(int)
See Also:
KSD_MAIN

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.