]>
git.saurik.com Git - wxWidgets.git/blob - 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
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #include "wx/toplevel.h"
20 #include "wx/dfb/private.h"
22 #define TRACE_EVENTS "events"
24 // ============================================================================
25 // wxTopLevelWindowDFB
26 // ============================================================================
28 // ----------------------------------------------------------------------------
29 // creation & destruction
30 // ----------------------------------------------------------------------------
32 void wxTopLevelWindowDFB::Init()
34 m_isMaximized
= false;
35 m_fsIsShowing
= false;
38 bool wxTopLevelWindowDFB::Create(wxWindow
*parent
,
40 const wxString
& title
,
41 const wxPoint
& posOrig
,
42 const wxSize
& sizeOrig
,
46 // always create a frame of some reasonable, even if arbitrary, size (at
47 // least for MSW compatibility)
48 wxSize
size(sizeOrig
);
49 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
51 wxSize sizeDefault
= GetDefaultSize();
52 if ( size
.x
== wxDefaultCoord
)
53 size
.x
= sizeDefault
.x
;
54 if ( size
.y
== wxDefaultCoord
)
55 size
.y
= sizeDefault
.y
;
59 if ( pos
.x
== wxDefaultCoord
)
61 if ( pos
.y
== wxDefaultCoord
)
64 if ( !wxNonOwnedWindow::Create(parent
, id
, pos
, size
, style
, name
) )
67 wxTopLevelWindows
.Append(this);
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 #warning "FIXME: the rest of this file is almost same as for MGL, merge it"
78 bool wxTopLevelWindowDFB::ShowFullScreen(bool show
, long style
)
80 if ( show
== m_fsIsShowing
)
87 m_fsSaveStyle
= m_windowStyle
;
89 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
90 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
92 if ( style
& wxFULLSCREEN_NOCAPTION
)
93 m_windowStyle
&= ~wxCAPTION
;
94 if ( style
& wxFULLSCREEN_NOBORDER
)
95 m_windowStyle
= wxSIMPLE_BORDER
;
98 wxDisplaySize(&x
, &y
);
103 m_windowStyle
= m_fsSaveStyle
;
104 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
105 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
111 bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha
)
115 if ( !m_dfbwin
->SetOpacity(alpha
) )
123 // ----------------------------------------------------------------------------
124 // maximize, minimize etc.
125 // ----------------------------------------------------------------------------
127 void wxTopLevelWindowDFB::Maximize(bool maximize
)
130 wxClientDisplayRect(&x
, &y
, &w
, &h
);
132 if ( maximize
&& !m_isMaximized
)
134 m_isMaximized
= true;
136 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
137 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
141 else if ( !maximize
&& m_isMaximized
)
143 m_isMaximized
= false;
144 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
145 m_savedFrame
.width
, m_savedFrame
.height
);
149 bool wxTopLevelWindowDFB::IsMaximized() const
151 return m_isMaximized
;
154 void wxTopLevelWindowDFB::Restore()
162 void wxTopLevelWindowDFB::Iconize(bool WXUNUSED(iconize
))
164 wxFAIL_MSG(wxT("Iconize not supported under wxDFB"));
167 bool wxTopLevelWindowDFB::IsIconized() const
172 // ----------------------------------------------------------------------------
174 // ----------------------------------------------------------------------------
176 void wxTopLevelWindowDFB::HandleFocusEvent(const wxDFBWindowEvent
& event_
)
178 const DFBWindowEvent
& dfbevent
= event_
;
179 const bool activate
= (dfbevent
.type
== DWET_GOTFOCUS
);
181 wxLogTrace(TRACE_EVENTS
,
182 "toplevel window %p ('%s') %s focus",
184 activate
? "got" : "lost");
186 wxActivateEvent
event(wxEVT_ACTIVATE
, activate
, GetId());
187 event
.SetEventObject(this);
188 HandleWindowEvent(event
);
190 // if a frame that doesn't have wx focus inside it just got focus, we
191 // need to set focus to it (or its child):
194 wxWindow
*focused
= wxWindow::FindFocus();
195 if ( !focused
|| focused
->GetTLW() != this )
197 wxLogTrace(TRACE_EVENTS
,
198 "setting wx focus to toplevel window %p ('%s')",
201 if ( CanAcceptFocus() )
204 wxLogTrace(TRACE_EVENTS
, "...which doesn't accept it");