| 1 |
#include "font_picker_ctrl_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "font_property.h" |
| 4 |
#include "wxgui_defs.h" |
| 5 |
#include "wxgui_helpers.h" |
| 6 |
#include "xmlutils.h" |
| 7 |
#include <wx/fontpicker.h> |
| 8 |
|
| 9 |
FontPickerCtrlWrapper::FontPickerCtrlWrapper() |
| 10 |
: wxcWidget(ID_WXFONTPICKER) |
| 11 |
{ |
| 12 |
SetPropertyString(_("Common Settings"), "wxFontPickerCtrl"); |
| 13 |
DelProperty(PROP_FONT); |
| 14 |
|
| 15 |
PREPEND_STYLE(wxFNTP_USE_TEXTCTRL, false); |
| 16 |
PREPEND_STYLE(wxFNTP_FONTDESC_AS_LABEL, false); |
| 17 |
PREPEND_STYLE(wxFNTP_USEFONT_FOR_LABEL, false); |
| 18 |
PREPEND_STYLE(wxFNTP_DEFAULT_STYLE, true); |
| 19 |
|
| 20 |
RegisterEvent(wxT("wxEVT_COMMAND_FONTPICKER_CHANGED"), wxT("wxFontPickerEvent"), |
| 21 |
_("Generated whenever the selected font changes.")); |
| 22 |
AddProperty(new FontProperty(PROP_VALUE, wxEmptyString, _("Initial font"))); |
| 23 |
m_namePattern = wxT("m_fontPicker"); |
| 24 |
SetName(GenerateName()); |
| 25 |
} |
| 26 |
|
| 27 |
FontPickerCtrlWrapper::~FontPickerCtrlWrapper() {} |
| 28 |
|
| 29 |
wxcWidget* FontPickerCtrlWrapper::Clone() const { return new FontPickerCtrlWrapper(); } |
| 30 |
|
| 31 |
wxString FontPickerCtrlWrapper::CppCtorCode() const |
| 32 |
{ |
| 33 |
wxString code; |
| 34 |
wxString fontCode; |
| 35 |
wxString fontMemberName = GetName() + wxT("Font"); |
| 36 |
if(wxCrafter::FontToCpp(PropertyString(PROP_VALUE), fontMemberName) != wxT("wxNullFont")) { |
| 37 |
code << wxCrafter::FontToCpp(PropertyString(PROP_VALUE), fontMemberName); |
| 38 |
fontCode = fontMemberName; |
| 39 |
|
| 40 |
} else { |
| 41 |
fontCode = wxT("wxNullFont"); |
| 42 |
} |
| 43 |
|
| 44 |
code << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ") |
| 45 |
<< WindowID() << wxT(", ") << fontCode << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() |
| 46 |
<< wxT(", ") << StyleFlags(wxT("wxFNTP_DEFAULT_STYLE")) << wxT(");\n"); |
| 47 |
|
| 48 |
code << CPPCommonAttributes(); |
| 49 |
return code; |
| 50 |
} |
| 51 |
|
| 52 |
void FontPickerCtrlWrapper::GetIncludeFile(wxArrayString& headers) const |
| 53 |
{ |
| 54 |
headers.Add(wxT("#include <wx/fontpicker.h>")); |
| 55 |
} |
| 56 |
|
| 57 |
wxString FontPickerCtrlWrapper::GetWxClassName() const { return wxT("wxFontPickerCtrl"); } |
| 58 |
|
| 59 |
void FontPickerCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 60 |
{ |
| 61 |
text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("<value>") |
| 62 |
<< wxCrafter::FontToXRC(PropertyString(PROP_VALUE)) << wxT("</value>") << XRCSuffix(); |
| 63 |
} |
| 64 |
|
| 65 |
void FontPickerCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 66 |
{ |
| 67 |
// First call the base-class for the standard things |
| 68 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 69 |
|
| 70 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); |
| 71 |
if(propertynode) { SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); } |
| 72 |
} |
| 73 |
|
| 74 |
void FontPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 75 |
{ |
| 76 |
// First call the base-class for the standard things |
| 77 |
wxcWidget::LoadPropertiesFromwxSmith(node); |
| 78 |
|
| 79 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); |
| 80 |
if(propertynode) { SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); } |
| 81 |
} |
| 82 |
|
| 83 |
void FontPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 84 |
{ |
| 85 |
// First call the base-class for the standard things |
| 86 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 87 |
|
| 88 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); |
| 89 |
if(propertynode) { |
| 90 |
wxString fontasstring = wxCrafter::FBToFontstring(propertynode->GetNodeContent()); |
| 91 |
if(!fontasstring.empty()) { SetPropertyString(PROP_VALUE, fontasstring); } |
| 92 |
} |
| 93 |
} |