added wxPropertyGrid from Jaakko Salli (#9934)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
278
interface/wx/propgrid/editors.h
Normal file
278
interface/wx/propgrid/editors.h
Normal file
@@ -0,0 +1,278 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: editors.h
|
||||
// Purpose: interface of wxPropertyGrid editors
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id:
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPGEditor
|
||||
|
||||
Base class for custom wxPropertyGrid editors.
|
||||
|
||||
@remarks
|
||||
- Names of builtin property editors are: TextCtrl, Choice,
|
||||
ComboBox, CheckBox, TextCtrlAndButton, and ChoiceAndButton. Additional editors
|
||||
include SpinCtrl and DatePickerCtrl, but using them requires calling
|
||||
wxPropertyGrid::RegisterAdditionalEditors() prior use.
|
||||
|
||||
- Pointer to builtin editor is available as wxPGEditor_EditorName
|
||||
(eg. wxPGEditor_TextCtrl).
|
||||
|
||||
- To add new editor you need to register it first using static function
|
||||
wxPropertyGrid::RegisterEditorClass(), with code like this:
|
||||
@code
|
||||
wxPGEditor* editorPointer = wxPropertyGrid::RegisterEditorClass(new MyEditorClass(), "MyEditor");
|
||||
@endcode
|
||||
After that, wxPropertyGrid will take ownership of the given object, but
|
||||
you should still store editorPointer somewhere, so you can pass it to
|
||||
wxPGProperty::SetEditor(), or return it from wxPGEditor::DoGetEditorClass().
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPGEditor : public wxObject
|
||||
{
|
||||
public:
|
||||
|
||||
/** Constructor. */
|
||||
wxPGEditor()
|
||||
: wxObject()
|
||||
{
|
||||
m_clientData = NULL;
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~wxPGEditor();
|
||||
|
||||
/** Returns pointer to the name of the editor. For example, wxPG_EDITOR(TextCtrl)
|
||||
has name "TextCtrl". This method is autogenerated for custom editors.
|
||||
*/
|
||||
virtual wxString GetName() const = 0;
|
||||
|
||||
/** Instantiates editor controls.
|
||||
@param propgrid
|
||||
wxPropertyGrid to which the property belongs (use as parent for control).
|
||||
@param property
|
||||
Property for which this method is called.
|
||||
@param pos
|
||||
Position, inside wxPropertyGrid, to create control(s) to.
|
||||
@param size
|
||||
Initial size for control(s).
|
||||
|
||||
@remarks
|
||||
- Primary control shall use id wxPG_SUBID1, and secondary (button) control
|
||||
shall use wxPG_SUBID2.
|
||||
- Implementation shoud use connect all necessary events to the
|
||||
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
||||
@code
|
||||
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
||||
// control to the OnEvent.
|
||||
// NOTE: This event in particular is actually automatically conveyed, but
|
||||
// it is just used as an example.
|
||||
propgrid->Connect( wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent) );
|
||||
@endcode
|
||||
OnCustomEditorEvent will then forward events, first to wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
|
||||
|
||||
*/
|
||||
virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
const wxPoint& pos, const wxSize& size ) const = 0;
|
||||
|
||||
/** Loads value from property to the control. */
|
||||
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const = 0;
|
||||
|
||||
/** Draws value for given property.
|
||||
*/
|
||||
virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
|
||||
|
||||
/** Handles events. Returns true if value in control was modified
|
||||
(see wxPGProperty::OnEvent for more information).
|
||||
*/
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd_primary, wxEvent& event ) const = 0;
|
||||
|
||||
/** Returns value from control, via parameter 'variant'.
|
||||
Usually ends up calling property's StringToValue or IntToValue.
|
||||
Returns true if value was different.
|
||||
*/
|
||||
virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const;
|
||||
|
||||
/** Sets value in control to unspecified. */
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property, wxWindow* ctrl ) const = 0;
|
||||
|
||||
/** Sets control's value specifically from string. */
|
||||
virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
|
||||
|
||||
/** Sets control's value specifically from int (applies to choice etc.). */
|
||||
virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
|
||||
|
||||
/** Inserts item to existing control. Index -1 means appending.
|
||||
Default implementation does nothing. Returns index of item added.
|
||||
*/
|
||||
virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
|
||||
|
||||
/** Deletes item from existing control.
|
||||
Default implementation does nothing.
|
||||
*/
|
||||
virtual void DeleteItem( wxWindow* ctrl, int index ) const;
|
||||
|
||||
/** Extra processing when control gains focus. For example, wxTextCtrl
|
||||
based controls should select all text.
|
||||
*/
|
||||
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
||||
|
||||
/** Returns true if control itself can contain the custom image. Default is
|
||||
to return false.
|
||||
*/
|
||||
virtual bool CanContainCustomImage() const;
|
||||
|
||||
//
|
||||
// This member is public so scripting language bindings
|
||||
// wrapper code can access it freely.
|
||||
void* m_clientData;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPGMultiButton
|
||||
|
||||
This class can be used to have multiple buttons in a property editor.
|
||||
You will need to create a new property editor class, override CreateControls,
|
||||
and have it return wxPGMultiButton instance in wxPGWindowList::SetSecondary().
|
||||
For instance, here we add three buttons to a textctrl editor:
|
||||
|
||||
@code
|
||||
|
||||
#include <wx/propgrid/editors.h>
|
||||
|
||||
class wxMultiButtonTextCtrlEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
WX_PG_DECLARE_EDITOR_CLASS(wxMultiButtonTextCtrlEditor)
|
||||
public:
|
||||
wxMultiButtonTextCtrlEditor() {}
|
||||
virtual ~wxMultiButtonTextCtrlEditor() {}
|
||||
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
virtual bool OnEvent( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
wxEvent& event ) const;
|
||||
|
||||
};
|
||||
|
||||
WX_PG_IMPLEMENT_EDITOR_CLASS(MultiButtonTextCtrlEditor, wxMultiButtonTextCtrlEditor,
|
||||
wxPGTextCtrlEditor)
|
||||
|
||||
wxPGWindowList wxMultiButtonTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sz ) const
|
||||
{
|
||||
// Create and populate buttons-subwindow
|
||||
wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
|
||||
|
||||
// Add two regular buttons
|
||||
buttons->Add( "..." );
|
||||
buttons->Add( "A" );
|
||||
// Add a bitmap button
|
||||
buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
|
||||
|
||||
// Create the 'primary' editor control (textctrl in this case)
|
||||
wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls
|
||||
( propGrid, property, pos, buttons->GetPrimarySize() );
|
||||
|
||||
// Finally, move buttons-subwindow to correct position and make sure
|
||||
// returned wxPGWindowList contains our custom button list.
|
||||
buttons->FinalizePosition(pos);
|
||||
|
||||
wndList.SetSecondary( buttons );
|
||||
return wndList;
|
||||
}
|
||||
|
||||
bool wxMultiButtonTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
wxEvent& event ) const
|
||||
{
|
||||
if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
|
||||
{
|
||||
wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
|
||||
|
||||
if ( event.GetId() == buttons->GetButtonId(0) )
|
||||
{
|
||||
// Do something when first button is pressed
|
||||
return true;
|
||||
}
|
||||
if ( event.GetId() == buttons->GetButtonId(1) )
|
||||
{
|
||||
// Do something when first button is pressed
|
||||
return true;
|
||||
}
|
||||
if ( event.GetId() == buttons->GetButtonId(2) )
|
||||
{
|
||||
// Do something when second button is pressed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
|
||||
}
|
||||
|
||||
@endcode
|
||||
|
||||
Further to use this editor, code like this can be used:
|
||||
|
||||
@code
|
||||
|
||||
// Register editor class - needs only to be called once
|
||||
wxPGRegisterEditorClass( MultiButtonTextCtrlEditor );
|
||||
|
||||
// Insert the property that will have multiple buttons
|
||||
propGrid->Append( new wxLongStringProperty("MultipleButtons", wxPG_LABEL) );
|
||||
|
||||
// Change property to use editor created in the previous code segment
|
||||
propGrid->SetPropertyEditor( "MultipleButtons", wxPG_EDITOR(MultiButtonTextCtrlEditor) );
|
||||
|
||||
@endcode
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGMultiButton : public wxWindow
|
||||
{
|
||||
public:
|
||||
|
||||
wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
|
||||
|
||||
virtual ~wxPGMultiButton() { }
|
||||
|
||||
wxWindow* GetButton( unsigned int i ) { return (wxWindow*) m_buttons[i]; }
|
||||
const wxWindow* GetButton( unsigned int i ) const { return (const wxWindow*) m_buttons[i]; }
|
||||
|
||||
/** Utility function to be used in event handlers.
|
||||
*/
|
||||
int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
|
||||
|
||||
/** Returns number of buttons.
|
||||
*/
|
||||
int GetCount() const { return m_buttons.Count(); }
|
||||
|
||||
void Add( const wxString& label, int id = -2 );
|
||||
void Add( const wxBitmap& bitmap, int id = -2 );
|
||||
|
||||
wxSize GetPrimarySize() const
|
||||
{
|
||||
return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
|
||||
}
|
||||
|
||||
void FinalizePosition( const wxPoint& pos )
|
||||
{
|
||||
Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_EDITORS_H_
|
475
interface/wx/propgrid/manager.h
Normal file
475
interface/wx/propgrid/manager.h
Normal file
@@ -0,0 +1,475 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: manager.h
|
||||
// Purpose: interface of wxPropertyGridManager
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id:
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** @class wxPropertyGridPage
|
||||
|
||||
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.
|
||||
|
||||
@section propgridpage_event_handling Event Handling
|
||||
|
||||
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.
|
||||
|
||||
See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
|
||||
for more information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler,
|
||||
public wxPropertyGridInterface
|
||||
{
|
||||
friend class wxPropertyGridManager;
|
||||
public:
|
||||
|
||||
wxPropertyGridPage();
|
||||
virtual ~wxPropertyGridPage();
|
||||
|
||||
/** Deletes all properties on page.
|
||||
*/
|
||||
virtual void Clear();
|
||||
|
||||
/** Reduces column sizes to minimum possible that contents are still visibly (naturally
|
||||
some margin space will be applied as well).
|
||||
|
||||
@retval
|
||||
Minimum size for the page to still display everything.
|
||||
|
||||
@remarks
|
||||
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.
|
||||
*/
|
||||
wxSize FitColumns();
|
||||
|
||||
/** Returns page index in manager;
|
||||
*/
|
||||
inline int GetIndex() const;
|
||||
|
||||
/** Returns x-coordinate position of splitter on a page.
|
||||
*/
|
||||
int GetSplitterPosition( int col = 0 ) const { return GetStatePtr()->DoGetSplitterPosition(col); }
|
||||
|
||||
/** Returns "root property". It does not have name, etc. and it is not
|
||||
visible. It is only useful for accessing its children.
|
||||
*/
|
||||
wxPGProperty* GetRoot() const { return GetStatePtr()->DoGetRoot(); }
|
||||
|
||||
/** Returns id of the tool bar item that represents this page on wxPropertyGridManager's wxToolBar.
|
||||
*/
|
||||
int GetToolId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/** Do any member initialization in this method.
|
||||
@remarks
|
||||
- Called every time the page is added into a manager.
|
||||
- You can add properties to the page here.
|
||||
*/
|
||||
virtual void Init() {}
|
||||
|
||||
/** Return false here to indicate unhandled events should be
|
||||
propagated to manager's parent, as normal.
|
||||
*/
|
||||
virtual bool IsHandlingAllEvents() const { return true; }
|
||||
|
||||
/** Called every time page is about to be shown.
|
||||
Useful, for instance, creating properties just-in-time.
|
||||
*/
|
||||
virtual void OnShow();
|
||||
|
||||
virtual void RefreshProperty( wxPGProperty* p );
|
||||
|
||||
/** Sets splitter position on page.
|
||||
@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.
|
||||
*/
|
||||
void SetSplitterPosition( int splitterPos, int col = 0 );
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPropertyGridManager
|
||||
|
||||
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.
|
||||
|
||||
@section propgridmanager_window_styles_ Window Styles
|
||||
|
||||
See @ref propgrid_window_styles.
|
||||
|
||||
@section propgridmanager_event_handling Event Handling
|
||||
|
||||
See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
|
||||
for more information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface
|
||||
{
|
||||
public:
|
||||
/** Creates new property page. Note that the first page is not created
|
||||
automatically.
|
||||
@param label
|
||||
A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
@param bmp
|
||||
Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
||||
default image is used.
|
||||
@param pageObj
|
||||
wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
NULL indicates that a default page instance should be created.
|
||||
@retval
|
||||
Returns index to the page created.
|
||||
@remarks
|
||||
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.
|
||||
*/
|
||||
int AddPage( const wxString& label = wxEmptyString,
|
||||
const wxBitmap& bmp = wxPG_NULL_BITMAP,
|
||||
wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL )
|
||||
{
|
||||
return InsertPage(-1,label,bmp,pageObj);
|
||||
}
|
||||
|
||||
void ClearModifiedStatus ( wxPGPropArg id );
|
||||
|
||||
void ClearModifiedStatus ()
|
||||
{
|
||||
m_pPropGrid->ClearModifiedStatus();
|
||||
}
|
||||
|
||||
/** Deletes all all properties and all pages.
|
||||
*/
|
||||
virtual void Clear();
|
||||
|
||||
/** Deletes all properties on given page.
|
||||
*/
|
||||
void ClearPage( int page );
|
||||
|
||||
/** Forces updating the value of property from the editor control.
|
||||
Returns true if DoPropertyChanged was actually called.
|
||||
*/
|
||||
bool CommitChangesFromEditor( wxUint32 flags = 0 )
|
||||
{
|
||||
return m_pPropGrid->CommitChangesFromEditor(flags);
|
||||
}
|
||||
|
||||
/** 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.
|
||||
@sa @link wndflags Additional Window Styles@endlink
|
||||
*/
|
||||
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxChar* name = wxPropertyGridManagerNameStr );
|
||||
|
||||
/** Enables or disables (shows/hides) categories according to parameter enable.
|
||||
WARNING: Not tested properly, use at your own risk.
|
||||
*/
|
||||
bool EnableCategories( bool enable )
|
||||
{
|
||||
long fl = m_windowStyle | wxPG_HIDE_CATEGORIES;
|
||||
if ( enable ) fl = m_windowStyle & ~(wxPG_HIDE_CATEGORIES);
|
||||
SetWindowStyleFlag(fl);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Selects page, scrolls and/or expands items to ensure that the
|
||||
given item is visible. Returns true if something was actually done.
|
||||
*/
|
||||
bool EnsureVisible( wxPGPropArg id );
|
||||
|
||||
/** Returns number of children of the root property of the selected page. */
|
||||
size_t GetChildrenCount()
|
||||
{
|
||||
return GetChildrenCount( m_pPropGrid->m_pState->m_properties );
|
||||
}
|
||||
|
||||
/** Returns number of children of the root property of given page. */
|
||||
size_t GetChildrenCount( int pageIndex );
|
||||
|
||||
/** Returns number of children for the property.
|
||||
|
||||
NB: Cannot be in container methods class due to name hiding.
|
||||
*/
|
||||
size_t GetChildrenCount( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
|
||||
return p->GetChildCount();
|
||||
}
|
||||
|
||||
/** Returns number of columns on given page. By the default,
|
||||
returns number of columns on current page. */
|
||||
int GetColumnCount( int page = -1 ) const;
|
||||
|
||||
/** Returns height of the description text box. */
|
||||
int GetDescBoxHeight() const;
|
||||
|
||||
/** 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 instance.
|
||||
*/
|
||||
wxPropertyGrid* GetGrid()
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return m_pPropGrid;
|
||||
};
|
||||
|
||||
const wxPropertyGrid* GetGrid() const
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return (const wxPropertyGrid*)m_pPropGrid;
|
||||
};
|
||||
|
||||
/** Returns iterator class instance.
|
||||
@remarks
|
||||
Calling this method in wxPropertyGridManager causes run-time assertion failure.
|
||||
Please only iterate through individual pages or use CreateVIterator().
|
||||
*/
|
||||
wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL )
|
||||
{
|
||||
wxFAIL_MSG(wxT("Please only iterate through individual pages or use CreateVIterator()"));
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL ) const
|
||||
{
|
||||
wxFAIL_MSG(wxT("Please only iterate through individual pages or use CreateVIterator()"));
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
/** Returns iterator class instance.
|
||||
@remarks
|
||||
Calling this method in wxPropertyGridManager causes run-time assertion failure.
|
||||
Please only iterate through individual pages or use CreateVIterator().
|
||||
*/
|
||||
wxPropertyGridIterator GetIterator( int flags, int startPos )
|
||||
{
|
||||
wxFAIL_MSG(wxT("Please only iterate through individual pages or use CreateVIterator()"));
|
||||
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
|
||||
{
|
||||
wxFAIL_MSG(wxT("Please only iterate through individual pages or use CreateVIterator()"));
|
||||
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
||||
}
|
||||
|
||||
/** Similar to GetIterator, but instead returns wxPGVIterator instance,
|
||||
which can be useful for forward-iterating through arbitrary property
|
||||
containers.
|
||||
*/
|
||||
virtual wxPGVIterator GetVIterator( int flags ) const;
|
||||
|
||||
/** Returns currently selected page.
|
||||
*/
|
||||
wxPropertyGridPage* GetCurrentPage() const
|
||||
{
|
||||
return GetPage(m_selPage);
|
||||
}
|
||||
|
||||
/** Returns last page.
|
||||
*/
|
||||
wxPropertyGridPage* GetLastPage() const
|
||||
{
|
||||
return GetPage(m_arrPages.size()-1);
|
||||
}
|
||||
|
||||
/** Returns page object for given page index.
|
||||
*/
|
||||
wxPropertyGridPage* GetPage( unsigned int ind ) const
|
||||
{
|
||||
return (wxPropertyGridPage*)m_arrPages.Item(ind);
|
||||
}
|
||||
|
||||
/** Returns page object for given page name.
|
||||
*/
|
||||
wxPropertyGridPage* GetPage( const wxString& name ) const
|
||||
{
|
||||
return GetPage(GetPageByName(name));
|
||||
}
|
||||
|
||||
/** Returns index for a page name. If no match is found, wxNOT_FOUND is returned. */
|
||||
int GetPageByName( const wxString& name ) const;
|
||||
|
||||
/** Returns number of managed pages. */
|
||||
size_t GetPageCount() const;
|
||||
|
||||
/** Returns name of given page. */
|
||||
const wxString& GetPageName( int index ) const;
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
wxPGProperty* GetPageRoot( int index ) const;
|
||||
|
||||
/** Returns index to currently selected page. */
|
||||
int GetSelectedPage() const { return m_selPage; }
|
||||
|
||||
/** Shortcut for GetGrid()->GetSelection(). */
|
||||
wxPGProperty* GetSelectedProperty() const
|
||||
{
|
||||
return m_pPropGrid->GetSelection();
|
||||
}
|
||||
|
||||
/** Synonyme for GetSelectedPage. */
|
||||
int GetSelection() const { return m_selPage; }
|
||||
|
||||
/** Returns a pointer to the toolbar currently associated with the
|
||||
wxPropertyGridManager (if any). */
|
||||
wxToolBar* GetToolBar() const { return m_pToolbar; }
|
||||
|
||||
/** Creates new property page. Note that the first page is not created
|
||||
automatically.
|
||||
@param index
|
||||
Add to this position. -1 will add as the last item.
|
||||
@param label
|
||||
A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
@param bmp
|
||||
Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
||||
default image is used.
|
||||
@param pageObj
|
||||
wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
If NULL, default page object is constructed.
|
||||
@retval
|
||||
Returns index to the page created.
|
||||
*/
|
||||
virtual int InsertPage( int index, const wxString& label, const wxBitmap& bmp = wxNullBitmap,
|
||||
wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL );
|
||||
|
||||
/** Returns true if any property on any page has been modified by the user. */
|
||||
bool IsAnyModified() const;
|
||||
|
||||
/** Returns true if updating is frozen (ie. Freeze() called but not yet Thaw() ). */
|
||||
bool IsFrozen() const { return (m_pPropGrid->m_frozen>0)?true:false; }
|
||||
|
||||
/** Returns true if any property on given page has been modified by the user. */
|
||||
bool IsPageModified( size_t index ) const;
|
||||
|
||||
virtual void Refresh( bool eraseBackground = true,
|
||||
const wxRect* rect = (const wxRect*) NULL );
|
||||
|
||||
/** Removes a page.
|
||||
@retval
|
||||
Returns false if it was not possible to remove page in question.
|
||||
*/
|
||||
virtual bool RemovePage( int page );
|
||||
|
||||
/** Select and displays a given page. Also makes it target page for
|
||||
insert operations etc.
|
||||
@param index
|
||||
Index of page being seleced. Can be -1 to select nothing.
|
||||
*/
|
||||
void SelectPage( int index );
|
||||
|
||||
/** Select and displays a given page (by label). */
|
||||
void SelectPage( const wxString& label )
|
||||
{
|
||||
int index = GetPageByName(label);
|
||||
wxCHECK_RET( index >= 0, wxT("No page with such name") );
|
||||
SelectPage( index );
|
||||
}
|
||||
|
||||
/** Select and displays a given page. */
|
||||
void SelectPage( wxPropertyGridPage* ptr )
|
||||
{
|
||||
SelectPage( GetPageByState(ptr) );
|
||||
}
|
||||
|
||||
/** Select a property. */
|
||||
bool SelectProperty( wxPGPropArg id, bool focus = false )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return p->GetParentState()->DoSelectProperty(p, focus);
|
||||
}
|
||||
|
||||
/** Sets number of columns on given page (default is current page).
|
||||
*/
|
||||
void SetColumnCount( int colCount, int page = -1 );
|
||||
|
||||
/** Sets label and text in description box.
|
||||
*/
|
||||
void SetDescription( const wxString& label, const wxString& content );
|
||||
|
||||
/** Sets y coordinate of the description box splitter. */
|
||||
void SetDescBoxHeight( int ht, bool refresh = true );
|
||||
|
||||
/** Sets property attribute for all applicapple properties.
|
||||
Be sure to use this method after all properties have been
|
||||
added to the grid.
|
||||
*/
|
||||
void SetPropertyAttributeAll( const wxString& name, wxVariant value );
|
||||
|
||||
/** Moves splitter as left as possible, while still allowing all
|
||||
labels to be shown in full.
|
||||
@param subProps
|
||||
If false, will still allow sub-properties (ie. properties which
|
||||
parent is not root or category) to be cropped.
|
||||
@param allPages
|
||||
If true, takes labels on all pages into account.
|
||||
*/
|
||||
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 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.
|
||||
*/
|
||||
void SetSplitterPosition( int pos, int column = 0 );
|
||||
|
||||
/** Synonyme for SelectPage(name). */
|
||||
void SetStringSelection( const wxChar* name )
|
||||
{
|
||||
SelectPage( GetPageByName(name) );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// Subclassing helpers
|
||||
//
|
||||
|
||||
/** Creates property grid for the manager. Override to use subclassed
|
||||
wxPropertyGrid.
|
||||
*/
|
||||
virtual wxPropertyGrid* CreatePropertyGrid() const;
|
||||
|
||||
virtual void RefreshProperty( wxPGProperty* p );
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
1558
interface/wx/propgrid/property.h
Normal file
1558
interface/wx/propgrid/property.h
Normal file
File diff suppressed because it is too large
Load Diff
839
interface/wx/propgrid/propgrid.h
Normal file
839
interface/wx/propgrid/propgrid.h
Normal file
@@ -0,0 +1,839 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: propgrid.h
|
||||
// Purpose: interface of wxPropertyGrid
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id:
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/** @section propgrid_window_styles wxPropertyGrid Window Styles
|
||||
|
||||
SetWindowStyleFlag method can be used to modify some of these at run-time.
|
||||
@{
|
||||
*/
|
||||
enum wxPG_WINDOW_STYLES
|
||||
{
|
||||
|
||||
/** This will cause Sort() automatically after an item is added.
|
||||
When inserting a lot of items in this mode, it may make sense to
|
||||
use Freeze() before operations and Thaw() afterwards to increase
|
||||
performance.
|
||||
*/
|
||||
wxPG_AUTO_SORT = 0x00000010,
|
||||
|
||||
/** Categories are not initially shown (even if added).
|
||||
IMPORTANT NOTE: If you do not plan to use categories, then this
|
||||
style will waste resources.
|
||||
This flag can also be changed using wxPropertyGrid::EnableCategories method.
|
||||
*/
|
||||
wxPG_HIDE_CATEGORIES = 0x00000020,
|
||||
|
||||
/* This style combines non-categoric mode and automatic sorting.
|
||||
*/
|
||||
wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
|
||||
|
||||
/** Modified values are shown in bold font. Changing this requires Refresh()
|
||||
to show changes.
|
||||
*/
|
||||
wxPG_BOLD_MODIFIED = 0x00000040,
|
||||
|
||||
/** When wxPropertyGrid is resized, splitter moves to the center. This
|
||||
behavior stops once the user manually moves the splitter.
|
||||
*/
|
||||
wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
|
||||
|
||||
/** Display tooltips for cell text that cannot be shown completely. If
|
||||
wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
|
||||
*/
|
||||
wxPG_TOOLTIPS = 0x00000100,
|
||||
|
||||
/** Disables margin and hides all expand/collapse buttons that would appear
|
||||
outside the margin (for sub-properties). Toggling this style automatically
|
||||
expands all collapsed items.
|
||||
*/
|
||||
wxPG_HIDE_MARGIN = 0x00000200,
|
||||
|
||||
/** This style prevents user from moving the splitter.
|
||||
*/
|
||||
wxPG_STATIC_SPLITTER = 0x00000400,
|
||||
|
||||
/** Combination of other styles that make it impossible for user to modify
|
||||
the layout.
|
||||
*/
|
||||
wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
|
||||
|
||||
/** Disables wxTextCtrl based editors for properties which
|
||||
can be edited in another way. Equals calling wxPropertyGrid::LimitPropertyEditing
|
||||
for all added properties.
|
||||
*/
|
||||
wxPG_LIMITED_EDITING = 0x00000800,
|
||||
|
||||
/** wxPropertyGridManager only: Show toolbar for mode and page selection. */
|
||||
wxPG_TOOLBAR = 0x00001000,
|
||||
|
||||
/** wxPropertyGridManager only: Show adjustable text box showing description
|
||||
or help text, if available, for currently selected property.
|
||||
*/
|
||||
wxPG_DESCRIPTION = 0x00002000
|
||||
|
||||
};
|
||||
|
||||
enum wxPG_EX_WINDOW_STYLES
|
||||
{
|
||||
|
||||
/**
|
||||
NOTE: wxPG_EX_xxx are extra window styles and must be set using SetExtraStyle()
|
||||
member function.
|
||||
|
||||
Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if wxPG_HIDE_CATEGORIES
|
||||
is not defined, the non-categorized data storage is not activated, and switching
|
||||
the mode first time becomes somewhat slower. wxPG_EX_INIT_NOCAT activates the
|
||||
non-categorized data storage right away. IMPORTANT NOTE: If you do plan not
|
||||
switching to non-categoric mode, or if you don't plan to use categories at
|
||||
all, then using this style will result in waste of resources.
|
||||
|
||||
*/
|
||||
wxPG_EX_INIT_NOCAT = 0x00001000,
|
||||
|
||||
/** Extended window style that sets wxPropertyGridManager toolbar to not
|
||||
use flat style.
|
||||
*/
|
||||
wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
|
||||
|
||||
/** Shows alphabetic/categoric mode buttons from toolbar.
|
||||
*/
|
||||
wxPG_EX_MODE_BUTTONS = 0x00008000,
|
||||
|
||||
/** Show property help strings as tool tips instead as text on the status bar.
|
||||
You can set the help strings using SetPropertyHelpString member function.
|
||||
*/
|
||||
wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
|
||||
|
||||
/** Prevent TAB from focusing to wxButtons. This behavior was default
|
||||
in version 1.2.0 and earlier.
|
||||
NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
|
||||
atleast the button doesn't properly propagate key events (yes, I'm using
|
||||
wxWANTS_CHARS).
|
||||
*/
|
||||
//wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
|
||||
|
||||
/** Allows relying on native double-buffering.
|
||||
*/
|
||||
wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
|
||||
|
||||
/** Set this style to let user have ability to set values of properties to
|
||||
unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
|
||||
all properties.
|
||||
*/
|
||||
wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
|
||||
|
||||
/** If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION and wxPG_STRING_PASSWORD)
|
||||
are not stored into property's attribute storage (thus they are not readable).
|
||||
|
||||
Note that this option is global, and applies to all wxPG property containers.
|
||||
*/
|
||||
wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
|
||||
|
||||
/** With this style Validators on properties will work same as in wxPropertyGrid 1.2.
|
||||
*/
|
||||
wxPG_EX_LEGACY_VALIDATORS = 0x00800000,
|
||||
|
||||
/** Hides page selection buttons from toolbar.
|
||||
*/
|
||||
wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000
|
||||
|
||||
};
|
||||
|
||||
/** Combines various styles.
|
||||
*/
|
||||
#define wxPG_DEFAULT_STYLE (0)
|
||||
|
||||
/** Combines various styles.
|
||||
*/
|
||||
#define wxPGMAN_DEFAULT_STYLE (0)
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** wxPropertyGrid Validation Failure Behavior Flags
|
||||
@{
|
||||
*/
|
||||
|
||||
enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
|
||||
{
|
||||
|
||||
/** Prevents user from leaving property unless value is valid. If this
|
||||
behavior flag is not used, then value change is instead cancelled.
|
||||
*/
|
||||
wxPG_VFB_STAY_IN_PROPERTY = 0x01,
|
||||
|
||||
/** Calls wxBell() on validation failure.
|
||||
*/
|
||||
wxPG_VFB_BEEP = 0x02,
|
||||
|
||||
/** Cell with invalid value will be marked (with red colour).
|
||||
*/
|
||||
wxPG_VFB_MARK_CELL = 0x04,
|
||||
|
||||
/** Display customizable text message explaining the situation.
|
||||
*/
|
||||
wxPG_VFB_SHOW_MESSAGE = 0x08,
|
||||
|
||||
/** Defaults. */
|
||||
wxPG_VFB_DEFAULT = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
|
||||
|
||||
/** Only used internally. */
|
||||
wxPG_VFB_UNDEFINED = 0x80
|
||||
|
||||
};
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
typedef wxByte wxPGVFBFlags;
|
||||
|
||||
/** wxPGValidationInfo
|
||||
|
||||
Used to convey validation information to and from functions that
|
||||
actually perform validation.
|
||||
*/
|
||||
struct wxPGValidationInfo
|
||||
{
|
||||
/** Value to be validated.
|
||||
*/
|
||||
wxVariant* m_pValue;
|
||||
|
||||
/** Message displayed on validation failure.
|
||||
*/
|
||||
wxString m_failureMessage;
|
||||
|
||||
/** Validation failure behavior. Use wxPG_VFB_XXX flags.
|
||||
*/
|
||||
wxPGVFBFlags m_failureBehavior;
|
||||
|
||||
wxPGVFBFlags GetFailureBehavior() const { return m_failureBehavior; }
|
||||
|
||||
void SetFailureBehavior(wxPGVFBFlags failureBehavior) { m_failureBehavior = failureBehavior; }
|
||||
|
||||
const wxString& GetFailureMessage() const { return m_failureMessage; }
|
||||
|
||||
void SetFailureMessage(const wxString& message) { m_failureMessage = message; }
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** wxPropertyGrid Action Identifiers
|
||||
These are used with wxPropertyGrid::AddActionTrigger() and wxPropertyGrid::ClearActionTriggers().
|
||||
@{
|
||||
*/
|
||||
|
||||
enum wxPG_KEYBOARD_ACTIONS
|
||||
{
|
||||
wxPG_ACTION_INVALID = 0,
|
||||
wxPG_ACTION_NEXT_PROPERTY,
|
||||
wxPG_ACTION_PREV_PROPERTY,
|
||||
wxPG_ACTION_EXPAND_PROPERTY,
|
||||
wxPG_ACTION_COLLAPSE_PROPERTY,
|
||||
wxPG_ACTION_CANCEL_EDIT,
|
||||
wxPG_ACTION_CUT,
|
||||
wxPG_ACTION_COPY,
|
||||
wxPG_ACTION_PASTE,
|
||||
wxPG_ACTION_MAX
|
||||
};
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPropertyGrid
|
||||
|
||||
wxPropertyGrid is a specialized grid for editing properties
|
||||
such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
|
||||
used to do the very same thing, but it hasn't been updated for a while
|
||||
and it is currently deprecated.
|
||||
|
||||
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.
|
||||
|
||||
See also @ref overview_propgrid.
|
||||
|
||||
@section propgrid_window_styles_ Window Styles
|
||||
|
||||
See @ref propgrid_window_styles.
|
||||
|
||||
@section propgrid_event_handling Event Handling
|
||||
|
||||
To process input from a propertygrid control, use these event handler macros to
|
||||
direct input to member functions that take a wxPropertyGridEvent argument.
|
||||
|
||||
@beginEventTable{wxPropertyGridEvent}
|
||||
@event{EVT_PG_SELECTED (id, func)}
|
||||
Respond to wxEVT_PG_SELECTED event, generated when property value
|
||||
has been changed by user.
|
||||
@event{EVT_PG_CHANGING(id, func)}
|
||||
Respond to wxEVT_PG_CHANGING event, generated when property value
|
||||
is about to be changed by user. Use wxPropertyGridEvent::GetValue()
|
||||
to take a peek at the pending value, and wxPropertyGridEvent::Veto()
|
||||
to prevent change from taking place, if necessary.
|
||||
@event{EVT_PG_HIGHLIGHTED(id, func)}
|
||||
Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
|
||||
moves over a property. Event's property is NULL if hovered area does
|
||||
not belong to any property.
|
||||
@event{EVT_PG_RIGHT_CLICK(id, func)}
|
||||
Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
|
||||
clicked on with right mouse button.
|
||||
@event{EVT_PG_DOUBLE_CLICK(id, func)}
|
||||
Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
|
||||
double-clicked onwith left mouse button.
|
||||
@event{EVT_PG_ITEM_COLLAPSED(id, func)}
|
||||
Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
|
||||
a property or category..
|
||||
@event{EVT_PG_ITEM_EXPANDED(id, func)}
|
||||
Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
|
||||
a property or category..
|
||||
@endEventTable
|
||||
|
||||
@remarks
|
||||
|
||||
- Use Freeze() and Thaw() respectively to disable and enable drawing. This
|
||||
will also delay sorting etc. miscellaneous calculations to the last possible
|
||||
moment.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Two step constructor. Call Create when this constructor is called to build up the
|
||||
wxPropertyGrid
|
||||
*/
|
||||
wxPropertyGrid();
|
||||
|
||||
/** The default constructor. The styles to be used are styles valid for
|
||||
the wxWindow and wxScrolledWindow.
|
||||
@sa @link wndflags Additional Window Styles@endlink
|
||||
*/
|
||||
wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPG_DEFAULT_STYLE,
|
||||
const wxChar* name = wxPropertyGridNameStr );
|
||||
|
||||
/** Destructor */
|
||||
virtual ~wxPropertyGrid();
|
||||
|
||||
/** Adds given key combination to trigger given action.
|
||||
@param action
|
||||
Which action to trigger. See @link pgactions List of list of wxPropertyGrid actions@endlink.
|
||||
*/
|
||||
void AddActionTrigger( int action, int keycode, int modifiers = 0 );
|
||||
|
||||
/** This static function enables or disables automatic use of wxGetTranslation for
|
||||
following strings: wxEnumProperty list labels, wxFlagsProperty sub-property
|
||||
labels.
|
||||
Default is false.
|
||||
*/
|
||||
static void AutoGetTranslation( bool enable );
|
||||
|
||||
/** Changes value of a property, as if from an editor. Use this instead of SetPropertyValue()
|
||||
if you need the value to run through validation process, and also send the property
|
||||
change event.
|
||||
|
||||
@return
|
||||
Returns true if value was successfully changed.
|
||||
*/
|
||||
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
|
||||
|
||||
/** Centers the splitter. If argument is true, automatic splitter centering is
|
||||
enabled (only applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
|
||||
*/
|
||||
void CenterSplitter( bool enable_auto_centering = false );
|
||||
|
||||
/** Deletes all properties.
|
||||
*/
|
||||
virtual void Clear();
|
||||
|
||||
/** Clears action triggers for given action.
|
||||
@param action
|
||||
Which action to trigger. See @link pgactions List of list of wxPropertyGrid actions@endlink.
|
||||
*/
|
||||
void ClearActionTriggers( int action );
|
||||
|
||||
/** Forces updating the value of property from the editor control.
|
||||
Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using ProcessEvent,
|
||||
meaning your event handlers will be called immediately.
|
||||
|
||||
@retval
|
||||
Returns true if anything was changed.
|
||||
*/
|
||||
virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
|
||||
|
||||
/** 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
|
||||
@sa @link wndflags Additional Window Styles@endlink
|
||||
*/
|
||||
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPG_DEFAULT_STYLE,
|
||||
const wxChar* name = wxPropertyGridNameStr );
|
||||
|
||||
/** Call when editor widget's contents is modified. For example, this is called
|
||||
when changes text in wxTextCtrl (used in wxStringProperty and wxIntProperty).
|
||||
|
||||
@remarks
|
||||
This function should only be called by custom properties.
|
||||
|
||||
@see wxPGProperty::OnEvent()
|
||||
*/
|
||||
void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
|
||||
|
||||
/** Reverse of EditorsValueWasModified().
|
||||
|
||||
@remarks
|
||||
This function should only be called by custom properties.
|
||||
*/
|
||||
void EditorsValueWasNotModified()
|
||||
{
|
||||
m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
|
||||
}
|
||||
|
||||
/** Enables or disables (shows/hides) categories according to parameter enable. */
|
||||
bool EnableCategories( bool enable );
|
||||
|
||||
/** Scrolls and/or expands items to ensure that the given item is visible.
|
||||
Returns true if something was actually done.
|
||||
*/
|
||||
bool EnsureVisible( wxPGPropArg id );
|
||||
|
||||
/** Reduces column sizes to minimum possible that contents are still visibly (naturally
|
||||
some margin space will be applied as well).
|
||||
|
||||
@return
|
||||
Minimum size for the grid to still display everything.
|
||||
|
||||
@remarks
|
||||
Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
|
||||
|
||||
This function only works properly if grid size prior to call was already
|
||||
fairly large.
|
||||
|
||||
Note that you can also get calculated column widths by calling GetState->GetColumnWidth()
|
||||
immediately after this function returns.
|
||||
*/
|
||||
wxSize FitColumns()
|
||||
{
|
||||
wxSize sz = m_pState->DoFitColumns();
|
||||
return sz;
|
||||
}
|
||||
|
||||
/** Returns wxWindow that the properties are painted on, and which should be used
|
||||
as the parent for editor controls.
|
||||
*/
|
||||
wxPanel* GetPanel() const
|
||||
{
|
||||
return m_canvas;
|
||||
}
|
||||
|
||||
/** Returns current category caption background colour. */
|
||||
wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
|
||||
|
||||
wxFont& GetCaptionFont() { return m_captionFont; }
|
||||
|
||||
const wxFont& GetCaptionFont() const { return m_captionFont; }
|
||||
|
||||
/** Returns current category caption text colour. */
|
||||
wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
|
||||
|
||||
/** Returns current cell background colour. */
|
||||
wxColour GetCellBackgroundColour() const { return m_colPropBack; }
|
||||
|
||||
/** Returns current cell text colour when disabled. */
|
||||
wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
|
||||
|
||||
/** Returns current cell text colour. */
|
||||
wxColour GetCellTextColour() const { return m_colPropFore; }
|
||||
|
||||
/** Returns number of columns on current page. */
|
||||
int GetColumnCount() const
|
||||
{
|
||||
return m_pState->m_colWidths.size();
|
||||
}
|
||||
|
||||
/** Returns colour of empty space below properties. */
|
||||
wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
|
||||
|
||||
/** Returns height of highest characters of used font. */
|
||||
int GetFontHeight() const { return m_fontHeight; }
|
||||
|
||||
/** Returns pointer to itself. Dummy function that enables same kind
|
||||
of code to use wxPropertyGrid and wxPropertyGridManager.
|
||||
*/
|
||||
wxPropertyGrid* GetGrid() { return this; }
|
||||
|
||||
/** Returns rectangle of custom paint image.
|
||||
*/
|
||||
wxRect GetImageRect( wxPGProperty* p, int item ) const;
|
||||
|
||||
/** Returns size of the custom paint image in front of property.
|
||||
If no argument is given, returns preferred size.
|
||||
*/
|
||||
wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
|
||||
|
||||
//@{
|
||||
/** Returns last item which could be iterated using given flags.
|
||||
@param flags
|
||||
See @ref propgrid_iterator_flags.
|
||||
*/
|
||||
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
|
||||
{
|
||||
return m_pState->GetLastItem(flags);
|
||||
}
|
||||
|
||||
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
|
||||
{
|
||||
return m_pState->GetLastItem(flags);
|
||||
}
|
||||
//@}
|
||||
|
||||
/** Returns colour of lines between cells. */
|
||||
wxColour GetLineColour() const { return m_colLine; }
|
||||
|
||||
/** Returns background colour of margin. */
|
||||
wxColour GetMarginColour() const { return m_colMargin; }
|
||||
|
||||
/** Returns cell background colour of a property. */
|
||||
wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const;
|
||||
|
||||
/** Returns cell background colour of a property. */
|
||||
wxColour GetPropertyTextColour( wxPGPropArg id ) const;
|
||||
|
||||
/** Returns "root property". It does not have name, etc. and it is not
|
||||
visible. It is only useful for accessing its children.
|
||||
*/
|
||||
wxPGProperty* GetRoot() const { return m_pState->m_properties; }
|
||||
|
||||
/** Returns height of a single grid row (in pixels). */
|
||||
int GetRowHeight() const { return m_lineHeight; }
|
||||
|
||||
/** Returns currently selected property. */
|
||||
wxPGProperty* GetSelectedProperty () const { return GetSelection(); }
|
||||
|
||||
/** Returns currently selected property. */
|
||||
wxPGProperty* GetSelection() const
|
||||
{
|
||||
return m_selected;
|
||||
}
|
||||
|
||||
/** Returns current selection background colour. */
|
||||
wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
|
||||
|
||||
/** Returns current selection text colour. */
|
||||
wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
|
||||
|
||||
/** Returns current splitter x position. */
|
||||
int GetSplitterPosition() const { return m_pState->DoGetSplitterPosition(0); }
|
||||
|
||||
/** Returns wxTextCtrl active in currently selected property, if any. Takes
|
||||
into account wxOwnerDrawnComboBox.
|
||||
*/
|
||||
wxTextCtrl* GetEditorTextCtrl() const;
|
||||
|
||||
wxPGValidationInfo& GetValidationInfo()
|
||||
{
|
||||
return m_validationInfo;
|
||||
}
|
||||
|
||||
/** Returns current vertical spacing. */
|
||||
int GetVerticalSpacing() const { return (int)m_vspacing; }
|
||||
|
||||
/** Returns true if editor's value was marked modified.
|
||||
*/
|
||||
bool IsEditorsValueModified() const { return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
|
||||
|
||||
/** Returns information about arbitrary position in the grid.
|
||||
*/
|
||||
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
|
||||
|
||||
/** Returns true if any property has been modified by the user. */
|
||||
bool IsAnyModified() const { return (m_pState->m_anyModified>0); }
|
||||
|
||||
/** Returns true if updating is frozen (ie. Freeze() called but not yet Thaw() ). */
|
||||
bool IsFrozen() const { return (m_frozen>0)?true:false; }
|
||||
|
||||
/** Redraws given property.
|
||||
*/
|
||||
virtual void RefreshProperty( wxPGProperty* p );
|
||||
|
||||
/** Registers a new editor class.
|
||||
@retval
|
||||
Pointer to the editor class instance that should be used.
|
||||
*/
|
||||
static wxPGEditor* RegisterEditorClass( wxPGEditor* editor, const wxString& name,
|
||||
bool noDefCheck = false );
|
||||
|
||||
/** Resets all colours to the original system values.
|
||||
*/
|
||||
void ResetColours();
|
||||
|
||||
/** Selects a property. Editor widget is automatically created, but
|
||||
not focused unless focus is true. This will generate wxEVT_PG_SELECT event.
|
||||
@param id
|
||||
Property to select.
|
||||
@retval
|
||||
True if selection finished successfully. Usually only fails if current
|
||||
value in editor is not valid.
|
||||
@sa wxPropertyGrid::Unselect
|
||||
*/
|
||||
bool SelectProperty( wxPGPropArg id, bool focus = false )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return DoSelectProperty(p,focus?wxPG_SEL_FOCUS:0);
|
||||
}
|
||||
|
||||
/** Changes keyboard shortcut to push the editor button.
|
||||
@remarks
|
||||
You can set default with keycode 0. Good value for the platform is guessed,
|
||||
but don't expect it to be very accurate.
|
||||
*/
|
||||
void SetButtonShortcut( int keycode, bool ctrlDown = false, bool altDown = false );
|
||||
|
||||
/** Sets category caption background colour. */
|
||||
void SetCaptionBackgroundColour(const wxColour& col);
|
||||
|
||||
/** Sets category caption text colour. */
|
||||
void SetCaptionTextColour(const wxColour& col);
|
||||
|
||||
/** Sets default cell background colour - applies to property cells.
|
||||
Note that appearance of editor widgets may not be affected.
|
||||
*/
|
||||
void SetCellBackgroundColour(const wxColour& col);
|
||||
|
||||
/** Sets cell text colour for disabled properties.
|
||||
*/
|
||||
void SetCellDisabledTextColour(const wxColour& col);
|
||||
|
||||
/** Sets default cell text colour - applies to property name and value text.
|
||||
Note that appearance of editor widgets may not be affected.
|
||||
*/
|
||||
void SetCellTextColour(const wxColour& col);
|
||||
|
||||
/** Set number of columns (2 or more).
|
||||
*/
|
||||
void SetColumnCount( int colCount )
|
||||
{
|
||||
m_pState->SetColumnCount(colCount);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/** Sets the 'current' category - Append will add non-category properties under it.
|
||||
*/
|
||||
void SetCurrentCategory( wxPGPropArg id );
|
||||
|
||||
/** Sets colour of empty space below properties. */
|
||||
void SetEmptySpaceColour(const wxColour& col);
|
||||
|
||||
/** Sets colour of lines between cells. */
|
||||
void SetLineColour(const wxColour& col);
|
||||
|
||||
/** Sets background colour of margin. */
|
||||
void SetMarginColour(const wxColour& col);
|
||||
|
||||
/** Sets property attribute for all applicapple properties.
|
||||
Be sure to use this method only after all properties have been
|
||||
added to the grid.
|
||||
*/
|
||||
void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
|
||||
|
||||
/** Sets background colour of property and all its children. Colours of
|
||||
captions are not affected. Background brush cache is optimized for often
|
||||
set colours to be set last.
|
||||
*/
|
||||
void SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& col );
|
||||
|
||||
/** Resets text and background colours of given property.
|
||||
*/
|
||||
void SetPropertyColoursToDefault( wxPGPropArg id );
|
||||
|
||||
/** Sets text colour of property and all its children.
|
||||
*/
|
||||
void SetPropertyTextColour( wxPGPropArg id, const wxColour& col, bool recursively = true );
|
||||
|
||||
/** Sets selection background colour - applies to selected property name background. */
|
||||
void SetSelectionBackgroundColour(const wxColour& col);
|
||||
|
||||
/** Sets selection foreground colour - applies to selected property name text. */
|
||||
void SetSelectionTextColour(const wxColour& col);
|
||||
|
||||
/** Sets x coordinate of the splitter.
|
||||
@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.
|
||||
*/
|
||||
void SetSplitterPosition( int newxpos, int col = 0 )
|
||||
{
|
||||
DoSetSplitterPosition_(newxpos, true, col);
|
||||
m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
|
||||
}
|
||||
|
||||
/** Set virtual width for this particular page. Width -1 indicates that the
|
||||
virtual width should be disabled. */
|
||||
void SetVirtualWidth( int width );
|
||||
|
||||
/** Sets name of a property.
|
||||
@param id
|
||||
Name or pointer of property which name to change.
|
||||
@param newname
|
||||
New name.
|
||||
*/
|
||||
void SetPropertyName( wxPGPropArg id, const wxString& newname )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
DoSetPropertyName( p, newname );
|
||||
}
|
||||
|
||||
/** Moves splitter as left as possible, while still allowing all
|
||||
labels to be shown in full.
|
||||
@param subProps
|
||||
If false, will still allow sub-properties (ie. properties which
|
||||
parent is not root or category) to be cropped.
|
||||
*/
|
||||
void SetSplitterLeft( bool subProps = false )
|
||||
{
|
||||
m_pState->SetSplitterLeft(subProps);
|
||||
}
|
||||
|
||||
/** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
|
||||
height. Value of 2 should be default on most platforms.
|
||||
@remarks
|
||||
On wxMSW, wxComboBox, when used as property editor widget, will spill
|
||||
out with anything less than 3.
|
||||
*/
|
||||
void SetVerticalSpacing( int vspacing )
|
||||
{
|
||||
m_vspacing = (unsigned char)vspacing;
|
||||
CalculateFontAndBitmapStuff( vspacing );
|
||||
if ( !m_pState->m_itemsAdded ) Refresh();
|
||||
}
|
||||
|
||||
/** Shows an brief error message that is related to a property. */
|
||||
void ShowPropertyError( wxPGPropArg id, const wxString& msg )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
DoShowPropertyError(p, msg);
|
||||
}
|
||||
|
||||
/** Sorts all items at all levels (except sub-properties). */
|
||||
void Sort();
|
||||
|
||||
/** Sorts children of a category.
|
||||
*/
|
||||
void SortChildren( wxPGPropArg id );
|
||||
};
|
||||
|
||||
|
||||
/** @class wxPropertyGridEvent
|
||||
|
||||
A propertygrid event holds information about events associated with
|
||||
wxPropertyGrid objects.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPropertyGridEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
|
||||
/** Constructor. */
|
||||
wxPropertyGridEvent(wxEventType commandType=0, int id=0);
|
||||
|
||||
/** Copy constructor. */
|
||||
wxPropertyGridEvent(const wxPropertyGridEvent& event);
|
||||
|
||||
/** Destructor. */
|
||||
~wxPropertyGridEvent();
|
||||
|
||||
/** Copyer. */
|
||||
virtual wxEvent* Clone() const;
|
||||
|
||||
wxPGProperty* GetMainParent() const
|
||||
{
|
||||
wxASSERT(m_property);
|
||||
return m_property->GetMainParent();
|
||||
}
|
||||
|
||||
/** Returns id of associated property. */
|
||||
wxPGProperty* GetProperty() const
|
||||
{
|
||||
return m_property;
|
||||
}
|
||||
|
||||
wxPGValidationInfo& GetValidationInfo()
|
||||
{
|
||||
wxASSERT(m_validationInfo);
|
||||
return *m_validationInfo;
|
||||
}
|
||||
|
||||
/** Returns true if event has associated property. */
|
||||
bool HasProperty() const { return ( m_property != (wxPGProperty*) NULL ); }
|
||||
|
||||
/** Returns true if you can veto the action that the event is signaling.
|
||||
*/
|
||||
bool CanVeto() const { return m_canVeto; }
|
||||
|
||||
/** Call this from your event handler to veto action that the event is signaling.
|
||||
You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns true.
|
||||
@remarks
|
||||
Currently only wxEVT_PG_CHANGING supports vetoing.
|
||||
*/
|
||||
void Veto( bool veto = true ) { m_wasVetoed = veto; }
|
||||
|
||||
/** Returns value that is about to be set for wxEVT_PG_CHANGING.
|
||||
*/
|
||||
const wxVariant& GetValue() const
|
||||
{
|
||||
wxASSERT_MSG( m_validationInfo,
|
||||
wxT("Only call GetValue from a handler of event type that supports it") );
|
||||
return *m_validationInfo->m_pValue;
|
||||
}
|
||||
|
||||
/** Set override validation failure behavior. Only effective if Veto was also called,
|
||||
and only allowed if event type is wxEVT_PG_CHANGING.
|
||||
*/
|
||||
void SetValidationFailureBehavior( int flags )
|
||||
{
|
||||
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
|
||||
m_validationInfo->m_failureBehavior = (wxPGVFBFlags) flags;
|
||||
}
|
||||
|
||||
/** Sets custom failure message for this time only. Only applies if
|
||||
wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
|
||||
*/
|
||||
void SetValidationFailureMessage( const wxString& message )
|
||||
{
|
||||
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
|
||||
m_validationInfo->m_failureMessage = message;
|
||||
}
|
||||
|
||||
wxPGVFBFlags GetValidationFailureBehavior() const
|
||||
{
|
||||
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
|
||||
return m_validationInfo->m_failureBehavior;
|
||||
}
|
||||
|
||||
void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
|
||||
bool WasVetoed() const { return m_wasVetoed; }
|
||||
|
||||
/** Changes the associated property. */
|
||||
void SetProperty( wxPGProperty* p ) { m_property = p; }
|
||||
|
||||
void SetPropertyGrid( wxPropertyGrid* pg ) { m_pg = pg; }
|
||||
};
|
992
interface/wx/propgrid/propgridiface.h
Normal file
992
interface/wx/propgrid/propgridiface.h
Normal file
@@ -0,0 +1,992 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: property.h
|
||||
// Purpose: interface of wxPGProperty
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id:
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPropertyGridInterface
|
||||
|
||||
Most of the shared property manipulation interface shared by wxPropertyGrid,
|
||||
wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
|
||||
|
||||
@remarks
|
||||
- In separate wxPropertyGrid component this class was known as wxPropertyContainerMethods.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Destructor */
|
||||
virtual ~wxPropertyGridInterface() { }
|
||||
|
||||
/** Adds choice to a property that can accept one.
|
||||
@remarks
|
||||
- If you need to make sure that you modify only the set of choices of
|
||||
a single property (and not also choices of other properties with initially
|
||||
identical set), call wxPropertyGrid::SetPropertyChoicesPrivate.
|
||||
- This usually only works for wxEnumProperty and derivatives (wxFlagsProperty
|
||||
can get accept new items but its items may not get updated).
|
||||
*/
|
||||
void AddPropertyChoice( wxPGPropArg id, const wxString& label, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
/** Appends property to the list. wxPropertyGrid assumes ownership of the object.
|
||||
Becomes child of most recently added category.
|
||||
@remarks
|
||||
- wxPropertyGrid takes the ownership of the property pointer.
|
||||
- If appending a category with name identical to a category already in the
|
||||
wxPropertyGrid, then newly created category is deleted, and most recently
|
||||
added category (under which properties are appended) is set to the one with
|
||||
same name. This allows easier adding of items to same categories in multiple
|
||||
passes.
|
||||
- Does not automatically redraw the control, so you may need to call Refresh
|
||||
when calling this function after control has been shown for the first time.
|
||||
*/
|
||||
wxPGProperty* Append( wxPGProperty* property );
|
||||
|
||||
wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty );
|
||||
|
||||
/** Inorder to add new items into a property with fixed children (for instance, wxFlagsProperty),
|
||||
you need to call this method. After populating has been finished, you need to call EndAddChildren.
|
||||
*/
|
||||
void BeginAddChildren( wxPGPropArg id );
|
||||
|
||||
/** Deletes all properties.
|
||||
*/
|
||||
virtual void Clear() = 0;
|
||||
|
||||
/** Deselect current selection, if any. Returns true if success
|
||||
(ie. validator did not intercept). */
|
||||
bool ClearSelection();
|
||||
|
||||
/** Resets modified status of all properties.
|
||||
*/
|
||||
void ClearModifiedStatus()
|
||||
{
|
||||
SetPropertyModifiedStatus(m_pState->m_properties, false);
|
||||
m_pState->m_anyModified = false;
|
||||
}
|
||||
|
||||
/** Collapses given category or property with children.
|
||||
Returns true if actually collapses.
|
||||
*/
|
||||
bool Collapse( wxPGPropArg id );
|
||||
|
||||
/** Collapses all items that can be collapsed.
|
||||
|
||||
@retval
|
||||
Return false if failed (may fail if editor value cannot be validated).
|
||||
*/
|
||||
bool CollapseAll() { return ExpandAll(false); }
|
||||
|
||||
/** Changes value of a property, as if from an editor. Use this instead of SetPropertyValue()
|
||||
if you need the value to run through validation process, and also send the property
|
||||
change event.
|
||||
|
||||
@retval
|
||||
Returns true if value was successfully changed.
|
||||
*/
|
||||
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
|
||||
|
||||
/** Resets value of a property to its default. */
|
||||
bool ClearPropertyValue( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
p->SetValue(p->GetDefaultValue());
|
||||
RefreshProperty(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Deletes a property by id. If category is deleted, all children are automatically deleted as well. */
|
||||
void DeleteProperty( wxPGPropArg id );
|
||||
|
||||
/** Deletes choice from a property.
|
||||
|
||||
If selected item is deleted, then the value is set to unspecified.
|
||||
|
||||
See AddPropertyChoice for more details.
|
||||
*/
|
||||
void DeletePropertyChoice( wxPGPropArg id, int index );
|
||||
|
||||
/** Disables property. */
|
||||
bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
|
||||
|
||||
/** Returns true if all property grid data changes have been committed. Usually
|
||||
only returns false if value in active editor has been invalidated by a
|
||||
wxValidator.
|
||||
*/
|
||||
bool EditorValidate();
|
||||
|
||||
/** Enables or disables property, depending on whether enable is true or false. */
|
||||
bool EnableProperty( wxPGPropArg id, bool enable = true );
|
||||
|
||||
/** Called after population of property with fixed children has finished.
|
||||
*/
|
||||
void EndAddChildren( wxPGPropArg id );
|
||||
|
||||
/** Expands given category or property with children.
|
||||
Returns true if actually expands.
|
||||
*/
|
||||
bool Expand( wxPGPropArg id );
|
||||
|
||||
/** Expands all items that can be expanded.
|
||||
*/
|
||||
bool ExpandAll( bool expand = true );
|
||||
|
||||
/** Returns list of expanded properties.
|
||||
*/
|
||||
wxArrayPGProperty GetExpandedProperties() const
|
||||
{
|
||||
wxArrayPGProperty array;
|
||||
GetPropertiesWithFlag(&array, wxPG_PROP_COLLAPSED, true,
|
||||
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN);
|
||||
return array;
|
||||
}
|
||||
|
||||
/** Returns id of first child of given property.
|
||||
@remarks
|
||||
Does not return sub-properties!
|
||||
*/
|
||||
wxPGProperty* GetFirstChild( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
|
||||
|
||||
if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||
return wxNullProperty;
|
||||
|
||||
return p->Item(0);
|
||||
}
|
||||
|
||||
//@{
|
||||
/** Returns iterator class instance.
|
||||
@param flags
|
||||
See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
|
||||
iteration over everything except private child properties.
|
||||
@param firstProp
|
||||
Property to start iteration from. If NULL, then first child of root is used.
|
||||
@param startPos
|
||||
Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start from
|
||||
the first property from the top, and wxBOTTOM means that the iteration will
|
||||
instead begin from bottommost valid item.
|
||||
*/
|
||||
wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL )
|
||||
{
|
||||
return wxPropertyGridIterator( m_pState, flags, firstProp );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL ) const
|
||||
{
|
||||
return wxPropertyGridConstIterator( m_pState, flags, firstProp );
|
||||
}
|
||||
|
||||
wxPropertyGridIterator GetIterator( int flags, int startPos )
|
||||
{
|
||||
return wxPropertyGridIterator( m_pState, flags, startPos );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
|
||||
{
|
||||
return wxPropertyGridConstIterator( m_pState, flags, startPos );
|
||||
}
|
||||
//@}
|
||||
|
||||
/** Returns id of first item, whether it is a category or property.
|
||||
@param flags
|
||||
@link iteratorflags List of iterator flags@endlink
|
||||
*/
|
||||
wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL )
|
||||
{
|
||||
wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 );
|
||||
return *it;
|
||||
}
|
||||
|
||||
const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const
|
||||
{
|
||||
return ((wxPropertyGridInterface*)this)->GetFirst(flags);
|
||||
}
|
||||
|
||||
/** Returns id of property with given name (case-sensitive). If there is no
|
||||
property with such name, returned property id is invalid ( i.e. it will return
|
||||
false with IsOk method).
|
||||
@remarks
|
||||
- Sub-properties (i.e. properties which have parent that is not category or
|
||||
root) can not be accessed globally by their name. Instead, use
|
||||
"<property>.<subproperty>" in place of "<subproperty>".
|
||||
*/
|
||||
wxPGProperty* GetProperty( const wxString& name ) const
|
||||
{
|
||||
return GetPropertyByName(name);
|
||||
}
|
||||
|
||||
/** Returns map-like storage of property's attributes.
|
||||
@remarks
|
||||
Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
|
||||
then builtin-attributes are not included in the storage.
|
||||
*/
|
||||
const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage*)NULL));
|
||||
return p->GetAttributes();
|
||||
}
|
||||
|
||||
/** Adds to 'targetArr' pointers to properties that have given
|
||||
flags 'flags' set. However, if 'inverse' is set to true, then
|
||||
only properties without given flags are stored.
|
||||
@param flags
|
||||
Property flags to use.
|
||||
@param iterFlags
|
||||
Iterator flags to use. Default is everything expect private children.
|
||||
*/
|
||||
void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
|
||||
wxPGProperty::FlagType flags,
|
||||
bool inverse = false,
|
||||
int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
|
||||
|
||||
/** Returns value of given attribute. If none found, returns NULL-variant.
|
||||
*/
|
||||
wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant)
|
||||
return p->GetAttribute(attrName);
|
||||
}
|
||||
|
||||
/** Returns pointer of property's nearest parent category. If no category
|
||||
found, returns NULL.
|
||||
*/
|
||||
wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL)
|
||||
return m_pState->GetPropertyCategory(p);
|
||||
}
|
||||
|
||||
/** Returns client data (void*) of a property. */
|
||||
void* GetPropertyClientData( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
|
||||
return p->GetClientData();
|
||||
}
|
||||
|
||||
/** Returns first property which label matches given string. NULL if none found.
|
||||
Note that this operation is extremely slow when compared to GetPropertyByName().
|
||||
*/
|
||||
wxPGProperty* GetPropertyByLabel( const wxString& label ) const;
|
||||
|
||||
/** Returns property with given name. NULL if none found.
|
||||
*/
|
||||
wxPGProperty* GetPropertyByName( const wxString& name ) const;
|
||||
|
||||
/** Returns child property 'subname' of property 'name'. Same as
|
||||
calling GetPropertyByName("name.subname"), albeit slightly faster.
|
||||
*/
|
||||
wxPGProperty* GetPropertyByName( const wxString& name, const wxString& subname ) const;
|
||||
|
||||
/** Returns writable reference to property's list of choices (and relevant
|
||||
values). If property does not have any choices, will return reference
|
||||
to an invalid set of choices that will return false on IsOk call.
|
||||
*/
|
||||
wxPGChoices& GetPropertyChoices( wxPGPropArg id );
|
||||
|
||||
/** Returns property's editor. */
|
||||
const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
|
||||
return p->GetEditorClass();
|
||||
}
|
||||
|
||||
/** Returns help string associated with a property. */
|
||||
wxString GetPropertyHelpString( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
|
||||
return p->GetHelpString();
|
||||
}
|
||||
|
||||
/** Returns property's custom value image (NULL of none). */
|
||||
wxBitmap* GetPropertyImage( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
|
||||
return p->GetValueImage();
|
||||
}
|
||||
|
||||
/** Returns property's position under its parent. */
|
||||
unsigned int GetPropertyIndex( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX)
|
||||
return p->GetIndexInParent();
|
||||
}
|
||||
|
||||
/** Returns label of a property. */
|
||||
const wxString& GetPropertyLabel( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
|
||||
return p->GetLabel();
|
||||
}
|
||||
|
||||
/** Returns name of a property, by which it is globally accessible. */
|
||||
wxString GetPropertyName( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
|
||||
return p->GetName();
|
||||
}
|
||||
|
||||
/** Returns parent item of a property. */
|
||||
wxPGProperty* GetPropertyParent( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
|
||||
return p->GetParent();
|
||||
}
|
||||
|
||||
/** Returns validator of a property as a reference, which you
|
||||
can pass to any number of SetPropertyValidator.
|
||||
*/
|
||||
wxValidator* GetPropertyValidator( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
|
||||
return p->GetValidator();
|
||||
}
|
||||
|
||||
/** Returns value as wxVariant. To get wxObject pointer from it,
|
||||
you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
|
||||
|
||||
If property value is unspecified, Null variant is returned.
|
||||
*/
|
||||
wxVariant GetPropertyValue( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
|
||||
return p->GetValue();
|
||||
}
|
||||
|
||||
wxString GetPropertyValueAsString( wxPGPropArg id ) const;
|
||||
long GetPropertyValueAsLong( wxPGPropArg id ) const;
|
||||
unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const
|
||||
{
|
||||
return (unsigned long) GetPropertyValueAsLong(id);
|
||||
}
|
||||
int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
|
||||
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
|
||||
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
|
||||
wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
|
||||
void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
|
||||
|
||||
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
|
||||
return p->m_value.GetArrayString();
|
||||
}
|
||||
|
||||
wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
|
||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint);
|
||||
}
|
||||
|
||||
wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
|
||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize);
|
||||
}
|
||||
|
||||
wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id))
|
||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue();
|
||||
}
|
||||
|
||||
wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id))
|
||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue();
|
||||
}
|
||||
|
||||
wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
|
||||
wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt);
|
||||
return arr;
|
||||
}
|
||||
|
||||
wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
|
||||
|
||||
if ( wxStrcmp(p->m_value.GetType(), wxT("datetime")) != 0 )
|
||||
{
|
||||
wxPGGetFailed(p, wxT("datetime"));
|
||||
return wxDateTime();
|
||||
}
|
||||
return p->m_value.GetDateTime();
|
||||
}
|
||||
|
||||
/** Returns a wxVariant list containing wxVariant versions of all
|
||||
property values. Order is not guaranteed.
|
||||
@param flags
|
||||
Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
|
||||
category will be its own wxVariantList of wxVariant.
|
||||
Use wxPG_INC_ATTRIBUTES to include property attributes as well.
|
||||
Each attribute will be stored as list variant named "@@<propname>@@attr."
|
||||
@remarks
|
||||
*/
|
||||
wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
|
||||
wxPGProperty* baseparent = NULL, long flags = 0 ) const
|
||||
{
|
||||
return m_pState->DoGetPropertyValues(listname, baseparent, flags);
|
||||
}
|
||||
|
||||
wxString GetPropertyValueType( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
|
||||
return p->GetValueType();
|
||||
}
|
||||
|
||||
/** Returns currently selected property. */
|
||||
wxPGProperty* GetSelection() const
|
||||
{
|
||||
return m_pState->GetSelection();
|
||||
}
|
||||
|
||||
/** Similar to GetIterator(), but instead returns wxPGVIterator instance,
|
||||
which can be useful for forward-iterating through arbitrary property
|
||||
containers.
|
||||
|
||||
@param flags
|
||||
See @ref propgrid_iterator_flags.
|
||||
*/
|
||||
virtual wxPGVIterator GetVIterator( int flags ) const;
|
||||
|
||||
/** Hides or reveals a property.
|
||||
@param hide
|
||||
If true, hides property, otherwise reveals it.
|
||||
@param flags
|
||||
By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
|
||||
*/
|
||||
bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE );
|
||||
|
||||
/** Initializes *all* property types. Causes references to most object
|
||||
files in the library, so calling this may cause significant increase
|
||||
in executable size when linking with static library.
|
||||
*/
|
||||
static void InitAllTypeHandlers();
|
||||
|
||||
//@{
|
||||
/** Inserts property to the property container.
|
||||
|
||||
@param priorThis
|
||||
New property is inserted just prior to this. Available only
|
||||
in the first variant. There are two versions of this function
|
||||
to allow this parameter to be either an id or name to
|
||||
a property.
|
||||
|
||||
@param newproperty
|
||||
Pointer to the inserted property. wxPropertyGrid will take
|
||||
ownership of this object.
|
||||
|
||||
@param parent
|
||||
New property is inserted under this category. Available only
|
||||
in the second variant. There are two versions of this function
|
||||
to allow this parameter to be either an id or name to
|
||||
a property.
|
||||
|
||||
@param index
|
||||
Index under category. Available only in the second variant.
|
||||
If index is < 0, property is appended in category.
|
||||
|
||||
@return
|
||||
Returns id for the property,
|
||||
|
||||
@remarks
|
||||
|
||||
- wxPropertyGrid takes the ownership of the property pointer.
|
||||
|
||||
- While Append may be faster way to add items, make note that when
|
||||
both types of data storage (categoric and
|
||||
non-categoric) are active, Insert becomes even more slow. This is
|
||||
especially true if current mode is non-categoric.
|
||||
|
||||
Example of use:
|
||||
|
||||
@code
|
||||
|
||||
// append category
|
||||
wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") );
|
||||
|
||||
...
|
||||
|
||||
// insert into category - using second variant
|
||||
wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") );
|
||||
|
||||
// insert before to first item - using first variant
|
||||
wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") );
|
||||
|
||||
@endcode
|
||||
|
||||
*/
|
||||
wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty );
|
||||
wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newproperty );
|
||||
//@}
|
||||
|
||||
/** Returns true if property is a category. */
|
||||
bool IsPropertyCategory( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return p->IsCategory();
|
||||
}
|
||||
|
||||
/** Inserts choice to a property that can accept one.
|
||||
|
||||
See AddPropertyChoice for more details.
|
||||
*/
|
||||
void InsertPropertyChoice( wxPGPropArg id, const wxString& label, int index, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
/** Returns true if property is enabled. */
|
||||
bool IsPropertyEnabled( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false;
|
||||
}
|
||||
|
||||
/** Returns true if given property is expanded. Naturally, always returns false
|
||||
for properties that cannot be expanded.
|
||||
*/
|
||||
bool IsPropertyExpanded( wxPGPropArg id ) const;
|
||||
|
||||
/** Returns true if property has been modified after value set or modify flag
|
||||
clear by software.
|
||||
*/
|
||||
bool IsPropertyModified( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false );
|
||||
}
|
||||
|
||||
/** Returns true if property is shown (ie. hideproperty with true not called for it). */
|
||||
bool IsPropertyShown( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false;
|
||||
}
|
||||
|
||||
/** Returns true if property value is set to unspecified.
|
||||
*/
|
||||
bool IsPropertyValueUnspecified( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return p->IsValueUnspecified();
|
||||
}
|
||||
|
||||
/** Disables (limit = true) or enables (limit = false) wxTextCtrl editor of a property,
|
||||
if it is not the sole mean to edit the value.
|
||||
*/
|
||||
void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
|
||||
|
||||
/** If state is shown in it's grid, refresh it now.
|
||||
*/
|
||||
virtual void RefreshGrid();
|
||||
|
||||
/** Initializes additional property editors (SpinCtrl etc.). Causes references
|
||||
to most object files in the library, so calling this may cause significant increase
|
||||
in executable size when linking with static library.
|
||||
*/
|
||||
static void RegisterAdditionalEditors();
|
||||
|
||||
/** Replaces property with id with newly created property. For example,
|
||||
this code replaces existing property named "Flags" with one that
|
||||
will have different set of items:
|
||||
@code
|
||||
pg->ReplaceProperty("Flags",
|
||||
wxFlagsProperty("Flags", wxPG_LABEL, newItems))
|
||||
@endcode
|
||||
For more info, see wxPropertyGrid::Insert.
|
||||
*/
|
||||
wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
|
||||
|
||||
|
||||
/** @anchor propgridinterface_editablestate_flags
|
||||
|
||||
Flags for wxPropertyGridInterface::SaveEditableState() and
|
||||
wxPropertyGridInterface::RestoreEditableState().
|
||||
*/
|
||||
enum EditableStateFlags
|
||||
{
|
||||
/** Include selected property. */
|
||||
SelectionState = 0x01,
|
||||
/** Include expanded/collapsed property information. */
|
||||
ExpandedState = 0x02,
|
||||
/** Include scrolled position. */
|
||||
ScrollPosState = 0x04,
|
||||
/** Include selected page information. Only applies to wxPropertyGridManager. */
|
||||
PageState = 0x08,
|
||||
/** Include splitter position. Stored for each page. */
|
||||
SplitterPosState = 0x10,
|
||||
|
||||
/** Include all supported user editable state information. This is usually the default value. */
|
||||
AllStates = SelectionState | ExpandedState | ScrollPosState | PageState | SplitterPosState
|
||||
};
|
||||
|
||||
/** Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState().
|
||||
|
||||
@param src
|
||||
String generated by SaveEditableState.
|
||||
|
||||
@param restoreStates
|
||||
Which parts to restore from source string. See @ref propgridinterface_editablestate_flags
|
||||
"list of editable state flags".
|
||||
|
||||
@return
|
||||
False if there was problem reading the string.
|
||||
|
||||
@remarks
|
||||
If some parts of state (such as scrolled or splitter position) fail to restore correctly,
|
||||
please make sure that you call this function after wxPropertyGrid size has been set
|
||||
(this may sometimes be tricky when sizers are used).
|
||||
*/
|
||||
bool RestoreEditableState( const wxString& src,
|
||||
int restoreStates = AllStates );
|
||||
|
||||
/** Used to acquire user-editable state (selected property, expanded properties, scrolled position,
|
||||
splitter positions).
|
||||
|
||||
@param includedStates
|
||||
Which parts of state to include. See @ref propgridinterface_editablestate_flags
|
||||
"list of editable state flags".
|
||||
*/
|
||||
wxString SaveEditableState( int includedStates = AllStates ) const;
|
||||
|
||||
/** Lets user to set the strings listed in the choice dropdown of a wxBoolProperty.
|
||||
Defaults are "True" and "False", so changing them to, say, "Yes" and "No" may
|
||||
be useful in some less technical applications.
|
||||
*/
|
||||
static void SetBoolChoices( const wxString& trueChoice, const wxString& falseChoice );
|
||||
|
||||
/** Sets or clears flag(s) of all properties in given array.
|
||||
@param flags
|
||||
Property flags to set or clear.
|
||||
@param inverse
|
||||
Set to true if you want to clear flag instead of setting them.
|
||||
*/
|
||||
void SetPropertiesFlag( const wxArrayPGProperty& srcArr, wxPGProperty::FlagType flags,
|
||||
bool inverse = false );
|
||||
|
||||
/** Sets an attribute for this property.
|
||||
@param name
|
||||
Text identifier of attribute. See @ref propgrid_property_attributes.
|
||||
@param value
|
||||
Value of attribute.
|
||||
@param argFlags
|
||||
Optional. Use wxPG_RECURSE to set the attribute to child properties recursively.
|
||||
*/
|
||||
void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, wxVariant value, long argFlags = 0 )
|
||||
{
|
||||
DoSetPropertyAttribute(id,attrName,value,argFlags);
|
||||
}
|
||||
|
||||
/** Sets attributes from a wxPGAttributeStorage.
|
||||
*/
|
||||
void SetPropertyAttributes( wxPGPropArg id, const wxPGAttributeStorage& attributes )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetAttributes(attributes);
|
||||
}
|
||||
|
||||
/** Sets text, bitmap, and colours for given column's cell.
|
||||
|
||||
@remarks
|
||||
- You can set label cell by setting column to 0.
|
||||
- You can use wxPG_LABEL as text to use default text for column.
|
||||
*/
|
||||
void SetPropertyCell( wxPGPropArg id,
|
||||
int column,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxBitmap& bitmap = wxNullBitmap,
|
||||
const wxColour& fgCol = wxNullColour,
|
||||
const wxColour& bgCol = wxNullColour )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) );
|
||||
}
|
||||
|
||||
/** Set choices of a property to specified set of labels and values.
|
||||
|
||||
@remarks
|
||||
This operation clears the property value.
|
||||
*/
|
||||
void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices)
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetChoices(choices);
|
||||
}
|
||||
|
||||
|
||||
/** If property's set of choices is shared, then calling this method converts
|
||||
it to private.
|
||||
*/
|
||||
void SetPropertyChoicesExclusive( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetChoicesExclusive();
|
||||
}
|
||||
|
||||
/** Sets client data (void*) of a property.
|
||||
@remarks
|
||||
This untyped client data has to be deleted manually.
|
||||
*/
|
||||
void SetPropertyClientData( wxPGPropArg id, void* clientData )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetClientData(clientData);
|
||||
}
|
||||
|
||||
/** Sets editor for a property.
|
||||
|
||||
@param editor
|
||||
For builtin editors, use wxPGEditor_X, where X is builtin editor's
|
||||
name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list).
|
||||
|
||||
For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
|
||||
*/
|
||||
void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
wxCHECK_RET( editor, wxT("unknown/NULL editor") );
|
||||
p->SetEditor(editor);
|
||||
RefreshProperty(p);
|
||||
}
|
||||
|
||||
/** Sets editor control of a property. As editor argument, use
|
||||
editor name string, such as "TextCtrl" or "Choice".
|
||||
*/
|
||||
void SetPropertyEditor( wxPGPropArg id, const wxString& editorName )
|
||||
{
|
||||
SetPropertyEditor(id,GetEditorByName(editorName));
|
||||
}
|
||||
|
||||
/** Sets label of a property.
|
||||
@remarks
|
||||
This is the only way to set property's name. There is not
|
||||
wxPGProperty::SetLabel() method.
|
||||
*/
|
||||
void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
|
||||
|
||||
/** Set modified status of a property and all its children.
|
||||
*/
|
||||
void SetPropertyModifiedStatus( wxPGPropArg id, bool modified )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetModifiedStatus(modified);
|
||||
}
|
||||
|
||||
/** Sets property (and, recursively, its children) to have read-only value. In other words,
|
||||
user cannot change the value in the editor, but they can still copy it.
|
||||
@remarks
|
||||
This is mainly for use with textctrl editor. Not all other editors fully
|
||||
support it.
|
||||
@param flags
|
||||
By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
|
||||
*/
|
||||
void SetPropertyReadOnly( wxPGPropArg id, bool set = true, int flags = wxPG_RECURSE )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
if ( flags & wxPG_RECURSE )
|
||||
p->SetFlagRecursively(wxPG_PROP_READONLY, set);
|
||||
else
|
||||
p->SetFlag(wxPG_PROP_READONLY);
|
||||
}
|
||||
|
||||
/** Sets property's value to unspecified. If it has children (it may be category),
|
||||
then the same thing is done to them.
|
||||
*/
|
||||
void SetPropertyValueUnspecified( wxPGPropArg id );
|
||||
|
||||
/** Sets various property values from a list of wxVariants. If property with
|
||||
name is missing from the grid, new property is created under given default
|
||||
category (or root if omitted).
|
||||
*/
|
||||
void SetPropertyValues( const wxVariantList& list, wxPGPropArg defaultCategory = wxNullProperty )
|
||||
{
|
||||
wxPGProperty *p;
|
||||
if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this);
|
||||
else p = defaultCategory.GetPtr0();
|
||||
m_pState->DoSetPropertyValues(list, p);
|
||||
}
|
||||
|
||||
void SetPropertyValues( const wxVariant& list, wxPGPropArg defaultCategory = wxNullProperty )
|
||||
{
|
||||
SetPropertyValues(list.GetList(),defaultCategory);
|
||||
}
|
||||
|
||||
/** Associates the help string with property.
|
||||
@remarks
|
||||
By default, text is shown either in the manager's "description"
|
||||
text box or in the status bar. If extra window style wxPG_EX_HELP_AS_TOOLTIPS
|
||||
is used, then the text will appear as a tooltip.
|
||||
*/
|
||||
void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetHelpString(helpString);
|
||||
}
|
||||
|
||||
/** Set wxBitmap in front of the value.
|
||||
@remarks
|
||||
- Bitmap will be scaled to a size returned by wxPropertyGrid::GetImageSize();
|
||||
*/
|
||||
void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetValueImage(bmp);
|
||||
RefreshProperty(p);
|
||||
}
|
||||
|
||||
/** Sets max length of property's text.
|
||||
*/
|
||||
bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
|
||||
|
||||
/** Sets validator of a property.
|
||||
*/
|
||||
void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetValidator(validator);
|
||||
}
|
||||
|
||||
/** Sets value (long integer) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, long value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
/** Sets value (integer) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, int value )
|
||||
{
|
||||
wxVariant v((long)value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (floating point) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, double value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (bool) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, bool value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
void SetPropertyValue( wxPGPropArg id, const wxChar* value )
|
||||
{
|
||||
SetPropertyValueString( id, wxString(value) );
|
||||
}
|
||||
void SetPropertyValue( wxPGPropArg id, const wxString& value )
|
||||
{
|
||||
SetPropertyValueString( id, value );
|
||||
}
|
||||
|
||||
/** Sets value (wxArrayString) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, const wxArrayString& value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
void SetPropertyValue( wxPGPropArg id, const wxDateTime& value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
/** Sets value (wxObject*) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, wxObject* value )
|
||||
{
|
||||
wxVariant v(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
void SetPropertyValue( wxPGPropArg id, wxObject& value )
|
||||
{
|
||||
wxVariant v(&value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
/** Sets value (wxPoint&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, const wxPoint& value )
|
||||
{
|
||||
wxVariant v = WXVARIANT(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (wxSize&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, const wxSize& value )
|
||||
{
|
||||
wxVariant v = WXVARIANT(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (wxLongLong&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, wxLongLong_t value )
|
||||
{
|
||||
wxVariant v = WXVARIANT(wxLongLong(value));
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (wxULongLong&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, wxULongLong_t value )
|
||||
{
|
||||
wxVariant v = WXVARIANT(wxULongLong(value));
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
/** Sets value (wxArrayInt&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value )
|
||||
{
|
||||
wxVariant v = WXVARIANT(value);
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
/** Sets value (wxString) of a property.
|
||||
|
||||
@remarks
|
||||
This method uses wxPGProperty::SetValueFromString, which all properties
|
||||
should implement. This means that there should not be a type error,
|
||||
and instead the string is converted to property's actual value type.
|
||||
*/
|
||||
void SetPropertyValueString( wxPGPropArg id, const wxString& value );
|
||||
|
||||
/** Sets value (wxVariant&) of a property.
|
||||
|
||||
@remarks
|
||||
Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
|
||||
validation process and send property change event.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, wxVariant value )
|
||||
{
|
||||
SetPropVal( id, value );
|
||||
}
|
||||
|
||||
/** Adjusts how wxPropertyGrid behaves when invalid value is entered
|
||||
in a property.
|
||||
@param vfbFlags
|
||||
See @link vfbflags list of valid flags values@endlink
|
||||
*/
|
||||
void SetValidationFailureBehavior( int vfbFlags );
|
||||
|
||||
// GetPropertyByName With nice assertion error message.
|
||||
wxPGProperty* GetPropertyByNameA( const wxString& name ) const;
|
||||
|
||||
static wxPGEditor* GetEditorByName( const wxString& editorName );
|
||||
|
||||
virtual void RefreshProperty( wxPGProperty* p ) = 0;
|
||||
};
|
||||
|
170
interface/wx/propgrid/propgridpagestate.h
Normal file
170
interface/wx/propgrid/propgridpagestate.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: property.h
|
||||
// Purpose: interface of wxPGProperty
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id:
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/** @section propgrid_hittestresult wxPropertyGridHitTestResult
|
||||
|
||||
A return value from wxPropertyGrid::HitTest(),
|
||||
contains all you need to know about an arbitrary location on the grid.
|
||||
*/
|
||||
struct wxPropertyGridHitTestResult
|
||||
{
|
||||
public:
|
||||
|
||||
wxPGProperty* GetProperty() const { return property; }
|
||||
|
||||
/** Column. -1 for margin. */
|
||||
int column;
|
||||
|
||||
/** Index of splitter hit, -1 for none. */
|
||||
int splitter;
|
||||
|
||||
/** If splitter hit, offset to that */
|
||||
int splitterHitOffset;
|
||||
|
||||
private:
|
||||
/** Property. NULL if empty space below properties was hit */
|
||||
wxPGProperty* property;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxPG_IT_CHILDREN(A) (A<<16)
|
||||
|
||||
/** @section propgrid_iterator_flags wxPropertyGridIterator Flags
|
||||
@{
|
||||
|
||||
NOTES: At lower 16-bits, there are flags to check if item will be included. At higher
|
||||
16-bits, there are same flags, but to instead check if children will be included.
|
||||
*/
|
||||
|
||||
enum wxPG_ITERATOR_FLAGS
|
||||
{
|
||||
|
||||
/** Iterate through 'normal' property items (does not include children of aggregate or hidden items by default).
|
||||
*/
|
||||
wxPG_ITERATE_PROPERTIES = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
|
||||
wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)),
|
||||
|
||||
/** Iterate children of collapsed parents, and individual items that are hidden.
|
||||
*/
|
||||
wxPG_ITERATE_HIDDEN = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)),
|
||||
|
||||
/** Iterate children of parent that is an aggregate property (ie. has fixed children).
|
||||
*/
|
||||
wxPG_ITERATE_FIXED_CHILDREN = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES),
|
||||
|
||||
/** Iterate categories. Note that even without this flag, children of categories
|
||||
are still iterated through.
|
||||
*/
|
||||
wxPG_ITERATE_CATEGORIES = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED),
|
||||
|
||||
wxPG_ITERATE_ALL_PARENTS = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY),
|
||||
|
||||
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)),
|
||||
|
||||
wxPG_ITERATOR_FLAGS_ALL = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
|
||||
wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED),
|
||||
|
||||
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
|
||||
|
||||
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL, // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
|
||||
|
||||
/** Combines all flags needed to iterate through visible properties
|
||||
(ie. hidden properties and children of collapsed parents are skipped).
|
||||
*/
|
||||
wxPG_ITERATE_VISIBLE = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)),
|
||||
|
||||
/** Iterate all items.
|
||||
*/
|
||||
wxPG_ITERATE_ALL = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN),
|
||||
|
||||
/** Iterate through individual properties (ie. categories and children of
|
||||
aggregate properties are skipped).
|
||||
*/
|
||||
wxPG_ITERATE_NORMAL = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN),
|
||||
|
||||
/** Default iterator flags.
|
||||
*/
|
||||
wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
|
||||
|
||||
};
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
||||
/** @section propgrid_iterator_class wxPropertyGridIterator
|
||||
|
||||
Preferable way to iterate through contents of wxPropertyGrid,
|
||||
wxPropertyGridManager, and wxPropertyGridPage.
|
||||
|
||||
See wxPropertyGridInterface::GetIterator() for more information about usage.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPropertyGridIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
|
||||
void Assign( const wxPropertyGridIteratorBase& it );
|
||||
|
||||
bool AtEnd() const { return m_property == NULL; }
|
||||
|
||||
/** Get current property.
|
||||
*/
|
||||
wxPGProperty* GetProperty() const { return m_property; }
|
||||
|
||||
/** Iterate to the next property.
|
||||
*/
|
||||
void Next( bool iterateChildren = true );
|
||||
|
||||
/** Iterate to the previous property.
|
||||
*/
|
||||
void Prev();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @section propgrid_viterator_class wxPGVIterator
|
||||
|
||||
Abstract implementation of a simple iterator. Can only be used
|
||||
to iterate in forward order, and only through the entire container.
|
||||
Used to have functions dealing with all properties work with both
|
||||
wxPropertyGrid and wxPropertyGridManager.
|
||||
*/
|
||||
class wxPGVIterator
|
||||
{
|
||||
public:
|
||||
wxPGVIterator() { m_pIt = NULL; }
|
||||
wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
|
||||
~wxPGVIterator() { UnRef(); }
|
||||
void UnRef() { if (m_pIt) m_pIt->DecRef(); }
|
||||
wxPGVIterator( const wxPGVIterator& it )
|
||||
{
|
||||
m_pIt = it.m_pIt;
|
||||
m_pIt->IncRef();
|
||||
}
|
||||
const wxPGVIterator& operator=( const wxPGVIterator& it )
|
||||
{
|
||||
UnRef();
|
||||
m_pIt = it.m_pIt;
|
||||
m_pIt->IncRef();
|
||||
return *this;
|
||||
}
|
||||
void Next() { m_pIt->Next(); }
|
||||
bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
|
||||
wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
|
||||
protected:
|
||||
wxPGVIteratorBase* m_pIt;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user