From 774f37d0a34cda7a1d06514ccae65b88d690a27b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 3 Mar 2015 20:39:20 -0800 Subject: [PATCH] Add more missing classes --- interface/wx/propgrid/editors.h | 242 +++++++++++++++++++++++++++++++ interface/wx/propgrid/property.h | 84 +++++++++++ 2 files changed, 326 insertions(+) diff --git a/interface/wx/propgrid/editors.h b/interface/wx/propgrid/editors.h index 0d5ae8f349..ca7488394d 100644 --- a/interface/wx/propgrid/editors.h +++ b/interface/wx/propgrid/editors.h @@ -5,6 +5,26 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +/** + @class wxPGWindowList + + Contains a list of editor windows returned by CreateControls. +*/ + +class wxPGWindowList +{ +public: + wxPGWindowList(); + void SetSecondary( wxWindow* secondary ); + + wxWindow* m_primary; + wxWindow* m_secondary; + + wxPGWindowList( wxWindow* a ); + wxPGWindowList( wxWindow* a, wxWindow* b ); +}; + + /** @class wxPGEditor @@ -166,6 +186,228 @@ public: Default implementation returns @false. */ virtual bool CanContainCustomImage() const; + + // + // This member is public so scripting language bindings + // wrapper code can access it freely. + void* m_clientData; + +}; + + + + +class wxPGTextCtrlEditor : public wxPGEditor +{ +public: + wxPGTextCtrlEditor(); + virtual ~wxPGTextCtrlEditor(); + + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; + virtual void UpdateControl( wxPGProperty* property, + wxWindow* ctrl ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxPGProperty* property, + wxWindow* primaryCtrl, + wxEvent& event ) const; + virtual bool GetValueFromControl( wxVariant& variant, + wxPGProperty* property, + wxWindow* ctrl ) const; + + virtual wxString GetName() const; + + virtual void SetControlStringValue( wxPGProperty* property, + wxWindow* ctrl, + const wxString& txt ) const; + virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const; + + static bool OnTextCtrlEvent( wxPropertyGrid* propgrid, + wxPGProperty* property, + wxWindow* ctrl, + wxEvent& event ); + + static bool GetTextCtrlValueFromControl( wxVariant& variant, + wxPGProperty* property, + wxWindow* ctrl ); +}; + + +class wxPGChoiceEditor : public wxPGEditor +{ +public: + wxPGChoiceEditor() + virtual ~wxPGChoiceEditor(); + + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; + virtual void UpdateControl( wxPGProperty* property, + wxWindow* ctrl ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxPGProperty* property, + wxWindow* primaryCtrl, + wxEvent& event ) const; + virtual bool GetValueFromControl( wxVariant& variant, + wxPGProperty* property, + wxWindow* ctrl ) const; + virtual void SetValueToUnspecified( wxPGProperty* property, + wxWindow* ctrl ) const; + virtual wxString GetName() const; + + virtual void SetControlIntValue( wxPGProperty* property, + wxWindow* ctrl, + int value ) const; + virtual void SetControlStringValue( wxPGProperty* property, + wxWindow* ctrl, + const wxString& txt ) const; + + virtual int InsertItem( wxWindow* ctrl, + const wxString& label, + int index ) const; + virtual void DeleteItem( wxWindow* ctrl, int index ) const; + virtual bool CanContainCustomImage() const; + + wxWindow* CreateControlsBase( wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& sz, + long extraStyle ) const; + +}; + + +class wxPGComboBoxEditor : public wxPGChoiceEditor +{ +public: + wxPGComboBoxEditor(); + virtual ~wxPGComboBoxEditor(); + + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; + + virtual wxString GetName() const; + + virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const; + + virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, + wxWindow* ctrl, wxEvent& event ) const; + + virtual bool GetValueFromControl( wxVariant& variant, + wxPGProperty* property, + wxWindow* ctrl ) const; + + virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const; + +}; + + +class wxPGChoiceAndButtonEditor : public wxPGChoiceEditor +{ +public: + wxPGChoiceAndButtonEditor(); + virtual ~wxPGChoiceAndButtonEditor(); + virtual wxString GetName() const; + + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; +}; + +class wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor +{ +public: + wxPGTextCtrlAndButtonEditor(); + virtual ~wxPGTextCtrlAndButtonEditor(); + virtual wxString GetName() const; + + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; +}; + + + + + +class wxPGCheckBoxEditor : public wxPGEditor +{ +public: + wxPGCheckBoxEditor(); + virtual ~wxPGCheckBoxEditor(); + + virtual wxString GetName() const; + virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& size) const; + virtual void UpdateControl( wxPGProperty* property, + wxWindow* ctrl ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxPGProperty* property, + wxWindow* primaryCtrl, + wxEvent& event ) const; + virtual bool GetValueFromControl( wxVariant& variant, + wxPGProperty* property, + wxWindow* ctrl ) const; + virtual void SetValueToUnspecified( wxPGProperty* property, + wxWindow* ctrl ) const; + + virtual void DrawValue( wxDC& dc, + const wxRect& rect, + wxPGProperty* property, + const wxString& text ) const; + + virtual void SetControlIntValue( wxPGProperty* property, + wxWindow* ctrl, + int value ) const; +}; + + + +/** + @class wxPGEditorDialogAdapter + + Derive a class from this to adapt an existing editor dialog or function to + be used when editor button of a property is pushed. + + You only need to derive class and implement DoShowDialog() to create and + show the dialog, and finally submit the value returned by the dialog + via SetValue(). + + @library{wxpropgrid} + @category{propgrid} +*/ +class wxPGEditorDialogAdapter : public wxObject +{ +public: + wxPGEditorDialogAdapter(); + virtual ~wxPGEditorDialogAdapter(); + + bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property ); + + virtual bool DoShowDialog( wxPropertyGrid* propGrid, + wxPGProperty* property ) = 0; + + void SetValue( wxVariant value ); + + /** + This method is typically only used if deriving class from existing + adapter with value conversion purposes. + */ + wxVariant& GetValue() { return m_value; } + + // + // This member is public so scripting language bindings + // wrapper code can access it freely. + void* m_clientData; }; diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index db818933d5..1614173cf0 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -177,6 +177,44 @@ public: }; +/** + @class wxPGDefaultRenderer + + Default cell renderer, that can handles the common + scenarios. +*/ +class wxPGDefaultRenderer : public wxPGCellRenderer +{ +public: + virtual bool Render( wxDC& dc, + const wxRect& rect, + const wxPropertyGrid* propertyGrid, + wxPGProperty* property, + int column, + int item, + int flags ) const; + + virtual wxSize GetImageSize( const wxPGProperty* property, + int column, + int item ) const; +}; + + +class wxPGCellData : public wxObjectRefData +{ +public: + wxPGCellData(); + + void SetText( const wxString& text ); + void SetBitmap( const wxBitmap& bitmap ); + void SetFgCol( const wxColour& col ); + void SetBgCol( const wxColour& col ); + void SetFont( const wxFont& font ); + +protected: + virtual ~wxPGCellData() { } +}; + /** @@ -2403,6 +2441,52 @@ public: // ----------------------------------------------------------------------- + +/** + @class wxPGChoiceEntry + Data of a single wxPGChoices choice. +*/ +class wxPGChoiceEntry : public wxPGCell +{ +public: + wxPGChoiceEntry(); + wxPGChoiceEntry(const wxPGChoiceEntry& other); + wxPGChoiceEntry( const wxString& label, + int value = wxPG_INVALID_VALUE ); + + virtual ~wxPGChoiceEntry(); + + void SetValue( int value ); + int GetValue() const; + + wxPGChoiceEntry& operator=( const wxPGChoiceEntry& other ); +}; + + +class wxPGChoicesData : public wxObjectRefData +{ +public: + // Constructor sets m_refCount to 1. + wxPGChoicesData(); + + void CopyDataFrom( wxPGChoicesData* data ); + + wxPGChoiceEntry& Insert( int index, const wxPGChoiceEntry& item ); + + // Delete all entries + void Clear(); + + unsigned int GetCount() const; + + const wxPGChoiceEntry& Item( unsigned int i ) const; + wxPGChoiceEntry& Item( unsigned int i ); +}; + +#define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL) + + + + /** @class wxPGChoices