~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsframe.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: 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 $
 
21
*/
 
22
 
 
23
#include <wx/app.h>        // wxTheApp
 
24
#include <wx/frame.h>
 
25
#include <wx/settings.h> // wxSystemSettings, wxSYS_COLOUR_APPWORKSPACE
 
26
#include "wxsframe.h"
 
27
#include "../wxsgridpanel.h"
 
28
 
 
29
namespace
 
30
{
 
31
    wxsRegisterItem<wxsFrame> Reg( _T("Frame"), wxsTContainer, _T(""), 0 );
 
32
 
 
33
    WXS_ST_BEGIN(wxsFrameStyles,_T("wxDEFAULT_FRAME_STYLE"))
 
34
        WXS_ST_CATEGORY("wxFrame")
 
35
        WXS_ST(wxSTAY_ON_TOP)
 
36
        WXS_ST(wxCAPTION)
 
37
        WXS_ST(wxDEFAULT_DIALOG_STYLE)
 
38
        WXS_ST(wxDEFAULT_FRAME_STYLE)
 
39
        WXS_ST(wxSYSTEM_MENU)
 
40
        WXS_ST(wxRESIZE_BORDER)
 
41
        WXS_ST(wxCLOSE_BOX)
 
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)
 
48
        WXS_ST(wxSTAY_ON_TOP)
 
49
        WXS_ST(wxTAB_TRAVERSAL)
 
50
        WXS_EXST(wxFRAME_EX_METAL)
 
51
        WXS_EXST(wxFRAME_EX_CONTEXTHELP)
 
52
        WXS_ST_DEFAULTS()
 
53
    WXS_ST_END()
 
54
 
 
55
    WXS_EV_BEGIN(wxsFrameEvents)
 
56
        WXS_EVI(EVT_CLOSE,wxEVT_CLOSE_WINDOW,wxCloseEvent,Close)
 
57
        WXS_EV_DEFAULTS()
 
58
    WXS_EV_END()
 
59
 
 
60
}
 
61
 
 
62
wxsFrame::wxsFrame(wxsItemResData* Data):
 
63
    wxsContainer(
 
64
        Data,
 
65
        &Reg.Info,
 
66
        wxsFrameEvents,
 
67
        wxsFrameStyles),
 
68
    Title(_("Frame")),
 
69
    Centered(false)
 
70
{}
 
71
 
 
72
void wxsFrame::OnBuildCreatingCode()
 
73
{
 
74
    switch ( GetLanguage() )
 
75
    {
 
76
        case wxsCPP:
 
77
        {
 
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) )
 
81
            {
 
82
                Codef(_T("%ASetClientSize(%S);\n"));
 
83
            }
 
84
            if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
 
85
            {
 
86
                Codef(_T("%AMove(%P);\n"));
 
87
            }
 
88
            BuildSetupWindowCode();
 
89
            if ( !Icon.IsEmpty() )
 
90
            {
 
91
                AddHeader(_T("<wx/icon.h>"), GetInfo().ClassName, hfLocal);
 
92
                Codef(
 
93
                    _T("{\n")
 
94
                    _T("\twxIcon FrameIcon;\n")
 
95
                    _T("\tFrameIcon.CopyFromBitmap(%i);\n")
 
96
                    _T("\t%ASetIcon(FrameIcon);\n")
 
97
                    _T("}\n"),
 
98
                        &Icon,_T("wxART_FRAME_ICON"));
 
99
            }
 
100
 
 
101
            AddChildrenCode();
 
102
            if ( Centered )
 
103
            {
 
104
                Codef(_T("%ACenter();\n"));
 
105
            }
 
106
 
 
107
            return;
 
108
        }
 
109
 
 
110
        case wxsUnknownLanguage: // fall-through
 
111
        default:
 
112
        {
 
113
            wxsCodeMarks::Unknown(_T("wxsFrame::OnBuildCreatingCode"),GetLanguage());
 
114
        }
 
115
    }
 
116
}
 
117
 
 
118
wxObject* wxsFrame::OnBuildPreview(wxWindow* Parent,long Flags)
 
119
{
 
120
    wxWindow* NewItem = 0;
 
121
    wxFrame* Frm = 0;
 
122
 
 
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 )
 
126
    {
 
127
        Frm = wxDynamicCast(Parent,wxFrame);
 
128
        if ( Frm )
 
129
        {
 
130
            Frm->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style());
 
131
            Frm->SetClientSize(Size(wxTheApp->GetTopWindow()));
 
132
            Frm->Move(Pos(wxTheApp->GetTopWindow()));
 
133
        }
 
134
        NewItem = Frm;
 
135
        SetupWindow(NewItem,Flags);
 
136
        if ( !Icon.IsEmpty() )
 
137
        {
 
138
            wxIcon FrameIcon;
 
139
            FrameIcon.CopyFromBitmap(Icon.GetPreview(wxDefaultSize,_T("wxART_FRAME_ICON")));
 
140
            Frm->SetIcon(FrameIcon);
 
141
        }
 
142
 
 
143
        AddChildrenPreview(NewItem,Flags);
 
144
        if ( Centered )
 
145
        {
 
146
            Frm->Centre();
 
147
        }
 
148
 
 
149
    }
 
150
    else
 
151
    {
 
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);
 
156
 
 
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 )
 
160
        {
 
161
            wxSize NewSize = Size(Parent);
 
162
            if ( !NewSize.IsFullySpecified() )
 
163
            {
 
164
                NewSize.SetDefaults(wxSize(400,450));
 
165
            }
 
166
            NewItem->SetSize(NewSize);
 
167
            #if wxCHECK_VERSION(2,8,0)
 
168
                NewItem->SetInitialSize(NewSize);
 
169
            #else
 
170
                NewItem->SetBestFittingSize(NewSize);
 
171
            #endif
 
172
            if ( GetChildCount() == 1 )
 
173
            {
 
174
                // If there's only one child it's size gets dialog's size
 
175
                wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow);
 
176
                if ( ChildPreview )
 
177
                {
 
178
                    ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight());
 
179
                }
 
180
            }
 
181
        }
 
182
    }
 
183
 
 
184
    return NewItem;
 
185
}
 
186
 
 
187
void wxsFrame::OnEnumContainerProperties(long Flags)
 
188
{
 
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"));
 
192
}