Added wxPropertyGridManager header support; Refactored wxPropertyGrid DoSetSplitterPosition() code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2009-12-13 12:00:04 +00:00
parent 9804064630
commit f525476870
10 changed files with 491 additions and 74 deletions

View File

@@ -23,6 +23,7 @@
#include "wx/button.h"
#include "wx/textctrl.h"
#include "wx/dialog.h"
#include <wx/headerctrl.h>
// -----------------------------------------------------------------------
@@ -161,8 +162,7 @@ protected:
*/
virtual void DoSetSplitterPosition( int pos,
int splitterColumn = 0,
bool allPages = false,
bool fromAutoCenter = false );
int flags = wxPG_SPLITTER_REFRESH );
/** Page label (may be referred as name in some parts of documentation).
Can be set in constructor, or passed in
@@ -188,6 +188,11 @@ private:
// -----------------------------------------------------------------------
#if wxUSE_HEADERCTRL
class wxPGHeaderCtrl;
#endif
/** @class wxPropertyGridManager
wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
@@ -534,7 +539,21 @@ public:
return p->GetParentState()->DoSelectProperty(p, focus);
}
/** Sets number of columns on given page (default is current page).
/**
Sets a column title. Default title for column 0 is "Property",
and "Value" for column 1.
@remarks If header is not shown yet, then calling this
member function will make it visible.
*/
void SetColumnTitle( int idx, const wxString& title );
/**
Sets number of columns on given page (default is current page).
@remarks If you use header, then you should always use this
member function to set the column count, instead of
ones present in wxPropertyGrid or wxPropertyGridPage.
*/
void SetColumnCount( int colCount, int page = -1 );
@@ -555,20 +574,40 @@ public:
*/
void SetSplitterLeft( bool subProps = false, bool allPages = true );
/** Sets splitter position on individual page. */
void SetPageSplitterPosition( int page, int pos, int column = 0 )
{
GetPage(page)->DoSetSplitterPosition( pos, column );
}
/**
Sets splitter position on individual page.
/** Sets splitter position for all pages.
@remarks
Splitter position cannot exceed grid size, and therefore setting it
during form creation may fail as initial grid size is often smaller
than desired splitter position, especially when sizers are being used.
@remarks If you use header, then you should always use this
member function to set the splitter position, instead of
ones present in wxPropertyGrid or wxPropertyGridPage.
*/
void SetPageSplitterPosition( int page, int pos, int column = 0 );
/**
Sets splitter position for all pages.
@remarks Splitter position cannot exceed grid size, and therefore
setting it during form creation may fail as initial grid
size is often smaller than desired splitter position,
especially when sizers are being used.
If you use header, then you should always use this
member function to set the splitter position, instead of
ones present in wxPropertyGrid or wxPropertyGridPage.
*/
void SetSplitterPosition( int pos, int column = 0 );
#if wxUSE_HEADERCTRL
/**
Show or hide the property grid header control. It is hidden
by the default.
@remarks Grid may look better if you use wxPG_NO_INTERNAL_BORDER
window style when showing a header.
*/
void ShowHeader(bool show = true);
#endif
protected:
//
@@ -600,13 +639,11 @@ public:
virtual void SetWindowStyleFlag ( long style );
virtual bool Reparent( wxWindowBase *newParent );
#ifndef SWIG
protected:
virtual wxSize DoGetBestSize() const;
public:
#ifndef SWIG
//
// Event handlers
//
@@ -620,8 +657,8 @@ public:
void OnToolbarClick( wxCommandEvent &event );
void OnResize( wxSizeEvent& event );
void OnPropertyGridSelect( wxPropertyGridEvent& event );
void OnPGColDrag( wxPropertyGridEvent& event );
protected:
wxPropertyGrid* m_pPropGrid;
@@ -629,12 +666,17 @@ protected:
#if wxUSE_TOOLBAR
wxToolBar* m_pToolbar;
#endif
#if wxUSE_HEADERCTRL
wxPGHeaderCtrl* m_pHeaderCtrl;
#endif
wxStaticText* m_pTxtHelpCaption;
wxStaticText* m_pTxtHelpContent;
wxPropertyGridPage* m_emptyPage;
wxArrayString m_columnLabels;
long m_iFlags;
// Selected page index.
@@ -664,6 +706,8 @@ protected:
unsigned char m_onSplitter;
bool m_showHeader;
virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const;
/** Select and displays a given page. */

View File

@@ -192,8 +192,8 @@ wxPG_TOOLBAR = 0x00001000,
*/
wxPG_DESCRIPTION = 0x00002000,
/** wxPropertyGridManager only: don't show an internal border around
the property grid.
/** wxPropertyGridManager only: don't show an internal border around the
property grid. Recommended if you use a header.
*/
wxPG_NO_INTERNAL_BORDER = 0x00004000
};
@@ -511,6 +511,19 @@ enum wxPG_KEYBOARD_ACTIONS
// Don't make any graphics updates
#define wxPG_SEL_NO_REFRESH 0x0100
// -----------------------------------------------------------------------
// DoSetSplitterPosition() flags
enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
{
wxPG_SPLITTER_REFRESH = 0x0001,
wxPG_SPLITTER_ALL_PAGES = 0x0002,
wxPG_SPLITTER_FROM_EVENT = 0x0004,
wxPG_SPLITTER_FROM_AUTO_CENTER = 0x0008
};
// -----------------------------------------------------------------------
#ifndef SWIG
@@ -640,7 +653,9 @@ enum wxPG_KEYBOARD_ACTIONS
starts resizing a column - can be vetoed.
@event{EVT_PG_COL_DRAGGING,(id, func)}
Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
column resize by user is in progress.
column resize by user is in progress. This event is also generated
when user double-clicks the splitter in order to recenter
it.
@event{EVT_PG_COL_END_DRAG(id, func)}
Respond to wxEVT_PG_COL_END_DRAG event, generated after column
resize by user has finished.
@@ -662,6 +677,7 @@ class WXDLLIMPEXP_PROPGRID
friend class wxPropertyGridPageState;
friend class wxPropertyGridInterface;
friend class wxPropertyGridManager;
friend class wxPGHeaderCtrl;
DECLARE_DYNAMIC_CLASS(wxPropertyGrid)
public:
@@ -894,6 +910,9 @@ public:
/** Returns background colour of margin. */
wxColour GetMarginColour() const { return m_colMargin; }
/** Returns margin width. */
int GetMarginWidth() const { return m_marginWidth; }
/**
Returns most up-to-date value of selected property. This will return
value different from GetSelectedProperty()->GetValue() only when text
@@ -1176,10 +1195,9 @@ public:
during form creation may fail as initial grid size is often smaller
than desired splitter position, especially when sizers are being used.
*/
void SetSplitterPosition( int newxpos, int col = 0 )
void SetSplitterPosition( int newXPos, int col = 0 )
{
DoSetSplitterPosition_(newxpos, true, col);
m_pState->m_isSplitterPreSet = true;
DoSetSplitterPosition(newXPos, col, wxPG_SPLITTER_REFRESH);
}
/**
@@ -1994,6 +2012,10 @@ protected:
void DoSetSelection( const wxArrayPGProperty& newSelection,
int selFlags = 0 );
void DoSetSplitterPosition( int newxpos,
int splitterIndex = 0,
int flags = wxPG_SPLITTER_REFRESH );
bool DoAddToSelection( wxPGProperty* prop,
int selFlags = 0 );
@@ -2007,11 +2029,6 @@ protected:
wxPGProperty* DoGetItemAtY( int y ) const;
void DoSetSplitterPosition_( int newxpos,
bool refresh = true,
int splitterIndex = 0,
bool allPages = false );
void DestroyEditorWnd( wxWindow* wnd );
void FreeEditors();
@@ -2039,7 +2056,11 @@ protected:
void PrepareAfterItemsAdded();
// Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
/**
Send event from the property grid.
Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
*/
bool SendEvent( int eventType, wxPGProperty* p,
wxVariant* pValue = NULL,
unsigned int selFlags = wxPG_SEL_NOVALIDATE,

View File

@@ -463,8 +463,7 @@ public:
*/
virtual void DoSetSplitterPosition( int pos,
int splitterColumn = 0,
bool allPages = false,
bool fromAutoCenter = false );
int flags = 0 );
bool EnableCategories( bool enable );