2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/propgrid/manager.h
|
|
|
|
// Purpose: wxPropertyGridManager
|
|
|
|
// Author: Jaakko Salli
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2005-01-14
|
|
|
|
// Copyright: (c) Jaakko Salli
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_PROPGRID_MANAGER_H_
|
|
|
|
#define _WX_PROPGRID_MANAGER_H_
|
|
|
|
|
2010-08-26 09:25:07 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#if wxUSE_PROPGRID
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
#include "wx/propgrid/propgrid.h"
|
|
|
|
|
|
|
|
#include "wx/dcclient.h"
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/toolbar.h"
|
|
|
|
#include "wx/stattext.h"
|
|
|
|
#include "wx/button.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#include "wx/dialog.h"
|
2010-01-04 05:08:01 -05:00
|
|
|
#include "wx/headerctrl.h"
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2008-11-02 17:16:14 -05:00
|
|
|
extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridManagerNameStr[];
|
2008-09-12 16:57:41 -04:00
|
|
|
#endif
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Holder of property grid page information. You can subclass this and
|
|
|
|
// give instance in wxPropertyGridManager::AddPage. It inherits from
|
|
|
|
// wxEvtHandler and can be used to process events specific to this
|
|
|
|
// page (id of events will still be same as manager's). If you don't
|
|
|
|
// want to use it to process all events of the page, you need to
|
|
|
|
// return false in the derived wxPropertyGridPage::IsHandlingAllEvents.
|
|
|
|
//
|
|
|
|
// Please note that wxPropertyGridPage lacks many non-const property
|
|
|
|
// manipulation functions found in wxPropertyGridManager. Please use
|
|
|
|
// parent manager (m_manager member variable) when needed.
|
|
|
|
//
|
|
|
|
// Please note that most member functions are inherited and as such not
|
|
|
|
// documented on this page. This means you will probably also want to read
|
|
|
|
// wxPropertyGridInterface class reference.
|
|
|
|
//
|
|
|
|
// wxPropertyGridPage receives events emitted by its wxPropertyGridManager, but
|
|
|
|
// only those events that are specific to that page. If
|
|
|
|
// wxPropertyGridPage::IsHandlingAllEvents returns false, then unhandled
|
|
|
|
// events are sent to the manager's parent, as usual.
|
2008-09-12 16:57:41 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler,
|
|
|
|
public wxPropertyGridInterface,
|
|
|
|
public wxPropertyGridPageState
|
|
|
|
{
|
|
|
|
friend class wxPropertyGridManager;
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxPropertyGridPage);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
wxPropertyGridPage();
|
|
|
|
virtual ~wxPropertyGridPage();
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Deletes all properties on page.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Clear() wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Reduces column sizes to minimum possible that contents are still
|
|
|
|
// visibly (naturally some margin space will be applied as well).
|
|
|
|
// Returns minimum size for the page to still display everything.
|
|
|
|
// This function only works properly if size of containing grid was
|
|
|
|
// already fairly large.
|
|
|
|
// Note that you can also get calculated column widths by calling
|
|
|
|
// GetColumnWidth() immediately after this function returns.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxSize FitColumns();
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns page index in manager;
|
2008-09-12 16:57:41 -04:00
|
|
|
inline int GetIndex() const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns x-coordinate position of splitter on a page.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetSplitterPosition( int col = 0 ) const
|
|
|
|
{ return GetStatePtr()->DoGetSplitterPosition(col); }
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns "root property". It does not have name, etc. and it is not
|
|
|
|
// visible. It is only useful for accessing its children.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* GetRoot() const { return GetStatePtr()->DoGetRoot(); }
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns pointer to contained property grid state.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridPageState* GetStatePtr()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns pointer to contained property grid state.
|
2008-09-12 16:57:41 -04:00
|
|
|
const wxPropertyGridPageState* GetStatePtr() const
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns id of the tool bar item that represents this page on
|
|
|
|
// wxPropertyGridManager's wxToolBar.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetToolId() const
|
|
|
|
{
|
2010-12-27 06:17:40 -05:00
|
|
|
return m_toolId;
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Do any member initialization in this method.
|
|
|
|
// Notes:
|
|
|
|
// - Called every time the page is added into a manager.
|
|
|
|
// - You can add properties to the page here.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void Init() {}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Return false here to indicate unhandled events should be
|
|
|
|
// propagated to manager's parent, as normal.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual bool IsHandlingAllEvents() const { return true; }
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Called every time page is about to be shown.
|
|
|
|
// Useful, for instance, creating properties just-in-time.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void OnShow();
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Refreshes given property on page.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void RefreshProperty( wxPGProperty* p ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets splitter position on page.
|
|
|
|
// 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.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetSplitterPosition( int splitterPos, int col = 0 );
|
|
|
|
|
2015-01-13 11:41:33 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_3_0
|
2014-07-14 13:18:58 -04:00
|
|
|
// To avoid ambiguity between functions inherited
|
|
|
|
// from both wxPropertyGridInterface and wxPropertyGridPageState
|
|
|
|
using wxPropertyGridInterface::GetPropertyByLabel;
|
|
|
|
#endif // WXWIN_COMPATIBILITY_3_0
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
protected:
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Propagate to other pages.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void DoSetSplitterPosition( int pos,
|
|
|
|
int splitterColumn = 0,
|
2014-03-29 20:02:23 -04:00
|
|
|
int flags = wxPG_SPLITTER_REFRESH ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Page label (may be referred as name in some parts of documentation).
|
|
|
|
// Can be set in constructor, or passed in
|
|
|
|
// wxPropertyGridManager::AddPage(), but *not* in both.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxString m_label;
|
|
|
|
|
|
|
|
//virtual bool ProcessEvent( wxEvent& event );
|
|
|
|
|
|
|
|
wxPropertyGridManager* m_manager;
|
|
|
|
|
2010-12-27 06:17:40 -05:00
|
|
|
// Toolbar tool id. Note that this is only valid when the tool bar
|
|
|
|
// exists.
|
|
|
|
int m_toolId;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_isDefault; // is this base page object?
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-12-13 07:00:04 -05:00
|
|
|
#if wxUSE_HEADERCTRL
|
|
|
|
class wxPGHeaderCtrl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
|
|
|
|
// which can optionally have toolbar for mode and page selection, and help
|
|
|
|
// text box.
|
|
|
|
// Use window flags to select components to include.
|
2008-09-12 16:57:41 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID
|
|
|
|
wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxPropertyGridManager);
|
2008-09-12 16:57:41 -04:00
|
|
|
friend class wxPropertyGridPage;
|
|
|
|
public:
|
|
|
|
|
2009-05-30 07:20:35 -04:00
|
|
|
#ifndef SWIG
|
2016-07-23 17:38:39 -04:00
|
|
|
// Two step constructor.
|
|
|
|
// Call Create when this constructor is called to build up the
|
|
|
|
// wxPropertyGridManager.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridManager();
|
2009-05-30 07:20:35 -04:00
|
|
|
#endif
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// The default constructor. The styles to be used are styles valid for
|
|
|
|
// the wxWindow.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxPGMAN_DEFAULT_STYLE,
|
2008-11-02 17:16:14 -05:00
|
|
|
const wxString& name = wxPropertyGridManagerNameStr );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Destructor.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual ~wxPropertyGridManager();
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Creates new property page. Note that the first page is not created
|
|
|
|
// automatically.
|
|
|
|
// label - A label for the page. This may be shown as a toolbar tooltip etc.
|
|
|
|
// bmp - Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
|
|
|
// default image is used.
|
|
|
|
// pageObj - wxPropertyGridPage instance. Manager will take ownership of this object.
|
|
|
|
// NULL indicates that a default page instance should be created.
|
|
|
|
// Returns pointer to created page.
|
|
|
|
// If toolbar is used, it is highly recommended that the pages are
|
|
|
|
// added when the toolbar is not turned off using window style flag
|
|
|
|
// switching.
|
2008-09-25 13:19:49 -04:00
|
|
|
wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString,
|
2015-07-17 16:29:37 -04:00
|
|
|
const wxBitmap& bmp = wxNullBitmap,
|
2008-09-25 13:19:49 -04:00
|
|
|
wxPropertyGridPage* pageObj = NULL )
|
2008-09-12 16:57:41 -04:00
|
|
|
{
|
2008-09-25 13:19:49 -04:00
|
|
|
return InsertPage(-1, label, bmp, pageObj);
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Deletes all all properties and all pages.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Clear() wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Deletes all properties on given page.
|
2008-09-12 16:57:41 -04:00
|
|
|
void ClearPage( int page );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Forces updating the value of property from the editor control.
|
|
|
|
// Returns true if DoPropertyChanged was actually called.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool CommitChangesFromEditor( wxUint32 flags = 0 )
|
|
|
|
{
|
|
|
|
return m_pPropGrid->CommitChangesFromEditor(flags);
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Two step creation.
|
|
|
|
// Whenever the control is created without any parameters, use Create to
|
|
|
|
// actually create it. Don't access the control's public methods before
|
|
|
|
// this is called.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxPGMAN_DEFAULT_STYLE,
|
2008-11-02 17:16:14 -05:00
|
|
|
const wxString& name = wxPropertyGridManagerNameStr );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Enables or disables (shows/hides) categories according to parameter
|
|
|
|
// enable.
|
|
|
|
// Calling this may not properly update toolbar buttons.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool EnableCategories( bool enable )
|
|
|
|
{
|
|
|
|
long fl = m_windowStyle | wxPG_HIDE_CATEGORIES;
|
|
|
|
if ( enable ) fl = m_windowStyle & ~(wxPG_HIDE_CATEGORIES);
|
|
|
|
SetWindowStyleFlag(fl);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Selects page, scrolls and/or expands items to ensure that the
|
|
|
|
// given item is visible. Returns true if something was actually done.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool EnsureVisible( wxPGPropArg id );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns number of columns on given page. By the default,
|
|
|
|
// returns number of columns on current page.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetColumnCount( int page = -1 ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns height of the description text box.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetDescBoxHeight() const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns pointer to the contained wxPropertyGrid. This does not change
|
|
|
|
// after wxPropertyGridManager has been created, so you can safely obtain
|
|
|
|
// pointer once and use it for the entire lifetime of the manager instance.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGrid* GetGrid()
|
|
|
|
{
|
|
|
|
wxASSERT(m_pPropGrid);
|
|
|
|
return m_pPropGrid;
|
2014-03-31 03:08:06 -04:00
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
const wxPropertyGrid* GetGrid() const
|
|
|
|
{
|
|
|
|
wxASSERT(m_pPropGrid);
|
|
|
|
return (const wxPropertyGrid*)m_pPropGrid;
|
2014-03-31 03:08:06 -04:00
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns iterator class instance.
|
|
|
|
// Calling this method in wxPropertyGridManager causes run-time assertion
|
|
|
|
// failure. Please only iterate through individual pages or use
|
|
|
|
// CreateVIterator().
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT,
|
|
|
|
wxPGProperty* firstProp = NULL )
|
|
|
|
{
|
2015-06-12 17:39:00 -04:00
|
|
|
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
|
|
|
wxS("or use CreateVIterator()") );
|
2008-09-12 16:57:41 -04:00
|
|
|
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPropertyGridConstIterator
|
|
|
|
GetIterator(int flags = wxPG_ITERATE_DEFAULT,
|
|
|
|
wxPGProperty* firstProp = NULL) const
|
|
|
|
{
|
2015-06-12 17:39:00 -04:00
|
|
|
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
|
|
|
wxS("or use CreateVIterator()") );
|
2008-09-12 16:57:41 -04:00
|
|
|
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns iterator class instance.
|
|
|
|
// Calling this method in wxPropertyGridManager causes run-time assertion
|
|
|
|
// failure. Please only iterate through individual pages or use
|
|
|
|
// CreateVIterator().
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridIterator GetIterator( int flags, int startPos )
|
|
|
|
{
|
2015-06-12 17:39:00 -04:00
|
|
|
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
|
|
|
wxS("or use CreateVIterator()") );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
|
|
|
|
{
|
2015-06-12 17:39:00 -04:00
|
|
|
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
|
|
|
wxS("or use CreateVIterator()") );
|
2008-09-12 16:57:41 -04:00
|
|
|
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Similar to GetIterator, but instead returns wxPGVIterator instance,
|
|
|
|
// which can be useful for forward-iterating through arbitrary property
|
|
|
|
// containers.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxPGVIterator GetVIterator( int flags ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns currently selected page.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridPage* GetCurrentPage() const
|
|
|
|
{
|
|
|
|
return GetPage(m_selPage);
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns page object for given page index.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridPage* GetPage( unsigned int ind ) const
|
|
|
|
{
|
2008-09-30 13:23:27 -04:00
|
|
|
return m_arrPages[ind];
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns page object for given page name.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridPage* GetPage( const wxString& name ) const
|
|
|
|
{
|
|
|
|
return GetPage(GetPageByName(name));
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns index for a page name.
|
|
|
|
// If no match is found, wxNOT_FOUND is returned.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetPageByName( const wxString& name ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns index for a relevant propertygrid state.
|
|
|
|
// If no match is found, wxNOT_FOUND is returned.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetPageByState( const wxPropertyGridPageState* pstate ) const;
|
|
|
|
|
2008-11-16 13:20:21 -05:00
|
|
|
protected:
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns wxPropertyGridPageState of given page, current page's for -1.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxPropertyGridPageState* GetPageState( int page ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2008-11-16 13:20:21 -05:00
|
|
|
public:
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns number of managed pages.
|
2008-09-12 16:57:41 -04:00
|
|
|
size_t GetPageCount() const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns name of given page.
|
2008-09-12 16:57:41 -04:00
|
|
|
const wxString& GetPageName( int index ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns "root property" of the given page. It does not have name, etc.
|
|
|
|
// and it is not visible. It is only useful for accessing its children.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* GetPageRoot( int index ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns index to currently selected page.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetSelectedPage() const { return m_selPage; }
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Alias for GetSelection().
|
2008-10-12 07:29:41 -04:00
|
|
|
wxPGProperty* GetSelectedProperty() const
|
|
|
|
{
|
|
|
|
return GetSelection();
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Shortcut for GetGrid()->GetSelection().
|
2008-09-25 13:11:02 -04:00
|
|
|
wxPGProperty* GetSelection() const
|
2008-09-12 16:57:41 -04:00
|
|
|
{
|
|
|
|
return m_pPropGrid->GetSelection();
|
|
|
|
}
|
|
|
|
|
2016-02-25 15:37:26 -05:00
|
|
|
#if wxUSE_TOOLBAR
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns a pointer to the toolbar currently associated with the
|
|
|
|
// wxPropertyGridManager (if any).
|
2008-09-12 16:57:41 -04:00
|
|
|
wxToolBar* GetToolBar() const { return m_pToolbar; }
|
2016-02-25 15:37:26 -05:00
|
|
|
#endif // wxUSE_TOOLBAR
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Creates new property page. Note that the first page is not created
|
|
|
|
// automatically.
|
|
|
|
// index - Add to this position. -1 will add as the last item.
|
|
|
|
// label - A label for the page. This may be shown as a toolbar tooltip etc.
|
|
|
|
// bmp - Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
|
|
|
// default image is used.
|
|
|
|
// pageObj - wxPropertyGridPage instance. Manager will take ownership of this object.
|
|
|
|
// If NULL, default page object is constructed.
|
|
|
|
// Returns pointer to created page.
|
2008-09-25 13:19:49 -04:00
|
|
|
virtual wxPropertyGridPage* InsertPage( int index,
|
|
|
|
const wxString& label,
|
|
|
|
const wxBitmap& bmp = wxNullBitmap,
|
|
|
|
wxPropertyGridPage* pageObj = NULL );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns true if any property on any page has been modified by the user.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool IsAnyModified() const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns true if any property on given page has been modified by the
|
|
|
|
// user.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool IsPageModified( size_t index ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns true if property is selected. Since selection is page
|
|
|
|
// based, this function checks every page in the manager.
|
2009-08-17 14:36:00 -04:00
|
|
|
virtual bool IsPropertySelected( wxPGPropArg id ) const;
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void Refresh( bool eraseBackground = true,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxRect* rect = (const wxRect*) NULL ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Removes a page.
|
|
|
|
// Returns false if it was not possible to remove page in question.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual bool RemovePage( int page );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Select and displays a given page.
|
|
|
|
// index - Index of page being selected. Can be -1 to select nothing.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SelectPage( int index );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Select and displays a given page (by label).
|
2008-09-12 16:57:41 -04:00
|
|
|
void SelectPage( const wxString& label )
|
|
|
|
{
|
|
|
|
int index = GetPageByName(label);
|
2015-05-31 13:12:29 -04:00
|
|
|
wxCHECK_RET( index >= 0, wxS("No page with such name") );
|
2008-09-12 16:57:41 -04:00
|
|
|
SelectPage( index );
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Select and displays a given page.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SelectPage( wxPropertyGridPage* ptr )
|
|
|
|
{
|
|
|
|
SelectPage( GetPageByState(ptr) );
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Select a property.
|
2008-09-12 16:57:41 -04:00
|
|
|
bool SelectProperty( wxPGPropArg id, bool focus = false )
|
|
|
|
{
|
|
|
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
2015-06-29 14:03:25 -04:00
|
|
|
unsigned int flags = wxPG_SEL_DONT_SEND_EVENT;
|
|
|
|
if ( focus )
|
|
|
|
flags |= wxPG_SEL_FOCUS;
|
|
|
|
|
|
|
|
return p->GetParentState()->DoSelectProperty(p, flags);
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
2015-05-31 12:05:53 -04:00
|
|
|
#if wxUSE_HEADERCTRL
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets a column title. Default title for column 0 is "Property",
|
|
|
|
// and "Value" for column 1.
|
|
|
|
// If header is not shown yet, then calling this
|
|
|
|
// member function will make it visible.
|
2009-12-13 07:00:04 -05:00
|
|
|
void SetColumnTitle( int idx, const wxString& title );
|
2015-05-31 12:05:53 -04:00
|
|
|
#endif // wxUSE_HEADERCTRL
|
2009-12-13 07:00:04 -05:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets number of columns on given page (default is current page).
|
|
|
|
// 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.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetColumnCount( int colCount, int page = -1 );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets label and text in description box.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetDescription( const wxString& label, const wxString& content );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets y coordinate of the description box splitter.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetDescBoxHeight( int ht, bool refresh = true );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Moves splitter as left as possible, while still allowing all
|
|
|
|
// labels to be shown in full.
|
|
|
|
// subProps - If false, will still allow sub-properties (ie. properties which
|
|
|
|
// parent is not root or category) to be cropped.
|
|
|
|
// allPages - If true, takes labels on all pages into account.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetSplitterLeft( bool subProps = false, bool allPages = true );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Moves splitter as left as possible on an individual page, while still allowing all
|
|
|
|
// labels to be shown in full.
|
2012-03-18 16:35:01 -04:00
|
|
|
void SetPageSplitterLeft(int page, bool subProps = false);
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets splitter position on individual page.
|
|
|
|
// 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.
|
2009-12-13 07:00:04 -05:00
|
|
|
void SetPageSplitterPosition( int page, int pos, int column = 0 );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets splitter position for all pages.
|
|
|
|
// 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.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetSplitterPosition( int pos, int column = 0 );
|
|
|
|
|
2009-12-13 07:00:04 -05:00
|
|
|
#if wxUSE_HEADERCTRL
|
2016-07-23 17:38:39 -04:00
|
|
|
// Show or hide the property grid header control. It is hidden
|
|
|
|
// by the default.
|
|
|
|
// Grid may look better if you use wxPG_NO_INTERNAL_BORDER
|
|
|
|
// window style when showing a header.
|
2009-12-13 07:00:04 -05:00
|
|
|
void ShowHeader(bool show = true);
|
|
|
|
#endif
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
//
|
|
|
|
// Subclassing helpers
|
|
|
|
//
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Creates property grid for the manager. Reimplement in derived class to
|
|
|
|
// use subclassed wxPropertyGrid. However, if you do this then you
|
|
|
|
// must also use the two-step construction (i.e. default constructor and
|
|
|
|
// Create() instead of constructor with arguments) when creating the
|
|
|
|
// manager.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual wxPropertyGrid* CreatePropertyGrid() const;
|
|
|
|
|
|
|
|
public:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void RefreshProperty( wxPGProperty* p ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overridden functions - no documentation required.
|
|
|
|
//
|
|
|
|
|
2014-12-09 12:11:59 -05:00
|
|
|
void SetId( wxWindowID winid ) wxOVERRIDE;
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetExtraStyle ( long exStyle ) wxOVERRIDE;
|
|
|
|
virtual bool SetFont ( const wxFont& font ) wxOVERRIDE;
|
|
|
|
virtual void SetWindowStyleFlag ( long style ) wxOVERRIDE;
|
|
|
|
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoFreeze() wxOVERRIDE;
|
|
|
|
virtual void DoThaw() wxOVERRIDE;
|
2014-01-17 13:56:13 -05:00
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
//
|
|
|
|
// Event handlers
|
|
|
|
//
|
|
|
|
void OnMouseMove( wxMouseEvent &event );
|
|
|
|
void OnMouseClick( wxMouseEvent &event );
|
|
|
|
void OnMouseUp( wxMouseEvent &event );
|
|
|
|
void OnMouseEntry( wxMouseEvent &event );
|
|
|
|
|
|
|
|
void OnPaint( wxPaintEvent &event );
|
|
|
|
|
2014-12-03 12:01:35 -05:00
|
|
|
#if wxUSE_TOOLBAR
|
2008-09-12 16:57:41 -04:00
|
|
|
void OnToolbarClick( wxCommandEvent &event );
|
2014-12-03 12:01:35 -05:00
|
|
|
#endif
|
2008-09-12 16:57:41 -04:00
|
|
|
void OnResize( wxSizeEvent& event );
|
|
|
|
void OnPropertyGridSelect( wxPropertyGridEvent& event );
|
2019-01-07 14:14:35 -05:00
|
|
|
void OnPGScrollH(wxPropertyGridEvent& evt);
|
2019-04-27 15:53:49 -04:00
|
|
|
void OnColWidthsChanged(wxPropertyGridEvent& evt);
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
wxPropertyGrid* m_pPropGrid;
|
|
|
|
|
2008-09-30 13:23:27 -04:00
|
|
|
wxVector<wxPropertyGridPage*> m_arrPages;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
#if wxUSE_TOOLBAR
|
|
|
|
wxToolBar* m_pToolbar;
|
2009-12-13 07:00:04 -05:00
|
|
|
#endif
|
|
|
|
#if wxUSE_HEADERCTRL
|
|
|
|
wxPGHeaderCtrl* m_pHeaderCtrl;
|
2008-09-12 16:57:41 -04:00
|
|
|
#endif
|
|
|
|
wxStaticText* m_pTxtHelpCaption;
|
|
|
|
wxStaticText* m_pTxtHelpContent;
|
|
|
|
|
|
|
|
wxPropertyGridPage* m_emptyPage;
|
|
|
|
|
|
|
|
long m_iFlags;
|
|
|
|
|
|
|
|
// Selected page index.
|
|
|
|
int m_selPage;
|
|
|
|
|
|
|
|
int m_width;
|
|
|
|
|
|
|
|
int m_height;
|
|
|
|
|
|
|
|
int m_extraHeight;
|
|
|
|
|
|
|
|
int m_splitterY;
|
|
|
|
|
|
|
|
int m_splitterHeight;
|
|
|
|
|
|
|
|
int m_dragOffset;
|
|
|
|
|
|
|
|
wxCursor m_cursorSizeNS;
|
|
|
|
|
|
|
|
int m_nextDescBoxSize;
|
|
|
|
|
2010-12-27 06:17:40 -05:00
|
|
|
// Toolbar tool ids for categorized and alphabetic mode selectors.
|
|
|
|
int m_categorizedModeToolId;
|
|
|
|
int m_alphabeticModeToolId;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
unsigned char m_dragStatus;
|
|
|
|
|
2019-01-08 16:31:05 -05:00
|
|
|
bool m_onSplitter;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2009-12-13 07:00:04 -05:00
|
|
|
bool m_showHeader;
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Select and displays a given page.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoSelectPage( int index ) wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
// Sets some members to defaults.
|
|
|
|
void Init1();
|
|
|
|
|
|
|
|
// Initializes some members.
|
|
|
|
void Init2( int style );
|
|
|
|
|
|
|
|
/*#ifdef __WXMSW__
|
|
|
|
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const;
|
|
|
|
#endif*/
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool ProcessEvent( wxEvent& event ) wxOVERRIDE;
|
2009-01-25 06:58:39 -05:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Recalculates new positions for components, according to the
|
|
|
|
// given size.
|
2008-09-12 16:57:41 -04:00
|
|
|
void RecalculatePositions( int width, int height );
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// (Re)creates/destroys controls, according to the window style bits.
|
2008-09-12 16:57:41 -04:00
|
|
|
void RecreateControls();
|
|
|
|
|
2008-12-06 14:01:32 -05:00
|
|
|
void UpdateDescriptionBox( int new_splittery, int new_width, int new_height );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2009-02-07 08:35:26 -05:00
|
|
|
void RepaintDescBoxDecorations( wxDC& dc,
|
|
|
|
int newSplitterY,
|
|
|
|
int newWidth,
|
|
|
|
int newHeight );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
void SetDescribedProperty( wxPGProperty* p );
|
|
|
|
|
2008-10-04 06:59:06 -04:00
|
|
|
// Reimplement these to handle "descboxheight" state item
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) wxOVERRIDE;
|
|
|
|
virtual wxVariant GetEditableStateItem( const wxString& name ) const wxOVERRIDE;
|
2008-10-04 06:59:06 -04:00
|
|
|
|
2014-12-09 12:07:59 -05:00
|
|
|
// Reconnect propgrid event handlers.
|
|
|
|
void ReconnectEventHandlers(wxWindowID oldId, wxWindowID newId);
|
2008-09-12 16:57:41 -04:00
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline int wxPropertyGridPage::GetIndex() const
|
|
|
|
{
|
|
|
|
if ( !m_manager )
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
return m_manager->GetPageByState(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#endif // wxUSE_PROPGRID
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
#endif // _WX_PROPGRID_MANAGER_H_
|