]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/toplevel.cpp
moved primitive string and string iterators operations to stringops.h/cpp files to...
[wxWidgets.git] / src / dfb / toplevel.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/toplevel.cpp
3// Purpose: Top level window, abstraction of wxFrame and wxDialog
4// Author: Vaclav Slavik
5// Created: 2006-08-10
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#include "wx/toplevel.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/app.h"
b3c86150
VS
18#endif // WX_PRECOMP
19
b3c86150
VS
20#include "wx/dfb/private.h"
21
b3c86150
VS
22// ============================================================================
23// wxTopLevelWindowDFB
24// ============================================================================
25
26// ----------------------------------------------------------------------------
27// creation & destruction
28// ----------------------------------------------------------------------------
29
30void wxTopLevelWindowDFB::Init()
31{
b3c86150
VS
32 m_isMaximized = false;
33 m_fsIsShowing = false;
b3c86150
VS
34}
35
36bool wxTopLevelWindowDFB::Create(wxWindow *parent,
37 wxWindowID id,
38 const wxString& title,
39 const wxPoint& posOrig,
40 const wxSize& sizeOrig,
41 long style,
42 const wxString &name)
43{
b3c86150
VS
44 // always create a frame of some reasonable, even if arbitrary, size (at
45 // least for MSW compatibility)
46 wxSize size(sizeOrig);
47 if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord )
48 {
49 wxSize sizeDefault = GetDefaultSize();
50 if ( size.x == wxDefaultCoord )
51 size.x = sizeDefault.x;
52 if ( size.y == wxDefaultCoord )
53 size.y = sizeDefault.y;
54 }
55
56 wxPoint pos(posOrig);
57 if ( pos.x == wxDefaultCoord )
58 pos.x = 0;
59 if ( pos.y == wxDefaultCoord )
60 pos.y = 0;
61
42b0d8b9 62 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
b3c86150 63 return false;
b3c86150
VS
64
65 wxTopLevelWindows.Append(this);
66 m_title = title;
67
b3c86150
VS
68 return true;
69}
70
b3c86150
VS
71// ----------------------------------------------------------------------------
72// showing and hiding
73// ----------------------------------------------------------------------------
74
75#warning "FIXME: the rest of this file is almost same as for MGL, merge it"
76bool wxTopLevelWindowDFB::ShowFullScreen(bool show, long style)
77{
42b0d8b9
VS
78 if ( show == m_fsIsShowing )
79 return true;
b3c86150
VS
80
81 m_fsIsShowing = show;
82
83 if (show)
84 {
85 m_fsSaveStyle = m_windowStyle;
86 m_fsSaveFlag = style;
87 GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
88 GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
89
90 if ( style & wxFULLSCREEN_NOCAPTION )
91 m_windowStyle &= ~wxCAPTION;
92 if ( style & wxFULLSCREEN_NOBORDER )
93 m_windowStyle = wxSIMPLE_BORDER;
94
95 int x, y;
96 wxDisplaySize(&x, &y);
97 SetSize(0, 0, x, y);
98 }
99 else
100 {
101 m_windowStyle = m_fsSaveStyle;
102 SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
103 m_fsSaveFrame.width, m_fsSaveFrame.height);
104 }
105
106 return true;
107}
108
b3c86150
VS
109bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha)
110{
111 if ( IsShown() )
112 {
52c8d32a 113 if ( !m_dfbwin->SetOpacity(alpha) )
b3c86150
VS
114 return false;
115 }
116
117 m_opacity = alpha;
118 return true;
119}
120
121// ----------------------------------------------------------------------------
122// maximize, minimize etc.
123// ----------------------------------------------------------------------------
124
125void wxTopLevelWindowDFB::Maximize(bool maximize)
126{
127 int x, y, w, h;
128 wxClientDisplayRect(&x, &y, &w, &h);
129
130 if ( maximize && !m_isMaximized )
131 {
132 m_isMaximized = true;
133
134 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
135 GetSize(&m_savedFrame.width, &m_savedFrame.height);
136
137 SetSize(x, y, w, h);
138 }
139 else if ( !maximize && m_isMaximized )
140 {
141 m_isMaximized = false;
142 SetSize(m_savedFrame.x, m_savedFrame.y,
143 m_savedFrame.width, m_savedFrame.height);
144 }
145}
146
147bool wxTopLevelWindowDFB::IsMaximized() const
148{
149 return m_isMaximized;
150}
151
152void wxTopLevelWindowDFB::Restore()
153{
154 if ( IsMaximized() )
155 {
156 Maximize(false);
157 }
158}
159
160void wxTopLevelWindowDFB::Iconize(bool WXUNUSED(iconize))
161{
162 wxFAIL_MSG(wxT("Iconize not supported under wxDFB"));
163}
164
165bool wxTopLevelWindowDFB::IsIconized() const
166{
167 return false;
168}