]>
Commit | Line | Data |
---|---|---|
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 | |
7 | // Copyright: (c) Jaakko Salli | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wx.h" | |
12 | #include "wx/propgrid/propgrid.h" | |
13 | #include "wx/propgrid/advprops.h" | |
14 | ||
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); | |
23 | ||
24 | private: | |
25 | wxPropertyGrid* m_pg; | |
26 | DECLARE_EVENT_TABLE() | |
27 | }; | |
28 | ||
29 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
30 | EVT_MENU(wxID_HIGHEST+1, MyFrame::OnAction) | |
31 | EVT_PG_CHANGED( -1, MyFrame::OnPropertyGridChange ) | |
32 | EVT_PG_CHANGING( -1, MyFrame::OnPropertyGridChanging ) | |
33 | END_EVENT_TABLE() | |
34 | ||
35 | MyFrame::MyFrame(wxWindow* parent) | |
36 | : wxFrame(parent, wxID_ANY, wxT("PropertyGrid Test")) | |
37 | { | |
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); | |
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 | ||
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) ); | |
52 | ||
53 | SetSize(400, 600); | |
54 | } | |
55 | ||
56 | void MyFrame::OnPropertyGridChange(wxPropertyGridEvent &event) | |
57 | { | |
58 | wxPGProperty* p = event.GetProperty(); | |
59 | ||
60 | if ( p ) | |
61 | { | |
62 | wxLogVerbose("OnPropertyGridChange(%s, value=%s)", | |
63 | p->GetName().c_str(), p->GetValueAsString().c_str()); | |
64 | } | |
65 | else | |
66 | { | |
67 | wxLogVerbose("OnPropertyGridChange(NULL)"); | |
68 | } | |
69 | } | |
70 | ||
71 | void MyFrame::OnPropertyGridChanging(wxPropertyGridEvent &event) | |
72 | { | |
73 | wxPGProperty* p = event.GetProperty(); | |
74 | ||
75 | wxLogVerbose("OnPropertyGridChanging(%s)", p->GetName().c_str()); | |
76 | } | |
77 | ||
78 | void MyFrame::OnAction(wxCommandEvent &) | |
79 | { | |
80 | } | |
81 | ||
82 | // Called from propgridsample.cpp | |
83 | // | |
84 | void DisplayMinimalFrame(wxWindow* parent) | |
85 | { | |
86 | MyFrame *frame = new MyFrame(parent); | |
87 | frame->Show(true); | |
88 | } |