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