| 1 |
#include "command_link_button_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "bitmap_picker_property.h" |
| 5 |
#include "bool_property.h" |
| 6 |
#include "file_ficker_property.h" |
| 7 |
#include "wxc_bitmap_code_generator.h" |
| 8 |
#include "wxgui_defs.h" |
| 9 |
#include "wxgui_helpers.h" |
| 10 |
|
| 11 |
#include <wx/button.h> |
| 12 |
|
| 13 |
CommandLinkButtonWrapper::CommandLinkButtonWrapper() |
| 14 |
: wxcWidget(ID_WXCOMMANDLINKBUTTON) |
| 15 |
{ |
| 16 |
PREPEND_STYLE(wxBU_BOTTOM, false); |
| 17 |
PREPEND_STYLE(wxBU_EXACTFIT, false); |
| 18 |
PREPEND_STYLE(wxBU_LEFT, false); |
| 19 |
PREPEND_STYLE(wxBU_RIGHT, false); |
| 20 |
PREPEND_STYLE(wxBU_TOP, false); |
| 21 |
|
| 22 |
SetPropertyString(_("Common Settings"), "wxCommandLinkButton"); |
| 23 |
DelProperty(_("Control Specific Settings")); |
| 24 |
AddProperty(new CategoryProperty("wxCommandLinkButton")); |
| 25 |
|
| 26 |
RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", "wxCommandEvent", |
| 27 |
_("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), |
| 28 |
"wxCommandEventHandler"); |
| 29 |
|
| 30 |
AddProperty(new StringProperty(PROP_LABEL, _("Label"), |
| 31 |
_("First line of text on the button, typically the label of an action that will be " |
| 32 |
"made when the button is pressed"))); |
| 33 |
AddProperty(new StringProperty( |
| 34 |
PROP_NOTE, "", _("Second line of text describing the action performed when the button is pressed"))); |
| 35 |
AddProperty(new BitmapPickerProperty(PROP_BITMAP_PATH, "", _("Select the bitmap file"))); |
| 36 |
AddProperty(new BoolProperty(PROP_DEFAULT_BUTTON, false, _("Make this button the default button"))); |
| 37 |
|
| 38 |
m_namePattern = "m_cmdLnkBtn"; |
| 39 |
SetName(GenerateName()); |
| 40 |
} |
| 41 |
|
| 42 |
CommandLinkButtonWrapper::~CommandLinkButtonWrapper() {} |
| 43 |
|
| 44 |
wxcWidget* CommandLinkButtonWrapper::Clone() const { return new CommandLinkButtonWrapper(); } |
| 45 |
|
| 46 |
wxString CommandLinkButtonWrapper::CppCtorCode() const |
| 47 |
{ |
| 48 |
wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); |
| 49 |
wxString cppCode; |
| 50 |
cppCode << GetName() << " = new " << GetRealClassName() << "(" << GetWindowParent() << ", " << GetId() << ", " |
| 51 |
<< Label() << ", " << wxCrafter::UNDERSCORE(PropertyString(PROP_NOTE)) << ", " |
| 52 |
<< "wxDefaultPosition, " << SizeAsString() << ", " << StyleFlags("0") << ");\n"; |
| 53 |
|
| 54 |
wxString bmpCpp = wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)); |
| 55 |
if(bmpCpp != "wxNullBitmap") { |
| 56 |
cppCode << GetName() << "->SetBitmap(" << bmpCpp << ", wxLEFT );\n"; |
| 57 |
} |
| 58 |
|
| 59 |
if(PropertyBool(PROP_DEFAULT_BUTTON) == "true") { |
| 60 |
cppCode << GetName() << "->SetDefault();\n"; |
| 61 |
} |
| 62 |
|
| 63 |
cppCode << CPPCommonAttributes(); |
| 64 |
return cppCode; |
| 65 |
} |
| 66 |
|
| 67 |
void CommandLinkButtonWrapper::GetIncludeFile(wxArrayString& headers) const |
| 68 |
{ |
| 69 |
headers.Add("#include <wx/commandlinkbutton.h>"); |
| 70 |
} |
| 71 |
|
| 72 |
wxString CommandLinkButtonWrapper::GetWxClassName() const { return "wxCommandLinkButton"; } |
| 73 |
|
| 74 |
void CommandLinkButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 75 |
{ |
| 76 |
wxUnusedVar(type); |
| 77 |
text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << XRCLabel() << XRCBitmap() << "<note>" |
| 78 |
<< wxCrafter::CDATA(PropertyString(PROP_NOTE)) << "</note>" << XRCSuffix(); |
| 79 |
} |