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