X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f4bc1aa27cb33f679d7e9c1518a7855bbc1fa471..f55d9f749b61b3a8435c58a285ac096726d15040:/include/wx/propgrid/editors.h diff --git a/include/wx/propgrid/editors.h b/include/wx/propgrid/editors.h index 656cef681e..daa34f2e7a 100644 --- a/include/wx/propgrid/editors.h +++ b/include/wx/propgrid/editors.h @@ -4,7 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: 2007-04-14 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -113,20 +113,17 @@ 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)); + control->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED, + wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent), + NULL, propgrid); @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, @@ -158,6 +155,12 @@ public: /** Handles events. Returns true if value in control was modified (see wxPGProperty::OnEvent for more information). + + @remarks wxPropertyGrid will automatically unfocus the editor when + wxEVT_COMMAND_TEXT_ENTER is received and when it results in + property value being modified. This happens regardless of + editor type (ie. behavior is same for any wxTextCtrl and + wxComboBox based editor). */ virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, wxWindow* wnd_primary, wxEvent& event ) const = 0; @@ -421,7 +424,7 @@ public: if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \ { \ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \ - wxPGConstruct##EDITOR##EditorClass(), wxS(#EDITOR) ); \ + wxPGConstruct##EDITOR##EditorClass() ); \ } // Use this in RegisterDefaultEditors. @@ -429,7 +432,7 @@ public: if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \ { \ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \ - wxPGConstruct##EDITOR##EditorClass(), wxS(#EDITOR), true ); \ + wxPGConstruct##EDITOR##EditorClass(), true ); \ } #define wxPG_INIT_REQUIRED_EDITOR(T) \ @@ -497,113 +500,7 @@ private: This class can be used to have multiple buttons in a property editor. You will need to create a new property editor class, override CreateControls, and have it return wxPGMultiButton instance in - wxPGWindowList::SetSecondary(). For instance, here we add three buttons to - a textctrl editor: - - @code - - #include - - class wxMultiButtonTextCtrlEditor : public wxPGTextCtrlEditor - { - WX_PG_DECLARE_EDITOR_CLASS(wxMultiButtonTextCtrlEditor) - public: - wxMultiButtonTextCtrlEditor() {} - virtual ~wxMultiButtonTextCtrlEditor() {} - - wxPG_DECLARE_CREATECONTROLS - virtual bool OnEvent( wxPropertyGrid* propGrid, - wxPGProperty* property, - wxWindow* ctrl, - wxEvent& event ) const; - - }; - - WX_PG_IMPLEMENT_EDITOR_CLASS(MultiButtonTextCtrlEditor, - wxMultiButtonTextCtrlEditor, - wxPGTextCtrlEditor) - - wxPGWindowList - wxMultiButtonTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid, - wxPGProperty* property, - const wxPoint& pos, - const wxSize& sz ) const - { - // Create and populate buttons-subwindow - wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz ); - - // Add two regular buttons - buttons->Add( "..." ); - buttons->Add( "A" ); - // Add a bitmap button - buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) ); - - // Create the 'primary' editor control (textctrl in this case) - wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls( - propGrid, - property, - pos, - buttons->GetPrimarySize() - ); - - // Finally, move buttons-subwindow to correct position and make sure - // returned wxPGWindowList contains our custom button list. - buttons->FinalizePosition(pos); - - wndList.SetSecondary( buttons ); - return wndList; - } - - bool wxMultiButtonTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid, - wxPGProperty* property, - wxWindow* ctrl, - wxEvent& event ) const - { - if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) - { - wxPGMultiButton* buttons = (wxPGMultiButton*) - propGrid->GetEditorControlSecondary(); - - if ( event.GetId() == buttons->GetButtonId(0) ) - { - // Do something when first button is pressed - return true; - } - if ( event.GetId() == buttons->GetButtonId(1) ) - { - // Do something when first button is pressed - return true; - } - if ( event.GetId() == buttons->GetButtonId(2) ) - { - // Do something when second button is pressed - return true; - } - } - return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); - } - - @endcode - - Further to use this editor, code like this can be used: - - @code - - // Register editor class - needs only to be called once - wxPGRegisterEditorClass( MultiButtonTextCtrlEditor ); - - // Insert the property that will have multiple buttons - propGrid->Append( new wxLongStringProperty("MultipleButtons", - wxPG_LABEL) ); - - // Change property to use editor created in the previous code segment - propGrid->SetPropertyEditor( "MultipleButtons", - wxPG_EDITOR(MultiButtonTextCtrlEditor) ); - - @endcode - - @library{wxpropgrid} - @category{propgrid} + wxPGWindowList::SetSecondary(). */ class WXDLLIMPEXP_PROPGRID wxPGMultiButton : public wxWindow { @@ -632,10 +529,7 @@ public: return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y); } - void FinalizePosition( const wxPoint& pos ) - { - Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y ); - } + void Finalize( wxPropertyGrid* propGrid, const wxPoint& pos ); #ifndef DOXYGEN protected: