File: std_button_wrapper.cpp

package info (click to toggle)
codelite 14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (71 lines) | stat: -rw-r--r-- 2,751 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "std_button_wrapper.h"
#include "allocator_mgr.h"
#include "bool_property.h"
#include "choice_property.h"
#include "multi_strings_property.h"
#include "wxgui_defs.h"
#include "xmlutils.h"

StdButtonWrapper::StdButtonWrapper()
    : wxcWidget(ID_WXSTDBUTTON)
{
    m_properties.DeleteValues();
    wxArrayString ids;
    ids.Add("wxID_OK");
    ids.Add("wxID_YES");
    ids.Add("wxID_SAVE");
    ids.Add("wxID_APPLY");
    ids.Add("wxID_CLOSE");
    ids.Add("wxID_NO");
    ids.Add("wxID_CANCEL");
    ids.Add("wxID_HELP");
    ids.Add("wxID_CONTEXT_HELP");

    RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"),
                  wxT("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."),
                  wxT("wxCommandEventHandler"));

    AddProperty(new CategoryProperty(_("Standard wxButton")));
    AddProperty(new ChoiceProperty(PROP_WINDOW_ID, ids, 0, _("Button ID")));
    AddProperty(new StringProperty(PROP_NAME, wxT(""), _("C++ member name")));
    AddProperty(new MultiStringsProperty(PROP_TOOLTIP, _("Tooltip"), wxT("\\n"), _("Tooltip text:")));
    AddProperty(new BoolProperty(PROP_DEFAULT_BUTTON, false, wxT("Make this button the default button")));
    m_namePattern = "m_button";
    SetName(GenerateName());
}

StdButtonWrapper::~StdButtonWrapper() {}

wxcWidget* StdButtonWrapper::Clone() const { return new StdButtonWrapper(); }

wxString StdButtonWrapper::CppCtorCode() const
{
    wxString code;
    code << CPPStandardWxCtorWithLabel("0");
    if(PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { code << GetName() << wxT("->SetDefault();\n"); }
    code << CPPCommonAttributes();
    return code;
}

void StdButtonWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/button.h>")); }

wxString StdButtonWrapper::GetWxClassName() const { return "wxButton"; }

void StdButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const
{
    text << "<object class=\"button\">" << wxT("<object class=\"") << GetWxClassName() << wxT("\" name=\"") << GetId()
         << wxT("\">") << XRCLabel() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("<default>")
         << PropertyString(PROP_DEFAULT_BUTTON) << wxT("</default>") << XRCSuffix() // wxButton
         << XRCSuffix();                                                            // button
}

void StdButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
{
    // First call the base-class for the standard things
    wxcWidget::LoadPropertiesFromXRC(node);

    wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("default"));
    if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); }
}

// wxFB doesn't do anything here