]> git.saurik.com Git - wxWidgets.git/blob - samples/propgrid/propgrid.h
Add semi-public wxDynamicLibrary::MSWGetModuleHandle().
[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 // RCS-ID: $Id$
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
17 class wxAdvImageFileProperty : public wxFileProperty
18 {
19 WX_PG_DECLARE_PROPERTY_CLASS(wxAdvImageFileProperty)
20 public:
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
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 );
34
35 void LoadThumbnails( size_t n );
36
37 protected:
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
47 class wxVector3f
48 {
49 public:
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
62 inline 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
67 WX_PG_DECLARE_VARIANT_DATA(wxVector3f)
68
69 class wxVectorProperty : public wxPGProperty
70 {
71 WX_PG_DECLARE_PROPERTY_CLASS(wxVectorProperty)
72 public:
73
74 wxVectorProperty( const wxString& label = wxPG_LABEL,
75 const wxString& name = wxPG_LABEL,
76 const wxVector3f& value = wxVector3f() );
77 virtual ~wxVectorProperty();
78
79 virtual wxVariant ChildChanged( wxVariant& thisValue,
80 int childIndex,
81 wxVariant& childValue ) const;
82 virtual void RefreshChildren();
83
84 protected:
85 };
86
87 // -----------------------------------------------------------------------
88
89 class wxTriangle
90 {
91 public:
92 wxVector3f a, b, c;
93 };
94
95 inline 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
100 WX_PG_DECLARE_VARIANT_DATA(wxTriangle)
101
102 class wxTriangleProperty : public wxPGProperty
103 {
104 WX_PG_DECLARE_PROPERTY_CLASS(wxTriangleProperty)
105 public:
106
107 wxTriangleProperty( const wxString& label = wxPG_LABEL,
108 const wxString& name = wxPG_LABEL,
109 const wxTriangle& value = wxTriangle() );
110 virtual ~wxTriangleProperty();
111
112 virtual wxVariant ChildChanged( wxVariant& thisValue,
113 int childIndex,
114 wxVariant& childValue ) const;
115 virtual void RefreshChildren();
116
117 protected:
118 };
119
120 // -----------------------------------------------------------------------
121
122 enum
123 {
124 ID_COLOURSCHEME4 = 100
125 };
126
127 // -----------------------------------------------------------------------
128
129 class FormMain : public wxFrame
130 {
131 public:
132 FormMain(const wxString& title, const wxPoint& pos, const wxSize& size );
133 ~FormMain();
134
135 wxPropertyGridManager* m_pPropGridManager;
136 wxPropertyGrid* m_propGrid;
137
138 wxTextCtrl* m_tcPropLabel;
139 wxWindow* m_panel;
140 wxBoxSizer* m_topSizer;
141
142 wxPGEditor* m_pSampleMultiButtonEditor;
143 wxPGChoices m_combinedFlags;
144
145 wxMenuItem* m_itemCatColours;
146 wxMenuItem* m_itemFreeze;
147 wxMenuItem* m_itemEnable;
148
149 wxVariant m_storedValues;
150
151 wxString m_savedState;
152
153
154 void CreateGrid( int style, int extraStyle );
155 void FinalizeFramePosition();
156
157 // These are used in CreateGrid(), and in tests to compose
158 // grids for testing purposes.
159 void InitPanel();
160 void PopulateGrid();
161 void FinalizePanel( bool wasCreated = true );
162
163 void PopulateWithStandardItems();
164 void PopulateWithExamples();
165 void PopulateWithLibraryConfig();
166
167 void OnCloseClick( wxCommandEvent& event );
168 void OnLabelTextChange( wxCommandEvent& event );
169
170 void OnColourScheme( wxCommandEvent& event );
171
172 void OnInsertPropClick( wxCommandEvent& event );
173 void OnAppendPropClick( wxCommandEvent& event );
174 void OnClearClick( wxCommandEvent& event );
175 void OnAppendCatClick( wxCommandEvent& event );
176 void OnInsertCatClick( wxCommandEvent& event );
177 void OnDelPropClick( wxCommandEvent& event );
178 void OnDelPropRClick( wxCommandEvent& event );
179
180 void OnContextMenu( wxContextMenuEvent& event );
181
182 void OnEnableDisable( wxCommandEvent& event );
183 void OnHideShow( wxCommandEvent& event );
184 void OnSetBackgroundColour( wxCommandEvent& event );
185 void OnClearModifyStatusClick( wxCommandEvent& event );
186 void OnFreezeClick( wxCommandEvent& event );
187 void OnEnableLabelEditing( wxCommandEvent& event );
188 void OnDumpList( wxCommandEvent& event );
189 void OnCatColours( wxCommandEvent& event );
190 void OnSetColumns( wxCommandEvent& event );
191 void OnMisc( wxCommandEvent& event );
192 void OnPopulateClick( wxCommandEvent& event );
193 void OnSetSpinCtrlEditorClick( wxCommandEvent& event );
194 void OnTestReplaceClick( wxCommandEvent& event );
195 void OnTestXRC( wxCommandEvent& event );
196 void OnEnableCommonValues( wxCommandEvent& event );
197 void OnSelectStyle( wxCommandEvent& event );
198
199 void OnFitColumnsClick( wxCommandEvent& event );
200
201 void OnChangeFlagsPropItemsClick( wxCommandEvent& event );
202
203 void OnSaveToFileClick( wxCommandEvent& event );
204 void OnLoadFromFileClick( wxCommandEvent& event );
205
206 void OnSetPropertyValue( wxCommandEvent& event );
207 void OnInsertChoice( wxCommandEvent& event );
208 void OnDeleteChoice( wxCommandEvent& event );
209 void OnInsertPage( wxCommandEvent& event );
210 void OnRemovePage( wxCommandEvent& event );
211
212 void OnSaveState( wxCommandEvent& event );
213 void OnRestoreState( wxCommandEvent& event );
214
215 void OnRunMinimalClick( wxCommandEvent& event );
216
217 void OnIterate1Click( wxCommandEvent& event );
218 void OnIterate2Click( wxCommandEvent& event );
219 void OnIterate3Click( wxCommandEvent& event );
220 void OnIterate4Click( wxCommandEvent& event );
221
222 void OnPropertyGridChange( wxPropertyGridEvent& event );
223 void OnPropertyGridChanging( wxPropertyGridEvent& event );
224 void OnPropertyGridSelect( wxPropertyGridEvent& event );
225 void OnPropertyGridHighlight( wxPropertyGridEvent& event );
226 void OnPropertyGridItemRightClick( wxPropertyGridEvent& event );
227 void OnPropertyGridItemDoubleClick( wxPropertyGridEvent& event );
228 void OnPropertyGridPageChange( wxPropertyGridEvent& event );
229 void OnPropertyGridButtonClick( wxCommandEvent& event );
230 void OnPropertyGridTextUpdate( wxCommandEvent& event );
231 void OnPropertyGridKeyEvent( wxKeyEvent& event );
232 void OnPropertyGridItemCollapse( wxPropertyGridEvent& event );
233 void OnPropertyGridItemExpand( wxPropertyGridEvent& event );
234 void OnPropertyGridLabelEditBegin( wxPropertyGridEvent& event );
235 void OnPropertyGridLabelEditEnding( wxPropertyGridEvent& event );
236
237 void OnAbout( wxCommandEvent& event );
238
239 void OnMove( wxMoveEvent& event );
240 void OnResize( wxSizeEvent& event );
241 void OnPaint( wxPaintEvent& event );
242 void OnCloseEvent( wxCloseEvent& event );
243
244 void OnIdle( wxIdleEvent& event );
245
246 void AddTestProperties( wxPropertyGridPage* pg );
247
248 bool RunTests( bool fullTest, bool interactive = false );
249
250 private:
251 DECLARE_EVENT_TABLE()
252 };
253
254 // -----------------------------------------------------------------------
255
256 class cxApplication : public wxApp
257 {
258 public:
259
260 virtual bool OnInit();
261
262 private:
263 FormMain *Form1;
264 };
265
266 DECLARE_APP(cxApplication)
267
268 // -----------------------------------------------------------------------
269
270 #endif // _WX_SAMPLES_PROPGRID_PROPGRID_H_