2
* This file is part of wxSmith plugin for Code::Blocks Studio
3
* Copyright (C) 2006-2007 Bartlomiej Swiecki
5
* wxSmith is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* wxSmith is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
19
* $Id: wxsframe.cpp 8704 2012-12-23 20:32:03Z mortenmacfly $
20
* $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsframe.cpp $
23
#include <wx/app.h> // wxTheApp
25
#include <wx/settings.h> // wxSystemSettings, wxSYS_COLOUR_APPWORKSPACE
27
#include "../wxsgridpanel.h"
31
wxsRegisterItem<wxsFrame> Reg( _T("Frame"), wxsTContainer, _T(""), 0 );
33
WXS_ST_BEGIN(wxsFrameStyles,_T("wxDEFAULT_FRAME_STYLE"))
34
WXS_ST_CATEGORY("wxFrame")
37
WXS_ST(wxDEFAULT_DIALOG_STYLE)
38
WXS_ST(wxDEFAULT_FRAME_STYLE)
40
WXS_ST(wxRESIZE_BORDER)
42
WXS_ST(wxFRAME_NO_TASKBAR)
43
WXS_ST(wxFRAME_SHAPED)
44
WXS_ST(wxFRAME_TOOL_WINDOW)
45
WXS_ST(wxFRAME_FLOAT_ON_PARENT)
46
WXS_ST(wxMAXIMIZE_BOX)
47
WXS_ST(wxMINIMIZE_BOX)
49
WXS_ST(wxTAB_TRAVERSAL)
50
WXS_EXST(wxFRAME_EX_METAL)
51
WXS_EXST(wxFRAME_EX_CONTEXTHELP)
55
WXS_EV_BEGIN(wxsFrameEvents)
56
WXS_EVI(EVT_CLOSE,wxEVT_CLOSE_WINDOW,wxCloseEvent,Close)
62
wxsFrame::wxsFrame(wxsItemResData* Data):
72
void wxsFrame::OnBuildCreatingCode()
74
switch ( GetLanguage() )
78
AddHeader(_T("<wx/frame.h>"),GetInfo().ClassName,hfInPCH);
79
Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str());
80
if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) )
82
Codef(_T("%ASetClientSize(%S);\n"));
84
if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
86
Codef(_T("%AMove(%P);\n"));
88
BuildSetupWindowCode();
89
if ( !Icon.IsEmpty() )
91
AddHeader(_T("<wx/icon.h>"), GetInfo().ClassName, hfLocal);
94
_T("\twxIcon FrameIcon;\n")
95
_T("\tFrameIcon.CopyFromBitmap(%i);\n")
96
_T("\t%ASetIcon(FrameIcon);\n")
98
&Icon,_T("wxART_FRAME_ICON"));
104
Codef(_T("%ACenter();\n"));
110
case wxsUnknownLanguage: // fall-through
113
wxsCodeMarks::Unknown(_T("wxsFrame::OnBuildCreatingCode"),GetLanguage());
118
wxObject* wxsFrame::OnBuildPreview(wxWindow* Parent,long Flags)
120
wxWindow* NewItem = 0;
123
// In case of frame and dialog when in "Exact" mode, we do not create
124
// new object, but use Parent and call Create for it.
125
if ( Flags & pfExact )
127
Frm = wxDynamicCast(Parent,wxFrame);
130
Frm->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style());
131
Frm->SetClientSize(Size(wxTheApp->GetTopWindow()));
132
Frm->Move(Pos(wxTheApp->GetTopWindow()));
135
SetupWindow(NewItem,Flags);
136
if ( !Icon.IsEmpty() )
139
FrameIcon.CopyFromBitmap(Icon.GetPreview(wxDefaultSize,_T("wxART_FRAME_ICON")));
140
Frm->SetIcon(FrameIcon);
143
AddChildrenPreview(NewItem,Flags);
152
NewItem = new wxsGridPanel(Parent,GetId(),wxDefaultPosition,Size(Parent),0);
153
NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
154
SetupWindow(NewItem,Flags);
155
AddChildrenPreview(NewItem,Flags);
157
// wxPanel tends to behave very strange when it has children and no sizer,
158
// we have to manually resize it's content
159
if ( !GetChildCount() || GetChild(0)->GetType()!=wxsTSizer )
161
wxSize NewSize = Size(Parent);
162
if ( !NewSize.IsFullySpecified() )
164
NewSize.SetDefaults(wxSize(400,450));
166
NewItem->SetSize(NewSize);
167
#if wxCHECK_VERSION(2,8,0)
168
NewItem->SetInitialSize(NewSize);
170
NewItem->SetBestFittingSize(NewSize);
172
if ( GetChildCount() == 1 )
174
// If there's only one child it's size gets dialog's size
175
wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow);
178
ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight());
187
void wxsFrame::OnEnumContainerProperties(long Flags)
189
WXS_SHORT_STRING(wxsFrame,Title,_("Title"),_T("title"),_T(""),false)
190
WXS_BOOL(wxsFrame,Centered,_("Centered"),_T("centered"),false);
191
WXS_ICON(wxsFrame,Icon,_T("Icon"),_T("icon"),_T("wxART_FRAME_ICON"));