]> git.saurik.com Git - wxWidgets.git/blob - samples/propgrid/propgrid.h
Don't generate any events from wxSpinCtrl and wxSpinCtrlDouble methods.
[wxWidgets.git] / samples / propgrid / propgrid.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid sample
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: 2004-09-25
7 // Copyright: (c) Jaakko Salli
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_SAMPLES_PROPGRID_PROPGRID_H_
12 #define _WX_SAMPLES_PROPGRID_PROPGRID_H_
13
14 // -----------------------------------------------------------------------
15
16 class wxAdvImageFileProperty : public wxFileProperty
17 {
18 WX_PG_DECLARE_PROPERTY_CLASS(wxAdvImageFileProperty)
19 public:
20
21 wxAdvImageFileProperty( const wxString& label = wxPG_LABEL,
22 const wxString& name = wxPG_LABEL,
23 const wxString& value = wxEmptyString );
24 virtual ~wxAdvImageFileProperty ();
25
26 virtual void OnSetValue(); // Override to allow image loading.
27
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 );
33
34 void LoadThumbnails( size_t n );
35
36 protected:
37 wxImage* m_pImage; // Temporary thumbnail data.
38
39 static wxPGChoices ms_choices;
40
41 int m_index; // Index required for choice behaviour.
42 };
43
44 // -----------------------------------------------------------------------
45
46 class wxVector3f
47 {
48 public:
49 wxVector3f()
50 {
51 x = y = z = 0.0;
52 }
53 wxVector3f( double x, double y, double z )
54 {
55 x = x; y = y; z = z;
56 }
57
58 double x, y, z;
59 };
60
61 inline bool operator == (const wxVector3f& a, const wxVector3f& b)
62 {
63 return (a.x == b.x && a.y == b.y && a.z == b.z);
64 }
65
66 WX_PG_DECLARE_VARIANT_DATA(wxVector3f)
67
68 class wxVectorProperty : public wxPGProperty
69 {
70 WX_PG_DECLARE_PROPERTY_CLASS(wxVectorProperty)
71 public:
72
73 wxVectorProperty( const wxString& label = wxPG_LABEL,
74 const wxString& name = wxPG_LABEL,
75 const wxVector3f& value = wxVector3f() );
76 virtual ~wxVectorProperty();
77
78 virtual wxVariant ChildChanged( wxVariant& thisValue,
79 int childIndex,
80 wxVariant& childValue ) const;
81 virtual void RefreshChildren();
82
83 protected:
84 };
85
86 // -----------------------------------------------------------------------
87
88 class wxTriangle
89 {
90 public:
91 wxVector3f a, b, c;
92 };
93
94 inline bool operator == (const wxTriangle& a, const wxTriangle& b)
95 {
96 return (a.a == b.a && a.b == b.b && a.c == b.c);
97 }
98
99 WX_PG_DECLARE_VARIANT_DATA(wxTriangle)
100
101 class wxTriangleProperty : public wxPGProperty
102 {
103 WX_PG_DECLARE_PROPERTY_CLASS(wxTriangleProperty)
104 public:
105
106 wxTriangleProperty( const wxString& label = wxPG_LABEL,
107 const wxString& name = wxPG_LABEL,
108 const wxTriangle& value = wxTriangle() );
109 virtual ~wxTriangleProperty();
110
111 virtual wxVariant ChildChanged( wxVariant& thisValue,
112 int childIndex,
113 wxVariant& childValue ) const;
114 virtual void RefreshChildren();
115
116 protected:
117 };
118
119 // -----------------------------------------------------------------------
120
121 enum
122 {
123 ID_COLOURSCHEME4 = 100
124 };
125
126 // -----------------------------------------------------------------------
127
128 class FormMain : public wxFrame
129 {
130 public:
131 FormMain(const wxString& title, const wxPoint& pos, const wxSize& size );
132 ~FormMain();
133
134 wxPropertyGridManager* m_pPropGridManager;
135 wxPropertyGrid* m_propGrid;
136
137 wxTextCtrl* m_tcPropLabel;
138 wxWindow* m_panel;
139 wxBoxSizer* m_topSizer;
140
141 #if wxUSE_LOGWINDOW
142 wxLogWindow* m_logWindow;
143 #endif
144
145 wxPGEditor* m_pSampleMultiButtonEditor;
146 wxPGChoices m_combinedFlags;
147
148 wxMenuItem* m_itemCatColours;
149 wxMenuItem* m_itemFreeze;
150 wxMenuItem* m_itemEnable;
151 wxMenuItem* m_itemVetoDragging;
152
153 wxVariant m_storedValues;
154
155 wxString m_savedState;
156
157
158 void CreateGrid( int style, int extraStyle );
159 void FinalizeFramePosition();
160
161 // These are used in CreateGrid(), and in tests to compose
162 // grids for testing purposes.
163 void InitPanel();
164 void PopulateGrid();
165 void FinalizePanel( bool wasCreated = true );
166
167 void PopulateWithStandardItems();
168 void PopulateWithExamples();
169 void PopulateWithLibraryConfig();
170
171 void OnCloseClick( wxCommandEvent& event );
172 void OnLabelTextChange( wxCommandEvent& event );
173
174 void OnColourScheme( wxCommandEvent& event );
175
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 );
183
184 void OnContextMenu( wxContextMenuEvent& event );
185
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 );
204
205 void OnFitColumnsClick( wxCommandEvent& event );
206
207 void OnChangeFlagsPropItemsClick( wxCommandEvent& event );
208
209 void OnSaveToFileClick( wxCommandEvent& event );
210 void OnLoadFromFileClick( wxCommandEvent& event );
211
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 );
217
218 void OnSaveState( wxCommandEvent& event );
219 void OnRestoreState( wxCommandEvent& event );
220
221 void OnRunMinimalClick( wxCommandEvent& event );
222
223 void OnIterate1Click( wxCommandEvent& event );
224 void OnIterate2Click( wxCommandEvent& event );
225 void OnIterate3Click( wxCommandEvent& event );
226 void OnIterate4Click( wxCommandEvent& event );
227
228 void OnExtendedKeyNav( wxCommandEvent& event );
229
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 );
247
248 void OnAbout( wxCommandEvent& event );
249
250 void OnMove( wxMoveEvent& event );
251 void OnResize( wxSizeEvent& event );
252 void OnPaint( wxPaintEvent& event );
253 void OnCloseEvent( wxCloseEvent& event );
254
255 void OnIdle( wxIdleEvent& event );
256 void OnShowPopup( wxCommandEvent& event );
257
258 void AddTestProperties( wxPropertyGridPage* pg );
259
260 bool RunTests( bool fullTest, bool interactive = false );
261
262 private:
263 DECLARE_EVENT_TABLE()
264 };
265
266 // -----------------------------------------------------------------------
267
268 class cxApplication : public wxApp
269 {
270 public:
271
272 virtual bool OnInit();
273
274 private:
275 FormMain *Form1;
276 };
277
278 DECLARE_APP(cxApplication)
279
280 // -----------------------------------------------------------------------
281
282 #endif // _WX_SAMPLES_PROPGRID_PROPGRID_H_