Contents Up Previous Next 原文へのリンク

wxEvtHandler

このクラスは、ウィンドウシステムからのイベントをハンドリングすることができます。 wxWindow クラス (したがって、全てのウィンドウクラス) はこのクラスから派生しています。
A class that can handle events from the windowing system. wxWindow (and therefore all window classes) are derived from this class.

Derived from

wxObject

Include files

<wx/event.h>

See also

Event handling overview

Members

wxEvtHandler::wxEvtHandler
wxEvtHandler::~wxEvtHandler
wxEvtHandler::AddPendingEvent
wxEvtHandler::Connect
wxEvtHandler::Disconnect
wxEvtHandler::GetClientData
wxEvtHandler::GetClientObject
wxEvtHandler::GetEvtHandlerEnabled
wxEvtHandler::GetNextHandler
wxEvtHandler::GetPreviousHandler
wxEvtHandler::ProcessEvent
wxEvtHandler::SearchEventTable
wxEvtHandler::SetClientData
wxEvtHandler::SetClientObject
wxEvtHandler::SetEvtHandlerEnabled
wxEvtHandler::SetNextHandler
wxEvtHandler::SetPreviousHandler


wxEvtHandler::wxEvtHandler

wxEvtHandler()

コンストラクタ。
Constructor.


wxEvtHandler::~wxEvtHandler

~wxEvtHandler()

デストラクタ。 もしハンドラがチェインの一つであれば、 デストラクタは自分自身をそれから切り離し、 そして、前後のハンドラがそれぞれを指すように修復します。
Destructor. If the handler is part of a chain, the destructor will unlink itself and restore the previous and next handlers so that they point to each other.


wxEvtHandler::AddPendingEvent

virtual void AddPendingEvent(wxEvent& event)

この関数はその後処理されるイベントを追加します。
This function posts an event to be processed later.

Parameters

event

Remarks

(ProcessEvent メソッドを使って) イベントを送る(send)ことと、ポストすることとの違いは、 前者においては関数が帰る前にイベントは処理されるが、 後者においては関数は直ちに帰り、 そしてイベントはその後いつか(大抵、次のイベントループの繰り返しの間に)処理されることです。
The difference between sending an event (using the ProcessEvent method) and posting it is that in the first case the event is processed before the function returns, while in the second case, the function returns immediately and the event will be processed sometime later (usually during the next event loop iteration).

イベントのコピーは関数によって作られ、 オリジナルは関数が戻るとすぐに削除されます (一般的にオリジナルはスタック上に作られる)。 これは、それが処理されるまで複製と保存(stored)ができるように、 wxEvent::Clone メソッドがイベントにより実装されていることを要求します。
A copy of event is made by the function, so the original can be deleted as soon as function returns (it is common that the original is created on the stack). This requires that the wxEvent::Clone method be implemented by event so that it can be duplicated and stored until it gets processed.

これもまた、スレッド間通信のために呼ばれるメソッドです。 --- これは異なるスレッド間で安全にポストします。 このメソッドは必要とされる場所でクリティカルセクションを使用することによってスレッドセーフであることを意味します。 マルチスレッドプログラムにおいて、 あなたはたびたびメイン GUI スレッドに他の動作中のスレッドの状態を知らせる必要があります。 そして、そのような通知はこのメソッドを使うことで行われるべきです。
This is also the method to call for inter-thread communication---it will post events safely between different threads which means that this method is thread-safe by using critical sections where needed. In a multi-threaded program, you often need to inform the main GUI thread about the status of other working threads and such notification should be done using this method.

基盤となるウィンドウシステムが現在アイドル状態で、 少しのアイドルイベントも送らないならば、 このメソッドは自動的にアイドル処理を起動します。 (アイドル処理は ::wxWakeUpIdle を呼び出すことで起動されます。)
This method automatically wakes up idle handling if the underlying window system is currently idle and thus would not send any idle events. (Waking up idle handling is done calling ::wxWakeUpIdle.)


wxEvtHandler::Connect

void Connect(int id, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL)

void Connect(int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL)

イベントハンドラ、ID、そしてイベントタイプと共に与えられた関数を動的に接続します。 これは静的イベントテーブルの使用に代わるものです。 使用方は 'dynamic' サンプルを参照してください。
Connects the given function dynamically with the event handler, id and event type. This is an alternative to the use of static event tables. See the 'dynamic' sample for usage.

Parameters

id

lastId

eventType

function

userData

Example

  frame->Connect( wxID_EXIT,
    wxEVT_COMMAND_MENU_SELECTED,
    (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) MyFrame::OnQuit );

wxEvtHandler::Disconnect

bool Disconnect(int id, wxEventType eventType = wxEVT_NULL, wxObjectEventFunction function = NULL, wxObject* userData = NULL)

bool Disconnect(int id, int lastId = -1, wxEventType eventType = wxEVT_NULL, wxObjectEventFunction function = NULL, wxObject* userData = NULL)

検索基準としての指定されたパラメータを使用して、 動的に与えられた関数をイベントハンドラからの切断します。 もし、マッチした関数を発見し削除したならば TRUE を返します。 このメソッドは、 wxEvtHandler::Connect メソッドを使用して追加された関数の切断にしか使用できません。 (静的な)イベントテーブルを使用して接続された関数を切断する方法はありません。
Disconnects the given function dynamically from the event handler, using the specified parameters as search criteria and returning TRUE if a matching function has been found and removed. This method can only disconnect functions which have been added using the wxEvtHandler::Connect method. There is no way to disconnect functions connected using the (static) event tables.

Parameters

id

lastId

eventType

function

userData


wxEvtHandler::GetClientData

void* GetClientData()

ユーザにより供給されたクライアントデータを取得する。
Gets user-supplied client data.

Remarks

通常、プログラマがオブジェクトと関連付けたいと望むいかなる追加データも、 新しいデータメンバと共に新しいクラスを派生することによって、 利用することができるように作られるべきです。
Normally, any extra data the programmer wishes to associate with the object should be made available by deriving a new class with new data members.

See also

wxEvtHandler::SetClientData


wxEvtHandler::GetClientObject

wxClientData* GetClientObject() const

ユーザによって供給されたクライアントデータオブジェクトへのポインタを取得する。
Get a pointer to the user-supplied client data object.

See also

wxEvtHandler::SetClientObject, wxClientData


wxEvtHandler::GetEvtHandlerEnabled

bool GetEvtHandlerEnabled()

イベントハンドラが有効なら TRUE 、それ以外は FALSE を返す。
Returns TRUE if the event handler is enabled, FALSE otherwise.

See also

wxEvtHandler::SetEvtHandlerEnabled


wxEvtHandler::GetNextHandler

wxEvtHandler* GetNextHandler()

チェインの中の次のハンドラへのポインタを取得する。
Gets the pointer to the next handler in the chain.

See also

wxEvtHandler::SetNextHandler, wxEvtHandler::GetPreviousHandler, wxEvtHandler::SetPreviousHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler


wxEvtHandler::GetPreviousHandler

wxEvtHandler* GetPreviousHandler()

チェインの中の前のハンドラへのポインタを取得する。
Gets the pointer to the previous handler in the chain.

See also

wxEvtHandler::SetPreviousHandler, wxEvtHandler::GetNextHandler, wxEvtHandler::SetNextHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler


wxEvtHandler::ProcessEvent

virtual bool ProcessEvent(wxEvent& event)

イベントテーブルを検索しイベントを処理します。 そして、ゼロかより適切なイベントハンドラ関数(複数)を呼び出します。
Processes an event, searching event tables and calling zero or more suitable event handler function(s).

Parameters

event

Return value

適切なイベントハンドラを発見し実行したのなら TRUE 。 また、この関数は wxEvent::Skip を呼び出しません。
TRUE if a suitable event handler function was found and executed, and the function did not call wxEvent::Skip.

Remarks

通常、フレームワーク(と、アプリケーション)に送られるユーザインターフェイスイベントのディスパッチは、 wxWidgets の実装の中から呼ばれるため、 あなたのアプリケーションからこの関数を呼ぶことはないでしょう。
Normally, your application would not call this function: it is called in the wxWidgets implementation to dispatch incoming user interface events to the framework (and application).

しかし、新しい機能(新しいコントロールのような)を実装している場合、 ユーザが仮想関数をオーバーライドすることができることに対して、 新しいイベントタイプを定義するところで、 あなたはそれを呼ぶ必要があるかもしれません。
However, you might need to call it if implementing new functionality (such as a new control) where you define new event types, as opposed to allowing the user to override virtual functions.

あなたが、ProcessEvent 関数を実際にオーバーライドするかもしれない例は、 あなたが、通常 wxWidgets によって通常通知されなかったイベント処理をイベントハンドラに指示したいときです。 例えば、ドキュメント/ビューアーキテクチャにおいて、ドキュメントとビューは潜在的なイベントハンドラです。 イベントがフレームに届く時、 イベントハンドラ関数がそれらのオブジェクトに関連付けられている場合において、 ProcessEvent は、関連付けられたドキュメントとビュー上で呼び出される必要があります。 プロパティクラスライブラリ(wxProperty)もまた、同じような理由で ProcessEvent をオーバーライドします。
An instance where you might actually override the ProcessEvent function is where you want to direct event processing to event handlers not normally noticed by wxWidgets. For example, in the document/view architecture, documents and views are potential event handlers. When an event reaches a frame, ProcessEvent will need to be called on the associated document and view in case event handler functions are associated with these objects. The property classes library (wxProperty) also overrides ProcessEvent for similar reasons.

イベントテーブルの通常の走査順序は次の通りです:
The normal order of event table searching is as follows:

  1. もし、オブジェクトが使用不能(disabled) (wxEvtHandler::SetEvtHandlerEnabled 呼び出しを通して) ならば、関数はステップ (6) にスキップします。
    If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled) the function skips to step (6).
  2. もし、オブジェクトが wxWindow クラスならば、 ProcessEvent はウィンドウの wxValidator 上で再帰的に呼び出されます。 もし、これが TRUE を返すならばこの関数は終了します。
    If the object is a wxWindow, ProcessEvent is recursively called on the window's wxValidator. If this returns TRUE, the function exits.
  3. SearchEventTable は、このイベントハンドラのために呼び出されます。 もし、これに失敗するのなら、ベースクラステーブルが試されます。 そして、他のテーブルが存在、または適切な関数がこれ以上発見できない場合は関数は終了します。
    SearchEventTable is called for this event handler. If this fails, the base class table is tried, and so on until no more tables exist or an appropriate function was found, in which case the function exits.
  4. 検索はイベントハンドラの全てのチェイン(大抵はチェインは 1 の長さを持ちます)を下って適用されます。
    The search is applied down the entire chain of event handlers (usually the chain has a length of one). If this succeeds, the function exits.
  5. オブジェクトが wxWindow クラスで、そしてもし、イベントが wxCommandEvent であるならば、 ProcessEventは再帰的に親ウィンドウのイベントハンドラに適用されます。 もし、これが TRUE を返すなら、この関数は終了します。
    If the object is a wxWindow and the event is a wxCommandEvent, ProcessEvent is recursively applied to the parent window's event handler. If this returns TRUE, the function exits.
  6. 最後に、ProcessEvent は wxApp オブジェクト上で呼び出されます。
    Finally, ProcessEvent is called on the wxApp object.

See also

wxEvtHandler::SearchEventTable


wxEvtHandler::SearchEventTable

bool SearchEventTable(wxEventTable& table, wxEvent& event)

イベントテーブルを検索します。 もし、該当するものを発見したのならイベントハンドラ関数を実行します。
Searches the event table, executing an event handler function if an appropriate one is found.

Parameters

table

event

Return value

もし、適当なイベントハンドラ関数が発見、実行された場合は TRUE。 そして、この関数は wxEvent::Skip を呼び出しません。
TRUE if a suitable event handler function was found and executed, and the function did not call wxEvent::Skip.

Remarks

この関数は、オブジェクトのイベントテーブルと通し見て、 イベントにマッチさせるエントリを発見しようとします。
This function looks through the object's event table and tries to find an entry that will match the event.

もし、エントリがマッチするなら:
An entry will match if:

  1. このイベントタイプがマッチ、そして
    The event type matches, and
  2. 識別子か識別子の範囲がマッチ、またはそのイベントテーブルエントリの識別子がゼロ。
    the identifier or identifier range matches, or the event table entry's identifier is zero.

もし、適切な関数が呼ばれ、しかし wxEvent::Skip が呼ばれたなら、この関数は失敗し、そして検索は続行されるでしょう。
If a suitable function is called but calls wxEvent::Skip, this function will fail, and searching will continue.

See also

wxEvtHandler::ProcessEvent


wxEvtHandler::SetClientData

void SetClientData(void* data)

ユーザから提供されるクライアントデータをセット。
Sets user-supplied client data.

Parameters

data

Remarks

通常、プログラマがオブジェクトと関連付けたいと望むいかなる追加データも、 新しいデータメンバと共に新しいクラスを派生することによって、 利用することができるように作られるべきです。 このメソッドと SetClientObject を同じクラス上で呼び出してはいけません - どちらか一つ。
Normally, any extra data the programmer wishes to associate with the object should be made available by deriving a new class with new data members. You must not call this method and SetClientObject on the same class - only one of them.

See also

wxEvtHandler::GetClientData


wxEvtHandler::SetClientObject

void SetClientObject(wxClientData* data)

クライアントデータオブジェクトをセットする。 いかなる前のオブジェクトも削除されるでしょう。
Set the client data object. Any previous object will be deleted.

See also

wxEvtHandler::GetClientObject, wxClientData


wxEvtHandler::SetEvtHandlerEnabled

void SetEvtHandlerEnabled(bool enabled)

イベントハンドラの有効化、無効化。
Enables or disables the event handler.

Parameters

enabled

Remarks

例えば、あなたはダイアログエディタを実装していて、編集からテストモードに変更するときに、 チェインからイベントハンドラを削除しなければならないことを避けるために、この関数を使用することができます。
You can use this function to avoid having to remove the event handler from the chain, for example when implementing a dialog editor and changing from edit to test mode.

See also

wxEvtHandler::GetEvtHandlerEnabled


wxEvtHandler::SetNextHandler

void SetNextHandler(wxEvtHandler* handler)

次のハンドラへのポインタをセットする。
Sets the pointer to the next handler.

Parameters

handler

See also

wxEvtHandler::GetNextHandler, wxEvtHandler::SetPreviousHandler, wxEvtHandler::GetPreviousHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler


wxEvtHandler::SetPreviousHandler

void SetPreviousHandler(wxEvtHandler* handler)

前のハンドラへのポインタをセットする。
Sets the pointer to the previous handler.

Parameters

handler

See also

wxEvtHandler::GetPreviousHandler, wxEvtHandler::SetNextHandler, wxEvtHandler::GetNextHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler