[Sofaswitch-svn] [commit] r422 - sofaswitch/trunk/callflow/src
Author: derek Date: Mon Jun 16 01:10:08 2008 New Revision: 422 Modified: sofaswitch/trunk/callflow/src/callflow.cpp sofaswitch/trunk/callflow/src/callflow.h sofaswitch/trunk/callflow/src/canvas.cpp sofaswitch/trunk/callflow/src/canvas.h Log: Another attempt to make event handling of key clicks work. Modified: sofaswitch/trunk/callflow/src/callflow.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.cpp (original) +++ sofaswitch/trunk/callflow/src/callflow.cpp Mon Jun 16 01:10:08 2008 @@ -167,7 +167,8 @@ { // create a child control here canvas = new MyCanvas(this); - + canvas->PushEventHandler(new KeyEvtHandler(*canvas)); + // menu setup goes here tbarVertical = NULL; wxMenu * Edit_menu = new wxMenu ; @@ -230,7 +231,7 @@ void MyFrame::OnKeyDown(wxKeyEvent & event) { - canvas->OnKeyDown(event); + canvas->HandleKeyDown(event); } void MyFrame::OnClose (wxCloseEvent& event) Modified: sofaswitch/trunk/callflow/src/callflow.h ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.h (original) +++ sofaswitch/trunk/callflow/src/callflow.h Mon Jun 16 01:10:08 2008 @@ -83,10 +83,13 @@ /**Destructor */ ~MyFrame (); + protected: /**Process event - character read from the keyboard when the key is pressed */ void OnKeyDown(wxKeyEvent & event); - + + public: + /**Called in response to a shutdown command issued from somewhere */ void OnClose (wxCloseEvent& event); Modified: sofaswitch/trunk/callflow/src/canvas.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/canvas.cpp (original) +++ sofaswitch/trunk/callflow/src/canvas.cpp Mon Jun 16 01:10:08 2008 @@ -642,6 +642,23 @@ } +///////////////////////////////////////////////////////////////////////////// + +KeyEvtHandler::KeyEvtHandler(MyCanvas &_myCanvas) +: myCanvas(_myCanvas) +{ +} + +void KeyEvtHandler::OnKeyDown(wxKeyEvent & event) +{ + myCanvas.HandleKeyDown(event); +} + +BEGIN_EVENT_TABLE(KeyEvtHandler, wxEvtHandler) +EVT_KEY_DOWN(KeyEvtHandler::OnKeyDown) +END_EVENT_TABLE(); + + /* The comment below is magic for those who use emacs to edit this file. With * the comment below, the tab key does auto indent to 4 spaces. Modified: sofaswitch/trunk/callflow/src/canvas.h ============================================================================== --- sofaswitch/trunk/callflow/src/canvas.h (original) +++ sofaswitch/trunk/callflow/src/canvas.h Mon Jun 16 01:10:08 2008 @@ -25,9 +25,10 @@ /**Destroy this canvas, which is called by the system on close down */ ~MyCanvas (); - /**Process event - character read from the keyboard when the key - is pressed */ - void OnKeyDown(wxKeyEvent & event); + + /**Alllow the onKeyDown method to be called... */ + void HandleKeyDown(wxKeyEvent & event) + { OnKeyDown(event); } /**Process event - left mouse button has been pressed */ void OnLeftDown (wxMouseEvent & event); @@ -124,9 +125,13 @@ bool Compile(wxTextFile & file) { return activeShapes.Compile(file); } - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE(); protected: + /**Process event - character read from the keyboard when the key + is pressed */ + void OnKeyDown(wxKeyEvent & event); + /**Given a mouse event at some location, what is the correct (in this canvas view point) location of this event? This method returns the value sought. */ @@ -182,6 +187,34 @@ /**The mouse position at which we were told the mouse last moved */ wxPoint lastMouseMovePoint; }; + +///////////////////////////////////////////////////////////////////////////// + + +class KeyEvtHandler : public wxEvtHandler +{ +public: + /**Constructor */ + KeyEvtHandler(MyCanvas & _myCanvas); + + /**The key down event goes here */ + void OnKeyDown(wxKeyEvent & event); + +private: + /**Reference back to the class that has to collect the event */ + MyCanvas & myCanvas; + + /**Make WxWidgets happy, use this macro, which means we collect + key events in this class */ + DECLARE_EVENT_TABLE() +}; + + + + + + + #endif
participants (1)
-
SofaSWITCH SVN