1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/manager.cpp
3 // Purpose: wxPropertyGridManager
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
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();
626 wxDELETE(m_pPropGrid
);
629 for ( i
=0; i
<m_arrPages
.size(); i
++ )
631 delete m_arrPages
[i
];
637 // -----------------------------------------------------------------------
639 wxPropertyGrid
* wxPropertyGridManager::CreatePropertyGrid() const
641 return new wxPropertyGrid();
644 // -----------------------------------------------------------------------
646 void wxPropertyGridManager::SetId( wxWindowID winid
)
648 wxWindow::SetId(winid
);
650 // TODO: Reconnect propgrid event handler(s).
652 m_pPropGrid
->SetId(winid
);
655 // -----------------------------------------------------------------------
657 wxSize
wxPropertyGridManager::DoGetBestSize() const
659 return wxSize(60,150);
662 // -----------------------------------------------------------------------
664 bool wxPropertyGridManager::SetFont( const wxFont
& font
)
666 bool res
= wxWindow::SetFont(font
);
667 m_pPropGrid
->SetFont(font
);
669 // TODO: Need to do caption recacalculations for other pages as well.
671 for ( i
=0; i
<m_arrPages
.size(); i
++ )
673 wxPropertyGridPage
* page
= GetPage(i
);
675 if ( page
!= m_pPropGrid
->GetState() )
676 page
->CalculateFontAndBitmapStuff(-1);
682 // -----------------------------------------------------------------------
684 void wxPropertyGridManager::SetExtraStyle( long exStyle
)
686 wxWindow::SetExtraStyle( exStyle
);
687 m_pPropGrid
->SetExtraStyle( exStyle
& 0xFFFFF000 );
689 if ( (exStyle
& wxPG_EX_NO_FLAT_TOOLBAR
) && m_pToolbar
)
694 // -----------------------------------------------------------------------
696 void wxPropertyGridManager::Freeze()
698 m_pPropGrid
->Freeze();
702 // -----------------------------------------------------------------------
704 void wxPropertyGridManager::Thaw()
710 // -----------------------------------------------------------------------
712 void wxPropertyGridManager::SetWindowStyleFlag( long style
)
714 int oldWindowStyle
= GetWindowStyleFlag();
716 wxWindow::SetWindowStyleFlag( style
);
717 m_pPropGrid
->SetWindowStyleFlag( (m_pPropGrid
->GetWindowStyleFlag()&~(wxPG_MAN_PASS_FLAGS_MASK
)) |
718 (style
&wxPG_MAN_PASS_FLAGS_MASK
) );
720 // Need to re-position windows?
721 if ( (oldWindowStyle
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) !=
722 (style
& (wxPG_TOOLBAR
|wxPG_DESCRIPTION
)) )
728 // -----------------------------------------------------------------------
730 bool wxPropertyGridManager::Reparent( wxWindowBase
*newParent
)
733 m_pPropGrid
->OnTLPChanging((wxWindow
*)newParent
);
735 bool res
= wxPanel::Reparent(newParent
);
740 // -----------------------------------------------------------------------
742 // Actually shows given page.
743 bool wxPropertyGridManager::DoSelectPage( int index
)
745 // -1 means no page was selected
746 //wxASSERT( m_selPage >= 0 );
748 wxCHECK_MSG( index
>= -1 && index
< (int)GetPageCount(),
750 wxT("invalid page index") );
752 if ( m_selPage
== index
)
755 if ( m_pPropGrid
->GetSelection() )
757 if ( !m_pPropGrid
->ClearSelection() )
761 wxPropertyGridPage
* prevPage
;
763 if ( m_selPage
>= 0 )
764 prevPage
= GetPage(m_selPage
);
766 prevPage
= m_emptyPage
;
768 wxPropertyGridPage
* nextPage
;
772 nextPage
= m_arrPages
[index
];
780 m_emptyPage
= new wxPropertyGridPage();
781 m_emptyPage
->m_pPropGrid
= m_pPropGrid
;
784 nextPage
= m_emptyPage
;
787 m_iFlags
|= wxPG_FL_DESC_REFRESH_REQUIRED
;
789 m_pPropGrid
->SwitchState( nextPage
->GetStatePtr() );
791 m_pState
= m_pPropGrid
->m_pState
;
799 m_pToolbar
->ToggleTool( nextPage
->m_id
, true );
801 m_pToolbar
->ToggleTool( prevPage
->m_id
, false );
807 m_pHeaderCtrl
->OnPageChanged(nextPage
);
813 // -----------------------------------------------------------------------
815 // Changes page *and* set the target page for insertion operations.
816 void wxPropertyGridManager::SelectPage( int index
)
821 // -----------------------------------------------------------------------
823 int wxPropertyGridManager::GetPageByName( const wxString
& name
) const
826 for ( i
=0; i
<GetPageCount(); i
++ )
828 if ( m_arrPages
[i
]->m_label
== name
)
834 // -----------------------------------------------------------------------
836 int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState
* pState
) const
841 for ( i
=0; i
<GetPageCount(); i
++ )
843 if ( pState
== m_arrPages
[i
]->GetStatePtr() )
850 // -----------------------------------------------------------------------
852 const wxString
& wxPropertyGridManager::GetPageName( int index
) const
854 wxASSERT( index
>= 0 && index
< (int)GetPageCount() );
855 return m_arrPages
[index
]->m_label
;
858 // -----------------------------------------------------------------------
860 wxPropertyGridPageState
* wxPropertyGridManager::GetPageState( int page
) const
862 // Do not change this into wxCHECK because returning NULL is important
863 // for wxPropertyGridInterface page enumeration mechanics.
864 if ( page
>= (int)GetPageCount() )
869 return m_arrPages
[page
];
872 // -----------------------------------------------------------------------
874 void wxPropertyGridManager::Clear()
876 m_pPropGrid
->ClearSelection(false);
878 m_pPropGrid
->Freeze();
881 for ( i
=(int)GetPageCount()-1; i
>=0; i
-- )
885 m_nextTbInd
= m_baseId
+ID_ADVTBITEMSBASE_OFFSET
+ 2;
890 // -----------------------------------------------------------------------
892 void wxPropertyGridManager::ClearPage( int page
)
894 wxASSERT( page
>= 0 );
895 wxASSERT( page
< (int)GetPageCount() );
897 if ( page
>= 0 && page
< (int)GetPageCount() )
899 wxPropertyGridPageState
* state
= m_arrPages
[page
];
901 if ( state
== m_pPropGrid
->GetState() )
902 m_pPropGrid
->Clear();
908 // -----------------------------------------------------------------------
910 int wxPropertyGridManager::GetColumnCount( int page
) const
912 wxASSERT( page
>= -1 );
913 wxASSERT( page
< (int)GetPageCount() );
915 return GetPageState(page
)->GetColumnCount();
918 // -----------------------------------------------------------------------
920 void wxPropertyGridManager::SetColumnCount( int colCount
, int page
)
922 wxASSERT( page
>= -1 );
923 wxASSERT( page
< (int)GetPageCount() );
925 GetPageState(page
)->SetColumnCount( colCount
);
926 GetGrid()->Refresh();
930 m_pHeaderCtrl
->OnPageUpdated();
933 // -----------------------------------------------------------------------
935 size_t wxPropertyGridManager::GetPageCount() const
937 if ( !(m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
) )
940 return m_arrPages
.size();
943 // -----------------------------------------------------------------------
945 wxPropertyGridPage
* wxPropertyGridManager::InsertPage( int index
,
946 const wxString
& label
,
948 wxPropertyGridPage
* pageObj
)
951 index
= GetPageCount();
953 wxCHECK_MSG( (size_t)index
== GetPageCount(), NULL
,
954 wxT("wxPropertyGridManager currently only supports appending pages (due to wxToolBar limitation)."));
956 bool needInit
= true;
957 bool isPageInserted
= m_iFlags
& wxPG_MAN_FL_PAGE_INSERTED
? true : false;
959 wxASSERT( index
== 0 || isPageInserted
);
963 // No custom page object was given, so we will either re-use the default base
964 // page (if index==0), or create a new default page object.
965 if ( !isPageInserted
)
967 pageObj
= GetPage(0);
968 // Of course, if the base page was custom, we need to delete and
970 if ( !pageObj
->m_isDefault
)
973 pageObj
= new wxPropertyGridPage();
974 m_arrPages
[0] = pageObj
;
980 pageObj
= new wxPropertyGridPage();
982 pageObj
->m_isDefault
= true;
986 if ( !isPageInserted
)
988 // Initial page needs to be deleted and replaced
990 m_arrPages
[0] = pageObj
;
991 m_pPropGrid
->m_pState
= pageObj
->GetStatePtr();
995 wxPropertyGridPageState
* state
= pageObj
->GetStatePtr();
997 pageObj
->m_manager
= this;
1001 state
->m_pPropGrid
= m_pPropGrid
;
1002 state
->InitNonCatMode();
1005 if ( label
.length() )
1007 wxASSERT_MSG( !pageObj
->m_label
.length(),
1008 wxT("If page label is given in constructor, empty label must be given in AddPage"));
1009 pageObj
->m_label
= label
;
1012 pageObj
->m_id
= m_nextTbInd
;
1014 if ( !HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
1015 pageObj
->m_dontCenterSplitter
= true;
1017 if ( isPageInserted
)
1018 m_arrPages
.push_back( pageObj
);
1021 if ( m_windowStyle
& wxPG_TOOLBAR
)
1026 if ( !(GetExtraStyle()&wxPG_EX_HIDE_PAGE_BUTTONS
) )
1028 wxASSERT( m_pToolbar
);
1030 // Add separator before first page.
1031 if ( GetPageCount() < 2 && (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) &&
1032 m_pToolbar
->GetToolsCount() < 3 )
1033 m_pToolbar
->AddSeparator();
1035 if ( &bmp
!= &wxNullBitmap
)
1036 m_pToolbar
->AddTool(m_nextTbInd
,label
,bmp
,label
,wxITEM_RADIO
);
1037 //m_pToolbar->InsertTool(index+3,m_nextTbInd,bmp);
1039 m_pToolbar
->AddTool(m_nextTbInd
,label
,wxBitmap(gs_xpm_defpage
),
1040 label
,wxITEM_RADIO
);
1044 m_pToolbar
->Realize();
1051 // If selected page was above the point of insertion, fix the current page index
1052 if ( isPageInserted
)
1054 if ( m_selPage
>= index
)
1061 // Set this value only when adding the first page
1067 m_iFlags
|= wxPG_MAN_FL_PAGE_INSERTED
;
1069 wxASSERT( pageObj
->GetGrid() );
1074 // -----------------------------------------------------------------------
1076 bool wxPropertyGridManager::IsAnyModified() const
1079 for ( i
=0; i
<GetPageCount(); i
++ )
1081 if ( m_arrPages
[i
]->GetStatePtr()->m_anyModified
)
1087 // -----------------------------------------------------------------------
1089 bool wxPropertyGridManager::IsPageModified( size_t index
) const
1091 if ( m_arrPages
[index
]->GetStatePtr()->m_anyModified
)
1096 // -----------------------------------------------------------------------
1098 #if wxUSE_HEADERCTRL
1099 void wxPropertyGridManager::ShowHeader(bool show
)
1101 if ( show
!= m_showHeader
)
1103 m_showHeader
= show
;
1109 // -----------------------------------------------------------------------
1111 #if wxUSE_HEADERCTRL
1112 void wxPropertyGridManager::SetColumnTitle( int idx
, const wxString
& title
)
1114 if ( !m_pHeaderCtrl
)
1117 m_pHeaderCtrl
->SetColumnTitle(idx
, title
);
1121 // -----------------------------------------------------------------------
1123 bool wxPropertyGridManager::IsPropertySelected( wxPGPropArg id
) const
1125 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1126 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1128 if ( GetPageState(i
)->DoIsPropertySelected(p
) )
1134 // -----------------------------------------------------------------------
1136 wxPGProperty
* wxPropertyGridManager::GetPageRoot( int index
) const
1138 wxASSERT( index
>= 0 );
1139 wxASSERT( index
< (int)m_arrPages
.size() );
1141 return m_arrPages
[index
]->GetStatePtr()->m_properties
;
1144 // -----------------------------------------------------------------------
1146 bool wxPropertyGridManager::RemovePage( int page
)
1148 wxCHECK_MSG( (page
>= 0) && (page
< (int)GetPageCount()),
1150 wxT("invalid page index") );
1152 wxPropertyGridPage
* pd
= m_arrPages
[page
];
1154 if ( m_arrPages
.size() == 1 )
1156 // Last page: do not remove page entry
1157 m_pPropGrid
->Clear();
1159 m_iFlags
&= ~wxPG_MAN_FL_PAGE_INSERTED
;
1160 pd
->m_label
.clear();
1163 // Change selection if current is page
1164 else if ( page
== m_selPage
)
1166 if ( !m_pPropGrid
->ClearSelection() )
1169 // Substitute page to select
1170 int substitute
= page
- 1;
1171 if ( substitute
< 0 )
1172 substitute
= page
+ 1;
1174 SelectPage(substitute
);
1177 // Remove toolbar icon
1179 if ( HasFlag(wxPG_TOOLBAR
) )
1181 wxASSERT( m_pToolbar
);
1183 int toolPos
= GetExtraStyle() & wxPG_EX_MODE_BUTTONS
? 3 : 0;
1186 // Delete separator as well, for consistency
1187 if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS
) &&
1188 GetPageCount() == 1 )
1189 m_pToolbar
->DeleteToolByPos(2);
1191 m_pToolbar
->DeleteToolByPos(toolPos
);
1195 if ( m_arrPages
.size() > 1 )
1197 m_arrPages
.erase(m_arrPages
.begin() + page
);
1201 // Adjust indexes that were above removed
1202 if ( m_selPage
> page
)
1208 // -----------------------------------------------------------------------
1210 bool wxPropertyGridManager::ProcessEvent( wxEvent
& event
)
1212 int evtType
= event
.GetEventType();
1214 // NB: For some reason, under wxPython, Connect in Init doesn't work properly,
1215 // so we'll need to call OnPropertyGridSelect manually. Multiple call's
1216 // don't really matter.
1217 if ( evtType
== wxEVT_PG_SELECTED
)
1218 OnPropertyGridSelect((wxPropertyGridEvent
&)event
);
1220 // Property grid events get special attention
1221 if ( evtType
>= wxPG_BASE_EVT_TYPE
&&
1222 evtType
< (wxPG_MAX_EVT_TYPE
) &&
1225 wxPropertyGridPage
* page
= GetPage(m_selPage
);
1226 wxPropertyGridEvent
* pgEvent
= wxDynamicCast(&event
, wxPropertyGridEvent
);
1228 // Add property grid events to appropriate custom pages
1229 // but stop propagating to parent if page says it is
1230 // handling everything.
1231 if ( pgEvent
&& !page
->m_isDefault
)
1233 /*if ( pgEvent->IsPending() )
1234 page->AddPendingEvent(event);
1236 page
->ProcessEvent(event
);
1238 if ( page
->IsHandlingAllEvents() )
1239 event
.StopPropagation();
1243 return wxPanel::ProcessEvent(event
);
1246 // -----------------------------------------------------------------------
1248 void wxPropertyGridManager::RepaintDescBoxDecorations( wxDC
& dc
,
1254 wxColour bgcol
= GetBackgroundColour();
1257 int rectHeight
= m_splitterHeight
;
1258 dc
.DrawRectangle(0, newSplitterY
, newWidth
, rectHeight
);
1259 dc
.SetPen( wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) );
1260 int splitterBottom
= newSplitterY
+ m_splitterHeight
- 1;
1261 int boxHeight
= newHeight
- splitterBottom
;
1262 if ( boxHeight
> 1 )
1263 dc
.DrawRectangle(0, splitterBottom
, newWidth
, boxHeight
);
1265 dc
.DrawLine(0, splitterBottom
, newWidth
, splitterBottom
);
1268 // -----------------------------------------------------------------------
1270 void wxPropertyGridManager::UpdateDescriptionBox( int new_splittery
, int new_width
, int new_height
)
1272 int use_hei
= new_height
;
1275 // Fix help control positions.
1276 int cap_hei
= m_pPropGrid
->m_fontHeight
;
1277 int cap_y
= new_splittery
+m_splitterHeight
+5;
1278 int cnt_y
= cap_y
+cap_hei
+3;
1279 int sub_cap_hei
= cap_y
+cap_hei
-use_hei
;
1280 int cnt_hei
= use_hei
-cnt_y
;
1281 if ( sub_cap_hei
> 0 )
1283 cap_hei
-= sub_cap_hei
;
1288 m_pTxtHelpCaption
->Show( false );
1289 m_pTxtHelpContent
->Show( false );
1293 m_pTxtHelpCaption
->SetSize(3,cap_y
,new_width
-6,cap_hei
);
1294 m_pTxtHelpCaption
->Wrap(-1);
1295 m_pTxtHelpCaption
->Show( true );
1298 m_pTxtHelpContent
->Show( false );
1302 m_pTxtHelpContent
->SetSize(3,cnt_y
,new_width
-6,cnt_hei
);
1303 m_pTxtHelpContent
->Show( true );
1307 wxRect
r(0, new_splittery
, new_width
, new_height
-new_splittery
);
1310 m_splitterY
= new_splittery
;
1312 m_iFlags
&= ~(wxPG_FL_DESC_REFRESH_REQUIRED
);
1315 // -----------------------------------------------------------------------
1317 void wxPropertyGridManager::RecalculatePositions( int width
, int height
)
1320 int propgridBottomY
= height
;
1322 // Toolbar at the top.
1326 m_pToolbar
->SetSize(0, 0, width
, -1);
1327 propgridY
+= m_pToolbar
->GetSize().y
;
1329 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1334 // Header comes after the tool bar
1335 #if wxUSE_HEADERCTRL
1338 m_pHeaderCtrl
->SetSize(0, propgridY
, width
, -1);
1339 propgridY
+= m_pHeaderCtrl
->GetSize().y
;
1344 if ( m_pTxtHelpCaption
)
1346 int new_splittery
= m_splitterY
;
1349 if ( ( m_splitterY
>= 0 || m_nextDescBoxSize
) && m_height
> 32 )
1351 if ( m_nextDescBoxSize
>= 0 )
1353 new_splittery
= m_height
- m_nextDescBoxSize
- m_splitterHeight
;
1354 m_nextDescBoxSize
= -1;
1356 new_splittery
+= (height
-m_height
);
1360 new_splittery
= height
- wxPGMAN_DEFAULT_NEGATIVE_SPLITTER_Y
;
1361 if ( new_splittery
< 32 )
1365 // Check if beyond minimum.
1366 int nspy_min
= propgridY
+ m_pPropGrid
->m_lineHeight
;
1367 if ( new_splittery
< nspy_min
)
1368 new_splittery
= nspy_min
;
1370 propgridBottomY
= new_splittery
;
1372 UpdateDescriptionBox( new_splittery
, width
, height
);
1375 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
1377 int pgh
= propgridBottomY
- propgridY
;
1380 m_pPropGrid
->SetSize( 0, propgridY
, width
, pgh
);
1382 m_extraHeight
= height
- pgh
;
1389 // -----------------------------------------------------------------------
1391 void wxPropertyGridManager::SetDescBoxHeight( int ht
, bool refresh
)
1393 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1395 if ( ht
!= GetDescBoxHeight() )
1397 m_nextDescBoxSize
= ht
;
1399 RecalculatePositions(m_width
, m_height
);
1404 // -----------------------------------------------------------------------
1406 int wxPropertyGridManager::GetDescBoxHeight() const
1408 return GetClientSize().y
- m_splitterY
- m_splitterHeight
;
1411 // -----------------------------------------------------------------------
1413 void wxPropertyGridManager::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1417 // Update everything inside the box
1418 wxRect r
= GetUpdateRegion().GetBox();
1420 if (GetExtraStyle() & wxPG_EX_TOOLBAR_SEPARATOR
)
1422 if (m_pToolbar
&& m_pPropGrid
)
1424 wxPen
marginPen(m_pPropGrid
->GetMarginColour());
1425 dc
.SetPen(marginPen
);
1427 int y
= m_pPropGrid
->GetPosition().y
-1;
1428 dc
.DrawLine(0, y
, GetClientSize().x
, y
);
1432 // Repaint splitter and any other description box decorations
1433 if ( (r
.y
+ r
.height
) >= m_splitterY
&& m_splitterY
!= -1)
1434 RepaintDescBoxDecorations( dc
, m_splitterY
, m_width
, m_height
);
1437 // -----------------------------------------------------------------------
1439 void wxPropertyGridManager::Refresh(bool eraseBackground
, const wxRect
* rect
)
1441 m_pPropGrid
->Refresh(eraseBackground
);
1442 wxWindow::Refresh(eraseBackground
,rect
);
1445 // -----------------------------------------------------------------------
1447 void wxPropertyGridManager::RefreshProperty( wxPGProperty
* p
)
1449 wxPropertyGrid
* grid
= p
->GetGrid();
1451 if ( GetPage(m_selPage
)->GetStatePtr() == p
->GetParent()->GetParentState() )
1452 grid
->RefreshProperty(p
);
1455 // -----------------------------------------------------------------------
1457 void wxPropertyGridManager::RecreateControls()
1460 bool was_shown
= IsShown();
1464 wxWindowID baseId
= m_pPropGrid
->GetId();
1466 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
1469 if ( m_windowStyle
& wxPG_TOOLBAR
)
1474 long toolBarFlags
= ((GetExtraStyle()&wxPG_EX_NO_FLAT_TOOLBAR
)?0:wxTB_FLAT
);
1475 if (GetExtraStyle() & wxPG_EX_NO_TOOLBAR_DIVIDER
)
1476 toolBarFlags
|= wxTB_NODIVIDER
;
1478 m_pToolbar
= new wxToolBar(this,baseId
+ID_ADVTOOLBAR_OFFSET
,
1479 wxDefaultPosition
,wxDefaultSize
,
1481 m_pToolbar
->SetToolBitmapSize(wxSize(16, 15));
1483 #if defined(__WXMSW__)
1484 // Eliminate toolbar flicker on XP
1485 // NOTE: Not enabled since it corrupts drawing somewhat.
1488 #ifndef WS_EX_COMPOSITED
1489 #define WS_EX_COMPOSITED 0x02000000L
1492 HWND hWnd = (HWND)m_pToolbar->GetHWND();
1494 ::SetWindowLong( hWnd, GWL_EXSTYLE,
1495 ::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_COMPOSITED );
1500 m_pToolbar
->SetCursor ( *wxSTANDARD_CURSOR
);
1502 if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) )
1504 wxString
desc1(_("Categorized Mode"));
1505 wxString
desc2(_("Alphabetic Mode"));
1506 m_pToolbar
->AddTool(baseId
+ID_ADVTBITEMSBASE_OFFSET
+0,
1507 desc1
,wxBitmap (gs_xpm_catmode
),
1508 desc1
,wxITEM_RADIO
);
1509 m_pToolbar
->AddTool(baseId
+ID_ADVTBITEMSBASE_OFFSET
+1,
1510 desc2
,wxBitmap (gs_xpm_noncatmode
),
1511 desc2
,wxITEM_RADIO
);
1512 m_pToolbar
->Realize();
1517 if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS
) )
1519 // Toggle correct mode button.
1520 // TODO: This doesn't work in wxMSW (when changing,
1521 // both items will get toggled).
1522 int toggle_but_on_ind
= ID_ADVTBITEMSBASE_OFFSET
+0;
1523 int toggle_but_off_ind
= ID_ADVTBITEMSBASE_OFFSET
+1;
1524 if ( m_pPropGrid
->m_pState
->IsInNonCatMode() )
1526 toggle_but_on_ind
++;
1527 toggle_but_off_ind
--;
1530 m_pToolbar
->ToggleTool(baseId
+toggle_but_on_ind
,true);
1531 m_pToolbar
->ToggleTool(baseId
+toggle_but_off_ind
,false);
1539 m_pToolbar
->Destroy();
1544 #if wxUSE_HEADERCTRL
1549 if ( !m_pHeaderCtrl
)
1551 hc
= new wxPGHeaderCtrl(this);
1552 hc
->Create(this, baseId
+ID_ADVHEADERCTRL_OFFSET
);
1557 m_pHeaderCtrl
->Show();
1560 m_pHeaderCtrl
->OnPageChanged(GetCurrentPage());
1564 if ( m_pHeaderCtrl
)
1565 m_pHeaderCtrl
->Hide();
1569 if ( m_windowStyle
& wxPG_DESCRIPTION
)
1572 m_pPropGrid
->m_iFlags
|= (wxPG_FL_NOSTATUSBARHELP
);
1574 if ( !m_pTxtHelpCaption
)
1576 m_pTxtHelpCaption
= new wxStaticText(this,
1577 baseId
+ID_ADVHELPCAPTION_OFFSET
,
1581 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1582 m_pTxtHelpCaption
->SetFont( m_pPropGrid
->m_captionFont
);
1583 m_pTxtHelpCaption
->SetCursor( *wxSTANDARD_CURSOR
);
1585 if ( !m_pTxtHelpContent
)
1587 m_pTxtHelpContent
= new wxStaticText(this,
1588 baseId
+ID_ADVHELPCONTENT_OFFSET
,
1592 wxALIGN_LEFT
|wxST_NO_AUTORESIZE
);
1593 m_pTxtHelpContent
->SetCursor( *wxSTANDARD_CURSOR
);
1596 SetDescribedProperty(GetSelection());
1601 m_pPropGrid
->m_iFlags
&= ~(wxPG_FL_NOSTATUSBARHELP
);
1603 if ( m_pTxtHelpCaption
)
1604 m_pTxtHelpCaption
->Destroy();
1606 m_pTxtHelpCaption
= NULL
;
1608 if ( m_pTxtHelpContent
)
1609 m_pTxtHelpContent
->Destroy();
1611 m_pTxtHelpContent
= NULL
;
1616 GetClientSize(&width
,&height
);
1618 RecalculatePositions(width
,height
);
1624 // -----------------------------------------------------------------------
1626 wxPGProperty
* wxPropertyGridManager::DoGetPropertyByName( const wxString
& name
) const
1629 for ( i
=0; i
<GetPageCount(); i
++ )
1631 wxPropertyGridPageState
* pState
= m_arrPages
[i
]->GetStatePtr();
1632 wxPGProperty
* p
= pState
->BaseGetPropertyByName(name
);
1641 // -----------------------------------------------------------------------
1643 bool wxPropertyGridManager::EnsureVisible( wxPGPropArg id
)
1645 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1647 wxPropertyGridPageState
* parentState
= p
->GetParentState();
1649 // Select correct page.
1650 if ( m_pPropGrid
->m_pState
!= parentState
)
1651 DoSelectPage( GetPageByState(parentState
) );
1653 return m_pPropGrid
->EnsureVisible(id
);
1656 // -----------------------------------------------------------------------
1658 void wxPropertyGridManager::OnToolbarClick( wxCommandEvent
&event
)
1660 int id
= event
.GetId();
1663 int baseId
= m_pPropGrid
->GetId();
1665 baseId
= wxPG_MAN_ALTERNATE_BASE_ID
;
1667 if ( id
== ( baseId
+ ID_ADVTBITEMSBASE_OFFSET
+ 0 ) )
1669 // Categorized mode.
1670 if ( m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
)
1672 if ( !m_pPropGrid
->HasInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
) )
1673 m_pPropGrid
->m_windowStyle
&= ~wxPG_AUTO_SORT
;
1674 m_pPropGrid
->EnableCategories( true );
1677 else if ( id
== ( baseId
+ ID_ADVTBITEMSBASE_OFFSET
+ 1 ) )
1680 if ( !(m_pPropGrid
->m_windowStyle
& wxPG_HIDE_CATEGORIES
) )
1682 if ( m_pPropGrid
->HasFlag(wxPG_AUTO_SORT
) )
1683 m_pPropGrid
->SetInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1685 m_pPropGrid
->ClearInternalFlag(wxPG_FL_CATMODE_AUTO_SORT
);
1687 m_pPropGrid
->m_windowStyle
|= wxPG_AUTO_SORT
;
1688 m_pPropGrid
->EnableCategories( false );
1697 wxPropertyGridPage
* pdc
;
1699 // Find page with given id.
1700 for ( i
=0; i
<GetPageCount(); i
++ )
1702 pdc
= m_arrPages
[i
];
1703 if ( pdc
->m_id
== id
)
1710 wxASSERT( index
>= 0 );
1712 if ( DoSelectPage( index
) )
1715 // Event dispatching must be last.
1716 m_pPropGrid
->SendEvent( wxEVT_PG_PAGE_CHANGED
, NULL
);
1721 // TODO: Depress the old button on toolbar.
1728 // -----------------------------------------------------------------------
1730 bool wxPropertyGridManager::SetEditableStateItem( const wxString
& name
, wxVariant value
)
1732 if ( name
== wxS("descboxheight") )
1734 SetDescBoxHeight(value
.GetLong(), true);
1740 // -----------------------------------------------------------------------
1742 wxVariant
wxPropertyGridManager::GetEditableStateItem( const wxString
& name
) const
1744 if ( name
== wxS("descboxheight") )
1746 return (long) GetDescBoxHeight();
1748 return wxNullVariant
;
1751 // -----------------------------------------------------------------------
1753 void wxPropertyGridManager::SetDescription( const wxString
& label
, const wxString
& content
)
1755 if ( m_pTxtHelpCaption
)
1757 wxSize osz1
= m_pTxtHelpCaption
->GetSize();
1758 wxSize osz2
= m_pTxtHelpContent
->GetSize();
1760 m_pTxtHelpCaption
->SetLabel(label
);
1761 m_pTxtHelpContent
->SetLabel(content
);
1763 m_pTxtHelpCaption
->SetSize(-1,osz1
.y
);
1764 m_pTxtHelpContent
->SetSize(-1,osz2
.y
);
1766 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1770 // -----------------------------------------------------------------------
1772 void wxPropertyGridManager::SetDescribedProperty( wxPGProperty
* p
)
1774 if ( m_pTxtHelpCaption
)
1778 SetDescription( p
->GetLabel(), p
->GetHelpString() );
1782 SetDescription( wxEmptyString
, wxEmptyString
);
1787 // -----------------------------------------------------------------------
1789 void wxPropertyGridManager::SetSplitterLeft( bool subProps
, bool allPages
)
1793 m_pPropGrid
->SetSplitterLeft(subProps
);
1797 wxClientDC
dc(this);
1798 dc
.SetFont(m_pPropGrid
->GetFont());
1803 for ( i
=0; i
<GetPageCount(); i
++ )
1805 int maxW
= m_pState
->GetColumnFitWidth(dc
, m_arrPages
[i
]->m_properties
, 0, subProps
);
1806 maxW
+= m_pPropGrid
->m_marginWidth
;
1807 if ( maxW
> highest
)
1809 m_pState
->m_dontCenterSplitter
= true;
1813 m_pPropGrid
->SetSplitterPosition( highest
);
1816 #if wxUSE_HEADERCTRL
1818 m_pHeaderCtrl
->OnColumWidthsChanged();
1822 // -----------------------------------------------------------------------
1824 void wxPropertyGridManager::OnPropertyGridSelect( wxPropertyGridEvent
& event
)
1827 wxASSERT_MSG( GetId() == m_pPropGrid
->GetId(),
1828 wxT("wxPropertyGridManager id must be set with wxPropertyGridManager::SetId (not wxWindow::SetId).") );
1830 SetDescribedProperty(event
.GetProperty());
1834 // -----------------------------------------------------------------------
1837 wxPropertyGridManager::OnPGColDrag( wxPropertyGridEvent
& WXUNUSED(event
) )
1839 #if wxUSE_HEADERCTRL
1840 if ( !m_showHeader
)
1843 m_pHeaderCtrl
->OnColumWidthsChanged();
1847 // -----------------------------------------------------------------------
1849 void wxPropertyGridManager::OnResize( wxSizeEvent
& WXUNUSED(event
) )
1853 GetClientSize(&width
, &height
);
1855 if ( m_width
== -12345 )
1858 RecalculatePositions(width
, height
);
1860 if ( m_pPropGrid
&& m_pPropGrid
->m_parent
)
1862 int pgWidth
, pgHeight
;
1863 m_pPropGrid
->GetClientSize(&pgWidth
, &pgHeight
);
1865 // Regenerate splitter positions for non-current pages
1866 for ( unsigned int i
=0; i
<GetPageCount(); i
++ )
1868 wxPropertyGridPage
* page
= GetPage(i
);
1869 if ( page
!= m_pPropGrid
->GetState() )
1871 page
->OnClientWidthChange(pgWidth
,
1872 pgWidth
- page
->m_width
,
1879 // -----------------------------------------------------------------------
1881 void wxPropertyGridManager::OnMouseEntry( wxMouseEvent
& WXUNUSED(event
) )
1883 // Correct cursor. This is required atleast for wxGTK, for which
1884 // setting button's cursor to *wxSTANDARD_CURSOR does not work.
1885 SetCursor( wxNullCursor
);
1889 // -----------------------------------------------------------------------
1891 void wxPropertyGridManager::OnMouseMove( wxMouseEvent
&event
)
1893 if ( !m_pTxtHelpCaption
)
1898 if ( m_dragStatus
> 0 )
1900 int sy
= y
- m_dragOffset
;
1902 // Calculate drag limits
1903 int bottom_limit
= m_height
- m_splitterHeight
+ 1;
1904 int top_limit
= m_pPropGrid
->m_lineHeight
;
1906 if ( m_pToolbar
) top_limit
+= m_pToolbar
->GetSize().y
;
1909 if ( sy
>= top_limit
&& sy
< bottom_limit
)
1912 int change
= sy
- m_splitterY
;
1917 m_pPropGrid
->SetSize( m_width
, m_splitterY
- m_pPropGrid
->GetPosition().y
);
1918 UpdateDescriptionBox( m_splitterY
, m_width
, m_height
);
1920 m_extraHeight
-= change
;
1921 InvalidateBestSize();
1929 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1931 SetCursor ( m_cursorSizeNS
);
1938 SetCursor ( wxNullCursor
);
1945 // -----------------------------------------------------------------------
1947 void wxPropertyGridManager::OnMouseClick( wxMouseEvent
&event
)
1951 // Click on splitter.
1952 if ( y
>= m_splitterY
&& y
< (m_splitterY
+m_splitterHeight
+2) )
1954 if ( m_dragStatus
== 0 )
1957 // Begin draggin the splitter
1964 m_dragOffset
= y
- m_splitterY
;
1970 // -----------------------------------------------------------------------
1972 void wxPropertyGridManager::OnMouseUp( wxMouseEvent
&event
)
1974 // No event type check - basicly calling this method should
1975 // just stop dragging.
1977 if ( m_dragStatus
>= 1 )
1980 // End Splitter Dragging
1985 // DO NOT ENABLE FOLLOWING LINE!
1986 // (it is only here as a reminder to not to do it)
1989 // This is necessary to return cursor
1992 // Set back the default cursor, if necessary
1993 if ( y
< m_splitterY
|| y
>= (m_splitterY
+m_splitterHeight
+2) )
1995 SetCursor ( wxNullCursor
);
2002 // -----------------------------------------------------------------------
2004 void wxPropertyGridManager::SetSplitterPosition( int pos
, int splitterColumn
)
2006 wxASSERT_MSG( GetPageCount(),
2007 wxT("SetSplitterPosition() has no effect until pages have been added") );
2010 for ( i
=0; i
<GetPageCount(); i
++ )
2012 wxPropertyGridPage
* page
= GetPage(i
);
2013 page
->DoSetSplitterPosition( pos
, splitterColumn
,
2014 wxPG_SPLITTER_REFRESH
);
2017 #if wxUSE_HEADERCTRL
2019 m_pHeaderCtrl
->OnColumWidthsChanged();
2023 // -----------------------------------------------------------------------
2025 void wxPropertyGridManager::SetPageSplitterPosition( int page
,
2029 GetPage(page
)->DoSetSplitterPosition( pos
, column
);
2031 #if wxUSE_HEADERCTRL
2033 m_pHeaderCtrl
->OnColumWidthsChanged();
2037 // -----------------------------------------------------------------------
2038 // wxPGVIterator_Manager
2039 // -----------------------------------------------------------------------
2041 // Default returned by wxPropertyGridInterface::CreateVIterator().
2042 class wxPGVIteratorBase_Manager
: public wxPGVIteratorBase
2045 wxPGVIteratorBase_Manager( wxPropertyGridManager
* manager
, int flags
)
2046 : m_manager(manager
), m_flags(flags
), m_curPage(0)
2048 m_it
.Init(manager
->GetPage(0), flags
);
2050 virtual ~wxPGVIteratorBase_Manager() { }
2059 if ( m_curPage
< m_manager
->GetPageCount() )
2060 m_it
.Init( m_manager
->GetPage(m_curPage
), m_flags
);
2064 wxPropertyGridManager
* m_manager
;
2066 unsigned int m_curPage
;
2069 wxPGVIterator
wxPropertyGridManager::GetVIterator( int flags
) const
2071 return wxPGVIterator( new wxPGVIteratorBase_Manager( (wxPropertyGridManager
*)this, flags
) );
2074 #endif // wxUSE_PROPGRID