1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/app.cpp
3 // Purpose: wxApp implementation
4 // Author: Vaclav Slavik
5 // based on MGL implementation
8 // Copyright: (c) 2006 REA Elektronik GmbH
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/evtloop.h"
22 #include "wx/dfb/private.h"
23 #include "wx/private/fontmgr.h"
25 //-----------------------------------------------------------------------------
26 // wxApp initialization
27 //-----------------------------------------------------------------------------
29 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
31 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
32 EVT_IDLE(wxAppBase::OnIdle
)
43 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
45 if ( !wxAppBase::Initialize(argc
, argv
) )
48 if ( !wxDfbCheckReturn(DirectFBInit(&argc
, &argv
)) )
51 // update internal arg[cv] as DFB may have removed processed options:
55 if ( !wxIDirectFB::Get() )
65 wxFontsManager::CleanUp();
67 wxEventLoop::CleanUp();
68 wxIDirectFB::CleanUp();
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
75 static wxVideoMode
GetCurrentVideoMode()
77 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
79 return wxVideoMode(); // invalid
81 return layer
->GetVideoMode();
84 wxVideoMode
wxApp::GetDisplayMode() const
86 if ( !m_videoMode
.IsOk() )
87 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
92 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
94 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
101 //-----------------------------------------------------------------------------
102 // events processing related
103 //-----------------------------------------------------------------------------
105 void wxApp::WakeUpIdle()
108 if (!wxThread::IsMain())
112 wxEventLoop
* const loop
= wxEventLoop::GetActive();
117 if (!wxThread::IsMain())
123 bool wxApp::Yield(bool onlyIfNeeded
)
126 if ( !wxThread::IsMain() )
127 return true; // can't process events from other threads
128 #endif // wxUSE_THREADS
130 static bool s_inYield
= false;
136 wxFAIL_MSG( wxT("wxYield called recursively" ) );
146 wxEventLoop
* const loop
= wxEventLoop::GetActive();
150 // it's necessary to call ProcessIdle() to update the frames sizes which
151 // might have been changed (it also will update other things set from
152 // OnUpdateUI() which is a nice (and desired) side effect)
153 while ( ProcessIdle() ) {}