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: wxsdialog.cpp 8704 2012-12-23 20:32:03Z mortenmacfly $
20
* $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsdialog.cpp $
23
#include <wx/app.h> // wxTheApp
24
#include <wx/frame.h> // wxFRAME_SHAPED
25
#include <wx/settings.h> // wxSystemSettings, wxSYS_COLOUR_BTNFACE
26
#include "wxsdialog.h"
27
#include "../wxsgridpanel.h"
31
wxsRegisterItem<wxsDialog> Reg( _T("Dialog"), wxsTContainer, _T(""), 0 );
33
WXS_ST_BEGIN(wxsDialogStyles,_T("wxDEFAULT_DIALOG_STYLE"))
34
WXS_ST_CATEGORY("wxDialog")
37
WXS_ST(wxDEFAULT_DIALOG_STYLE)
39
WXS_ST(wxRESIZE_BORDER)
41
WXS_ST(wxDIALOG_NO_PARENT)
42
WXS_ST(wxTAB_TRAVERSAL)
43
WXS_ST(wxMAXIMIZE_BOX)
44
WXS_ST(wxMINIMIZE_BOX)
45
WXS_ST(wxFRAME_SHAPED)
46
WXS_EXST(wxDIALOG_EX_CONTEXTHELP)
47
WXS_EXST(wxDIALOG_EX_METAL)
51
WXS_EV_BEGIN(wxsDialogEvents)
52
WXS_EVI(EVT_INIT_DIALOG,wxEVT_INIT_DIALOG,wxInitDialogEvent,Init)
53
WXS_EVI(EVT_CLOSE,wxEVT_CLOSE_WINDOW,wxCloseEvent,Close)
58
wxsDialog::wxsDialog(wxsItemResData* Data):
68
void wxsDialog::OnBuildCreatingCode()
70
switch ( GetLanguage() )
74
AddHeader(_T("<wx/dialog.h>"),GetInfo().ClassName,hfInPCH);
75
Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str());
76
if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) )
78
Codef(_T("%ASetClientSize(%S);\n"));
80
if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
82
Codef(_T("%AMove(%P);\n"));
84
BuildSetupWindowCode();
88
Codef(_T("%ACenter();\n"));
94
case wxsUnknownLanguage: // fall-through
97
wxsCodeMarks::Unknown(_T("wxsDialog::OnBuildCreatingCode"),GetLanguage());
102
wxObject* wxsDialog::OnBuildPreview(wxWindow* Parent,long Flags)
104
wxWindow* NewItem = 0;
107
// In case of frame and dialog when in "Exact" mode, we do not create
108
// new object, but use Parent and call Create for it.
109
if ( Flags & pfExact )
111
Dlg = wxDynamicCast(Parent,wxDialog);
114
Dlg->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style());
115
Dlg->SetClientSize(Size(wxTheApp->GetTopWindow()));
116
Dlg->Move(Pos(wxTheApp->GetTopWindow()));
119
SetupWindow(NewItem,Flags);
120
AddChildrenPreview(NewItem,Flags);
128
NewItem = new wxsGridPanel(Parent,GetId(),wxPoint(0,0),Size(Parent),0);
129
NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
130
SetupWindow(NewItem,Flags);
131
AddChildrenPreview(NewItem,Flags);
133
// wxPanel tends to behave very strange when it has children and no sizer,
134
// we have to manually resize it's content
135
if ( !GetChildCount() || GetChild(0)->GetType()!=wxsTSizer )
137
wxSize NewSize = Size(Parent);
138
if ( !NewSize.IsFullySpecified() )
140
NewSize.SetDefaults(wxSize(400,450));
141
NewItem->SetSize(NewSize);
142
#if wxCHECK_VERSION(2,8,0)
143
NewItem->SetInitialSize(NewSize);
145
NewItem->SetBestFittingSize(NewSize);
147
if ( GetChildCount() == 1 )
149
// If there's only one child it's size gets dialog's size
150
wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow);
153
ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight());
159
NewItem->SetSize(NewSize);
160
#if wxCHECK_VERSION(2,8,0)
161
NewItem->SetInitialSize(NewSize);
163
NewItem->SetBestFittingSize(NewSize);
172
void wxsDialog::OnEnumContainerProperties(long Flags)
174
WXS_SHORT_STRING(wxsDialog,Title,_("Title"),_T("title"),_T(""),false)
175
WXS_BOOL(wxsDialog,Centered,_("Centered"),_T("centered"),false);