Contents Up Previous Next 原文へのリンク

wxApp

wxAppクラスはアプリケーション自身をあらわしています。以下の様に使われます。
The wxApp class represents the application itself. It is used to:

アプリケーションクラスのインスタンスをどのように作るかをwxWidgetsに通知するためには 自分のアプリケーションインプリメンテーションファイル内でIMPLEMENT_APP(appClass)マクロを使うべきです。
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.

あなたが wxGetApp 関数(あなたのアプリケーション・オブジェクトのリファレンスを返す)を他のファイルに見えて欲しいならば、ヘッダ・ファイルの中でDECLARE_APP(appClass)を使用してください。
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.
継承元
Derived from

wxEvtHandler
wxObject

インクルードファイル
Include files

<wx/app.h>

参照
See also

wxApp overview

メンバ
Members

wxApp::wxApp
wxApp::~wxApp
wxApp::argc
wxApp::argv
wxApp::CreateLogTarget
wxApp::Dispatch
wxApp::FilterEvent
wxApp::GetAppName
wxApp::GetAuto3D
wxApp::GetClassName
wxApp::GetExitOnFrameDelete
wxApp::GetTopWindow
wxApp::GetUseBestVisual
wxApp::GetVendorName
wxApp::ExitMainLoop
wxApp::Initialized
wxApp::MainLoop
wxApp::OnAssert
wxApp::OnExit
wxApp::OnCmdLineError
wxApp::OnCmdLineHelp
wxApp::OnCmdLineParsed
wxApp::OnFatalException
wxApp::OnInit
wxApp::OnInitCmdLine
wxApp::OnQueryEndSession
wxApp::ProcessMessage
wxApp::Pending
wxApp::SendIdleEvents
wxApp::SetAppName
wxApp::SetAuto3D
wxApp::SetClassName
wxApp::SetExitOnFrameDelete
wxApp::SetTopWindow
wxApp::SetVendorName
wxApp::SetUseBestVisual
wxApp::Yield


wxApp::wxApp

void wxApp()

コンストラクタ。wxAppオブジェクトの構築時に暗黙のうちに呼ばれる。

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


wxApp::~wxApp

void ~wxApp()

デストラクタ。wxAppオブジェクトをスタック上に生成していればプログラム終了時に暗黙のうちに呼ばれる。

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


wxApp::argc

int argc

コマンドライン引数の数(環境固有の処理の後)。

Number of command line arguments (after environment-specific processing).


wxApp::argv

char ** argv

コマンドライン引数(環境固有の処理の後)。

Command line arguments (after environment-specific processing).


wxApp::CreateLogTarget

virtual wxLog* CreateLogTarget()

エラーログを使うアプリケーションのためにwxLogクラスを生成します。 デフォルトのインプリメンテーションでは新しいwxLogGuiクラスを返します。

Creates a wxLog class for the application to use for logging errors. The default implementation returns a new wxLogGui class.

See also

wxLog


wxApp::Dispatch

void Dispatch()

ウィンドウのイベントキューに次のイベントを送ります。

この関数は次の例のようにイベントループをプログラミングするときに使われます。

Dispatches the next event in the windowing system event queue.

This can be used for programming event loops, e.g.

  while (app.Pending())
    Dispatch();
See also

wxApp::Pending


wxApp::FilterEvent

int FilterEvent(wxEvent& event)

この関数はあらゆるイベント処理に先駆けて呼ばれ、アプリケーションが何らかのイベント処理を前もって行うのを 許可します。

This function is called before processing any event and allows the application to preempt the processing of some events.

案1. イベントが普通に処理されれば、このメソッドは-1を返します。そうでない場合は、TRUEもしくはFALSEを 返し、以下に従って直ちにイベント処理を止めるべきです。イベント処理はすでにされていたなら戻り値はTRUE。 あらゆる処理をしていないならFALSE。

案2. イベントが普通に処理されれば、このメソッドは-1を返します。そうでない場合は、イベントがすでに処理されている(TRUE)か 全く処理しようとしていない(FALSE)かを検討して、TRUEかFALSEが返され、イベント処理はすぐにとまります。

(訳注:多分案2のような気がします。)

If this method returns -1 the event is processed normally, otherwise either TRUE or FALSE should be returned and the event processing stops immediately considering that the event had been already processed (for the former return value) or that it is not going to be processed at all (for the latter one).


wxApp::GetAppName

wxString GetAppName() const

アプリケーションの名前を返します。

Returns the application name.

Remarks

wxWindowクラスがwxApp::OnInitを呼ぶ前に相応のデフォルト値を設定しますが、アプリケーションは自由にリセットできます。

wxWidgets sets this to a reasonable default before calling wxApp::OnInit, but the application can reset it at will.


wxApp::GetAuto3D

bool GetAuto3D() const

3DコントロールモードならTRUEがそうでなければFALSEを返します。

Returns TRUE if 3D control mode is on, FALSE otherwise.

See also

wxApp::SetAuto3D


wxApp::GetClassName

wxString GetClassName() const

アプリケーションのクラス名を取得します。 クラス名は、プラットホーム固有な方法でアプリケーションを参照するために使われます。
Gets the class name of the application. The class name may be used in a platform specific manner to refer to the application.

See also

wxApp::SetClassName


wxApp::GetExitOnFrameDelete

bool GetExitFrameOnDelete() const

トップレベルウィンドウが削除されたとき、アプリケーションが終了するなら(すれば)、 TRUEを返します。そうでなければ、FALSEを返します。

Returns TRUE if the application will exit when the top-level window is deleted, FALSE otherwise.

See also

wxApp::SetExitOnFrameDelete,
wxApp shutdown overview


wxApp::GetTopWindow

virtual wxWindow * GetTopWindow() const

トップウィンドウへのポインタを返す。

Returns a pointer to the top window.

Remarks

もし、wxApp::SetTopWindowを使ってトップウィンドウが設定されたのでなければ、 この関数は最初のトップレベルウィンドウ(フレームかダイアログ)を見つけてそれを返します。

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

See also

SetTopWindow


wxApp::GetUseBestVisual

bool GetUseBestVisual() const

アプリケーションが、異なる外観をサポートしているシステム上でベストな外観を 使っていればTRUEをそうでなければFALSEを返します。
(訳注:OSが提供するコントロールなどの外観とwxWindowが 提供する外観のどちらを使用しているかによるということでしょうか?)
たぶん、gtk+とかの話じゃないのかな? -- by 灰
Returns TRUE if the application will use the best visual on systems that support different visuals, FALSE otherwise.

See also

SetUseBestVisual


wxApp::GetVendorName

wxString GetVendorName() const

アプリケーションのベンダの名前を返します。

Returns the application's vendor name.


wxApp::ExitMainLoop

void ExitMainLoop()

メインメッセージループ(イベント)を終了する際、この関数を明示的に呼びます。 普通、トップウィンドウを削除する際にメインループ(とアプリケーション)を終了するべきでしょう。

Call this to explicitly exit the main message (event) loop. You should normally exit the main loop (and the application) by deleting the top window.


wxApp::Initialized

bool Initialized()

アプリケーションが初期化されればTRUEを返します(例wxApp::OnInitが成功したら)。 この関数は、どの出力方法がプログラムの現在の状態にとって最適かをエラーメッセージ ルーチンが決めるのに役立ちます。 (いくつかのウィンドウシステムではメインループに入る前にダイアログをポップアップすることを 好まないようです。)

Returns TRUE if the application has been initialized (i.e. if wxApp::OnInit has returned successfully). This can be useful for error message routines to determine which method of output is best for the current state of the program (some windowing systems may not like dialogs to pop up before the main loop has been entered).


wxApp::MainLoop

int MainLoop()

アプリケーションの作成の際、wxWidgetsによって呼ばれます。 自作の(環境依存する)メインループを提供したい場合はこの関数をオーバーライドしてください。
(訳注:int MainLoop() => virtual int MainLoopのような気がします。他の関数とかも。)

Called by wxWidgets on creation of the application. Override this if you wish to provide your own (environment-dependent) main loop.

Return value

Xの場合0が、Windowsの場合WM_QUITを返します。

Returns 0 under X, and the wParam of the WM_QUIT message under Windows.


wxApp::OnAssert

void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg)

この関数はアサート失敗が起こったときに呼ばれます。 例.wxASSERTマクロで値がFALSEだと評価された状態。 この関数はデバッグモード(__WXDEBUG__が定義されているとき)でのみ呼ばれ、 リリースコードでは全く残りません。

This function is called when an assert failure occurs, i.e. the condition specified in wxASSERT macro evaluated to FALSE. It is only called in debug mode (when __WXDEBUG__ is defined) as asserts are not left in the release code at all.
ベースクラスバージョンではデフォルトのASSERT失敗ダイアログを出して、 プログラムを止めるか続けるか、あるいは今後起こるアサートをすべて無視するかをユーザーに 提示します。
The base class version show the default assert failure dialog box proposing to the user to stop the program, continue or ignore all subsequent asserts.
Parameters

file

line

cond

msg


wxApp::OnExit

int OnExit()

この関数はアプリケーションが終了しようとしていることを知る必要のある処理のために用意されています。 OnExitはすべてのウィンドウやコントロールが壊された後かつ、wxWidgetsがなくなる前に呼ばれます。
(訳注:おそらく、WindowsのWM_DESTROYでの処理と同等でしょう。)

Provide this member function for any processing which needs to be done as the application is about to exit. OnExit is called after destroying all application windows and controls, but before wxWidgets cleanup.


wxApp::OnCmdLineError

bool OnCmdLineError(wxCmdLineParser& parser)

コマンドラインのパースに失敗したとき(例.ユーザによる不正なコマンドラインオプションであると分かったとき)に呼ばれます。

Called when command line parsing fails (i.e. an incorrect command line option was specified by the user). The default behaviour is to show the program usage text and abort the program.

通常に実行を続ける場合はTRUEを、OnInitからFALSEが返った場合、つまりプログラムを終わらせる場合はFALSEを返します。

Return TRUE to continue normal execution or FALSE to return FALSE from OnInit thus terminating the program.

See also

OnInitCmdLine


wxApp::OnCmdLineHelp

bool OnCmdLineHelp(wxCmdLineParser& parser)

コマンドラインにヘルプオプション(--help)があったときに呼ばれます。デフォルトではプログラムのusage(コマンドライン構文)を示してプログラムは終了します。

Called when the help option (--help) was specified on the command line. The default behaviour is to show the program usage text and abort the program.

通常に実行を続ける場合はTRUEを、OnInitからFALSEが返った場合、つまりプログラムを終わらせる場合はFALSEを返します。

Return TRUE to continue normal execution or FALSE to return FALSE from OnInit thus terminating the program.

See also

OnInitCmdLine


wxApp::OnCmdLineParsed

bool OnCmdLineParsed(wxCmdLineParser& parser)

コマンドラインのパースに成功した後に呼ばれます。コマンドラインに指定されたパラメータのテストのためにこのメソッドをオーバーライドすることができます。

Called after the command line had been successfully parsed. You may override this method to test for the values of the various parameters which could be set from the command line.

もし、通常のコマンドラインオプションの処理を続けたいのなら、基底クラスの メソッドを呼ぶことを忘れてはいけません。

Don't forget to call the base class version unless you want to suppress processing of the standard command line options.

通常に実行を続ける場合はTRUEを、OnInitからFALSEが返った場合、つまりプログラムを終わらせる場合はFALSEを返します。

Return TRUE to continue normal execution or FALSE to return FALSE from OnInit thus terminating the program.

See also

OnInitCmdLine


wxApp::OnFatalException

void OnFatalException()

この関数は何らかの致命的なエラー:例えば、Win32ならUnhandled Exeption、UnixならFatal Signalが発生したら呼ばれます。しかし、これはデフォルトでは発生しません:この関数(が呼ばれること)を有効にするには、明示的にwxHandleFatalExceptionsを呼ぶ必要があります。

This function may be called if something fatal happens: an unhandled exception under Win32 or a a fatal signal under Unix, for example. However, this will not happen by default: you have to explicitly call wxHandleFatalExceptions to enable this.

一般的に、この関数はユーザーにメッセージを見せて返るだけにすべきです。もし、(この関数内で)未保存のデータを保存しようとしたとしても、それがうまくいくかは未保証で、実際に、多分うまくいかないでしょう。

Generally speaking, this function should only show a message to the user and return. You may attempt to save unsaved data but this is not guaranteed to work and, in fact, probably won't.

See also

wxHandleFatalExcetions


wxApp::OnInit

bool OnInit()

この関数はアプリケーションによって提供する必要があります。そして、普通はwxApp::SetTopWindowを呼んでウィンドウを作成します。

This must be provided by the application, and will usually create the application's main window, optionally calling wxApp::SetTopWindow.

wxWidgetsを使ってコマンドライン処理をしたい場合は継承先のOnInitから基底クラス(wxApp)のOnInit()を呼ばなければならないことに注意してください。

Notice that if you want to to use the command line processing provided by wxWidgets you have to call the base class version in the derived class OnInit().

処理を続ける場合はTRUEを、アプリケーションを終了する場合(参加しない方が良いか)はFALSEを返します。

Return TRUE to continue processing, FALSE to exit the application.


wxApp::OnInitCmdLine

void OnInitCmdLine(wxCmdLineParser& parser)

OnInitから呼ばれ、 アプリケーションのコマンドラインをパースして初期化するために使われます。 基底クラスはわずかな基本的オプションしかサポートしていません。

Called from OnInit and may be used to initialize the parser with the command line options for this application. The base class versions adds support for a few standard options only.


wxApp::OnQueryEndSession

void OnQueryEndSession(wxCloseEvent& event)

この関数はOSかGUIセッションが終了しようとしているときに呼ばれるイベントハンドラです。 典型的には、アプリケーションはここで未保存のデータを保存します。

This is an event handler function called when the operating system or GUI session is about to close down. Typically, an application will try to save unsaved documents at this point.

もし、wxCloseEvent::CanVetoがTRUEを返せば、 アプリケーションはwxCloseEvent::Veto を呼ぶことによってシャットダウンを拒否することが許されています。 データの保存プロンプトを表示して、ユーザーが保存をキャンセルした後に アプリケーションはシャットダウンを拒否してはどうでしょう。

If wxCloseEvent::CanVeto returns TRUE, the application is allowed to veto the shutdown by calling wxCloseEvent::Veto. The application might veto the shutdown after prompting for documents to be saved, and the user has cancelled the save.

クエリ終了セッションイベントを操作するためにはEVT_QUERY_END_SESSIONマクロを 使います。

Use the EVT_QUERY_END_SESSION event table macro to handle query end session events.

wxCloseEvent::GetForceでアプリケーションがウィンドウの削除を強制されるかどうかを チェックすべきです。もしこれがTRUEなら、 wxWindow::Destroy でウィンドウを削除してください。 そうでなければ、ウィンドウを削除するのに応答するかどうかはプログラマ次第です。

You should check whether the application is forcing the deletion of the window using wxCloseEvent::GetForce. If this is TRUE, destroy the window using wxWindow::Destroy. If not, it is up to you whether you respond by destroying the window.

デフォルトのハンドラは最上面ウィンドウのwxWindow::Closeを 呼びます。 そして、FALSEが返ってくればシャットダウンを拒否します。 こうすることで多くのアプリケーションでは十分です。

The default handler calls wxWindow::Close on the top-level window, and vetoes the shutdown if Close returns FALSE. This will be sufficient for many applications.

Remarks

XではOnQueryEndSessionは'save session'イベントに応えて飛ばれます。

Under X, OnQueryEndSession is called in response to the 'save session' event.

WindowsではWM_QUERYENDSESSIONメッセージに応えて呼ばれます。

Under Windows, OnQueryEndSession is called in response to the WM_QUERYENDSESSION message.

See also

wxWindow::Close, wxCloseEvent


wxApp::ProcessMessage

bool ProcessMessage(WXMSG *msg)

メッセージを処理するWindowsのみの関数です。 この関数はメインメッセージループから呼ばれ、 ウィンドウがそのメッセージを処理しようとするかをチェックします。 メッセージが処理されるならTRUEをそうでなければFALSEをこの関数は返します。 もし、wxWidgetsを独自のメッセージループを持つ別のクラスライブラリで使うのなら、 wxWidgetsがきちんとメッセージを受け取れるように この関数が呼ばれていることをチェックしてください。 例えば、MFCとの共存ができるようにPreTranslateMessage関数をオーバーライドしてください。

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:

// wxWidgetsのメッセージループの互換を提供する
// Provide wxWidgets message loop compatibility
BOOL CTheApp::PreTranslateMessage(MSG *msg) { if (wxTheApp && wxTheApp->ProcessMessage((WXMSW *)msg)) return TRUE; else return CWinApp::PreTranslateMessage(msg); }

wxApp::Pending

bool Pending()

処理されていないイベントがウィンドウのイベントキューにあればTRUEを返します。

Returns TRUE if unprocessed events are in the window system event queue.

See also

wxApp::Dispatch


wxApp::SendIdleEvents

bool SendIdleEvents()

すべてのトップレベルウィンドウにアイドルイベントを送ります。

Sends idle events to all top-level windows.

bool SendIdleEvents(wxWindow* win)

指定したウィンドウとその子ウィンドウにアイドルイベントを送ります。

Sends idle events to a window and its children.

Remarks

この関数はアイドルイベント処理のため、 トップレベルウィンドウとその子ウィンドウを調べます。 で、TRUEが返れば、OnIdle処理が1つあるいは複数のウィンドウから要求されています。

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


wxApp::SetAppName

void SetAppName(const wxString& name)

アプリケーション名を設定します。 名前はダイアログで(例えばドキュメント/ビューフレームによって) 使われるかもしれません。デフォルト名はwxWidgetsによって設定されます。
Sets the name of the application. The name may be used in dialogs (for example by the document/view framework). A default name is set by wxWidgets.

See also

wxApp::GetAppName


wxApp::SetAuto3D

void SetAuto3D(const bool auto3D)

自動的に3Dコントロールにするかどうかを切り替えます。

Switches automatic 3D controls on or off.

Parameters

auto3D

Remarks

Windowsでのみこの関数は効果を持っています。
(訳注:effectというのはXPスタイルとかのこと?)

This has an effect on Windows only.

See also

wxApp::GetAuto3D


wxApp::SetClassName

void SetClassName(const wxString& name)

アプリケーションのクラス名を設定します。クラス名は特定のプラットフォームで、アプリケーションを照合するために使われます。
Sets the class name of the application. This may be used in a platform specific manner to refer to the application.

See also

wxApp::GetClassName


wxApp::SetExitOnFrameDelete

void SetExitOnFrameDelete(bool flag)

ウィンドウのフレームが削除されたときにアプリケーションが 終了するかどうかをプログラマが選ぶことができます。

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

Parameters

flag

See also

wxApp::GetExitOnFrameDelete,
wxApp shutdown overview


wxApp::SetTopWindow

void SetTopWindow(wxWindow* window)

'top'ウィンドウを設定します。 wxWidgetsにどれがメインウィンドウかを知らせるために この関数は呼ばれますが、wxApp::OnInit内からしか 呼ぶことができません。 プログラマは自分でトップウィンドウを設定する必要はありません ;(例えば)ある親ウィンドウを持たないダイアログが特定のウィンドウを トップウィンドウとして用いることのできるので便利なだけです。
(訳注:変な訳ですなぁ)
アプリケーションがトップレベルウィンドウをひとつも指定しない場合、 必要に応じて最初のフレームまたはダイアログをトップレベルウィンドウとして wxWidgetsのリストに入れて使います。

Sets the 'top' window. You can call this from within wxApp::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

See also

wxApp::GetTopWindow, wxApp::OnInit


wxApp::SetVendorName

void SetVendorName(const wxString& name)

アプリケーションのベンダを設定します。 名前はレジストリアクセスに使われます。 デフォルトの名前はwxWidgetsが設定します。

Sets the name of application's vendor. The name will be used in registry access. A default name is set by wxWidgets.

See also

wxApp::GetVendorName


wxApp::SetUseBestVisual

void SetUseBestVisual(bool flag)

アプリケーションが同じディスプレイでいくつかの 外観をサポートしているシステム上でベストな外観を 使用するかどうかをプログラマが許可します。 これは典型的にSolarisとIRIXでのケースです。 これらのOSではデフォルトの外観は8bitなのに対して 特定のアプリケーションではTrueColorモードでの実行をサポートしています。

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.

この関数はwxAppのコンストラクタ内で呼ばなければならず、 その後に呼んでも何の効果もないことに注意してください。

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.

この関数は現在のところGTKでのみ有効です。

This function currently only has effect under GTK.

Parameters

flag


wxApp::Yield

bool Yield(bool onlyIfNeeded = FALSE)

Yield(処理の明け渡し)はウィンドウシステムでペンディング(未処理)メッセージを 制御します。これは例えば時間のかかる処理がテキストウィンドウに 書き込むときに役に立ちます。時々のYieldがないと、 テキストウィンドウは適切に更新できません。 さらにWindows3.1のように協調的なマルチタスクのシステムでは 他のプロセスが応答できないでしょう。
(訳注:テキストウィンドウ => コンソールウィンドウのことでしょうか。)

Yields control to pending messages in the windowing system. This can be useful, for example, when a time-consuming process writes to a text window. Without an occasional yield, the text window will not be updated properly, and on systems with cooperative multitasking, such as Windows 3.1 other processes will not respond.

しかしながら、使用には注意が必要です。 というのはyieldingはユーザーが現在のタスクと共存できない操作を 許可するかもしれないからです。 処理の実行中はメニューを無効にしておけば、 実行してほしくないコードの再実行を避けることができます。 ベターな関数として::wxSafeYieldも見てください。

Caution should be exercised, however, since yielding may allow the user to perform actions which are not compatible with the current task. Disabling menu items or whole menus during processing can avoid unwanted reentrance of code: see ::wxSafeYield for a better function.

Yield関数はメッセージのログをフラッシュしないことに注意してください。 このことはYeild関数を呼ぶのはたいていがすばやくスクリーンを更新したり、 メッセージボックスを使うのが不適切な場合に使われるので、 意図してしていることです。 ログメッセージをすぐにフラッシュしたい(もしくは次のアイドルループ中にしたい)場合は、 wxLog::FlushActive関数を呼んでください。

Note that Yield() will not flush the message logs. This is intentional as calling Yield() is usually done to quickly update the screen and popping up a message box dialog may be undesirable. If you do wish to flush the log messages immediately (otherwise it will be done during the next idle loop iteration), call wxLog::FlushActive.

再帰的にYield関数を呼ぶのは普通はエラーで、 デバッグ版でそのような状況を見つければアサート失敗が立ちます。 しかし、onlyIfNeededがTRUEのときにはメソッドは アサーションの代わりにただFALSEを返すだけです。
Calling Yield() recursively is normally an error and an assert failure is raised in debug build if such situation is detected. However if the the onlyIfNeeded parameter is TRUE, the method will just silently return FALSE instead.