| 1 |
#include "aui_manager_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "choice_property.h" |
| 4 |
#include "color_property.h" |
| 5 |
#include "int_property.h" |
| 6 |
#include "wxgui_helpers.h" |
| 7 |
#include <wx/aui/framemanager.h> |
| 8 |
|
| 9 |
AuiManagerWrapper::AuiManagerWrapper() |
| 10 |
: wxcWidget(ID_WXAUIMANAGER) |
| 11 |
{ |
| 12 |
m_sizerFlags.Clear(); |
| 13 |
m_properties.DeleteValues(); |
| 14 |
|
| 15 |
// wxAUI_DOCKART_PANE_BORDER_SIZE |
| 16 |
// wxAUI_DOCKART_BACKGROUND_COLOUR |
| 17 |
// wxAUI_DOCKART_SASH_COLOUR |
| 18 |
// wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR |
| 19 |
// wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR |
| 20 |
// wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR |
| 21 |
// wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR |
| 22 |
// wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR |
| 23 |
// wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR |
| 24 |
// wxAUI_DOCKART_BORDER_COLOUR |
| 25 |
// wxAUI_DOCKART_GRIPPER_COLOUR |
| 26 |
// wxAUI_DOCKART_GRADIENT_TYPE |
| 27 |
|
| 28 |
SetPropertyString(_("Common Settings"), "wxAuiManager"); |
| 29 |
AddProperty(new CategoryProperty(_("General"))); |
| 30 |
AddProperty(new StringProperty(PROP_NAME, "", _("wxAuiManager member name"))); |
| 31 |
AddProperty(new ColorProperty(PROP_BG, "<Default>", _("Background Colour"))); |
| 32 |
AddProperty(new IntProperty(PROP_AUI_PANE_BORDER_SIZE, -1, _("Pane border size"))); |
| 33 |
|
| 34 |
AddProperty(new CategoryProperty(_("Sash"))); |
| 35 |
AddProperty(new ColorProperty(PROP_AUI_SASH_COLOUR, "<Default>", _("Sash colour"))); |
| 36 |
AddProperty(new IntProperty(PROP_AUI_SASH_SIZE, -1, _("Set the wxAUI sash size"))); |
| 37 |
|
| 38 |
AddProperty(new CategoryProperty(_("Caption"))); |
| 39 |
wxArrayString gradientTypes; |
| 40 |
gradientTypes.Add("wxAUI_GRADIENT_NONE"); |
| 41 |
gradientTypes.Add("wxAUI_GRADIENT_VERTICAL"); |
| 42 |
gradientTypes.Add("wxAUI_GRADIENT_HORIZONTAL"); |
| 43 |
AddProperty(new ChoiceProperty(PROP_AUI_GRADIENT_TYPE, gradientTypes, 0, _("Gradient type"))); |
| 44 |
|
| 45 |
AddProperty(new ColorProperty(PROP_AUI_CAPTION_COLOUR, "<Default>", _("Active caption colour"))); |
| 46 |
AddProperty(new ColorProperty(PROP_AUI_CAPTION_COLOUR_GRADIENT, "<Default>", _("Active caption gradient colour"))); |
| 47 |
AddProperty(new ColorProperty(PROP_AUI_INACTIVE_CAPTION_COLOUR, "<Default>", _("Inactive caption colour"))); |
| 48 |
AddProperty(new ColorProperty(PROP_AUI_INACTIVE_CAPTION_COLOUR_GRADIENT, "<Default>", |
| 49 |
_("Inactive caption gradient colour"))); |
| 50 |
AddProperty(new ColorProperty(PROP_AUI_ACTIVE_CAPTION_TEXT_COLOUR, "<Default>", _("Active caption text colour"))); |
| 51 |
AddProperty( |
| 52 |
new ColorProperty(PROP_AUI_INACTIVE_CAPTION_TEXT_COLOUR, "<Default>", _("Inactive caption text colour"))); |
| 53 |
|
| 54 |
m_styles.Clear(); |
| 55 |
|
| 56 |
PREPEND_STYLE(wxAUI_MGR_ALLOW_FLOATING, true); |
| 57 |
PREPEND_STYLE(wxAUI_MGR_ALLOW_ACTIVE_PANE, true); |
| 58 |
PREPEND_STYLE(wxAUI_MGR_TRANSPARENT_DRAG, true); |
| 59 |
PREPEND_STYLE(wxAUI_MGR_TRANSPARENT_DRAG, true); |
| 60 |
PREPEND_STYLE(wxAUI_MGR_TRANSPARENT_HINT, true); |
| 61 |
PREPEND_STYLE(wxAUI_MGR_VENETIAN_BLINDS_HINT, false); |
| 62 |
PREPEND_STYLE(wxAUI_MGR_RECTANGLE_HINT, false); |
| 63 |
PREPEND_STYLE(wxAUI_MGR_HINT_FADE, false); |
| 64 |
PREPEND_STYLE(wxAUI_MGR_NO_VENETIAN_BLINDS_FADE, false); |
| 65 |
PREPEND_STYLE(wxAUI_MGR_LIVE_RESIZE, true); |
| 66 |
|
| 67 |
RegisterEvent("wxEVT_AUI_PANE_BUTTON", "wxAuiManagerEvent", |
| 68 |
_("Triggered when any button is pressed for any docked panes")); |
| 69 |
RegisterEvent("wxEVT_AUI_PANE_CLOSE", "wxAuiManagerEvent", |
| 70 |
_("Triggered when a docked or floating pane is closed.")); |
| 71 |
RegisterEvent("wxEVT_AUI_PANE_MAXIMIZE", "wxAuiManagerEvent", _("Triggered when a pane is maximized.")); |
| 72 |
RegisterEvent("wxEVT_AUI_PANE_RESTORE", "wxAuiManagerEvent", _("Triggered when a pane is restored.")); |
| 73 |
RegisterEvent("wxEVT_AUI_PANE_ACTIVATED", "wxAuiManagerEvent", |
| 74 |
_("Triggered when a pane is made 'active'. This event is new since wxWidgets 2.9.4.")); |
| 75 |
RegisterEvent("wxEVT_AUI_RENDER", "wxAuiManagerEvent", |
| 76 |
_("This event can be caught to override the default renderer in order " |
| 77 |
"to custom draw your wxAuiManager window (not recommended).")); |
| 78 |
|
| 79 |
m_namePattern = "m_auimgr"; |
| 80 |
SetName(GenerateName()); |
| 81 |
} |
| 82 |
|
| 83 |
AuiManagerWrapper::~AuiManagerWrapper() {} |
| 84 |
|
| 85 |
wxcWidget* AuiManagerWrapper::Clone() const { return new AuiManagerWrapper(); } |
| 86 |
|
| 87 |
wxString AuiManagerWrapper::CppCtorCode() const |
| 88 |
{ |
| 89 |
wxString cppCode; |
| 90 |
cppCode << GetName() << " = new wxAuiManager;\n"; |
| 91 |
|
| 92 |
if(GetParent()->IsTopWindow()) { |
| 93 |
cppCode << GetName() << "->SetManagedWindow( this );\n"; |
| 94 |
} else { |
| 95 |
cppCode << GetName() << "->SetManagedWindow( " << GetParent()->GetName() << " );\n"; |
| 96 |
} |
| 97 |
cppCode << GetName() << "->SetFlags( " << StyleFlags("0") << ");\n"; |
| 98 |
if(PropertyInt(PROP_AUI_SASH_SIZE) != -1) |
| 99 |
cppCode << GetName() << "->GetArtProvider()->SetMetric( wxAUI_DOCKART_SASH_SIZE, " |
| 100 |
<< PropertyInt(PROP_AUI_SASH_SIZE) << ");\n"; |
| 101 |
|
| 102 |
if(PropertyInt(PROP_AUI_PANE_BORDER_SIZE) != -1) |
| 103 |
cppCode << GetName() << "->GetArtProvider()->SetMetric( wxAUI_DOCKART_PANE_BORDER_SIZE, " |
| 104 |
<< PropertyInt(PROP_AUI_PANE_BORDER_SIZE) << ");\n"; |
| 105 |
|
| 106 |
wxString col; |
| 107 |
|
| 108 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_SASH_COLOUR)); |
| 109 |
if(!col.IsEmpty()) |
| 110 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_SASH_COLOUR, " << col << ");\n"; |
| 111 |
|
| 112 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_CAPTION_COLOUR)); |
| 113 |
if(!col.IsEmpty()) |
| 114 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR, " << col << ");\n"; |
| 115 |
|
| 116 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_CAPTION_COLOUR_GRADIENT)); |
| 117 |
if(!col.IsEmpty()) |
| 118 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, " << col |
| 119 |
<< ");\n"; |
| 120 |
|
| 121 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR)); |
| 122 |
if(!col.IsEmpty()) |
| 123 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR, " << col |
| 124 |
<< ");\n"; |
| 125 |
|
| 126 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR_GRADIENT)); |
| 127 |
if(!col.IsEmpty()) |
| 128 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR, " << col |
| 129 |
<< ");\n"; |
| 130 |
|
| 131 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_ACTIVE_CAPTION_TEXT_COLOUR)); |
| 132 |
if(!col.IsEmpty()) |
| 133 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR, " << col |
| 134 |
<< ");\n"; |
| 135 |
|
| 136 |
col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_TEXT_COLOUR)); |
| 137 |
if(!col.IsEmpty()) |
| 138 |
cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, " << col |
| 139 |
<< ");\n"; |
| 140 |
cppCode << GetName() << "->GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE, " |
| 141 |
<< PropertyString(PROP_AUI_GRADIENT_TYPE) << ");\n"; |
| 142 |
|
| 143 |
return cppCode; |
| 144 |
} |
| 145 |
|
| 146 |
void AuiManagerWrapper::GetIncludeFile(wxArrayString& headers) const |
| 147 |
{ |
| 148 |
headers.Add("#include <wx/aui/framemanager.h>"); |
| 149 |
headers.Add("#include <wx/aui/dockart.h>"); |
| 150 |
} |
| 151 |
|
| 152 |
wxString AuiManagerWrapper::GetWxClassName() const { return "wxAuiManager"; } |
| 153 |
|
| 154 |
void AuiManagerWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 155 |
{ |
| 156 |
text << "<object class=\"wxAuiManager\">"; |
| 157 |
text << "<style>" << StyleFlags("wxAUI_MGR_DEFAULT") << "</style>"; |
| 158 |
text << "<sashsize>" << PropertyInt(PROP_AUI_SASH_SIZE) << "</sashsize>"; |
| 159 |
text << "<pane-border-size>" << PropertyInt(PROP_AUI_PANE_BORDER_SIZE) << "</pane-border-size>"; |
| 160 |
text << "<sash-colour>" << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_SASH_COLOUR)) << "</sash-colour>"; |
| 161 |
text << "<caption-colour>" << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_CAPTION_COLOUR)); |
| 162 |
text << "</caption-colour>"; |
| 163 |
text << "<caption-colour-gradient>" << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_CAPTION_COLOUR_GRADIENT)); |
| 164 |
text << "</caption-colour-gradient>"; |
| 165 |
text << "<inactive-caption-colour>" << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR)); |
| 166 |
text << "</inactive-caption-colour>"; |
| 167 |
text << "<inactive-caption-colour-gradient>"; |
| 168 |
text << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR_GRADIENT)); |
| 169 |
text << "</inactive-caption-colour-gradient>"; |
| 170 |
text << "<caption-text-colour>" << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_ACTIVE_CAPTION_TEXT_COLOUR)); |
| 171 |
text << "</caption-text-colour>"; |
| 172 |
text << "<inactive-caption-text-colour>"; |
| 173 |
text << wxCrafter::GetColourForXRC(PropertyString(PROP_AUI_ACTIVE_CAPTION_TEXT_COLOUR)); |
| 174 |
text << "</inactive-caption-text-colour>"; |
| 175 |
text << "<gradient-type>" << PropertyString(PROP_AUI_GRADIENT_TYPE) << "</gradient-type>"; |
| 176 |
|
| 177 |
ChildrenXRC(text, type); |
| 178 |
text << XRCSuffix(); |
| 179 |
} |
| 180 |
|
| 181 |
wxString AuiManagerWrapper::CppDtorCode() const |
| 182 |
{ |
| 183 |
wxString cppCode; |
| 184 |
cppCode << " " << GetName() << "->UnInit();\n"; |
| 185 |
cppCode << " delete " << GetName() << ";\n"; |
| 186 |
return cppCode; |
| 187 |
} |