]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/app.cpp
MinGW-w64 provides isfinite() in both 32 and 64 bit builds.
[wxWidgets.git] / src / dfb / app.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/app.cpp
3// Purpose: wxApp implementation
4// Author: Vaclav Slavik
b3c86150 5// Created: 2006-08-16
b3c86150
VS
6// Copyright: (c) 2006 REA Elektronik GmbH
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#include "wx/app.h"
18
19#include "wx/evtloop.h"
1ecd8ca4 20#include "wx/thread.h"
b3c86150 21#include "wx/dfb/private.h"
d7ae4a62 22#include "wx/private/fontmgr.h"
b3c86150
VS
23
24//-----------------------------------------------------------------------------
25// wxApp initialization
26//-----------------------------------------------------------------------------
27
28IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
29
b3c86150
VS
30wxApp::wxApp()
31{
32}
33
34wxApp::~wxApp()
35{
36}
37
b3c86150
VS
38bool wxApp::Initialize(int& argc, wxChar **argv)
39{
40 if ( !wxAppBase::Initialize(argc, argv) )
41 return false;
42
b11af9ed
VS
43 // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This
44 // is just a temporary fix to make wxDFB compile in Unicode
45 // build, the real fix is to change Initialize()'s signature
46 // to use char* on Unix.
47#if wxUSE_UNICODE
48 // DirectFBInit() wants UTF-8, not wchar_t, so convert
49 int i;
50 char **argvDFB = new char *[argc + 1];
51 for ( i = 0; i < argc; i++ )
52 {
53 argvDFB[i] = strdup(wxConvUTF8.cWX2MB(argv[i]));
54 }
55
56 argvDFB[argc] = NULL;
57
58 int argcDFB = argc;
59
60 if ( !wxDfbCheckReturn(DirectFBInit(&argcDFB, &argvDFB)) )
61 return false;
62
63 if ( argcDFB != argc )
64 {
65 // we have to drop the parameters which were consumed by DFB+
66 for ( i = 0; i < argcDFB; i++ )
67 {
68 while ( strcmp(wxConvUTF8.cWX2MB(argv[i]), argvDFB[i]) != 0 )
69 {
70 memmove(argv + i, argv + i + 1, (argc - i)*sizeof(*argv));
71 }
72 }
73
74 argc = argcDFB;
75 }
76 //else: DirectFBInit() didn't modify our parameters
77
78 // free our copy
79 for ( i = 0; i < argcDFB; i++ )
80 {
81 free(argvDFB[i]);
82 }
83
84 delete [] argvDFB;
85
86#else // ANSI
87
52c8d32a 88 if ( !wxDfbCheckReturn(DirectFBInit(&argc, &argv)) )
b3c86150
VS
89 return false;
90
b11af9ed
VS
91#endif // Unicode/ANSI
92
50f1747a
VS
93 // update internal arg[cv] as DFB may have removed processed options:
94 this->argc = argc;
95 this->argv = argv;
96
52c8d32a 97 if ( !wxIDirectFB::Get() )
b3c86150
VS
98 return false;
99
b3c86150
VS
100 return true;
101}
102
103void wxApp::CleanUp()
104{
105 wxAppBase::CleanUp();
106
d7ae4a62
VS
107 wxFontsManager::CleanUp();
108
e48a3055 109 wxEventLoop::CleanUp();
52c8d32a 110 wxIDirectFB::CleanUp();
b3c86150
VS
111}
112
113//-----------------------------------------------------------------------------
114// display mode
115//-----------------------------------------------------------------------------
116
117static wxVideoMode GetCurrentVideoMode()
118{
fa28b00c
VS
119 wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
120 if ( !layer )
121 return wxVideoMode(); // invalid
b3c86150 122
fa28b00c 123 return layer->GetVideoMode();
b3c86150
VS
124}
125
126wxVideoMode wxApp::GetDisplayMode() const
127{
128 if ( !m_videoMode.IsOk() )
129 wxConstCast(this, wxApp)->m_videoMode = GetCurrentVideoMode();
130
131 return m_videoMode;
132}
133
134bool wxApp::SetDisplayMode(const wxVideoMode& mode)
135{
52c8d32a 136 if ( !wxIDirectFB::Get()->SetVideoMode(mode.w, mode.h, mode.bpp) )
b3c86150
VS
137 return false;
138
139 m_videoMode = mode;
140 return true;
141}
142
143//-----------------------------------------------------------------------------
144// events processing related
145//-----------------------------------------------------------------------------
146
147void wxApp::WakeUpIdle()
148{
5f3dc0f0
VS
149 // we don't need a mutex here, since we use the wxConsoleEventLoop
150 // and wxConsoleEventLoop::WakeUp() is thread-safe
2ddff00c 151 wxEventLoopBase * const loop = wxEventLoop::GetActive();
655c20fc
VS
152 if ( loop )
153 loop->WakeUp();
b3c86150 154}