Debian Codegraph @

wxcrafter/src/custom_pg_properties.cpp

raw
1 #include "custom_pg_properties.h"
2 #include "color_property.h"
3 #include "wxguicraft_main_view.h"
4 #include <event_notifier.h>
5
6 bool wxPG_Colour::OnEvent(wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event)
7 {
8 if(propgrid->IsMainButtonEvent(event)) {
9 SetValueToUnspecified();
10 ColorProperty* pb = reinterpret_cast<ColorProperty*>(GetClientData());
11 if(pb) { pb->SetValue("<Default>"); }
12
13 // Notify about modifications
14 wxCommandEvent evt(wxEVT_PROPERTIES_MODIFIED);
15 if(pb->GetLabel() == PROP_NAME) { evt.SetString(GetValueAsString()); }
16 EventNotifier::Get()->AddPendingEvent(evt);
17 return true;
18
19 } else {
20 return wxSystemColourProperty::OnEvent(propgrid, primary, event);
21 }
22 }
23
24 // -----------------------------------------------------------------------
25 // wxcPGChoiceAndButtonEditor
26 // -----------------------------------------------------------------------
27
28 wxPGWindowList wxcPGChoiceAndButtonEditor::CreateControls(wxPropertyGrid* propGrid, wxPGProperty* property,
29 const wxPoint& pos, const wxSize& sz) const
30 {
31 // Use one two units smaller to match size of the combo's dropbutton.
32 // (normally a bigger button is used because it looks better)
33 int bt_wid = sz.y;
34 bt_wid -= 2;
35 wxSize bt_sz(bt_wid, bt_wid);
36
37 // Position of button.
38 wxPoint bt_pos(pos.x + sz.x - bt_sz.x, pos.y);
39 #ifdef __WXMAC__
40 bt_pos.y -= 1;
41 #else
42 bt_pos.y += 1;
43 #endif
44
45 wxWindow* bt = propGrid->GenerateEditorButton(bt_pos, bt_sz);
46 bt->SetToolTip(_("Clear"));
47 wxButton* button = dynamic_cast<wxButton*>(bt);
48 if(button) { button->SetLabel("X"); }
49
50 // Size of choice.
51 wxSize ch_sz(sz.x - bt->GetSize().x, sz.y);
52 #if 0
53 #ifdef __WXMAC__
54 ch_sz.x -= wxPG_TEXTCTRL_AND_BUTTON_SPACING;
55 #endif
56 #endif
57
58 wxWindow* ch = wxPGEditor_Choice->CreateControls(propGrid, property, pos, ch_sz).m_primary;
59
60 #ifdef __WXMSW__
61 bt->Show();
62 #endif
63
64 return wxPGWindowList(ch, bt);
65 }
66
67 wxcPGChoiceAndButtonEditor::~wxcPGChoiceAndButtonEditor() {}
68
69 wxString wxcPGChoiceAndButtonEditor::GetName() const { return GetClassInfo()->GetClassName(); }