Debian Codegraph @

wxcrafter/controls/bitmaptogglebuttonwrapper.cpp

raw
1 #include "bitmaptogglebuttonwrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxc_bitmap_code_generator.h"
4 #include "wxgui_defs.h"
5
6 BitmapToggleButtonWrapper::BitmapToggleButtonWrapper()
7 : wxcWidget(ID_WXBITMAPTOGGLEBUTTON)
8 {
9 SetPropertyString(_("Common Settings"), "wxBitmapToggleButton");
10 AddProperty(new BitmapPickerProperty(PROP_BITMAP_PATH, "", _("The bitmap")));
11 AddProperty(new BoolProperty(PROP_CHECKED, false, _("The button initial state")));
12
13 PREPEND_STYLE(wxBU_BOTTOM, false);
14 PREPEND_STYLE(wxBU_EXACTFIT, false);
15 PREPEND_STYLE(wxBU_LEFT, false);
16 PREPEND_STYLE(wxBU_RIGHT, false);
17 PREPEND_STYLE(wxBU_TOP, false);
18
19 RegisterEventCommand(wxT("wxEVT_COMMAND_TOGGLEBUTTON_CLICKED"), _("Handles a toggle button click event."));
20
21 m_namePattern = "m_bmpToggleBtn";
22 SetName(GenerateName());
23 }
24
25 BitmapToggleButtonWrapper::~BitmapToggleButtonWrapper() {}
26
27 wxcWidget* BitmapToggleButtonWrapper::Clone() const { return new BitmapToggleButtonWrapper(); }
28
29 wxString BitmapToggleButtonWrapper::CppCtorCode() const
30 {
31 wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH));
32 wxString cpp;
33 cpp << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ") << WindowID()
34 << wxT(", ") << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << wxT(", ")
35 << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags("0") << wxT(");\n");
36 cpp << CPPCommonAttributes();
37 cpp << GetName() << wxT("->SetValue(") << PropertyBool(PROP_CHECKED) << wxT(");\n");
38 return cpp;
39 }
40
41 void BitmapToggleButtonWrapper::GetIncludeFile(wxArrayString& headers) const
42 {
43 headers.Add(wxT("#include <wx/tglbtn.h>"));
44 headers.Add(wxT("#include <wx/button.h>"));
45 }
46
47 wxString BitmapToggleButtonWrapper::GetWxClassName() const { return "wxBitmapToggleButton"; }
48
49 void BitmapToggleButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const
50 {
51 text << XRCPrefix() << XRCStyle() << XRCSize() << XRCBitmap() << XRCCommonAttributes() << wxT("<checked>")
52 << PropertyString(PROP_CHECKED) << wxT("</checked>") << XRCSuffix();
53 }