]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: manager.h | |
3 | // Purpose: interface of wxPropertyGridManager | |
4 | // Author: wxWidgets team | |
526954c5 | 5 | // Licence: wxWindows licence |
1c4293cb VZ |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
0ad10f30 FM |
8 | /** |
9 | @class wxPropertyGridPage | |
1c4293cb VZ |
10 | |
11 | Holder of property grid page information. You can subclass this and | |
12 | give instance in wxPropertyGridManager::AddPage. It inherits from | |
13 | wxEvtHandler and can be used to process events specific to this | |
14 | page (id of events will still be same as manager's). If you don't | |
15 | want to use it to process all events of the page, you need to | |
0ad10f30 | 16 | return @false in the derived wxPropertyGridPage::IsHandlingAllEvents. |
1c4293cb VZ |
17 | |
18 | Please note that wxPropertyGridPage lacks many non-const property | |
0ad10f30 FM |
19 | manipulation functions found in wxPropertyGridManager. |
20 | Please use parent manager (m_manager member variable) when needed. | |
1c4293cb | 21 | |
bb6720bb JS |
22 | Please note that most member functions are inherited and as such not |
23 | documented on this page. This means you will probably also want to read | |
24 | wxPropertyGridInterface class reference. | |
1c4293cb VZ |
25 | |
26 | @section propgridpage_event_handling Event Handling | |
27 | ||
28 | wxPropertyGridPage receives events emitted by its wxPropertyGridManager, but | |
bb6720bb JS |
29 | only those events that are specific to that page. If wxPropertyGridPage:: |
30 | IsHandlingAllEvents returns false, then unhandled events are sent to the | |
31 | manager's parent, as usual. | |
1c4293cb VZ |
32 | |
33 | See @ref propgrid_event_handling "wxPropertyGrid Event Handling" | |
34 | for more information. | |
35 | ||
36 | @library{wxpropgrid} | |
37 | @category{propgrid} | |
38 | */ | |
39 | class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler, | |
40 | public wxPropertyGridInterface | |
41 | { | |
42 | friend class wxPropertyGridManager; | |
1c4293cb | 43 | |
0ad10f30 | 44 | public: |
1c4293cb VZ |
45 | wxPropertyGridPage(); |
46 | virtual ~wxPropertyGridPage(); | |
47 | ||
bb6720bb JS |
48 | /** |
49 | Deletes all properties on page. | |
1c4293cb VZ |
50 | */ |
51 | virtual void Clear(); | |
52 | ||
bb6720bb JS |
53 | /** |
54 | Reduces column sizes to minimum possible that contents are still visibly | |
55 | (naturally some margin space will be applied as well). | |
1c4293cb | 56 | |
bb6720bb | 57 | @return Returns minimum size for the page to still display everything. |
1c4293cb | 58 | |
bb6720bb JS |
59 | @remarks This function only works properly if size of containing grid was |
60 | already fairly large. | |
1c4293cb | 61 | |
bb6720bb JS |
62 | Note that you can also get calculated column widths by calling |
63 | GetColumnWidth() immediately after this function returns. | |
1c4293cb VZ |
64 | */ |
65 | wxSize FitColumns(); | |
66 | ||
bb6720bb JS |
67 | /** |
68 | Returns page index in manager; | |
1c4293cb VZ |
69 | */ |
70 | inline int GetIndex() const; | |
71 | ||
bb6720bb JS |
72 | /** |
73 | Returns "root property". It does not have name, etc. and it is not | |
74 | visible. It is only useful for accessing its children. | |
1c4293cb | 75 | */ |
bb6720bb | 76 | wxPGProperty* GetRoot() const; |
1c4293cb | 77 | |
bb6720bb JS |
78 | /** |
79 | Returns x-coordinate position of splitter on a page. | |
1c4293cb | 80 | */ |
bb6720bb | 81 | int GetSplitterPosition( int col = 0 ) const; |
1c4293cb | 82 | |
bb6720bb JS |
83 | /** |
84 | Returns id of the tool bar item that represents this page on | |
85 | wxPropertyGridManager's wxToolBar. | |
1c4293cb | 86 | */ |
0ad10f30 | 87 | int GetToolId() const; |
1c4293cb | 88 | |
bb6720bb JS |
89 | /** |
90 | Do any member initialization in this method. | |
91 | ||
92 | @remarks - Called every time the page is added into a manager. | |
93 | - You can add properties to the page here. | |
1c4293cb | 94 | */ |
0ad10f30 | 95 | virtual void Init(); |
1c4293cb | 96 | |
bb6720bb JS |
97 | /** |
98 | Return false here to indicate unhandled events should be | |
1c4293cb VZ |
99 | propagated to manager's parent, as normal. |
100 | */ | |
0ad10f30 | 101 | virtual bool IsHandlingAllEvents() const; |
1c4293cb | 102 | |
bb6720bb JS |
103 | /** |
104 | Called every time page is about to be shown. | |
1c4293cb VZ |
105 | Useful, for instance, creating properties just-in-time. |
106 | */ | |
107 | virtual void OnShow(); | |
108 | ||
bb6720bb JS |
109 | /** |
110 | Refreshes given property on page. | |
111 | */ | |
1c4293cb VZ |
112 | virtual void RefreshProperty( wxPGProperty* p ); |
113 | ||
0ad10f30 FM |
114 | /** |
115 | Sets splitter position on page. | |
116 | ||
1c4293cb | 117 | @remarks |
bb6720bb JS |
118 | Splitter position cannot exceed grid size, and therefore setting it |
119 | during form creation may fail as initial grid size is often smaller than | |
120 | desired splitter position, especially when sizers are being used. | |
1c4293cb VZ |
121 | */ |
122 | void SetSplitterPosition( int splitterPos, int col = 0 ); | |
123 | }; | |
124 | ||
1c4293cb | 125 | |
0ad10f30 FM |
126 | /** |
127 | @class wxPropertyGridManager | |
1c4293cb VZ |
128 | |
129 | wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid, | |
f5254768 JS |
130 | which can optionally have toolbar for mode and page selection, a help text |
131 | box, and a header. | |
bba3f9b5 JS |
132 | |
133 | wxPropertyGridManager inherits from wxPropertyGridInterface, and as such | |
134 | it has most property manipulation functions. However, only some of them affect | |
135 | properties on all pages (eg. GetPropertyByName() and ExpandAll()), while some | |
136 | (eg. Append()) only apply to the currently selected page. | |
137 | ||
bb6720bb JS |
138 | To operate explicitly on properties on specific page, use |
139 | wxPropertyGridManager::GetPage() to obtain pointer to page's | |
140 | wxPropertyGridPage object. | |
bba3f9b5 JS |
141 | |
142 | Visual methods, such as SetCellBackgroundColour() are only available in | |
143 | wxPropertyGrid. Use wxPropertyGridManager::GetGrid() to obtain pointer to it. | |
144 | ||
145 | Non-virtual iterators will not work in wxPropertyGridManager. Instead, you must | |
146 | acquire the internal grid (GetGrid()) or wxPropertyGridPage object (GetPage()). | |
147 | ||
148 | wxPropertyGridManager constructor has exact same format as wxPropertyGrid | |
f090e4ef | 149 | constructor, and basically accepts same extra window style flags (albeit also |
bba3f9b5 JS |
150 | has some extra ones). |
151 | ||
152 | Here's some example code for creating and populating a wxPropertyGridManager: | |
153 | ||
154 | @code | |
bba3f9b5 JS |
155 | wxPropertyGridManager* pgMan = new wxPropertyGridManager(this, PGID, |
156 | wxDefaultPosition, wxDefaultSize, | |
157 | // These and other similar styles are automatically | |
158 | // passed to the embedded wxPropertyGrid. | |
159 | wxPG_BOLD_MODIFIED|wxPG_SPLITTER_AUTO_CENTER| | |
160 | // Include toolbar. | |
161 | wxPG_TOOLBAR | | |
162 | // Include description box. | |
163 | wxPG_DESCRIPTION | | |
164 | // Include compactor. | |
165 | wxPG_COMPACTOR | | |
166 | // Plus defaults. | |
167 | wxPGMAN_DEFAULT_STYLE | |
168 | ); | |
169 | ||
170 | wxPropertyGridPage* page; | |
171 | ||
f8ebb70d | 172 | page = pgMan->AddPage("First Page"); |
bba3f9b5 | 173 | |
f8ebb70d | 174 | page->Append( new wxPropertyCategory("Category A1") ); |
bba3f9b5 | 175 | |
f8ebb70d | 176 | page->Append( new wxIntProperty("Number",wxPG_LABEL,1) ); |
bba3f9b5 | 177 | |
f8ebb70d | 178 | page->Append( new wxColourProperty("Colour",wxPG_LABEL,*wxWHITE) ); |
bba3f9b5 | 179 | |
f8ebb70d | 180 | page = pgMan->AddPage("Second Page"); |
bba3f9b5 | 181 | |
f8ebb70d | 182 | page->Append( "Text",wxPG_LABEL,"(no text)" ); |
bba3f9b5 | 183 | |
f8ebb70d | 184 | page->Append( new wxFontProperty("Font",wxPG_LABEL) ); |
f5254768 JS |
185 | |
186 | // Display a header above the grid | |
187 | pgMan->ShowHeader(); | |
bba3f9b5 JS |
188 | @endcode |
189 | ||
1c4293cb VZ |
190 | @section propgridmanager_window_styles_ Window Styles |
191 | ||
192 | See @ref propgrid_window_styles. | |
193 | ||
194 | @section propgridmanager_event_handling Event Handling | |
195 | ||
196 | See @ref propgrid_event_handling "wxPropertyGrid Event Handling" | |
197 | for more information. | |
198 | ||
199 | @library{wxpropgrid} | |
200 | @category{propgrid} | |
201 | */ | |
202 | class wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface | |
203 | { | |
204 | public: | |
bb6720bb JS |
205 | /** |
206 | Creates new property page. Note that the first page is not created | |
1c4293cb | 207 | automatically. |
bb6720bb | 208 | |
1c4293cb | 209 | @param label |
bb6720bb JS |
210 | A label for the page. This may be shown as a toolbar tooltip etc. |
211 | ||
1c4293cb | 212 | @param bmp |
bb6720bb JS |
213 | Bitmap image for toolbar. If wxNullBitmap is used, then a built-in |
214 | default image is used. | |
215 | ||
1c4293cb | 216 | @param pageObj |
bb6720bb JS |
217 | wxPropertyGridPage instance. Manager will take ownership of this |
218 | object. NULL indicates that a default page instance should be created. | |
219 | ||
9288df34 | 220 | @return Returns pointer to created property grid page. |
bb6720bb JS |
221 | |
222 | @remarks If toolbar is used, it is highly recommended that the pages are | |
223 | added when the toolbar is not turned off using window style flag | |
224 | switching. Otherwise toolbar buttons might not be added properly. | |
1c4293cb | 225 | */ |
9288df34 JS |
226 | wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString, |
227 | const wxBitmap& bmp = wxPG_NULL_BITMAP, | |
228 | wxPropertyGridPage* pageObj = NULL ); | |
1c4293cb | 229 | |
bb6720bb JS |
230 | /** |
231 | Deletes all properties and all pages. | |
1c4293cb VZ |
232 | */ |
233 | virtual void Clear(); | |
234 | ||
bb6720bb JS |
235 | /** |
236 | Deletes all properties on given page. | |
1c4293cb VZ |
237 | */ |
238 | void ClearPage( int page ); | |
239 | ||
bb6720bb JS |
240 | /** |
241 | Forces updating the value of property from the editor control. | |
242 | ||
243 | @return Returns @true if value was actually updated. | |
1c4293cb | 244 | */ |
0ad10f30 | 245 | bool CommitChangesFromEditor( wxUint32 flags = 0 ); |
1c4293cb | 246 | |
bb6720bb JS |
247 | /** |
248 | Two step creation. Whenever the control is created without any parameters, | |
1c4293cb VZ |
249 | use Create to actually create it. Don't access the control's public methods |
250 | before this is called. | |
bb6720bb JS |
251 | |
252 | @see @ref propgrid_window_styles | |
1c4293cb VZ |
253 | */ |
254 | bool Create( wxWindow *parent, wxWindowID id = wxID_ANY, | |
255 | const wxPoint& pos = wxDefaultPosition, | |
256 | const wxSize& size = wxDefaultSize, | |
257 | long style = wxPGMAN_DEFAULT_STYLE, | |
67414f00 | 258 | const wxString& name = wxPropertyGridManagerNameStr ); |
1c4293cb | 259 | |
bb6720bb JS |
260 | /** |
261 | Enables or disables (shows/hides) categories according to parameter enable. | |
262 | ||
263 | @remarks | |
264 | Calling his may not properly update toolbar buttons. | |
1c4293cb | 265 | */ |
0ad10f30 | 266 | bool EnableCategories( bool enable ); |
1c4293cb | 267 | |
bb6720bb JS |
268 | /** |
269 | Selects page, scrolls and/or expands items to ensure that the | |
270 | given item is visible. | |
271 | ||
272 | @return Returns @true if something was actually done. | |
1c4293cb VZ |
273 | */ |
274 | bool EnsureVisible( wxPGPropArg id ); | |
275 | ||
bb6720bb JS |
276 | /** |
277 | Returns number of columns on given page. By the default, | |
278 | returns number of columns on current page. | |
279 | */ | |
1c4293cb VZ |
280 | int GetColumnCount( int page = -1 ) const; |
281 | ||
bb6720bb JS |
282 | /** |
283 | Returns height of the description text box. | |
284 | */ | |
1c4293cb VZ |
285 | int GetDescBoxHeight() const; |
286 | ||
bb6720bb JS |
287 | /** |
288 | Returns pointer to the contained wxPropertyGrid. This does not change | |
1c4293cb | 289 | after wxPropertyGridManager has been created, so you can safely obtain |
bb6720bb JS |
290 | pointer once and use it for the entire lifetime of the manager |
291 | instance. | |
1c4293cb | 292 | */ |
bb6720bb | 293 | wxPropertyGrid* GetGrid(); |
1c4293cb | 294 | |
bb6720bb JS |
295 | /** |
296 | Similar to GetIterator, but instead returns wxPGVIterator instance, | |
1c4293cb VZ |
297 | which can be useful for forward-iterating through arbitrary property |
298 | containers. | |
299 | */ | |
300 | virtual wxPGVIterator GetVIterator( int flags ) const; | |
301 | ||
bb6720bb JS |
302 | /** |
303 | Returns currently selected page. | |
1c4293cb | 304 | */ |
bb6720bb | 305 | wxPropertyGridPage* GetCurrentPage() const; |
1c4293cb | 306 | |
bb6720bb JS |
307 | /** |
308 | Returns page object for given page index. | |
1c4293cb | 309 | */ |
0ad10f30 | 310 | wxPropertyGridPage* GetPage( unsigned int ind ) const; |
1c4293cb | 311 | |
bb6720bb JS |
312 | /** |
313 | Returns page object for given page name. | |
1c4293cb | 314 | */ |
0ad10f30 | 315 | wxPropertyGridPage* GetPage( const wxString& name ) const; |
1c4293cb | 316 | |
bb6720bb JS |
317 | /** |
318 | Returns index for a page name. If no match is found, wxNOT_FOUND is | |
319 | returned. | |
320 | */ | |
1c4293cb VZ |
321 | int GetPageByName( const wxString& name ) const; |
322 | ||
bb6720bb JS |
323 | /** |
324 | Returns number of managed pages. | |
325 | */ | |
1c4293cb VZ |
326 | size_t GetPageCount() const; |
327 | ||
0ad10f30 FM |
328 | /** |
329 | Returns name of given page. | |
330 | */ | |
1c4293cb VZ |
331 | const wxString& GetPageName( int index ) const; |
332 | ||
bb6720bb JS |
333 | /** |
334 | Returns "root property" of the given page. It does not have name, etc. | |
1c4293cb VZ |
335 | and it is not visible. It is only useful for accessing its children. |
336 | */ | |
337 | wxPGProperty* GetPageRoot( int index ) const; | |
338 | ||
339 | /** Returns index to currently selected page. */ | |
0ad10f30 | 340 | int GetSelectedPage() const; |
1c4293cb | 341 | |
67414f00 | 342 | /** Alias for GetSelection(). */ |
0ad10f30 | 343 | wxPGProperty* GetSelectedProperty() const; |
1c4293cb | 344 | |
67414f00 VZ |
345 | /** Shortcut for GetGrid()->GetSelection(). */ |
346 | wxPGProperty* GetSelection() const; | |
1c4293cb | 347 | |
bb6720bb JS |
348 | /** |
349 | Returns a pointer to the toolbar currently associated with the | |
350 | wxPropertyGridManager (if any). | |
351 | */ | |
0ad10f30 | 352 | wxToolBar* GetToolBar() const; |
1c4293cb | 353 | |
0ad10f30 FM |
354 | /** |
355 | Creates new property page. Note that the first page is not created | |
1c4293cb | 356 | automatically. |
bb6720bb | 357 | |
1c4293cb | 358 | @param index |
bb6720bb JS |
359 | Add to this position. -1 will add as the last item. |
360 | ||
1c4293cb | 361 | @param label |
bb6720bb JS |
362 | A label for the page. This may be shown as a toolbar tooltip etc. |
363 | ||
1c4293cb | 364 | @param bmp |
bb6720bb JS |
365 | Bitmap image for toolbar. If wxNullBitmap is used, then a built-in |
366 | default image is used. | |
367 | ||
1c4293cb | 368 | @param pageObj |
bb6720bb JS |
369 | wxPropertyGridPage instance. Manager will take ownership of this |
370 | object. If NULL, default page object is constructed. | |
371 | ||
9288df34 | 372 | @return Returns pointer to created page. |
1c4293cb | 373 | */ |
9288df34 JS |
374 | virtual wxPropertyGridPage* InsertPage( int index, const wxString& label, |
375 | const wxBitmap& bmp = wxNullBitmap, | |
376 | wxPropertyGridPage* pageObj = NULL ); | |
1c4293cb | 377 | |
bb6720bb JS |
378 | /** |
379 | Returns @true if any property on any page has been modified by the user. | |
380 | */ | |
1c4293cb VZ |
381 | bool IsAnyModified() const; |
382 | ||
bb6720bb | 383 | /** |
0ad10f30 | 384 | Returns @true if updating is frozen (ie. Freeze() called but not yet Thaw() ). |
bb6720bb JS |
385 | */ |
386 | bool IsFrozen() const; | |
1c4293cb | 387 | |
bb6720bb JS |
388 | /** |
389 | Returns @true if any property on given page has been modified by the user. | |
390 | */ | |
1c4293cb VZ |
391 | bool IsPageModified( size_t index ) const; |
392 | ||
fc72fab6 JS |
393 | /** |
394 | Returns true if property is selected. Since selection is page | |
395 | based, this function checks every page in the manager. | |
396 | */ | |
397 | virtual bool IsPropertySelected( wxPGPropArg id ) const; | |
398 | ||
0ad10f30 FM |
399 | /** |
400 | Removes a page. | |
bb6720bb JS |
401 | |
402 | @return Returns @false if it was not possible to remove page in question. | |
1c4293cb VZ |
403 | */ |
404 | virtual bool RemovePage( int page ); | |
405 | ||
0ad10f30 FM |
406 | /** |
407 | Select and displays a given page. | |
24588cd3 | 408 | |
1c4293cb | 409 | @param index |
24588cd3 | 410 | Index of page being seleced. Can be -1 to select nothing. |
1c4293cb VZ |
411 | */ |
412 | void SelectPage( int index ); | |
413 | ||
bb6720bb JS |
414 | /** |
415 | Select and displays a given page (by label). | |
416 | */ | |
417 | void SelectPage( const wxString& label ); | |
1c4293cb VZ |
418 | |
419 | /** Select and displays a given page. */ | |
bb6720bb | 420 | void SelectPage( wxPropertyGridPage* page ); |
1c4293cb | 421 | |
01b5ad3b JS |
422 | /** |
423 | Select a property. | |
424 | ||
425 | @see wxPropertyGrid::SelectProperty(), | |
426 | wxPropertyGridInterface::ClearSelection() | |
427 | */ | |
bb6720bb | 428 | bool SelectProperty( wxPGPropArg id, bool focus = false ); |
1c4293cb | 429 | |
bb6720bb JS |
430 | /** |
431 | Sets number of columns on given page (default is current page). | |
f5254768 JS |
432 | |
433 | @remarks If you use header, then you should always use this | |
434 | member function to set the column count, instead of | |
435 | ones present in wxPropertyGrid or wxPropertyGridPage. | |
1c4293cb VZ |
436 | */ |
437 | void SetColumnCount( int colCount, int page = -1 ); | |
438 | ||
f5254768 JS |
439 | /** |
440 | Sets a column title. Default title for column 0 is "Property", | |
441 | and "Value" for column 1. | |
442 | ||
443 | @remarks If header is not shown yet, then calling this | |
444 | member function will make it visible. | |
445 | */ | |
446 | void SetColumnTitle( int idx, const wxString& title ); | |
447 | ||
0ad10f30 FM |
448 | /** |
449 | Sets label and text in description box. | |
1c4293cb VZ |
450 | */ |
451 | void SetDescription( const wxString& label, const wxString& content ); | |
452 | ||
453 | /** Sets y coordinate of the description box splitter. */ | |
454 | void SetDescBoxHeight( int ht, bool refresh = true ); | |
455 | ||
0ad10f30 FM |
456 | /** |
457 | Moves splitter as left as possible, while still allowing all | |
1c4293cb | 458 | labels to be shown in full. |
bb6720bb | 459 | |
1c4293cb | 460 | @param subProps |
bb6720bb JS |
461 | If @false, will still allow sub-properties (ie. properties which |
462 | parent is not root or category) to be cropped. | |
463 | ||
1c4293cb | 464 | @param allPages |
bb6720bb | 465 | If @true, takes labels on all pages into account. |
1c4293cb VZ |
466 | */ |
467 | void SetSplitterLeft( bool subProps = false, bool allPages = true ); | |
468 | ||
216b59c6 JS |
469 | /** Moves splitter as left as possible on an individual page, while still allowing all |
470 | labels to be shown in full. | |
471 | */ | |
472 | void SetPageSplitterLeft(int page, bool subProps = false); | |
473 | ||
f5254768 JS |
474 | /** |
475 | Sets splitter position on individual page. | |
476 | ||
477 | @remarks If you use header, then you should always use this | |
478 | member function to set the splitter position, instead of | |
479 | ones present in wxPropertyGrid or wxPropertyGridPage. | |
480 | */ | |
0ad10f30 | 481 | void SetPageSplitterPosition( int page, int pos, int column = 0 ); |
1c4293cb | 482 | |
bb6720bb JS |
483 | /** |
484 | Sets splitter position for all pages. | |
485 | ||
f5254768 JS |
486 | @remarks Splitter position cannot exceed grid size, and therefore |
487 | setting it during form creation may fail as initial grid | |
488 | size is often smaller than desired splitter position, | |
489 | especially when sizers are being used. | |
490 | ||
491 | If you use header, then you should always use this | |
492 | member function to set the splitter position, instead of | |
493 | ones present in wxPropertyGrid or wxPropertyGridPage. | |
1c4293cb VZ |
494 | */ |
495 | void SetSplitterPosition( int pos, int column = 0 ); | |
496 | ||
f5254768 JS |
497 | /** |
498 | Show or hide the property grid header control. It is hidden | |
499 | by the default. | |
500 | ||
501 | @remarks Grid may look better if you use wxPG_NO_INTERNAL_BORDER | |
502 | window style when showing a header. | |
503 | */ | |
504 | void ShowHeader(bool show = true); | |
505 | ||
1c4293cb VZ |
506 | protected: |
507 | ||
508 | // | |
509 | // Subclassing helpers | |
510 | // | |
511 | ||
bb6720bb | 512 | /** |
3cfde7c0 | 513 | Creates property grid for the manager. Reimplement in derived class to |
4c51a665 DS |
514 | use subclassed wxPropertyGrid. However, if you do this then you |
515 | must also use the two-step construction (ie. default constructor and | |
3cfde7c0 JS |
516 | Create() instead of constructor with arguments) when creating the |
517 | manager. | |
1c4293cb VZ |
518 | */ |
519 | virtual wxPropertyGrid* CreatePropertyGrid() const; | |
1c4293cb | 520 | }; |