wxApp
wxAppクラスはアプリケーション自身をあらわしています。以下の様に使われます。
The wxApp class represents the application itself. It is used to:
- アプリケーションレベルのプロパティの設定と取得
- ウィンドウメッセージまたはイベントループのインプリメント(手段)
- wxApp::OnInitによってアプリケーションの処理の初期化
- アプリケーション内の他のオブジェクトが処理しないデフォルトのイベント処理の許可
- set and get application-wide properties;
- implement the windowing system message or event loop;
- initiate application processing via wxApp::OnInit;
- allow default processing of events not handled by other
objects in the application.
アプリケーションクラスのインスタンスをどのように作るかを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.
継承元
wxEvtHandler
wxObject
インクルードファイル
<wx/app.h>
参照
wxApp overview
メンバ
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が返され、イベント処理はすぐにとまります。
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.
注
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
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を返します。
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によって呼ばれます。
自作の(環境依存する)メインループを提供したい場合はこの関数をオーバーライドしてください。
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
// 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でのみこの関数は効果を持っています。
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
The new top 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.
This function currently only has effect under GTK.
Parameters
flag
If TRUE, the app will use the best visual.
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.