21
21
int cbSplashScreen_timer_id = wxNewId();
24
BEGIN_EVENT_TABLE(cbSplashScreen, wxFrame)
25
EVT_PAINT(cbSplashScreen::OnPaint)
26
EVT_TIMER(cbSplashScreen_timer_id, cbSplashScreen::OnTimer)
27
EVT_ERASE_BACKGROUND(cbSplashScreen::OnEraseBackground)
28
EVT_CLOSE(cbSplashScreen::OnCloseWindow)
29
EVT_CHAR(cbSplashScreen::OnChar)
30
EVT_MOUSE_EVENTS(cbSplashScreen::OnMouseEvent)
24
33
void cbSplashScreen::DoPaint(wxDC &dc)
26
static const wxString release(wxT(RELEASE));
27
static const wxString revision = ConfigManager::GetRevisionString();
30
dc.SetClippingRegion(r);
36
#if wxCHECK_VERSION(2, 9, 0)
37
// dc.SetDeviceClippingRegion(m_region); // was used for 08/02 splash screen (transparent regions)
39
// dc.SetClippingRegion(m_region); // was used for 08/02 splash screen (transparent regions)
33
dc.DrawBitmap(m_label, 0, 0, false);
35
wxFont largeFont(16, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
36
wxFont smallFont(9, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
38
wxCoord a, b, c, d, e, f;
40
dc.GetTextExtent(release, &a, &b, 0, 0, &largeFont);
41
dc.GetTextExtent(revision, &c, &d, 0, 0, &smallFont);
42
dc.GetTextExtent(_("SAFE MODE"), &e, &f, 0, 0, &largeFont);
45
int y = 180 - ((b + d + 8)>>1);
47
dc.SetTextForeground(*wxBLACK);
48
dc.SetFont(largeFont);
43
dc.DrawBitmap(m_label, 0, 0, false);
45
{ // keep this (kind of) in sync with dlgabout.cpp!
46
static const wxString release(wxT(RELEASE));
47
static const wxString revision = ConfigManager::GetRevisionString();
49
wxFont largeFont(16, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
50
wxFont smallFont(9, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
52
wxCoord lf_width, lf_heigth, sf_width, sf_heigth, sm_width, sm_height;
54
dc.GetTextExtent(release, &lf_width, &lf_heigth, 0, 0, &largeFont);
55
dc.GetTextExtent(revision, &sf_width, &sf_heigth, 0, 0, &smallFont);
57
dc.GetTextExtent(_("SAFE MODE"), &sm_width, &sm_height, 0, 0, &largeFont);
64
int y = y_offset - ((lf_heigth + sf_heigth + 8) >> 1);
66
dc.SetTextForeground(*wxBLACK);
68
dc.SetFont(largeFont);
50
dc.DrawText(release, 92 - a, y);
70
dc.DrawText(release, x_offset - lf_width, y);
71
// only render SVN revision when not building official release
72
dc.SetFont(smallFont);
73
dc.DrawText(revision, x_offset - sf_width, y + lf_heigth);
52
dc.DrawText(release, 92 - a, y + (b >> 1));
54
if (PluginManager::GetSafeMode())
56
dc.SetTextForeground(*wxRED);
57
dc.DrawText(_("SAFE MODE"), (dc.GetSize().GetX() - e) / 2, y + b);
58
dc.SetTextForeground(*wxBLACK);
61
// only render SVN revision when not building official release
62
dc.SetFont(smallFont);
63
dc.DrawText(revision, 92 - c, y + b);
75
dc.DrawText(release, x_offset - lf_width, y + (lf_heigth >> 1));
78
if (PluginManager::GetSafeMode())
80
dc.SetFont(largeFont);
81
dc.SetTextForeground(*wxRED);
82
dc.DrawText(_("SAFE MODE"), (dc.GetSize().GetX() - sm_width) / 2, y + lf_heigth);
83
dc.SetTextForeground(*wxBLACK);
67
88
void cbSplashScreen::OnPaint(wxPaintEvent &)
69
// an obscure statement in the wxWidgets book says to
70
// allocate the DC even if you don't paint to avoid
71
// a paint loop. //pecan 2006/04/3
72
wxPaintDC paint_dc(this);
90
// an obscure statement in the wxWidgets book says to
91
// allocate the DC even if you don't paint to avoid
92
// a paint loop. //pecan 2006/04/3
93
wxPaintDC paint_dc(this);
76
97
void cbSplashScreen::OnEraseBackground(wxEraseEvent &event)
78
wxDC *dc = event.GetDC();
99
wxDC *dc = event.GetDC();
82
DoPaint(*dc); // why not? :)
102
DoPaint(*dc); // why not? :)
86
105
void cbSplashScreen::OnTimer(wxTimerEvent &)
91
110
void cbSplashScreen::OnCloseWindow(wxCloseEvent &)
94
/* Don't destroy it here. It creates a dangling pointer
95
in app.cpp and crashes C::B */
113
// Don't destroy it here. It creates a dangling pointer in app.cpp and crashes C::B
99
117
void cbSplashScreen::OnChar(wxKeyEvent &)
104
122
void cbSplashScreen::OnMouseEvent(wxMouseEvent &event)
106
if (event.LeftDown() || event.RightDown())
124
if (event.LeftDown() || event.RightDown())
112
128
cbSplashScreen::cbSplashScreen(wxBitmap &label, long timeout, wxWindow *parent, wxWindowID id, long style)
113
129
: wxFrame(parent, id, wxEmptyString, wxPoint(0, 0), wxSize(100, 100), style),
114
m_timer(this, cbSplashScreen_timer_id), r(0, 0, 181, 181)
130
m_timer(this, cbSplashScreen_timer_id), m_region(0, 0, 181, 181)
116
r.Union(50, 35, 181, 181);
117
r.Union(166, 13, 181, 181);
118
r.Union(259, 29, 181, 181);
120
int w = label.GetWidth();
121
int h = label.GetHeight();
126
wxScreenDC screen_dc;
132
if (!platform::macosx)
138
m_label.Create(w, h);
140
label_dc.SelectObject(m_label);
141
if (!platform::macosx)
143
label_dc.Blit(0, 0, w, h, &screen_dc, x, y);
147
label_dc.SetBackground(*wxWHITE_BRUSH);
150
label_dc.DrawBitmap(label, 0, 0, true);
151
label_dc.SelectObject(wxNullBitmap);
156
SetThemeEnabled(false); // seems to be useful by description
157
SetBackgroundStyle(wxBG_STYLE_CUSTOM); // the trick for GTK+ (notice it's after Show())
159
if (platform::macosx)
160
Centre(wxBOTH | wxCENTRE_ON_SCREEN); // centre only works when the window is showing
162
if(platform::windows || platform::macosx)
169
m_timer.Start(timeout, true);
132
m_region.Union(50, 35, 181, 181);
133
m_region.Union(166, 13, 181, 181);
134
m_region.Union(259, 29, 181, 181);
136
int w = label.GetWidth();
137
int h = label.GetHeight();
142
wxScreenDC screen_dc;
148
if (!platform::macosx)
154
m_label.Create(w, h);
156
label_dc.SelectObject(m_label);
157
if (!platform::macosx)
159
label_dc.Blit(0, 0, w, h, &screen_dc, x, y);
163
label_dc.SetBackground(*wxWHITE_BRUSH);
166
label_dc.DrawBitmap(label, 0, 0, true);
167
label_dc.SelectObject(wxNullBitmap);
169
// SetShape(m_region); // was used for 08/02 splash screen (transparent regions)
172
SetThemeEnabled(false); // seems to be useful by description
173
SetBackgroundStyle(wxBG_STYLE_CUSTOM); // the trick for GTK+ (notice it's after Show())
175
if (platform::macosx)
176
Centre(wxBOTH | wxCENTRE_ON_SCREEN); // centre only works when the window is showing
178
if (platform::windows || platform::macosx)
184
m_timer.Start(timeout, true);
173
187
cbSplashScreen::~cbSplashScreen()
178
BEGIN_EVENT_TABLE(cbSplashScreen, wxFrame)
179
EVT_PAINT(cbSplashScreen::OnPaint)
180
EVT_TIMER(cbSplashScreen_timer_id, cbSplashScreen::OnTimer)
181
EVT_ERASE_BACKGROUND(cbSplashScreen::OnEraseBackground)
182
EVT_CLOSE(cbSplashScreen::OnCloseWindow)
183
EVT_CHAR(cbSplashScreen::OnChar)
184
EVT_MOUSE_EVENTS(cbSplashScreen::OnMouseEvent)