@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,
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 );
@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;
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
int extraStyle,
int maxLen )
{
+ wxWindowID id = wxPG_SUBID1;
wxPGProperty* selected = m_selected;
wxASSERT(selected);
#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 )
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;
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;
}
wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz )
{
+ wxWindowID id = wxPG_SUBID2;
wxPGProperty* selected = m_selected;
wxASSERT(selected);
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;
#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();
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;
}
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()
// 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()
#endif
wxWindow* primaryCtrl = GetEditorControl();
- SetupEventHandling(primaryCtrl, wxPG_SUBID1);
+ SetupChildEventHandling(primaryCtrl, wxPG_SUBID1);
// Focus and select all (wxTextCtrl, wxComboBox etc)
if ( flags & wxPG_SEL_FOCUS )
#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.