~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/src/splashscreen.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
3
 * http://www.gnu.org/licenses/gpl-3.0.html
4
4
 *
5
 
 * $Revision$
6
 
 * $Id$
7
 
 * $HeadURL$
 
5
 * $Revision: 6261 $
 
6
 * $Id: splashscreen.cpp 6261 2010-05-19 09:59:01Z mortenmacfly $
 
7
 * $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/src/splashscreen.cpp $
8
8
 */
9
9
 
10
10
#include "splashscreen.h"
21
21
  int cbSplashScreen_timer_id = wxNewId();
22
22
}
23
23
 
 
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)
 
31
END_EVENT_TABLE()
 
32
 
24
33
void cbSplashScreen::DoPaint(wxDC &dc)
25
34
{
26
 
  static const wxString release(wxT(RELEASE));
27
 
  static const wxString revision = ConfigManager::GetRevisionString();
28
 
 
29
 
  #ifdef __WIN32__
30
 
  dc.SetClippingRegion(r);
 
35
#ifdef __WIN32__
 
36
  #if wxCHECK_VERSION(2, 9, 0)
 
37
//    dc.SetDeviceClippingRegion(m_region); // was used for 08/02 splash screen (transparent regions)
 
38
  #else
 
39
//    dc.SetClippingRegion(m_region); // was used for 08/02 splash screen (transparent regions)
31
40
  #endif
32
 
 
33
 
  dc.DrawBitmap(m_label, 0, 0, false);
34
 
 
35
 
  wxFont largeFont(16, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
36
 
  wxFont smallFont(9, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
37
 
 
38
 
  wxCoord a, b, c, d, e, f;
39
 
 
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);
43
 
 
44
 
  a >>= 1; c >>=1;
45
 
  int y = 180 - ((b + d + 8)>>1);
46
 
 
47
 
  dc.SetTextForeground(*wxBLACK);
48
 
  dc.SetFont(largeFont);
 
41
#endif
 
42
 
 
43
    dc.DrawBitmap(m_label, 0, 0, false);
 
44
 
 
45
    {  // keep this (kind of) in sync with dlgabout.cpp!
 
46
        static const wxString release(wxT(RELEASE));
 
47
        static const wxString revision = ConfigManager::GetRevisionString();
 
48
 
 
49
        wxFont largeFont(16, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
 
50
        wxFont smallFont(9,  wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
 
51
 
 
52
        wxCoord lf_width, lf_heigth, sf_width, sf_heigth, sm_width, sm_height;
 
53
 
 
54
        dc.GetTextExtent(release,  &lf_width, &lf_heigth, 0, 0, &largeFont);
 
55
        dc.GetTextExtent(revision, &sf_width, &sf_heigth, 0, 0, &smallFont);
 
56
 
 
57
        dc.GetTextExtent(_("SAFE MODE"), &sm_width, &sm_height, 0, 0, &largeFont);
 
58
 
 
59
        int x_offset = 310;
 
60
        int y_offset = 150;
 
61
 
 
62
        lf_width >>= 1;
 
63
        sf_width >>= 1;
 
64
        int y      = y_offset - ((lf_heigth + sf_heigth + 8) >> 1);
 
65
 
 
66
        dc.SetTextForeground(*wxBLACK);
 
67
 
 
68
        dc.SetFont(largeFont);
49
69
#if SVN_BUILD
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);
51
74
#else
52
 
  dc.DrawText(release,  92 - a, y + (b >> 1));
53
 
#endif
54
 
  if (PluginManager::GetSafeMode())
55
 
  {
56
 
        dc.SetTextForeground(*wxRED);
57
 
        dc.DrawText(_("SAFE MODE"), (dc.GetSize().GetX() - e) / 2, y + b);
58
 
        dc.SetTextForeground(*wxBLACK);
59
 
  }
60
 
#if SVN_BUILD
61
 
  // only render SVN revision when not building official release
62
 
  dc.SetFont(smallFont);
63
 
  dc.DrawText(revision, 92 - c, y + b);
64
 
#endif
 
75
        dc.DrawText(release,  x_offset - lf_width, y + (lf_heigth >> 1));
 
76
#endif
 
77
 
 
78
        if (PluginManager::GetSafeMode())
 
79
        {
 
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);
 
84
        }
 
85
    }
65
86
}
66
87
 
67
88
void cbSplashScreen::OnPaint(wxPaintEvent &)
68
89
{
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);
73
 
  DoPaint(paint_dc);
 
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);
 
94
    DoPaint(paint_dc);
74
95
}
75
96
 
76
97
void cbSplashScreen::OnEraseBackground(wxEraseEvent &event)
77
98
{
78
 
  wxDC *dc = event.GetDC();
 
99
    wxDC *dc = event.GetDC();
79
100
 
80
 
  if (dc)
81
 
  {
82
 
    DoPaint(*dc); // why not? :)
83
 
  }
 
101
    if (dc)
 
102
        DoPaint(*dc); // why not? :)
84
103
}
85
104
 
86
105
void cbSplashScreen::OnTimer(wxTimerEvent &)
87
106
{
88
 
  Close(true);
 
107
    Close(true);
89
108
}
90
109
 
91
110
void cbSplashScreen::OnCloseWindow(wxCloseEvent &)
92
111
{
93
 
  m_timer.Stop();
94
 
  /* Don't destroy it here. It creates a dangling pointer
95
 
     in app.cpp and crashes C::B */
96
 
  Hide();
 
112
    m_timer.Stop();
 
113
    // Don't destroy it here. It creates a dangling pointer in app.cpp and crashes C::B
 
114
    Hide();
97
115
}
98
116
 
99
117
void cbSplashScreen::OnChar(wxKeyEvent &)
100
118
{
101
 
  Close(true);
 
119
    Close(true);
102
120
}
103
121
 
104
122
void cbSplashScreen::OnMouseEvent(wxMouseEvent &event)
105
123
{
106
 
  if (event.LeftDown() || event.RightDown())
107
 
  {
108
 
    Close(true);
109
 
  }
 
124
    if (event.LeftDown() || event.RightDown())
 
125
        Close(true);
110
126
}
111
127
 
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)
115
131
{
116
 
  r.Union(50, 35, 181, 181);
117
 
  r.Union(166, 13, 181, 181);
118
 
  r.Union(259, 29, 181, 181);
119
 
 
120
 
  int w = label.GetWidth();
121
 
  int h = label.GetHeight();
122
 
 
123
 
  SetClientSize(w, h);
124
 
  CentreOnScreen();
125
 
 
126
 
  wxScreenDC screen_dc;
127
 
  wxMemoryDC label_dc;
128
 
 
129
 
  int x;
130
 
  int y;
131
 
 
132
 
  if (!platform::macosx)
133
 
  {
134
 
    x = GetPosition().x;
135
 
    y = GetPosition().y;
136
 
  }
137
 
 
138
 
  m_label.Create(w, h);
139
 
 
140
 
  label_dc.SelectObject(m_label);
141
 
  if (!platform::macosx)
142
 
  {
143
 
    label_dc.Blit(0, 0, w, h, &screen_dc, x, y);
144
 
  }
145
 
  else
146
 
  {
147
 
    label_dc.SetBackground(*wxWHITE_BRUSH);
148
 
    label_dc.Clear();
149
 
  }
150
 
  label_dc.DrawBitmap(label, 0, 0, true);
151
 
  label_dc.SelectObject(wxNullBitmap);
152
 
 
153
 
  SetShape(r);
154
 
 
155
 
  Show(true);
156
 
  SetThemeEnabled(false); // seems to be useful by description
157
 
  SetBackgroundStyle(wxBG_STYLE_CUSTOM); // the trick for GTK+ (notice it's after Show())
158
 
 
159
 
  if (platform::macosx)
160
 
    Centre(wxBOTH | wxCENTRE_ON_SCREEN); // centre only works when the window is showing
161
 
 
162
 
  if(platform::windows || platform::macosx)
163
 
    Update();
164
 
  else
165
 
    wxYieldIfNeeded();
166
 
 
167
 
  if (timeout != -1)
168
 
  {
169
 
    m_timer.Start(timeout, true);
170
 
  }
 
132
    m_region.Union(50,  35, 181, 181);
 
133
    m_region.Union(166, 13, 181, 181);
 
134
    m_region.Union(259, 29, 181, 181);
 
135
 
 
136
    int w = label.GetWidth();
 
137
    int h = label.GetHeight();
 
138
 
 
139
    SetClientSize(w, h);
 
140
    CentreOnScreen();
 
141
 
 
142
    wxScreenDC screen_dc;
 
143
    wxMemoryDC label_dc;
 
144
 
 
145
    int x;
 
146
    int y;
 
147
 
 
148
    if (!platform::macosx)
 
149
    {
 
150
        x = GetPosition().x;
 
151
        y = GetPosition().y;
 
152
    }
 
153
 
 
154
    m_label.Create(w, h);
 
155
 
 
156
    label_dc.SelectObject(m_label);
 
157
    if (!platform::macosx)
 
158
    {
 
159
        label_dc.Blit(0, 0, w, h, &screen_dc, x, y);
 
160
    }
 
161
    else
 
162
    {
 
163
        label_dc.SetBackground(*wxWHITE_BRUSH);
 
164
        label_dc.Clear();
 
165
    }
 
166
    label_dc.DrawBitmap(label, 0, 0, true);
 
167
    label_dc.SelectObject(wxNullBitmap);
 
168
 
 
169
//    SetShape(m_region); // was used for 08/02 splash screen (transparent regions)
 
170
 
 
171
    Show(true);
 
172
    SetThemeEnabled(false); // seems to be useful by description
 
173
    SetBackgroundStyle(wxBG_STYLE_CUSTOM); // the trick for GTK+ (notice it's after Show())
 
174
 
 
175
    if (platform::macosx)
 
176
      Centre(wxBOTH | wxCENTRE_ON_SCREEN); // centre only works when the window is showing
 
177
 
 
178
    if (platform::windows || platform::macosx)
 
179
        Update();
 
180
    else
 
181
        wxYieldIfNeeded();
 
182
 
 
183
    if (timeout != -1)
 
184
        m_timer.Start(timeout, true);
171
185
}
172
186
 
173
187
cbSplashScreen::~cbSplashScreen()
174
188
{
175
 
  m_timer.Stop();
 
189
    m_timer.Stop();
176
190
}
177
 
 
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)
185
 
END_EVENT_TABLE()