]>
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
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #include "wx/toplevel.h"
19 #include "wx/dfb/private.h"
21 #define TRACE_EVENTS "events"
23 // ============================================================================
24 // wxTopLevelWindowDFB
25 // ============================================================================
27 // ----------------------------------------------------------------------------
28 // creation & destruction
29 // ----------------------------------------------------------------------------
31 void wxTopLevelWindowDFB::Init()
33 m_isMaximized
= false;
34 m_fsIsShowing
= false;
37 bool wxTopLevelWindowDFB::Create(wxWindow
*parent
,
39 const wxString
& title
,
40 const wxPoint
& posOrig
,
41 const wxSize
& sizeOrig
,
45 // always create a frame of some reasonable, even if arbitrary, size (at
46 // least for MSW compatibility)
47 wxSize
size(sizeOrig
);
48 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
50 wxSize sizeDefault
= GetDefaultSize();
51 if ( size
.x
== wxDefaultCoord
)
52 size
.x
= sizeDefault
.x
;
53 if ( size
.y
== wxDefaultCoord
)
54 size
.y
= sizeDefault
.y
;
58 if ( pos
.x
== wxDefaultCoord
)
60 if ( pos
.y
== wxDefaultCoord
)
63 if ( !wxNonOwnedWindow::Create(parent
, id
, pos
, size
, style
, name
) )
66 wxTopLevelWindows
.Append(this);
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 bool wxTopLevelWindowDFB::ShowFullScreen(bool show
, long style
)
78 if ( show
== m_fsIsShowing
)
85 m_fsSaveStyle
= m_windowStyle
;
87 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
88 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
90 if ( style
& wxFULLSCREEN_NOCAPTION
)
91 m_windowStyle
&= ~wxCAPTION
;
92 if ( style
& wxFULLSCREEN_NOBORDER
)
93 m_windowStyle
= wxSIMPLE_BORDER
;
96 wxDisplaySize(&x
, &y
);
101 m_windowStyle
= m_fsSaveStyle
;
102 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
103 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
109 bool wxTopLevelWindowDFB::SetTransparent(wxByte alpha
)
113 if ( !m_dfbwin
->SetOpacity(alpha
) )
121 // ----------------------------------------------------------------------------
122 // maximize, minimize etc.
123 // ----------------------------------------------------------------------------
125 void wxTopLevelWindowDFB::Maximize(bool maximize
)
128 wxClientDisplayRect(&x
, &y
, &w
, &h
);
130 if ( maximize
&& !m_isMaximized
)
132 m_isMaximized
= true;
134 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
135 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
139 else if ( !maximize
&& m_isMaximized
)
141 m_isMaximized
= false;
142 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
143 m_savedFrame
.width
, m_savedFrame
.height
);
147 bool wxTopLevelWindowDFB::IsMaximized() const
149 return m_isMaximized
;
152 void wxTopLevelWindowDFB::Restore()
160 void wxTopLevelWindowDFB::Iconize(bool WXUNUSED(iconize
))
162 wxFAIL_MSG(wxT("Iconize not supported under wxDFB"));
165 bool wxTopLevelWindowDFB::IsIconized() const
170 // ----------------------------------------------------------------------------
172 // ----------------------------------------------------------------------------
174 void wxTopLevelWindowDFB::HandleFocusEvent(const wxDFBWindowEvent
& event_
)
176 const DFBWindowEvent
& dfbevent
= event_
;
177 const bool activate
= (dfbevent
.type
== DWET_GOTFOCUS
);
179 wxLogTrace(TRACE_EVENTS
,
180 "toplevel window %p ('%s') %s focus",
182 activate
? "got" : "lost");
184 wxActivateEvent
event(wxEVT_ACTIVATE
, activate
, GetId());
185 event
.SetEventObject(this);
186 HandleWindowEvent(event
);
188 // if a frame that doesn't have wx focus inside it just got focus, we
189 // need to set focus to it (or its child):
192 wxWindow
*focused
= wxWindow::FindFocus();
193 if ( !focused
|| focused
->GetTLW() != this )
195 wxLogTrace(TRACE_EVENTS
,
196 "setting wx focus to toplevel window %p ('%s')",
199 if ( CanAcceptFocus() )
202 wxLogTrace(TRACE_EVENTS
, "...which doesn't accept it");