1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/propgrid_minimal.cpp
3 // Purpose: Minimal portion of wxPropertyGrid sample
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/propgrid/propgrid.h"
15 class MyFrame
: public wxFrame
18 MyFrame(wxWindow
* parent
);
20 void OnAction(wxCommandEvent
& event
);
21 void OnPropertyGridChange(wxPropertyGridEvent
& event
);
29 // Called from propgridsample.cpp
31 void DisplayMinimalFrame(wxWindow
* parent
)
33 MyFrame
*frame
= new MyFrame(parent
);
37 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
38 EVT_MENU(wxID_HIGHEST
+1, MyFrame::OnAction
)
39 EVT_PG_CHANGED( -1, MyFrame::OnPropertyGridChange
)
42 MyFrame::MyFrame(wxWindow
* parent
)
43 : wxFrame(parent
, wxID_ANY
, wxT("PropertyGrid Test"))
45 wxMenu
*Menu
= new wxMenu
;
46 Menu
->Append(wxID_HIGHEST
+1, wxT("Action"));
47 wxMenuBar
*MenuBar
= new wxMenuBar();
48 MenuBar
->Append(Menu
, wxT("Action"));
51 wxPropertyGrid
*pg
= new wxPropertyGrid(this,-1,wxDefaultPosition
,wxSize(400,400),
52 wxPG_SPLITTER_AUTO_CENTER
|
56 for ( int i
=0; i
< 20; i
++ )
57 pg
->Append(new wxStringProperty(wxString::Format(wxT("Item %i"),i
), wxPG_LABEL
));
63 topId
= pg
->Append( new wxStringProperty(wxT("Top Item"), wxPG_LABEL
, wxT("<composed>")) );
64 pg
->LimitPropertyEditing(topId
, true);
65 medId
= pg
->AppendIn( topId
, new wxStringProperty(wxT("Medium Level Item A"), wxPG_LABEL
, wxT("<composed>")) );
66 pg
->LimitPropertyEditing(medId
, true);
67 botId
= pg
->AppendIn( medId
, new wxStringProperty(wxT("Position"), wxPG_LABEL
, wxT("<composed>")) );
68 pg
->LimitPropertyEditing(botId
, true);
69 pg
->AppendIn( botId
, new wxFloatProperty(wxT("x"), wxPG_LABEL
, 1.0) );
70 pg
->AppendIn( botId
, new wxFloatProperty(wxT("y"), wxPG_LABEL
, 2.0) );
71 pg
->AppendIn( botId
, new wxFloatProperty(wxT("z"), wxPG_LABEL
, 3.0) );
72 pg
->AppendIn( medId
, new wxStringProperty(wxT("Name"), wxPG_LABEL
, wxT("name")) );
73 medId
= pg
->AppendIn( topId
, new wxStringProperty(wxT("Medium Level Item B"), wxPG_LABEL
, wxT("<composed>")) );
74 pg
->LimitPropertyEditing(medId
, true);
75 botId
= pg
->AppendIn( medId
, new wxStringProperty(wxT("Position"), wxPG_LABEL
, wxT("<composed>")) );
76 pg
->LimitPropertyEditing(botId
, true);
77 pg
->AppendIn( botId
, new wxFloatProperty(wxT("x"), wxPG_LABEL
, 1.0) );
78 pg
->AppendIn( botId
, new wxFloatProperty(wxT("y"), wxPG_LABEL
, 2.0) );
79 pg
->AppendIn( botId
, new wxFloatProperty(wxT("z"), wxPG_LABEL
, 3.0) );
80 pg
->AppendIn( medId
, new wxStringProperty(wxT("Name"), wxPG_LABEL
, wxT("name")) );
81 medId
= pg
->AppendIn( topId
, new wxStringProperty(wxT("Medium Level Item C"), wxPG_LABEL
, wxT("<composed>")) );
82 pg
->LimitPropertyEditing(medId
, true);
83 botId
= pg
->AppendIn( medId
, new wxStringProperty(wxT("Position"), wxPG_LABEL
, wxT("<composed>")) );
84 pg
->LimitPropertyEditing(botId
, true);
85 pg
->AppendIn( botId
, new wxFloatProperty(wxT("x"), wxPG_LABEL
, 1.0) );
86 pg
->AppendIn( botId
, new wxFloatProperty(wxT("y"), wxPG_LABEL
, 2.0) );
87 pg
->AppendIn( botId
, new wxFloatProperty(wxT("z"), wxPG_LABEL
, 3.0) );
88 pg
->AppendIn( medId
, new wxStringProperty(wxT("Name"), wxPG_LABEL
, wxT("name")) );
93 void MyFrame::OnPropertyGridChange(wxPropertyGridEvent
&event
)
95 wxPGProperty
* p
= event
.GetProperty();
97 wxLogDebug(wxT("OnPropertyGridChange(%s)"), p
->GetName().c_str());
99 if ( p
->GetBaseName() == wxT("x") )
101 wxLogDebug(wxT("double values=%.2f)"), m_pg
->GetPropertyValueAsDouble(p
));
105 void MyFrame::OnAction(wxCommandEvent
&)