]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/propgrid/propgridpagestate.h | |
3 | // Purpose: wxPropertyGridPageState class | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-24 | |
ea5af9c5 | 7 | // RCS-ID: $Id$ |
1c4293cb | 8 | // Copyright: (c) Jaakko Salli |
526954c5 | 9 | // Licence: wxWindows licence |
1c4293cb VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_ | |
13 | #define _WX_PROPGRID_PROPGRIDPAGESTATE_H_ | |
14 | ||
6f631217 JS |
15 | #include "wx/defs.h" |
16 | ||
f4bc1aa2 JS |
17 | #if wxUSE_PROPGRID |
18 | ||
1c4293cb VZ |
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 | */ | |
0ee31682 | 28 | class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult |
1c4293cb VZ |
29 | { |
30 | friend class wxPropertyGridPageState; | |
31 | public: | |
0ee31682 JS |
32 | wxPropertyGridHitTestResult() |
33 | { | |
34 | m_property = NULL; | |
35 | m_column = -1; | |
36 | m_splitter = -1; | |
37 | m_splitterHitOffset = 0; | |
38 | } | |
1c4293cb | 39 | |
0ee31682 JS |
40 | ~wxPropertyGridHitTestResult() |
41 | { | |
42 | } | |
1c4293cb | 43 | |
0ee31682 JS |
44 | /** |
45 | Returns column hit. -1 for margin. | |
46 | */ | |
47 | int GetColumn() const { return m_column; } | |
1c4293cb | 48 | |
0ee31682 JS |
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 | } | |
1c4293cb | 57 | |
0ee31682 JS |
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; } | |
1c4293cb VZ |
68 | |
69 | private: | |
70 | /** Property. NULL if empty space below properties was hit */ | |
0ee31682 JS |
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; | |
1c4293cb VZ |
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 | { \ | |
a09307ab PC |
273 | if (this != &it) \ |
274 | Assign(it); \ | |
1c4293cb VZ |
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 | ||
1d882226 JS |
329 | /** |
330 | Additional copy constructor. | |
331 | */ | |
332 | wxPropertyGridConstIterator( const wxPropertyGridIterator& other ) | |
333 | { | |
334 | Assign(other); | |
335 | } | |
336 | ||
c724444f JS |
337 | /** |
338 | Additional assignment operator. | |
339 | */ | |
340 | const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it ) | |
341 | { | |
342 | Assign(it); | |
343 | return *this; | |
344 | } | |
345 | ||
1c4293cb VZ |
346 | protected: |
347 | }; | |
348 | ||
349 | // ----------------------------------------------------------------------- | |
350 | ||
351 | /** Base class to derive new viterators. | |
352 | */ | |
92ffc98a | 353 | class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData |
1c4293cb VZ |
354 | { |
355 | friend class wxPGVIterator; | |
356 | public: | |
92ffc98a | 357 | wxPGVIteratorBase() { } |
1c4293cb | 358 | virtual void Next() = 0; |
1c4293cb VZ |
359 | protected: |
360 | virtual ~wxPGVIteratorBase() { } | |
361 | ||
362 | wxPropertyGridIterator m_it; | |
1c4293cb VZ |
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 | } | |
1c4293cb VZ |
384 | const wxPGVIterator& operator=( const wxPGVIterator& it ) |
385 | { | |
a09307ab PC |
386 | if (this != &it) |
387 | { | |
388 | UnRef(); | |
389 | m_pIt = it.m_pIt; | |
390 | m_pIt->IncRef(); | |
391 | } | |
1c4293cb VZ |
392 | return *this; |
393 | } | |
1c4293cb VZ |
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 | ||
1c4293cb VZ |
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 behavior on property | |
441 | deletion. | |
442 | */ | |
f915d44b | 443 | virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); |
1c4293cb VZ |
444 | |
445 | wxSize DoFitColumns( bool allowGridResize = false ); | |
446 | ||
447 | wxPGProperty* DoGetItemAtY( int y ) const; | |
448 | ||
449 | /** | |
450 | Override this member function to add custom behavior 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, | |
f5254768 | 463 | int flags = 0 ); |
1c4293cb VZ |
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 | ||
1c4293cb VZ |
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 | { | |
68bcfd2c | 502 | return (unsigned int) m_colWidths.size(); |
1c4293cb VZ |
503 | } |
504 | ||
1c4293cb VZ |
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 | ||
fc72fab6 JS |
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 | ||
7f3f8f1e JS |
547 | void DoRemoveFromSelection( wxPGProperty* prop ); |
548 | ||
fe01f16e JS |
549 | void DoSetColumnProportion( unsigned int column, int proportion ); |
550 | ||
4279fdb4 JS |
551 | int DoGetColumnProportion( unsigned int column ) const |
552 | { | |
553 | return m_columnProportions[column]; | |
554 | } | |
555 | ||
76733d4c JS |
556 | void ResetColumnSizes( int setSplitterFlags ); |
557 | ||
1c4293cb VZ |
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 | ||
020b0041 JS |
569 | void DoSetPropertyName( wxPGProperty* p, const wxString& newName ); |
570 | ||
1c4293cb VZ |
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 | ||
e276acb5 JS |
588 | /** |
589 | Returns information about arbitrary position in the grid. | |
1c4293cb | 590 | |
e276acb5 JS |
591 | @param pt |
592 | Logical coordinates in the virtual grid space. Use | |
2e2e62de | 593 | wxScrolled<T>::CalcUnscrolledPosition() if you need to |
e276acb5 | 594 | translate a scrolled position into a logical one. |
1c4293cb VZ |
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 | ||
1c4293cb VZ |
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 | ||
1c4293cb VZ |
638 | void SetSplitterLeft( bool subProps = false ); |
639 | ||
640 | /** Set virtual width for this particular page. */ | |
641 | void SetVirtualWidth( int width ); | |
642 | ||
0eb877f2 JS |
643 | void DoSortChildren( wxPGProperty* p, int flags = 0 ); |
644 | void DoSort( int flags = 0 ); | |
645 | ||
646 | bool PrepareAfterItemsAdded(); | |
1c4293cb | 647 | |
1c4293cb VZ |
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 | ||
1c4293cb VZ |
661 | /** Called in, for example, wxPropertyGrid::Clear. */ |
662 | void DoClear(); | |
663 | ||
fc72fab6 JS |
664 | bool DoIsPropertySelected( wxPGProperty* prop ) const; |
665 | ||
1c4293cb VZ |
666 | bool DoCollapse( wxPGProperty* p ); |
667 | ||
668 | bool DoExpand( wxPGProperty* p ); | |
669 | ||
670 | void CalculateFontAndBitmapStuff( int vspacing ); | |
671 | ||
672 | protected: | |
673 | ||
169dc975 JS |
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 | ||
1c4293cb VZ |
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 | ||
2fd4a524 | 689 | bool PrepareToAddItem( wxPGProperty* property, |
1c4293cb VZ |
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 | ||
58935d4a JS |
712 | /** List of indices of columns the user can edit by clicking it. */ |
713 | wxArrayInt m_editableColumns; | |
714 | ||
fe01f16e JS |
715 | /** Column proportions */ |
716 | wxArrayInt m_columnProportions; | |
717 | ||
1c4293cb VZ |
718 | double m_fSplitterX; |
719 | ||
720 | /** Most recently added category. */ | |
721 | wxPropertyCategory* m_currentCategory; | |
722 | ||
fc72fab6 JS |
723 | /** Array of selected property. */ |
724 | wxArrayPGProperty m_selection; | |
1c4293cb VZ |
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; | |
94b8ecf1 | 745 | |
0da1f1c4 JS |
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 | ||
94b8ecf1 JS |
752 | private: |
753 | /** Only inits arrays, doesn't migrate things or such. */ | |
754 | void InitNonCatMode(); | |
1c4293cb VZ |
755 | }; |
756 | ||
1c4293cb VZ |
757 | // ----------------------------------------------------------------------- |
758 | ||
f4bc1aa2 JS |
759 | #endif // wxUSE_PROPGRID |
760 | ||
1c4293cb VZ |
761 | #endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_ |
762 |