]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/toplevel.cpp
implement event loop for console applications (heavily modified patch 1715735)
[wxWidgets.git] / src / dfb / toplevel.cpp
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"
18 #endif // WX_PRECOMP
19
20 #include "wx/dfb/private.h"
21
22 // ============================================================================
23 // wxTopLevelWindowDFB
24 // ============================================================================
25
26 // ----------------------------------------------------------------------------
27 // creation & destruction
28 // ----------------------------------------------------------------------------
29
30 void wxTopLevelWindowDFB::Init()
31 {
32 m_isMaximized = false;
33 m_fsIsShowing = false;
34 }
35
36 bool 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 {
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
62 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
63 return false;
64
65 wxTopLevelWindows.Append(this);
66 m_title = title;
67
68 return true;
69 }
70
71 // ----------------------------------------------------------------------------
72 // showing and hiding
73 // ----------------------------------------------------------------------------
74
75 #warning "FIXME: the rest of this file is almost same as for MGL, merge it"
76 bool wxTopLevelWindowDFB::ShowFullScreen(bool show, long style)
77 {
78 if ( show == m_fsIsShowing )
79 return true;
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
109 bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha)
110 {
111 if ( IsShown() )
112 {
113 if ( !m_dfbwin->SetOpacity(alpha) )
114 return false;
115 }
116
117 m_opacity = alpha;
118 return true;
119 }
120
121 // ----------------------------------------------------------------------------
122 // maximize, minimize etc.
123 // ----------------------------------------------------------------------------
124
125 void 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
147 bool wxTopLevelWindowDFB::IsMaximized() const
148 {
149 return m_isMaximized;
150 }
151
152 void wxTopLevelWindowDFB::Restore()
153 {
154 if ( IsMaximized() )
155 {
156 Maximize(false);
157 }
158 }
159
160 void wxTopLevelWindowDFB::Iconize(bool WXUNUSED(iconize))
161 {
162 wxFAIL_MSG(wxT("Iconize not supported under wxDFB"));
163 }
164
165 bool wxTopLevelWindowDFB::IsIconized() const
166 {
167 return false;
168 }