]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/app.cpp
removed stray return from SetFont()
[wxWidgets.git] / src / dfb / app.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/app.cpp
3// Purpose: wxApp implementation
4// Author: Vaclav Slavik
5// based on MGL implementation
6// Created: 2006-08-16
7// RCS-ID: $Id$
8// Copyright: (c) 2006 REA Elektronik GmbH
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#include "wx/app.h"
20
21#include "wx/evtloop.h"
22#include "wx/dfb/private.h"
d7ae4a62 23#include "wx/private/fontmgr.h"
b3c86150
VS
24
25//-----------------------------------------------------------------------------
26// wxApp initialization
27//-----------------------------------------------------------------------------
28
29IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
30
31BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
32 EVT_IDLE(wxAppBase::OnIdle)
33END_EVENT_TABLE()
34
35wxApp::wxApp()
36{
37}
38
39wxApp::~wxApp()
40{
41}
42
b3c86150
VS
43bool wxApp::Initialize(int& argc, wxChar **argv)
44{
45 if ( !wxAppBase::Initialize(argc, argv) )
46 return false;
47
52c8d32a 48 if ( !wxDfbCheckReturn(DirectFBInit(&argc, &argv)) )
b3c86150
VS
49 return false;
50
52c8d32a 51 if ( !wxIDirectFB::Get() )
b3c86150
VS
52 return false;
53
b3c86150
VS
54 return true;
55}
56
57void wxApp::CleanUp()
58{
59 wxAppBase::CleanUp();
60
d7ae4a62
VS
61 wxFontsManager::CleanUp();
62
e48a3055 63 wxEventLoop::CleanUp();
52c8d32a 64 wxIDirectFB::CleanUp();
b3c86150
VS
65}
66
67//-----------------------------------------------------------------------------
68// display mode
69//-----------------------------------------------------------------------------
70
71static wxVideoMode GetCurrentVideoMode()
72{
fa28b00c
VS
73 wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
74 if ( !layer )
75 return wxVideoMode(); // invalid
b3c86150 76
fa28b00c 77 return layer->GetVideoMode();
b3c86150
VS
78}
79
80wxVideoMode wxApp::GetDisplayMode() const
81{
82 if ( !m_videoMode.IsOk() )
83 wxConstCast(this, wxApp)->m_videoMode = GetCurrentVideoMode();
84
85 return m_videoMode;
86}
87
88bool wxApp::SetDisplayMode(const wxVideoMode& mode)
89{
52c8d32a 90 if ( !wxIDirectFB::Get()->SetVideoMode(mode.w, mode.h, mode.bpp) )
b3c86150
VS
91 return false;
92
93 m_videoMode = mode;
94 return true;
95}
96
97//-----------------------------------------------------------------------------
98// events processing related
99//-----------------------------------------------------------------------------
100
101void wxApp::WakeUpIdle()
102{
103#if wxUSE_THREADS
104 if (!wxThread::IsMain())
105 wxMutexGuiEnter();
106#endif
107
655c20fc
VS
108 wxEventLoop * const loop = wxEventLoop::GetActive();
109 if ( loop )
110 loop->WakeUp();
b3c86150
VS
111
112#if wxUSE_THREADS
113 if (!wxThread::IsMain())
114 wxMutexGuiLeave();
115#endif
116}
117
118
119bool wxApp::Yield(bool onlyIfNeeded)
120{
121#if wxUSE_THREADS
122 if ( !wxThread::IsMain() )
123 return true; // can't process events from other threads
124#endif // wxUSE_THREADS
125
126 static bool s_inYield = false;
127
128 if ( s_inYield )
129 {
130 if ( !onlyIfNeeded )
131 {
132 wxFAIL_MSG( wxT("wxYield called recursively" ) );
133 }
134
135 return false;
136 }
137
138 s_inYield = true;
139
140 wxLog::Suspend();
141
655c20fc
VS
142 wxEventLoop * const loop = wxEventLoop::GetActive();
143 if ( loop )
144 loop->Yield();
b3c86150
VS
145
146 // it's necessary to call ProcessIdle() to update the frames sizes which
147 // might have been changed (it also will update other things set from
148 // OnUpdateUI() which is a nice (and desired) side effect)
149 while ( ProcessIdle() ) {}
150
151 wxLog::Resume();
152
153 s_inYield = false;
154
155 return true;
156}