]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: samples/propgrid/propgrid_minimal.cpp | |
3 | // Purpose: Minimal portion of wxPropertyGrid sample | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-23 | |
1c4293cb | 7 | // Copyright: (c) Jaakko Salli |
526954c5 | 8 | // Licence: wxWindows licence |
1c4293cb VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #include "wx/wx.h" | |
12 | #include "wx/propgrid/propgrid.h" | |
5e2ab81d | 13 | #include "wx/propgrid/advprops.h" |
1c4293cb | 14 | |
8a28bf76 VZ |
15 | class MyFrame : public wxFrame |
16 | { | |
17 | public: | |
18 | MyFrame(wxWindow* parent); | |
19 | ||
20 | void OnAction(wxCommandEvent& event); | |
21 | void OnPropertyGridChange(wxPropertyGridEvent& event); | |
22 | void OnPropertyGridChanging(wxPropertyGridEvent& event); | |
1c4293cb VZ |
23 | |
24 | private: | |
25 | wxPropertyGrid* m_pg; | |
26 | DECLARE_EVENT_TABLE() | |
27 | }; | |
28 | ||
1c4293cb VZ |
29 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
30 | EVT_MENU(wxID_HIGHEST+1, MyFrame::OnAction) | |
31 | EVT_PG_CHANGED( -1, MyFrame::OnPropertyGridChange ) | |
0371f89b | 32 | EVT_PG_CHANGING( -1, MyFrame::OnPropertyGridChanging ) |
1c4293cb VZ |
33 | END_EVENT_TABLE() |
34 | ||
35 | MyFrame::MyFrame(wxWindow* parent) | |
36 | : wxFrame(parent, wxID_ANY, wxT("PropertyGrid Test")) | |
37 | { | |
8a28bf76 VZ |
38 | wxMenu *Menu = new wxMenu; |
39 | Menu->Append(wxID_HIGHEST+1, wxT("Action")); | |
40 | wxMenuBar *MenuBar = new wxMenuBar(); | |
41 | MenuBar->Append(Menu, wxT("Action")); | |
42 | SetMenuBar(MenuBar); | |
1c4293cb VZ |
43 | |
44 | wxPropertyGrid *pg = new wxPropertyGrid(this,-1,wxDefaultPosition,wxSize(400,400), | |
45 | wxPG_SPLITTER_AUTO_CENTER | | |
46 | wxPG_BOLD_MODIFIED ); | |
47 | m_pg = pg; | |
48 | ||
68545f78 JS |
49 | pg->Append( new wxStringProperty("String Property", wxPG_LABEL) ); |
50 | pg->Append( new wxIntProperty("Int Property", wxPG_LABEL) ); | |
51 | pg->Append( new wxBoolProperty("Bool Property", wxPG_LABEL) ); | |
1c4293cb VZ |
52 | |
53 | SetSize(400, 600); | |
54 | } | |
55 | ||
56 | void MyFrame::OnPropertyGridChange(wxPropertyGridEvent &event) | |
57 | { | |
58 | wxPGProperty* p = event.GetProperty(); | |
59 | ||
68545f78 | 60 | if ( p ) |
43b2d5e7 | 61 | { |
8a28bf76 | 62 | wxLogVerbose("OnPropertyGridChange(%s, value=%s)", |
0371f89b | 63 | p->GetName().c_str(), p->GetValueAsString().c_str()); |
43b2d5e7 | 64 | } |
68545f78 | 65 | else |
43b2d5e7 | 66 | { |
8a28bf76 | 67 | wxLogVerbose("OnPropertyGridChange(NULL)"); |
43b2d5e7 | 68 | } |
1c4293cb VZ |
69 | } |
70 | ||
0371f89b JS |
71 | void MyFrame::OnPropertyGridChanging(wxPropertyGridEvent &event) |
72 | { | |
73 | wxPGProperty* p = event.GetProperty(); | |
74 | ||
8a28bf76 | 75 | wxLogVerbose("OnPropertyGridChanging(%s)", p->GetName().c_str()); |
0371f89b JS |
76 | } |
77 | ||
8a28bf76 | 78 | void MyFrame::OnAction(wxCommandEvent &) |
1c4293cb VZ |
79 | { |
80 | } | |
68545f78 JS |
81 | |
82 | // Called from propgridsample.cpp | |
83 | // | |
84 | void DisplayMinimalFrame(wxWindow* parent) | |
85 | { | |
86 | MyFrame *frame = new MyFrame(parent); | |
87 | frame->Show(true); | |
88 | } |