2
* This file is part of wxSmith plugin for Code::Blocks Studio
3
* Copyright (C) 2008 Ron Collins
4
* Copyright (C) 2008 Bartlomiej Swiecki
6
* wxSmith is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* wxSmith is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
21
#include "wxssashlayoutwindow.h"
22
#include <wx/sashwin.h>
23
#include <wx/laywin.h>
26
//------------------------------------------------------------------------------
31
wxsRegisterItem<wxsSashLayoutWindow> Reg(
32
_T("SashLayoutWindow"),
39
WXS_ST_BEGIN(wxsSashLayoutWindowStyles,_T("wxSW_3D|wxCLIP_CHILDREN"))
40
WXS_ST_CATEGORY("wxSashLayoutWindow")
48
WXS_EV_BEGIN(wxsSashLayoutWindowEvents)
49
WXS_EVI(EVT_SASH_DRAGGED, wxEVT_SASH_DRAGGED, wxSashEvent, SashDragged)
50
WXS_EVI(EVT_QUERY_LAYOUT_INFO, wxEVT_QUERY_LAYOUT_INFO, wxQueryLayoutInfoEvent, SashQueryLayout)
51
WXS_EVI(EVT_CALCULATE_LAYOUT, wxEVT_CALCULATE_LAYOUT, wxCalculateLayoutEvent, SashCalculateLayout)
56
//------------------------------------------------------------------------------
58
wxsSashLayoutWindow::wxsSashLayoutWindow(wxsItemResData* Data):
59
wxsContainer(Data,&Reg.Info,wxsSashLayoutWindowEvents,wxsSashLayoutWindowStyles)
65
mAlign = wxLAYOUT_LEFT;
66
mOrient = wxLAYOUT_HORIZONTAL;
69
//------------------------------------------------------------------------------
71
wxObject* wxsSashLayoutWindow::OnBuildPreview(wxWindow* Parent,long Flags)
73
// make a thing to display
75
wxSashLayoutWindow* swin = new wxSashLayoutWindow(Parent,GetId(),Pos(Parent),Size(Parent),Style());
76
SetupWindow(swin, Flags);
78
// for now, a sash on all edges
80
swin->SetSashVisible(wxSASH_TOP, mTop);
81
swin->SetSashVisible(wxSASH_BOTTOM, mBottom);
82
swin->SetSashVisible(wxSASH_LEFT, mLeft);
83
swin->SetSashVisible(wxSASH_RIGHT, mRight);
87
if (mAlign == wxLAYOUT_TOP) swin->SetAlignment(wxLAYOUT_TOP);
88
else if (mAlign == wxLAYOUT_BOTTOM) swin->SetAlignment(wxLAYOUT_BOTTOM);
89
else if (mAlign == wxLAYOUT_LEFT) swin->SetAlignment(wxLAYOUT_LEFT);
90
else if (mAlign == wxLAYOUT_RIGHT) swin->SetAlignment(wxLAYOUT_RIGHT);
94
if (mOrient == wxLAYOUT_HORIZONTAL) swin->SetOrientation(wxLAYOUT_HORIZONTAL);
95
else swin->SetOrientation(wxLAYOUT_VERTICAL);
97
// don't forget the kids
99
AddChildrenPreview(swin, Flags);
106
//------------------------------------------------------------------------------
108
void wxsSashLayoutWindow::OnBuildCreatingCode()
110
switch ( GetLanguage() )
113
AddHeader(_T("<wx/sashwin.h>"),GetInfo().ClassName, 0);
114
AddHeader(_T("<wx/laywin.h>"), GetInfo().ClassName, 0);
116
Codef(_T("%C(%W, %I, %P, %S, %T, %N);\n"));
117
BuildSetupWindowCode();
120
Codef( _T("%ASetSashVisible(wxSASH_TOP, %b);\n"), mTop);
121
Codef( _T("%ASetSashVisible(wxSASH_BOTTOM, %b);\n"), mBottom);
122
Codef( _T("%ASetSashVisible(wxSASH_LEFT, %b);\n"), mLeft);
123
Codef( _T("%ASetSashVisible(wxSASH_RIGHT, %b);\n"), mRight);
125
if (mAlign == wxLAYOUT_TOP) Codef( _T("%ASetAlignment(wxLAYOUT_TOP);\n"));
126
else if (mAlign == wxLAYOUT_BOTTOM) Codef( _T("%ASetAlignment(wxLAYOUT_BOTTOM);\n"));
127
else if (mAlign == wxLAYOUT_LEFT) Codef( _T("%ASetAlignment(wxLAYOUT_LEFT);\n"));
128
else if (mAlign == wxLAYOUT_RIGHT) Codef( _T("%ASetAlignment(wxLAYOUT_RIGHT);\n"));
130
if (mOrient == wxLAYOUT_HORIZONTAL) Codef(_T("%ASetOrientation(wxLAYOUT_HORIZONTAL);\n"));
131
else Codef(_T("%ASetOrientation(wxLAYOUT_VERTICAL);\n"));
136
wxsCodeMarks::Unknown(_T("wxsSashLayoutWindow::OnBuildCreatingCode"),GetLanguage());
140
//------------------------------------------------------------------------------
142
void wxsSashLayoutWindow::OnEnumContainerProperties(long Flags)
144
static const long valign[] = { wxLAYOUT_TOP, wxLAYOUT_LEFT, wxLAYOUT_RIGHT, wxLAYOUT_BOTTOM, 0};
145
static const wxChar *nalign[] = {_T("wxLAYOUT_TOP"), _T("wxLAYOUT_LEFT"), _T("wxLAYOUT_RIGHT"), _T("wxLAYOUT_BOTTOM"), 0};
147
static const long vorient[] = { wxLAYOUT_HORIZONTAL, wxLAYOUT_VERTICAL, 0};
148
static const wxChar *norient[] = {_T("wxLAYOUT_HORIZONTAL"), _T("wxLAYOUT_VERTICAL"), 0};
151
WXS_BOOL(wxsSashLayoutWindow, mTop, _("Drag Top"), _("dragtop"), true);
152
WXS_BOOL(wxsSashLayoutWindow, mBottom, _("Drag Bottom"), _("dragbottom"), true);
153
WXS_BOOL(wxsSashLayoutWindow, mLeft, _("Drag Left"), _("dragleft"), true);
154
WXS_BOOL(wxsSashLayoutWindow, mRight, _("Drag Right"), _("dragright"), true);
156
WXS_ENUM(wxsSashLayoutWindow, mAlign, _("Alignment"), _T("alignment"), valign, nalign, wxLAYOUT_LEFT);
157
WXS_ENUM(wxsSashLayoutWindow, mOrient, _("Orientation"), _T("orientation"), vorient, norient, wxLAYOUT_HORIZONTAL);
161
//------------------------------------------------------------------------------
163
bool wxsSashLayoutWindow::OnCanAddChild(wxsItem* Item,bool ShowMessage)