1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/manager.cpp
3 // Purpose: wxPropertyGridManager
4 // Author: Jaakko Salli
7 // Copyright: (c) Jaakko Salli
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
22 #include "wx/object.h"
24 #include "wx/string.h"
27 #include "wx/window.h"
32 #include "wx/cursor.h"
33 #include "wx/settings.h"
34 #include "wx/textctrl.h"
36 #include "wx/statusbr.h"
40 // This define is necessary to prevent macro clearing
41 #define __wxPG_SOURCE_FILE__
43 #include "wx/propgrid/propgrid.h"
45 #include "wx/propgrid/manager.h"
48 #define wxPG_MAN_ALTERNATE_BASE_ID 11249 // Needed for wxID_ANY madnesss
51 // -----------------------------------------------------------------------
53 // For wxMSW cursor consistency, we must do mouse capturing even
54 // when using custom controls
56 #define BEGIN_MOUSE_CAPTURE \
57 if ( !(m_iFlags & wxPG_FL_MOUSE_CAPTURED) ) \
60 m_iFlags |= wxPG_FL_MOUSE_CAPTURED; \
63 #define END_MOUSE_CAPTURE \
64 if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED ) \
67 m_iFlags &= ~(wxPG_FL_MOUSE_CAPTURED); \
70 // -----------------------------------------------------------------------
71 // wxPropertyGridManager
72 // -----------------------------------------------------------------------
74 const char wxPropertyGridManagerNameStr
[] = "wxPropertyGridManager";
77 // Categoric Mode Icon
78 static const char* const gs_xpm_catmode
[] = {
103 // Alphabetic Mode Icon
104 static const char* const gs_xpm_noncatmode
[] = {
129 // Default Page Icon.
130 static const char* const gs_xpm_defpage
[] = {
155 // -----------------------------------------------------------------------
156 // wxPropertyGridPage
157 // -----------------------------------------------------------------------
160 IMPLEMENT_CLASS(wxPropertyGridPage
, wxEvtHandler
)
163 BEGIN_EVENT_TABLE(wxPropertyGridPage
, wxEvtHandler
)
167 wxPropertyGridPage::wxPropertyGridPage()
168 : wxEvtHandler(), wxPropertyGridInterface(), wxPropertyGridPageState()
170 m_pState
= this; // wxPropertyGridInterface to point to State
175 wxPropertyGridPage::~wxPropertyGridPage()
179 void wxPropertyGridPage::Clear()
181 GetStatePtr()->DoClear();
184 wxSize
wxPropertyGridPage::FitColumns()
186 wxSize sz
= DoFitColumns();
190 void wxPropertyGridPage::RefreshProperty( wxPGProperty
* p
)
193 m_manager
->RefreshProperty(p
);
196 void wxPropertyGridPage::OnShow()
200 void wxPropertyGridPage::SetSplitterPosition( int splitterPos
, int col
)
202 wxPropertyGrid
* pg
= GetGrid();
203 if ( pg
->GetState() == this )
204 pg
->SetSplitterPosition(splitterPos
);
206 DoSetSplitterPosition(splitterPos
, col
, false);
209 void wxPropertyGridPage::DoSetSplitterPosition( int pos
,
213 if ( (flags
& wxPG_SPLITTER_ALL_PAGES
) && m_manager
->GetPageCount() )
214 m_manager
->SetSplitterPosition( pos
, splitterColumn
);
216 wxPropertyGridPageState::DoSetSplitterPosition( pos
,
221 // -----------------------------------------------------------------------
223 // -----------------------------------------------------------------------
227 class wxPGHeaderCtrl
: public wxHeaderCtrl
230 wxPGHeaderCtrl(wxPropertyGridManager
* manager
) :
234 EnsureColumnCount(2);
236 // Seed titles with defaults
237 m_columns
[0]->SetTitle(_("Property"));
238 m_columns
[1]->SetTitle(_("Value"));
241 virtual ~wxPGHeaderCtrl()
243 for (unsigned int i
=0; i
<m_columns
.size(); i
++ )
247 int DetermineColumnWidth(unsigned int idx
, int* pMinWidth
) const
249 const wxPropertyGridPage
* page
= m_page
;
250 int colWidth
= page
->GetColumnWidth(idx
);
251 int colMinWidth
= page
->GetColumnMinWidth(idx
);
254 wxPropertyGrid
* pg
= m_manager
->GetGrid();
255 int margin
= pg
->GetMarginWidth();
257 // Compensate for the internal border
258 margin
+= (pg
->GetSize().x
- pg
->GetClientSize().x
) / 2;
261 colMinWidth
+= margin
;
263 *pMinWidth
= colMinWidth
;
267 void OnPageChanged(const wxPropertyGridPage
* page
)
275 // Get column info from the page
276 const wxPropertyGridPage
* page
= m_page
;
277 unsigned int colCount
= page
->GetColumnCount();
278 EnsureColumnCount(colCount
);
280 for ( unsigned int i
=0; i
<colCount
; i
++ )
282 wxHeaderColumnSimple
* colInfo
= m_columns
[i
];
284 int colWidth
= DetermineColumnWidth(i
, &colMinWidth
);
285 colInfo
->SetWidth(colWidth
);
286 colInfo
->SetMinWidth(colMinWidth
);
289 SetColumnCount(colCount
);
292 void OnColumWidthsChanged()
294 const wxPropertyGridPage
* page
= m_page
;
295 unsigned int colCount
= page
->GetColumnCount();
297 for ( unsigned int i
=0; i
<colCount
; i
++ )
299 wxHeaderColumnSimple
* colInfo
= m_columns
[i
];
301 int colWidth
= DetermineColumnWidth(i
, &colMinWidth
);
302 colInfo
->SetWidth(colWidth
);
303 colInfo
->SetMinWidth(colMinWidth
);
308 virtual const wxHeaderColumn
& GetColumn(unsigned int idx
) const
310 return *m_columns
[idx
];
313 void SetColumnTitle(unsigned int idx
, const wxString
& title
)
315 EnsureColumnCount(idx
+1);
316 m_columns
[idx
]->SetTitle(title
);
320 void EnsureColumnCount(unsigned int count
)
322 while ( m_columns
.size() < count
)
324 wxHeaderColumnSimple
* colInfo
= new wxHeaderColumnSimple("");
325 m_columns
.push_back(colInfo
);
329 void OnSetColumnWidth(int col
, int colWidth
)
331 wxPropertyGrid
* pg
= m_manager
->GetGrid();
333 // Compensate for the internal border
334 int x
= -((pg
->GetSize().x
- pg
->GetClientSize().x
) / 2);
336 for ( int i
=0; i
<col
; i
++ )
337 x
+= m_columns
[i
]->GetWidth();
341 pg
->DoSetSplitterPosition(x
, col
,
342 wxPG_SPLITTER_REFRESH
|
343 wxPG_SPLITTER_FROM_EVENT
);
346 virtual bool ProcessEvent( wxEvent
& event
)
348 if ( event
.IsKindOf(wxCLASSINFO(wxHeaderCtrlEvent
)) )
350 wxHeaderCtrlEvent
& hcEvent
=
351 static_cast<wxHeaderCtrlEvent
&>(event
);
353 wxPropertyGrid
* pg
= m_manager
->GetGrid();
354 int col
= hcEvent
.GetColumn();
355 int evtType
= event
.GetEventType();
357 if ( evtType
== wxEVT_HEADER_RESIZING
)
359 int colWidth
= hcEvent
.GetWidth();
361 OnSetColumnWidth(col
, colWidth
);
363 pg
->SendEvent(wxEVT_PG_COL_DRAGGING
,
369 else if ( evtType
== wxEVT_HEADER_BEGIN_RESIZE
)
371 // Never allow column resize if layout is static
372 if ( m_manager
->HasFlag(wxPG_STATIC_SPLITTER
) )
374 // Allow application to veto dragging
375 else if ( pg
->SendEvent(wxEVT_PG_COL_BEGIN_DRAG
,
382 else if ( evtType
== wxEVT_HEADER_END_RESIZE
)
384 pg
->SendEvent(wxEVT_PG_COL_END_DRAG
,
392 return wxHeaderCtrl::ProcessEvent(event
);
395 wxPropertyGridManager
* m_manager
;
396 const wxPropertyGridPage
* m_page
;
397 wxVector
<wxHeaderColumnSimple
*> m_columns
;
400 #endif // wxUSE_HEADERCTRL
402 // -----------------------------------------------------------------------
403 // wxPropertyGridManager
404 // -----------------------------------------------------------------------
406 // Final default splitter y is client height minus this.
407 #define wxPGMAN_DEFAULT_NEGATIVE_SPLITTER_Y 100
409 // -----------------------------------------------------------------------
411 IMPLEMENT_CLASS(wxPropertyGridManager
, wxPanel
)
413 // -----------------------------------------------------------------------
415 BEGIN_EVENT_TABLE(wxPropertyGridManager
, wxPanel
)
416 EVT_MOTION(wxPropertyGridManager::OnMouseMove
)
417 EVT_SIZE(wxPropertyGridManager::OnResize
)
418 EVT_PAINT(wxPropertyGridManager::OnPaint
)
419 EVT_LEFT_DOWN(wxPropertyGridManager::OnMouseClick
)
420 EVT_LEFT_UP(wxPropertyGridManager::OnMouseUp
)
421 EVT_LEAVE_WINDOW(wxPropertyGridManager::OnMouseEntry
)
422 //EVT_ENTER_WINDOW(wxPropertyGridManager::OnMouseEntry)
425 // -----------------------------------------------------------------------
427 wxPropertyGridManager::wxPropertyGridManager()
433 // -----------------------------------------------------------------------
435 wxPropertyGridManager::wxPropertyGridManager( wxWindow
*parent
,
440 const wxString
& name
)
444 Create(parent
,id
,pos
,size
,style
,name
);
447 // -----------------------------------------------------------------------
449 bool wxPropertyGridManager::Create( wxWindow
*parent
,
454 const wxString
& name
)
457 m_pPropGrid
= CreatePropertyGrid();
459 bool res
= wxPanel::Create( parent
, id
, pos
, size
,
460 (style
&0xFFFF0000)|wxWANTS_CHARS
,
464 // FIXME: this changes call ordering so wxPropertyGrid is created
465 // immediately, before SetExtraStyle has a chance to be called. However,
466 // without it, we may get assertions if size is wxDefaultSize.
467 //SetInitialSize(size);
472 // -----------------------------------------------------------------------
475 // Initialize values to defaults
477 void wxPropertyGridManager::Init1()
486 m_pHeaderCtrl
= NULL
;
487 m_showHeader
= false;
489 m_pTxtHelpCaption
= NULL
;
490 m_pTxtHelpContent
= NULL
;
496 m_width
= m_height
= 0;
498 m_splitterHeight
= 5;
500 m_splitterY
= -1; // -1 causes default to be set.
502 m_nextDescBoxSize
= -1;
504 m_categorizedModeToolId
= -1;
505 m_alphabeticModeToolId
= -1;
513 // -----------------------------------------------------------------------
515 // These flags are always used in wxPropertyGrid integrated in wxPropertyGridManager.
516 #define wxPG_MAN_PROPGRID_FORCED_FLAGS ( wxBORDER_THEME | \
517 wxNO_FULL_REPAINT_ON_RESIZE| \
520 // Which flags can be passed to underlying wxPropertyGrid.
521 #define wxPG_MAN_PASS_FLAGS_MASK (0xFFF0|wxTAB_TRAVERSAL)
524 // Initialize after parent etc. set
526 void wxPropertyGridManager::Init2( int style
)
529 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
532 m_windowStyle
|= (style
&0x0000FFFF);
534 wxSize csz
= GetClientSize();
536 m_cursorSizeNS
= wxCursor(wxCURSOR_SIZENS
);
538 // Prepare the first page
539 // NB: But just prepare - you still need to call Add/InsertPage
540 // to actually add properties on it.
541 wxPropertyGridPage
* pd
= new wxPropertyGridPage();
542 pd
->m_isDefault
= true;
543 pd
->m_manager
= this;
544 wxPropertyGridPageState
* state
= pd
->GetStatePtr();
545 state
->m_pPropGrid
= m_pPropGrid
;
546 m_arrPages
.push_back( pd
);
547 m_pPropGrid
->m_pState
= state
;
549 wxWindowID baseId
= GetId();
550 wxWindowID useId
= baseId
;
552 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
555 // Smaller controls on Mac
556 SetWindowVariant(wxWINDOW_VARIANT_SMALL
);
559 long propGridFlags
= (m_windowStyle
&wxPG_MAN_PASS_FLAGS_MASK
)
560 |wxPG_MAN_PROPGRID_FORCED_FLAGS
;
562 propGridFlags
&= ~wxBORDER_MASK
;
564 if ((style
& wxPG_NO_INTERNAL_BORDER
) == 0)
566 propGridFlags
|= wxBORDER_THEME
;
570 propGridFlags
|= wxBORDER_NONE
;
571 wxWindow::SetExtraStyle(wxPG_EX_TOOLBAR_SEPARATOR
);
574 // Create propertygrid.
575 m_pPropGrid
->Create(this,baseId
,wxPoint(0,0),csz
, propGridFlags
);
577 m_pPropGrid
->m_eventObject
= this;
579 m_pPropGrid
->SetId(useId
);
581 m_pPropGrid
->m_iFlags
|= wxPG_FL_IN_MANAGER
;
583 m_pState
= m_pPropGrid
->m_pState
;
585 m_pPropGrid
->SetExtraStyle(wxPG_EX_INIT_NOCAT
);
587 // Connect to property grid onselect event.
588 // NB: Even if wxID_ANY is used, this doesn't connect properly in wxPython
589 // (see wxPropertyGridManager::ProcessEvent).
590 Connect(m_pPropGrid
->GetId(),
592 wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect
));
594 Connect(m_pPropGrid
->GetId(),
595 wxEVT_PG_COL_DRAGGING
,
596 wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag
));
598 // Optional initial controls.
601 m_iFlags
|= wxPG_FL_INITIALIZED
;
605 // -----------------------------------------------------------------------
607 wxPropertyGridManager::~wxPropertyGridManager()
611 //m_pPropGrid->ClearSelection();
612 wxDELETE(m_pPropGrid
);
615 for ( i
=0; i
<m_arrPages
.size(); i
++ )
617 delete m_arrPages
[i
];
623 // -----------------------------------------------------------------------
625 wxPropertyGrid
* wxPropertyGridManager::CreatePropertyGrid() const
627 return new wxPropertyGrid();
630 // -----------------------------------------------------------------------
632 void wxPropertyGridManager::SetId( wxWindowID winid
)
634 wxWindow::SetId(winid
);
636 // TODO: Reconnect propgrid event handler(s).
638 m_pPropGrid
->SetId(winid
);
641 // -----------------------------------------------------------------------
643 wxSize
wxPropertyGridManager::DoGetBestSize() const
645 return wxSize(60,150);
648 // -----------------------------------------------------------------------
650 bool wxPropertyGridManager::SetFont( const wxFont
& font
)
652 bool res
= wxWindow::SetFont(font
);
653 m_pPropGrid
->SetFont(font
);
655 // TODO: Need to do caption recacalculations for other pages as well.
657 for ( i
=0; i
<m_arrPages
.size(); i
++ )
659 wxPropertyGridPage
* page
= GetPage(i
);
661 if ( page
!= m_pPropGrid
->GetState() )
662 page
->CalculateFontAndBitmapStuff(-1);
668 // -----------------------------------------------------------------------
670 void wxPropertyGridManager::SetExtraStyle( long exStyle
)
672 wxWindow::SetExtraStyle( exStyle
);
673 m_pPropGrid
->SetExtraStyle( exStyle
& 0xFFFFF000 );
675 if ( (exStyle
& wxPG_EX_NO_FLAT_TOOLBAR
) && m_pToolbar
)
680 // -----------------------------------------------------------------------
682 void wxPropertyGridManager::Freeze()
684 m_pPropGrid
->Freeze();
688 // -----------------------------------------------------------------------
690 void wxPropertyGridManager::Thaw()
696 // -----------------------------------------------------------------------
698 void wxPropertyGridManager::SetWindowStyleFlag( long style
)
700 int oldWindowStyle
= GetWindowStyleFlag();
702 wxWindow::SetWindowStyleFlag( style
);
703 m_pPropGrid
->SetWindowStyleFlag( (m_pPropGrid
->GetWindowStyleFlag()&~(wxPG_MAN_PASS_FLAGS_MASK
)) |
704 (style
&wxPG_MAN_PASS_FLAGS_MASK
) );
706 // Need to re-position windows?
707 if ( (oldWindowStyle
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) !=
708 (style
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) )
714 // -----------------------------------------------------------------------
716 bool wxPropertyGridManager::Reparent( wxWindowBase
*newParent
)
719 m_pPropGrid
->OnTLPChanging((wxWindow
*)newParent
);
721 bool res
= wxPanel::Reparent(newParent
);
726 // -----------------------------------------------------------------------
728 // Actually shows given page.
729 bool wxPropertyGridManager::DoSelectPage( int index
)
731 // -1 means no page was selected
732 //wxASSERT( m_selPage >= 0 );
734 wxCHECK_MSG( index
>= -1 && index
< (int)GetPageCount(),
736 wxT("invalid page index") );
738 if ( m_selPage
== index
)
741 if ( m_pPropGrid
->GetSelection() )
743 if ( !m_pPropGrid
->ClearSelection() )
748 wxPropertyGridPage
* prevPage
;
750 if ( m_selPage
>= 0 )
751 prevPage
= GetPage(m_selPage
);
753 prevPage
= m_emptyPage
;
756 wxPropertyGridPage
* nextPage
;
760 nextPage
= m_arrPages
[index
];
768 m_emptyPage
= new wxPropertyGridPage();
769 m_emptyPage
->m_pPropGrid
= m_pPropGrid
;
772 nextPage
= m_emptyPage
;
775 m_iFlags
|= wxPG_FL_DESC_REFRESH_REQUIRED
;
777 m_pPropGrid
->SwitchState( nextPage
->GetStatePtr() );
779 m_pState
= m_pPropGrid
->m_pState
;
787 m_pToolbar
->ToggleTool( nextPage
->m_toolId
, true );
789 m_pToolbar
->ToggleTool( prevPage
->m_toolId
, false );
795 m_pHeaderCtrl
->OnPageChanged(nextPage
);
801 // -----------------------------------------------------------------------
803 // Changes page *and* set the target page for insertion operations.
804 void wxPropertyGridManager::SelectPage( int index
)
809 // -----------------------------------------------------------------------
811 int wxPropertyGridManager::GetPageByName( const wxString
& name
) const
814 for ( i
=0; i
<GetPageCount(); i
++ )
816 if ( m_arrPages
[i
]->m_label
== name
)
822 // -----------------------------------------------------------------------
824 int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState
* pState
) const
829 for ( i
=0; i
<GetPageCount(); i
++ )
831 if ( pState
== m_arrPages
[i
]->GetStatePtr() )
838 // -----------------------------------------------------------------------
840 const wxString
& wxPropertyGridManager::GetPageName( int index
) const
842 wxASSERT( index
>= 0 && index
< (int)GetPageCount() );
843 return m_arrPages
[index
]->m_label
;
846 // -----------------------------------------------------------------------
848 wxPropertyGridPageState
* wxPropertyGridManager::GetPageState( int page
) const
850 // Do not change this into wxCHECK because returning NULL is important
851 // for wxPropertyGridInterface page enumeration mechanics.
852 if ( page
>= (int)GetPageCount() )
857 return m_arrPages
[page
];
860 // -----------------------------------------------------------------------
862 void wxPropertyGridManager::Clear()
864 m_pPropGrid
->ClearSelection(false);
866 m_pPropGrid
->Freeze();
869 for ( i
=(int)GetPageCount()-1; i
>=0; i
-- )
875 // -----------------------------------------------------------------------
877 void wxPropertyGridManager::ClearPage( int page
)
879 wxASSERT( page
>= 0 );
880 wxASSERT( page
< (int)GetPageCount() );
882 if ( page
>= 0 && page
< (int)GetPageCount() )
884 wxPropertyGridPageState
* state
= m_arrPages
[page
];
886 if ( state
== m_pPropGrid
->GetState() )
887 m_pPropGrid
->Clear();
893 // -----------------------------------------------------------------------
895 int wxPropertyGridManager::GetColumnCount( int page
) const
897 wxASSERT( page
>= -1 );
898 wxASSERT( page
< (int)GetPageCount() );
900 return GetPageState(page
)->GetColumnCount();
903 // -----------------------------------------------------------------------
905 void wxPropertyGridManager::SetColumnCount( int colCount
, int page
)
907 wxASSERT( page
>= -1 );
908 wxASSERT( page
< (int)GetPageCount() );
910 GetPageState(page
)->SetColumnCount( colCount
);
911 GetGrid()->Refresh();
915 m_pHeaderCtrl
->OnPageUpdated();
918 // -----------------------------------------------------------------------
920 size_t wxPropertyGridManager::GetPageCount() const
922 if ( !(m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
) )
925 return m_arrPages
.size();
928 // -----------------------------------------------------------------------
930 wxPropertyGridPage
* wxPropertyGridManager::InsertPage( int index
,
931 const wxString
& label
,
933 wxPropertyGridPage
* pageObj
)
936 index
= GetPageCount();
938 wxCHECK_MSG( (size_t)index
== GetPageCount(), NULL
,
939 wxT("wxPropertyGridManager currently only supports appending pages (due to wxToolBar limitation)."));
941 bool needInit
= true;
942 bool isPageInserted
= m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
? true : false;
944 wxASSERT( index
== 0 || isPageInserted
);
948 // No custom page object was given, so we will either re-use the default base
949 // page (if index==0), or create a new default page object.
950 if ( !isPageInserted
)
952 pageObj
= GetPage(0);
953 // Of course, if the base page was custom, we need to delete and
955 if ( !pageObj
->m_isDefault
)
958 pageObj
= new wxPropertyGridPage();
959 m_arrPages
[0] = pageObj
;
965 pageObj
= new wxPropertyGridPage();
967 pageObj
->m_isDefault
= true;
971 if ( !isPageInserted
)
973 // Initial page needs to be deleted and replaced
975 m_arrPages
[0] = pageObj
;
976 m_pPropGrid
->m_pState
= pageObj
->GetStatePtr();
980 wxPropertyGridPageState
* state
= pageObj
->GetStatePtr();
982 pageObj
->m_manager
= this;
986 state
->m_pPropGrid
= m_pPropGrid
;
987 state
->InitNonCatMode();
990 if ( !label
.empty() )
992 wxASSERT_MSG( !pageObj
->m_label
.length(),
993 wxT("If page label is given in constructor, empty label must be given in AddPage"));
994 pageObj
->m_label
= label
;
997 pageObj
->m_toolId
= -1;
999 if ( !HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
1000 pageObj
->m_dontCenterSplitter
= true;
1002 if ( isPageInserted
)
1003 m_arrPages
.push_back( pageObj
);
1006 if ( m_windowStyle
& wxPG_TOOLBAR
)
1011 if ( !(GetExtraStyle()&wxPG_EX_HIDE_PAGE_BUTTONS
) )
1013 wxASSERT( m_pToolbar
);
1015 // Add separator before first page.
1016 if ( GetPageCount() < 2 && (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) &&
1017 m_pToolbar
->GetToolsCount() < 3 )
1018 m_pToolbar
->AddSeparator();
1020 wxToolBarToolBase
* tool
;
1022 if ( &bmp
!= &wxNullBitmap
)
1023 tool
= m_pToolbar
->AddTool(wxID_ANY
, label
, bmp
,
1024 label
, wxITEM_RADIO
);
1026 tool
= m_pToolbar
->AddTool(wxID_ANY
, label
,
1027 wxBitmap(gs_xpm_defpage
),
1028 label
, wxITEM_RADIO
);
1030 pageObj
->m_toolId
= tool
->GetId();
1032 // Connect to toolbar button events.
1033 Connect(pageObj
->m_toolId
,
1035 wxCommandEventHandler(
1036 wxPropertyGridManager::OnToolbarClick
));
1038 m_pToolbar
->Realize();
1045 // If selected page was above the point of insertion, fix the current page index
1046 if ( isPageInserted
)
1048 if ( m_selPage
>= index
)
1055 // Set this value only when adding the first page
1061 m_iFlags
|= wxPG_MAN_FL_PAGE_INSERTED
;
1063 wxASSERT( pageObj
->GetGrid() );
1068 // -----------------------------------------------------------------------
1070 bool wxPropertyGridManager::IsAnyModified() const
1073 for ( i
=0; i
<GetPageCount(); i
++ )
1075 if ( m_arrPages
[i
]->GetStatePtr()->m_anyModified
)
1081 // -----------------------------------------------------------------------
1083 bool wxPropertyGridManager::IsPageModified( size_t index
) const
1085 if ( m_arrPages
[index
]->GetStatePtr()->m_anyModified
)
1090 // -----------------------------------------------------------------------
1092 #if wxUSE_HEADERCTRL
1093 void wxPropertyGridManager::ShowHeader(bool show
)
1095 if ( show
!= m_showHeader
)
1097 m_showHeader
= show
;
1103 // -----------------------------------------------------------------------
1105 #if wxUSE_HEADERCTRL
1106 void wxPropertyGridManager::SetColumnTitle( int idx
, const wxString
& title
)
1108 if ( !m_pHeaderCtrl
)
1111 m_pHeaderCtrl
->SetColumnTitle(idx
, title
);
1115 // -----------------------------------------------------------------------
1117 bool wxPropertyGridManager::IsPropertySelected( wxPGPropArg id
) const
1119 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1120 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1122 if ( GetPageState(i
)->DoIsPropertySelected(p
) )
1128 // -----------------------------------------------------------------------
1130 wxPGProperty
* wxPropertyGridManager::GetPageRoot( int index
) const
1132 wxASSERT( index
>= 0 );
1133 wxASSERT( index
< (int)m_arrPages
.size() );
1135 return m_arrPages
[index
]->GetStatePtr()->m_properties
;
1138 // -----------------------------------------------------------------------
1140 bool wxPropertyGridManager::RemovePage( int page
)
1142 wxCHECK_MSG( (page
>= 0) && (page
< (int)GetPageCount()),
1144 wxT("invalid page index") );
1146 wxPropertyGridPage
* pd
= m_arrPages
[page
];
1148 if ( m_arrPages
.size() == 1 )
1150 // Last page: do not remove page entry
1151 m_pPropGrid
->Clear();
1153 m_iFlags
&= ~wxPG_MAN_FL_PAGE_INSERTED
;
1154 pd
->m_label
.clear();
1157 // Change selection if current is page
1158 else if ( page
== m_selPage
)
1160 if ( !m_pPropGrid
->ClearSelection() )
1163 // Substitute page to select
1164 int substitute
= page
- 1;
1165 if ( substitute
< 0 )
1166 substitute
= page
+ 1;
1168 SelectPage(substitute
);
1171 // Remove toolbar icon
1173 if ( HasFlag(wxPG_TOOLBAR
) )
1175 wxASSERT( m_pToolbar
);
1177 int toolPos
= GetExtraStyle() & wxPG_EX_MODE_BUTTONS
? 3 : 0;
1180 // Delete separator as well, for consistency
1181 if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS
) &&
1182 GetPageCount() == 1 )
1183 m_pToolbar
->DeleteToolByPos(2);
1185 m_pToolbar
->DeleteToolByPos(toolPos
);
1189 if ( m_arrPages
.size() > 1 )
1191 m_arrPages
.erase(m_arrPages
.begin() + page
);
1195 // Adjust indexes that were above removed
1196 if ( m_selPage
> page
)
1202 // -----------------------------------------------------------------------
1204 bool wxPropertyGridManager::ProcessEvent( wxEvent
& event
)
1206 int evtType
= event
.GetEventType();
1208 // NB: For some reason, under wxPython, Connect in Init doesn't work properly,
1209 // so we'll need to call OnPropertyGridSelect manually. Multiple call's
1210 // don't really matter.
1211 if ( evtType
== wxEVT_PG_SELECTED
)
1212 OnPropertyGridSelect((wxPropertyGridEvent
&)event
);
1214 // Property grid events get special attention
1215 if ( evtType
>= wxPG_BASE_EVT_TYPE
&&
1216 evtType
< (wxPG_MAX_EVT_TYPE
) &&
1219 wxPropertyGridPage
* page
= GetPage(m_selPage
);
1220 wxPropertyGridEvent
* pgEvent
= wxDynamicCast(&event
, wxPropertyGridEvent
);
1222 // Add property grid events to appropriate custom pages
1223 // but stop propagating to parent if page says it is
1224 // handling everything.
1225 if ( pgEvent
&& !page
->m_isDefault
)
1227 /*if ( pgEvent->IsPending() )
1228 page->AddPendingEvent(event);
1230 page
->ProcessEvent(event
);
1232 if ( page
->IsHandlingAllEvents() )
1233 event
.StopPropagation();
1237 return wxPanel::ProcessEvent(event
);
1240 // -----------------------------------------------------------------------
1242 void wxPropertyGridManager::RepaintDescBoxDecorations( wxDC
& dc
,
1248 wxColour bgcol
= GetBackgroundColour();
1251 int rectHeight
= m_splitterHeight
;
1252 dc
.DrawRectangle(0, newSplitterY
, newWidth
, rectHeight
);
1253 dc
.SetPen( wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) );
1254 int splitterBottom
= newSplitterY
+ m_splitterHeight
- 1;
1255 int boxHeight
= newHeight
- splitterBottom
;
1256 if ( boxHeight
> 1 )
1257 dc
.DrawRectangle(0, splitterBottom
, newWidth
, boxHeight
);
1259 dc
.DrawLine(0, splitterBottom
, newWidth
, splitterBottom
);
1262 // -----------------------------------------------------------------------
1264 void wxPropertyGridManager::UpdateDescriptionBox( int new_splittery
, int new_width
, int new_height
)
1266 int use_hei
= new_height
;
1269 // Fix help control positions.
1270 int cap_hei
= m_pPropGrid
->m_fontHeight
;
1271 int cap_y
= new_splittery
+m_splitterHeight
+5;
1272 int cnt_y
= cap_y
+cap_hei
+3;
1273 int sub_cap_hei
= cap_y
+cap_hei
-use_hei
;
1274 int cnt_hei
= use_hei
-cnt_y
;
1275 if ( sub_cap_hei
> 0 )
1277 cap_hei
-= sub_cap_hei
;
1282 m_pTxtHelpCaption
->Show( false );
1283 m_pTxtHelpContent
->Show( false );
1287 m_pTxtHelpCaption
->SetSize(3,cap_y
,new_width
-6,cap_hei
);
1288 m_pTxtHelpCaption
->Wrap(-1);
1289 m_pTxtHelpCaption
->Show( true );
1292 m_pTxtHelpContent
->Show( false );
1296 m_pTxtHelpContent
->SetSize(3,cnt_y
,new_width
-6,cnt_hei
);
1297 m_pTxtHelpContent
->Show( true );
1301 wxRect
r(0, new_splittery
, new_width
, new_height
-new_splittery
);
1304 m_splitterY
= new_splittery
;
1306 m_iFlags
&= ~(wxPG_FL_DESC_REFRESH_REQUIRED
);
1309 // -----------------------------------------------------------------------
1311 void wxPropertyGridManager::RecalculatePositions( int width
, int height
)
1314 int propgridBottomY
= height
;
1316 // Toolbar at the top.
1320 m_pToolbar
->SetSize(0, 0, width
, -1);
1321 propgridY
+= m_pToolbar
->GetSize().y
;
1323 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1328 // Header comes after the tool bar
1329 #if wxUSE_HEADERCTRL
1332 m_pHeaderCtrl
->SetSize(0, propgridY
, width
, -1);
1333 propgridY
+= m_pHeaderCtrl
->GetSize().y
;
1338 if ( m_pTxtHelpCaption
)
1340 int new_splittery
= m_splitterY
;
1343 if ( ( m_splitterY
>= 0 || m_nextDescBoxSize
) && m_height
> 32 )
1345 if ( m_nextDescBoxSize
>= 0 )
1347 new_splittery
= m_height
- m_nextDescBoxSize
- m_splitterHeight
;
1348 m_nextDescBoxSize
= -1;
1350 new_splittery
+= (height
-m_height
);
1354 new_splittery
= height
- wxPGMAN_DEFAULT_NEGATIVE_SPLITTER_Y
;
1355 if ( new_splittery
< 32 )
1359 // Check if beyond minimum.
1360 int nspy_min
= propgridY
+ m_pPropGrid
->m_lineHeight
;
1361 if ( new_splittery
< nspy_min
)
1362 new_splittery
= nspy_min
;
1364 propgridBottomY
= new_splittery
;
1366 UpdateDescriptionBox( new_splittery
, width
, height
);
1369 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
1371 int pgh
= propgridBottomY
- propgridY
;
1374 m_pPropGrid
->SetSize( 0, propgridY
, width
, pgh
);
1376 m_extraHeight
= height
- pgh
;
1383 // -----------------------------------------------------------------------
1385 void wxPropertyGridManager::SetDescBoxHeight( int ht
, bool refresh
)
1387 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1389 if ( ht
!= GetDescBoxHeight() )
1391 m_nextDescBoxSize
= ht
;
1393 RecalculatePositions(m_width
, m_height
);
1398 // -----------------------------------------------------------------------
1400 int wxPropertyGridManager::GetDescBoxHeight() const
1402 return GetClientSize().y
- m_splitterY
- m_splitterHeight
;
1405 // -----------------------------------------------------------------------
1407 void wxPropertyGridManager::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1411 // Update everything inside the box
1412 wxRect r
= GetUpdateRegion().GetBox();
1414 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1416 if (m_pToolbar
&& m_pPropGrid
)
1418 wxPen
marginPen(m_pPropGrid
->GetMarginColour());
1419 dc
.SetPen(marginPen
);
1421 int y
= m_pPropGrid
->GetPosition().y
-1;
1422 dc
.DrawLine(0, y
, GetClientSize().x
, y
);
1426 // Repaint splitter and any other description box decorations
1427 if ( (r
.y
+ r
.height
) >= m_splitterY
&& m_splitterY
!= -1)
1428 RepaintDescBoxDecorations( dc
, m_splitterY
, m_width
, m_height
);
1431 // -----------------------------------------------------------------------
1433 void wxPropertyGridManager::Refresh(bool eraseBackground
, const wxRect
* rect
)
1435 m_pPropGrid
->Refresh(eraseBackground
);
1436 wxWindow::Refresh(eraseBackground
,rect
);
1439 // -----------------------------------------------------------------------
1441 void wxPropertyGridManager::RefreshProperty( wxPGProperty
* p
)
1443 wxPropertyGrid
* grid
= p
->GetGrid();
1445 if ( GetPage(m_selPage
)->GetStatePtr() == p
->GetParent()->GetParentState() )
1446 grid
->RefreshProperty(p
);
1449 // -----------------------------------------------------------------------
1451 void wxPropertyGridManager::RecreateControls()
1454 bool was_shown
= IsShown();
1459 if ( m_windowStyle
& wxPG_TOOLBAR
)
1464 long toolBarFlags
= ((GetExtraStyle()&wxPG_EX_NO_FLAT_TOOLBAR
)?0:wxTB_FLAT
);
1465 if (GetExtraStyle() & wxPG_EX_NO_TOOLBAR_DIVIDER
)
1466 toolBarFlags
|= wxTB_NODIVIDER
;
1468 m_pToolbar
= new wxToolBar(this, wxID_ANY
,
1472 m_pToolbar
->SetToolBitmapSize(wxSize(16, 15));
1474 #if defined(__WXMSW__)
1475 // Eliminate toolbar flicker on XP
1476 // NOTE: Not enabled since it corrupts drawing somewhat.
1479 #ifndef WS_EX_COMPOSITED
1480 #define WS_EX_COMPOSITED 0x02000000L
1483 HWND hWnd = (HWND)m_pToolbar->GetHWND();
1485 ::SetWindowLong( hWnd, GWL_EXSTYLE,
1486 ::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_COMPOSITED );
1491 m_pToolbar
->SetCursor ( *wxSTANDARD_CURSOR
);
1493 if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) )
1495 wxString
desc1(_("Categorized Mode"));
1496 wxString
desc2(_("Alphabetic Mode"));
1498 wxToolBarToolBase
* tool
;
1500 tool
= m_pToolbar
->AddTool(wxID_ANY
,
1502 wxBitmap(gs_xpm_catmode
),
1505 m_categorizedModeToolId
= tool
->GetId();
1507 tool
= m_pToolbar
->AddTool(wxID_ANY
,
1509 wxBitmap(gs_xpm_noncatmode
),
1512 m_alphabeticModeToolId
= tool
->GetId();
1514 m_pToolbar
->Realize();
1516 Connect(m_categorizedModeToolId
,
1518 wxCommandEventHandler(
1519 wxPropertyGridManager::OnToolbarClick
));
1520 Connect(m_alphabeticModeToolId
,
1522 wxCommandEventHandler(
1523 wxPropertyGridManager::OnToolbarClick
));
1527 m_categorizedModeToolId
= -1;
1528 m_alphabeticModeToolId
= -1;
1533 if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS
) )
1535 // Toggle correct mode button.
1536 // TODO: This doesn't work in wxMSW (when changing,
1537 // both items will get toggled).
1538 int toggle_but_on_ind
;
1539 int toggle_but_off_ind
;
1540 if ( m_pPropGrid
->m_pState
->IsInNonCatMode() )
1542 toggle_but_on_ind
= m_alphabeticModeToolId
;
1543 toggle_but_off_ind
= m_categorizedModeToolId
;
1547 toggle_but_on_ind
= m_categorizedModeToolId
;
1548 toggle_but_off_ind
= m_alphabeticModeToolId
;
1551 m_pToolbar
->ToggleTool(toggle_but_on_ind
, true);
1552 m_pToolbar
->ToggleTool(toggle_but_off_ind
, false);
1560 m_pToolbar
->Destroy();
1565 #if wxUSE_HEADERCTRL
1570 if ( !m_pHeaderCtrl
)
1572 hc
= new wxPGHeaderCtrl(this);
1573 hc
->Create(this, wxID_ANY
);
1578 m_pHeaderCtrl
->Show();
1581 m_pHeaderCtrl
->OnPageChanged(GetCurrentPage());
1585 if ( m_pHeaderCtrl
)
1586 m_pHeaderCtrl
->Hide();
1590 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1593 m_pPropGrid
->m_iFlags
|= (wxPG_FL_NOSTATUSBARHELP
);
1595 if ( !m_pTxtHelpCaption
)
1597 m_pTxtHelpCaption
= new wxStaticText(this,
1602 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1603 m_pTxtHelpCaption
->SetFont( m_pPropGrid
->m_captionFont
);
1604 m_pTxtHelpCaption
->SetCursor( *wxSTANDARD_CURSOR
);
1606 if ( !m_pTxtHelpContent
)
1608 m_pTxtHelpContent
= new wxStaticText(this,
1613 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1614 m_pTxtHelpContent
->SetCursor( *wxSTANDARD_CURSOR
);
1617 SetDescribedProperty(GetSelection());
1622 m_pPropGrid
->m_iFlags
&= ~(wxPG_FL_NOSTATUSBARHELP
);
1624 if ( m_pTxtHelpCaption
)
1625 m_pTxtHelpCaption
->Destroy();
1627 m_pTxtHelpCaption
= NULL
;
1629 if ( m_pTxtHelpContent
)
1630 m_pTxtHelpContent
->Destroy();
1632 m_pTxtHelpContent
= NULL
;
1637 GetClientSize(&width
,&height
);
1639 RecalculatePositions(width
,height
);
1645 // -----------------------------------------------------------------------
1647 wxPGProperty
* wxPropertyGridManager::DoGetPropertyByName( const wxString
& name
) const
1650 for ( i
=0; i
<GetPageCount(); i
++ )
1652 wxPropertyGridPageState
* pState
= m_arrPages
[i
]->GetStatePtr();
1653 wxPGProperty
* p
= pState
->BaseGetPropertyByName(name
);
1662 // -----------------------------------------------------------------------
1664 bool wxPropertyGridManager::EnsureVisible( wxPGPropArg id
)
1666 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1668 wxPropertyGridPageState
* parentState
= p
->GetParentState();
1670 // Select correct page.
1671 if ( m_pPropGrid
->m_pState
!= parentState
)
1672 DoSelectPage( GetPageByState(parentState
) );
1674 return m_pPropGrid
->EnsureVisible(id
);
1677 // -----------------------------------------------------------------------
1679 void wxPropertyGridManager::OnToolbarClick( wxCommandEvent
&event
)
1681 int id
= event
.GetId();
1683 if ( id
== m_categorizedModeToolId
)
1685 // Categorized mode.
1686 if ( m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
)
1688 if ( !m_pPropGrid
->HasInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
) )
1689 m_pPropGrid
->m_windowStyle
&= ~wxPG_AUTO_SORT
;
1690 m_pPropGrid
->EnableCategories( true );
1693 else if ( id
== m_alphabeticModeToolId
)
1696 if ( !(m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
) )
1698 if ( m_pPropGrid
->HasFlag(wxPG_AUTO_SORT
) )
1699 m_pPropGrid
->SetInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1701 m_pPropGrid
->ClearInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1703 m_pPropGrid
->m_windowStyle
|= wxPG_AUTO_SORT
;
1704 m_pPropGrid
->EnableCategories( false );
1713 wxPropertyGridPage
* pdc
;
1715 // Find page with given id.
1716 for ( i
=0; i
<GetPageCount(); i
++ )
1718 pdc
= m_arrPages
[i
];
1719 if ( pdc
->m_toolId
== id
)
1726 wxASSERT( index
>= 0 );
1728 if ( DoSelectPage( index
) )
1730 // Event dispatching must be last.
1731 m_pPropGrid
->SendEvent( wxEVT_PG_PAGE_CHANGED
, NULL
);
1735 // TODO: Depress the old button on toolbar.
1740 // -----------------------------------------------------------------------
1742 bool wxPropertyGridManager::SetEditableStateItem( const wxString
& name
, wxVariant value
)
1744 if ( name
== wxS("descboxheight") )
1746 SetDescBoxHeight(value
.GetLong(), true);
1752 // -----------------------------------------------------------------------
1754 wxVariant
wxPropertyGridManager::GetEditableStateItem( const wxString
& name
) const
1756 if ( name
== wxS("descboxheight") )
1758 return (long) GetDescBoxHeight();
1760 return wxNullVariant
;
1763 // -----------------------------------------------------------------------
1765 void wxPropertyGridManager::SetDescription( const wxString
& label
, const wxString
& content
)
1767 if ( m_pTxtHelpCaption
)
1769 wxSize osz1
= m_pTxtHelpCaption
->GetSize();
1770 wxSize osz2
= m_pTxtHelpContent
->GetSize();
1772 m_pTxtHelpCaption
->SetLabel(label
);
1773 m_pTxtHelpContent
->SetLabel(content
);
1775 m_pTxtHelpCaption
->SetSize(-1,osz1
.y
);
1776 m_pTxtHelpContent
->SetSize(-1,osz2
.y
);
1778 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1782 // -----------------------------------------------------------------------
1784 void wxPropertyGridManager::SetDescribedProperty( wxPGProperty
* p
)
1786 if ( m_pTxtHelpCaption
)
1790 SetDescription( p
->GetLabel(), p
->GetHelpString() );
1794 SetDescription( wxEmptyString
, wxEmptyString
);
1799 // -----------------------------------------------------------------------
1801 void wxPropertyGridManager::SetSplitterLeft( bool subProps
, bool allPages
)
1805 m_pPropGrid
->SetSplitterLeft(subProps
);
1809 wxClientDC
dc(this);
1810 dc
.SetFont(m_pPropGrid
->GetFont());
1815 for ( i
=0; i
<GetPageCount(); i
++ )
1817 int maxW
= m_pState
->GetColumnFitWidth(dc
, m_arrPages
[i
]->m_properties
, 0, subProps
);
1818 maxW
+= m_pPropGrid
->m_marginWidth
;
1819 if ( maxW
> highest
)
1821 m_pState
->m_dontCenterSplitter
= true;
1825 SetSplitterPosition( highest
);
1828 #if wxUSE_HEADERCTRL
1830 m_pHeaderCtrl
->OnColumWidthsChanged();
1834 void wxPropertyGridManager::SetPageSplitterLeft(int page
, bool subProps
)
1836 wxASSERT_MSG( (page
< (int) GetPageCount()),
1837 wxT("SetPageSplitterLeft() has no effect until pages have been added") );
1839 if (page
< (int) GetPageCount())
1841 wxClientDC
dc(this);
1842 dc
.SetFont(m_pPropGrid
->GetFont());
1844 int maxW
= m_pState
->GetColumnFitWidth(dc
, m_arrPages
[page
]->m_properties
, 0, subProps
);
1845 maxW
+= m_pPropGrid
->m_marginWidth
;
1846 SetPageSplitterPosition( page
, maxW
);
1848 #if wxUSE_HEADERCTRL
1850 m_pHeaderCtrl
->OnColumWidthsChanged();
1855 // -----------------------------------------------------------------------
1857 void wxPropertyGridManager::OnPropertyGridSelect( wxPropertyGridEvent
& event
)
1860 wxASSERT_MSG( GetId() == m_pPropGrid
->GetId(),
1861 wxT("wxPropertyGridManager id must be set with wxPropertyGridManager::SetId (not wxWindow::SetId).") );
1863 SetDescribedProperty(event
.GetProperty());
1867 // -----------------------------------------------------------------------
1870 wxPropertyGridManager::OnPGColDrag( wxPropertyGridEvent
& WXUNUSED(event
) )
1872 #if wxUSE_HEADERCTRL
1873 if ( !m_showHeader
)
1876 m_pHeaderCtrl
->OnColumWidthsChanged();
1880 // -----------------------------------------------------------------------
1882 void wxPropertyGridManager::OnResize( wxSizeEvent
& WXUNUSED(event
) )
1886 GetClientSize(&width
, &height
);
1888 if ( m_width
== -12345 )
1891 RecalculatePositions(width
, height
);
1893 if ( m_pPropGrid
&& m_pPropGrid
->m_parent
)
1895 int pgWidth
, pgHeight
;
1896 m_pPropGrid
->GetClientSize(&pgWidth
, &pgHeight
);
1898 // Regenerate splitter positions for non-current pages
1899 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1901 wxPropertyGridPage
* page
= GetPage(i
);
1902 if ( page
!= m_pPropGrid
->GetState() )
1904 page
->OnClientWidthChange(pgWidth
,
1905 pgWidth
- page
->m_width
,
1911 #if wxUSE_HEADERCTRL
1913 m_pHeaderCtrl
->OnColumWidthsChanged();
1917 // -----------------------------------------------------------------------
1919 void wxPropertyGridManager::OnMouseEntry( wxMouseEvent
& WXUNUSED(event
) )
1921 // Correct cursor. This is required atleast for wxGTK, for which
1922 // setting button's cursor to *wxSTANDARD_CURSOR does not work.
1923 SetCursor( wxNullCursor
);
1927 // -----------------------------------------------------------------------
1929 void wxPropertyGridManager::OnMouseMove( wxMouseEvent
&event
)
1931 if ( !m_pTxtHelpCaption
)
1936 if ( m_dragStatus
> 0 )
1938 int sy
= y
- m_dragOffset
;
1940 // Calculate drag limits
1941 int bottom_limit
= m_height
- m_splitterHeight
+ 1;
1942 int top_limit
= m_pPropGrid
->m_lineHeight
;
1944 if ( m_pToolbar
) top_limit
+= m_pToolbar
->GetSize().y
;
1947 if ( sy
>= top_limit
&& sy
< bottom_limit
)
1950 int change
= sy
- m_splitterY
;
1955 m_pPropGrid
->SetSize( m_width
, m_splitterY
- m_pPropGrid
->GetPosition().y
);
1956 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1958 m_extraHeight
-= change
;
1959 InvalidateBestSize();
1967 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1969 SetCursor ( m_cursorSizeNS
);
1976 SetCursor ( wxNullCursor
);
1983 // -----------------------------------------------------------------------
1985 void wxPropertyGridManager::OnMouseClick( wxMouseEvent
&event
)
1989 // Click on splitter.
1990 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1992 if ( m_dragStatus
== 0 )
1995 // Begin draggin the splitter
2002 m_dragOffset
= y
- m_splitterY
;
2008 // -----------------------------------------------------------------------
2010 void wxPropertyGridManager::OnMouseUp( wxMouseEvent
&event
)
2012 // No event type check - basically calling this method should
2013 // just stop dragging.
2015 if ( m_dragStatus
>= 1 )
2018 // End Splitter Dragging
2023 // DO NOT ENABLE FOLLOWING LINE!
2024 // (it is only here as a reminder to not to do it)
2027 // This is necessary to return cursor
2030 // Set back the default cursor, if necessary
2031 if ( y
< m_splitterY
|| y
>= (m_splitterY
+m_splitterHeight
+2) )
2033 SetCursor ( wxNullCursor
);
2040 // -----------------------------------------------------------------------
2042 void wxPropertyGridManager::SetSplitterPosition( int pos
, int splitterColumn
)
2044 wxASSERT_MSG( GetPageCount(),
2045 wxT("SetSplitterPosition() has no effect until pages have been added") );
2048 for ( i
=0; i
<GetPageCount(); i
++ )
2050 wxPropertyGridPage
* page
= GetPage(i
);
2051 page
->DoSetSplitterPosition( pos
, splitterColumn
,
2052 wxPG_SPLITTER_REFRESH
);
2055 #if wxUSE_HEADERCTRL
2057 m_pHeaderCtrl
->OnColumWidthsChanged();
2061 // -----------------------------------------------------------------------
2063 void wxPropertyGridManager::SetPageSplitterPosition( int page
,
2067 GetPage(page
)->DoSetSplitterPosition( pos
, column
);
2069 #if wxUSE_HEADERCTRL
2071 m_pHeaderCtrl
->OnColumWidthsChanged();
2075 // -----------------------------------------------------------------------
2076 // wxPGVIterator_Manager
2077 // -----------------------------------------------------------------------
2079 // Default returned by wxPropertyGridInterface::CreateVIterator().
2080 class wxPGVIteratorBase_Manager
: public wxPGVIteratorBase
2083 wxPGVIteratorBase_Manager( wxPropertyGridManager
* manager
, int flags
)
2084 : m_manager(manager
), m_flags(flags
), m_curPage(0)
2086 m_it
.Init(manager
->GetPage(0), flags
);
2088 virtual ~wxPGVIteratorBase_Manager() { }
2097 if ( m_curPage
< m_manager
->GetPageCount() )
2098 m_it
.Init( m_manager
->GetPage(m_curPage
), m_flags
);
2102 wxPropertyGridManager
* m_manager
;
2104 unsigned int m_curPage
;
2107 wxPGVIterator
wxPropertyGridManager::GetVIterator( int flags
) const
2109 return wxPGVIterator( new wxPGVIteratorBase_Manager( (wxPropertyGridManager
*)this, flags
) );
2112 #endif // wxUSE_PROPGRID