Use template class instead of template function in wxVectorSort().
[wxWidgets.git] / samples / propgrid / propgrid.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: samples/propgrid/propgrid.h
3// Purpose: wxPropertyGrid sample
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2004-09-25
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_SAMPLES_PROPGRID_PROPGRID_H_
13#define _WX_SAMPLES_PROPGRID_PROPGRID_H_
14
15// -----------------------------------------------------------------------
16
17class wxAdvImageFileProperty : public wxFileProperty
18{
19 WX_PG_DECLARE_PROPERTY_CLASS(wxAdvImageFileProperty)
20public:
21
22 wxAdvImageFileProperty( const wxString& label = wxPG_LABEL,
23 const wxString& name = wxPG_LABEL,
24 const wxString& value = wxEmptyString );
25 virtual ~wxAdvImageFileProperty ();
26
27 virtual void OnSetValue(); // Override to allow image loading.
28
7eac5c53
JS
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 );
1c4293cb
VZ
34
35 void LoadThumbnails( size_t n );
36
37protected:
38 wxImage* m_pImage; // Temporary thumbnail data.
39
40 static wxPGChoices ms_choices;
41
42 int m_index; // Index required for choice behaviour.
43};
44
45// -----------------------------------------------------------------------
46
47class wxVector3f
48{
49public:
50 wxVector3f()
51 {
52 x = y = z = 0.0;
53 }
54 wxVector3f( double x, double y, double z )
55 {
56 x = x; y = y; z = z;
57 }
58
59 double x, y, z;
60};
61
62inline bool operator == (const wxVector3f& a, const wxVector3f& b)
63{
64 return (a.x == b.x && a.y == b.y && a.z == b.z);
65}
66
0372d42e 67WX_PG_DECLARE_VARIANT_DATA(wxVector3f)
1c4293cb
VZ
68
69class wxVectorProperty : public wxPGProperty
70{
71 WX_PG_DECLARE_PROPERTY_CLASS(wxVectorProperty)
72public:
73
74 wxVectorProperty( const wxString& label = wxPG_LABEL,
41f02b9a
FM
75 const wxString& name = wxPG_LABEL,
76 const wxVector3f& value = wxVector3f() );
1c4293cb
VZ
77 virtual ~wxVectorProperty();
78
b8b1ff48
JS
79 virtual wxVariant ChildChanged( wxVariant& thisValue,
80 int childIndex,
81 wxVariant& childValue ) const;
7eac5c53 82 virtual void RefreshChildren();
1c4293cb
VZ
83
84protected:
85};
86
87// -----------------------------------------------------------------------
88
89class wxTriangle
90{
91public:
92 wxVector3f a, b, c;
93};
94
95inline bool operator == (const wxTriangle& a, const wxTriangle& b)
96{
97 return (a.a == b.a && a.b == b.b && a.c == b.c);
98}
99
0372d42e 100WX_PG_DECLARE_VARIANT_DATA(wxTriangle)
1c4293cb
VZ
101
102class wxTriangleProperty : public wxPGProperty
103{
104 WX_PG_DECLARE_PROPERTY_CLASS(wxTriangleProperty)
105public:
106
107 wxTriangleProperty( const wxString& label = wxPG_LABEL,
108 const wxString& name = wxPG_LABEL,
109 const wxTriangle& value = wxTriangle() );
110 virtual ~wxTriangleProperty();
111
b8b1ff48
JS
112 virtual wxVariant ChildChanged( wxVariant& thisValue,
113 int childIndex,
114 wxVariant& childValue ) const;
7eac5c53 115 virtual void RefreshChildren();
1c4293cb
VZ
116
117protected:
118};
119
120// -----------------------------------------------------------------------
121
122enum
123{
124 ID_COLOURSCHEME4 = 100
125};
126
127// -----------------------------------------------------------------------
128
129class FormMain : public wxFrame
130{
131public:
132 FormMain(const wxString& title, const wxPoint& pos, const wxSize& size );
41f02b9a 133 ~FormMain();
1c4293cb
VZ
134
135 wxPropertyGridManager* m_pPropGridManager;
136 wxPropertyGrid* m_propGrid;
137
138 wxTextCtrl* m_tcPropLabel;
139 wxWindow* m_panel;
140 wxBoxSizer* m_topSizer;
141
9d136b8b
JS
142#if wxUSE_LOGWINDOW
143 wxLogWindow* m_logWindow;
144#endif
145
524d97b1 146 wxPGEditor* m_pSampleMultiButtonEditor;
1c4293cb
VZ
147 wxPGChoices m_combinedFlags;
148
149 wxMenuItem* m_itemCatColours;
150 wxMenuItem* m_itemFreeze;
151 wxMenuItem* m_itemEnable;
5405bfb4 152 wxMenuItem* m_itemVetoDragging;
1c4293cb
VZ
153
154 wxVariant m_storedValues;
155
156 wxString m_savedState;
157
158
159 void CreateGrid( int style, int extraStyle );
c324ed94 160 void FinalizeFramePosition();
1c4293cb
VZ
161
162 // These are used in CreateGrid(), and in tests to compose
163 // grids for testing purposes.
164 void InitPanel();
165 void PopulateGrid();
166 void FinalizePanel( bool wasCreated = true );
167
168 void PopulateWithStandardItems();
169 void PopulateWithExamples();
170 void PopulateWithLibraryConfig();
171
172 void OnCloseClick( wxCommandEvent& event );
173 void OnLabelTextChange( wxCommandEvent& event );
174
175 void OnColourScheme( wxCommandEvent& event );
176
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 );
184
185 void OnContextMenu( wxContextMenuEvent& event );
186
187 void OnEnableDisable( wxCommandEvent& event );
8669431a 188 void OnSetReadOnly( wxCommandEvent& event );
7fe5c04d 189 void OnHide( wxCommandEvent& event );
d7e2b522 190 void OnSetBackgroundColour( wxCommandEvent& event );
1c4293cb
VZ
191 void OnClearModifyStatusClick( wxCommandEvent& event );
192 void OnFreezeClick( wxCommandEvent& event );
58935d4a 193 void OnEnableLabelEditing( wxCommandEvent& event );
f5254768 194 void OnShowHeader( wxCommandEvent& event );
1c4293cb
VZ
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 );
205
206 void OnFitColumnsClick( wxCommandEvent& event );
207
208 void OnChangeFlagsPropItemsClick( wxCommandEvent& event );
209
210 void OnSaveToFileClick( wxCommandEvent& event );
211 void OnLoadFromFileClick( wxCommandEvent& event );
212
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 );
218
219 void OnSaveState( wxCommandEvent& event );
220 void OnRestoreState( wxCommandEvent& event );
221
222 void OnRunMinimalClick( wxCommandEvent& event );
223
224 void OnIterate1Click( wxCommandEvent& event );
225 void OnIterate2Click( wxCommandEvent& event );
226 void OnIterate3Click( wxCommandEvent& event );
227 void OnIterate4Click( wxCommandEvent& event );
228
229 void OnPropertyGridChange( wxPropertyGridEvent& event );
230 void OnPropertyGridChanging( wxPropertyGridEvent& event );
231 void OnPropertyGridSelect( wxPropertyGridEvent& event );
232 void OnPropertyGridHighlight( wxPropertyGridEvent& event );
233 void OnPropertyGridItemRightClick( wxPropertyGridEvent& event );
234 void OnPropertyGridItemDoubleClick( wxPropertyGridEvent& event );
235 void OnPropertyGridPageChange( wxPropertyGridEvent& event );
236 void OnPropertyGridButtonClick( wxCommandEvent& event );
237 void OnPropertyGridTextUpdate( wxCommandEvent& event );
238 void OnPropertyGridKeyEvent( wxKeyEvent& event );
239 void OnPropertyGridItemCollapse( wxPropertyGridEvent& event );
240 void OnPropertyGridItemExpand( wxPropertyGridEvent& event );
58935d4a
JS
241 void OnPropertyGridLabelEditBegin( wxPropertyGridEvent& event );
242 void OnPropertyGridLabelEditEnding( wxPropertyGridEvent& event );
5405bfb4
JS
243 void OnPropertyGridColBeginDrag( wxPropertyGridEvent& event );
244 void OnPropertyGridColDragging( wxPropertyGridEvent& event );
245 void OnPropertyGridColEndDrag( wxPropertyGridEvent& event );
1c4293cb
VZ
246
247 void OnAbout( wxCommandEvent& event );
248
249 void OnMove( wxMoveEvent& event );
250 void OnResize( wxSizeEvent& event );
251 void OnPaint( wxPaintEvent& event );
252 void OnCloseEvent( wxCloseEvent& event );
253
254 void OnIdle( wxIdleEvent& event );
255
256 void AddTestProperties( wxPropertyGridPage* pg );
257
258 bool RunTests( bool fullTest, bool interactive = false );
259
260private:
261 DECLARE_EVENT_TABLE()
262};
263
264// -----------------------------------------------------------------------
265
266class cxApplication : public wxApp
267{
268public:
269
270 virtual bool OnInit();
271
272private:
273 FormMain *Form1;
274};
275
276DECLARE_APP(cxApplication)
277
278// -----------------------------------------------------------------------
279
280#endif // _WX_SAMPLES_PROPGRID_PROPGRID_H_