~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsdialog.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of wxSmith plugin for Code::Blocks Studio
 
3
* Copyright (C) 2006-2007  Bartlomiej Swiecki
 
4
*
 
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.
 
9
*
 
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.
 
14
*
 
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/>.
 
17
*
 
18
* $Revision: 8704 $
 
19
* $Id: wxsdialog.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/wxsdialog.cpp $
 
21
*/
 
22
 
 
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"
 
28
 
 
29
namespace
 
30
{
 
31
    wxsRegisterItem<wxsDialog> Reg( _T("Dialog"), wxsTContainer, _T(""), 0 );
 
32
 
 
33
    WXS_ST_BEGIN(wxsDialogStyles,_T("wxDEFAULT_DIALOG_STYLE"))
 
34
        WXS_ST_CATEGORY("wxDialog")
 
35
        WXS_ST(wxSTAY_ON_TOP)
 
36
        WXS_ST(wxCAPTION)
 
37
        WXS_ST(wxDEFAULT_DIALOG_STYLE)
 
38
        WXS_ST(wxSYSTEM_MENU)
 
39
        WXS_ST(wxRESIZE_BORDER)
 
40
        WXS_ST(wxCLOSE_BOX)
 
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)
 
48
        WXS_ST_DEFAULTS()
 
49
    WXS_ST_END()
 
50
 
 
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)
 
54
        WXS_EV_DEFAULTS()
 
55
    WXS_EV_END()
 
56
}
 
57
 
 
58
wxsDialog::wxsDialog(wxsItemResData* Data):
 
59
    wxsContainer(
 
60
        Data,
 
61
        &Reg.Info,
 
62
        wxsDialogEvents,
 
63
        wxsDialogStyles),
 
64
    Title(_("Dialog")),
 
65
    Centered(true)
 
66
{}
 
67
 
 
68
void wxsDialog::OnBuildCreatingCode()
 
69
{
 
70
    switch ( GetLanguage() )
 
71
    {
 
72
        case wxsCPP:
 
73
        {
 
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) )
 
77
            {
 
78
                Codef(_T("%ASetClientSize(%S);\n"));
 
79
            }
 
80
            if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
 
81
            {
 
82
                Codef(_T("%AMove(%P);\n"));
 
83
            }
 
84
            BuildSetupWindowCode();
 
85
            AddChildrenCode();
 
86
            if ( Centered )
 
87
            {
 
88
                Codef(_T("%ACenter();\n"));
 
89
            }
 
90
 
 
91
            return;
 
92
        }
 
93
 
 
94
        case wxsUnknownLanguage: // fall-through
 
95
        default:
 
96
        {
 
97
            wxsCodeMarks::Unknown(_T("wxsDialog::OnBuildCreatingCode"),GetLanguage());
 
98
        }
 
99
    }
 
100
}
 
101
 
 
102
wxObject* wxsDialog::OnBuildPreview(wxWindow* Parent,long Flags)
 
103
{
 
104
    wxWindow* NewItem = 0;
 
105
    wxDialog* Dlg = 0;
 
106
 
 
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 )
 
110
    {
 
111
        Dlg = wxDynamicCast(Parent,wxDialog);
 
112
        if ( Dlg )
 
113
        {
 
114
            Dlg->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style());
 
115
            Dlg->SetClientSize(Size(wxTheApp->GetTopWindow()));
 
116
            Dlg->Move(Pos(wxTheApp->GetTopWindow()));
 
117
        }
 
118
        NewItem = Dlg;
 
119
        SetupWindow(NewItem,Flags);
 
120
        AddChildrenPreview(NewItem,Flags);
 
121
        if ( Centered )
 
122
        {
 
123
            Dlg->Centre();
 
124
        }
 
125
    }
 
126
    else
 
127
    {
 
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);
 
132
 
 
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 )
 
136
        {
 
137
            wxSize NewSize = Size(Parent);
 
138
            if ( !NewSize.IsFullySpecified() )
 
139
            {
 
140
                NewSize.SetDefaults(wxSize(400,450));
 
141
                NewItem->SetSize(NewSize);
 
142
                #if wxCHECK_VERSION(2,8,0)
 
143
                    NewItem->SetInitialSize(NewSize);
 
144
                #else
 
145
                    NewItem->SetBestFittingSize(NewSize);
 
146
                #endif
 
147
                if ( GetChildCount() == 1 )
 
148
                {
 
149
                    // If there's only one child it's size gets dialog's size
 
150
                    wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow);
 
151
                    if ( ChildPreview )
 
152
                    {
 
153
                        ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight());
 
154
                    }
 
155
                }
 
156
            }
 
157
            else
 
158
            {
 
159
                NewItem->SetSize(NewSize);
 
160
                #if wxCHECK_VERSION(2,8,0)
 
161
                    NewItem->SetInitialSize(NewSize);
 
162
                #else
 
163
                    NewItem->SetBestFittingSize(NewSize);
 
164
                #endif
 
165
            }
 
166
        }
 
167
    }
 
168
 
 
169
    return NewItem;
 
170
}
 
171
 
 
172
void wxsDialog::OnEnumContainerProperties(long Flags)
 
173
{
 
174
    WXS_SHORT_STRING(wxsDialog,Title,_("Title"),_T("title"),_T(""),false)
 
175
    WXS_BOOL(wxsDialog,Centered,_("Centered"),_T("centered"),false);
 
176
}