wxPGMultiButton Class Reference
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:
More...
#include <editors.h>
List of all members.
Detailed Description
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:
#include <wx/propgrid/editors.h>
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
{
wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
buttons->Add( wxT("...") );
buttons->Add( wxT("A") );
buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls
( propGrid, property, pos, buttons->GetPrimarySize() );
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) )
{
...
}
if ( event.GetId() == buttons->GetButtonId(1) )
{
...
}
if ( event.GetId() == buttons->GetButtonId(2) )
{
...
}
}
return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
}
Further to use this editor, code like this can be used:
Definition at line 552 of file editors.h.
Constructor & Destructor Documentation
wxPGMultiButton::wxPGMultiButton |
( |
wxPropertyGrid * |
pg, |
|
|
const wxSize & |
sz | |
|
) |
| | |
virtual wxPGMultiButton::~wxPGMultiButton |
( |
|
) |
[inline, virtual] |
Member Function Documentation
void wxPGMultiButton::Add |
( |
const wxString & |
label, |
|
|
int |
id = -2 | |
|
) |
| | |
void wxPGMultiButton::FinalizePosition |
( |
const wxPoint & |
pos |
) |
[inline] |
int wxPGMultiButton::GenId |
( |
int |
id |
) |
const [protected] |
const wxWindow* wxPGMultiButton::GetButton |
( |
unsigned int |
i |
) |
const [inline] |
wxWindow* wxPGMultiButton::GetButton |
( |
unsigned int |
i |
) |
[inline] |
int wxPGMultiButton::GetButtonId |
( |
unsigned int |
i |
) |
const [inline] |
Utility function to be used in event handlers.
Definition at line 565 of file editors.h.
int wxPGMultiButton::GetCount |
( |
|
) |
const [inline] |
Returns number of buttons.
Definition at line 569 of file editors.h.
wxSize wxPGMultiButton::GetPrimarySize |
( |
|
) |
const [inline] |
Member Data Documentation
The documentation for this class was generated from the following file: