2008-09-12 20:57:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: samples/propgrid/propgrid.cpp
|
|
|
|
// Purpose: wxPropertyGrid sample
|
|
|
|
// Author: Jaakko Salli
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2004-09-25
|
|
|
|
// Copyright: (c) Jaakko Salli
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-09-12 20:57:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// NOTES
|
|
|
|
//
|
|
|
|
// * Examples of custom property classes are in sampleprops.cpp.
|
|
|
|
//
|
|
|
|
// * Additional ones can be found below.
|
|
|
|
//
|
|
|
|
// * Currently there is no example of a custom property editor. However,
|
|
|
|
// SpinCtrl editor sample is well-commented. It can be found in
|
2008-10-16 17:24:27 +00:00
|
|
|
// src/propgrid/advprops.cpp.
|
2008-09-12 20:57:41 +00:00
|
|
|
//
|
|
|
|
// * To find code that populates the grid with properties, search for
|
|
|
|
// string "::Populate".
|
|
|
|
//
|
|
|
|
// * To find code that handles property grid changes, search for string
|
|
|
|
// "::OnPropertyGridChange".
|
|
|
|
//
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
|
|
|
// need because it includes almost all "standard" wxWidgets headers)
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2008-09-17 15:00:00 +00:00
|
|
|
#if !wxUSE_PROPGRID
|
|
|
|
#error "Please set wxUSE_PROPGRID to 1 and rebuild the library."
|
|
|
|
#endif
|
|
|
|
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/numdlg.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// Main propertygrid header.
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/propgrid/propgrid.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Extra property classes.
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/propgrid/advprops.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// This defines wxPropertyGridManager.
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/propgrid/manager.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#include "propgrid.h"
|
|
|
|
#include "sampleprops.h"
|
|
|
|
|
|
|
|
#if wxUSE_DATEPICKCTRL
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/datectrl.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/artprov.h"
|
2017-10-18 20:56:44 +00:00
|
|
|
#include "wx/dcbuffer.h" // for wxALWAYS_NATIVE_DOUBLE_BUFFER
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2012-03-04 00:28:58 +00:00
|
|
|
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
2009-02-08 01:01:00 +00:00
|
|
|
#include "../sample.xpm"
|
|
|
|
#endif
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/popupwin.h"
|
2013-08-06 13:05:42 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxSampleMultiButtonEditor
|
|
|
|
// A sample editor class that has multiple buttons.
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxSampleMultiButtonEditor : public wxPGTextCtrlEditor
|
|
|
|
{
|
2014-03-30 07:07:55 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxSampleMultiButtonEditor);
|
2008-09-12 20:57:41 +00:00
|
|
|
public:
|
|
|
|
wxSampleMultiButtonEditor() {}
|
|
|
|
virtual ~wxSampleMultiButtonEditor() {}
|
|
|
|
|
2008-09-27 14:03:10 +00:00
|
|
|
virtual wxPGWindowList CreateControls( wxPropertyGrid* propGrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxSize& sz ) const wxOVERRIDE;
|
2008-09-12 20:57:41 +00:00
|
|
|
virtual bool OnEvent( wxPropertyGrid* propGrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxEvent& event ) const wxOVERRIDE;
|
2008-09-12 20:57:41 +00:00
|
|
|
};
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxIMPLEMENT_DYNAMIC_CLASS(wxSampleMultiButtonEditor, wxPGTextCtrlEditor);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPGWindowList wxSampleMultiButtonEditor::CreateControls( wxPropertyGrid* propGrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& sz ) const
|
|
|
|
{
|
|
|
|
// Create and populate buttons-subwindow
|
|
|
|
wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
|
|
|
|
|
2008-09-27 14:03:10 +00:00
|
|
|
// Add two regular buttons
|
2018-09-29 01:45:15 +00:00
|
|
|
buttons->Add( "..." );
|
|
|
|
buttons->Add( "A" );
|
2008-09-27 14:03:10 +00:00
|
|
|
// Add a bitmap button
|
2008-09-12 20:57:41 +00:00
|
|
|
buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
|
|
|
|
|
|
|
|
// Create the 'primary' editor control (textctrl in this case)
|
|
|
|
wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls
|
2008-09-27 14:03:10 +00:00
|
|
|
( propGrid, property, pos,
|
|
|
|
buttons->GetPrimarySize() );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Finally, move buttons-subwindow to correct position and make sure
|
|
|
|
// returned wxPGWindowList contains our custom button list.
|
2008-09-27 14:03:10 +00:00
|
|
|
buttons->Finalize(propGrid, pos);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wndList.SetSecondary( buttons );
|
|
|
|
return wndList;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxSampleMultiButtonEditor::OnEvent( wxPropertyGrid* propGrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
wxEvent& event ) const
|
|
|
|
{
|
2013-04-25 10:11:03 +00:00
|
|
|
if ( event.GetEventType() == wxEVT_BUTTON )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
|
|
|
|
|
2008-09-27 14:03:10 +00:00
|
|
|
if ( event.GetId() == buttons->GetButtonId(0) )
|
|
|
|
{
|
2009-03-09 18:32:43 +00:00
|
|
|
// Do something when the first button is pressed
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("First button pressed");
|
2009-03-09 18:32:43 +00:00
|
|
|
return false; // Return false since value did not change
|
2008-09-27 14:03:10 +00:00
|
|
|
}
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( event.GetId() == buttons->GetButtonId(1) )
|
|
|
|
{
|
2009-03-09 18:32:43 +00:00
|
|
|
// Do something when the second button is pressed
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("Second button pressed");
|
2009-03-09 18:32:43 +00:00
|
|
|
return false; // Return false since value did not change
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
if ( event.GetId() == buttons->GetButtonId(2) )
|
|
|
|
{
|
2009-03-09 18:32:43 +00:00
|
|
|
// Do something when the third button is pressed
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("Third button pressed");
|
2009-03-09 18:32:43 +00:00
|
|
|
return false; // Return false since value did not change
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Validator for wxValidator use sample
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_VALIDATORS
|
|
|
|
|
|
|
|
// wxValidator for testing
|
|
|
|
|
|
|
|
class wxInvalidWordValidator : public wxValidator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
wxInvalidWordValidator( const wxString& invalidWord )
|
|
|
|
: wxValidator(), m_invalidWord(invalidWord)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxObject* Clone() const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
return new wxInvalidWordValidator(m_invalidWord);
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
|
2018-09-29 01:45:15 +00:00
|
|
|
wxCHECK_MSG(tc, true, "validator window must be wxTextCtrl");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxString val = tc->GetValue();
|
|
|
|
|
|
|
|
if ( val.find(m_invalidWord) == wxString::npos )
|
|
|
|
return true;
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
::wxMessageBox(wxString::Format("%s is not allowed word",m_invalidWord),
|
2018-09-29 01:45:15 +00:00
|
|
|
"Validation Failure");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_invalidWord;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_VALIDATORS
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxVectorProperty
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// See propgridsample.h for wxVector3f class
|
|
|
|
|
2008-09-16 15:55:53 +00:00
|
|
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxVector3f)
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2015-02-04 16:53:46 +00:00
|
|
|
wxPG_IMPLEMENT_PROPERTY_CLASS(wxVectorProperty,wxPGProperty,TextCtrl)
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxVectorProperty::wxVectorProperty( const wxString& label,
|
|
|
|
const wxString& name,
|
|
|
|
const wxVector3f& value )
|
|
|
|
: wxPGProperty(label,name)
|
|
|
|
{
|
2008-09-16 15:55:53 +00:00
|
|
|
SetValue( WXVARIANT(value) );
|
2018-09-29 01:45:15 +00:00
|
|
|
AddPrivateChild( new wxFloatProperty("X",wxPG_LABEL,value.x) );
|
|
|
|
AddPrivateChild( new wxFloatProperty("Y",wxPG_LABEL,value.y) );
|
|
|
|
AddPrivateChild( new wxFloatProperty("Z",wxPG_LABEL,value.z) );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxVectorProperty::~wxVectorProperty() { }
|
|
|
|
|
|
|
|
void wxVectorProperty::RefreshChildren()
|
|
|
|
{
|
|
|
|
if ( !GetChildCount() ) return;
|
2008-09-16 15:55:53 +00:00
|
|
|
const wxVector3f& vector = wxVector3fRefFromVariant(m_value);
|
2008-09-12 20:57:41 +00:00
|
|
|
Item(0)->SetValue( vector.x );
|
|
|
|
Item(1)->SetValue( vector.y );
|
|
|
|
Item(2)->SetValue( vector.z );
|
|
|
|
}
|
|
|
|
|
2009-06-07 07:52:53 +00:00
|
|
|
wxVariant wxVectorProperty::ChildChanged( wxVariant& thisValue,
|
|
|
|
int childIndex,
|
|
|
|
wxVariant& childValue ) const
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2008-09-16 15:55:53 +00:00
|
|
|
wxVector3f vector;
|
|
|
|
vector << thisValue;
|
2008-09-12 20:57:41 +00:00
|
|
|
switch ( childIndex )
|
|
|
|
{
|
|
|
|
case 0: vector.x = childValue.GetDouble(); break;
|
|
|
|
case 1: vector.y = childValue.GetDouble(); break;
|
|
|
|
case 2: vector.z = childValue.GetDouble(); break;
|
|
|
|
}
|
2009-06-07 07:52:53 +00:00
|
|
|
wxVariant newVariant;
|
|
|
|
newVariant << vector;
|
|
|
|
return newVariant;
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxTriangleProperty
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// See propgridsample.h for wxTriangle class
|
|
|
|
|
2008-09-16 15:55:53 +00:00
|
|
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxTriangle)
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2015-02-04 16:53:46 +00:00
|
|
|
wxPG_IMPLEMENT_PROPERTY_CLASS(wxTriangleProperty,wxPGProperty,TextCtrl)
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxTriangleProperty::wxTriangleProperty( const wxString& label,
|
|
|
|
const wxString& name,
|
|
|
|
const wxTriangle& value)
|
|
|
|
: wxPGProperty(label,name)
|
|
|
|
{
|
2008-09-16 15:55:53 +00:00
|
|
|
SetValue( WXVARIANT(value) );
|
2018-09-29 01:45:15 +00:00
|
|
|
AddPrivateChild( new wxVectorProperty("A",wxPG_LABEL,value.a) );
|
|
|
|
AddPrivateChild( new wxVectorProperty("B",wxPG_LABEL,value.b) );
|
|
|
|
AddPrivateChild( new wxVectorProperty("C",wxPG_LABEL,value.c) );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxTriangleProperty::~wxTriangleProperty() { }
|
|
|
|
|
|
|
|
void wxTriangleProperty::RefreshChildren()
|
|
|
|
{
|
|
|
|
if ( !GetChildCount() ) return;
|
2008-09-16 15:55:53 +00:00
|
|
|
const wxTriangle& triangle = wxTriangleRefFromVariant(m_value);
|
|
|
|
Item(0)->SetValue( WXVARIANT(triangle.a) );
|
|
|
|
Item(1)->SetValue( WXVARIANT(triangle.b) );
|
|
|
|
Item(2)->SetValue( WXVARIANT(triangle.c) );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-07 07:52:53 +00:00
|
|
|
wxVariant wxTriangleProperty::ChildChanged( wxVariant& thisValue,
|
|
|
|
int childIndex,
|
|
|
|
wxVariant& childValue ) const
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2008-09-16 15:55:53 +00:00
|
|
|
wxTriangle triangle;
|
|
|
|
triangle << thisValue;
|
|
|
|
const wxVector3f& vector = wxVector3fRefFromVariant(childValue);
|
2008-09-12 20:57:41 +00:00
|
|
|
switch ( childIndex )
|
|
|
|
{
|
|
|
|
case 0: triangle.a = vector; break;
|
|
|
|
case 1: triangle.b = vector; break;
|
|
|
|
case 2: triangle.c = vector; break;
|
|
|
|
}
|
2009-06-07 07:52:53 +00:00
|
|
|
wxVariant newVariant;
|
|
|
|
newVariant << triangle;
|
|
|
|
return newVariant;
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxSingleChoiceDialogAdapter (wxPGEditorDialogAdapter sample)
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxSingleChoiceDialogAdapter : public wxPGEditorDialogAdapter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
wxSingleChoiceDialogAdapter( const wxPGChoices& choices )
|
|
|
|
: wxPGEditorDialogAdapter(), m_choices(choices)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool DoShowDialog( wxPropertyGrid* WXUNUSED(propGrid),
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPGProperty* WXUNUSED(property) ) wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString s = ::wxGetSingleChoice("Message",
|
|
|
|
"Caption",
|
2008-09-12 20:57:41 +00:00
|
|
|
m_choices.GetLabels());
|
2011-01-22 14:38:36 +00:00
|
|
|
if ( !s.empty() )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
SetValue(s);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const wxPGChoices& m_choices;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SingleChoiceProperty : public wxStringProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SingleChoiceProperty( const wxString& label,
|
|
|
|
const wxString& name = wxPG_LABEL,
|
|
|
|
const wxString& value = wxEmptyString )
|
|
|
|
: wxStringProperty(label, name, value)
|
|
|
|
{
|
|
|
|
// Prepare choices
|
2018-09-29 01:45:15 +00:00
|
|
|
m_choices.Add("Cat");
|
|
|
|
m_choices.Add("Dog");
|
|
|
|
m_choices.Add("Gibbon");
|
|
|
|
m_choices.Add("Otter");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set editor to have button
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual const wxPGEditor* DoGetEditorClass() const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2008-10-05 14:23:28 +00:00
|
|
|
return wxPGEditor_TextCtrlAndButton;
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set what happens on button click
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPGEditorDialogAdapter* GetEditorDialog() const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
return new wxSingleChoiceDialogAdapter(m_choices);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxPGChoices m_choices;
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Menu IDs
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PGID = 1,
|
|
|
|
ID_ABOUT,
|
|
|
|
ID_QUIT,
|
|
|
|
ID_APPENDPROP,
|
|
|
|
ID_APPENDCAT,
|
|
|
|
ID_INSERTPROP,
|
|
|
|
ID_INSERTCAT,
|
|
|
|
ID_ENABLE,
|
2010-01-31 18:14:24 +00:00
|
|
|
ID_SETREADONLY,
|
2008-09-12 20:57:41 +00:00
|
|
|
ID_HIDE,
|
2015-04-04 08:18:36 +00:00
|
|
|
ID_BOOL_CHECKBOX,
|
2008-09-12 20:57:41 +00:00
|
|
|
ID_DELETE,
|
|
|
|
ID_DELETER,
|
|
|
|
ID_DELETEALL,
|
|
|
|
ID_UNSPECIFY,
|
|
|
|
ID_ITERATE1,
|
|
|
|
ID_ITERATE2,
|
|
|
|
ID_ITERATE3,
|
|
|
|
ID_ITERATE4,
|
|
|
|
ID_CLEARMODIF,
|
|
|
|
ID_FREEZE,
|
|
|
|
ID_DUMPLIST,
|
|
|
|
ID_COLOURSCHEME1,
|
|
|
|
ID_COLOURSCHEME2,
|
|
|
|
ID_COLOURSCHEME3,
|
|
|
|
ID_CATCOLOURS,
|
2008-10-31 18:53:37 +00:00
|
|
|
ID_SETBGCOLOUR,
|
|
|
|
ID_SETBGCOLOURRECUR,
|
2008-09-12 20:57:41 +00:00
|
|
|
ID_STATICLAYOUT,
|
|
|
|
ID_POPULATE1,
|
|
|
|
ID_POPULATE2,
|
|
|
|
ID_COLLAPSE,
|
|
|
|
ID_COLLAPSEALL,
|
|
|
|
ID_GETVALUES,
|
|
|
|
ID_SETVALUES,
|
|
|
|
ID_SETVALUES2,
|
|
|
|
ID_RUNTESTFULL,
|
|
|
|
ID_RUNTESTPARTIAL,
|
|
|
|
ID_FITCOLUMNS,
|
|
|
|
ID_CHANGEFLAGSITEMS,
|
|
|
|
ID_TESTINSERTCHOICE,
|
|
|
|
ID_TESTDELETECHOICE,
|
|
|
|
ID_INSERTPAGE,
|
|
|
|
ID_REMOVEPAGE,
|
|
|
|
ID_SETSPINCTRLEDITOR,
|
|
|
|
ID_SETPROPERTYVALUE,
|
|
|
|
ID_TESTREPLACE,
|
|
|
|
ID_SETCOLUMNS,
|
2018-12-27 08:04:37 +00:00
|
|
|
ID_SETVIRTWIDTH,
|
2008-09-12 20:57:41 +00:00
|
|
|
ID_TESTXRC,
|
|
|
|
ID_ENABLECOMMONVALUES,
|
|
|
|
ID_SELECTSTYLE,
|
|
|
|
ID_SAVESTATE,
|
|
|
|
ID_RESTORESTATE,
|
2009-08-23 15:31:03 +00:00
|
|
|
ID_RUNMINIMAL,
|
2009-12-12 09:38:10 +00:00
|
|
|
ID_ENABLELABELEDITING,
|
2009-12-13 12:00:04 +00:00
|
|
|
ID_VETOCOLDRAG,
|
2015-05-31 17:18:36 +00:00
|
|
|
#if wxUSE_HEADERCTRL
|
2010-06-12 09:30:57 +00:00
|
|
|
ID_SHOWHEADER,
|
2015-05-31 17:18:36 +00:00
|
|
|
#endif
|
2013-08-06 13:05:42 +00:00
|
|
|
ID_ONEXTENDEDKEYNAV,
|
|
|
|
ID_SHOWPOPUP,
|
|
|
|
ID_POPUPGRID
|
2008-09-12 20:57:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Event table
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2014-03-30 07:07:55 +00:00
|
|
|
wxBEGIN_EVENT_TABLE(FormMain, wxFrame)
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_IDLE(FormMain::OnIdle)
|
|
|
|
EVT_MOVE(FormMain::OnMove)
|
|
|
|
EVT_SIZE(FormMain::OnResize)
|
|
|
|
|
|
|
|
// This occurs when a property is selected
|
|
|
|
EVT_PG_SELECTED( PGID, FormMain::OnPropertyGridSelect )
|
|
|
|
// This occurs when a property value changes
|
|
|
|
EVT_PG_CHANGED( PGID, FormMain::OnPropertyGridChange )
|
|
|
|
// This occurs just prior a property value is changed
|
|
|
|
EVT_PG_CHANGING( PGID, FormMain::OnPropertyGridChanging )
|
|
|
|
// This occurs when a mouse moves over another property
|
|
|
|
EVT_PG_HIGHLIGHTED( PGID, FormMain::OnPropertyGridHighlight )
|
|
|
|
// This occurs when mouse is right-clicked.
|
|
|
|
EVT_PG_RIGHT_CLICK( PGID, FormMain::OnPropertyGridItemRightClick )
|
|
|
|
// This occurs when mouse is double-clicked.
|
|
|
|
EVT_PG_DOUBLE_CLICK( PGID, FormMain::OnPropertyGridItemDoubleClick )
|
|
|
|
// This occurs when propgridmanager's page changes.
|
|
|
|
EVT_PG_PAGE_CHANGED( PGID, FormMain::OnPropertyGridPageChange )
|
2009-08-23 15:31:03 +00:00
|
|
|
// This occurs when user starts editing a property label
|
|
|
|
EVT_PG_LABEL_EDIT_BEGIN( PGID,
|
|
|
|
FormMain::OnPropertyGridLabelEditBegin )
|
|
|
|
// This occurs when user stops editing a property label
|
|
|
|
EVT_PG_LABEL_EDIT_ENDING( PGID,
|
|
|
|
FormMain::OnPropertyGridLabelEditEnding )
|
2008-09-12 20:57:41 +00:00
|
|
|
// This occurs when property's editor button (if any) is clicked.
|
|
|
|
EVT_BUTTON( PGID, FormMain::OnPropertyGridButtonClick )
|
|
|
|
|
|
|
|
EVT_PG_ITEM_COLLAPSED( PGID, FormMain::OnPropertyGridItemCollapse )
|
|
|
|
EVT_PG_ITEM_EXPANDED( PGID, FormMain::OnPropertyGridItemExpand )
|
|
|
|
|
2009-12-12 09:38:10 +00:00
|
|
|
EVT_PG_COL_BEGIN_DRAG( PGID, FormMain::OnPropertyGridColBeginDrag )
|
|
|
|
EVT_PG_COL_DRAGGING( PGID, FormMain::OnPropertyGridColDragging )
|
|
|
|
EVT_PG_COL_END_DRAG( PGID, FormMain::OnPropertyGridColEndDrag )
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_TEXT( PGID, FormMain::OnPropertyGridTextUpdate )
|
|
|
|
|
|
|
|
//
|
|
|
|
// Rest of the events are not property grid specific
|
|
|
|
EVT_KEY_DOWN( FormMain::OnPropertyGridKeyEvent )
|
|
|
|
EVT_KEY_UP( FormMain::OnPropertyGridKeyEvent )
|
|
|
|
|
|
|
|
EVT_MENU( ID_APPENDPROP, FormMain::OnAppendPropClick )
|
|
|
|
EVT_MENU( ID_APPENDCAT, FormMain::OnAppendCatClick )
|
|
|
|
EVT_MENU( ID_INSERTPROP, FormMain::OnInsertPropClick )
|
|
|
|
EVT_MENU( ID_INSERTCAT, FormMain::OnInsertCatClick )
|
|
|
|
EVT_MENU( ID_DELETE, FormMain::OnDelPropClick )
|
|
|
|
EVT_MENU( ID_DELETER, FormMain::OnDelPropRClick )
|
|
|
|
EVT_MENU( ID_UNSPECIFY, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_DELETEALL, FormMain::OnClearClick )
|
|
|
|
EVT_MENU( ID_ENABLE, FormMain::OnEnableDisable )
|
2010-01-31 18:14:24 +00:00
|
|
|
EVT_MENU( ID_SETREADONLY, FormMain::OnSetReadOnly )
|
2010-02-25 14:04:25 +00:00
|
|
|
EVT_MENU( ID_HIDE, FormMain::OnHide )
|
2015-04-04 08:18:36 +00:00
|
|
|
EVT_MENU( ID_BOOL_CHECKBOX, FormMain::OnBoolCheckbox )
|
2008-10-31 18:53:37 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_MENU( ID_ITERATE1, FormMain::OnIterate1Click )
|
|
|
|
EVT_MENU( ID_ITERATE2, FormMain::OnIterate2Click )
|
|
|
|
EVT_MENU( ID_ITERATE3, FormMain::OnIterate3Click )
|
|
|
|
EVT_MENU( ID_ITERATE4, FormMain::OnIterate4Click )
|
2010-06-12 09:30:57 +00:00
|
|
|
EVT_MENU( ID_ONEXTENDEDKEYNAV, FormMain::OnExtendedKeyNav )
|
2008-10-31 18:53:37 +00:00
|
|
|
EVT_MENU( ID_SETBGCOLOUR, FormMain::OnSetBackgroundColour )
|
|
|
|
EVT_MENU( ID_SETBGCOLOURRECUR, FormMain::OnSetBackgroundColour )
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_MENU( ID_CLEARMODIF, FormMain::OnClearModifyStatusClick )
|
|
|
|
EVT_MENU( ID_FREEZE, FormMain::OnFreezeClick )
|
2009-08-23 15:31:03 +00:00
|
|
|
EVT_MENU( ID_ENABLELABELEDITING, FormMain::OnEnableLabelEditing )
|
2015-05-31 17:18:36 +00:00
|
|
|
#if wxUSE_HEADERCTRL
|
2009-12-13 12:00:04 +00:00
|
|
|
EVT_MENU( ID_SHOWHEADER, FormMain::OnShowHeader )
|
2015-05-31 17:18:36 +00:00
|
|
|
#endif
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_MENU( ID_DUMPLIST, FormMain::OnDumpList )
|
|
|
|
|
|
|
|
EVT_MENU( ID_COLOURSCHEME1, FormMain::OnColourScheme )
|
|
|
|
EVT_MENU( ID_COLOURSCHEME2, FormMain::OnColourScheme )
|
|
|
|
EVT_MENU( ID_COLOURSCHEME3, FormMain::OnColourScheme )
|
|
|
|
EVT_MENU( ID_COLOURSCHEME4, FormMain::OnColourScheme )
|
|
|
|
|
|
|
|
EVT_MENU( ID_ABOUT, FormMain::OnAbout )
|
|
|
|
EVT_MENU( ID_QUIT, FormMain::OnCloseClick )
|
|
|
|
|
|
|
|
EVT_MENU( ID_CATCOLOURS, FormMain::OnCatColours )
|
|
|
|
EVT_MENU( ID_SETCOLUMNS, FormMain::OnSetColumns )
|
2018-12-27 08:04:37 +00:00
|
|
|
EVT_MENU( ID_SETVIRTWIDTH, FormMain::OnSetVirtualWidth )
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_MENU( ID_TESTXRC, FormMain::OnTestXRC )
|
|
|
|
EVT_MENU( ID_ENABLECOMMONVALUES, FormMain::OnEnableCommonValues )
|
|
|
|
EVT_MENU( ID_SELECTSTYLE, FormMain::OnSelectStyle )
|
|
|
|
|
|
|
|
EVT_MENU( ID_STATICLAYOUT, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_COLLAPSE, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_COLLAPSEALL, FormMain::OnMisc )
|
|
|
|
|
|
|
|
EVT_MENU( ID_POPULATE1, FormMain::OnPopulateClick )
|
|
|
|
EVT_MENU( ID_POPULATE2, FormMain::OnPopulateClick )
|
|
|
|
|
|
|
|
EVT_MENU( ID_GETVALUES, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_SETVALUES, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_SETVALUES2, FormMain::OnMisc )
|
|
|
|
|
|
|
|
EVT_MENU( ID_FITCOLUMNS, FormMain::OnFitColumnsClick )
|
|
|
|
|
|
|
|
EVT_MENU( ID_CHANGEFLAGSITEMS, FormMain::OnChangeFlagsPropItemsClick )
|
|
|
|
|
|
|
|
EVT_MENU( ID_RUNTESTFULL, FormMain::OnMisc )
|
|
|
|
EVT_MENU( ID_RUNTESTPARTIAL, FormMain::OnMisc )
|
|
|
|
|
|
|
|
EVT_MENU( ID_TESTINSERTCHOICE, FormMain::OnInsertChoice )
|
|
|
|
EVT_MENU( ID_TESTDELETECHOICE, FormMain::OnDeleteChoice )
|
|
|
|
|
|
|
|
EVT_MENU( ID_INSERTPAGE, FormMain::OnInsertPage )
|
|
|
|
EVT_MENU( ID_REMOVEPAGE, FormMain::OnRemovePage )
|
|
|
|
|
|
|
|
EVT_MENU( ID_SAVESTATE, FormMain::OnSaveState )
|
|
|
|
EVT_MENU( ID_RESTORESTATE, FormMain::OnRestoreState )
|
|
|
|
|
|
|
|
EVT_MENU( ID_SETSPINCTRLEDITOR, FormMain::OnSetSpinCtrlEditorClick )
|
|
|
|
EVT_MENU( ID_TESTREPLACE, FormMain::OnTestReplaceClick )
|
|
|
|
EVT_MENU( ID_SETPROPERTYVALUE, FormMain::OnSetPropertyValue )
|
|
|
|
|
|
|
|
EVT_MENU( ID_RUNMINIMAL, FormMain::OnRunMinimalClick )
|
|
|
|
|
2015-08-27 17:05:15 +00:00
|
|
|
EVT_UPDATE_UI( ID_CATCOLOURS, FormMain::OnCatColoursUpdateUI )
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_CONTEXT_MENU( FormMain::OnContextMenu )
|
2013-08-06 13:05:42 +00:00
|
|
|
EVT_BUTTON(ID_SHOWPOPUP, FormMain::OnShowPopup)
|
2014-03-30 07:07:55 +00:00
|
|
|
wxEND_EVENT_TABLE()
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnMove( wxMoveEvent& event )
|
|
|
|
{
|
|
|
|
if ( !m_pPropGridManager )
|
|
|
|
{
|
|
|
|
// this check is here so the frame layout can be tested
|
|
|
|
// without creating propertygrid
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update position properties
|
|
|
|
int x, y;
|
|
|
|
GetPosition(&x,&y);
|
|
|
|
|
|
|
|
wxPGProperty* id;
|
|
|
|
|
|
|
|
// Must check if properties exist (as they may be deleted).
|
|
|
|
|
|
|
|
// Using m_pPropGridManager, we can scan all pages automatically.
|
2018-09-29 01:45:15 +00:00
|
|
|
id = m_pPropGridManager->GetPropertyByName( "X" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( id )
|
|
|
|
m_pPropGridManager->SetPropertyValue( id, x );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
id = m_pPropGridManager->GetPropertyByName( "Y" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( id )
|
|
|
|
m_pPropGridManager->SetPropertyValue( id, y );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
id = m_pPropGridManager->GetPropertyByName( "Position" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( id )
|
2008-09-27 15:09:33 +00:00
|
|
|
m_pPropGridManager->SetPropertyValue( id, WXVARIANT(wxPoint(x,y)) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Should always call event.Skip() in frame's MoveEvent handler
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnResize( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
if ( !m_pPropGridManager )
|
|
|
|
{
|
|
|
|
// this check is here so the frame layout can be tested
|
|
|
|
// without creating propertygrid
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update size properties
|
|
|
|
int w, h;
|
|
|
|
GetSize(&w,&h);
|
|
|
|
|
|
|
|
wxPGProperty* id;
|
|
|
|
wxPGProperty* p;
|
|
|
|
|
|
|
|
// Must check if properties exist (as they may be deleted).
|
|
|
|
|
|
|
|
// Using m_pPropGridManager, we can scan all pages automatically.
|
2018-09-29 01:45:15 +00:00
|
|
|
p = m_pPropGridManager->GetPropertyByName( "Width" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( p && !p->IsValueUnspecified() )
|
|
|
|
m_pPropGridManager->SetPropertyValue( p, w );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = m_pPropGridManager->GetPropertyByName( "Height" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( p && !p->IsValueUnspecified() )
|
|
|
|
m_pPropGridManager->SetPropertyValue( p, h );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
id = m_pPropGridManager->GetPropertyByName ( "Size" );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( id )
|
2008-09-27 15:09:33 +00:00
|
|
|
m_pPropGridManager->SetPropertyValue( id, WXVARIANT(wxSize(w,h)) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Should always call event.Skip() in frame's SizeEvent handler
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridChanging( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = event.GetProperty();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( p->GetName() == "Font" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
int res =
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox(wxString::Format("'%s' is about to change (to variant of type '%s')\n\nAllow or deny?",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName(),event.GetValue().GetType()),
|
2018-09-29 01:45:15 +00:00
|
|
|
"Testing wxEVT_PG_CHANGING", wxYES_NO, m_pPropGridManager);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
if ( res == wxNO )
|
|
|
|
{
|
|
|
|
wxASSERT(event.CanVeto());
|
|
|
|
|
|
|
|
event.Veto();
|
|
|
|
|
|
|
|
// Since we ask a question, it is better if we omit any validation
|
2011-03-22 14:17:38 +00:00
|
|
|
// failure behaviour.
|
2008-09-12 20:57:41 +00:00
|
|
|
event.SetValidationFailureBehavior(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Note how we use three types of value getting in this method:
|
|
|
|
// A) event.GetPropertyValueAsXXX
|
|
|
|
// B) event.GetPropertValue, and then variant's GetXXX
|
|
|
|
// C) grid's GetPropertyValueAsXXX(id)
|
|
|
|
//
|
|
|
|
void FormMain::OnPropertyGridChange( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
wxPGProperty* property = event.GetProperty();
|
|
|
|
|
|
|
|
const wxString& name = property->GetName();
|
2010-04-16 14:36:32 +00:00
|
|
|
|
|
|
|
// Properties store values internally as wxVariants, but it is preferred
|
|
|
|
// to use the more modern wxAny at the interface level
|
|
|
|
wxAny value = property->GetValue();
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Don't handle 'unspecified' values
|
|
|
|
if ( value.IsNull() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Some settings are disabled outside Windows platform
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( name == "X" )
|
2014-05-15 22:32:17 +00:00
|
|
|
SetSize( value.As<int>(), -1, -1, -1, wxSIZE_USE_EXISTING );
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Y" )
|
2008-09-12 20:57:41 +00:00
|
|
|
// wxPGVariantToInt is safe long int value getter
|
2014-05-15 22:32:17 +00:00
|
|
|
SetSize ( -1, value.As<int>(), -1, -1, wxSIZE_USE_EXISTING );
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Width" )
|
2014-05-15 22:32:17 +00:00
|
|
|
SetSize ( -1, -1, value.As<int>(), -1, wxSIZE_USE_EXISTING );
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Height" )
|
2014-05-15 22:32:17 +00:00
|
|
|
SetSize ( -1, -1, -1, value.As<int>(), wxSIZE_USE_EXISTING );
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Label" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
SetTitle( value.As<wxString>() );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Password" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
static int pwdMode = 0;
|
|
|
|
|
|
|
|
//m_pPropGridManager->SetPropertyAttribute(property, wxPG_STRING_PASSWORD, (long)pwdMode);
|
|
|
|
|
|
|
|
pwdMode++;
|
|
|
|
pwdMode &= 1;
|
|
|
|
}
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( name == "Font" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
wxFont font = value.As<wxFont>();
|
2011-05-03 16:29:04 +00:00
|
|
|
wxASSERT( font.IsOk() );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
m_pPropGridManager->SetFont( font );
|
|
|
|
}
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( name == "Margin Colour" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
wxColourPropertyValue cpv = value.As<wxColourPropertyValue>();
|
2008-09-16 15:55:53 +00:00
|
|
|
m_pPropGridManager->GetGrid()->SetMarginColour( cpv.m_colour );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Cell Colour" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
wxColourPropertyValue cpv = value.As<wxColourPropertyValue>();
|
2008-09-16 15:55:53 +00:00
|
|
|
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( cpv.m_colour );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Line Colour" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
wxColourPropertyValue cpv = value.As<wxColourPropertyValue>();
|
2008-09-16 15:55:53 +00:00
|
|
|
m_pPropGridManager->GetGrid()->SetLineColour( cpv.m_colour );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
2018-09-29 01:45:15 +00:00
|
|
|
else if ( name == "Cell Text Colour" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2014-05-15 22:32:17 +00:00
|
|
|
wxColourPropertyValue cpv = value.As<wxColourPropertyValue>();
|
2008-09-16 15:55:53 +00:00
|
|
|
m_pPropGridManager->GetGrid()->SetCellTextColour( cpv.m_colour );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridSelect( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
wxPGProperty* property = event.GetProperty();
|
|
|
|
if ( property )
|
|
|
|
{
|
2015-02-08 12:48:43 +00:00
|
|
|
m_itemEnable->Enable( true );
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( property->IsEnabled() )
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemEnable->SetItemLabel( "Disable" );
|
2008-09-12 20:57:41 +00:00
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemEnable->SetItemLabel( "Enable" );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-08 12:48:43 +00:00
|
|
|
m_itemEnable->Enable( false );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
wxPGProperty* prop = event.GetProperty();
|
|
|
|
wxStatusBar* sb = GetStatusBar();
|
|
|
|
if ( prop )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString text("Selected: ");
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPropertyLabel( prop );
|
|
|
|
sb->SetStatusText ( text );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridPageChange( wxPropertyGridEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
wxStatusBar* sb = GetStatusBar();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString text("Page Changed: ");
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPageName(m_pPropGridManager->GetSelectedPage());
|
|
|
|
sb->SetStatusText( text );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-08-23 15:31:03 +00:00
|
|
|
void FormMain::OnPropertyGridLabelEditBegin( wxPropertyGridEvent& event )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("wxPG_EVT_LABEL_EDIT_BEGIN(%s)",
|
2018-11-01 23:32:02 +00:00
|
|
|
event.GetProperty()->GetLabel());
|
2009-08-23 15:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridLabelEditEnding( wxPropertyGridEvent& event )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("wxPG_EVT_LABEL_EDIT_ENDING(%s)",
|
2018-11-01 23:32:02 +00:00
|
|
|
event.GetProperty()->GetLabel());
|
2009-08-23 15:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnPropertyGridHighlight( wxPropertyGridEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridItemRightClick( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
wxPGProperty* prop = event.GetProperty();
|
|
|
|
wxStatusBar* sb = GetStatusBar();
|
|
|
|
if ( prop )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString text("Right-clicked: ");
|
2008-09-12 20:57:41 +00:00
|
|
|
text += prop->GetLabel();
|
2018-09-29 01:45:15 +00:00
|
|
|
text += ", name=";
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPropertyName(prop);
|
|
|
|
sb->SetStatusText( text );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb->SetStatusText( wxEmptyString );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridItemDoubleClick( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
wxPGProperty* prop = event.GetProperty();
|
|
|
|
wxStatusBar* sb = GetStatusBar();
|
|
|
|
if ( prop )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString text("Double-clicked: ");
|
2008-09-12 20:57:41 +00:00
|
|
|
text += prop->GetLabel();
|
2018-09-29 01:45:15 +00:00
|
|
|
text += ", name=";
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPropertyName(prop);
|
|
|
|
sb->SetStatusText ( text );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb->SetStatusText ( wxEmptyString );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridButtonClick ( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
#if wxUSE_STATUSBAR
|
2008-09-25 17:11:02 +00:00
|
|
|
wxPGProperty* prop = m_pPropGridManager->GetSelection();
|
2008-09-12 20:57:41 +00:00
|
|
|
wxStatusBar* sb = GetStatusBar();
|
|
|
|
if ( prop )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString text("Button clicked: ");
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPropertyLabel(prop);
|
2018-09-29 01:45:15 +00:00
|
|
|
text += ", name=";
|
2008-09-12 20:57:41 +00:00
|
|
|
text += m_pPropGridManager->GetPropertyName(prop);
|
|
|
|
sb->SetStatusText( text );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
::wxMessageBox("SHOULD NOT HAPPEN!!!");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridItemCollapse( wxPropertyGridEvent& )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("Item was Collapsed");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridItemExpand( wxPropertyGridEvent& )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("Item was Expanded");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-12-12 09:38:10 +00:00
|
|
|
void FormMain::OnPropertyGridColBeginDrag( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
if ( m_itemVetoDragging->IsChecked() )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("Splitter %i resize was vetoed", event.GetColumn());
|
2009-12-12 09:38:10 +00:00
|
|
|
event.Veto();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("Splitter %i resize began", event.GetColumn());
|
2009-12-12 09:38:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridColDragging( wxPropertyGridEvent& event )
|
|
|
|
{
|
2009-12-12 09:59:20 +00:00
|
|
|
wxUnusedVar(event);
|
2009-12-12 09:38:10 +00:00
|
|
|
// For now, let's not spam the log output
|
2018-09-29 01:45:15 +00:00
|
|
|
//wxLogDebug("Splitter %i is being resized", event.GetColumn());
|
2009-12-12 09:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridColEndDrag( wxPropertyGridEvent& event )
|
|
|
|
{
|
2017-11-25 16:50:08 +00:00
|
|
|
wxUnusedVar(event);
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("Splitter %i resize ended", event.GetColumn());
|
2009-12-12 09:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// EVT_TEXT handling
|
|
|
|
void FormMain::OnPropertyGridTextUpdate( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPropertyGridKeyEvent( wxKeyEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
// Occurs on wxGTK mostly, but not wxMSW.
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnLabelTextChange( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
// Uncomment following to allow property label modify in real-time
|
|
|
|
// wxPGProperty& p = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
// if ( !p.IsOk() ) return;
|
|
|
|
// m_pPropGridManager->SetPropertyLabel( p, m_tcPropLabel->DoGetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
static const wxString _fs_windowstyle_labels[] = {
|
|
|
|
"wxSIMPLE_BORDER",
|
|
|
|
"wxDOUBLE_BORDER",
|
|
|
|
"wxSUNKEN_BORDER",
|
|
|
|
"wxRAISED_BORDER",
|
|
|
|
"wxNO_BORDER",
|
|
|
|
"wxTRANSPARENT_WINDOW",
|
|
|
|
"wxTAB_TRAVERSAL",
|
|
|
|
"wxWANTS_CHARS",
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxNO_FULL_REPAINT_ON_RESIZE
|
2018-09-29 01:45:15 +00:00
|
|
|
"wxNO_FULL_REPAINT_ON_RESIZE",
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
2018-09-29 01:45:15 +00:00
|
|
|
"wxVSCROLL",
|
|
|
|
"wxALWAYS_SHOW_SB",
|
|
|
|
"wxCLIP_CHILDREN",
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxFULL_REPAINT_ON_RESIZE
|
2018-09-29 01:45:15 +00:00
|
|
|
"wxFULL_REPAINT_ON_RESIZE",
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
2018-09-29 01:45:15 +00:00
|
|
|
};
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
static const long _fs_windowstyle_values[] = {
|
|
|
|
wxSIMPLE_BORDER,
|
|
|
|
wxDOUBLE_BORDER,
|
|
|
|
wxSUNKEN_BORDER,
|
|
|
|
wxRAISED_BORDER,
|
|
|
|
wxNO_BORDER,
|
|
|
|
wxTRANSPARENT_WINDOW,
|
|
|
|
wxTAB_TRAVERSAL,
|
|
|
|
wxWANTS_CHARS,
|
|
|
|
#if wxNO_FULL_REPAINT_ON_RESIZE
|
|
|
|
wxNO_FULL_REPAINT_ON_RESIZE,
|
|
|
|
#endif
|
|
|
|
wxVSCROLL,
|
|
|
|
wxALWAYS_SHOW_SB,
|
|
|
|
wxCLIP_CHILDREN,
|
|
|
|
#if wxFULL_REPAINT_ON_RESIZE
|
|
|
|
wxFULL_REPAINT_ON_RESIZE
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
static const wxString _fs_framestyle_labels[] = {
|
|
|
|
"wxCAPTION",
|
|
|
|
"wxMINIMIZE",
|
|
|
|
"wxMAXIMIZE",
|
|
|
|
"wxCLOSE_BOX",
|
|
|
|
"wxSTAY_ON_TOP",
|
|
|
|
"wxSYSTEM_MENU",
|
|
|
|
"wxRESIZE_BORDER",
|
|
|
|
"wxFRAME_TOOL_WINDOW",
|
|
|
|
"wxFRAME_NO_TASKBAR",
|
|
|
|
"wxFRAME_FLOAT_ON_PARENT",
|
|
|
|
"wxFRAME_SHAPED"
|
2008-09-12 20:57:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const long _fs_framestyle_values[] = {
|
|
|
|
wxCAPTION,
|
|
|
|
wxMINIMIZE,
|
|
|
|
wxMAXIMIZE,
|
|
|
|
wxCLOSE_BOX,
|
|
|
|
wxSTAY_ON_TOP,
|
|
|
|
wxSYSTEM_MENU,
|
|
|
|
wxRESIZE_BORDER,
|
|
|
|
wxFRAME_TOOL_WINDOW,
|
|
|
|
wxFRAME_NO_TASKBAR,
|
|
|
|
wxFRAME_FLOAT_ON_PARENT,
|
|
|
|
wxFRAME_SHAPED
|
|
|
|
};
|
|
|
|
void FormMain::OnTestXRC(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("Sorry, not yet implemented");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormMain::OnEnableCommonValues(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2008-09-25 17:11:02 +00:00
|
|
|
wxPGProperty* prop = m_pPropGridManager->GetSelection();
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( prop )
|
|
|
|
prop->EnableCommonValue();
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormMain::PopulateWithStandardItems ()
|
|
|
|
{
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPropertyGridPage* pg = pgman->GetPage("Standard Items");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Append is ideal way to add items to wxPropertyGrid.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxPropertyCategory("Appearance",wxPG_LABEL) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty("Label",wxPG_LABEL,GetTitle()) );
|
|
|
|
pg->Append( new wxFontProperty("Font",wxPG_LABEL) );
|
|
|
|
pg->SetPropertyHelpString ( "Font", "Editing this will change font used in the property grid." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxSystemColourProperty("Margin Colour",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->GetGrid()->GetMarginColour()) );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxSystemColourProperty("Cell Colour",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->GetGrid()->GetCellBackgroundColour()) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxSystemColourProperty("Cell Text Colour",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->GetGrid()->GetCellTextColour()) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxSystemColourProperty("Line Colour",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->GetGrid()->GetLineColour()) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxFlagsProperty("Window Styles",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
m_combinedFlags, GetWindowStyle()) );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
//pg->SetPropertyAttribute("Window Styles",wxPG_BOOL_USE_CHECKBOX,true,wxPG_RECURSE);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxCursorProperty("Cursor",wxPG_LABEL) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxPropertyCategory("Position","PositionCategory") );
|
|
|
|
pg->SetPropertyHelpString( "PositionCategory", "Change in items in this category will cause respective changes in frame." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Let's demonstrate 'Units' attribute here
|
|
|
|
|
|
|
|
// Note that we use many attribute constants instead of strings here
|
2018-09-29 01:45:15 +00:00
|
|
|
// (for instance, wxPG_ATTR_MIN, instead of "min").
|
2008-09-12 20:57:41 +00:00
|
|
|
// Using constant may reduce binary size.
|
|
|
|
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->Append( new wxIntProperty("Height",wxPG_LABEL,480L) );
|
|
|
|
pg->SetPropertyAttribute("Height", wxPG_ATTR_MIN, 10L );
|
|
|
|
pg->SetPropertyAttribute("Height", wxPG_ATTR_MAX, 2048L );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute("Height", wxPG_ATTR_UNITS, "Pixels" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2009-12-26 10:45:04 +00:00
|
|
|
// Set value to unspecified so that Hint attribute will be demonstrated
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValueUnspecified("Height");
|
|
|
|
pg->SetPropertyAttribute("Height", wxPG_ATTR_HINT,
|
|
|
|
"Enter new height for window" );
|
2009-12-26 10:45:04 +00:00
|
|
|
|
|
|
|
// Difference between hint and help string is that the hint is shown in
|
|
|
|
// an empty value cell, while help string is shown either in the
|
|
|
|
// description text box, as a tool tip, or on the status bar.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString("Height",
|
|
|
|
"This property uses attributes \"Units\" and \"Hint\".");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->Append( new wxIntProperty("Width",wxPG_LABEL,640L) );
|
|
|
|
pg->SetPropertyAttribute("Width", wxPG_ATTR_MIN, 10L );
|
|
|
|
pg->SetPropertyAttribute("Width", wxPG_ATTR_MAX, 2048L );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute("Width", wxPG_ATTR_UNITS, "Pixels" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValueUnspecified("Width");
|
|
|
|
pg->SetPropertyAttribute("Width", wxPG_ATTR_HINT,
|
|
|
|
"Enter new width for window" );
|
|
|
|
pg->SetPropertyHelpString("Width",
|
|
|
|
"This property uses attributes \"Units\" and \"Hint\".");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->Append( new wxIntProperty("X",wxPG_LABEL,10L) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute("X", wxPG_ATTR_UNITS, "Pixels" );
|
|
|
|
pg->SetPropertyHelpString("X", "This property uses \"Units\" attribute.");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->Append( new wxIntProperty("Y",wxPG_LABEL,10L) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute("Y", wxPG_ATTR_UNITS, "Pixels" );
|
|
|
|
pg->SetPropertyHelpString("Y", "This property uses \"Units\" attribute.");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
const wxString disabledHelpString = "This property is simply disabled. In order to have label disabled as well, "
|
|
|
|
"you need to set wxPG_EX_GREY_LABEL_WHEN_DISABLED using SetExtraStyle.";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxPropertyCategory("Environment",wxPG_LABEL) );
|
|
|
|
pg->Append( new wxStringProperty("Operating System",wxPG_LABEL,::wxGetOsDescription()) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty("User Id",wxPG_LABEL,::wxGetUserId()) );
|
|
|
|
pg->Append( new wxDirProperty("User Home",wxPG_LABEL,::wxGetUserHome()) );
|
|
|
|
pg->Append( new wxStringProperty("User Name",wxPG_LABEL,::wxGetUserName()) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Disable some of them
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->DisableProperty( "Operating System" );
|
|
|
|
pg->DisableProperty( "User Id" );
|
|
|
|
pg->DisableProperty( "User Name" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "Operating System", disabledHelpString );
|
|
|
|
pg->SetPropertyHelpString( "User Id", disabledHelpString );
|
|
|
|
pg->SetPropertyHelpString( "User Name", disabledHelpString );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxPropertyCategory("More Examples",wxPG_LABEL) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxFontDataProperty( "FontDataProperty", wxPG_LABEL) );
|
|
|
|
pg->SetPropertyHelpString( "FontDataProperty",
|
|
|
|
"This demonstrates wxFontDataProperty class defined in this sample app. "
|
|
|
|
"It is exactly like wxFontProperty from the library, but also has colour sub-property."
|
2008-09-12 20:57:41 +00:00
|
|
|
);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxDirsProperty("DirsProperty",wxPG_LABEL) );
|
|
|
|
pg->SetPropertyHelpString( "DirsProperty",
|
|
|
|
"This demonstrates wxDirsProperty class defined in this sample app. "
|
|
|
|
"It is built with WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR macro, "
|
|
|
|
"with custom action (dir dialog popup) defined."
|
2008-09-12 20:57:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
wxArrayDouble arrdbl;
|
|
|
|
arrdbl.Add(-1.0);
|
|
|
|
arrdbl.Add(-0.5);
|
|
|
|
arrdbl.Add(0.0);
|
|
|
|
arrdbl.Add(0.5);
|
|
|
|
arrdbl.Add(1.0);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxArrayDoubleProperty("ArrayDoubleProperty",wxPG_LABEL,arrdbl) );
|
2019-05-26 16:52:43 +00:00
|
|
|
//pg->SetPropertyAttribute("ArrayDoubleProperty",wxPG_FLOAT_PRECISION,2L);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "ArrayDoubleProperty",
|
|
|
|
"This demonstrates wxArrayDoubleProperty class defined in this sample app. "
|
|
|
|
"It is an example of a custom list editor property."
|
2008-09-12 20:57:41 +00:00
|
|
|
);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxLongStringProperty("Information",wxPG_LABEL,
|
|
|
|
"Editing properties will have immediate effect on this window, "
|
|
|
|
"and vice versa (at least in most cases, that is)."
|
2008-09-12 20:57:41 +00:00
|
|
|
) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "Information",
|
|
|
|
"This property is read-only." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyReadOnly( "Information", true );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Set test information for cells in columns 3 and 4
|
|
|
|
// (reserve column 2 for displaying units)
|
|
|
|
wxPropertyGridIterator it;
|
2018-12-23 21:13:43 +00:00
|
|
|
int bmpH = pg->GetGrid()->GetRowHeight() - 2;
|
|
|
|
wxBitmap bmp = wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(bmpH, bmpH));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
for ( it = pg->GetGrid()->GetIterator();
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
if ( p->IsCategory() )
|
|
|
|
continue;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyCell( p, 3, "Cell 3", bmp );
|
|
|
|
pg->SetPropertyCell( p, 4, "Cell 4", wxNullBitmap, *wxWHITE, *wxBLACK );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::PopulateWithExamples ()
|
|
|
|
{
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPropertyGridPage* pg = pgman->GetPage("Examples");
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPGProperty* pid;
|
2008-09-19 17:39:09 +00:00
|
|
|
wxPGProperty* prop;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
//pg->Append( new wxPropertyCategory("Examples (low priority)","Examples") );
|
|
|
|
//pg->SetPropertyHelpString ( "Examples", "This category has example of (almost) every built-in property class." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#if wxUSE_SPINBTN
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->Append( new wxIntProperty ( "SpinCtrl", wxPG_LABEL, 0L ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyEditor( "SpinCtrl", wxPGEditor_SpinCtrl );
|
2019-06-28 18:45:04 +00:00
|
|
|
pg->SetPropertyAttribute( "SpinCtrl", wxPG_ATTR_MIN, -2L ); // Use constants instead of string
|
2019-05-26 16:52:43 +00:00
|
|
|
pg->SetPropertyAttribute( "SpinCtrl", wxPG_ATTR_MAX, 16384L ); // for reduced binary size.
|
|
|
|
pg->SetPropertyAttribute( "SpinCtrl", wxPG_ATTR_SPINCTRL_STEP, 2L );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute( "SpinCtrl", wxPG_ATTR_SPINCTRL_MOTION, true );
|
|
|
|
//pg->SetPropertyAttribute( "SpinCtrl", wxPG_ATTR_SPINCTRL_WRAP, true );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "SpinCtrl",
|
|
|
|
"This is regular wxIntProperty, which editor has been "
|
|
|
|
"changed to wxPGEditor_SpinCtrl. Note however that "
|
|
|
|
"static wxPropertyGrid::RegisterAdditionalEditors() "
|
|
|
|
"needs to be called prior to using it.");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Add bool property
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxBoolProperty( "BoolProperty", wxPG_LABEL, false ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Add bool property with check box
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxBoolProperty( "BoolProperty with CheckBox", wxPG_LABEL, false ) );
|
|
|
|
pg->SetPropertyAttribute( "BoolProperty with CheckBox",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPG_BOOL_USE_CHECKBOX,
|
|
|
|
true );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "BoolProperty with CheckBox",
|
|
|
|
"Property attribute wxPG_BOOL_USE_CHECKBOX has been set to true." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pg->Append( new wxFloatProperty("FloatProperty",
|
2010-07-25 09:23:25 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
1234500.23) );
|
2015-01-21 17:11:36 +00:00
|
|
|
prop->SetAttribute(wxPG_ATTR_MIN, -100.12);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// A string property that can be edited in a separate editor dialog.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxLongStringProperty( "LongStringProperty", "LongStringProp",
|
|
|
|
"This is much longer string than the first one. Edit it by clicking the button." ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// A property that edits a wxArrayString.
|
|
|
|
wxArrayString example_array;
|
2018-09-29 01:45:15 +00:00
|
|
|
example_array.Add( "String 1");
|
|
|
|
example_array.Add( "String 2");
|
|
|
|
example_array.Add( "String 3");
|
|
|
|
pg->Append( new wxArrayStringProperty( "ArrayStringProperty", wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
example_array) );
|
|
|
|
|
|
|
|
// Test adding same category multiple times ( should not actually create a new one )
|
2018-09-29 01:45:15 +00:00
|
|
|
//pg->Append( new wxPropertyCategory("Examples (low priority)","Examples") );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// A file selector property. Note that argument between name
|
|
|
|
// and initial value is wildcard (format same as in wxFileDialog).
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = new wxFileProperty( "FileProperty", "TextFile" );
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->Append( prop );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
prop->SetAttribute(wxPG_FILE_WILDCARD,"Text Files (*.txt)|*.txt");
|
2019-08-03 18:47:06 +00:00
|
|
|
prop->SetAttribute(wxPG_DIALOG_TITLE,"Custom File Dialog Title");
|
2008-09-12 20:57:41 +00:00
|
|
|
prop->SetAttribute(wxPG_FILE_SHOW_FULL_PATH,false);
|
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
2018-09-29 01:45:15 +00:00
|
|
|
prop->SetAttribute(wxPG_FILE_SHOW_RELATIVE_PATH,"C:\\Windows");
|
|
|
|
pg->SetPropertyValue(prop,"C:\\Windows\\System32\\msvcrt71.dll");
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if wxUSE_IMAGE
|
|
|
|
// An image file property. Arguments are just like for FileProperty, but
|
|
|
|
// wildcard is missing (it is autogenerated from supported image formats).
|
|
|
|
// If you really need to override it, create property separately, and call
|
|
|
|
// its SetWildcard method.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxImageFileProperty( "ImageFile", wxPG_LABEL ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = pg->Append( new wxColourProperty("ColourProperty",wxPG_LABEL,*wxRED) );
|
|
|
|
pg->SetPropertyEditor( "ColourProperty", wxPGEditor_ComboBox );
|
|
|
|
pg->GetProperty("ColourProperty")->SetAutoUnspecified(true);
|
|
|
|
pg->SetPropertyHelpString( "ColourProperty",
|
|
|
|
"wxPropertyGrid::SetPropertyEditor method has been used to change "
|
|
|
|
"editor of this property to wxPGEditor_ComboBox)");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = pg->Append( new wxColourProperty("ColourPropertyWithAlpha",
|
2011-01-02 10:14:29 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
wxColour(15, 200, 95, 128)) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute("ColourPropertyWithAlpha", wxPG_COLOUR_HAS_ALPHA, true);
|
|
|
|
pg->SetPropertyHelpString("ColourPropertyWithAlpha",
|
|
|
|
"Attribute \"HasAlpha\" is set to true for this property.");
|
2011-01-02 10:14:29 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
//
|
|
|
|
// This demonstrates using alternative editor for colour property
|
|
|
|
// to trigger colour dialog directly from button.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxColourProperty("ColourProperty2",wxPG_LABEL,*wxGREEN) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// wxEnumProperty does not store strings or even list of strings
|
|
|
|
// ( so that's why they are static in function ).
|
2018-09-29 01:45:15 +00:00
|
|
|
static const wxString enum_prop_labels[] = { "One Item",
|
|
|
|
"Another Item", "One More", "This Is Last" };
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// this value array would be optional if values matched string indexes
|
|
|
|
static long enum_prop_values[] = { 40, 80, 120, 160 };
|
|
|
|
|
|
|
|
// note that the initial value (the last argument) is the actual value,
|
|
|
|
// not index or anything like that. Thus, our value selects "Another Item".
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty",wxPG_LABEL,
|
|
|
|
wxArrayString(WXSIZEOF(enum_prop_labels), enum_prop_labels),
|
|
|
|
wxArrayInt(enum_prop_values, enum_prop_values+ WXSIZEOF(enum_prop_values)), 80 ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPGChoices soc;
|
|
|
|
|
|
|
|
// use basic table from our previous example
|
|
|
|
// can also set/add wxArrayStrings and wxArrayInts directly.
|
2018-09-29 01:45:15 +00:00
|
|
|
soc.Set(wxArrayString(WXSIZEOF(enum_prop_labels), enum_prop_labels),
|
|
|
|
wxArrayInt(enum_prop_values, enum_prop_values + WXSIZEOF(enum_prop_values)));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// add extra items
|
2018-09-29 01:45:15 +00:00
|
|
|
soc.Add( "Look, it continues", 200 );
|
|
|
|
soc.Add( "Even More", 240 );
|
|
|
|
soc.Add( "And More", 280 );
|
2015-06-04 20:53:30 +00:00
|
|
|
soc.Add( wxEmptyString, 300 );
|
2018-09-29 01:45:15 +00:00
|
|
|
soc.Add( "True End of the List", 320 );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Test custom colours ([] operator of wxPGChoices returns
|
|
|
|
// references to wxPGChoiceEntry).
|
|
|
|
soc[1].SetFgCol(*wxRED);
|
|
|
|
soc[1].SetBgCol(*wxLIGHT_GREY);
|
|
|
|
soc[2].SetFgCol(*wxGREEN);
|
|
|
|
soc[2].SetBgCol(*wxLIGHT_GREY);
|
|
|
|
soc[3].SetFgCol(*wxBLUE);
|
|
|
|
soc[3].SetBgCol(*wxLIGHT_GREY);
|
|
|
|
soc[4].SetBitmap(wxArtProvider::GetBitmap(wxART_FOLDER));
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty 2",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
soc,
|
|
|
|
240) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->GetProperty("EnumProperty 2")->AddChoice("Testing Extra", 360);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2009-02-04 16:45:23 +00:00
|
|
|
// Here we only display the original 'soc' choices
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty 3",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
soc, 240 ) );
|
|
|
|
|
2009-12-26 10:45:04 +00:00
|
|
|
// Test Hint attribute in EnumProperty
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->GetProperty("EnumProperty 3")->SetAttribute(wxPG_ATTR_HINT, "Dummy Hint");
|
2009-12-26 10:45:04 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString("EnumProperty 3",
|
|
|
|
"This property uses \"Hint\" attribute.");
|
2009-12-26 10:45:04 +00:00
|
|
|
|
2009-02-04 16:45:23 +00:00
|
|
|
// 'soc' plus one exclusive extra choice "4th only"
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty 4",wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
soc, 240 ) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->GetProperty("EnumProperty 4")->AddChoice("4th only", 360);
|
2008-09-19 16:57:33 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString("EnumProperty 4",
|
|
|
|
"Should have one extra item when compared to EnumProperty 3");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2015-06-28 22:04:47 +00:00
|
|
|
// Plus property value bitmap
|
2018-10-01 11:55:42 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty With Bitmap", "EnumProperty 5",
|
2015-06-28 22:04:47 +00:00
|
|
|
soc, 280) );
|
2018-10-01 11:55:42 +00:00
|
|
|
pg->SetPropertyHelpString("EnumProperty 5",
|
2018-09-29 01:45:15 +00:00
|
|
|
"Should have bitmap in front of the displayed value");
|
2015-06-28 22:04:47 +00:00
|
|
|
wxBitmap bmpVal = wxArtProvider::GetBitmap(wxART_REMOVABLE);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyImage("EnumProperty 5", bmpVal);
|
2015-06-28 22:04:47 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// Password property example.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty("Password",wxPG_LABEL, "password") );
|
|
|
|
pg->SetPropertyAttribute( "Password", wxPG_STRING_PASSWORD, true );
|
|
|
|
pg->SetPropertyHelpString( "Password",
|
|
|
|
"Has attribute wxPG_STRING_PASSWORD set to true" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// String editor with dir selector button. Uses wxEmptyString as name, which
|
|
|
|
// is allowed (naturally, in this case property cannot be accessed by name).
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxDirProperty( "DirProperty", wxPG_LABEL, ::wxGetUserHome()) );
|
|
|
|
pg->SetPropertyAttribute( "DirProperty",
|
2019-08-03 18:47:06 +00:00
|
|
|
wxPG_DIALOG_TITLE,
|
|
|
|
"This is a custom dir dialog title" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Add string property - first arg is label, second name, and third initial value
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty ( "StringProperty", wxPG_LABEL ) );
|
|
|
|
pg->SetPropertyMaxLength( "StringProperty", 6 );
|
|
|
|
pg->SetPropertyHelpString( "StringProperty",
|
|
|
|
"Max length of this text has been limited to 6, using wxPropertyGrid::SetPropertyMaxLength." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Set value after limiting so that it will be applied
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValue( "StringProperty", "some text" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2009-03-08 11:34:01 +00:00
|
|
|
//
|
|
|
|
// Demonstrate "AutoComplete" attribute
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty( "StringProperty AutoComplete",
|
2009-03-08 11:34:01 +00:00
|
|
|
wxPG_LABEL ) );
|
|
|
|
|
|
|
|
wxArrayString autoCompleteStrings;
|
2018-09-29 01:45:15 +00:00
|
|
|
autoCompleteStrings.Add("One choice");
|
|
|
|
autoCompleteStrings.Add("Another choice");
|
|
|
|
autoCompleteStrings.Add("Another choice, yeah");
|
|
|
|
autoCompleteStrings.Add("Yet another choice");
|
|
|
|
autoCompleteStrings.Add("Yet another choice, bear with me");
|
|
|
|
pg->SetPropertyAttribute( "StringProperty AutoComplete",
|
2015-01-21 17:11:36 +00:00
|
|
|
wxPG_ATTR_AUTOCOMPLETE,
|
2009-03-08 11:34:01 +00:00
|
|
|
autoCompleteStrings );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "StringProperty AutoComplete",
|
|
|
|
"AutoComplete attribute has been set for this property "
|
|
|
|
"(try writing something beginning with 'a', 'o' or 'y').");
|
2009-03-08 11:34:01 +00:00
|
|
|
|
2009-03-06 17:32:28 +00:00
|
|
|
// Add string property with arbitrarily wide bitmap in front of it. We
|
|
|
|
// intentionally lower-than-typical row height here so that the ugly
|
2015-06-13 20:28:28 +00:00
|
|
|
// scaling code won't be run.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxStringProperty( "StringPropertyWithBitmap",
|
2009-03-06 17:32:28 +00:00
|
|
|
wxPG_LABEL,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Test Text") );
|
2009-03-06 17:32:28 +00:00
|
|
|
wxBitmap myTestBitmap(60, 15, 32);
|
|
|
|
wxMemoryDC mdc;
|
|
|
|
mdc.SelectObject(myTestBitmap);
|
2019-10-01 22:08:24 +00:00
|
|
|
mdc.SetBackground(*wxWHITE_BRUSH);
|
2009-03-06 17:32:28 +00:00
|
|
|
mdc.Clear();
|
|
|
|
mdc.SetPen(*wxBLACK);
|
|
|
|
mdc.DrawLine(0, 0, 60, 15);
|
|
|
|
mdc.SelectObject(wxNullBitmap);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyImage( "StringPropertyWithBitmap", myTestBitmap );
|
2010-09-30 11:44:45 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// this value array would be optional if values matched string indexes
|
|
|
|
//long flags_prop_values[] = { wxICONIZE, wxCAPTION, wxMINIMIZE_BOX, wxMAXIMIZE_BOX };
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
//pg->Append( wxFlagsProperty("Example of FlagsProperty","FlagsProp",
|
2008-09-12 20:57:41 +00:00
|
|
|
// flags_prop_labels, flags_prop_values, 0, GetWindowStyle() ) );
|
|
|
|
|
|
|
|
|
|
|
|
// Multi choice dialog.
|
|
|
|
wxArrayString tchoices;
|
2018-09-29 01:45:15 +00:00
|
|
|
tchoices.Add("Cabbage");
|
|
|
|
tchoices.Add("Carrot");
|
|
|
|
tchoices.Add("Onion");
|
|
|
|
tchoices.Add("Potato");
|
|
|
|
tchoices.Add("Strawberry");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxArrayString tchoicesValues;
|
2018-09-29 01:45:15 +00:00
|
|
|
tchoicesValues.Add("Carrot");
|
|
|
|
tchoicesValues.Add("Potato");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("EnumProperty X",wxPG_LABEL, tchoices ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxMultiChoiceProperty( "MultiChoiceProperty", wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
tchoices, tchoicesValues ) );
|
2019-04-22 10:43:55 +00:00
|
|
|
pg->SetPropertyAttribute("MultiChoiceProperty", wxPG_ATTR_MULTICHOICE_USERSTRINGMODE, 1);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxSizeProperty( "SizeProperty", "Size", GetSize() ) );
|
|
|
|
pg->Append( new wxPointProperty( "PointProperty", "Position", GetPosition() ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// UInt samples
|
2015-04-03 19:13:44 +00:00
|
|
|
#if wxUSE_LONGLONG
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxUIntProperty( "UIntProperty", wxPG_LABEL, wxULongLong(wxULL(0xFEEEFEEEFEEE))));
|
2015-04-03 19:13:44 +00:00
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxUIntProperty( "UIntProperty", wxPG_LABEL, 0xFEEEFEEE));
|
2015-04-03 19:13:44 +00:00
|
|
|
#endif
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute( "UIntProperty", wxPG_UINT_PREFIX, wxPG_PREFIX_NONE );
|
|
|
|
pg->SetPropertyAttribute( "UIntProperty", wxPG_UINT_BASE, wxPG_BASE_HEX );
|
|
|
|
//pg->SetPropertyAttribute( "UIntProperty", wxPG_UINT_PREFIX, wxPG_PREFIX_NONE );
|
|
|
|
//pg->SetPropertyAttribute( "UIntProperty", wxPG_UINT_BASE, wxPG_BASE_OCT );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// wxEditEnumProperty
|
|
|
|
wxPGChoices eech;
|
2018-09-29 01:45:15 +00:00
|
|
|
eech.Add("Choice 1");
|
|
|
|
eech.Add("Choice 2");
|
|
|
|
eech.Add("Choice 3");
|
|
|
|
pg->Append( new wxEditEnumProperty("EditEnumProperty",
|
2009-10-01 16:06:58 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
eech,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Choice not in the list") );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2009-12-26 10:45:04 +00:00
|
|
|
// Test Hint attribute in EditEnumProperty
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->GetProperty("EditEnumProperty")->SetAttribute(wxPG_ATTR_HINT, "Dummy Hint");
|
2009-12-26 10:45:04 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
//wxString v_;
|
|
|
|
//wxTextValidator validator1(wxFILTER_NUMERIC,&v_);
|
2018-09-29 01:45:15 +00:00
|
|
|
//pg->SetPropertyValidator( "EditEnumProperty", validator1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#if wxUSE_DATETIME
|
|
|
|
//
|
|
|
|
// wxDateTimeProperty
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxDateProperty("DateProperty", wxPG_LABEL, wxDateTime::Now() ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#if wxUSE_DATEPICKCTRL
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyAttribute( "DateProperty", wxPG_DATE_PICKER_STYLE,
|
2009-01-12 17:05:37 +00:00
|
|
|
(long)(wxDP_DROPDOWN |
|
|
|
|
wxDP_SHOWCENTURY |
|
|
|
|
wxDP_ALLOWNONE) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "DateProperty",
|
|
|
|
"Attribute wxPG_DATE_PICKER_STYLE has been set to (long)"
|
|
|
|
"(wxDP_DROPDOWN | wxDP_SHOWCENTURY | wxDP_ALLOWNONE)." );
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// Add Triangle properties as both wxTriangleProperty and
|
|
|
|
// a generic parent property (using wxStringProperty).
|
|
|
|
//
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* topId = pg->Append( new wxStringProperty("3D Object", wxPG_LABEL, "<composed>") );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = pg->AppendIn( topId, new wxStringProperty("Triangle 1", "Triangle 1", "<composed>") );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "A", wxPG_LABEL ) );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "B", wxPG_LABEL ) );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "C", wxPG_LABEL ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn( topId, new wxTriangleProperty( "Triangle 2", "Triangle 2" ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString( "3D Object",
|
|
|
|
"3D Object is wxStringProperty with value \"<composed>\". Two of its children are similar wxStringProperties with "
|
|
|
|
"three wxVectorProperty children, and other two are custom wxTriangleProperties." );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = pg->AppendIn( topId, new wxStringProperty("Triangle 3", "Triangle 3", "<composed>") );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "A", wxPG_LABEL ) );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "B", wxPG_LABEL ) );
|
|
|
|
pg->AppendIn( pid, new wxVectorProperty( "C", wxPG_LABEL ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn( topId, new wxTriangleProperty( "Triangle 4", "Triangle 4" ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// This snippet is a doc sample test
|
|
|
|
//
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* carProp = pg->Append(new wxStringProperty("Car",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,
|
2018-09-29 01:45:15 +00:00
|
|
|
"<composed>"));
|
2008-09-21 14:13:32 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(carProp, new wxStringProperty("Model",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Lamborghini Diablo SV"));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(carProp, new wxIntProperty("Engine Size (cc)",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPG_LABEL,
|
2019-05-26 16:52:43 +00:00
|
|
|
5707L) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPGProperty* speedsProp = pg->AppendIn(carProp,
|
2018-09-29 01:45:15 +00:00
|
|
|
new wxStringProperty("Speeds",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,
|
2018-09-29 01:45:15 +00:00
|
|
|
"<composed>"));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn( speedsProp, new wxIntProperty("Max. Speed (mph)",
|
2019-05-26 16:52:43 +00:00
|
|
|
wxPG_LABEL,290L) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn( speedsProp, new wxFloatProperty("0-100 mph (sec)",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,3.9) );
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn( speedsProp, new wxFloatProperty("1/4 mile (sec)",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,8.6) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2008-09-21 14:13:32 +00:00
|
|
|
// This is how child property can be referred to by name
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValue( "Car.Speeds.Max. Speed (mph)", 300 );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(carProp, new wxIntProperty("Price ($)",
|
2008-09-21 14:13:32 +00:00
|
|
|
wxPG_LABEL,
|
2019-05-26 16:52:43 +00:00
|
|
|
300000L) );
|
2008-09-21 14:13:32 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(carProp, new wxBoolProperty("Convertible",
|
2009-01-04 18:38:00 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
false) );
|
|
|
|
|
2008-09-21 14:13:32 +00:00
|
|
|
// Displayed value of "Car" property is now very close to this:
|
|
|
|
// "Lamborghini Diablo SV; 5707 [300; 3.9; 8.6] 300000"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Test wxSampleMultiButtonEditor
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxLongStringProperty("MultipleButtons", wxPG_LABEL) );
|
|
|
|
pg->SetPropertyEditor("MultipleButtons", m_pSampleMultiButtonEditor );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Test SingleChoiceProperty
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new SingleChoiceProperty("SingleChoiceProperty") );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Test adding variable height bitmaps in wxPGChoices
|
|
|
|
wxPGChoices bc;
|
2018-09-29 01:45:15 +00:00
|
|
|
bc.Add("Wee",
|
2015-08-08 20:21:25 +00:00
|
|
|
wxArtProvider::GetBitmap(wxART_CDROM, wxART_OTHER, wxSize(16, 16)));
|
2018-09-29 01:45:15 +00:00
|
|
|
bc.Add("Not so wee",
|
2015-08-08 20:21:25 +00:00
|
|
|
wxArtProvider::GetBitmap(wxART_FLOPPY, wxART_OTHER, wxSize(32, 32)));
|
2018-09-29 01:45:15 +00:00
|
|
|
bc.Add("Friggin' huge",
|
2015-08-08 20:21:25 +00:00
|
|
|
wxArtProvider::GetBitmap(wxART_HARDDISK, wxART_OTHER, wxSize(64, 64)));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new wxEnumProperty("Variable Height Bitmaps",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
bc,
|
|
|
|
0) );
|
|
|
|
|
|
|
|
//
|
|
|
|
// Test how non-editable composite strings appear
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = new wxStringProperty("wxWidgets Traits", wxPG_LABEL, "<composed>");
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->SetPropertyReadOnly(pid);
|
|
|
|
|
2008-10-14 17:15:59 +00:00
|
|
|
//
|
|
|
|
// For testing purposes, combine two methods of adding children
|
|
|
|
//
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid->AppendChild( new wxStringProperty("Latest Release",
|
2009-03-12 18:17:55 +00:00
|
|
|
wxPG_LABEL,
|
2019-04-21 21:26:01 +00:00
|
|
|
"3.1.2"));
|
2018-09-29 01:45:15 +00:00
|
|
|
pid->AppendChild( new wxBoolProperty("Win API",
|
2009-03-12 18:17:55 +00:00
|
|
|
wxPG_LABEL,
|
|
|
|
true) );
|
2008-10-14 17:15:59 +00:00
|
|
|
|
|
|
|
pg->Append( pid );
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(pid, new wxBoolProperty("QT", wxPG_LABEL, true) );
|
|
|
|
pg->AppendIn(pid, new wxBoolProperty("Cocoa", wxPG_LABEL, true) );
|
2019-04-21 21:26:01 +00:00
|
|
|
pg->AppendIn(pid, new wxBoolProperty("Haiku", wxPG_LABEL, false) );
|
|
|
|
pg->AppendIn(pid, new wxStringProperty("Trunk Version", wxPG_LABEL, wxVERSION_NUM_DOT_STRING));
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->AppendIn(pid, new wxBoolProperty("GTK+", wxPG_LABEL, true) );
|
|
|
|
pg->AppendIn(pid, new wxBoolProperty("Android", wxPG_LABEL, false) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
AddTestProperties(pg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::PopulateWithLibraryConfig ()
|
|
|
|
{
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPropertyGridPage* pg = pgman->GetPage("wxWidgets Library Config");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2010-03-01 15:26:07 +00:00
|
|
|
// Set custom column proportions (here in the sample app we need
|
|
|
|
// to check if the grid has wxPG_SPLITTER_AUTO_CENTER style. You usually
|
|
|
|
// need not to do it in your application).
|
|
|
|
if ( pgman->HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
|
|
|
{
|
|
|
|
pg->SetColumnProportion(0, 3);
|
|
|
|
pg->SetColumnProportion(1, 1);
|
|
|
|
}
|
2010-02-14 14:09:06 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPGProperty* cat;
|
|
|
|
|
|
|
|
wxBitmap bmp = wxArtProvider::GetBitmap(wxART_REPORT_VIEW);
|
|
|
|
|
|
|
|
wxPGProperty* pid;
|
|
|
|
|
2009-10-15 14:41:00 +00:00
|
|
|
wxFont italicFont = pgman->GetGrid()->GetCaptionFont();
|
|
|
|
italicFont.SetStyle(wxFONTSTYLE_ITALIC);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString italicFontHelp = "Font of this property's wxPGCell has "
|
|
|
|
"been modified. Obtain property's cell "
|
|
|
|
"with wxPGProperty::"
|
|
|
|
"GetOrCreateCell(column).";
|
2009-10-15 14:41:00 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
#define ADD_WX_LIB_CONF_GROUP(A) \
|
|
|
|
cat = pg->AppendIn( pid, new wxPropertyCategory(A) ); \
|
2009-10-15 14:41:00 +00:00
|
|
|
pg->SetPropertyCell( cat, 0, wxPG_LABEL, bmp ); \
|
|
|
|
cat->GetCell(0).SetFont(italicFont); \
|
|
|
|
cat->SetHelpString(italicFontHelp);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
#define ADD_WX_LIB_CONF(A) pg->Append( new wxBoolProperty(#A,wxPG_LABEL,(bool)((A>0)?true:false)));
|
|
|
|
#define ADD_WX_LIB_CONF_NODEF(A) pg->Append( new wxBoolProperty(#A,wxPG_LABEL,(bool)false) ); \
|
|
|
|
pg->DisableProperty(#A);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pid = pg->Append( new wxPropertyCategory( "wxWidgets Library Configuration" ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->SetPropertyCell( pid, 0, wxPG_LABEL, bmp );
|
|
|
|
|
2009-12-29 16:04:40 +00:00
|
|
|
// Both of following lines would set a label for the second column
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyCell( pid, 1, "Is Enabled" );
|
|
|
|
pid->SetValue("Is Enabled");
|
2009-12-29 16:04:40 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Global Settings")
|
2008-09-12 20:57:41 +00:00
|
|
|
ADD_WX_LIB_CONF( wxUSE_GUI )
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Compatibility Settings")
|
2008-09-12 20:57:41 +00:00
|
|
|
#if defined(WXWIN_COMPATIBILITY_2_8)
|
|
|
|
ADD_WX_LIB_CONF( WXWIN_COMPATIBILITY_2_8 )
|
|
|
|
#endif
|
2014-01-04 20:07:33 +00:00
|
|
|
#if defined(WXWIN_COMPATIBILITY_3_0)
|
|
|
|
ADD_WX_LIB_CONF( WXWIN_COMPATIBILITY_3_0 )
|
|
|
|
#endif
|
2008-09-12 20:57:41 +00:00
|
|
|
#ifdef wxFONT_SIZE_COMPATIBILITY
|
|
|
|
ADD_WX_LIB_CONF( wxFONT_SIZE_COMPATIBILITY )
|
|
|
|
#else
|
|
|
|
ADD_WX_LIB_CONF_NODEF ( wxFONT_SIZE_COMPATIBILITY )
|
|
|
|
#endif
|
|
|
|
#ifdef wxDIALOG_UNIT_COMPATIBILITY
|
|
|
|
ADD_WX_LIB_CONF( wxDIALOG_UNIT_COMPATIBILITY )
|
|
|
|
#else
|
|
|
|
ADD_WX_LIB_CONF_NODEF ( wxDIALOG_UNIT_COMPATIBILITY )
|
|
|
|
#endif
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Debugging Settings")
|
2008-09-12 20:57:41 +00:00
|
|
|
ADD_WX_LIB_CONF( wxUSE_DEBUG_CONTEXT )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_MEMORY_TRACING )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_GLOBAL_MEMORY_OPERATORS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_DEBUG_NEW_ALWAYS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_ON_FATAL_EXCEPTION )
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Unicode Support")
|
2008-09-12 20:57:41 +00:00
|
|
|
ADD_WX_LIB_CONF( wxUSE_UNICODE )
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Global Features")
|
2008-09-12 20:57:41 +00:00
|
|
|
ADD_WX_LIB_CONF( wxUSE_EXCEPTIONS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_EXTENDED_RTTI )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_STL )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_LOG )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_LOGWINDOW )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_LOGGUI )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_LOG_DIALOG )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_CMDLINE_PARSER )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_THREADS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_STREAMS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_STD_IOSTREAM )
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
ADD_WX_LIB_CONF_GROUP("Non-GUI Features")
|
2008-09-12 20:57:41 +00:00
|
|
|
ADD_WX_LIB_CONF( wxUSE_LONGLONG )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FILE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FFILE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FSVOLUME )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_TEXTBUFFER )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_TEXTFILE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_INTL )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_DATETIME )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_TIMER )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_STOPWATCH )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_CONFIG )
|
|
|
|
#ifdef wxUSE_CONFIG_NATIVE
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_CONFIG_NATIVE )
|
|
|
|
#else
|
|
|
|
ADD_WX_LIB_CONF_NODEF ( wxUSE_CONFIG_NATIVE )
|
|
|
|
#endif
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_DIALUP_MANAGER )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_DYNLIB_CLASS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_DYNAMIC_LOADER )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_SOCKETS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FILESYSTEM )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FS_ZIP )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FS_INET )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_ZIPSTREAM )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_ZLIB )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_APPLE_IEEE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_JOYSTICK )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_FONTMAP )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_MIMETYPE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_PROTOCOL )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_PROTOCOL_FILE )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_PROTOCOL_FTP )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_PROTOCOL_HTTP )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_URL )
|
|
|
|
#ifdef wxUSE_URL_NATIVE
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_URL_NATIVE )
|
|
|
|
#else
|
|
|
|
ADD_WX_LIB_CONF_NODEF ( wxUSE_URL_NATIVE )
|
|
|
|
#endif
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_REGEX )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_SYSTEM_OPTIONS )
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_SOUND )
|
|
|
|
#ifdef wxUSE_XRC
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_XRC )
|
|
|
|
#else
|
|
|
|
ADD_WX_LIB_CONF_NODEF ( wxUSE_XRC )
|
|
|
|
#endif
|
|
|
|
ADD_WX_LIB_CONF( wxUSE_XML )
|
|
|
|
|
|
|
|
// Set them to use check box.
|
|
|
|
pg->SetPropertyAttribute(pid,wxPG_BOOL_USE_CHECKBOX,true,wxPG_RECURSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Handle events of the third page here.
|
|
|
|
class wxMyPropertyGridPage : public wxPropertyGridPage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Return false here to indicate unhandled events should be
|
|
|
|
// propagated to manager's parent, as normal.
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsHandlingAllEvents() const wxOVERRIDE { return false; }
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual wxPGProperty* DoInsert( wxPGProperty* parent,
|
|
|
|
int index,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPGProperty* property ) wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
return wxPropertyGridPage::DoInsert(parent,index,property);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnPropertySelect( wxPropertyGridEvent& event );
|
|
|
|
void OnPropertyChanging( wxPropertyGridEvent& event );
|
|
|
|
void OnPropertyChange( wxPropertyGridEvent& event );
|
|
|
|
void OnPageChange( wxPropertyGridEvent& event );
|
|
|
|
|
|
|
|
private:
|
2014-03-30 07:07:55 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2008-09-12 20:57:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-30 07:07:55 +00:00
|
|
|
wxBEGIN_EVENT_TABLE(wxMyPropertyGridPage, wxPropertyGridPage)
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_PG_SELECTED( wxID_ANY, wxMyPropertyGridPage::OnPropertySelect )
|
|
|
|
EVT_PG_CHANGING( wxID_ANY, wxMyPropertyGridPage::OnPropertyChanging )
|
|
|
|
EVT_PG_CHANGED( wxID_ANY, wxMyPropertyGridPage::OnPropertyChange )
|
|
|
|
EVT_PG_PAGE_CHANGED( wxID_ANY, wxMyPropertyGridPage::OnPageChange )
|
2014-03-30 07:07:55 +00:00
|
|
|
wxEND_EVENT_TABLE()
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
|
2015-02-15 23:26:42 +00:00
|
|
|
void wxMyPropertyGridPage::OnPropertySelect( wxPropertyGridEvent& event )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2015-02-15 23:26:42 +00:00
|
|
|
wxPGProperty* p = event.GetProperty();
|
2017-11-25 16:50:08 +00:00
|
|
|
wxUnusedVar(p);
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("wxMyPropertyGridPage::OnPropertySelect('%s' is %s",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName(),
|
2018-09-29 01:45:15 +00:00
|
|
|
IsPropertySelected(p)? "selected": "unselected");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxMyPropertyGridPage::OnPropertyChange( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = event.GetProperty();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogVerbose("wxMyPropertyGridPage::OnPropertyChange('%s', to value '%s')",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName(),
|
|
|
|
p->GetDisplayedString());
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxMyPropertyGridPage::OnPropertyChanging( wxPropertyGridEvent& event )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = event.GetProperty();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogVerbose("wxMyPropertyGridPage::OnPropertyChanging('%s', to value '%s')",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName(),
|
|
|
|
event.GetValue().GetString());
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxMyPropertyGridPage::OnPageChange( wxPropertyGridEvent& WXUNUSED(event) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("wxMyPropertyGridPage::OnPageChange()");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class wxPGKeyHandler : public wxEvtHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void OnKeyEvent( wxKeyEvent& event )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox(wxString::Format("%i",event.GetKeyCode()));
|
2008-09-12 20:57:41 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
private:
|
2014-03-30 07:07:55 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2008-09-12 20:57:41 +00:00
|
|
|
};
|
|
|
|
|
2014-03-30 07:07:55 +00:00
|
|
|
wxBEGIN_EVENT_TABLE(wxPGKeyHandler,wxEvtHandler)
|
2008-09-12 20:57:41 +00:00
|
|
|
EVT_KEY_DOWN( wxPGKeyHandler::OnKeyEvent )
|
2014-03-30 07:07:55 +00:00
|
|
|
wxEND_EVENT_TABLE()
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::InitPanel()
|
|
|
|
{
|
|
|
|
if ( m_panel )
|
|
|
|
m_panel->Destroy();
|
|
|
|
|
2008-10-18 15:11:44 +00:00
|
|
|
wxWindow* panel = new wxPanel(this, wxID_ANY,
|
|
|
|
wxPoint(0, 0), wxSize(400, 400),
|
|
|
|
wxTAB_TRAVERSAL);
|
2008-09-12 20:57:41 +00:00
|
|
|
m_panel = panel;
|
|
|
|
|
|
|
|
// Column
|
|
|
|
wxBoxSizer* topSizer = new wxBoxSizer ( wxVERTICAL );
|
|
|
|
|
|
|
|
m_topSizer = topSizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormMain::FinalizePanel( bool wasCreated )
|
|
|
|
{
|
2008-10-18 15:11:44 +00:00
|
|
|
// Button for tab traversal testing
|
|
|
|
m_topSizer->Add( new wxButton(m_panel, wxID_ANY,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Should be able to move here with Tab"),
|
2015-05-30 16:33:25 +00:00
|
|
|
wxSizerFlags(0).Expand());
|
2013-08-06 13:05:42 +00:00
|
|
|
m_topSizer->Add( new wxButton(m_panel, ID_SHOWPOPUP,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Show Popup"),
|
2015-05-30 16:33:25 +00:00
|
|
|
wxSizerFlags(0).Expand());
|
2008-10-18 15:11:44 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
m_panel->SetSizer( m_topSizer );
|
|
|
|
m_topSizer->SetSizeHints( m_panel );
|
|
|
|
|
|
|
|
wxBoxSizer* panelSizer = new wxBoxSizer( wxHORIZONTAL );
|
2015-05-30 16:33:25 +00:00
|
|
|
panelSizer->Add( m_panel, wxSizerFlags(1).Expand().FixedMinSize());
|
2008-10-18 15:11:44 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
SetSizer( panelSizer );
|
|
|
|
panelSizer->SetSizeHints( this );
|
|
|
|
|
|
|
|
if ( wasCreated )
|
2008-10-16 17:31:46 +00:00
|
|
|
FinalizeFramePosition();
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormMain::PopulateGrid()
|
|
|
|
{
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->AddPage("Standard Items");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
PopulateWithStandardItems();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->AddPage("wxWidgets Library Config");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
PopulateWithLibraryConfig();
|
|
|
|
|
|
|
|
wxPropertyGridPage* myPage = new wxMyPropertyGridPage();
|
2019-05-26 16:52:43 +00:00
|
|
|
myPage->Append( new wxIntProperty ( "IntProperty", wxPG_LABEL, 12345678L ) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Use wxMyPropertyGridPage (see above) to test the
|
|
|
|
// custom wxPropertyGridPage feature.
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->AddPage("Examples",wxNullBitmap,myPage);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
PopulateWithExamples();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormMain::CreateGrid( int style, int extraStyle )
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function (re)creates the property grid in our sample
|
|
|
|
//
|
|
|
|
|
|
|
|
if ( style == -1 )
|
|
|
|
style = // default style
|
|
|
|
wxPG_BOLD_MODIFIED |
|
|
|
|
wxPG_SPLITTER_AUTO_CENTER |
|
|
|
|
wxPG_AUTO_SORT |
|
|
|
|
//wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER |
|
|
|
|
//wxPG_TOOLTIPS |
|
|
|
|
//wxPG_HIDE_CATEGORIES |
|
|
|
|
//wxPG_LIMITED_EDITING |
|
|
|
|
wxPG_TOOLBAR |
|
|
|
|
wxPG_DESCRIPTION;
|
|
|
|
|
|
|
|
if ( extraStyle == -1 )
|
|
|
|
// default extra style
|
2009-08-17 18:36:00 +00:00
|
|
|
extraStyle = wxPG_EX_MODE_BUTTONS |
|
2017-10-18 20:56:44 +00:00
|
|
|
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
|
|
|
|
wxPG_EX_NATIVE_DOUBLE_BUFFERING |
|
|
|
|
#endif // wxALWAYS_NATIVE_DOUBLE_BUFFER
|
2009-08-17 18:36:00 +00:00
|
|
|
wxPG_EX_MULTIPLE_SELECTION;
|
2008-09-12 20:57:41 +00:00
|
|
|
//| wxPG_EX_AUTO_UNSPECIFIED_VALUES
|
|
|
|
//| wxPG_EX_GREY_LABEL_WHEN_DISABLED
|
|
|
|
//| wxPG_EX_HELP_AS_TOOLTIPS
|
|
|
|
|
|
|
|
bool wasCreated = m_panel ? false : true;
|
|
|
|
|
|
|
|
InitPanel();
|
|
|
|
|
|
|
|
//
|
|
|
|
// This shows how to combine two static choice descriptors
|
2018-09-29 01:45:15 +00:00
|
|
|
m_combinedFlags.Add( WXSIZEOF(_fs_windowstyle_labels), _fs_windowstyle_labels, _fs_windowstyle_values );
|
|
|
|
m_combinedFlags.Add( WXSIZEOF(_fs_framestyle_labels), _fs_framestyle_labels, _fs_framestyle_values );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager =
|
|
|
|
new wxPropertyGridManager(m_panel,
|
|
|
|
// Don't change this into wxID_ANY in the sample, or the
|
|
|
|
// event handling will obviously be broken.
|
|
|
|
PGID, /*wxID_ANY*/
|
|
|
|
wxDefaultPosition,
|
2014-12-12 22:40:00 +00:00
|
|
|
wxDefaultSize,
|
2008-09-12 20:57:41 +00:00
|
|
|
style );
|
|
|
|
|
|
|
|
m_propGrid = pgman->GetGrid();
|
|
|
|
|
|
|
|
pgman->SetExtraStyle(extraStyle);
|
|
|
|
|
2011-03-22 14:17:38 +00:00
|
|
|
// This is the default validation failure behaviour
|
2010-07-25 09:19:52 +00:00
|
|
|
m_pPropGridManager->SetValidationFailureBehavior( wxPG_VFB_MARK_CELL |
|
|
|
|
wxPG_VFB_SHOW_MESSAGEBOX );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
m_pPropGridManager->GetGrid()->SetVerticalSpacing( 2 );
|
|
|
|
|
2009-12-22 16:12:02 +00:00
|
|
|
//
|
|
|
|
// Set somewhat different unspecified value appearance
|
|
|
|
wxPGCell cell;
|
2018-09-29 01:45:15 +00:00
|
|
|
cell.SetText("Unspecified");
|
2009-12-22 16:12:02 +00:00
|
|
|
cell.SetFgCol(*wxLIGHT_GREY);
|
|
|
|
m_propGrid->SetUnspecifiedValueAppearance(cell);
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
PopulateGrid();
|
|
|
|
|
2019-04-27 18:35:39 +00:00
|
|
|
m_propGrid->MakeColumnEditable(0, m_labelEditingEnabled);
|
|
|
|
m_pPropGridManager->ShowHeader(m_hasHeader);
|
|
|
|
if ( m_hasHeader )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->SetColumnTitle(2, "Units");
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// Change some attributes in all properties
|
|
|
|
//pgman->SetPropertyAttributeAll(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING,true);
|
|
|
|
|
|
|
|
//m_pPropGridManager->SetSplitterLeft(true);
|
|
|
|
//m_pPropGridManager->SetSplitterPosition(137);
|
|
|
|
|
2015-05-30 16:33:25 +00:00
|
|
|
m_topSizer->Add( m_pPropGridManager, wxSizerFlags(1).Expand());
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
FinalizePanel(wasCreated);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size) :
|
|
|
|
wxFrame((wxFrame *)NULL, -1, title, pos, size,
|
|
|
|
(wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCAPTION|
|
|
|
|
wxTAB_TRAVERSAL|wxCLOSE_BOX|wxNO_FULL_REPAINT_ON_RESIZE) )
|
|
|
|
{
|
2009-02-08 01:01:00 +00:00
|
|
|
SetIcon(wxICON(sample));
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
m_propGrid = NULL;
|
|
|
|
m_panel = NULL;
|
2019-04-27 18:35:39 +00:00
|
|
|
m_hasHeader = false;
|
|
|
|
m_labelEditingEnabled = false;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// we need this in order to allow the about menu relocation, since ABOUT is
|
|
|
|
// not the default id of the about menu
|
|
|
|
wxApp::s_macAboutMenuItemId = ID_ABOUT;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if wxUSE_IMAGE
|
|
|
|
// This is here to really test the wxImageFileProperty.
|
|
|
|
wxInitAllImageHandlers();
|
|
|
|
#endif
|
|
|
|
|
2008-09-29 16:50:03 +00:00
|
|
|
// Register all editors (SpinCtrl etc.)
|
|
|
|
m_pPropGridManager->RegisterAdditionalEditors();
|
|
|
|
|
|
|
|
// Register our sample custom editors
|
|
|
|
m_pSampleMultiButtonEditor =
|
|
|
|
wxPropertyGrid::RegisterEditorClass(new wxSampleMultiButtonEditor());
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
CreateGrid( // style
|
|
|
|
wxPG_BOLD_MODIFIED |
|
|
|
|
wxPG_SPLITTER_AUTO_CENTER |
|
|
|
|
wxPG_AUTO_SORT |
|
|
|
|
//wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER |
|
|
|
|
//wxPG_TOOLTIPS |
|
|
|
|
//wxPG_HIDE_CATEGORIES |
|
|
|
|
//wxPG_LIMITED_EDITING |
|
|
|
|
wxPG_TOOLBAR |
|
|
|
|
wxPG_DESCRIPTION,
|
|
|
|
// extra style
|
2017-10-18 20:56:44 +00:00
|
|
|
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
|
|
|
|
wxPG_EX_NATIVE_DOUBLE_BUFFERING |
|
|
|
|
#endif // wxALWAYS_NATIVE_DOUBLE_BUFFER
|
2009-08-17 18:36:00 +00:00
|
|
|
wxPG_EX_MODE_BUTTONS |
|
|
|
|
wxPG_EX_MULTIPLE_SELECTION
|
2008-09-12 20:57:41 +00:00
|
|
|
//| wxPG_EX_AUTO_UNSPECIFIED_VALUES
|
|
|
|
//| wxPG_EX_GREY_LABEL_WHEN_DISABLED
|
|
|
|
//| wxPG_EX_HELP_AS_TOOLTIPS
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
2015-06-13 20:28:28 +00:00
|
|
|
// Create menu bar
|
2008-09-12 20:57:41 +00:00
|
|
|
wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF);
|
|
|
|
wxMenu *menuTry = new wxMenu;
|
|
|
|
wxMenu *menuTools1 = new wxMenu;
|
|
|
|
wxMenu *menuTools2 = new wxMenu;
|
|
|
|
wxMenu *menuHelp = new wxMenu;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
menuHelp->Append(ID_ABOUT, "&About", "Show about dialog" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools1->Append(ID_APPENDPROP, "Append New Property" );
|
|
|
|
menuTools1->Append(ID_APPENDCAT, "Append New Category\tCtrl-S" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools1->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools1->Append(ID_INSERTPROP, "Insert New Property\tCtrl-I" );
|
|
|
|
menuTools1->Append(ID_INSERTCAT, "Insert New Category\tCtrl-W" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools1->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools1->Append(ID_DELETE, "Delete Selected" );
|
|
|
|
menuTools1->Append(ID_DELETER, "Delete Random" );
|
|
|
|
menuTools1->Append(ID_DELETEALL, "Delete All" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools1->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools1->Append(ID_SETBGCOLOUR, "Set Bg Colour" );
|
|
|
|
menuTools1->Append(ID_SETBGCOLOURRECUR, "Set Bg Colour (Recursively)" );
|
|
|
|
menuTools1->Append(ID_UNSPECIFY, "Set Value to Unspecified");
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools1->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemEnable = menuTools1->Append(ID_ENABLE, "Enable",
|
|
|
|
"Toggles item's enabled state." );
|
2015-02-08 12:48:43 +00:00
|
|
|
m_itemEnable->Enable( false );
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools1->Append(ID_HIDE, "Hide", "Hides a property" );
|
|
|
|
menuTools1->Append(ID_SETREADONLY, "Set as Read-Only",
|
|
|
|
"Set property as read-only" );
|
|
|
|
|
|
|
|
menuTools2->Append(ID_ITERATE1, "Iterate Over Properties" );
|
|
|
|
menuTools2->Append(ID_ITERATE2, "Iterate Over Visible Items" );
|
|
|
|
menuTools2->Append(ID_ITERATE3, "Reverse Iterate Over Properties" );
|
|
|
|
menuTools2->Append(ID_ITERATE4, "Iterate Over Categories" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_ONEXTENDEDKEYNAV, "Extend Keyboard Navigation",
|
|
|
|
"This will set Enter to navigate to next property, "
|
|
|
|
"and allows arrow keys to navigate even when in "
|
|
|
|
"editor control.");
|
2010-06-12 09:30:57 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_SETPROPERTYVALUE, "Set Property Value" );
|
|
|
|
menuTools2->Append(ID_CLEARMODIF, "Clear Modified Status", "Clears wxPG_MODIFIED flag from all properties." );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemFreeze = menuTools2->AppendCheckItem(ID_FREEZE, "Freeze",
|
|
|
|
"Disables painting, auto-sorting, etc." );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_DUMPLIST, "Display Values as wxVariant List", "Tests GetAllValues method and wxVariant conversion." );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_GETVALUES, "Get Property Values", "Stores all property values." );
|
|
|
|
menuTools2->Append(ID_SETVALUES, "Set Property Values", "Reverts property values to those last stored." );
|
|
|
|
menuTools2->Append(ID_SETVALUES2, "Set Property Values 2", "Adds property values that should not initially be as items (so new items are created)." );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_SAVESTATE, "Save Editable State" );
|
|
|
|
menuTools2->Append(ID_RESTORESTATE, "Restore Editable State" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_ENABLECOMMONVALUES, "Enable Common Value",
|
|
|
|
"Enable values that are common to all properties, for selected property.");
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_COLLAPSE, "Collapse Selected" );
|
|
|
|
menuTools2->Append(ID_COLLAPSEALL, "Collapse All" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_INSERTPAGE, "Add Page" );
|
|
|
|
menuTools2->Append(ID_REMOVEPAGE, "Remove Page" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_FITCOLUMNS, "Fit Columns" );
|
2009-12-12 09:38:10 +00:00
|
|
|
m_itemVetoDragging =
|
|
|
|
menuTools2->AppendCheckItem(ID_VETOCOLDRAG,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Veto Column Dragging");
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_CHANGEFLAGSITEMS, "Change Children of FlagsProp" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_TESTINSERTCHOICE, "Test InsertPropertyChoice" );
|
|
|
|
menuTools2->Append(ID_TESTDELETECHOICE, "Test DeletePropertyChoice" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTools2->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTools2->Append(ID_SETSPINCTRLEDITOR, "Use SpinCtrl Editor" );
|
|
|
|
menuTools2->Append(ID_TESTREPLACE, "Test ReplaceProperty" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTry->Append(ID_SELECTSTYLE, "Set Window Style",
|
|
|
|
"Select window style flags used by the grid.");
|
|
|
|
menuTry->AppendCheckItem(ID_ENABLELABELEDITING, "Enable label editing",
|
|
|
|
"This calls wxPropertyGrid::MakeColumnEditable(0)");
|
2019-04-27 18:35:39 +00:00
|
|
|
menuTry->Check(ID_ENABLELABELEDITING, m_labelEditingEnabled);
|
2015-05-31 17:18:36 +00:00
|
|
|
#if wxUSE_HEADERCTRL
|
2009-12-13 12:00:04 +00:00
|
|
|
menuTry->AppendCheckItem(ID_SHOWHEADER,
|
2018-09-29 01:45:15 +00:00
|
|
|
"Enable header",
|
|
|
|
"This calls wxPropertyGridManager::ShowHeader()");
|
2019-04-27 18:35:39 +00:00
|
|
|
menuTry->Check(ID_SHOWHEADER, m_hasHeader);
|
2015-05-31 17:18:36 +00:00
|
|
|
#endif // wxUSE_HEADERCTRL
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTry->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTry->AppendRadioItem( ID_COLOURSCHEME1, "Standard Colour Scheme" );
|
|
|
|
menuTry->AppendRadioItem( ID_COLOURSCHEME2, "White Colour Scheme" );
|
|
|
|
menuTry->AppendRadioItem( ID_COLOURSCHEME3, ".NET Colour Scheme" );
|
|
|
|
menuTry->AppendRadioItem( ID_COLOURSCHEME4, "Cream Colour Scheme" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTry->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemCatColours = menuTry->AppendCheckItem(ID_CATCOLOURS, "Category Specific Colours",
|
|
|
|
"Switches between category-specific cell colours and default scheme (actually done using SetPropertyTextColour and SetPropertyBackgroundColour)." );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTry->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTry->AppendCheckItem(ID_STATICLAYOUT, "Static Layout",
|
|
|
|
"Switches between user-modifiable and static layouts." );
|
|
|
|
menuTry->AppendCheckItem(ID_BOOL_CHECKBOX, "Render Boolean values as checkboxes",
|
|
|
|
"Renders Boolean values as checkboxes");
|
|
|
|
menuTry->Append(ID_SETCOLUMNS, "Set Number of Columns" );
|
2018-12-27 08:04:37 +00:00
|
|
|
menuTry->Append(ID_SETVIRTWIDTH, "Set Virtual Width");
|
2008-09-12 20:57:41 +00:00
|
|
|
menuTry->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuTry->Append(ID_TESTXRC, "Display XRC sample" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
menuFile->Append(ID_RUNMINIMAL, "Run Minimal Sample" );
|
2008-09-12 20:57:41 +00:00
|
|
|
menuFile->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuFile->Append(ID_RUNTESTFULL, "Run Tests (full)" );
|
|
|
|
menuFile->Append(ID_RUNTESTPARTIAL, "Run Tests (fast)" );
|
2015-04-03 22:42:31 +00:00
|
|
|
menuFile->AppendSeparator();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuFile->Append(ID_QUIT, "E&xit\tAlt-X", "Quit this program" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Now append the freshly created menu to the menu bar...
|
|
|
|
wxMenuBar *menuBar = new wxMenuBar();
|
2018-09-29 01:45:15 +00:00
|
|
|
menuBar->Append(menuFile, "&File" );
|
|
|
|
menuBar->Append(menuTry, "&Try These!" );
|
|
|
|
menuBar->Append(menuTools1, "&Basic" );
|
|
|
|
menuBar->Append(menuTools2, "&Advanced" );
|
|
|
|
menuBar->Append(menuHelp, "&Help" );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// ... and attach this menu bar to the frame
|
|
|
|
SetMenuBar(menuBar);
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
// create a status bar
|
|
|
|
CreateStatusBar(1);
|
|
|
|
SetStatusText(wxEmptyString);
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
2008-10-16 17:31:46 +00:00
|
|
|
FinalizeFramePosition();
|
2009-12-12 09:59:20 +00:00
|
|
|
|
|
|
|
#if wxUSE_LOGWINDOW
|
|
|
|
// Create log window
|
2018-09-29 01:45:15 +00:00
|
|
|
m_logWindow = new wxLogWindow(this, "Log Messages", false);
|
2009-12-12 09:59:20 +00:00
|
|
|
m_logWindow->GetFrame()->Move(GetPosition().x + GetSize().x + 10,
|
|
|
|
GetPosition().y);
|
|
|
|
m_logWindow->Show();
|
|
|
|
#endif
|
2008-10-16 17:31:46 +00:00
|
|
|
}
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2008-10-16 17:31:46 +00:00
|
|
|
void FormMain::FinalizeFramePosition()
|
|
|
|
{
|
|
|
|
wxSize frameSize((wxSystemSettings::GetMetric(wxSYS_SCREEN_X)/10)*4,
|
|
|
|
(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)/10)*8);
|
|
|
|
|
|
|
|
if ( frameSize.x > 500 )
|
|
|
|
frameSize.x = 500;
|
|
|
|
|
|
|
|
SetSize(frameSize);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Normally, wxPropertyGrid does not check whether item with identical
|
|
|
|
// label already exists. However, since in this sample we use labels for
|
|
|
|
// identifying properties, we have to be sure not to generate identical
|
|
|
|
// labels.
|
|
|
|
//
|
|
|
|
void GenerateUniquePropertyLabel( wxPropertyGridManager* pg, wxString& baselabel )
|
|
|
|
{
|
|
|
|
int count = -1;
|
|
|
|
wxString newlabel;
|
|
|
|
|
|
|
|
if ( pg->GetPropertyByLabel( baselabel ) )
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
count++;
|
2018-11-01 23:32:02 +00:00
|
|
|
newlabel.Printf("%s%i",baselabel,count);
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( !pg->GetPropertyByLabel( newlabel ) ) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( count >= 0 )
|
|
|
|
{
|
|
|
|
baselabel = newlabel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnInsertPropClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxString propLabel;
|
|
|
|
|
2008-09-25 17:23:54 +00:00
|
|
|
if ( !m_pPropGridManager->GetGrid()->GetRoot()->GetChildCount() )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("No items to relate - first add some with Append.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPGProperty* id = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !id )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property - new one will be inserted right before that.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( propLabel.Len() < 1 ) propLabel = "Property";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
GenerateUniquePropertyLabel( m_pPropGridManager, propLabel );
|
|
|
|
|
|
|
|
m_pPropGridManager->Insert( m_pPropGridManager->GetPropertyParent(id),
|
2008-09-27 15:09:33 +00:00
|
|
|
id->GetIndexInParent(),
|
|
|
|
new wxStringProperty(propLabel) );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnAppendPropClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxString propLabel;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( propLabel.Len() < 1 ) propLabel = "Property";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
GenerateUniquePropertyLabel( m_pPropGridManager, propLabel );
|
|
|
|
|
|
|
|
m_pPropGridManager->Append( new wxStringProperty(propLabel) );
|
|
|
|
|
|
|
|
m_pPropGridManager->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnClearClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->GetGrid()->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnAppendCatClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxString propLabel;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( propLabel.Len() < 1 ) propLabel = "Category";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
GenerateUniquePropertyLabel( m_pPropGridManager, propLabel );
|
|
|
|
|
|
|
|
m_pPropGridManager->Append( new wxPropertyCategory (propLabel) );
|
|
|
|
|
|
|
|
m_pPropGridManager->Refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnInsertCatClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxString propLabel;
|
|
|
|
|
2008-09-25 17:23:54 +00:00
|
|
|
if ( !m_pPropGridManager->GetGrid()->GetRoot()->GetChildCount() )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("No items to relate - first add some with Append.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPGProperty* id = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !id )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property - new one will be inserted right before that.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( propLabel.Len() < 1 ) propLabel = "Category";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
GenerateUniquePropertyLabel( m_pPropGridManager, propLabel );
|
|
|
|
|
|
|
|
m_pPropGridManager->Insert( m_pPropGridManager->GetPropertyParent(id),
|
2008-09-27 15:09:33 +00:00
|
|
|
id->GetIndexInParent(),
|
|
|
|
new wxPropertyCategory (propLabel) );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnDelPropClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPGProperty* id = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !id )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pPropGridManager->DeleteProperty( id );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnDelPropRClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
// Delete random property
|
|
|
|
wxPGProperty* p = m_pPropGridManager->GetGrid()->GetRoot();
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ( !p->IsCategory() )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->DeleteProperty( p );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !p->GetChildCount() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
int n = rand() % ((int)p->GetChildCount());
|
|
|
|
|
|
|
|
p = p->Item(n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-07-03 14:49:19 +00:00
|
|
|
void FormMain::OnContextMenu( wxContextMenuEvent& event )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("FormMain::OnContextMenu(%i,%i)",
|
2008-09-12 20:57:41 +00:00
|
|
|
event.GetPosition().x,event.GetPosition().y);
|
|
|
|
|
2009-07-03 14:49:19 +00:00
|
|
|
wxUnusedVar(event);
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
//event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnCloseClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
/*#ifdef __WXDEBUG__
|
|
|
|
m_pPropGridManager->GetGrid()->DumpAllocatedChoiceSets();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug("\\-> Don't worry, this is perfectly normal in this sample.");
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif*/
|
|
|
|
|
|
|
|
Close(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
int IterateMessage( wxPGProperty* prop )
|
|
|
|
{
|
|
|
|
wxString s;
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
s.Printf( "\"%s\" class = %s, valuetype = %s", prop->GetLabel(),
|
|
|
|
prop->GetClassInfo()->GetClassName(), prop->GetValueType() );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
return wxMessageBox( s, "Iterating... (press CANCEL to end)", wxOK|wxCANCEL );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnIterate1Click( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = m_pPropGridManager->GetCurrentPage()->
|
|
|
|
GetIterator();
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
int res = IterateMessage( p );
|
|
|
|
if ( res == wxCANCEL ) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnIterate2Click( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = m_pPropGridManager->GetCurrentPage()->
|
|
|
|
GetIterator( wxPG_ITERATE_VISIBLE );
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
|
|
|
|
int res = IterateMessage( p );
|
|
|
|
if ( res == wxCANCEL ) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnIterate3Click( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
// iterate over items in reverse order
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = m_pPropGridManager->GetCurrentPage()->
|
|
|
|
GetIterator( wxPG_ITERATE_DEFAULT, wxBOTTOM );
|
|
|
|
!it.AtEnd();
|
2015-06-26 16:15:45 +00:00
|
|
|
--it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
|
|
|
|
int res = IterateMessage( p );
|
|
|
|
if ( res == wxCANCEL ) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnIterate4Click( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = m_pPropGridManager->GetCurrentPage()->
|
|
|
|
GetIterator( wxPG_ITERATE_CATEGORIES );
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
|
|
|
|
int res = IterateMessage( p );
|
|
|
|
if ( res == wxCANCEL ) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-06-12 09:30:57 +00:00
|
|
|
void FormMain::OnExtendedKeyNav( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
// Use AddActionTrigger() and DedicateKey() to set up Enter,
|
|
|
|
// Up, and Down keys for navigating between properties.
|
|
|
|
wxPropertyGrid* propGrid = m_pPropGridManager->GetGrid();
|
|
|
|
|
|
|
|
propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
|
|
|
|
WXK_RETURN);
|
|
|
|
propGrid->DedicateKey(WXK_RETURN);
|
|
|
|
|
2014-12-24 13:57:19 +00:00
|
|
|
// Up and Down keys are already associated with navigation,
|
2010-06-12 09:30:57 +00:00
|
|
|
// but we must also prevent them from being eaten by
|
|
|
|
// editor controls.
|
|
|
|
propGrid->DedicateKey(WXK_UP);
|
|
|
|
propGrid->DedicateKey(WXK_DOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnFitColumnsClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGridPage* page = m_pPropGridManager->GetCurrentPage();
|
|
|
|
|
|
|
|
// Remove auto-centering
|
|
|
|
m_pPropGridManager->SetWindowStyle( m_pPropGridManager->GetWindowStyle() & ~wxPG_SPLITTER_AUTO_CENTER);
|
|
|
|
|
|
|
|
// Grow manager size just prior fit - otherwise
|
|
|
|
// column information may be lost.
|
|
|
|
wxSize oldGridSize = m_pPropGridManager->GetGrid()->GetClientSize();
|
|
|
|
wxSize oldFullSize = GetSize();
|
|
|
|
SetSize(1000, oldFullSize.y);
|
|
|
|
|
|
|
|
wxSize newSz = page->FitColumns();
|
|
|
|
|
|
|
|
int dx = oldFullSize.x - oldGridSize.x;
|
|
|
|
int dy = oldFullSize.y - oldGridSize.y;
|
|
|
|
|
2015-06-14 15:10:28 +00:00
|
|
|
newSz.IncBy(dx, dy);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
SetSize(newSz);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnChangeFlagsPropItemsClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* p = m_pPropGridManager->GetPropertyByName("Window Styles");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPGChoices newChoices;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
newChoices.Add("Fast",0x1);
|
|
|
|
newChoices.Add("Powerful",0x2);
|
|
|
|
newChoices.Add("Safe",0x4);
|
|
|
|
newChoices.Add("Sleek",0x8);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2008-09-19 16:57:33 +00:00
|
|
|
p->SetChoices(newChoices);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnEnableDisable( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
wxPGProperty* id = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !id )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_pPropGridManager->IsPropertyEnabled( id ) )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->DisableProperty ( id );
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemEnable->SetItemLabel( "Enable" );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pPropGridManager->EnableProperty ( id );
|
2018-09-29 01:45:15 +00:00
|
|
|
m_itemEnable->SetItemLabel( "Disable" );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-01-31 18:14:24 +00:00
|
|
|
void FormMain::OnSetReadOnly( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !p )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property.");
|
2010-01-31 18:14:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_pPropGridManager->SetPropertyReadOnly(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-02-25 14:04:25 +00:00
|
|
|
void FormMain::OnHide( wxCommandEvent& WXUNUSED(event) )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* id = m_pPropGridManager->GetGrid()->GetSelection();
|
|
|
|
if ( !id )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property.");
|
2008-09-12 20:57:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:04:25 +00:00
|
|
|
m_pPropGridManager->HideProperty( id, true );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-04 08:18:36 +00:00
|
|
|
void FormMain::OnBoolCheckbox(wxCommandEvent& evt)
|
|
|
|
{
|
|
|
|
m_pPropGridManager->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, evt.IsChecked());
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-10-31 18:53:37 +00:00
|
|
|
#include "wx/colordlg.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
FormMain::OnSetBackgroundColour( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
wxPGProperty* prop = pg->GetSelection();
|
|
|
|
if ( !prop )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property.");
|
2008-10-31 18:53:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxColour col = ::wxGetColourFromUser(this, *wxWHITE, "Choose colour");
|
2008-10-31 18:53:37 +00:00
|
|
|
|
|
|
|
if ( col.IsOk() )
|
|
|
|
{
|
2019-01-23 19:08:57 +00:00
|
|
|
int flags = (event.GetId()==ID_SETBGCOLOURRECUR) ? wxPG_RECURSE : 0;
|
|
|
|
pg->SetPropertyBackgroundColour(prop, col, flags);
|
2008-10-31 18:53:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnInsertPage( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
m_pPropGridManager->AddPage("New Page");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnRemovePage( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->RemovePage(m_pPropGridManager->GetSelectedPage());
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnSaveState( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
m_savedState = m_pPropGridManager->SaveEditableState();
|
2018-11-01 23:32:02 +00:00
|
|
|
wxLogDebug("Saved editable state string: \"%s\"", m_savedState);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnRestoreState( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->RestoreEditableState(m_savedState);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnSetSpinCtrlEditorClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
#if wxUSE_SPINBTN
|
2008-09-25 17:11:02 +00:00
|
|
|
wxPGProperty* pgId = m_pPropGridManager->GetSelection();
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( pgId )
|
2008-10-05 14:23:28 +00:00
|
|
|
m_pPropGridManager->SetPropertyEditor( pgId, wxPGEditor_SpinCtrl );
|
2008-09-12 20:57:41 +00:00
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property");
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnTestReplaceClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2008-09-25 17:11:02 +00:00
|
|
|
wxPGProperty* pgId = m_pPropGridManager->GetSelection();
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( pgId )
|
|
|
|
{
|
|
|
|
wxPGChoices choices;
|
2018-09-29 01:45:15 +00:00
|
|
|
choices.Add("Flag 0",0x0001);
|
|
|
|
choices.Add("Flag 1",0x0002);
|
|
|
|
choices.Add("Flag 2",0x0004);
|
|
|
|
choices.Add("Flag 3",0x0008);
|
2015-03-28 20:27:06 +00:00
|
|
|
const long maxVal = 0x000F;
|
|
|
|
// Look for unused property name
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString propName = "ReplaceFlagsProperty";
|
2015-03-28 20:27:06 +00:00
|
|
|
int idx = 0;
|
|
|
|
while ( m_pPropGridManager->GetPropertyByName(propName) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
propName = wxString::Format("ReplaceFlagsProperty %i", ++idx);
|
2015-03-28 20:27:06 +00:00
|
|
|
}
|
|
|
|
// Replace property and select new one
|
|
|
|
// with random value in range [1..maxVal]
|
|
|
|
const long propVal = wxGetLocalTime() % maxVal + 1;
|
2008-09-12 20:57:41 +00:00
|
|
|
wxPGProperty* newId = m_pPropGridManager->ReplaceProperty( pgId,
|
2015-03-28 20:27:06 +00:00
|
|
|
new wxFlagsProperty(propName, wxPG_LABEL, choices, propVal) );
|
2008-09-12 20:57:41 +00:00
|
|
|
m_pPropGridManager->SetPropertyAttribute( newId,
|
|
|
|
wxPG_BOOL_USE_CHECKBOX,
|
|
|
|
true,
|
|
|
|
wxPG_RECURSE );
|
2015-03-28 20:27:06 +00:00
|
|
|
m_pPropGridManager->SelectProperty(newId);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First select a property");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnClearModifyStatusClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->ClearModifiedStatus();
|
2018-10-13 09:51:01 +00:00
|
|
|
m_pPropGridManager->Refresh();
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Freeze check-box checked?
|
|
|
|
void FormMain::OnFreezeClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if ( !m_pPropGridManager ) return;
|
|
|
|
|
|
|
|
if ( event.IsChecked() )
|
|
|
|
{
|
|
|
|
if ( !m_pPropGridManager->IsFrozen() )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->Freeze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_pPropGridManager->IsFrozen() )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->Thaw();
|
|
|
|
m_pPropGridManager->Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2015-08-19 17:40:20 +00:00
|
|
|
void FormMain::OnEnableLabelEditing(wxCommandEvent& event)
|
2009-08-23 15:31:03 +00:00
|
|
|
{
|
2019-04-27 18:35:39 +00:00
|
|
|
m_labelEditingEnabled = event.IsChecked();
|
|
|
|
m_propGrid->MakeColumnEditable(0, m_labelEditingEnabled);
|
2009-08-23 15:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2015-05-31 17:18:36 +00:00
|
|
|
#if wxUSE_HEADERCTRL
|
2009-12-13 12:00:04 +00:00
|
|
|
void FormMain::OnShowHeader( wxCommandEvent& event )
|
|
|
|
{
|
2019-04-27 18:35:39 +00:00
|
|
|
m_hasHeader = event.IsChecked();
|
|
|
|
m_pPropGridManager->ShowHeader(m_hasHeader);
|
|
|
|
if ( m_hasHeader )
|
2018-07-07 18:29:37 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
m_pPropGridManager->SetColumnTitle(2, "Units");
|
2018-07-07 18:29:37 +00:00
|
|
|
}
|
2009-12-13 12:00:04 +00:00
|
|
|
}
|
2015-05-31 17:18:36 +00:00
|
|
|
#endif // wxUSE_HEADERCTRL
|
2009-12-13 12:00:04 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxString msg;
|
2018-09-29 01:45:15 +00:00
|
|
|
msg.Printf( "wxPropertyGrid Sample"
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxUSE_UNICODE
|
|
|
|
#if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8
|
2018-09-29 01:45:15 +00:00
|
|
|
" <utf-8>"
|
2008-09-12 20:57:41 +00:00
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
" <unicode>"
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
" <ansi>"
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
#ifdef __WXDEBUG__
|
2018-09-29 01:45:15 +00:00
|
|
|
" <debug>"
|
2008-09-12 20:57:41 +00:00
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
" <release>"
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
2018-09-29 01:45:15 +00:00
|
|
|
"\n\n"
|
|
|
|
"Programmed by %s\n\n"
|
|
|
|
"Using %s\n\n",
|
|
|
|
"Jaakko Salli", wxVERSION_STRING
|
2008-09-12 20:57:41 +00:00
|
|
|
);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox(msg, "About", wxOK | wxICON_INFORMATION, this);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnColourScheme( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
if ( id == ID_COLOURSCHEME1 )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->GetGrid()->ResetColours();
|
|
|
|
}
|
|
|
|
else if ( id == ID_COLOURSCHEME2 )
|
|
|
|
{
|
|
|
|
// white
|
|
|
|
wxColour my_grey_1(212,208,200);
|
|
|
|
wxColour my_grey_3(113,111,100);
|
|
|
|
m_pPropGridManager->Freeze();
|
|
|
|
m_pPropGridManager->GetGrid()->SetMarginColour( *wxWHITE );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCaptionBackgroundColour( *wxWHITE );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( *wxWHITE );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCellTextColour( my_grey_3 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetLineColour( my_grey_1 ); //wxColour(160,160,160)
|
|
|
|
m_pPropGridManager->Thaw();
|
|
|
|
}
|
|
|
|
else if ( id == ID_COLOURSCHEME3 )
|
|
|
|
{
|
|
|
|
// .NET
|
|
|
|
wxColour my_grey_1(212,208,200);
|
|
|
|
wxColour my_grey_2(236,233,216);
|
|
|
|
m_pPropGridManager->Freeze();
|
|
|
|
m_pPropGridManager->GetGrid()->SetMarginColour( my_grey_1 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCaptionBackgroundColour( my_grey_1 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetLineColour( my_grey_1 );
|
|
|
|
m_pPropGridManager->Thaw();
|
|
|
|
}
|
|
|
|
else if ( id == ID_COLOURSCHEME4 )
|
|
|
|
{
|
|
|
|
// cream
|
|
|
|
|
|
|
|
wxColour my_grey_1(212,208,200);
|
|
|
|
wxColour my_grey_2(241,239,226);
|
|
|
|
wxColour my_grey_3(113,111,100);
|
|
|
|
m_pPropGridManager->Freeze();
|
|
|
|
m_pPropGridManager->GetGrid()->SetMarginColour( *wxWHITE );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCaptionBackgroundColour( *wxWHITE );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( my_grey_2 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( my_grey_2 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetCellTextColour( my_grey_3 );
|
|
|
|
m_pPropGridManager->GetGrid()->SetLineColour( my_grey_1 );
|
|
|
|
m_pPropGridManager->Thaw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2015-08-27 17:05:15 +00:00
|
|
|
void FormMain::OnCatColoursUpdateUI(wxUpdateUIEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
// Prevent menu item from being checked
|
|
|
|
// if it is selected from imroper page.
|
|
|
|
const wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
m_itemCatColours->SetCheckable(
|
|
|
|
pg->GetPropertyByName("Appearance") &&
|
|
|
|
pg->GetPropertyByName("PositionCategory") &&
|
|
|
|
pg->GetPropertyByName("Environment") &&
|
|
|
|
pg->GetPropertyByName("More Examples") );
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnCatColours( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
2015-08-27 17:05:15 +00:00
|
|
|
if ( !pg->GetPropertyByName("Appearance") ||
|
|
|
|
!pg->GetPropertyByName("PositionCategory") ||
|
|
|
|
!pg->GetPropertyByName("Environment") ||
|
|
|
|
!pg->GetPropertyByName("More Examples") )
|
|
|
|
{
|
|
|
|
wxMessageBox("First switch to 'Standard Items' page!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
m_pPropGridManager->Freeze();
|
|
|
|
|
|
|
|
if ( event.IsChecked() )
|
|
|
|
{
|
|
|
|
// Set custom colours.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyTextColour( "Appearance", wxColour(255,0,0), wxPG_DONT_RECURSE );
|
|
|
|
pg->SetPropertyBackgroundColour( "Appearance", wxColour(255,255,183) );
|
|
|
|
pg->SetPropertyTextColour( "Appearance", wxColour(255,0,183) );
|
|
|
|
pg->SetPropertyTextColour( "PositionCategory", wxColour(0,255,0), wxPG_DONT_RECURSE );
|
|
|
|
pg->SetPropertyBackgroundColour( "PositionCategory", wxColour(255,226,190) );
|
|
|
|
pg->SetPropertyTextColour( "PositionCategory", wxColour(255,0,190) );
|
|
|
|
pg->SetPropertyTextColour( "Environment", wxColour(0,0,255), wxPG_DONT_RECURSE );
|
|
|
|
pg->SetPropertyBackgroundColour( "Environment", wxColour(208,240,175) );
|
|
|
|
pg->SetPropertyTextColour( "Environment", wxColour(255,255,255) );
|
|
|
|
pg->SetPropertyBackgroundColour( "More Examples", wxColour(172,237,255) );
|
|
|
|
pg->SetPropertyTextColour( "More Examples", wxColour(172,0,255) );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Revert to original.
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyColoursToDefault( "Appearance" );
|
|
|
|
pg->SetPropertyColoursToDefault( "Appearance", wxPG_RECURSE );
|
|
|
|
pg->SetPropertyColoursToDefault( "PositionCategory" );
|
|
|
|
pg->SetPropertyColoursToDefault( "PositionCategory", wxPG_RECURSE );
|
|
|
|
pg->SetPropertyColoursToDefault( "Environment" );
|
|
|
|
pg->SetPropertyColoursToDefault( "Environment", wxPG_RECURSE );
|
|
|
|
pg->SetPropertyColoursToDefault( "More Examples", wxPG_RECURSE );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
m_pPropGridManager->Thaw();
|
|
|
|
m_pPropGridManager->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define ADD_FLAG(FLAG) \
|
2018-09-29 01:45:15 +00:00
|
|
|
chs.Add(#FLAG); \
|
2008-09-12 20:57:41 +00:00
|
|
|
vls.Add(FLAG); \
|
|
|
|
if ( (flags & FLAG) == FLAG ) sel.Add(ind); \
|
|
|
|
ind++;
|
|
|
|
|
|
|
|
void FormMain::OnSelectStyle( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2010-06-21 12:19:04 +00:00
|
|
|
int style = 0;
|
|
|
|
int extraStyle = 0;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
wxArrayString chs;
|
|
|
|
wxArrayInt vls;
|
|
|
|
wxArrayInt sel;
|
|
|
|
unsigned int ind = 0;
|
|
|
|
int flags = m_pPropGridManager->GetWindowStyle();
|
|
|
|
ADD_FLAG(wxPG_HIDE_CATEGORIES)
|
|
|
|
ADD_FLAG(wxPG_AUTO_SORT)
|
|
|
|
ADD_FLAG(wxPG_BOLD_MODIFIED)
|
|
|
|
ADD_FLAG(wxPG_SPLITTER_AUTO_CENTER)
|
|
|
|
ADD_FLAG(wxPG_TOOLTIPS)
|
|
|
|
ADD_FLAG(wxPG_STATIC_SPLITTER)
|
|
|
|
ADD_FLAG(wxPG_HIDE_MARGIN)
|
|
|
|
ADD_FLAG(wxPG_LIMITED_EDITING)
|
|
|
|
ADD_FLAG(wxPG_TOOLBAR)
|
|
|
|
ADD_FLAG(wxPG_DESCRIPTION)
|
2009-09-11 11:49:03 +00:00
|
|
|
ADD_FLAG(wxPG_NO_INTERNAL_BORDER)
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMultiChoiceDialog dlg( this, "Select window styles to use",
|
|
|
|
"wxPropertyGrid Window Style", chs );
|
2008-09-12 20:57:41 +00:00
|
|
|
dlg.SetSelections(sel);
|
|
|
|
if ( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
sel = dlg.GetSelections();
|
|
|
|
for ( ind = 0; ind < sel.size(); ind++ )
|
|
|
|
flags |= vls[sel[ind]];
|
|
|
|
|
|
|
|
style = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
wxArrayString chs;
|
|
|
|
wxArrayInt vls;
|
|
|
|
wxArrayInt sel;
|
|
|
|
unsigned int ind = 0;
|
|
|
|
int flags = m_pPropGridManager->GetExtraStyle();
|
|
|
|
ADD_FLAG(wxPG_EX_INIT_NOCAT)
|
|
|
|
ADD_FLAG(wxPG_EX_NO_FLAT_TOOLBAR)
|
|
|
|
ADD_FLAG(wxPG_EX_MODE_BUTTONS)
|
|
|
|
ADD_FLAG(wxPG_EX_HELP_AS_TOOLTIPS)
|
|
|
|
ADD_FLAG(wxPG_EX_NATIVE_DOUBLE_BUFFERING)
|
|
|
|
ADD_FLAG(wxPG_EX_AUTO_UNSPECIFIED_VALUES)
|
|
|
|
ADD_FLAG(wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES)
|
2009-08-17 18:36:00 +00:00
|
|
|
ADD_FLAG(wxPG_EX_HIDE_PAGE_BUTTONS)
|
|
|
|
ADD_FLAG(wxPG_EX_MULTIPLE_SELECTION)
|
2009-08-29 08:09:45 +00:00
|
|
|
ADD_FLAG(wxPG_EX_ENABLE_TLP_TRACKING)
|
2009-09-11 11:49:03 +00:00
|
|
|
ADD_FLAG(wxPG_EX_NO_TOOLBAR_DIVIDER)
|
|
|
|
ADD_FLAG(wxPG_EX_TOOLBAR_SEPARATOR)
|
2017-10-18 20:57:39 +00:00
|
|
|
ADD_FLAG(wxPG_EX_ALWAYS_ALLOW_FOCUS)
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMultiChoiceDialog dlg( this, "Select extra window styles to use",
|
|
|
|
"wxPropertyGrid Extra Style", chs );
|
2008-09-12 20:57:41 +00:00
|
|
|
dlg.SetSelections(sel);
|
|
|
|
if ( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
sel = dlg.GetSelections();
|
|
|
|
for ( ind = 0; ind < sel.size(); ind++ )
|
|
|
|
flags |= vls[sel[ind]];
|
|
|
|
|
|
|
|
extraStyle = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateGrid( style, extraStyle );
|
|
|
|
|
2008-10-16 17:31:46 +00:00
|
|
|
FinalizeFramePosition();
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnSetColumns( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
long colCount = ::wxGetNumberFromUser("Enter number of columns (2-20).","Columns:",
|
|
|
|
"Change Columns",m_pPropGridManager->GetColumnCount(),
|
2008-09-12 20:57:41 +00:00
|
|
|
2,20);
|
|
|
|
|
|
|
|
if ( colCount >= 2 )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->SetColumnCount(colCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-12-27 08:04:37 +00:00
|
|
|
void FormMain::OnSetVirtualWidth(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
long oldWidth = m_pPropGridManager->GetState()->GetVirtualWidth();
|
|
|
|
long newWidth = oldWidth;
|
|
|
|
{
|
|
|
|
wxNumberEntryDialog dlg(this, "Enter virtual width (-1-2000).", "Width:",
|
|
|
|
"Change Virtual Width", oldWidth, -1, 2000);
|
|
|
|
if ( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
newWidth = dlg.GetValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( newWidth != oldWidth )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->GetGrid()->SetVirtualWidth((int)newWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
void FormMain::OnSetPropertyValue( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
wxPGProperty* selected = pg->GetSelection();
|
|
|
|
|
|
|
|
if ( selected )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString value = ::wxGetTextFromUser( "Enter new value:" );
|
2008-09-12 20:57:41 +00:00
|
|
|
pg->SetPropertyValue( selected, value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnInsertChoice( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
|
|
|
|
wxPGProperty* selected = pg->GetSelection();
|
2008-09-19 16:57:33 +00:00
|
|
|
const wxPGChoices& choices = selected->GetChoices();
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Insert new choice to the center of list
|
|
|
|
|
|
|
|
if ( choices.IsOk() )
|
|
|
|
{
|
|
|
|
int pos = choices.GetCount() / 2;
|
2018-09-29 01:45:15 +00:00
|
|
|
selected->InsertChoice("New Choice", pos);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
::wxMessageBox("First select a property with some choices.");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnDeleteChoice( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
|
|
|
|
wxPGProperty* selected = pg->GetSelection();
|
2008-09-19 16:57:33 +00:00
|
|
|
const wxPGChoices& choices = selected->GetChoices();
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Deletes choice from the center of list
|
|
|
|
|
|
|
|
if ( choices.IsOk() )
|
|
|
|
{
|
|
|
|
int pos = choices.GetCount() / 2;
|
2008-09-19 16:57:33 +00:00
|
|
|
selected->DeleteChoice(pos);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
::wxMessageBox("First select a property with some choices.");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/colordlg.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
void FormMain::OnMisc ( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
if ( id == ID_STATICLAYOUT )
|
|
|
|
{
|
|
|
|
long wsf = m_pPropGridManager->GetWindowStyleFlag();
|
|
|
|
if ( event.IsChecked() ) m_pPropGridManager->SetWindowStyleFlag( wsf|wxPG_STATIC_LAYOUT );
|
|
|
|
else m_pPropGridManager->SetWindowStyleFlag( wsf&~(wxPG_STATIC_LAYOUT) );
|
|
|
|
}
|
|
|
|
else if ( id == ID_COLLAPSEALL )
|
|
|
|
{
|
|
|
|
wxPGVIterator it;
|
|
|
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
|
|
|
|
|
|
|
for ( it = pg->GetVIterator( wxPG_ITERATE_ALL ); !it.AtEnd(); it.Next() )
|
|
|
|
it.GetProperty()->SetExpanded( false );
|
|
|
|
|
|
|
|
pg->RefreshGrid();
|
|
|
|
}
|
|
|
|
else if ( id == ID_GETVALUES )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
m_storedValues = m_pPropGridManager->GetGrid()->GetPropertyValues("Test",
|
2008-09-12 20:57:41 +00:00
|
|
|
m_pPropGridManager->GetGrid()->GetRoot(),
|
|
|
|
wxPG_KEEP_STRUCTURE|wxPG_INC_ATTRIBUTES);
|
|
|
|
}
|
|
|
|
else if ( id == ID_SETVALUES )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( m_storedValues.IsType("list") )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
m_pPropGridManager->GetGrid()->SetPropertyValues(m_storedValues);
|
|
|
|
}
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox("First use Get Property Values.");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else if ( id == ID_SETVALUES2 )
|
|
|
|
{
|
|
|
|
wxVariant list;
|
|
|
|
list.NullList();
|
2019-05-26 16:52:43 +00:00
|
|
|
list.Append( wxVariant(1234L,"VariantLong") );
|
2018-09-29 01:45:15 +00:00
|
|
|
list.Append( wxVariant(true,"VariantBool") );
|
|
|
|
list.Append( wxVariant("Test Text","VariantString") );
|
2008-09-12 20:57:41 +00:00
|
|
|
m_pPropGridManager->GetGrid()->SetPropertyValues(list);
|
|
|
|
}
|
|
|
|
else if ( id == ID_COLLAPSE )
|
|
|
|
{
|
|
|
|
// Collapses selected.
|
2016-02-18 17:42:06 +00:00
|
|
|
wxPGProperty* selProp = m_pPropGridManager->GetSelection();
|
|
|
|
if ( selProp )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2016-02-18 17:42:06 +00:00
|
|
|
m_pPropGridManager->Collapse(selProp);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( id == ID_RUNTESTFULL )
|
|
|
|
{
|
|
|
|
// Runs a regression test.
|
|
|
|
RunTests(true);
|
|
|
|
}
|
|
|
|
else if ( id == ID_RUNTESTPARTIAL )
|
|
|
|
{
|
|
|
|
// Runs a regression test.
|
|
|
|
RunTests(false);
|
|
|
|
}
|
|
|
|
else if ( id == ID_UNSPECIFY )
|
|
|
|
{
|
2008-09-25 17:11:02 +00:00
|
|
|
wxPGProperty* prop = m_pPropGridManager->GetSelection();
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( prop )
|
|
|
|
{
|
|
|
|
m_pPropGridManager->SetPropertyValueUnspecified(prop);
|
2009-01-04 10:37:22 +00:00
|
|
|
prop->RefreshEditor();
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnPopulateClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
m_propGrid->Clear();
|
|
|
|
m_propGrid->Freeze();
|
|
|
|
if ( id == ID_POPULATE1 )
|
|
|
|
{
|
|
|
|
PopulateWithStandardItems();
|
|
|
|
}
|
|
|
|
else if ( id == ID_POPULATE2 )
|
|
|
|
{
|
|
|
|
PopulateWithLibraryConfig();
|
|
|
|
}
|
|
|
|
m_propGrid->Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DisplayMinimalFrame(wxWindow* parent); // in minimal.cpp
|
|
|
|
|
|
|
|
void FormMain::OnRunMinimalClick( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
DisplayMinimalFrame(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FormMain::~FormMain()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxIMPLEMENT_APP(cxApplication);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
bool cxApplication::OnInit()
|
|
|
|
{
|
|
|
|
//wxLocale Locale;
|
|
|
|
//Locale.Init(wxLANGUAGE_FINNISH);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
FormMain* frame = Form1 = new FormMain( "wxPropertyGrid Sample", wxPoint(0,0), wxSize(300,500) );
|
2009-08-29 08:09:45 +00:00
|
|
|
frame->Show(true);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Parse command-line
|
|
|
|
wxApp& app = wxGetApp();
|
|
|
|
if ( app.argc > 1 )
|
|
|
|
{
|
|
|
|
wxString s = app.argv[1];
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( s == "--run-tests" )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Run tests
|
|
|
|
bool testResult = frame->RunTests(true);
|
|
|
|
|
|
|
|
if ( testResult )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-29 08:09:45 +00:00
|
|
|
return true;
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnIdle( wxIdleEvent& event )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
// This code is useful for debugging focus problems
|
|
|
|
static wxWindow* last_focus = (wxWindow*) NULL;
|
|
|
|
|
|
|
|
wxWindow* cur_focus = ::wxWindow::FindFocus();
|
|
|
|
|
|
|
|
if ( cur_focus != last_focus )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
const wxChar* class_name = "<none>";
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( cur_focus )
|
|
|
|
class_name = cur_focus->GetClassInfo()->GetClassName();
|
|
|
|
last_focus = cur_focus;
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogDebug( "FOCUSED: %s %X",
|
2008-09-12 20:57:41 +00:00
|
|
|
class_name,
|
|
|
|
(unsigned int)cur_focus);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2013-08-06 13:05:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxPGProperty* GetRealRoot(wxPropertyGrid *grid)
|
|
|
|
{
|
|
|
|
wxPGProperty *property = grid->GetRoot();
|
|
|
|
return property ? grid->GetFirstChild(property) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetColumnWidths(wxClientDC &dc, wxPropertyGrid *grid, wxPGProperty *root, int width[3])
|
|
|
|
{
|
|
|
|
wxPropertyGridPageState *state = grid->GetState();
|
|
|
|
|
|
|
|
width[0] =
|
|
|
|
width[1] =
|
|
|
|
width[2] = 0;
|
|
|
|
int minWidths[3] = { state->GetColumnMinWidth(0),
|
|
|
|
state->GetColumnMinWidth(1),
|
|
|
|
state->GetColumnMinWidth(2) };
|
2013-08-07 12:08:10 +00:00
|
|
|
unsigned ii;
|
|
|
|
for (ii = 0; ii < root->GetChildCount(); ++ii)
|
2013-08-06 13:05:42 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = root->Item(ii);
|
|
|
|
|
2013-08-07 12:08:10 +00:00
|
|
|
width[0] = wxMax(width[0], state->GetColumnFullWidth(dc, p, 0));
|
|
|
|
width[1] = wxMax(width[1], state->GetColumnFullWidth(dc, p, 1));
|
|
|
|
width[2] = wxMax(width[2], state->GetColumnFullWidth(dc, p, 2));
|
2013-08-06 13:05:42 +00:00
|
|
|
}
|
2013-08-07 12:08:10 +00:00
|
|
|
for (ii = 0; ii < root->GetChildCount(); ++ii)
|
2013-08-06 13:05:42 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = root->Item(ii);
|
|
|
|
if (p->IsExpanded())
|
|
|
|
{
|
|
|
|
int w[3];
|
|
|
|
GetColumnWidths(dc, grid, p, w);
|
2013-08-07 12:08:10 +00:00
|
|
|
width[0] = wxMax(width[0], w[0]);
|
|
|
|
width[1] = wxMax(width[1], w[1]);
|
|
|
|
width[2] = wxMax(width[2], w[2]);
|
2013-08-06 13:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 12:08:10 +00:00
|
|
|
width[0] = wxMax(width[0], minWidths[0]);
|
|
|
|
width[1] = wxMax(width[1], minWidths[1]);
|
|
|
|
width[2] = wxMax(width[2], minWidths[2]);
|
2013-08-06 13:05:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetColumnWidths(wxPropertyGrid *grid, wxPGProperty *root, int width[3])
|
|
|
|
{
|
|
|
|
wxClientDC dc(grid);
|
|
|
|
dc.SetFont(grid->GetFont());
|
|
|
|
GetColumnWidths(dc, grid, root, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMinSize(wxPropertyGrid *grid)
|
|
|
|
{
|
|
|
|
wxPGProperty *p = GetRealRoot(grid);
|
|
|
|
wxPGProperty *first = grid->wxPropertyGridInterface::GetFirst(wxPG_ITERATE_ALL);
|
|
|
|
wxPGProperty *last = grid->GetLastItem(wxPG_ITERATE_DEFAULT);
|
|
|
|
wxRect rect = grid->GetPropertyRect(first, last);
|
|
|
|
int height = rect.height + 2 * grid->GetVerticalSpacing();
|
|
|
|
|
|
|
|
// add some height when the root item is collapsed,
|
|
|
|
// this is needed to prevent the vertical scroll from showing
|
|
|
|
if (!grid->IsPropertyExpanded(p))
|
|
|
|
height += 2 * grid->GetVerticalSpacing();
|
|
|
|
|
|
|
|
int width[3];
|
|
|
|
GetColumnWidths(grid, grid->GetRoot(), width);
|
|
|
|
rect.width = width[0]+width[1]+width[2];
|
|
|
|
|
|
|
|
int minWidth = (wxSystemSettings::GetMetric(wxSYS_SCREEN_X, grid->GetParent())*3)/2;
|
|
|
|
int minHeight = (wxSystemSettings::GetMetric(wxSYS_SCREEN_Y, grid->GetParent())*3)/2;
|
|
|
|
|
2013-08-07 12:08:10 +00:00
|
|
|
wxSize size(wxMin(minWidth, rect.width + grid->GetMarginWidth()), wxMin(minHeight, height));
|
2013-08-06 13:05:42 +00:00
|
|
|
grid->SetMinSize(size);
|
|
|
|
|
|
|
|
int proportions[3];
|
2015-01-21 17:14:22 +00:00
|
|
|
proportions[0] = wxRound((double)width[0]/size.x*100.0);
|
|
|
|
proportions[1] = wxRound((double)width[1]/size.x*100.0);
|
2013-08-07 12:08:10 +00:00
|
|
|
proportions[2]= wxMax(100 - proportions[0] - proportions[1], 0);
|
2013-08-06 13:05:42 +00:00
|
|
|
grid->SetColumnProportion(0, proportions[0]);
|
|
|
|
grid->SetColumnProportion(1, proportions[1]);
|
|
|
|
grid->SetColumnProportion(2, proportions[2]);
|
|
|
|
grid->ResetColumnSizes(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PropertyGridPopup : wxPopupWindow
|
|
|
|
{
|
|
|
|
wxScrolledWindow *m_panel;
|
|
|
|
wxPropertyGrid *m_grid;
|
|
|
|
wxBoxSizer *m_sizer;
|
|
|
|
|
|
|
|
PropertyGridPopup(wxWindow *parent) : wxPopupWindow(parent, wxBORDER_NONE|wxWANTS_CHARS)
|
|
|
|
{
|
|
|
|
m_panel = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(200, 200));
|
|
|
|
m_grid = new wxPropertyGrid(m_panel, ID_POPUPGRID, wxDefaultPosition, wxSize(400,400), wxPG_SPLITTER_AUTO_CENTER);
|
|
|
|
m_grid->SetColumnCount(3);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty *prop=m_grid->Append(new wxStringProperty("test_name", wxPG_LABEL, "test_value"));
|
|
|
|
m_grid->SetPropertyAttribute(prop, wxPG_ATTR_UNITS, "type");
|
|
|
|
wxPGProperty *prop1 = m_grid->AppendIn(prop, new wxStringProperty("sub_name1", wxPG_LABEL, "sub_value1"));
|
2013-08-06 13:05:42 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
m_grid->AppendIn(prop1, new wxSystemColourProperty("Cell Colour",wxPG_LABEL, m_grid->GetGrid()->GetCellBackgroundColour()));
|
|
|
|
wxPGProperty *prop2 = m_grid->AppendIn(prop, new wxStringProperty("sub_name2", wxPG_LABEL, "sub_value2"));
|
|
|
|
m_grid->AppendIn(prop2, new wxStringProperty("sub_name21", wxPG_LABEL, "sub_value21"));
|
2013-08-06 13:05:42 +00:00
|
|
|
|
|
|
|
wxArrayDouble arrdbl;
|
|
|
|
arrdbl.Add(-1.0); arrdbl.Add(-0.5); arrdbl.Add(0.0); arrdbl.Add(0.5); arrdbl.Add(1.0);
|
2018-09-29 01:45:15 +00:00
|
|
|
m_grid->AppendIn(prop, new wxArrayDoubleProperty("ArrayDoubleProperty",wxPG_LABEL,arrdbl) );
|
|
|
|
m_grid->AppendIn(prop, new wxFontProperty("Font",wxPG_LABEL));
|
|
|
|
m_grid->AppendIn(prop2, new wxStringProperty("sub_name22", wxPG_LABEL, "sub_value22"));
|
|
|
|
m_grid->AppendIn(prop2, new wxStringProperty("sub_name23", wxPG_LABEL, "sub_value23"));
|
2013-08-06 13:05:42 +00:00
|
|
|
prop2->SetExpanded(false);
|
|
|
|
|
|
|
|
::SetMinSize(m_grid);
|
|
|
|
|
|
|
|
m_sizer = new wxBoxSizer( wxVERTICAL );
|
2015-05-30 16:33:25 +00:00
|
|
|
m_sizer->Add(m_grid, wxSizerFlags(0).Expand().Border(wxALL, 0));
|
2013-08-06 13:05:42 +00:00
|
|
|
m_panel->SetAutoLayout(true);
|
|
|
|
m_panel->SetSizer(m_sizer);
|
|
|
|
m_sizer->Fit(m_panel);
|
|
|
|
m_sizer->Fit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnCollapse(wxPropertyGridEvent& WXUNUSED(event))
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("OnCollapse");
|
2013-08-06 13:05:42 +00:00
|
|
|
Fit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnExpand(wxPropertyGridEvent& WXUNUSED(event))
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxLogMessage("OnExpand");
|
2013-08-06 13:05:42 +00:00
|
|
|
Fit();
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
void Fit() wxOVERRIDE
|
2013-08-06 13:05:42 +00:00
|
|
|
{
|
|
|
|
::SetMinSize(m_grid);
|
|
|
|
m_sizer->Fit(m_panel);
|
|
|
|
wxPoint pos = GetScreenPosition();
|
|
|
|
wxSize size = m_panel->GetScreenRect().GetSize();
|
|
|
|
SetSize(pos.x, pos.y, size.x, size.y);
|
|
|
|
}
|
|
|
|
|
2014-03-30 07:07:55 +00:00
|
|
|
wxDECLARE_ABSTRACT_CLASS(PropertyGridPopup);
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
2013-08-06 13:05:42 +00:00
|
|
|
};
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxIMPLEMENT_CLASS(PropertyGridPopup, wxPopupWindow);
|
2014-03-30 07:07:55 +00:00
|
|
|
wxBEGIN_EVENT_TABLE(PropertyGridPopup, wxPopupWindow)
|
2013-08-06 13:05:42 +00:00
|
|
|
EVT_PG_ITEM_COLLAPSED(ID_POPUPGRID, PropertyGridPopup::OnCollapse)
|
|
|
|
EVT_PG_ITEM_EXPANDED(ID_POPUPGRID, PropertyGridPopup::OnExpand)
|
2014-03-30 07:07:55 +00:00
|
|
|
wxEND_EVENT_TABLE()
|
2013-08-06 13:05:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FormMain::OnShowPopup(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
static PropertyGridPopup *popup = NULL;
|
|
|
|
if ( popup )
|
|
|
|
{
|
|
|
|
delete popup;
|
|
|
|
popup = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
popup = new PropertyGridPopup(this);
|
|
|
|
wxPoint pt = wxGetMousePosition();
|
|
|
|
popup->Position(pt, wxSize(0, 0));
|
|
|
|
popup->Show();
|
|
|
|
}
|