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