1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid sample
4 // Author: Jaakko Salli
7 // Copyright: (c) Jaakko Salli
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_SAMPLES_PROPGRID_PROPGRID_H_
12 #define _WX_SAMPLES_PROPGRID_PROPGRID_H_
14 // -----------------------------------------------------------------------
16 class wxAdvImageFileProperty
: public wxFileProperty
18 WX_PG_DECLARE_PROPERTY_CLASS(wxAdvImageFileProperty
)
21 wxAdvImageFileProperty( const wxString
& label
= wxPG_LABEL
,
22 const wxString
& name
= wxPG_LABEL
,
23 const wxString
& value
= wxEmptyString
);
24 virtual ~wxAdvImageFileProperty ();
26 virtual void OnSetValue(); // Override to allow image loading.
28 virtual bool IntToValue( wxVariant
& variant
, int number
, int argFlags
= 0 ) const;
29 virtual bool OnEvent( wxPropertyGrid
* propgrid
, wxWindow
* primary
, wxEvent
& event
);
30 virtual wxSize
OnMeasureImage( int item
) const;
31 virtual void OnCustomPaint( wxDC
& dc
,
32 const wxRect
& rect
, wxPGPaintData
& paintdata
);
34 void LoadThumbnails( size_t n
);
37 wxImage
* m_pImage
; // Temporary thumbnail data.
39 static wxPGChoices ms_choices
;
41 int m_index
; // Index required for choice behaviour.
44 // -----------------------------------------------------------------------
53 wxVector3f( double x
, double y
, double z
)
61 inline bool operator == (const wxVector3f
& a
, const wxVector3f
& b
)
63 return (a
.x
== b
.x
&& a
.y
== b
.y
&& a
.z
== b
.z
);
66 WX_PG_DECLARE_VARIANT_DATA(wxVector3f
)
68 class wxVectorProperty
: public wxPGProperty
70 WX_PG_DECLARE_PROPERTY_CLASS(wxVectorProperty
)
73 wxVectorProperty( const wxString
& label
= wxPG_LABEL
,
74 const wxString
& name
= wxPG_LABEL
,
75 const wxVector3f
& value
= wxVector3f() );
76 virtual ~wxVectorProperty();
78 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
80 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 wxVariant
ChildChanged( wxVariant
& thisValue
,
113 wxVariant
& childValue
) const;
114 virtual void RefreshChildren();
119 // -----------------------------------------------------------------------
123 ID_COLOURSCHEME4
= 100
126 // -----------------------------------------------------------------------
128 class FormMain
: public wxFrame
131 FormMain(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
134 wxPropertyGridManager
* m_pPropGridManager
;
135 wxPropertyGrid
* m_propGrid
;
137 wxTextCtrl
* m_tcPropLabel
;
139 wxBoxSizer
* m_topSizer
;
142 wxLogWindow
* m_logWindow
;
145 wxPGEditor
* m_pSampleMultiButtonEditor
;
146 wxPGChoices m_combinedFlags
;
148 wxMenuItem
* m_itemCatColours
;
149 wxMenuItem
* m_itemFreeze
;
150 wxMenuItem
* m_itemEnable
;
151 wxMenuItem
* m_itemVetoDragging
;
153 wxVariant m_storedValues
;
155 wxString m_savedState
;
158 void CreateGrid( int style
, int extraStyle
);
159 void FinalizeFramePosition();
161 // These are used in CreateGrid(), and in tests to compose
162 // grids for testing purposes.
165 void FinalizePanel( bool wasCreated
= true );
167 void PopulateWithStandardItems();
168 void PopulateWithExamples();
169 void PopulateWithLibraryConfig();
171 void OnCloseClick( wxCommandEvent
& event
);
172 void OnLabelTextChange( wxCommandEvent
& event
);
174 void OnColourScheme( wxCommandEvent
& event
);
176 void OnInsertPropClick( wxCommandEvent
& event
);
177 void OnAppendPropClick( wxCommandEvent
& event
);
178 void OnClearClick( wxCommandEvent
& event
);
179 void OnAppendCatClick( wxCommandEvent
& event
);
180 void OnInsertCatClick( wxCommandEvent
& event
);
181 void OnDelPropClick( wxCommandEvent
& event
);
182 void OnDelPropRClick( wxCommandEvent
& event
);
184 void OnContextMenu( wxContextMenuEvent
& event
);
186 void OnEnableDisable( wxCommandEvent
& event
);
187 void OnSetReadOnly( wxCommandEvent
& event
);
188 void OnHide( wxCommandEvent
& event
);
189 void OnSetBackgroundColour( wxCommandEvent
& event
);
190 void OnClearModifyStatusClick( wxCommandEvent
& event
);
191 void OnFreezeClick( wxCommandEvent
& event
);
192 void OnEnableLabelEditing( wxCommandEvent
& event
);
193 void OnShowHeader( wxCommandEvent
& event
);
194 void OnDumpList( wxCommandEvent
& event
);
195 void OnCatColours( wxCommandEvent
& event
);
196 void OnSetColumns( wxCommandEvent
& event
);
197 void OnMisc( wxCommandEvent
& event
);
198 void OnPopulateClick( wxCommandEvent
& event
);
199 void OnSetSpinCtrlEditorClick( wxCommandEvent
& event
);
200 void OnTestReplaceClick( wxCommandEvent
& event
);
201 void OnTestXRC( wxCommandEvent
& event
);
202 void OnEnableCommonValues( wxCommandEvent
& event
);
203 void OnSelectStyle( wxCommandEvent
& event
);
205 void OnFitColumnsClick( wxCommandEvent
& event
);
207 void OnChangeFlagsPropItemsClick( wxCommandEvent
& event
);
209 void OnSaveToFileClick( wxCommandEvent
& event
);
210 void OnLoadFromFileClick( wxCommandEvent
& event
);
212 void OnSetPropertyValue( wxCommandEvent
& event
);
213 void OnInsertChoice( wxCommandEvent
& event
);
214 void OnDeleteChoice( wxCommandEvent
& event
);
215 void OnInsertPage( wxCommandEvent
& event
);
216 void OnRemovePage( wxCommandEvent
& event
);
218 void OnSaveState( wxCommandEvent
& event
);
219 void OnRestoreState( wxCommandEvent
& event
);
221 void OnRunMinimalClick( wxCommandEvent
& event
);
223 void OnIterate1Click( wxCommandEvent
& event
);
224 void OnIterate2Click( wxCommandEvent
& event
);
225 void OnIterate3Click( wxCommandEvent
& event
);
226 void OnIterate4Click( wxCommandEvent
& event
);
228 void OnExtendedKeyNav( wxCommandEvent
& event
);
230 void OnPropertyGridChange( wxPropertyGridEvent
& event
);
231 void OnPropertyGridChanging( wxPropertyGridEvent
& event
);
232 void OnPropertyGridSelect( wxPropertyGridEvent
& event
);
233 void OnPropertyGridHighlight( wxPropertyGridEvent
& event
);
234 void OnPropertyGridItemRightClick( wxPropertyGridEvent
& event
);
235 void OnPropertyGridItemDoubleClick( wxPropertyGridEvent
& event
);
236 void OnPropertyGridPageChange( wxPropertyGridEvent
& event
);
237 void OnPropertyGridButtonClick( wxCommandEvent
& event
);
238 void OnPropertyGridTextUpdate( wxCommandEvent
& event
);
239 void OnPropertyGridKeyEvent( wxKeyEvent
& event
);
240 void OnPropertyGridItemCollapse( wxPropertyGridEvent
& event
);
241 void OnPropertyGridItemExpand( wxPropertyGridEvent
& event
);
242 void OnPropertyGridLabelEditBegin( wxPropertyGridEvent
& event
);
243 void OnPropertyGridLabelEditEnding( wxPropertyGridEvent
& event
);
244 void OnPropertyGridColBeginDrag( wxPropertyGridEvent
& event
);
245 void OnPropertyGridColDragging( wxPropertyGridEvent
& event
);
246 void OnPropertyGridColEndDrag( wxPropertyGridEvent
& event
);
248 void OnAbout( wxCommandEvent
& event
);
250 void OnMove( wxMoveEvent
& event
);
251 void OnResize( wxSizeEvent
& event
);
252 void OnPaint( wxPaintEvent
& event
);
253 void OnCloseEvent( wxCloseEvent
& event
);
255 void OnIdle( wxIdleEvent
& event
);
256 void OnShowPopup( wxCommandEvent
& 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_