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