| 1 |
#include "SimpleHtmlListBoxWrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "wxgui_helpers.h" |
| 4 |
#include <wx/htmllbox.h> |
| 5 |
|
| 6 |
SimpleHtmlListBoxWrapper::SimpleHtmlListBoxWrapper() |
| 7 |
: wxcWidget(ID_WXSIMPLEHTMLLISTBOX) |
| 8 |
{ |
| 9 |
// Styles |
| 10 |
PREPEND_STYLE(wxHLB_DEFAULT_STYLE, true); |
| 11 |
PREPEND_STYLE(wxHLB_MULTIPLE, false); |
| 12 |
|
| 13 |
// Events |
| 14 |
RegisterEventCommand("wxEVT_LISTBOX", _("Process a wxEVT_LISTBOX event, when an item on the list is selected")); |
| 15 |
RegisterEventCommand("wxEVT_LISTBOX_DCLICK", |
| 16 |
_("Process a wxEVT_LISTBOX_DCLICK event, when the listbox is double-clicked")); |
| 17 |
RegisterEvent("wxEVT_HTML_CELL_CLICKED", "wxHtmlCellEvent", _("A wxHtmlCell was clicked. See wxHtmlCellEvent")); |
| 18 |
RegisterEvent("wxEVT_HTML_CELL_HOVER", "wxHtmlCellEvent", |
| 19 |
_("The mouse passed over a wxHtmlCell. See wxHtmlCellEvent")); |
| 20 |
RegisterEvent("wxEVT_HTML_LINK_CLICKED", "wxHtmlLinkEvent", |
| 21 |
_("A wxHtmlCell which contains an hyperlink was clicked. See wxHtmlLinkEvent")); |
| 22 |
SetPropertyString(_("Common Settings"), "wxSimpleHtmlListBox"); |
| 23 |
AddProperty(new MultiStringsProperty( |
| 24 |
PROP_OPTIONS, _("The List Box Items. A semi-colon list of strings. This list may contain HTML fragments"))); |
| 25 |
AddProperty(new StringProperty( |
| 26 |
PROP_SELECTION, wxT("-1"), |
| 27 |
_("The zero-based position of any initially selected string, or -1 if none are to be selected"))); |
| 28 |
|
| 29 |
// Basic name pattern |
| 30 |
m_namePattern = "m_htmlListBox"; |
| 31 |
SetName(GenerateName()); |
| 32 |
} |
| 33 |
|
| 34 |
SimpleHtmlListBoxWrapper::~SimpleHtmlListBoxWrapper() {} |
| 35 |
|
| 36 |
void SimpleHtmlListBoxWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/htmllbox.h>"); } |
| 37 |
|
| 38 |
wxString SimpleHtmlListBoxWrapper::CppCtorCode() const |
| 39 |
{ |
| 40 |
wxString code; |
| 41 |
wxArrayString options = wxCrafter::Split(PropertyString(PROP_OPTIONS), wxT(";")); |
| 42 |
|
| 43 |
wxString optionsArr; |
| 44 |
optionsArr << GetName() << wxT("Arr"); |
| 45 |
|
| 46 |
code << wxT("wxArrayString ") << optionsArr << wxT(";\n"); |
| 47 |
for(size_t i = 0; i < options.GetCount(); i++) { |
| 48 |
|
| 49 |
code << optionsArr << wxT(".Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); |
| 50 |
} |
| 51 |
|
| 52 |
code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID() |
| 53 |
<< wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ") << optionsArr << wxT(", ") |
| 54 |
<< StyleFlags(wxT("0")) << wxT(");\n"); |
| 55 |
code << CPPCommonAttributes(); |
| 56 |
|
| 57 |
int sel = wxCrafter::ToNumber(PropertyString(PROP_SELECTION), -1); |
| 58 |
if(sel >= 0 && sel < (int)options.GetCount()) { |
| 59 |
code << GetName() << wxT("->SetSelection(") << PropertyString(PROP_SELECTION) << wxT(");\n"); |
| 60 |
} |
| 61 |
return code; |
| 62 |
} |
| 63 |
|
| 64 |
wxString SimpleHtmlListBoxWrapper::GetWxClassName() const { return "wxSimpleHtmlListBox"; } |
| 65 |
|
| 66 |
void SimpleHtmlListBoxWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 67 |
{ |
| 68 |
wxArrayString options = wxCrafter::Split(PropertyString(PROP_OPTIONS), wxT(";")); |
| 69 |
text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes() << XRCContentItems() << XRCSelection() |
| 70 |
<< XRCSuffix(); |
| 71 |
} |