1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid sample
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SAMPLES_PROPGRID_PROPGRID_H_
13 #define _WX_SAMPLES_PROPGRID_PROPGRID_H_
15 // -----------------------------------------------------------------------
17 class wxAdvImageFileProperty
: public wxFileProperty
19 WX_PG_DECLARE_PROPERTY_CLASS(wxAdvImageFileProperty
)
22 wxAdvImageFileProperty( const wxString
& label
= wxPG_LABEL
,
23 const wxString
& name
= wxPG_LABEL
,
24 const wxString
& value
= wxEmptyString
);
25 virtual ~wxAdvImageFileProperty ();
27 virtual void OnSetValue(); // Override to allow image loading.
29 virtual bool IntToValue( wxVariant
& variant
, int number
, int argFlags
= 0 ) const;
30 virtual bool OnEvent( wxPropertyGrid
* propgrid
, wxWindow
* primary
, wxEvent
& event
);
31 virtual wxSize
OnMeasureImage( int item
) const;
32 virtual void OnCustomPaint( wxDC
& dc
,
33 const wxRect
& rect
, wxPGPaintData
& paintdata
);
35 void LoadThumbnails( size_t n
);
38 wxImage
* m_pImage
; // Temporary thumbnail data.
40 static wxPGChoices ms_choices
;
42 int m_index
; // Index required for choice behaviour.
45 // -----------------------------------------------------------------------
54 wxVector3f( double x
, double y
, double z
)
62 inline bool operator == (const wxVector3f
& a
, const wxVector3f
& b
)
64 return (a
.x
== b
.x
&& a
.y
== b
.y
&& a
.z
== b
.z
);
67 WX_PG_DECLARE_VARIANT_DATA(wxVector3f
)
69 class wxVectorProperty
: public wxPGProperty
71 WX_PG_DECLARE_PROPERTY_CLASS(wxVectorProperty
)
74 wxVectorProperty( const wxString
& label
= wxPG_LABEL
,
75 const wxString
& name
= wxPG_LABEL
,
76 const wxVector3f
& value
= wxVector3f() );
77 virtual ~wxVectorProperty();
79 virtual void ChildChanged( wxVariant
& thisValue
,
80 int childIndex
, wxVariant
& childValue
) const;
81 virtual void RefreshChildren();
86 // -----------------------------------------------------------------------
94 inline bool operator == (const wxTriangle
& a
, const wxTriangle
& b
)
96 return (a
.a
== b
.a
&& a
.b
== b
.b
&& a
.c
== b
.c
);
99 WX_PG_DECLARE_VARIANT_DATA(wxTriangle
)
101 class wxTriangleProperty
: public wxPGProperty
103 WX_PG_DECLARE_PROPERTY_CLASS(wxTriangleProperty
)
106 wxTriangleProperty( const wxString
& label
= wxPG_LABEL
,
107 const wxString
& name
= wxPG_LABEL
,
108 const wxTriangle
& value
= wxTriangle() );
109 virtual ~wxTriangleProperty();
111 virtual void ChildChanged( wxVariant
& thisValue
,
112 int childIndex
, wxVariant
& childValue
) const;
113 virtual void RefreshChildren();
118 // -----------------------------------------------------------------------
122 ID_COLOURSCHEME4
= 100
125 // -----------------------------------------------------------------------
127 class FormMain
: public wxFrame
130 FormMain(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
133 wxPropertyGridManager
* m_pPropGridManager
;
134 wxPropertyGrid
* m_propGrid
;
136 wxTextCtrl
* m_tcPropLabel
;
138 wxBoxSizer
* m_topSizer
;
140 wxPGEditor
* m_pSampleMultiButtonEditor
;
141 wxPGChoices m_combinedFlags
;
143 wxMenuItem
* m_itemCatColours
;
144 wxMenuItem
* m_itemFreeze
;
145 wxMenuItem
* m_itemEnable
;
147 wxVariant m_storedValues
;
149 wxString m_savedState
;
152 void CreateGrid( int style
, int extraStyle
);
153 void FinalizeFramePosition();
155 // These are used in CreateGrid(), and in tests to compose
156 // grids for testing purposes.
159 void FinalizePanel( bool wasCreated
= true );
161 void PopulateWithStandardItems();
162 void PopulateWithExamples();
163 void PopulateWithLibraryConfig();
165 void OnCloseClick( wxCommandEvent
& event
);
166 void OnLabelTextChange( wxCommandEvent
& event
);
168 void OnColourScheme( wxCommandEvent
& event
);
170 void OnInsertPropClick( wxCommandEvent
& event
);
171 void OnAppendPropClick( wxCommandEvent
& event
);
172 void OnClearClick( wxCommandEvent
& event
);
173 void OnAppendCatClick( wxCommandEvent
& event
);
174 void OnInsertCatClick( wxCommandEvent
& event
);
175 void OnDelPropClick( wxCommandEvent
& event
);
176 void OnDelPropRClick( wxCommandEvent
& event
);
178 void OnContextMenu( wxContextMenuEvent
& event
);
180 void OnEnableDisable( wxCommandEvent
& event
);
181 void OnHideShow( wxCommandEvent
& event
);
182 void OnSetBackgroundColour( wxCommandEvent
& event
);
183 void OnClearModifyStatusClick( wxCommandEvent
& event
);
184 void OnFreezeClick( wxCommandEvent
& event
);
185 void OnDumpList( wxCommandEvent
& event
);
186 void OnCatColours( wxCommandEvent
& event
);
187 void OnSetColumns( wxCommandEvent
& event
);
188 void OnMisc( wxCommandEvent
& event
);
189 void OnPopulateClick( wxCommandEvent
& event
);
190 void OnSetSpinCtrlEditorClick( wxCommandEvent
& event
);
191 void OnTestReplaceClick( wxCommandEvent
& event
);
192 void OnTestXRC( wxCommandEvent
& event
);
193 void OnEnableCommonValues( wxCommandEvent
& event
);
194 void OnSelectStyle( wxCommandEvent
& event
);
196 void OnFitColumnsClick( wxCommandEvent
& event
);
198 void OnChangeFlagsPropItemsClick( wxCommandEvent
& event
);
200 void OnSaveToFileClick( wxCommandEvent
& event
);
201 void OnLoadFromFileClick( wxCommandEvent
& event
);
203 void OnSetPropertyValue( wxCommandEvent
& event
);
204 void OnInsertChoice( wxCommandEvent
& event
);
205 void OnDeleteChoice( wxCommandEvent
& event
);
206 void OnInsertPage( wxCommandEvent
& event
);
207 void OnRemovePage( wxCommandEvent
& event
);
209 void OnSaveState( wxCommandEvent
& event
);
210 void OnRestoreState( wxCommandEvent
& event
);
212 void OnRunMinimalClick( wxCommandEvent
& event
);
214 void OnIterate1Click( wxCommandEvent
& event
);
215 void OnIterate2Click( wxCommandEvent
& event
);
216 void OnIterate3Click( wxCommandEvent
& event
);
217 void OnIterate4Click( wxCommandEvent
& event
);
219 void OnPropertyGridChange( wxPropertyGridEvent
& event
);
220 void OnPropertyGridChanging( wxPropertyGridEvent
& event
);
221 void OnPropertyGridSelect( wxPropertyGridEvent
& event
);
222 void OnPropertyGridHighlight( wxPropertyGridEvent
& event
);
223 void OnPropertyGridItemRightClick( wxPropertyGridEvent
& event
);
224 void OnPropertyGridItemDoubleClick( wxPropertyGridEvent
& event
);
225 void OnPropertyGridPageChange( wxPropertyGridEvent
& event
);
226 void OnPropertyGridButtonClick( wxCommandEvent
& event
);
227 void OnPropertyGridTextUpdate( wxCommandEvent
& event
);
228 void OnPropertyGridKeyEvent( wxKeyEvent
& event
);
229 void OnPropertyGridItemCollapse( wxPropertyGridEvent
& event
);
230 void OnPropertyGridItemExpand( wxPropertyGridEvent
& event
);
232 void OnAbout( wxCommandEvent
& event
);
234 void OnMove( wxMoveEvent
& event
);
235 void OnResize( wxSizeEvent
& event
);
236 void OnPaint( wxPaintEvent
& event
);
237 void OnCloseEvent( wxCloseEvent
& event
);
239 void OnIdle( wxIdleEvent
& event
);
241 void AddTestProperties( wxPropertyGridPage
* pg
);
243 bool RunTests( bool fullTest
, bool interactive
= false );
246 DECLARE_EVENT_TABLE()
249 // -----------------------------------------------------------------------
251 class cxApplication
: public wxApp
255 virtual bool OnInit();
261 DECLARE_APP(cxApplication
)
263 // -----------------------------------------------------------------------
265 #endif // _WX_SAMPLES_PROPGRID_PROPGRID_H_