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