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     if ( !wxIDirectFB::Get() ) 
  61     wxFontsManager::CleanUp(); 
  63     wxEventLoop::CleanUp(); 
  64     wxIDirectFB::CleanUp(); 
  67 //----------------------------------------------------------------------------- 
  69 //----------------------------------------------------------------------------- 
  71 static wxVideoMode 
GetCurrentVideoMode() 
  73     wxIDirectFBDisplayLayerPtr 
layer(wxIDirectFB::Get()->GetDisplayLayer()); 
  75         return wxVideoMode(); // invalid 
  77     return layer
->GetVideoMode(); 
  80 wxVideoMode 
wxApp::GetDisplayMode() const 
  82     if ( !m_videoMode
.IsOk() ) 
  83         wxConstCast(this, wxApp
)->m_videoMode 
= GetCurrentVideoMode(); 
  88 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
) 
  90     if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) ) 
  97 //----------------------------------------------------------------------------- 
  98 // events processing related 
  99 //----------------------------------------------------------------------------- 
 101 void wxApp::WakeUpIdle() 
 104     if (!wxThread::IsMain()) 
 108     wxEventLoop::GetActive()->WakeUp(); 
 111     if (!wxThread::IsMain()) 
 117 bool wxApp::Yield(bool onlyIfNeeded
) 
 120     if ( !wxThread::IsMain() ) 
 121         return true; // can't process events from other threads 
 122 #endif // wxUSE_THREADS 
 124     static bool s_inYield 
= false; 
 130             wxFAIL_MSG( wxT("wxYield called recursively" ) ); 
 140     if ( wxEventLoop::GetActive() ) 
 142         while (wxEventLoop::GetActive()->Pending()) 
 143             wxEventLoop::GetActive()->Dispatch(); 
 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() ) {}