-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplashScreen.cpp
executable file
·171 lines (137 loc) · 4.6 KB
/
SplashScreen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//////////////////////////////////////////////////////////////////////
// Calques 3D - a 3D Dynamic Geometry Learning Environment
// Copyright (c) 1997-2007 Nicolas Van Labeke
//////////////////////////////////////////////////////////////////////
// This file is part of Calques 3D.
//
// Calques 3D is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Calques 3D is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Calques 3D; if not, write to The Free Software Foundation, Inc.,
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//////////////////////////////////////////////////////////////////////
// SplashScreen.cpp: implementation of the CSplashScreen class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "calques3d.h"
#include "SplashScreen.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplashScreen dialog
BEGIN_MESSAGE_MAP(CSplashScreen, CDialog)
//{{AFX_MSG_MAP(CSplashScreen)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CSplashScreen::CSplashScreen()
{
//{{AFX_DATA_INIT(CSplashScreen)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
BOOL CSplashScreen::Create(CWnd* pParent)
{
//{{AFX_DATA_INIT(CSplashWnd)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
if (!CDialog::Create(CSplashScreen::IDD, pParent))
{
TRACE0("Warning: creation of CSplashWnd dialog failed\n");
return FALSE;
}
return TRUE;
}
void CSplashScreen::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSplashScreen)
DDX_Control(pDX, IDC_ABOUTCALQUE, m_wndIcon);
//}}AFX_DATA_MAP
}
BOOL CSplashScreen::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
// initialize the big icon control
m_icon.SubclassDlgItem(IDC_BIGICON, this);
m_icon.SizeToContent();
m_wndIcon.m_cImage.SetImageSize(CSize(297,298));
m_wndIcon.m_cImage.Load(IDB_SPLASH);
m_wndIcon.m_cImage.SetTransparentColor(RGB(255,0,0));
m_wndIcon.SetImage(0);
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
// CSplashScreen message handlers
/////////////////////////////////////////////////////////////////////////////
// CBigIcon
BEGIN_MESSAGE_MAP(CBigIcon, CButton)
//{{AFX_MSG_MAP(CBigIcon)
ON_WM_DRAWITEM()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBigIcon message handlers
#define CY_SHADOW 4
#define CX_SHADOW 4
void CBigIcon::SizeToContent()
{
m_bitmap.LoadBitmap(IDB_BITMAP48);
BITMAP bm;
m_bitmap.GetObject(sizeof(bm), &bm);
m_sizeBitmap = CSize(bm.bmWidth, bm.bmHeight);
// get system icon size
// a big icon should be twice the size of an icon + shadows
SetWindowPos(NULL, 0, 0, bm.bmWidth + CX_SHADOW + 4, bm.bmHeight + CY_SHADOW + 4,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
}
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
ASSERT(pDC != NULL);
CRect rect;
GetClientRect(rect);
int cxClient = rect.Width();
int cyClient = rect.Height();
// draw border around icon
CPen pen;
pen.CreateStockObject(BLACK_PEN);
CPen* pPenOld = pDC->SelectObject(&pen);
pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW);
if (pPenOld)
pDC->SelectObject(pPenOld);
// draw shadows around icon
CBrush br;
br.CreateStockObject(DKGRAY_BRUSH);
rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient);
pDC->FillRect(rect, &br);
rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient);
pDC->FillRect(rect, &br);
// draw the bitmap contents
CDC dcMem;
if (!dcMem.CreateCompatibleDC(pDC))
return;
CBitmap* pBitmapOld = dcMem.SelectObject(&m_bitmap);
if (pBitmapOld == NULL)
return;
pDC->BitBlt(2, 2, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY);
dcMem.SelectObject(pBitmapOld);
}
BOOL CBigIcon::OnEraseBkgnd(CDC*)
{
return TRUE; // we don't do any erasing...
}