# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx::PG # 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 {Wx::PG::PGMultiButton} instance in Wx::PGWindowList#set_secondary. # For instance, here we add three buttons to a TextCtrl editor: # # ``` # #include # # class wxSampleMultiButtonEditor : public wxPGTextCtrlEditor # { # wxDECLARE_DYNAMIC_CLASS(wxSampleMultiButtonEditor); # # public: # wxSampleMultiButtonEditor() {} # virtual ~wxSampleMultiButtonEditor() {} # # virtual wxString GetName() const { return "SampleMultiButtonEditor"; } # # virtual wxPGWindowList CreateControls( wxPropertyGrid* propGrid, # wxPGProperty* property, # const wxPoint& pos, # const wxSize& sz ) const; # virtual bool OnEvent( wxPropertyGrid* propGrid, # wxPGProperty* property, # wxWindow* ctrl, # wxEvent& event ) const; # }; # # wxIMPLEMENT_DYNAMIC_CLASS(wxSampleMultiButtonEditor, wxPGTextCtrlEditor); # # wxPGWindowList wxSampleMultiButtonEditor::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->Finalize(propGrid, pos); # # wndList.SetSecondary( buttons ); # return wndList; # } # # bool wxSampleMultiButtonEditor::OnEvent( wxPropertyGrid* propGrid, # wxPGProperty* property, # wxWindow* ctrl, # wxEvent& event ) const # { # if ( event.GetEventType() == wxEVT_BUTTON ) # { # wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); # # if ( event.GetId() == buttons->GetButtonId(0) ) # { # // Do something when the first button is pressed # // Return true if the action modified the value in editor. # ... # } # if ( event.GetId() == buttons->GetButtonId(1) ) # { # // Do something when the second button is pressed # ... # } # if ( event.GetId() == buttons->GetButtonId(2) ) # { # // Do something when the third button is pressed # ... # } # } # return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); # } # ``` # # Further to use this editor, code like this can be used: # # ``` # // Register editor class - needs only to be called once # wxPGEditor* multiButtonEditor = new wxSampleMultiButtonEditor(); # wxPropertyGrid::RegisterEditorClass( multiButtonEditor ); # # // 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", multiButtonEditor ); # ``` # # === # # Category: {Wx::PG::PropertyGrid} # class PGMultiButton < Window # Constructor. # @param pg [Wx::PropertyGrid] # @param sz [Array(Integer, Integer), Wx::Size] # @return [PGMultiButton] def initialize(pg, sz) end # @overload add(label, id=-2) # Adds new button, with given label. # @param label [String] # @param id [Integer] # @return [void] # @overload add(bitmap, id=-2) # Adds new bitmap button. # @param bitmap [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @param id [Integer] # @return [void] def add(*args) end # Call this in CreateControls() of your custom editor class after all buttons have been added. # @param propGrid [Wx::PropertyGrid] {Wx::PG::PropertyGrid} given in CreateControls(). # @param pos [Array(Integer, Integer), Wx::Point] {Wx::Point} given in CreateControls(). # @return [void] def finalize(propGrid, pos) end # Returns pointer to one of the buttons. # @param i [Integer] # @return [Wx::Window] def get_button(i) end alias_method :button, :get_button # Returns Id of one of the buttons. # This is utility function to be used in event handlers. # @param i [Integer] # @return [Integer] def get_button_id(i) end alias_method :button_id, :get_button_id # Returns number of buttons. # @return [Integer] def get_count; end alias_method :count, :get_count # Returns size of primary editor control, as appropriately reduced by number of buttons present. # @return [Wx::Size] def get_primary_size; end alias_method :primary_size, :get_primary_size end # PGMultiButton end