| 1 |
#include "AuiToolBarTopLevel.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "virtual_folder_property.h" |
| 5 |
#include "winid_property.h" |
| 6 |
#include "xy_pair.h" |
| 7 |
|
| 8 |
#include <wx/aui/auibar.h> |
| 9 |
|
| 10 |
AuiToolBarTopLevelWrapper::AuiToolBarTopLevelWrapper() |
| 11 |
: TopLevelWinWrapper(ID_WXAUITOOLBARTOPLEVEL) |
| 12 |
{ |
| 13 |
m_properties.DeleteValues(); |
| 14 |
m_sizerFlags.Clear(); |
| 15 |
|
| 16 |
SetPropertyString(_("Common Settings"), "wxAuiToolBar"); |
| 17 |
|
| 18 |
AddCategory(_("wxAuiToolBar")); |
| 19 |
AddProperty(new WinIdProperty()); |
| 20 |
AddProperty(new StringProperty(PROP_NAME, "", _("The generated C++ class name"))); |
| 21 |
AddProperty(new StringProperty(PROP_SIZE, "-1,-1", |
| 22 |
_("The control size. It is recommended to leave it as -1,-1 and " |
| 23 |
"let\nthe sizers calculate the best size for the window"))); |
| 24 |
AddProperty(new StringProperty(PROP_TOOLTIP, "", _("Tooltip"))); |
| 25 |
|
| 26 |
AddCategory(_("Inherited C++ Class Properties")); |
| 27 |
AddProperty(new StringProperty(PROP_INHERITED_CLASS, "", |
| 28 |
_("Inherited class name\nFill this field to generate a class that inherits from the " |
| 29 |
"base class,\nwhere you should place all your application logic.\ne.g. for a " |
| 30 |
"generated class 'FooDialogBase', you might enter 'FooDialog' here."))); |
| 31 |
AddProperty(new StringProperty( |
| 32 |
PROP_FILE, "", |
| 33 |
_("The name for the inherited class's files (without any file extension).\nwxCrafter will generate a " |
| 34 |
"$(FILE).cpp and $(FILE).hpp\ne.g. for an inherited class 'FooDialog', you might enter 'foodialog' here."))); |
| 35 |
AddProperty(new StringProperty(PROP_CLASS_DECORATOR, "", |
| 36 |
_("MSW Only\nC++ macro decorator - allows exporting this class from a DLL"))); |
| 37 |
|
| 38 |
if(m_properties.Contains(PROP_NAME)) { |
| 39 |
m_properties.Item(PROP_NAME)->SetTooltip(_("The generated C++ class name")); |
| 40 |
} |
| 41 |
|
| 42 |
AddProperty( |
| 43 |
new VirtualFolderProperty(PROP_VIRTUAL_FOLDER, "", _("codelite's virtual folder for the generated files"))); |
| 44 |
|
| 45 |
AddCategory(_("Control Specific Settings")); |
| 46 |
AddProperty(new StringProperty(PROP_BITMAP_SIZE, "16,16", _("Sets the default size of each tool bitmap"))); |
| 47 |
AddProperty(new StringProperty(PROP_MARGINS, "-1,-1", _("Set the values to be used as margins for the toolbar."))); |
| 48 |
|
| 49 |
PREPEND_STYLE_FALSE(wxAUI_TB_TEXT); |
| 50 |
PREPEND_STYLE_FALSE(wxAUI_TB_NO_TOOLTIPS); |
| 51 |
PREPEND_STYLE_FALSE(wxAUI_TB_NO_AUTORESIZE); |
| 52 |
PREPEND_STYLE_FALSE(wxAUI_TB_GRIPPER); |
| 53 |
PREPEND_STYLE_FALSE(wxAUI_TB_OVERFLOW); |
| 54 |
PREPEND_STYLE_FALSE(wxAUI_TB_VERTICAL); |
| 55 |
PREPEND_STYLE_FALSE(wxAUI_TB_HORZ_LAYOUT); |
| 56 |
PREPEND_STYLE_FALSE(wxAUI_TB_HORZ_TEXT); |
| 57 |
PREPEND_STYLE_TRUE(wxAUI_TB_DEFAULT_STYLE); |
| 58 |
PREPEND_STYLE_TRUE(wxAUI_TB_PLAIN_BACKGROUND); |
| 59 |
|
| 60 |
m_namePattern = "m_auibar"; |
| 61 |
SetName(GenerateName()); |
| 62 |
} |
| 63 |
|
| 64 |
AuiToolBarTopLevelWrapper::~AuiToolBarTopLevelWrapper() {} |
| 65 |
|
| 66 |
wxString AuiToolBarTopLevelWrapper::BaseCtorDecl() const |
| 67 |
{ |
| 68 |
wxString code; |
| 69 |
code << " " << CreateBaseclassName() << "(wxWindow *parent, wxWindowID id = " << WindowID() |
| 70 |
<< ", const wxPoint &position = wxDefaultPosition" |
| 71 |
<< ", const wxSize &size = " << SizeAsString() << ", long style = " << StyleFlags("wxAUI_TB_DEFAULT_STYLE") |
| 72 |
<< ");\n"; |
| 73 |
return code; |
| 74 |
} |
| 75 |
|
| 76 |
wxString AuiToolBarTopLevelWrapper::BaseCtorImplPrefix() const |
| 77 |
{ |
| 78 |
wxString code; |
| 79 |
code << CreateBaseclassName() << "::" << CreateBaseclassName() << "(" |
| 80 |
<< "wxWindow *parent, " |
| 81 |
<< "wxWindowID id, " |
| 82 |
<< "const wxPoint &position, " |
| 83 |
<< "const wxSize &size, " |
| 84 |
<< "long style" |
| 85 |
<< ")\n" |
| 86 |
<< " : " << GetRealClassName() << "(parent, id, position, size, style)\n"; |
| 87 |
return code; |
| 88 |
} |
| 89 |
|
| 90 |
wxcWidget* AuiToolBarTopLevelWrapper::Clone() const { return new AuiToolBarTopLevelWrapper(); } |
| 91 |
|
| 92 |
wxString AuiToolBarTopLevelWrapper::CppCtorCode() const |
| 93 |
{ |
| 94 |
wxString code; |
| 95 |
XYPair pr(PropertyString(PROP_BITMAP_SIZE), 16, 16); |
| 96 |
code << "SetToolBitmapSize(wxSize" << pr.ToString(true) << ");\n"; |
| 97 |
|
| 98 |
XYPair margins(PropertyString(PROP_MARGINS), -1, -1); |
| 99 |
if(margins != XYPair(-1, -1)) { |
| 100 |
code << " SetMargins(" << margins.ToString() << ");\n"; |
| 101 |
} |
| 102 |
return code; |
| 103 |
} |
| 104 |
|
| 105 |
wxString AuiToolBarTopLevelWrapper::DesignerXRC(bool forPreviewDialog) const |
| 106 |
{ |
| 107 |
wxString text; |
| 108 |
text << "<object class=\"wxPanel\" name=\"PreviewPanel\">" |
| 109 |
<< "<size>-1,-1</size>" |
| 110 |
// Fake a sizer |
| 111 |
<< "<object class=\"wxBoxSizer\">" |
| 112 |
<< "<orient>wxVERTICAL</orient>" |
| 113 |
<< "<object class=\"sizeritem\">" |
| 114 |
<< "<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</flag>" |
| 115 |
<< "<border>0</border>"; |
| 116 |
|
| 117 |
ToXRC(text, XRC_DESIGNER); |
| 118 |
|
| 119 |
text << "</object>" // sizeritem |
| 120 |
<< "</object>" // wxBoxSizer |
| 121 |
<< "</object>"; // PreviewPanel |
| 122 |
WrapXRC(text); |
| 123 |
return text; |
| 124 |
} |
| 125 |
|
| 126 |
wxString AuiToolBarTopLevelWrapper::DoGenerateClassMember() const { return GenerateClassMembers(this); } |
| 127 |
|
| 128 |
void AuiToolBarTopLevelWrapper::GetIncludeFile(wxArrayString& headers) const { BaseGetIncludeFile(headers); } |
| 129 |
|
| 130 |
wxString AuiToolBarTopLevelWrapper::GetWxClassName() const { return "wxAuiToolBar"; } |
| 131 |
|
| 132 |
void AuiToolBarTopLevelWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 133 |
{ |
| 134 |
if(type == XRC_PREVIEW) { |
| 135 |
text << "<object class=\"wxPanel\" name=\"" << GetName() << "\">" |
| 136 |
<< "<size>-1,-1</size>" |
| 137 |
// Fake a sizer |
| 138 |
<< "<object class=\"wxBoxSizer\">" |
| 139 |
<< "<orient>wxVERTICAL</orient>" |
| 140 |
<< "<object class=\"sizeritem\">" |
| 141 |
<< "<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</flag>" |
| 142 |
<< "<border>5</border>"; |
| 143 |
} |
| 144 |
XYPair prSize(PropertyString(PROP_BITMAP_SIZE), 16, 16); |
| 145 |
XYPair prMargins(PropertyString(PROP_MARGINS), -1, -1); |
| 146 |
|
| 147 |
if(type == XRC_PREVIEW) { |
| 148 |
// IN Preview Mode, append to the class name |
| 149 |
// a number to distinguish it from the panel |
| 150 |
// that we added earlier in this function |
| 151 |
text << "<object class=\"" << GetWxClassName() << "\" name=\"" << GetName() << "1" |
| 152 |
<< "\">"; |
| 153 |
} else { |
| 154 |
text << XRCPrefix(); |
| 155 |
} |
| 156 |
text << XRCStyle() << XRCCommonAttributes() << "<bitmapsize>" << prSize.ToString() << "</bitmapsize>"; |
| 157 |
|
| 158 |
if(prMargins != XYPair(-1, -1)) { |
| 159 |
text << "<margins>" << prMargins.ToString() << "</margins>"; |
| 160 |
} |
| 161 |
|
| 162 |
ChildrenXRC(text, type); |
| 163 |
text << XRCSuffix(); |
| 164 |
|
| 165 |
if(type == XRC_PREVIEW) { |
| 166 |
text << "</object>" // sizeritem |
| 167 |
<< "</object>" // wxBoxSizer |
| 168 |
<< "</object>"; // PreviewPanel |
| 169 |
WrapXRC(text); |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
void AuiToolBarTopLevelWrapper::DoGenerateExtraFunctions(wxString& decl, wxString& impl) const |
| 174 |
{ |
| 175 |
GenerateExtraFunctions(this, decl, impl); |
| 176 |
} |