1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid sample
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
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 wxVariant
ChildChanged( wxVariant
& thisValue
,
81 wxVariant
& childValue
) const;
82 virtual void RefreshChildren();
87 // -----------------------------------------------------------------------
95 inline bool operator == (const wxTriangle
& a
, const wxTriangle
& b
)
97 return (a
.a
== b
.a
&& a
.b
== b
.b
&& a
.c
== b
.c
);
100 WX_PG_DECLARE_VARIANT_DATA(wxTriangle
)
102 class wxTriangleProperty
: public wxPGProperty
104 WX_PG_DECLARE_PROPERTY_CLASS(wxTriangleProperty
)
107 wxTriangleProperty( const wxString
& label
= wxPG_LABEL
,
108 const wxString
& name
= wxPG_LABEL
,
109 const wxTriangle
& value
= wxTriangle() );
110 virtual ~wxTriangleProperty();
112 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
114 wxVariant
& childValue
) const;
115 virtual void RefreshChildren();
120 // -----------------------------------------------------------------------
124 ID_COLOURSCHEME4
= 100
127 // -----------------------------------------------------------------------
129 class FormMain
: public wxFrame
132 FormMain(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
135 wxPropertyGridManager
* m_pPropGridManager
;
136 wxPropertyGrid
* m_propGrid
;
138 wxTextCtrl
* m_tcPropLabel
;
140 wxBoxSizer
* m_topSizer
;
143 wxLogWindow
* m_logWindow
;
146 wxPGEditor
* m_pSampleMultiButtonEditor
;
147 wxPGChoices m_combinedFlags
;
149 wxMenuItem
* m_itemCatColours
;
150 wxMenuItem
* m_itemFreeze
;
151 wxMenuItem
* m_itemEnable
;
152 wxMenuItem
* m_itemVetoDragging
;
154 wxVariant m_storedValues
;
156 wxString m_savedState
;
159 void CreateGrid( int style
, int extraStyle
);
160 void FinalizeFramePosition();
162 // These are used in CreateGrid(), and in tests to compose
163 // grids for testing purposes.
166 void FinalizePanel( bool wasCreated
= true );
168 void PopulateWithStandardItems();
169 void PopulateWithExamples();
170 void PopulateWithLibraryConfig();
172 void OnCloseClick( wxCommandEvent
& event
);
173 void OnLabelTextChange( wxCommandEvent
& event
);
175 void OnColourScheme( wxCommandEvent
& event
);
177 void OnInsertPropClick( wxCommandEvent
& event
);
178 void OnAppendPropClick( wxCommandEvent
& event
);
179 void OnClearClick( wxCommandEvent
& event
);
180 void OnAppendCatClick( wxCommandEvent
& event
);
181 void OnInsertCatClick( wxCommandEvent
& event
);
182 void OnDelPropClick( wxCommandEvent
& event
);
183 void OnDelPropRClick( wxCommandEvent
& event
);
185 void OnContextMenu( wxContextMenuEvent
& event
);
187 void OnEnableDisable( wxCommandEvent
& event
);
188 void OnSetReadOnly( wxCommandEvent
& event
);
189 void OnHide( wxCommandEvent
& event
);
190 void OnSetBackgroundColour( wxCommandEvent
& event
);
191 void OnClearModifyStatusClick( wxCommandEvent
& event
);
192 void OnFreezeClick( wxCommandEvent
& event
);
193 void OnEnableLabelEditing( wxCommandEvent
& event
);
194 void OnShowHeader( wxCommandEvent
& event
);
195 void OnDumpList( wxCommandEvent
& event
);
196 void OnCatColours( wxCommandEvent
& event
);
197 void OnSetColumns( wxCommandEvent
& event
);
198 void OnMisc( wxCommandEvent
& event
);
199 void OnPopulateClick( wxCommandEvent
& event
);
200 void OnSetSpinCtrlEditorClick( wxCommandEvent
& event
);
201 void OnTestReplaceClick( wxCommandEvent
& event
);
202 void OnTestXRC( wxCommandEvent
& event
);
203 void OnEnableCommonValues( wxCommandEvent
& event
);
204 void OnSelectStyle( wxCommandEvent
& event
);
206 void OnFitColumnsClick( wxCommandEvent
& event
);
208 void OnChangeFlagsPropItemsClick( wxCommandEvent
& event
);
210 void OnSaveToFileClick( wxCommandEvent
& event
);
211 void OnLoadFromFileClick( wxCommandEvent
& event
);
213 void OnSetPropertyValue( wxCommandEvent
& event
);
214 void OnInsertChoice( wxCommandEvent
& event
);
215 void OnDeleteChoice( wxCommandEvent
& event
);
216 void OnInsertPage( wxCommandEvent
& event
);
217 void OnRemovePage( wxCommandEvent
& event
);
219 void OnSaveState( wxCommandEvent
& event
);
220 void OnRestoreState( wxCommandEvent
& event
);
222 void OnRunMinimalClick( wxCommandEvent
& event
);
224 void OnIterate1Click( wxCommandEvent
& event
);
225 void OnIterate2Click( wxCommandEvent
& event
);
226 void OnIterate3Click( wxCommandEvent
& event
);
227 void OnIterate4Click( wxCommandEvent
& event
);
229 void OnExtendedKeyNav( wxCommandEvent
& event
);
231 void OnPropertyGridChange( wxPropertyGridEvent
& event
);
232 void OnPropertyGridChanging( wxPropertyGridEvent
& event
);
233 void OnPropertyGridSelect( wxPropertyGridEvent
& event
);
234 void OnPropertyGridHighlight( wxPropertyGridEvent
& event
);
235 void OnPropertyGridItemRightClick( wxPropertyGridEvent
& event
);
236 void OnPropertyGridItemDoubleClick( wxPropertyGridEvent
& event
);
237 void OnPropertyGridPageChange( wxPropertyGridEvent
& event
);
238 void OnPropertyGridButtonClick( wxCommandEvent
& event
);
239 void OnPropertyGridTextUpdate( wxCommandEvent
& event
);
240 void OnPropertyGridKeyEvent( wxKeyEvent
& event
);
241 void OnPropertyGridItemCollapse( wxPropertyGridEvent
& event
);
242 void OnPropertyGridItemExpand( wxPropertyGridEvent
& event
);
243 void OnPropertyGridLabelEditBegin( wxPropertyGridEvent
& event
);
244 void OnPropertyGridLabelEditEnding( wxPropertyGridEvent
& event
);
245 void OnPropertyGridColBeginDrag( wxPropertyGridEvent
& event
);
246 void OnPropertyGridColDragging( wxPropertyGridEvent
& event
);
247 void OnPropertyGridColEndDrag( wxPropertyGridEvent
& event
);
249 void OnAbout( wxCommandEvent
& event
);
251 void OnMove( wxMoveEvent
& event
);
252 void OnResize( wxSizeEvent
& event
);
253 void OnPaint( wxPaintEvent
& event
);
254 void OnCloseEvent( wxCloseEvent
& event
);
256 void OnIdle( wxIdleEvent
& event
);
258 void AddTestProperties( wxPropertyGridPage
* pg
);
260 bool RunTests( bool fullTest
, bool interactive
= false );
263 DECLARE_EVENT_TABLE()
266 // -----------------------------------------------------------------------
268 class cxApplication
: public wxApp
272 virtual bool OnInit();
278 DECLARE_APP(cxApplication
)
280 // -----------------------------------------------------------------------
282 #endif // _WX_SAMPLES_PROPGRID_PROPGRID_H_