wxApp Class Reference
[Application and Process Management]

#include <wx/app.h>

Inheritance diagram for wxApp:

wxAppConsole wxEvtHandler wxObject

List of all members.


Detailed Description

The wxApp class represents the application itself. It is used to:

You should use the macro IMPLEMENT_APP(appClass) in your application implementation file to tell wxWidgets how to create an instance of your application class.

Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function (which returns a reference to your application object) to be visible to other files.

Library:  wxBase

Category:  Application and Process Management

See also:
wxApp Overview

Public Member Functions

 wxApp ()
virtual ~wxApp ()
bool GetExitOnFrameDelete () const
bool GetUseBestVisual () const
virtual wxWindowGetTopWindow () const
virtual bool IsActive () const
bool ProcessMessage (WXMSG *msg)
virtual bool SendIdleEvents (wxWindow *win, wxIdleEvent &event)
void SetExitOnFrameDelete (bool flag)
virtual bool SetNativeTheme (const wxString &theme)
void SetTopWindow (wxWindow *window)
void SetUseBestVisual (bool flag, bool forceTrueColour=false)

Static Public Member Functions

static void SetInstance (wxAppConsole *app)

Constructor & Destructor Documentation

wxApp::wxApp (  ) 

Constructor. Called implicitly with a definition of a wxApp object.

virtual wxApp::~wxApp (  )  [virtual]

Destructor. Will be called implicitly on program exit if the wxApp object is created on the stack.


Member Function Documentation

bool wxApp::GetExitOnFrameDelete (  )  const

Returns true if the application will exit when the top-level frame is deleted.

See also:
SetExitOnFrameDelete()

bool wxApp::GetUseBestVisual (  )  const

Returns true if the application will use the best visual on systems that support different visuals, false otherwise.

See also:
SetUseBestVisual()

virtual wxWindow* wxApp::GetTopWindow (  )  const [virtual]

Returns a pointer to the top window.

Remarks:
If the top window hasn't been set using SetTopWindow(), this function will find the first top-level window (frame or dialog) and return that.
See also:
SetTopWindow()

virtual bool wxApp::IsActive (  )  const [virtual]

Returns true if the application is active, i.e. if one of its windows is currently in the foreground.

If this function returns false and you need to attract users attention to the application, you may use wxTopLevelWindow::RequestUserAttention to do it.

bool wxApp::ProcessMessage ( WXMSG *  msg  ) 

Windows-only function for processing a message. This function is called from the main message loop, checking for windows that may wish to process it.

The function returns true if the message was processed, false otherwise. If you use wxWidgets with another class library with its own message loop, you should make sure that this function is called to allow wxWidgets to receive messages. For example, to allow co-existence with the Microsoft Foundation Classes, override the PreTranslateMessage function:

        // Provide wxWidgets message loop compatibility
        BOOL CTheApp::PreTranslateMessage(MSG *msg)
        {
            if (wxTheApp && wxTheApp->ProcessMessage((WXMSW *)msg))
                return true;
            else
                return CWinApp::PreTranslateMessage(msg);
        }

Availability:  only available for the wxMSW port.

virtual bool wxApp::SendIdleEvents ( wxWindow win,
wxIdleEvent event 
) [virtual]

Sends idle events to a window and its children. Please note that this function is internal to wxWidgets and shouldn't be used by user code.

Remarks:
These functions poll the top-level windows, and their children, for idle event processing. If true is returned, more OnIdle processing is requested by one or more window.
See also:
wxIdleEvent

void wxApp::SetExitOnFrameDelete ( bool  flag  ) 

Allows the programmer to specify whether the application will exit when the top-level frame is deleted.

Parameters:
flag If true (the default), the application will exit when the top-level frame is deleted. If false, the application will continue to run.
See also:
GetExitOnFrameDelete(), Application Shutdown

static void wxApp::SetInstance ( wxAppConsole app  )  [static]

Allows external code to modify global wxTheApp, but you should really know what you're doing if you call it.

Parameters:
app Replacement for the global application object.
See also:
GetInstance()

Reimplemented from wxAppConsole.

virtual bool wxApp::SetNativeTheme ( const wxString theme  )  [virtual]

Allows runtime switching of the UI environment theme.

Currently implemented for wxGTK2-only. Return true if theme was successfully changed.

Parameters:
theme The name of the new theme or an absolute path to a gtkrc-theme-file

void wxApp::SetTopWindow ( wxWindow window  ) 

Sets the 'top' window. You can call this from within OnInit() to let wxWidgets know which is the main window. You don't have to set the top window; it is only a convenience so that (for example) certain dialogs without parents can use a specific window as the top window. If no top window is specified by the application, wxWidgets just uses the first frame or dialog in its top-level window list, when it needs to use the top window.

Parameters:
window The new top window.
See also:
GetTopWindow(), OnInit()

void wxApp::SetUseBestVisual ( bool  flag,
bool  forceTrueColour = false 
)

Allows the programmer to specify whether the application will use the best visual on systems that support several visual on the same display. This is typically the case under Solaris and IRIX, where the default visual is only 8-bit whereas certain applications are supposed to run in TrueColour mode.

Note that this function has to be called in the constructor of the wxApp instance and won't have any effect when called later on. This function currently only has effect under GTK.

Parameters:
flag If true, the app will use the best visual.
forceTrueColour If true then the application will try to force using a TrueColour visual and abort the app if none is found.



wxWidgets logo

[ top ]