]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed and clarified editor control event handling
authorJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 26 Sep 2008 18:20:17 +0000 (18:20 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 26 Sep 2008 18:20:17 +0000 (18:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/editors.h
include/wx/propgrid/propgrid.h
interface/wx/propgrid/editors.h
src/propgrid/editors.cpp
src/propgrid/propgrid.cpp

index 656cef681e1a8b2f44a57bde25cc6e4ef7514b79..7a6a1e3e2b45bbf9655717fdef9ea4d2299b8b1e 100644 (file)
@@ -113,20 +113,16 @@ public:
         @remarks
         - Primary control shall use id wxPG_SUBID1, and secondary (button)
           control shall use wxPG_SUBID2.
-        - Implementation shoud use connect all necessary events to the
+        - Implementation shoud connect all necessary events to the
           wxPropertyGrid::OnCustomEditorEvent. For Example:
             @code
                 // Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
                 // control to the OnEvent.
-                // NOTE: This event in particular is actually automatically
-                // conveyed, but it is just used as an example.
-                propgrid->Connect(wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
-                                  wxCommandEventHandler(
-                                    wxPropertyGrid::OnCustomEditorEvent));
+                propgrid->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
+                                  wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
             @endcode
-            OnCustomEditorEvent will then forward events, first to
-            wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
-
+          OnCustomEditorEvent will then forward events, first to
+          wxPGEditor::OnEvent() and then to wxPGProperty::OnEvent().
     */
     virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
                                           wxPGProperty* property,
index 4fce66d137174555c1a86611e83dffb335eff41c..23fe4b1f1bbd919012b5f1427c995635ce39bb76 100644 (file)
@@ -1792,8 +1792,8 @@ protected:
 
     void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
 
-    // Setups event handling for child control
-    void SetupEventHandling( wxWindow* wnd, int id );
+    // Sets up basic event handling for child control
+    void SetupChildEventHandling( wxWindow* wnd, int id );
 
     void CustomSetCursor( int type, bool override = false );
 
index 40e1f76b76cbb754ff9af1e5f5a3f8c4ec1039b2..693112e573181068a86a1b2c59858f4490fe4007 100644 (file)
@@ -65,18 +65,16 @@ public:
         @remarks
         - Primary control shall use id wxPG_SUBID1, and secondary (button) control
           shall use wxPG_SUBID2.
-        - Implementation shoud use connect all necessary events to the
+        - Implementation shoud connect all necessary events to the
           wxPropertyGrid::OnCustomEditorEvent. For Example:
             @code
                 // Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
                 // control to the OnEvent.
-                // NOTE: This event in particular is actually automatically conveyed, but
-                //   it is just used as an example.
-                propgrid->Connect( wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
-                                  wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent) );
+                propgrid->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
+                                  wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
             @endcode
-            OnCustomEditorEvent will then forward events, first to wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
-
+          OnCustomEditorEvent will then forward events, first to
+          wxPGEditor::OnEvent() and then to wxPGProperty::OnEvent().
     */
     virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
         const wxPoint& pos, const wxSize& size ) const = 0;
index dc12656da960ab6e33d0a660fcbfe0bda88d66a2..bddeac99bf3c6e27ae0c172cbcb8e0e394ef7fac 100644 (file)
@@ -1066,6 +1066,15 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
     else
         cb->SetSelection( -1 );
 
+    // Connect event handling
+    wxWindowID id = cb->GetId();
+    propGrid->Connect(id, wxEVT_COMMAND_COMBOBOX_SELECTED,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+    propGrid->Connect(id, wxEVT_COMMAND_TEXT_UPDATED,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+    propGrid->Connect(id, wxEVT_COMMAND_TEXT_ENTER,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+
 #ifdef __WXMSW__
     cb->Show();
 #endif
@@ -1872,6 +1881,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
                                                   int extraStyle,
                                                   int maxLen )
 {
+    wxWindowID id = wxPG_SUBID1;
     wxPGProperty* selected = m_selected;
     wxASSERT(selected);
 
@@ -1908,7 +1918,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
 #if defined(__WXMSW__)
     wnd->Hide();
 #endif
-    wnd->Create(GetPanel(),wxPG_SUBID1,p,s);
+    wnd->Create(GetPanel(),id,p,s);
 
     // This generates rect of the control inside the clipper window
     if ( !hasSpecialSize )
@@ -1933,7 +1943,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
     tc->Hide();
 #endif
     SetupTextCtrlValue(value);
-    tc->Create(ctrlParent,wxPG_SUBID1,value, p, s,tcFlags);
+    tc->Create(ctrlParent,id,value, p, s,tcFlags);
 
 #if wxPG_NAT_TEXTCTRL_BORDER_ANY
     wxWindow* ed = wnd;
@@ -1956,6 +1966,13 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
     if ( maxLen > 0 )
         tc->SetMaxLength( maxLen );
 
+    // Connect event handling
+    id = ed->GetId();
+    this->Connect(id, wxEVT_COMMAND_TEXT_UPDATED,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+    this->Connect(id, wxEVT_COMMAND_TEXT_ENTER,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+
     return (wxWindow*) ed;
 }
 
@@ -1963,6 +1980,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
 
 wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz )
 {
+    wxWindowID id = wxPG_SUBID2;
     wxPGProperty* selected = m_selected;
     wxASSERT(selected);
 
@@ -1975,7 +1993,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
    wxSize s(25, -1);
 
    wxButton* but = new wxButton();
-   but->Create(GetPanel(),wxPG_SUBID2,wxS("..."),p,s,wxWANTS_CHARS);
+   but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS);
 
    // Now that we know the size, move to the correct position
    p.x = pos.x + sz.x - but->GetSize().x - 2;
@@ -2002,7 +2020,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
   #ifdef __WXMSW__
     but->Hide();
   #endif
-    but->Create(GetPanel(),wxPG_SUBID2,wxS("..."),p,s,wxWANTS_CHARS);
+    but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS);
 
   #ifdef __WXGTK__
     wxFont font = GetFont();
@@ -2016,6 +2034,11 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
     if ( selected->HasFlag(wxPG_PROP_READONLY) )
         but->Disable();
 
+    // Connect event handling
+    id = but->GetId();
+    this->Connect(id, wxEVT_COMMAND_BUTTON_CLICKED,
+        wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
+
     return but;
 }
 
index 9ecf73f6b110c6ead6f85560a1222d94caf0cbca..06f9ba5aedd626df8fb41a22f807f415d5874196 100644 (file)
@@ -499,7 +499,6 @@ BEGIN_EVENT_TABLE(wxPropertyGrid, wxScrolledWindow)
   EVT_CHILD_FOCUS(wxPropertyGrid::OnChildFocusEvent)
   EVT_SET_FOCUS(wxPropertyGrid::OnFocusEvent)
   EVT_KILL_FOCUS(wxPropertyGrid::OnFocusEvent)
-  EVT_TEXT_ENTER(wxPG_SUBID1,wxPropertyGrid::OnCustomEditorEvent)
   EVT_SYS_COLOUR_CHANGED(wxPropertyGrid::OnSysColourChanged)
 END_EVENT_TABLE()
 
@@ -3471,33 +3470,38 @@ void wxPropertyGrid::CustomSetCursor( int type, bool override )
 // wxPropertyGrid property selection
 // -----------------------------------------------------------------------
 
-#define CONNECT_CHILD(EVT,FUNCTYPE,FUNC) \
-    wnd->Connect(id, EVT, \
-        (wxObjectEventFunction) (wxEventFunction)  \
-        FUNCTYPE (&wxPropertyGrid::FUNC), \
-        NULL, this );
-
 // Setups event handling for child control
-void wxPropertyGrid::SetupEventHandling( wxWindow* argWnd, int id )
+void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd, int id )
 {
     wxWindow* wnd = argWnd;
 
     if ( argWnd == m_wndEditor )
     {
-        CONNECT_CHILD(wxEVT_MOTION,(wxMouseEventFunction),OnMouseMoveChild)
-        CONNECT_CHILD(wxEVT_LEFT_UP,(wxMouseEventFunction),OnMouseUpChild)
-        CONNECT_CHILD(wxEVT_LEFT_DOWN,(wxMouseEventFunction),OnMouseClickChild)
-        CONNECT_CHILD(wxEVT_RIGHT_UP,(wxMouseEventFunction),OnMouseRightClickChild)
-        CONNECT_CHILD(wxEVT_ENTER_WINDOW,(wxMouseEventFunction),OnMouseEntry)
-        CONNECT_CHILD(wxEVT_LEAVE_WINDOW,(wxMouseEventFunction),OnMouseEntry)
+        this->Connect(id, wxEVT_MOTION,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild));
+        this->Connect(id, wxEVT_LEFT_UP,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild));
+        this->Connect(id, wxEVT_LEFT_DOWN,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild));
+        this->Connect(id, wxEVT_RIGHT_UP,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild));
+        this->Connect(id, wxEVT_ENTER_WINDOW,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseEntry));
+        this->Connect(id, wxEVT_LEAVE_WINDOW,
+            wxMouseEventHandler(wxPropertyGrid::OnMouseEntry));
     }
     else
     {
-        CONNECT_CHILD(wxEVT_NAVIGATION_KEY,(wxNavigationKeyEventFunction),OnNavigationKey)
+        this->Connect(id, wxEVT_NAVIGATION_KEY,
+            wxNavigationKeyEventHandler(wxPropertyGrid::OnNavigationKey));
     }
-    CONNECT_CHILD(wxEVT_KEY_DOWN,(wxCharEventFunction),OnChildKeyDown)
-    CONNECT_CHILD(wxEVT_KEY_UP,(wxCharEventFunction),OnChildKeyUp)
-    CONNECT_CHILD(wxEVT_KILL_FOCUS,(wxFocusEventFunction),OnFocusEvent)
+
+    this->Connect(id, wxEVT_KEY_DOWN,
+        wxKeyEventHandler(wxPropertyGrid::OnChildKeyDown));
+    this->Connect(id, wxEVT_KEY_UP,
+        wxKeyEventHandler(wxPropertyGrid::OnChildKeyUp));
+    this->Connect(id, wxEVT_KILL_FOCUS,
+        wxFocusEventHandler(wxPropertyGrid::OnFocusEvent));
 }
 
 void wxPropertyGrid::FreeEditors()
@@ -3754,7 +3758,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
                 #endif
 
                     wxWindow* primaryCtrl = GetEditorControl();
-                    SetupEventHandling(primaryCtrl, wxPG_SUBID1);
+                    SetupChildEventHandling(primaryCtrl, wxPG_SUBID1);
 
                     // Focus and select all (wxTextCtrl, wxComboBox etc)
                     if ( flags & wxPG_SEL_FOCUS )
@@ -3794,7 +3798,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
                 #endif
                     m_wndEditor2->Show();
 
-                    SetupEventHandling(m_wndEditor2,wxPG_SUBID2);
+                    SetupChildEventHandling(m_wndEditor2,wxPG_SUBID2);
 
                     // If no primary editor, focus to button to allow
                     // it to interprete ENTER etc.