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]int Run(int argc, char* argv[])
Called by main.
[more]void Exit(Uint16 error_code = 0)
Causes the application to perform shutdown procedures and exit with the error code passed.
[more]virtual void Init()
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 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.
[more]void SetJoystickAxisRepeat(bool enable)
Enables/disables joystick axis repeat.
[more]void SetJoystickEvents(bool enable)
Enables/disables joystick events.
[more]void SetJoystickCursor(bool enable)
Enables/disables the joystick cursor.
[more]void SetJoystickCursorSensitvity(unsigned int _s)
Sets the joystick cursor sensitivity
[more]void SetJoystickCursorNum(unsigned int _joy)
Sets which joystick controls the cursor
[more]bool GetJoystickAxisRepeat() const
Returns true if joystick axis repeat is enabled
[more]bool GetJoystickEvents() const
Returns true if joystick events are enabled
[more]bool GetJoystickCursor() const
Returns true if joystick cursor is enabled
[more]unsigned int GetJoystickCursorSensitivity() const
Returns the joystick cursor sensitivity
[more]unsigned int GetJoystickCursorNum() const
Returns the joystick number that controls the cursor

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]int GetArgCount()
Returns the number of arguments on the command line


Inherited from TWidget:

Public Fields

Widget event signals

Public Methods

oTWidget* GetParent()
oint GetClientWidth() const
oint GetClientHeight() const

void SetPosition(...)

ovirtual bool IsInside(int X, int Y)
ovirtual bool IsInsideLocal(int X, int Y)
ovoid MakeLocal(int& X, int& Y)
ovoid MakeGlobal(int& X, int& Y)
ovoid Resize(int w, int h)

Public widget flag "sets"

Widget flags "gets"

oinline TSurface* GetSurface()

Widget Attribute "Sets"

Widget Attribute "Gets"

ovoid Show()
ovoid Hide()
ovoid SetVisible(bool v)
obool IsVisible() const
ovoid SetEnabled(bool _enable)
ovoid Enable()
ovoid Disable()
obool IsEnabled() const
ovoid NeedsRepaint()
ovoid NeedsUpdate()
ovoid MarkAsChanged()
ovoid MarkAllAsChanged()
ovoid ResetChanged()
obool GetChanged() const

Protected Methods

obool GrabKeyboardFocus()
obool GrabJoystickFocus()
oinline void Scroll(Uint16 ScrollX, Uint16 ScrollY)
ovirtual void DoResize(int Width, int Height)
ovoid ClearBuffer()
ovirtual TSurface* GetParentSurface()
ovirtual TRect GetClientRect() const
ovoid SetAutoClearBuffer(bool _acb)
ovoid SetDrawOnDemand(bool _dod)
ovoid SetTransparentBackground(bool _tb)
ovoid SetAcceptInput(bool _ai)
ovoid SetAllowChildren(bool _ac)
ovoid SetHollowClientArea(bool _hca)
ovoid SetDoubleBuffered(bool _db)
ovoid SetEmbedInParent(bool _eip)
ovoid SetAutoSaveBuffer(bool _asb)
ovoid SetAutoResetChanged(bool _arc)
ovoid SetHasClientArea(bool _hca)
ovoid SetParentDirect(bool _pd)

Built-in Event Functions

Do-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.

oint 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

ovoid Exit(Uint16 error_code = 0)
Causes the application to perform shutdown procedures and exit with the error code passed. \textsl{This should be used in place of any standard program terminating functions, like exit().} (Note: As of libksd 0.0.4 this function doesn't work as a replacement for exit! You will have to call Exit and then wait out a draw look for it to exit properly! This should be fixed in future releases.)
Parameters:
error_code - The error code to exit with.

ovirtual void Init()
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:

\being{itemize}

  • "sdl" - This the default backend. It allows for 2D drawing directly to the screen surface.
  • "opengl" - Uses OpenGL. This allows the main surface to be drawn to using standard OpenGL calls. When using this backend you can not perform drawing directly to the screen surface and must create buffered sub-surfaces to do so.

    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 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 \textsl{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

    ovoid SetJoystickAxisRepeat(bool enable)
    Enables/disables joystick axis repeat. This causes all axis events to be repeated until they no longer occur.

    ovoid SetJoystickEvents(bool enable)
    Enables/disables joystick events. When disabled the application will not receive any joystick events.

    ovoid SetJoystickCursor(bool enable)
    Enables/disables the joystick cursor. This causes a particular joystick to control the cursor. (Note: As of libksd 0.0.4 this is not implemented.)

    ovoid SetJoystickCursorSensitvity(unsigned int _s)
    Sets the joystick cursor sensitivity

    ovoid SetJoystickCursorNum(unsigned int _joy)
    Sets which joystick controls the cursor

    obool GetJoystickAxisRepeat() const
    Returns true if joystick axis repeat is enabled

    obool GetJoystickEvents() const
    Returns true if joystick events are enabled

    obool GetJoystickCursor() const
    Returns true if joystick cursor is enabled

    ounsigned int GetJoystickCursorSensitivity() const
    Returns the joystick cursor sensitivity

    ounsigned int GetJoystickCursorNum() const
    Returns the joystick number that controls the cursor

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

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


  • This class has no child classes.
    Friends:
    class EventThread
    See Also:
    KSD_MAIN

    Alphabetic index HTML hierarchy of classes or Java



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