1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPropertyGridManager
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 @class wxPropertyGridPage
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
16 return @false in the derived wxPropertyGridPage::IsHandlingAllEvents.
18 Please note that wxPropertyGridPage lacks many non-const property
19 manipulation functions found in wxPropertyGridManager.
20 Please use parent manager (m_manager member variable) when needed.
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.
26 @section propgridpage_event_handling Event Handling
28 wxPropertyGridPage receives events emitted by its wxPropertyGridManager, but
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.
33 See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
39 class WXDLLIMPEXP_PROPGRID wxPropertyGridPage
: public wxEvtHandler
,
40 public wxPropertyGridInterface
42 friend class wxPropertyGridManager
;
46 virtual ~wxPropertyGridPage();
49 Deletes all properties on page.
54 Reduces column sizes to minimum possible that contents are still visibly
55 (naturally some margin space will be applied as well).
57 @return Returns minimum size for the page to still display everything.
59 @remarks This function only works properly if size of containing grid was
62 Note that you can also get calculated column widths by calling
63 GetColumnWidth() immediately after this function returns.
68 Returns page index in manager;
70 inline int GetIndex() const;
73 Returns "root property". It does not have name, etc. and it is not
74 visible. It is only useful for accessing its children.
76 wxPGProperty
* GetRoot() const;
79 Returns x-coordinate position of splitter on a page.
81 int GetSplitterPosition( int col
= 0 ) const;
84 Returns id of the tool bar item that represents this page on
85 wxPropertyGridManager's wxToolBar.
87 int GetToolId() const;
90 Do any member initialization in this method.
92 @remarks - Called every time the page is added into a manager.
93 - You can add properties to the page here.
98 Return false here to indicate unhandled events should be
99 propagated to manager's parent, as normal.
101 virtual bool IsHandlingAllEvents() const;
104 Called every time page is about to be shown.
105 Useful, for instance, creating properties just-in-time.
107 virtual void OnShow();
110 Refreshes given property on page.
112 virtual void RefreshProperty( wxPGProperty
* p
);
115 Sets splitter position on page.
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.
122 void SetSplitterPosition( int splitterPos
, int col
= 0 );
127 @class wxPropertyGridManager
129 wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
130 which can optionally have toolbar for mode and page selection, a help text
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.
138 To operate explicitly on properties on specific page, use
139 wxPropertyGridManager::GetPage() to obtain pointer to page's
140 wxPropertyGridPage object.
142 Visual methods, such as SetCellBackgroundColour() are only available in
143 wxPropertyGrid. Use wxPropertyGridManager::GetGrid() to obtain pointer to it.
145 Non-virtual iterators will not work in wxPropertyGridManager. Instead, you must
146 acquire the internal grid (GetGrid()) or wxPropertyGridPage object (GetPage()).
148 wxPropertyGridManager constructor has exact same format as wxPropertyGrid
149 constructor, and basically accepts same extra window style flags (albeit also
150 has some extra ones).
152 Here's some example code for creating and populating a wxPropertyGridManager:
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|
162 // Include description box.
164 // Include compactor.
167 wxPGMAN_DEFAULT_STYLE
170 wxPropertyGridPage* page;
172 page = pgMan->AddPage("First Page");
174 page->Append( new wxPropertyCategory("Category A1") );
176 page->Append( new wxIntProperty("Number",wxPG_LABEL,1) );
178 page->Append( new wxColourProperty("Colour",wxPG_LABEL,*wxWHITE) );
180 page = pgMan->AddPage("Second Page");
182 page->Append( "Text",wxPG_LABEL,"(no text)" );
184 page->Append( new wxFontProperty("Font",wxPG_LABEL) );
186 // Display a header above the grid
190 @section propgridmanager_window_styles_ Window Styles
192 See @ref propgrid_window_styles.
194 @section propgridmanager_event_handling Event Handling
196 See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
197 for more information.
202 class wxPropertyGridManager
: public wxPanel
, public wxPropertyGridInterface
206 Creates new property page. Note that the first page is not created
210 A label for the page. This may be shown as a toolbar tooltip etc.
213 Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
214 default image is used.
217 wxPropertyGridPage instance. Manager will take ownership of this
218 object. NULL indicates that a default page instance should be created.
220 @return Returns pointer to created property grid page.
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.
226 wxPropertyGridPage
* AddPage( const wxString
& label
= wxEmptyString
,
227 const wxBitmap
& bmp
= wxPG_NULL_BITMAP
,
228 wxPropertyGridPage
* pageObj
= NULL
);
231 Deletes all properties and all pages.
233 virtual void Clear();
236 Deletes all properties on given page.
238 void ClearPage( int page
);
241 Forces updating the value of property from the editor control.
243 @return Returns @true if value was actually updated.
245 bool CommitChangesFromEditor( wxUint32 flags
= 0 );
248 Two step creation. Whenever the control is created without any parameters,
249 use Create to actually create it. Don't access the control's public methods
250 before this is called.
252 @see @ref propgrid_window_styles
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
,
258 const wxString
& name
= wxPropertyGridManagerNameStr
);
261 Enables or disables (shows/hides) categories according to parameter enable.
264 Calling his may not properly update toolbar buttons.
266 bool EnableCategories( bool enable
);
269 Selects page, scrolls and/or expands items to ensure that the
270 given item is visible.
272 @return Returns @true if something was actually done.
274 bool EnsureVisible( wxPGPropArg id
);
277 Returns number of columns on given page. By the default,
278 returns number of columns on current page.
280 int GetColumnCount( int page
= -1 ) const;
283 Returns height of the description text box.
285 int GetDescBoxHeight() const;
288 Returns pointer to the contained wxPropertyGrid. This does not change
289 after wxPropertyGridManager has been created, so you can safely obtain
290 pointer once and use it for the entire lifetime of the manager
293 wxPropertyGrid
* GetGrid();
296 Similar to GetIterator, but instead returns wxPGVIterator instance,
297 which can be useful for forward-iterating through arbitrary property
300 virtual wxPGVIterator
GetVIterator( int flags
) const;
303 Returns currently selected page.
305 wxPropertyGridPage
* GetCurrentPage() const;
308 Returns page object for given page index.
310 wxPropertyGridPage
* GetPage( unsigned int ind
) const;
313 Returns page object for given page name.
315 wxPropertyGridPage
* GetPage( const wxString
& name
) const;
318 Returns index for a page name. If no match is found, wxNOT_FOUND is
321 int GetPageByName( const wxString
& name
) const;
324 Returns number of managed pages.
326 size_t GetPageCount() const;
329 Returns name of given page.
331 const wxString
& GetPageName( int index
) const;
334 Returns "root property" of the given page. It does not have name, etc.
335 and it is not visible. It is only useful for accessing its children.
337 wxPGProperty
* GetPageRoot( int index
) const;
339 /** Returns index to currently selected page. */
340 int GetSelectedPage() const;
342 /** Alias for GetSelection(). */
343 wxPGProperty
* GetSelectedProperty() const;
345 /** Shortcut for GetGrid()->GetSelection(). */
346 wxPGProperty
* GetSelection() const;
349 Returns a pointer to the toolbar currently associated with the
350 wxPropertyGridManager (if any).
352 wxToolBar
* GetToolBar() const;
355 Creates new property page. Note that the first page is not created
359 Add to this position. -1 will add as the last item.
362 A label for the page. This may be shown as a toolbar tooltip etc.
365 Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
366 default image is used.
369 wxPropertyGridPage instance. Manager will take ownership of this
370 object. If NULL, default page object is constructed.
372 @return Returns pointer to created page.
374 virtual wxPropertyGridPage
* InsertPage( int index
, const wxString
& label
,
375 const wxBitmap
& bmp
= wxNullBitmap
,
376 wxPropertyGridPage
* pageObj
= NULL
);
379 Returns @true if any property on any page has been modified by the user.
381 bool IsAnyModified() const;
384 Returns @true if updating is frozen (ie. Freeze() called but not yet Thaw() ).
386 bool IsFrozen() const;
389 Returns @true if any property on given page has been modified by the user.
391 bool IsPageModified( size_t index
) const;
394 Returns true if property is selected. Since selection is page
395 based, this function checks every page in the manager.
397 virtual bool IsPropertySelected( wxPGPropArg id
) const;
402 @return Returns @false if it was not possible to remove page in question.
404 virtual bool RemovePage( int page
);
407 Select and displays a given page.
410 Index of page being seleced. Can be -1 to select nothing.
412 void SelectPage( int index
);
415 Select and displays a given page (by label).
417 void SelectPage( const wxString
& label
);
419 /** Select and displays a given page. */
420 void SelectPage( wxPropertyGridPage
* page
);
425 @see wxPropertyGrid::SelectProperty(),
426 wxPropertyGridInterface::ClearSelection()
428 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
431 Sets number of columns on given page (default is current page).
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.
437 void SetColumnCount( int colCount
, int page
= -1 );
440 Sets a column title. Default title for column 0 is "Property",
441 and "Value" for column 1.
443 @remarks If header is not shown yet, then calling this
444 member function will make it visible.
446 void SetColumnTitle( int idx
, const wxString
& title
);
449 Sets label and text in description box.
451 void SetDescription( const wxString
& label
, const wxString
& content
);
453 /** Sets y coordinate of the description box splitter. */
454 void SetDescBoxHeight( int ht
, bool refresh
= true );
457 Moves splitter as left as possible, while still allowing all
458 labels to be shown in full.
461 If @false, will still allow sub-properties (ie. properties which
462 parent is not root or category) to be cropped.
465 If @true, takes labels on all pages into account.
467 void SetSplitterLeft( bool subProps
= false, bool allPages
= true );
469 /** Moves splitter as left as possible on an individual page, while still allowing all
470 labels to be shown in full.
472 void SetPageSplitterLeft(int page
, bool subProps
= false);
475 Sets splitter position on individual page.
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.
481 void SetPageSplitterPosition( int page
, int pos
, int column
= 0 );
484 Sets splitter position for all pages.
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.
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.
495 void SetSplitterPosition( int pos
, int column
= 0 );
498 Show or hide the property grid header control. It is hidden
501 @remarks Grid may look better if you use wxPG_NO_INTERNAL_BORDER
502 window style when showing a header.
504 void ShowHeader(bool show
= true);
509 // Subclassing helpers
513 Creates property grid for the manager. Reimplement in derived class to
514 use subclassed wxPropertyGrid. However, if you do this then you
515 must also use the two-step construction (ie. default constructor and
516 Create() instead of constructor with arguments) when creating the
519 virtual wxPropertyGrid
* CreatePropertyGrid() const;