| 1 |
#include "banner_window_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "choice_property.h" |
| 5 |
#include "color_property.h" |
| 6 |
#include "file_ficker_property.h" |
| 7 |
#include "multi_strings_property.h" |
| 8 |
#include "wxc_bitmap_code_generator.h" |
| 9 |
#include "wxgui_helpers.h" |
| 10 |
|
| 11 |
#include <wx/bannerwindow.h> |
| 12 |
|
| 13 |
BannerWindowWrapper::BannerWindowWrapper() |
| 14 |
: wxcWidget(ID_WXBANNERWINDOW) |
| 15 |
{ |
| 16 |
wxArrayString options; |
| 17 |
options.Add("wxTOP"); |
| 18 |
options.Add("wxBOTTOM"); |
| 19 |
options.Add("wxLEFT"); |
| 20 |
options.Add("wxRIGHT"); |
| 21 |
|
| 22 |
SetPropertyString(_("Common Settings"), "wxBannerWindow"); |
| 23 |
AddProperty(new MultiStringsProperty( |
| 24 |
PROP_TITLE, _("The Title\nTitle is rendered in bold and should be single line"), "\\n", "")); |
| 25 |
AddProperty(new MultiStringsProperty(PROP_MESSAGE, |
| 26 |
_("Message can have multiple lines but is not wrapped automatically\ninclude " |
| 27 |
"explicit line breaks in the string if you want to have multiple lines"), |
| 28 |
"\\n", "")); |
| 29 |
AddProperty( |
| 30 |
new ChoiceProperty(PROP_ORIENTATION, options, 2, |
| 31 |
_("The banner orientation changes how the text in it is displayed and also defines where is " |
| 32 |
"the bitmap truncated if it's too big to fit\nbut doesn't do anything for the banner " |
| 33 |
"position, this is supposed to be taken care of in the usual way, e.g. using sizers"))); |
| 34 |
AddProperty(new BitmapPickerProperty( |
| 35 |
PROP_BITMAP_PATH, "", |
| 36 |
_("Select the bitmap file\nImportant: You can set text and title OR a bitmap, but not both"))); |
| 37 |
AddProperty(new ColorProperty(PROP_COLOR_GRADIENT_START)); |
| 38 |
AddProperty(new ColorProperty(PROP_COLOR_GRADIENT_END)); |
| 39 |
|
| 40 |
SetPropertyString(PROP_TITLE, "Title"); |
| 41 |
SetPropertyString(PROP_MESSAGE, "Descriptive message"); |
| 42 |
m_namePattern = "m_banner"; |
| 43 |
SetName(GenerateName()); |
| 44 |
} |
| 45 |
|
| 46 |
BannerWindowWrapper::~BannerWindowWrapper() {} |
| 47 |
|
| 48 |
wxcWidget* BannerWindowWrapper::Clone() const { return new BannerWindowWrapper(); } |
| 49 |
|
| 50 |
wxString BannerWindowWrapper::CppCtorCode() const |
| 51 |
{ |
| 52 |
wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); |
| 53 |
wxString cppCode; |
| 54 |
cppCode << GetName() << " = new " << GetRealClassName() << "(" << GetWindowParent() << ", " << WindowID() << ", " |
| 55 |
<< PropertyString(PROP_ORIENTATION) << ", " |
| 56 |
<< "wxDefaultPosition, " << SizeAsString() << ", " << StyleFlags("0") << ");\n"; |
| 57 |
|
| 58 |
cppCode << GetName() << "->SetBitmap(" << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) |
| 59 |
<< ");\n"; |
| 60 |
cppCode << GetName() << "->SetText(" << wxCrafter::UNDERSCORE(PropertyString(PROP_TITLE)) << ", " |
| 61 |
<< wxCrafter::UNDERSCORE(PropertyString(PROP_MESSAGE)) << ");\n"; |
| 62 |
|
| 63 |
wxString col1, col2; |
| 64 |
col1 = wxCrafter::ColourToCpp(PropertyString(PROP_COLOR_GRADIENT_START)); |
| 65 |
col2 = wxCrafter::ColourToCpp(PropertyString(PROP_COLOR_GRADIENT_END)); |
| 66 |
|
| 67 |
if(!col1.IsEmpty() && !col2.IsEmpty()) { |
| 68 |
cppCode << GetName() << "->SetGradient(" << col1 << ", " << col2 << ");\n"; |
| 69 |
} |
| 70 |
|
| 71 |
cppCode << CPPCommonAttributes(); |
| 72 |
return cppCode; |
| 73 |
} |
| 74 |
|
| 75 |
void BannerWindowWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/bannerwindow.h>"); } |
| 76 |
wxString BannerWindowWrapper::GetWxClassName() const { return "wxBannerWindow"; } |
| 77 |
|
| 78 |
void BannerWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 79 |
{ |
| 80 |
wxUnusedVar(type); |
| 81 |
text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << XRCBitmap() << "<title>" |
| 82 |
<< wxCrafter::CDATA(PropertyString(PROP_TITLE)) << "</title>" |
| 83 |
<< "<message>" << wxCrafter::CDATA(PropertyString(PROP_MESSAGE)) << "</message>" |
| 84 |
<< "<direction>" << PropertyString(PROP_ORIENTATION) << "</direction>" |
| 85 |
<< "<gradient-start>" << wxCrafter::GetColourForXRC(PropertyString(PROP_COLOR_GRADIENT_START)) |
| 86 |
<< "</gradient-start>" |
| 87 |
<< "<gradient-end>" << wxCrafter::GetColourForXRC(PropertyString(PROP_COLOR_GRADIENT_END)) << "</gradient-end>" |
| 88 |
<< XRCSuffix(); |
| 89 |
} |