1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/manager.cpp
3 // Purpose: wxPropertyGridManager
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/object.h"
25 #include "wx/string.h"
28 #include "wx/window.h"
33 #include "wx/cursor.h"
34 #include "wx/settings.h"
35 #include "wx/textctrl.h"
37 #include "wx/statusbr.h"
41 // This define is necessary to prevent macro clearing
42 #define __wxPG_SOURCE_FILE__
44 #include "wx/propgrid/propgrid.h"
46 #include "wx/propgrid/manager.h"
49 #define wxPG_MAN_ALTERNATE_BASE_ID 11249 // Needed for wxID_ANY madnesss
52 // -----------------------------------------------------------------------
54 // For wxMSW cursor consistency, we must do mouse capturing even
55 // when using custom controls
57 #define BEGIN_MOUSE_CAPTURE \
58 if ( !(m_iFlags & wxPG_FL_MOUSE_CAPTURED) ) \
61 m_iFlags |= wxPG_FL_MOUSE_CAPTURED; \
64 #define END_MOUSE_CAPTURE \
65 if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED ) \
68 m_iFlags &= ~(wxPG_FL_MOUSE_CAPTURED); \
71 // -----------------------------------------------------------------------
72 // wxPropertyGridManager
73 // -----------------------------------------------------------------------
75 const char wxPropertyGridManagerNameStr
[] = "wxPropertyGridManager";
78 // Categoric Mode Icon
79 static const char* const gs_xpm_catmode
[] = {
104 // Alphabetic Mode Icon
105 static const char* const gs_xpm_noncatmode
[] = {
130 // Default Page Icon.
131 static const char* const gs_xpm_defpage
[] = {
156 // -----------------------------------------------------------------------
157 // wxPropertyGridPage
158 // -----------------------------------------------------------------------
161 IMPLEMENT_CLASS(wxPropertyGridPage
, wxEvtHandler
)
164 BEGIN_EVENT_TABLE(wxPropertyGridPage
, wxEvtHandler
)
168 wxPropertyGridPage::wxPropertyGridPage()
169 : wxEvtHandler(), wxPropertyGridInterface(), wxPropertyGridPageState()
171 m_pState
= this; // wxPropertyGridInterface to point to State
176 wxPropertyGridPage::~wxPropertyGridPage()
180 void wxPropertyGridPage::Clear()
182 GetStatePtr()->DoClear();
185 wxSize
wxPropertyGridPage::FitColumns()
187 wxSize sz
= DoFitColumns();
191 void wxPropertyGridPage::RefreshProperty( wxPGProperty
* p
)
194 m_manager
->RefreshProperty(p
);
197 void wxPropertyGridPage::OnShow()
201 void wxPropertyGridPage::SetSplitterPosition( int splitterPos
, int col
)
203 wxPropertyGrid
* pg
= GetGrid();
204 if ( pg
->GetState() == this )
205 pg
->SetSplitterPosition(splitterPos
);
207 DoSetSplitterPosition(splitterPos
, col
, false);
210 void wxPropertyGridPage::DoSetSplitterPosition( int pos
,
214 if ( (flags
& wxPG_SPLITTER_ALL_PAGES
) && m_manager
->GetPageCount() )
215 m_manager
->SetSplitterPosition( pos
, splitterColumn
);
217 wxPropertyGridPageState::DoSetSplitterPosition( pos
,
222 // -----------------------------------------------------------------------
224 // -----------------------------------------------------------------------
228 class wxPGHeaderCtrl
: public wxHeaderCtrl
231 wxPGHeaderCtrl(wxPropertyGridManager
* manager
) :
235 EnsureColumnCount(2);
237 // Seed titles with defaults
238 m_columns
[0]->SetTitle(_("Property"));
239 m_columns
[1]->SetTitle(_("Value"));
242 virtual ~wxPGHeaderCtrl()
244 for (unsigned int i
=0; i
<m_columns
.size(); i
++ )
248 int DetermineColumnWidth(unsigned int idx
, int* pMinWidth
) const
250 const wxPropertyGridPage
* page
= m_page
;
251 int colWidth
= page
->GetColumnWidth(idx
);
252 int colMinWidth
= page
->GetColumnMinWidth(idx
);
255 wxPropertyGrid
* pg
= m_manager
->GetGrid();
256 int margin
= pg
->GetMarginWidth();
258 // Compensate for the internal border
259 margin
+= (pg
->GetSize().x
- pg
->GetClientSize().x
) / 2;
262 colMinWidth
+= margin
;
264 *pMinWidth
= colMinWidth
;
268 void OnPageChanged(const wxPropertyGridPage
* page
)
276 // Get column info from the page
277 const wxPropertyGridPage
* page
= m_page
;
278 unsigned int colCount
= page
->GetColumnCount();
279 EnsureColumnCount(colCount
);
281 for ( unsigned int i
=0; i
<colCount
; i
++ )
283 wxHeaderColumnSimple
* colInfo
= m_columns
[i
];
285 int colWidth
= DetermineColumnWidth(i
, &colMinWidth
);
286 colInfo
->SetWidth(colWidth
);
287 colInfo
->SetMinWidth(colMinWidth
);
290 SetColumnCount(colCount
);
293 void OnColumWidthsChanged()
295 const wxPropertyGridPage
* page
= m_page
;
296 unsigned int colCount
= page
->GetColumnCount();
298 for ( unsigned int i
=0; i
<colCount
; i
++ )
300 wxHeaderColumnSimple
* colInfo
= m_columns
[i
];
302 int colWidth
= DetermineColumnWidth(i
, &colMinWidth
);
303 colInfo
->SetWidth(colWidth
);
304 colInfo
->SetMinWidth(colMinWidth
);
309 virtual const wxHeaderColumn
& GetColumn(unsigned int idx
) const
311 return *m_columns
[idx
];
314 void SetColumnTitle(unsigned int idx
, const wxString
& title
)
316 EnsureColumnCount(idx
+1);
317 m_columns
[idx
]->SetTitle(title
);
321 void EnsureColumnCount(unsigned int count
)
323 while ( m_columns
.size() < count
)
325 wxHeaderColumnSimple
* colInfo
= new wxHeaderColumnSimple("");
326 m_columns
.push_back(colInfo
);
330 void OnSetColumnWidth(int col
, int colWidth
)
332 wxPropertyGrid
* pg
= m_manager
->GetGrid();
334 // Compensate for the internal border
335 int x
= -((pg
->GetSize().x
- pg
->GetClientSize().x
) / 2);
337 for ( int i
=0; i
<col
; i
++ )
338 x
+= m_columns
[i
]->GetWidth();
342 pg
->DoSetSplitterPosition(x
, col
,
343 wxPG_SPLITTER_REFRESH
|
344 wxPG_SPLITTER_FROM_EVENT
);
347 virtual bool ProcessEvent( wxEvent
& event
)
349 if ( event
.IsKindOf(CLASSINFO(wxHeaderCtrlEvent
)) )
351 wxHeaderCtrlEvent
& hcEvent
=
352 static_cast<wxHeaderCtrlEvent
&>(event
);
354 wxPropertyGrid
* pg
= m_manager
->GetGrid();
355 int col
= hcEvent
.GetColumn();
356 int evtType
= event
.GetEventType();
358 if ( evtType
== wxEVT_COMMAND_HEADER_RESIZING
)
360 int colWidth
= hcEvent
.GetWidth();
362 OnSetColumnWidth(col
, colWidth
);
364 pg
->SendEvent(wxEVT_PG_COL_DRAGGING
,
370 else if ( evtType
== wxEVT_COMMAND_HEADER_BEGIN_RESIZE
)
372 // Never allow column resize if layout is static
373 if ( m_manager
->HasFlag(wxPG_STATIC_SPLITTER
) )
375 // Allow application to veto dragging
376 else if ( pg
->SendEvent(wxEVT_PG_COL_BEGIN_DRAG
,
383 else if ( evtType
== wxEVT_COMMAND_HEADER_END_RESIZE
)
385 pg
->SendEvent(wxEVT_PG_COL_END_DRAG
,
393 return wxHeaderCtrl::ProcessEvent(event
);
396 wxPropertyGridManager
* m_manager
;
397 const wxPropertyGridPage
* m_page
;
398 wxVector
<wxHeaderColumnSimple
*> m_columns
;
401 #endif // wxUSE_HEADERCTRL
403 // -----------------------------------------------------------------------
404 // wxPropertyGridManager
405 // -----------------------------------------------------------------------
407 // Final default splitter y is client height minus this.
408 #define wxPGMAN_DEFAULT_NEGATIVE_SPLITTER_Y 100
410 // -----------------------------------------------------------------------
412 IMPLEMENT_CLASS(wxPropertyGridManager
, wxPanel
)
414 #define ID_ADVTOOLBAR_OFFSET 1
415 #define ID_ADVHELPCAPTION_OFFSET 2
416 #define ID_ADVHELPCONTENT_OFFSET 3
417 #define ID_ADVHEADERCTRL_OFFSET 4
418 #define ID_ADVTBITEMSBASE_OFFSET 5 // Must be last.
420 // -----------------------------------------------------------------------
422 BEGIN_EVENT_TABLE(wxPropertyGridManager
, wxPanel
)
423 EVT_MOTION(wxPropertyGridManager::OnMouseMove
)
424 EVT_SIZE(wxPropertyGridManager::OnResize
)
425 EVT_PAINT(wxPropertyGridManager::OnPaint
)
426 EVT_LEFT_DOWN(wxPropertyGridManager::OnMouseClick
)
427 EVT_LEFT_UP(wxPropertyGridManager::OnMouseUp
)
428 EVT_LEAVE_WINDOW(wxPropertyGridManager::OnMouseEntry
)
429 //EVT_ENTER_WINDOW(wxPropertyGridManager::OnMouseEntry)
432 // -----------------------------------------------------------------------
434 wxPropertyGridManager::wxPropertyGridManager()
440 // -----------------------------------------------------------------------
442 wxPropertyGridManager::wxPropertyGridManager( wxWindow
*parent
,
447 const wxString
& name
)
451 Create(parent
,id
,pos
,size
,style
,name
);
454 // -----------------------------------------------------------------------
456 bool wxPropertyGridManager::Create( wxWindow
*parent
,
461 const wxString
& name
)
464 m_pPropGrid
= CreatePropertyGrid();
466 bool res
= wxPanel::Create( parent
, id
, pos
, size
,
467 (style
&0xFFFF0000)|wxWANTS_CHARS
,
471 // FIXME: this changes call ordering so wxPropertyGrid is created
472 // immediately, before SetExtraStyle has a chance to be called. However,
473 // without it, we may get assertions if size is wxDefaultSize.
474 //SetInitialSize(size);
479 // -----------------------------------------------------------------------
482 // Initialize values to defaults
484 void wxPropertyGridManager::Init1()
493 m_pHeaderCtrl
= NULL
;
494 m_showHeader
= false;
496 m_pTxtHelpCaption
= NULL
;
497 m_pTxtHelpContent
= NULL
;
503 m_width
= m_height
= 0;
505 m_splitterHeight
= 5;
507 m_splitterY
= -1; // -1 causes default to be set.
509 m_nextDescBoxSize
= -1;
517 // -----------------------------------------------------------------------
519 // These flags are always used in wxPropertyGrid integrated in wxPropertyGridManager.
520 #define wxPG_MAN_PROPGRID_FORCED_FLAGS ( wxBORDER_THEME | \
521 wxNO_FULL_REPAINT_ON_RESIZE| \
524 // Which flags can be passed to underlying wxPropertyGrid.
525 #define wxPG_MAN_PASS_FLAGS_MASK (0xFFF0|wxTAB_TRAVERSAL)
528 // Initialize after parent etc. set
530 void wxPropertyGridManager::Init2( int style
)
533 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
536 m_windowStyle
|= (style
&0x0000FFFF);
538 wxSize csz
= GetClientSize();
540 m_cursorSizeNS
= wxCursor(wxCURSOR_SIZENS
);
542 // Prepare the first page
543 // NB: But just prepare - you still need to call Add/InsertPage
544 // to actually add properties on it.
545 wxPropertyGridPage
* pd
= new wxPropertyGridPage();
546 pd
->m_isDefault
= true;
547 pd
->m_manager
= this;
548 wxPropertyGridPageState
* state
= pd
->GetStatePtr();
549 state
->m_pPropGrid
= m_pPropGrid
;
550 m_arrPages
.push_back( pd
);
551 m_pPropGrid
->m_pState
= state
;
553 wxWindowID baseId
= GetId();
554 wxWindowID useId
= baseId
;
556 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
561 // Smaller controls on Mac
562 SetWindowVariant(wxWINDOW_VARIANT_SMALL
);
565 long propGridFlags
= (m_windowStyle
&wxPG_MAN_PASS_FLAGS_MASK
)
566 |wxPG_MAN_PROPGRID_FORCED_FLAGS
;
568 propGridFlags
&= ~wxBORDER_MASK
;
570 if ((style
& wxPG_NO_INTERNAL_BORDER
) == 0)
572 propGridFlags
|= wxBORDER_THEME
;
576 propGridFlags
|= wxBORDER_NONE
;
577 wxWindow::SetExtraStyle(wxPG_EX_TOOLBAR_SEPARATOR
);
580 // Create propertygrid.
581 m_pPropGrid
->Create(this,baseId
,wxPoint(0,0),csz
, propGridFlags
);
583 m_pPropGrid
->m_eventObject
= this;
585 m_pPropGrid
->SetId(useId
);
587 m_pPropGrid
->m_iFlags
|= wxPG_FL_IN_MANAGER
;
589 m_pState
= m_pPropGrid
->m_pState
;
591 m_pPropGrid
->SetExtraStyle(wxPG_EX_INIT_NOCAT
);
593 m_nextTbInd
= baseId
+ID_ADVTBITEMSBASE_OFFSET
+ 2;
596 // Connect to property grid onselect event.
597 // NB: Even if wxID_ANY is used, this doesn't connect properly in wxPython
598 // (see wxPropertyGridManager::ProcessEvent).
599 Connect(m_pPropGrid
->GetId(),
601 wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect
));
603 Connect(m_pPropGrid
->GetId(),
604 wxEVT_PG_COL_DRAGGING
,
605 wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag
));
607 // Connect to toolbar button events.
608 Connect(baseId
+ID_ADVTBITEMSBASE_OFFSET
,baseId
+ID_ADVTBITEMSBASE_OFFSET
+50,
609 wxEVT_COMMAND_TOOL_CLICKED
,
610 wxCommandEventHandler(wxPropertyGridManager::OnToolbarClick
) );
612 // Optional initial controls.
615 m_iFlags
|= wxPG_FL_INITIALIZED
;
619 // -----------------------------------------------------------------------
621 wxPropertyGridManager::~wxPropertyGridManager()
625 //m_pPropGrid->ClearSelection();
630 for ( i
=0; i
<m_arrPages
.size(); i
++ )
632 delete m_arrPages
[i
];
638 // -----------------------------------------------------------------------
640 wxPropertyGrid
* wxPropertyGridManager::CreatePropertyGrid() const
642 return new wxPropertyGrid();
645 // -----------------------------------------------------------------------
647 void wxPropertyGridManager::SetId( wxWindowID winid
)
649 wxWindow::SetId(winid
);
651 // TODO: Reconnect propgrid event handler(s).
653 m_pPropGrid
->SetId(winid
);
656 // -----------------------------------------------------------------------
658 wxSize
wxPropertyGridManager::DoGetBestSize() const
660 return wxSize(60,150);
663 // -----------------------------------------------------------------------
665 bool wxPropertyGridManager::SetFont( const wxFont
& font
)
667 bool res
= wxWindow::SetFont(font
);
668 m_pPropGrid
->SetFont(font
);
670 // TODO: Need to do caption recacalculations for other pages as well.
672 for ( i
=0; i
<m_arrPages
.size(); i
++ )
674 wxPropertyGridPage
* page
= GetPage(i
);
676 if ( page
!= m_pPropGrid
->GetState() )
677 page
->CalculateFontAndBitmapStuff(-1);
683 // -----------------------------------------------------------------------
685 void wxPropertyGridManager::SetExtraStyle( long exStyle
)
687 wxWindow::SetExtraStyle( exStyle
);
688 m_pPropGrid
->SetExtraStyle( exStyle
& 0xFFFFF000 );
690 if ( (exStyle
& wxPG_EX_NO_FLAT_TOOLBAR
) && m_pToolbar
)
695 // -----------------------------------------------------------------------
697 void wxPropertyGridManager::Freeze()
699 m_pPropGrid
->Freeze();
703 // -----------------------------------------------------------------------
705 void wxPropertyGridManager::Thaw()
711 // -----------------------------------------------------------------------
713 void wxPropertyGridManager::SetWindowStyleFlag( long style
)
715 int oldWindowStyle
= GetWindowStyleFlag();
717 wxWindow::SetWindowStyleFlag( style
);
718 m_pPropGrid
->SetWindowStyleFlag( (m_pPropGrid
->GetWindowStyleFlag()&~(wxPG_MAN_PASS_FLAGS_MASK
)) |
719 (style
&wxPG_MAN_PASS_FLAGS_MASK
) );
721 // Need to re-position windows?
722 if ( (oldWindowStyle
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) !=
723 (style
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) )
729 // -----------------------------------------------------------------------
731 bool wxPropertyGridManager::Reparent( wxWindowBase
*newParent
)
734 m_pPropGrid
->OnTLPChanging((wxWindow
*)newParent
);
736 bool res
= wxPanel::Reparent(newParent
);
741 // -----------------------------------------------------------------------
743 // Actually shows given page.
744 bool wxPropertyGridManager::DoSelectPage( int index
)
746 // -1 means no page was selected
747 //wxASSERT( m_selPage >= 0 );
749 wxCHECK_MSG( index
>= -1 && index
< (int)GetPageCount(),
751 wxT("invalid page index") );
753 if ( m_selPage
== index
)
756 if ( m_pPropGrid
->GetSelection() )
758 if ( !m_pPropGrid
->ClearSelection() )
762 wxPropertyGridPage
* prevPage
;
764 if ( m_selPage
>= 0 )
765 prevPage
= GetPage(m_selPage
);
767 prevPage
= m_emptyPage
;
769 wxPropertyGridPage
* nextPage
;
773 nextPage
= m_arrPages
[index
];
781 m_emptyPage
= new wxPropertyGridPage();
782 m_emptyPage
->m_pPropGrid
= m_pPropGrid
;
785 nextPage
= m_emptyPage
;
788 m_iFlags
|= wxPG_FL_DESC_REFRESH_REQUIRED
;
790 m_pPropGrid
->SwitchState( nextPage
->GetStatePtr() );
792 m_pState
= m_pPropGrid
->m_pState
;
800 m_pToolbar
->ToggleTool( nextPage
->m_id
, true );
802 m_pToolbar
->ToggleTool( prevPage
->m_id
, false );
808 m_pHeaderCtrl
->OnPageChanged(nextPage
);
814 // -----------------------------------------------------------------------
816 // Changes page *and* set the target page for insertion operations.
817 void wxPropertyGridManager::SelectPage( int index
)
822 // -----------------------------------------------------------------------
824 int wxPropertyGridManager::GetPageByName( const wxString
& name
) const
827 for ( i
=0; i
<GetPageCount(); i
++ )
829 if ( m_arrPages
[i
]->m_label
== name
)
835 // -----------------------------------------------------------------------
837 int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState
* pState
) const
842 for ( i
=0; i
<GetPageCount(); i
++ )
844 if ( pState
== m_arrPages
[i
]->GetStatePtr() )
851 // -----------------------------------------------------------------------
853 const wxString
& wxPropertyGridManager::GetPageName( int index
) const
855 wxASSERT( index
>= 0 && index
< (int)GetPageCount() );
856 return m_arrPages
[index
]->m_label
;
859 // -----------------------------------------------------------------------
861 wxPropertyGridPageState
* wxPropertyGridManager::GetPageState( int page
) const
863 // Do not change this into wxCHECK because returning NULL is important
864 // for wxPropertyGridInterface page enumeration mechanics.
865 if ( page
>= (int)GetPageCount() )
870 return m_arrPages
[page
];
873 // -----------------------------------------------------------------------
875 void wxPropertyGridManager::Clear()
877 m_pPropGrid
->ClearSelection(false);
879 m_pPropGrid
->Freeze();
882 for ( i
=(int)GetPageCount()-1; i
>=0; i
-- )
886 m_nextTbInd
= m_baseId
+ID_ADVTBITEMSBASE_OFFSET
+ 2;
891 // -----------------------------------------------------------------------
893 void wxPropertyGridManager::ClearPage( int page
)
895 wxASSERT( page
>= 0 );
896 wxASSERT( page
< (int)GetPageCount() );
898 if ( page
>= 0 && page
< (int)GetPageCount() )
900 wxPropertyGridPageState
* state
= m_arrPages
[page
];
902 if ( state
== m_pPropGrid
->GetState() )
903 m_pPropGrid
->Clear();
909 // -----------------------------------------------------------------------
911 int wxPropertyGridManager::GetColumnCount( int page
) const
913 wxASSERT( page
>= -1 );
914 wxASSERT( page
< (int)GetPageCount() );
916 return GetPageState(page
)->GetColumnCount();
919 // -----------------------------------------------------------------------
921 void wxPropertyGridManager::SetColumnCount( int colCount
, int page
)
923 wxASSERT( page
>= -1 );
924 wxASSERT( page
< (int)GetPageCount() );
926 GetPageState(page
)->SetColumnCount( colCount
);
927 GetGrid()->Refresh();
931 m_pHeaderCtrl
->OnPageUpdated();
934 // -----------------------------------------------------------------------
936 size_t wxPropertyGridManager::GetPageCount() const
938 if ( !(m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
) )
941 return m_arrPages
.size();
944 // -----------------------------------------------------------------------
946 wxPropertyGridPage
* wxPropertyGridManager::InsertPage( int index
,
947 const wxString
& label
,
949 wxPropertyGridPage
* pageObj
)
952 index
= GetPageCount();
954 wxCHECK_MSG( (size_t)index
== GetPageCount(), NULL
,
955 wxT("wxPropertyGridManager currently only supports appending pages (due to wxToolBar limitation)."));
957 bool needInit
= true;
958 bool isPageInserted
= m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
? true : false;
960 wxASSERT( index
== 0 || isPageInserted
);
964 // No custom page object was given, so we will either re-use the default base
965 // page (if index==0), or create a new default page object.
966 if ( !isPageInserted
)
968 pageObj
= GetPage(0);
969 // Of course, if the base page was custom, we need to delete and
971 if ( !pageObj
->m_isDefault
)
974 pageObj
= new wxPropertyGridPage();
975 m_arrPages
[0] = pageObj
;
981 pageObj
= new wxPropertyGridPage();
983 pageObj
->m_isDefault
= true;
987 if ( !isPageInserted
)
989 // Initial page needs to be deleted and replaced
991 m_arrPages
[0] = pageObj
;
992 m_pPropGrid
->m_pState
= pageObj
->GetStatePtr();
996 wxPropertyGridPageState
* state
= pageObj
->GetStatePtr();
998 pageObj
->m_manager
= this;
1002 state
->m_pPropGrid
= m_pPropGrid
;
1003 state
->InitNonCatMode();
1006 if ( label
.length() )
1008 wxASSERT_MSG( !pageObj
->m_label
.length(),
1009 wxT("If page label is given in constructor, empty label must be given in AddPage"));
1010 pageObj
->m_label
= label
;
1013 pageObj
->m_id
= m_nextTbInd
;
1015 if ( !HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
1016 pageObj
->m_dontCenterSplitter
= true;
1018 if ( isPageInserted
)
1019 m_arrPages
.push_back( pageObj
);
1022 if ( m_windowStyle
& wxPG_TOOLBAR
)
1027 if ( !(GetExtraStyle()&wxPG_EX_HIDE_PAGE_BUTTONS
) )
1029 wxASSERT( m_pToolbar
);
1031 // Add separator before first page.
1032 if ( GetPageCount() < 2 && (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) &&
1033 m_pToolbar
->GetToolsCount() < 3 )
1034 m_pToolbar
->AddSeparator();
1036 if ( &bmp
!= &wxNullBitmap
)
1037 m_pToolbar
->AddTool(m_nextTbInd
,label
,bmp
,label
,wxITEM_RADIO
);
1038 //m_pToolbar->InsertTool(index+3,m_nextTbInd,bmp);
1040 m_pToolbar
->AddTool(m_nextTbInd
,label
,wxBitmap(gs_xpm_defpage
),
1041 label
,wxITEM_RADIO
);
1045 m_pToolbar
->Realize();
1052 // If selected page was above the point of insertion, fix the current page index
1053 if ( isPageInserted
)
1055 if ( m_selPage
>= index
)
1062 // Set this value only when adding the first page
1068 m_iFlags
|= wxPG_MAN_FL_PAGE_INSERTED
;
1070 wxASSERT( pageObj
->GetGrid() );
1075 // -----------------------------------------------------------------------
1077 bool wxPropertyGridManager::IsAnyModified() const
1080 for ( i
=0; i
<GetPageCount(); i
++ )
1082 if ( m_arrPages
[i
]->GetStatePtr()->m_anyModified
)
1088 // -----------------------------------------------------------------------
1090 bool wxPropertyGridManager::IsPageModified( size_t index
) const
1092 if ( m_arrPages
[index
]->GetStatePtr()->m_anyModified
)
1097 // -----------------------------------------------------------------------
1099 #if wxUSE_HEADERCTRL
1100 void wxPropertyGridManager::ShowHeader(bool show
)
1102 if ( show
!= m_showHeader
)
1104 m_showHeader
= show
;
1110 // -----------------------------------------------------------------------
1112 #if wxUSE_HEADERCTRL
1113 void wxPropertyGridManager::SetColumnTitle( int idx
, const wxString
& title
)
1115 if ( !m_pHeaderCtrl
)
1118 m_pHeaderCtrl
->SetColumnTitle(idx
, title
);
1122 // -----------------------------------------------------------------------
1124 bool wxPropertyGridManager::IsPropertySelected( wxPGPropArg id
) const
1126 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1127 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1129 if ( GetPageState(i
)->DoIsPropertySelected(p
) )
1135 // -----------------------------------------------------------------------
1137 wxPGProperty
* wxPropertyGridManager::GetPageRoot( int index
) const
1139 wxASSERT( index
>= 0 );
1140 wxASSERT( index
< (int)m_arrPages
.size() );
1142 return m_arrPages
[index
]->GetStatePtr()->m_properties
;
1145 // -----------------------------------------------------------------------
1147 bool wxPropertyGridManager::RemovePage( int page
)
1149 wxCHECK_MSG( (page
>= 0) && (page
< (int)GetPageCount()),
1151 wxT("invalid page index") );
1153 wxPropertyGridPage
* pd
= m_arrPages
[page
];
1155 if ( m_arrPages
.size() == 1 )
1157 // Last page: do not remove page entry
1158 m_pPropGrid
->Clear();
1160 m_iFlags
&= ~wxPG_MAN_FL_PAGE_INSERTED
;
1161 pd
->m_label
.clear();
1164 // Change selection if current is page
1165 else if ( page
== m_selPage
)
1167 if ( !m_pPropGrid
->ClearSelection() )
1170 // Substitute page to select
1171 int substitute
= page
- 1;
1172 if ( substitute
< 0 )
1173 substitute
= page
+ 1;
1175 SelectPage(substitute
);
1178 // Remove toolbar icon
1180 if ( HasFlag(wxPG_TOOLBAR
) )
1182 wxASSERT( m_pToolbar
);
1184 int toolPos
= GetExtraStyle() & wxPG_EX_MODE_BUTTONS
? 3 : 0;
1187 // Delete separator as well, for consistency
1188 if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS
) &&
1189 GetPageCount() == 1 )
1190 m_pToolbar
->DeleteToolByPos(2);
1192 m_pToolbar
->DeleteToolByPos(toolPos
);
1196 if ( m_arrPages
.size() > 1 )
1198 m_arrPages
.erase(m_arrPages
.begin() + page
);
1202 // Adjust indexes that were above removed
1203 if ( m_selPage
> page
)
1209 // -----------------------------------------------------------------------
1211 bool wxPropertyGridManager::ProcessEvent( wxEvent
& event
)
1213 int evtType
= event
.GetEventType();
1215 // NB: For some reason, under wxPython, Connect in Init doesn't work properly,
1216 // so we'll need to call OnPropertyGridSelect manually. Multiple call's
1217 // don't really matter.
1218 if ( evtType
== wxEVT_PG_SELECTED
)
1219 OnPropertyGridSelect((wxPropertyGridEvent
&)event
);
1221 // Property grid events get special attention
1222 if ( evtType
>= wxPG_BASE_EVT_TYPE
&&
1223 evtType
< (wxPG_MAX_EVT_TYPE
) &&
1226 wxPropertyGridPage
* page
= GetPage(m_selPage
);
1227 wxPropertyGridEvent
* pgEvent
= wxDynamicCast(&event
, wxPropertyGridEvent
);
1229 // Add property grid events to appropriate custom pages
1230 // but stop propagating to parent if page says it is
1231 // handling everything.
1232 if ( pgEvent
&& !page
->m_isDefault
)
1234 /*if ( pgEvent->IsPending() )
1235 page->AddPendingEvent(event);
1237 page
->ProcessEvent(event
);
1239 if ( page
->IsHandlingAllEvents() )
1240 event
.StopPropagation();
1244 return wxPanel::ProcessEvent(event
);
1247 // -----------------------------------------------------------------------
1249 void wxPropertyGridManager::RepaintDescBoxDecorations( wxDC
& dc
,
1255 wxColour bgcol
= GetBackgroundColour();
1258 int rectHeight
= m_splitterHeight
;
1259 dc
.DrawRectangle(0, newSplitterY
, newWidth
, rectHeight
);
1260 dc
.SetPen( wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) );
1261 int splitterBottom
= newSplitterY
+ m_splitterHeight
- 1;
1262 int boxHeight
= newHeight
- splitterBottom
;
1263 if ( boxHeight
> 1 )
1264 dc
.DrawRectangle(0, splitterBottom
, newWidth
, boxHeight
);
1266 dc
.DrawLine(0, splitterBottom
, newWidth
, splitterBottom
);
1269 // -----------------------------------------------------------------------
1271 void wxPropertyGridManager::UpdateDescriptionBox( int new_splittery
, int new_width
, int new_height
)
1273 int use_hei
= new_height
;
1276 // Fix help control positions.
1277 int cap_hei
= m_pPropGrid
->m_fontHeight
;
1278 int cap_y
= new_splittery
+m_splitterHeight
+5;
1279 int cnt_y
= cap_y
+cap_hei
+3;
1280 int sub_cap_hei
= cap_y
+cap_hei
-use_hei
;
1281 int cnt_hei
= use_hei
-cnt_y
;
1282 if ( sub_cap_hei
> 0 )
1284 cap_hei
-= sub_cap_hei
;
1289 m_pTxtHelpCaption
->Show( false );
1290 m_pTxtHelpContent
->Show( false );
1294 m_pTxtHelpCaption
->SetSize(3,cap_y
,new_width
-6,cap_hei
);
1295 m_pTxtHelpCaption
->Wrap(-1);
1296 m_pTxtHelpCaption
->Show( true );
1299 m_pTxtHelpContent
->Show( false );
1303 m_pTxtHelpContent
->SetSize(3,cnt_y
,new_width
-6,cnt_hei
);
1304 m_pTxtHelpContent
->Show( true );
1308 wxRect
r(0, new_splittery
, new_width
, new_height
-new_splittery
);
1311 m_splitterY
= new_splittery
;
1313 m_iFlags
&= ~(wxPG_FL_DESC_REFRESH_REQUIRED
);
1316 // -----------------------------------------------------------------------
1318 void wxPropertyGridManager::RecalculatePositions( int width
, int height
)
1321 int propgridBottomY
= height
;
1323 // Toolbar at the top.
1327 m_pToolbar
->SetSize(0, 0, width
, -1);
1328 propgridY
+= m_pToolbar
->GetSize().y
;
1330 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1335 // Header comes after the tool bar
1336 #if wxUSE_HEADERCTRL
1339 m_pHeaderCtrl
->SetSize(0, propgridY
, width
, -1);
1340 propgridY
+= m_pHeaderCtrl
->GetSize().y
;
1345 if ( m_pTxtHelpCaption
)
1347 int new_splittery
= m_splitterY
;
1350 if ( ( m_splitterY
>= 0 || m_nextDescBoxSize
) && m_height
> 32 )
1352 if ( m_nextDescBoxSize
>= 0 )
1354 new_splittery
= m_height
- m_nextDescBoxSize
- m_splitterHeight
;
1355 m_nextDescBoxSize
= -1;
1357 new_splittery
+= (height
-m_height
);
1361 new_splittery
= height
- wxPGMAN_DEFAULT_NEGATIVE_SPLITTER_Y
;
1362 if ( new_splittery
< 32 )
1366 // Check if beyond minimum.
1367 int nspy_min
= propgridY
+ m_pPropGrid
->m_lineHeight
;
1368 if ( new_splittery
< nspy_min
)
1369 new_splittery
= nspy_min
;
1371 propgridBottomY
= new_splittery
;
1373 UpdateDescriptionBox( new_splittery
, width
, height
);
1376 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
1378 int pgh
= propgridBottomY
- propgridY
;
1381 m_pPropGrid
->SetSize( 0, propgridY
, width
, pgh
);
1383 m_extraHeight
= height
- pgh
;
1390 // -----------------------------------------------------------------------
1392 void wxPropertyGridManager::SetDescBoxHeight( int ht
, bool refresh
)
1394 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1396 if ( ht
!= GetDescBoxHeight() )
1398 m_nextDescBoxSize
= ht
;
1400 RecalculatePositions(m_width
, m_height
);
1405 // -----------------------------------------------------------------------
1407 int wxPropertyGridManager::GetDescBoxHeight() const
1409 return GetClientSize().y
- m_splitterY
- m_splitterHeight
;
1412 // -----------------------------------------------------------------------
1414 void wxPropertyGridManager::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1418 // Update everything inside the box
1419 wxRect r
= GetUpdateRegion().GetBox();
1421 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1423 if (m_pToolbar
&& m_pPropGrid
)
1425 wxPen
marginPen(m_pPropGrid
->GetMarginColour());
1426 dc
.SetPen(marginPen
);
1428 int y
= m_pPropGrid
->GetPosition().y
-1;
1429 dc
.DrawLine(0, y
, GetClientSize().x
, y
);
1433 // Repaint splitter and any other description box decorations
1434 if ( (r
.y
+ r
.height
) >= m_splitterY
&& m_splitterY
!= -1)
1435 RepaintDescBoxDecorations( dc
, m_splitterY
, m_width
, m_height
);
1438 // -----------------------------------------------------------------------
1440 void wxPropertyGridManager::Refresh(bool eraseBackground
, const wxRect
* rect
)
1442 m_pPropGrid
->Refresh(eraseBackground
);
1443 wxWindow::Refresh(eraseBackground
,rect
);
1446 // -----------------------------------------------------------------------
1448 void wxPropertyGridManager::RefreshProperty( wxPGProperty
* p
)
1450 wxPropertyGrid
* grid
= p
->GetGrid();
1452 if ( GetPage(m_selPage
)->GetStatePtr() == p
->GetParent()->GetParentState() )
1453 grid
->RefreshProperty(p
);
1456 // -----------------------------------------------------------------------
1458 void wxPropertyGridManager::RecreateControls()
1461 bool was_shown
= IsShown();
1465 wxWindowID baseId
= m_pPropGrid
->GetId();
1467 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
1470 if ( m_windowStyle
& wxPG_TOOLBAR
)
1475 long toolBarFlags
= ((GetExtraStyle()&wxPG_EX_NO_FLAT_TOOLBAR
)?0:wxTB_FLAT
);
1476 if (GetExtraStyle() & wxPG_EX_NO_TOOLBAR_DIVIDER
)
1477 toolBarFlags
|= wxTB_NODIVIDER
;
1479 m_pToolbar
= new wxToolBar(this,baseId
+ID_ADVTOOLBAR_OFFSET
,
1480 wxDefaultPosition
,wxDefaultSize
,
1482 m_pToolbar
->SetToolBitmapSize(wxSize(16, 15));
1484 #if defined(__WXMSW__)
1485 // Eliminate toolbar flicker on XP
1486 // NOTE: Not enabled since it corrupts drawing somewhat.
1489 #ifndef WS_EX_COMPOSITED
1490 #define WS_EX_COMPOSITED 0x02000000L
1493 HWND hWnd = (HWND)m_pToolbar->GetHWND();
1495 ::SetWindowLong( hWnd, GWL_EXSTYLE,
1496 ::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_COMPOSITED );
1501 m_pToolbar
->SetCursor ( *wxSTANDARD_CURSOR
);
1503 if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) )
1505 wxString
desc1(_("Categorized Mode"));
1506 wxString
desc2(_("Alphabetic Mode"));
1507 m_pToolbar
->AddTool(baseId
+ID_ADVTBITEMSBASE_OFFSET
+0,
1508 desc1
,wxBitmap (gs_xpm_catmode
),
1509 desc1
,wxITEM_RADIO
);
1510 m_pToolbar
->AddTool(baseId
+ID_ADVTBITEMSBASE_OFFSET
+1,
1511 desc2
,wxBitmap (gs_xpm_noncatmode
),
1512 desc2
,wxITEM_RADIO
);
1513 m_pToolbar
->Realize();
1518 if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) )
1520 // Toggle correct mode button.
1521 // TODO: This doesn't work in wxMSW (when changing,
1522 // both items will get toggled).
1523 int toggle_but_on_ind
= ID_ADVTBITEMSBASE_OFFSET
+0;
1524 int toggle_but_off_ind
= ID_ADVTBITEMSBASE_OFFSET
+1;
1525 if ( m_pPropGrid
->m_pState
->IsInNonCatMode() )
1527 toggle_but_on_ind
++;
1528 toggle_but_off_ind
--;
1531 m_pToolbar
->ToggleTool(baseId
+toggle_but_on_ind
,true);
1532 m_pToolbar
->ToggleTool(baseId
+toggle_but_off_ind
,false);
1540 m_pToolbar
->Destroy();
1545 #if wxUSE_HEADERCTRL
1550 if ( !m_pHeaderCtrl
)
1552 hc
= new wxPGHeaderCtrl(this);
1553 hc
->Create(this, baseId
+ID_ADVHEADERCTRL_OFFSET
);
1558 m_pHeaderCtrl
->Show();
1561 m_pHeaderCtrl
->OnPageChanged(GetCurrentPage());
1565 if ( m_pHeaderCtrl
)
1566 m_pHeaderCtrl
->Hide();
1570 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1573 m_pPropGrid
->m_iFlags
|= (wxPG_FL_NOSTATUSBARHELP
);
1575 if ( !m_pTxtHelpCaption
)
1577 m_pTxtHelpCaption
= new wxStaticText(this,
1578 baseId
+ID_ADVHELPCAPTION_OFFSET
,
1582 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1583 m_pTxtHelpCaption
->SetFont( m_pPropGrid
->m_captionFont
);
1584 m_pTxtHelpCaption
->SetCursor( *wxSTANDARD_CURSOR
);
1586 if ( !m_pTxtHelpContent
)
1588 m_pTxtHelpContent
= new wxStaticText(this,
1589 baseId
+ID_ADVHELPCONTENT_OFFSET
,
1593 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1594 m_pTxtHelpContent
->SetCursor( *wxSTANDARD_CURSOR
);
1597 SetDescribedProperty(GetSelection());
1602 m_pPropGrid
->m_iFlags
&= ~(wxPG_FL_NOSTATUSBARHELP
);
1604 if ( m_pTxtHelpCaption
)
1605 m_pTxtHelpCaption
->Destroy();
1607 m_pTxtHelpCaption
= NULL
;
1609 if ( m_pTxtHelpContent
)
1610 m_pTxtHelpContent
->Destroy();
1612 m_pTxtHelpContent
= NULL
;
1617 GetClientSize(&width
,&height
);
1619 RecalculatePositions(width
,height
);
1625 // -----------------------------------------------------------------------
1627 wxPGProperty
* wxPropertyGridManager::DoGetPropertyByName( const wxString
& name
) const
1630 for ( i
=0; i
<GetPageCount(); i
++ )
1632 wxPropertyGridPageState
* pState
= m_arrPages
[i
]->GetStatePtr();
1633 wxPGProperty
* p
= pState
->BaseGetPropertyByName(name
);
1642 // -----------------------------------------------------------------------
1644 bool wxPropertyGridManager::EnsureVisible( wxPGPropArg id
)
1646 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1648 wxPropertyGridPageState
* parentState
= p
->GetParentState();
1650 // Select correct page.
1651 if ( m_pPropGrid
->m_pState
!= parentState
)
1652 DoSelectPage( GetPageByState(parentState
) );
1654 return m_pPropGrid
->EnsureVisible(id
);
1657 // -----------------------------------------------------------------------
1659 void wxPropertyGridManager::OnToolbarClick( wxCommandEvent
&event
)
1661 int id
= event
.GetId();
1664 int baseId
= m_pPropGrid
->GetId();
1666 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
1668 if ( id
== ( baseId
+ ID_ADVTBITEMSBASE_OFFSET
+ 0 ) )
1670 // Categorized mode.
1671 if ( m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
)
1673 if ( !m_pPropGrid
->HasInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
) )
1674 m_pPropGrid
->m_windowStyle
&= ~wxPG_AUTO_SORT
;
1675 m_pPropGrid
->EnableCategories( true );
1678 else if ( id
== ( baseId
+ ID_ADVTBITEMSBASE_OFFSET
+ 1 ) )
1681 if ( !(m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
) )
1683 if ( m_pPropGrid
->HasFlag(wxPG_AUTO_SORT
) )
1684 m_pPropGrid
->SetInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1686 m_pPropGrid
->ClearInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1688 m_pPropGrid
->m_windowStyle
|= wxPG_AUTO_SORT
;
1689 m_pPropGrid
->EnableCategories( false );
1698 wxPropertyGridPage
* pdc
;
1700 // Find page with given id.
1701 for ( i
=0; i
<GetPageCount(); i
++ )
1703 pdc
= m_arrPages
[i
];
1704 if ( pdc
->m_id
== id
)
1711 wxASSERT( index
>= 0 );
1713 if ( DoSelectPage( index
) )
1716 // Event dispatching must be last.
1717 m_pPropGrid
->SendEvent( wxEVT_PG_PAGE_CHANGED
, NULL
);
1722 // TODO: Depress the old button on toolbar.
1729 // -----------------------------------------------------------------------
1731 bool wxPropertyGridManager::SetEditableStateItem( const wxString
& name
, wxVariant value
)
1733 if ( name
== wxS("descboxheight") )
1735 SetDescBoxHeight(value
.GetLong(), true);
1741 // -----------------------------------------------------------------------
1743 wxVariant
wxPropertyGridManager::GetEditableStateItem( const wxString
& name
) const
1745 if ( name
== wxS("descboxheight") )
1747 return (long) GetDescBoxHeight();
1749 return wxNullVariant
;
1752 // -----------------------------------------------------------------------
1754 void wxPropertyGridManager::SetDescription( const wxString
& label
, const wxString
& content
)
1756 if ( m_pTxtHelpCaption
)
1758 wxSize osz1
= m_pTxtHelpCaption
->GetSize();
1759 wxSize osz2
= m_pTxtHelpContent
->GetSize();
1761 m_pTxtHelpCaption
->SetLabel(label
);
1762 m_pTxtHelpContent
->SetLabel(content
);
1764 m_pTxtHelpCaption
->SetSize(-1,osz1
.y
);
1765 m_pTxtHelpContent
->SetSize(-1,osz2
.y
);
1767 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1771 // -----------------------------------------------------------------------
1773 void wxPropertyGridManager::SetDescribedProperty( wxPGProperty
* p
)
1775 if ( m_pTxtHelpCaption
)
1779 SetDescription( p
->GetLabel(), p
->GetHelpString() );
1783 SetDescription( wxEmptyString
, wxEmptyString
);
1788 // -----------------------------------------------------------------------
1790 void wxPropertyGridManager::SetSplitterLeft( bool subProps
, bool allPages
)
1794 m_pPropGrid
->SetSplitterLeft(subProps
);
1798 wxClientDC
dc(this);
1799 dc
.SetFont(m_pPropGrid
->GetFont());
1804 for ( i
=0; i
<GetPageCount(); i
++ )
1806 int maxW
= m_pState
->GetColumnFitWidth(dc
, m_arrPages
[i
]->m_properties
, 0, subProps
);
1807 maxW
+= m_pPropGrid
->m_marginWidth
;
1808 if ( maxW
> highest
)
1810 m_pState
->m_dontCenterSplitter
= true;
1814 m_pPropGrid
->SetSplitterPosition( highest
);
1817 #if wxUSE_HEADERCTRL
1819 m_pHeaderCtrl
->OnColumWidthsChanged();
1823 // -----------------------------------------------------------------------
1825 void wxPropertyGridManager::OnPropertyGridSelect( wxPropertyGridEvent
& event
)
1828 wxASSERT_MSG( GetId() == m_pPropGrid
->GetId(),
1829 wxT("wxPropertyGridManager id must be set with wxPropertyGridManager::SetId (not wxWindow::SetId).") );
1831 SetDescribedProperty(event
.GetProperty());
1835 // -----------------------------------------------------------------------
1838 wxPropertyGridManager::OnPGColDrag( wxPropertyGridEvent
& WXUNUSED(event
) )
1840 #if wxUSE_HEADERCTRL
1841 if ( !m_showHeader
)
1844 m_pHeaderCtrl
->OnColumWidthsChanged();
1848 // -----------------------------------------------------------------------
1850 void wxPropertyGridManager::OnResize( wxSizeEvent
& WXUNUSED(event
) )
1854 GetClientSize(&width
, &height
);
1856 if ( m_width
== -12345 )
1859 RecalculatePositions(width
, height
);
1861 if ( m_pPropGrid
&& m_pPropGrid
->m_parent
)
1863 int pgWidth
, pgHeight
;
1864 m_pPropGrid
->GetClientSize(&pgWidth
, &pgHeight
);
1866 // Regenerate splitter positions for non-current pages
1867 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1869 wxPropertyGridPage
* page
= GetPage(i
);
1870 if ( page
!= m_pPropGrid
->GetState() )
1872 page
->OnClientWidthChange(pgWidth
,
1873 pgWidth
- page
->m_width
,
1880 // -----------------------------------------------------------------------
1882 void wxPropertyGridManager::OnMouseEntry( wxMouseEvent
& WXUNUSED(event
) )
1884 // Correct cursor. This is required atleast for wxGTK, for which
1885 // setting button's cursor to *wxSTANDARD_CURSOR does not work.
1886 SetCursor( wxNullCursor
);
1890 // -----------------------------------------------------------------------
1892 void wxPropertyGridManager::OnMouseMove( wxMouseEvent
&event
)
1894 if ( !m_pTxtHelpCaption
)
1899 if ( m_dragStatus
> 0 )
1901 int sy
= y
- m_dragOffset
;
1903 // Calculate drag limits
1904 int bottom_limit
= m_height
- m_splitterHeight
+ 1;
1905 int top_limit
= m_pPropGrid
->m_lineHeight
;
1907 if ( m_pToolbar
) top_limit
+= m_pToolbar
->GetSize().y
;
1910 if ( sy
>= top_limit
&& sy
< bottom_limit
)
1913 int change
= sy
- m_splitterY
;
1918 m_pPropGrid
->SetSize( m_width
, m_splitterY
- m_pPropGrid
->GetPosition().y
);
1919 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1921 m_extraHeight
-= change
;
1922 InvalidateBestSize();
1930 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1932 SetCursor ( m_cursorSizeNS
);
1939 SetCursor ( wxNullCursor
);
1946 // -----------------------------------------------------------------------
1948 void wxPropertyGridManager::OnMouseClick( wxMouseEvent
&event
)
1952 // Click on splitter.
1953 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1955 if ( m_dragStatus
== 0 )
1958 // Begin draggin the splitter
1965 m_dragOffset
= y
- m_splitterY
;
1971 // -----------------------------------------------------------------------
1973 void wxPropertyGridManager::OnMouseUp( wxMouseEvent
&event
)
1975 // No event type check - basicly calling this method should
1976 // just stop dragging.
1978 if ( m_dragStatus
>= 1 )
1981 // End Splitter Dragging
1986 // DO NOT ENABLE FOLLOWING LINE!
1987 // (it is only here as a reminder to not to do it)
1990 // This is necessary to return cursor
1993 // Set back the default cursor, if necessary
1994 if ( y
< m_splitterY
|| y
>= (m_splitterY
+m_splitterHeight
+2) )
1996 SetCursor ( wxNullCursor
);
2003 // -----------------------------------------------------------------------
2005 void wxPropertyGridManager::SetSplitterPosition( int pos
, int splitterColumn
)
2007 wxASSERT_MSG( GetPageCount(),
2008 wxT("SetSplitterPosition() has no effect until pages have been added") );
2011 for ( i
=0; i
<GetPageCount(); i
++ )
2013 wxPropertyGridPage
* page
= GetPage(i
);
2014 page
->DoSetSplitterPosition( pos
, splitterColumn
,
2015 wxPG_SPLITTER_REFRESH
);
2018 #if wxUSE_HEADERCTRL
2020 m_pHeaderCtrl
->OnColumWidthsChanged();
2024 // -----------------------------------------------------------------------
2026 void wxPropertyGridManager::SetPageSplitterPosition( int page
,
2030 GetPage(page
)->DoSetSplitterPosition( pos
, column
);
2032 #if wxUSE_HEADERCTRL
2034 m_pHeaderCtrl
->OnColumWidthsChanged();
2038 // -----------------------------------------------------------------------
2039 // wxPGVIterator_Manager
2040 // -----------------------------------------------------------------------
2042 // Default returned by wxPropertyGridInterface::CreateVIterator().
2043 class wxPGVIteratorBase_Manager
: public wxPGVIteratorBase
2046 wxPGVIteratorBase_Manager( wxPropertyGridManager
* manager
, int flags
)
2047 : m_manager(manager
), m_flags(flags
), m_curPage(0)
2049 m_it
.Init(manager
->GetPage(0), flags
);
2051 virtual ~wxPGVIteratorBase_Manager() { }
2060 if ( m_curPage
< m_manager
->GetPageCount() )
2061 m_it
.Init( m_manager
->GetPage(m_curPage
), m_flags
);
2065 wxPropertyGridManager
* m_manager
;
2067 unsigned int m_curPage
;
2070 wxPGVIterator
wxPropertyGridManager::GetVIterator( int flags
) const
2072 return wxPGVIterator( new wxPGVIteratorBase_Manager( (wxPropertyGridManager
*)this, flags
) );
2075 #endif // wxUSE_PROPGRID