]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/propgrid/propgridpagestate.h | |
3 | // Purpose: wxPropertyGridPageState class | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-24 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Jaakko Salli | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_ | |
13 | #define _WX_PROPGRID_PROPGRIDPAGESTATE_H_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_PROPGRID | |
18 | ||
19 | #include "wx/propgrid/property.h" | |
20 | ||
21 | // ----------------------------------------------------------------------- | |
22 | ||
23 | /** @section propgrid_hittestresult wxPropertyGridHitTestResult | |
24 | ||
25 | A return value from wxPropertyGrid::HitTest(), | |
26 | contains all you need to know about an arbitrary location on the grid. | |
27 | */ | |
28 | class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult | |
29 | { | |
30 | friend class wxPropertyGridPageState; | |
31 | public: | |
32 | wxPropertyGridHitTestResult() | |
33 | { | |
34 | m_property = NULL; | |
35 | m_column = -1; | |
36 | m_splitter = -1; | |
37 | m_splitterHitOffset = 0; | |
38 | } | |
39 | ||
40 | ~wxPropertyGridHitTestResult() | |
41 | { | |
42 | } | |
43 | ||
44 | /** | |
45 | Returns column hit. -1 for margin. | |
46 | */ | |
47 | int GetColumn() const { return m_column; } | |
48 | ||
49 | /** | |
50 | Returns property hit. NULL if empty space below | |
51 | properties was hit instead. | |
52 | */ | |
53 | wxPGProperty* GetProperty() const | |
54 | { | |
55 | return m_property; | |
56 | } | |
57 | ||
58 | /** | |
59 | Returns index of splitter hit, -1 for none. | |
60 | */ | |
61 | int GetSplitter() const { return m_splitter; } | |
62 | ||
63 | /** | |
64 | If splitter hit, then this member function | |
65 | returns offset to the exact splitter position. | |
66 | */ | |
67 | int GetSplitterHitOffset() const { return m_splitterHitOffset; } | |
68 | ||
69 | private: | |
70 | /** Property. NULL if empty space below properties was hit */ | |
71 | wxPGProperty* m_property; | |
72 | ||
73 | /** Column. -1 for margin. */ | |
74 | int m_column; | |
75 | ||
76 | /** Index of splitter hit, -1 for none. */ | |
77 | int m_splitter; | |
78 | ||
79 | /** If splitter hit, offset to that */ | |
80 | int m_splitterHitOffset; | |
81 | }; | |
82 | ||
83 | // ----------------------------------------------------------------------- | |
84 | ||
85 | #define wxPG_IT_CHILDREN(A) ((A)<<16) | |
86 | ||
87 | /** @section propgrid_iterator_flags wxPropertyGridIterator Flags | |
88 | @{ | |
89 | ||
90 | NOTES: At lower 16-bits, there are flags to check if item will be included. | |
91 | At higher 16-bits, there are same flags, but to instead check if children | |
92 | will be included. | |
93 | */ | |
94 | ||
95 | enum wxPG_ITERATOR_FLAGS | |
96 | { | |
97 | ||
98 | /** | |
99 | Iterate through 'normal' property items (does not include children of | |
100 | aggregate or hidden items by default). | |
101 | */ | |
102 | wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY | | |
103 | wxPG_PROP_MISC_PARENT | | |
104 | wxPG_PROP_AGGREGATE | | |
105 | wxPG_PROP_COLLAPSED | | |
106 | wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) | | |
107 | wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY), | |
108 | ||
109 | /** Iterate children of collapsed parents, and individual items that are hidden. | |
110 | */ | |
111 | wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN | | |
112 | wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED), | |
113 | ||
114 | /** | |
115 | Iterate children of parent that is an aggregate property (ie has fixed | |
116 | children). | |
117 | */ | |
118 | wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) | | |
119 | wxPG_ITERATE_PROPERTIES, | |
120 | ||
121 | /** Iterate categories. | |
122 | Note that even without this flag, children of categories are still iterated | |
123 | through. | |
124 | */ | |
125 | wxPG_ITERATE_CATEGORIES = wxPG_PROP_CATEGORY | | |
126 | wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY) | | |
127 | wxPG_PROP_COLLAPSED, | |
128 | ||
129 | wxPG_ITERATE_ALL_PARENTS = wxPG_PROP_MISC_PARENT | | |
130 | wxPG_PROP_AGGREGATE | | |
131 | wxPG_PROP_CATEGORY, | |
132 | ||
133 | wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = wxPG_ITERATE_ALL_PARENTS | | |
134 | wxPG_IT_CHILDREN( | |
135 | wxPG_ITERATE_ALL_PARENTS), | |
136 | ||
137 | wxPG_ITERATOR_FLAGS_ALL = wxPG_PROP_PROPERTY | | |
138 | wxPG_PROP_MISC_PARENT | | |
139 | wxPG_PROP_AGGREGATE | | |
140 | wxPG_PROP_HIDDEN | | |
141 | wxPG_PROP_CATEGORY | | |
142 | wxPG_PROP_COLLAPSED, | |
143 | ||
144 | wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL, | |
145 | ||
146 | // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY) | |
147 | wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL, | |
148 | ||
149 | /** Combines all flags needed to iterate through visible properties | |
150 | (ie hidden properties and children of collapsed parents are skipped). | |
151 | */ | |
152 | wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES | | |
153 | wxPG_PROP_CATEGORY | | |
154 | wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE), | |
155 | ||
156 | /** Iterate all items. | |
157 | */ | |
158 | wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE | | |
159 | wxPG_ITERATE_HIDDEN, | |
160 | ||
161 | /** Iterate through individual properties (ie categories and children of | |
162 | aggregate properties are skipped). | |
163 | */ | |
164 | wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES | | |
165 | wxPG_ITERATE_HIDDEN, | |
166 | ||
167 | /** Default iterator flags. | |
168 | */ | |
169 | wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL | |
170 | ||
171 | }; | |
172 | ||
173 | /** @} | |
174 | */ | |
175 | ||
176 | ||
177 | #define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \ | |
178 | A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \ | |
179 | wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \ | |
180 | B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & \ | |
181 | wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF; | |
182 | ||
183 | ||
184 | // Macro to test if children of PWC should be iterated through | |
185 | #define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \ | |
186 | ( \ | |
187 | !(PWC->GetFlags() & PARENTMASK) && \ | |
188 | PWC->GetChildCount() \ | |
189 | ) | |
190 | ||
191 | ||
192 | // Base for wxPropertyGridIterator classes. | |
193 | class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase | |
194 | { | |
195 | public: | |
196 | wxPropertyGridIteratorBase() | |
197 | { | |
198 | } | |
199 | ||
200 | void Assign( const wxPropertyGridIteratorBase& it ); | |
201 | ||
202 | bool AtEnd() const { return m_property == NULL; } | |
203 | ||
204 | /** Get current property. | |
205 | */ | |
206 | wxPGProperty* GetProperty() const { return m_property; } | |
207 | ||
208 | void Init( wxPropertyGridPageState* state, | |
209 | int flags, | |
210 | wxPGProperty* property, | |
211 | int dir = 1 ); | |
212 | ||
213 | void Init( wxPropertyGridPageState* state, | |
214 | int flags, | |
215 | int startPos = wxTOP, | |
216 | int dir = 0 ); | |
217 | ||
218 | /** Iterate to the next property. | |
219 | */ | |
220 | void Next( bool iterateChildren = true ); | |
221 | ||
222 | /** Iterate to the previous property. | |
223 | */ | |
224 | void Prev(); | |
225 | ||
226 | /** | |
227 | Set base parent, ie a property when, in which iteration returns, it | |
228 | ends. | |
229 | ||
230 | Default base parent is the root of the used wxPropertyGridPageState. | |
231 | */ | |
232 | void SetBaseParent( wxPGProperty* baseParent ) | |
233 | { m_baseParent = baseParent; } | |
234 | ||
235 | protected: | |
236 | ||
237 | wxPGProperty* m_property; | |
238 | ||
239 | private: | |
240 | wxPropertyGridPageState* m_state; | |
241 | wxPGProperty* m_baseParent; | |
242 | ||
243 | // Masks are used to quickly exclude items | |
244 | int m_itemExMask; | |
245 | int m_parentExMask; | |
246 | }; | |
247 | ||
248 | ||
249 | #define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \ | |
250 | CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, \ | |
251 | PROPERTY* property = NULL, int dir = 1 ) \ | |
252 | : wxPropertyGridIteratorBase() \ | |
253 | { Init( (wxPropertyGridPageState*)state, flags, \ | |
254 | (wxPGProperty*)property, dir ); } \ | |
255 | CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \ | |
256 | : wxPropertyGridIteratorBase() \ | |
257 | { Init( (wxPropertyGridPageState*)state, flags, startPos, dir ); } \ | |
258 | CLASS() \ | |
259 | : wxPropertyGridIteratorBase() \ | |
260 | { \ | |
261 | m_property = NULL; \ | |
262 | } \ | |
263 | CLASS( const CLASS& it ) \ | |
264 | : wxPropertyGridIteratorBase( ) \ | |
265 | { \ | |
266 | Assign(it); \ | |
267 | } \ | |
268 | ~CLASS() \ | |
269 | { \ | |
270 | } \ | |
271 | const CLASS& operator=( const CLASS& it ) \ | |
272 | { \ | |
273 | if (this != &it) \ | |
274 | Assign(it); \ | |
275 | return *this; \ | |
276 | } \ | |
277 | CLASS& operator++() { Next(); return *this; } \ | |
278 | CLASS operator++(int) { CLASS it=*this;Next();return it; } \ | |
279 | CLASS& operator--() { Prev(); return *this; } \ | |
280 | CLASS operator--(int) { CLASS it=*this;Prev();return it; } \ | |
281 | PROPERTY* operator *() const { return (PROPERTY*)m_property; } \ | |
282 | static PROPERTY* OneStep( STATE* state, \ | |
283 | int flags = wxPG_ITERATE_DEFAULT, \ | |
284 | PROPERTY* property = NULL, \ | |
285 | int dir = 1 ) \ | |
286 | { \ | |
287 | CLASS it( state, flags, property, dir ); \ | |
288 | if ( property ) \ | |
289 | { \ | |
290 | if ( dir == 1 ) it.Next(); \ | |
291 | else it.Prev(); \ | |
292 | } \ | |
293 | return *it; \ | |
294 | } | |
295 | ||
296 | ||
297 | /** @class wxPropertyGridIterator | |
298 | ||
299 | Preferable way to iterate through contents of wxPropertyGrid, | |
300 | wxPropertyGridManager, and wxPropertyGridPage. | |
301 | ||
302 | See wxPropertyGridInterface::GetIterator() for more information about usage. | |
303 | ||
304 | @library{wxpropgrid} | |
305 | @category{propgrid} | |
306 | */ | |
307 | class WXDLLIMPEXP_PROPGRID | |
308 | wxPropertyGridIterator : public wxPropertyGridIteratorBase | |
309 | { | |
310 | public: | |
311 | ||
312 | wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator, | |
313 | wxPGProperty, | |
314 | wxPropertyGridPageState) | |
315 | ||
316 | protected: | |
317 | }; | |
318 | ||
319 | ||
320 | // Const version of wxPropertyGridIterator. | |
321 | class WXDLLIMPEXP_PROPGRID | |
322 | wxPropertyGridConstIterator : public wxPropertyGridIteratorBase | |
323 | { | |
324 | public: | |
325 | wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator, | |
326 | const wxPGProperty, | |
327 | const wxPropertyGridPageState) | |
328 | ||
329 | /** | |
330 | Additional copy constructor. | |
331 | */ | |
332 | wxPropertyGridConstIterator( const wxPropertyGridIterator& other ) | |
333 | { | |
334 | Assign(other); | |
335 | } | |
336 | ||
337 | /** | |
338 | Additional assignment operator. | |
339 | */ | |
340 | const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it ) | |
341 | { | |
342 | Assign(it); | |
343 | return *this; | |
344 | } | |
345 | ||
346 | protected: | |
347 | }; | |
348 | ||
349 | // ----------------------------------------------------------------------- | |
350 | ||
351 | /** Base class to derive new viterators. | |
352 | */ | |
353 | class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData | |
354 | { | |
355 | friend class wxPGVIterator; | |
356 | public: | |
357 | wxPGVIteratorBase() { } | |
358 | virtual void Next() = 0; | |
359 | protected: | |
360 | virtual ~wxPGVIteratorBase() { } | |
361 | ||
362 | wxPropertyGridIterator m_it; | |
363 | }; | |
364 | ||
365 | /** @class wxPGVIterator | |
366 | ||
367 | Abstract implementation of a simple iterator. Can only be used | |
368 | to iterate in forward order, and only through the entire container. | |
369 | Used to have functions dealing with all properties work with both | |
370 | wxPropertyGrid and wxPropertyGridManager. | |
371 | */ | |
372 | class WXDLLIMPEXP_PROPGRID wxPGVIterator | |
373 | { | |
374 | public: | |
375 | wxPGVIterator() { m_pIt = NULL; } | |
376 | wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; } | |
377 | ~wxPGVIterator() { UnRef(); } | |
378 | void UnRef() { if (m_pIt) m_pIt->DecRef(); } | |
379 | wxPGVIterator( const wxPGVIterator& it ) | |
380 | { | |
381 | m_pIt = it.m_pIt; | |
382 | m_pIt->IncRef(); | |
383 | } | |
384 | const wxPGVIterator& operator=( const wxPGVIterator& it ) | |
385 | { | |
386 | if (this != &it) | |
387 | { | |
388 | UnRef(); | |
389 | m_pIt = it.m_pIt; | |
390 | m_pIt->IncRef(); | |
391 | } | |
392 | return *this; | |
393 | } | |
394 | void Next() { m_pIt->Next(); } | |
395 | bool AtEnd() const { return m_pIt->m_it.AtEnd(); } | |
396 | wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); } | |
397 | protected: | |
398 | wxPGVIteratorBase* m_pIt; | |
399 | }; | |
400 | ||
401 | // ----------------------------------------------------------------------- | |
402 | ||
403 | /** @class wxPropertyGridPageState | |
404 | ||
405 | Contains low-level property page information (properties, column widths, | |
406 | etc) of a single wxPropertyGrid or single wxPropertyGridPage. Generally you | |
407 | should not use this class directly, but instead member functions in | |
408 | wxPropertyGridInterface, wxPropertyGrid, wxPropertyGridPage, and | |
409 | wxPropertyGridManager. | |
410 | ||
411 | @remarks | |
412 | - In separate wxPropertyGrid component this class was known as | |
413 | wxPropertyGridState. | |
414 | - Currently this class is not implemented in wxPython. | |
415 | ||
416 | @library{wxpropgrid} | |
417 | @category{propgrid} | |
418 | */ | |
419 | class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState | |
420 | { | |
421 | friend class wxPGProperty; | |
422 | friend class wxPropertyGrid; | |
423 | friend class wxPGCanvas; | |
424 | friend class wxPropertyGridInterface; | |
425 | friend class wxPropertyGridPage; | |
426 | friend class wxPropertyGridManager; | |
427 | public: | |
428 | ||
429 | /** Default constructor. */ | |
430 | wxPropertyGridPageState(); | |
431 | ||
432 | /** Destructor. */ | |
433 | virtual ~wxPropertyGridPageState(); | |
434 | ||
435 | /** Makes sure all columns have minimum width. | |
436 | */ | |
437 | void CheckColumnWidths( int widthChange = 0 ); | |
438 | ||
439 | /** | |
440 | Override this member function to add custom behaviour on property | |
441 | deletion. | |
442 | */ | |
443 | virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); | |
444 | ||
445 | wxSize DoFitColumns( bool allowGridResize = false ); | |
446 | ||
447 | wxPGProperty* DoGetItemAtY( int y ) const; | |
448 | ||
449 | /** | |
450 | Override this member function to add custom behaviour on property | |
451 | insertion. | |
452 | */ | |
453 | virtual wxPGProperty* DoInsert( wxPGProperty* parent, | |
454 | int index, | |
455 | wxPGProperty* property ); | |
456 | ||
457 | /** | |
458 | This needs to be overridden in grid used the manager so that splitter | |
459 | changes can be propagated to other pages. | |
460 | */ | |
461 | virtual void DoSetSplitterPosition( int pos, | |
462 | int splitterColumn = 0, | |
463 | int flags = 0 ); | |
464 | ||
465 | bool EnableCategories( bool enable ); | |
466 | ||
467 | /** Make sure virtual height is up-to-date. | |
468 | */ | |
469 | void EnsureVirtualHeight() | |
470 | { | |
471 | if ( m_vhCalcPending ) | |
472 | { | |
473 | RecalculateVirtualHeight(); | |
474 | m_vhCalcPending = 0; | |
475 | } | |
476 | } | |
477 | ||
478 | /** Returns (precalculated) height of contained visible properties. | |
479 | */ | |
480 | unsigned int GetVirtualHeight() const | |
481 | { | |
482 | wxASSERT( !m_vhCalcPending ); | |
483 | return m_virtualHeight; | |
484 | } | |
485 | ||
486 | /** Returns (precalculated) height of contained visible properties. | |
487 | */ | |
488 | unsigned int GetVirtualHeight() | |
489 | { | |
490 | EnsureVirtualHeight(); | |
491 | return m_virtualHeight; | |
492 | } | |
493 | ||
494 | /** Returns actual height of contained visible properties. | |
495 | @remarks | |
496 | Mostly used for internal diagnostic purposes. | |
497 | */ | |
498 | inline unsigned int GetActualVirtualHeight() const; | |
499 | ||
500 | unsigned int GetColumnCount() const | |
501 | { | |
502 | return (unsigned int) m_colWidths.size(); | |
503 | } | |
504 | ||
505 | int GetColumnMinWidth( int column ) const; | |
506 | ||
507 | int GetColumnWidth( unsigned int column ) const | |
508 | { | |
509 | return m_colWidths[column]; | |
510 | } | |
511 | ||
512 | wxPropertyGrid* GetGrid() const { return m_pPropGrid; } | |
513 | ||
514 | /** Returns last item which could be iterated using given flags. | |
515 | @param flags | |
516 | @link iteratorflags List of iterator flags@endlink | |
517 | */ | |
518 | wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ); | |
519 | ||
520 | const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const | |
521 | { | |
522 | return ((wxPropertyGridPageState*)this)->GetLastItem(flags); | |
523 | } | |
524 | ||
525 | /** | |
526 | Returns currently selected property. | |
527 | */ | |
528 | wxPGProperty* GetSelection() const | |
529 | { | |
530 | if ( m_selection.size() == 0 ) | |
531 | return NULL; | |
532 | return m_selection[0]; | |
533 | } | |
534 | ||
535 | void DoSetSelection( wxPGProperty* prop ) | |
536 | { | |
537 | m_selection.clear(); | |
538 | if ( prop ) | |
539 | m_selection.push_back(prop); | |
540 | } | |
541 | ||
542 | bool DoClearSelection() | |
543 | { | |
544 | return DoSelectProperty(NULL); | |
545 | } | |
546 | ||
547 | void DoRemoveFromSelection( wxPGProperty* prop ); | |
548 | ||
549 | void DoSetColumnProportion( unsigned int column, int proportion ); | |
550 | ||
551 | int DoGetColumnProportion( unsigned int column ) const | |
552 | { | |
553 | return m_columnProportions[column]; | |
554 | } | |
555 | ||
556 | void ResetColumnSizes( int setSplitterFlags ); | |
557 | ||
558 | wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const; | |
559 | ||
560 | wxPGProperty* GetPropertyByLabel( const wxString& name, | |
561 | wxPGProperty* parent = NULL ) const; | |
562 | ||
563 | wxVariant DoGetPropertyValues( const wxString& listname, | |
564 | wxPGProperty* baseparent, | |
565 | long flags ) const; | |
566 | ||
567 | wxPGProperty* DoGetRoot() const { return m_properties; } | |
568 | ||
569 | void DoSetPropertyName( wxPGProperty* p, const wxString& newName ); | |
570 | ||
571 | // Returns combined width of margin and all the columns | |
572 | int GetVirtualWidth() const | |
573 | { | |
574 | return m_width; | |
575 | } | |
576 | ||
577 | /** | |
578 | Returns minimal width for given column so that all images and texts | |
579 | will fit entirely. | |
580 | ||
581 | Used by SetSplitterLeft() and DoFitColumns(). | |
582 | */ | |
583 | int GetColumnFitWidth(wxClientDC& dc, | |
584 | wxPGProperty* pwc, | |
585 | unsigned int col, | |
586 | bool subProps) const; | |
587 | ||
588 | /** | |
589 | Returns information about arbitrary position in the grid. | |
590 | ||
591 | @param pt | |
592 | Logical coordinates in the virtual grid space. Use | |
593 | wxScrolled<T>::CalcUnscrolledPosition() if you need to | |
594 | translate a scrolled position into a logical one. | |
595 | */ | |
596 | wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; | |
597 | ||
598 | /** Returns true if page is visibly displayed. | |
599 | */ | |
600 | inline bool IsDisplayed() const; | |
601 | ||
602 | bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } | |
603 | ||
604 | void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true ) | |
605 | { | |
606 | p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit); | |
607 | } | |
608 | ||
609 | bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 ); | |
610 | ||
611 | /** widthChange is non-client. | |
612 | */ | |
613 | void OnClientWidthChange( int newWidth, | |
614 | int widthChange, | |
615 | bool fromOnResize = false ); | |
616 | ||
617 | /** Recalculates m_virtualHeight. | |
618 | */ | |
619 | void RecalculateVirtualHeight() | |
620 | { | |
621 | m_virtualHeight = GetActualVirtualHeight(); | |
622 | } | |
623 | ||
624 | void SetColumnCount( int colCount ); | |
625 | ||
626 | void PropagateColSizeDec( int column, int decrease, int dir ); | |
627 | ||
628 | bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE ); | |
629 | ||
630 | bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value ); | |
631 | ||
632 | bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value ); | |
633 | ||
634 | bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value ); | |
635 | void DoSetPropertyValues( const wxVariantList& list, | |
636 | wxPGProperty* default_category ); | |
637 | ||
638 | void SetSplitterLeft( bool subProps = false ); | |
639 | ||
640 | /** Set virtual width for this particular page. */ | |
641 | void SetVirtualWidth( int width ); | |
642 | ||
643 | void DoSortChildren( wxPGProperty* p, int flags = 0 ); | |
644 | void DoSort( int flags = 0 ); | |
645 | ||
646 | bool PrepareAfterItemsAdded(); | |
647 | ||
648 | /** Called after virtual height needs to be recalculated. | |
649 | */ | |
650 | void VirtualHeightChanged() | |
651 | { | |
652 | m_vhCalcPending = 1; | |
653 | } | |
654 | ||
655 | /** Base append. */ | |
656 | wxPGProperty* DoAppend( wxPGProperty* property ); | |
657 | ||
658 | /** Returns property by its name. */ | |
659 | wxPGProperty* BaseGetPropertyByName( const wxString& name ) const; | |
660 | ||
661 | /** Called in, for example, wxPropertyGrid::Clear. */ | |
662 | void DoClear(); | |
663 | ||
664 | bool DoIsPropertySelected( wxPGProperty* prop ) const; | |
665 | ||
666 | bool DoCollapse( wxPGProperty* p ); | |
667 | ||
668 | bool DoExpand( wxPGProperty* p ); | |
669 | ||
670 | void CalculateFontAndBitmapStuff( int vspacing ); | |
671 | ||
672 | protected: | |
673 | ||
674 | // Utility to check if two properties are visibly next to each other | |
675 | bool ArePropertiesAdjacent( wxPGProperty* prop1, | |
676 | wxPGProperty* prop2, | |
677 | int iterFlags = wxPG_ITERATE_VISIBLE ) const; | |
678 | ||
679 | int DoGetSplitterPosition( int splitterIndex = 0 ) const; | |
680 | ||
681 | /** Returns column at x coordinate (in GetGrid()->GetPanel()). | |
682 | @param pSplitterHit | |
683 | Give pointer to int that receives index to splitter that is at x. | |
684 | @param pSplitterHitOffset | |
685 | Distance from said splitter. | |
686 | */ | |
687 | int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const; | |
688 | ||
689 | bool PrepareToAddItem( wxPGProperty* property, | |
690 | wxPGProperty* scheduledParent ); | |
691 | ||
692 | /** If visible, then this is pointer to wxPropertyGrid. | |
693 | This shall *never* be NULL to indicate that this state is not visible. | |
694 | */ | |
695 | wxPropertyGrid* m_pPropGrid; | |
696 | ||
697 | /** Pointer to currently used array. */ | |
698 | wxPGProperty* m_properties; | |
699 | ||
700 | /** Array for categoric mode. */ | |
701 | wxPGRootProperty m_regularArray; | |
702 | ||
703 | /** Array for root of non-categoric mode. */ | |
704 | wxPGRootProperty* m_abcArray; | |
705 | ||
706 | /** Dictionary for name-based access. */ | |
707 | wxPGHashMapS2P m_dictName; | |
708 | ||
709 | /** List of column widths (first column does not include margin). */ | |
710 | wxArrayInt m_colWidths; | |
711 | ||
712 | /** List of indices of columns the user can edit by clicking it. */ | |
713 | wxArrayInt m_editableColumns; | |
714 | ||
715 | /** Column proportions */ | |
716 | wxArrayInt m_columnProportions; | |
717 | ||
718 | double m_fSplitterX; | |
719 | ||
720 | /** Most recently added category. */ | |
721 | wxPropertyCategory* m_currentCategory; | |
722 | ||
723 | /** Array of selected property. */ | |
724 | wxArrayPGProperty m_selection; | |
725 | ||
726 | /** Virtual width. */ | |
727 | int m_width; | |
728 | ||
729 | /** Indicates total virtual height of visible properties. */ | |
730 | unsigned int m_virtualHeight; | |
731 | ||
732 | /** 1 if m_lastCaption is also the bottommost caption. */ | |
733 | unsigned char m_lastCaptionBottomnest; | |
734 | ||
735 | /** 1 items appended/inserted, so stuff needs to be done before drawing; | |
736 | If m_virtualHeight == 0, then calcylatey's must be done. | |
737 | Otherwise just sort. | |
738 | */ | |
739 | unsigned char m_itemsAdded; | |
740 | ||
741 | /** 1 if any value is modified. */ | |
742 | unsigned char m_anyModified; | |
743 | ||
744 | unsigned char m_vhCalcPending; | |
745 | ||
746 | /** True if splitter has been pre-set by the application. */ | |
747 | bool m_isSplitterPreSet; | |
748 | ||
749 | /** Used to (temporarily) disable splitter centering. */ | |
750 | bool m_dontCenterSplitter; | |
751 | ||
752 | private: | |
753 | /** Only inits arrays, doesn't migrate things or such. */ | |
754 | void InitNonCatMode(); | |
755 | }; | |
756 | ||
757 | // ----------------------------------------------------------------------- | |
758 | ||
759 | #endif // wxUSE_PROPGRID | |
760 | ||
761 | #endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_ | |
762 |