-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreditsCtrl.h
executable file
·182 lines (159 loc) · 7.53 KB
/
CreditsCtrl.h
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
172
173
174
175
176
177
178
179
180
181
182
//////////////////////////////////////////////////////////////////////
// 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
//////////////////////////////////////////////////////////////////////
/// @file CreditsCtrl.h
/// @brief interface of the CCreditsCtrl class.
///
/// @author Marc Richarme (http://www.codeproject.com/dialog/ccreditsctrl.asp)
/// $Date: 2007-11-25 13:37:20+00 $
/// $Revision: 1.8 $
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CREDITSCTRL_H__0D506182_3886_4D4C_A609_DA8914C17718__INCLUDED_)
#define AFX_CREDITSCTRL_H__0D506182_3886_4D4C_A609_DA8914C17718__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CreditsCtrl.h : header file
//
#include <afxtempl.h>
/////////////////////////////////////////////////////////////////////////////
/// Implement a Scrolling credit control
///
/// @author Marc Richarme (http://www.codeproject.com/dialog/ccreditsctrl.asp)
/////////////////////////////////////////////////////////////////////////////
class CCreditsCtrl : public CWnd
{
// Construction
public:
CCreditsCtrl();
virtual ~CCreditsCtrl();
BOOL Create(DWORD dwExStyle, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0, UINT nDefaultCursorID = 0, UINT nLinkCursorID = 0);
BOOL Create(DWORD dwExStyle, DWORD dwStyle, UINT nPlaceholderID, CWnd* pParentWnd, UINT nID = 0, UINT nDefaultCursorID = 0, UINT nLinkCursorID = 0);
// Attributes
public:
static LPCTSTR m_lpszClassName;
/////////////////////////////////////////////////////////////////////////////
/// local structures used during parsing
/////////////////////////////////////////////////////////////////////////////
typedef struct
{
TCHAR szName[MAX_PATH];
int nSize;
int bBold;
int bItalic;
int bUnderline;
int bStrikeout;
COLORREF crColor;
COLORREF crBkColor;
} font_attribs;
/////////////////////////////////////////////////////////////////////////////
/// local structures used during parsing
/////////////////////////////////////////////////////////////////////////////
typedef struct
{
int nAlign; // 0: left, 1: center, 2: right
int nVAlign; // 0: top, 1: middle, 2: bottom
int nMaxWidth;
int nMaxHeight;
} general_attribs;
/////////////////////////////////////////////////////////////////////////////
/// local structures used during parsing
/////////////////////////////////////////////////////////////////////////////
typedef struct
{
RECT rcRect;
int nVAlign;
CString sLink;
} line_rect;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCreditsCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
////// Stuff that can be customized to fit your neeeds /////////////////
BOOL m_bCanScroll; // TRUE (default) if the user is allowed to manually scroll through the control using drag & drop
int m_nCurBitmapOffset; // normally you shouldn't touch this one
int m_nTimerSpeed; // default: 40
HCURSOR m_hDefaultCursor; // normally you would want to set this one in Create()
HCURSOR m_hLinkCursor; // normally you would want to set this one in Create()
CString m_sData; // use SetDataString() or FormatDataString()
void(*m_pBackgroundPaint)(CDC*,RECT,BOOL,DWORD); // background drawing function
DWORD m_dwBackgroundPaintLParam; // lParam to m_pBackgroundPaint.. by default this is the background color
COLORREF m_crInternalTransparentColor; // normally you would use a color close or equal to the background color
CArray<CRect,CRect&> m_HotRects;
CArray<CString,CString&> m_HotRectActions;
////// Functions you always should use /////////////////////////////////
// sets data string...
CString SetDataString(LPCTSTR lpszNewString);
CString SetDataString(UINT nStringResourceID);
CString FormatDataString(LPCTSTR lpszFormat, ...);
CString FormatDataString(UINT nFormatID, ...);
// returns data string
CString GetDataString();
////// Functions you might want to use /////////////////////////////////
// returns the index if the m_HotRects array the point matches or -1 for no hit
int HitTest(CPoint pt);
// sets the background color used by the default background drawer function
void SetDefaultBkColor(COLORREF crColor);
// parses the m_sData string, creates m_bmpNormal & m_bmpHot and fill the m_HotRects & m_HotRectActions arrays
void Initialize();
// set link cursor to a hand icon
void SetDefaultLinkCursor();
////// Functions you probably won't need ///////////////////////////////
// helpers for parsing
void Parse_AppendText(CDC *pDC, CDC *pHoverDC, int *pnCurHPos, int *pnCurVPos, int *pnCurHeight, CArray<line_rect,line_rect&>* parcLineRects, general_attribs *pga, font_attribs *pfa, CString sText, CString sCurLink, font_attribs &link);
void Parse_AppendBitmap(CDC *pDC, CDC *pHoverDC, int *pnCurHPos, int *pnCurVPos, int *pnCurHeight, CArray<line_rect,line_rect&>* parcLineRects, general_attribs *pga, CBitmap *pBitmap, COLORREF crBorder, int nBorder, CString sCurLink, font_attribs &link);
void Parse_AppendElement(CDC *pDC, CDC *pHoverDC, int *pnCurHPos, int *pnCurVPos, int *pnCurHeight, CArray<line_rect,line_rect&>* parcLineRects, general_attribs *pga, int nElementWidth, int nElementHeight, CDC *pElementDC, CDC *pHoverElementDC, CString sCurLink);
void Parse_VAlignLine(CDC *pDestDC, CDC *pHoverDestDC, CDC *pLineDC, CDC *pHoverLineDC, int nCurHPos, int nCurVPos, int nCurHeight, CArray<line_rect,line_rect&>* parcLineRects, general_attribs *pga);
BOOL StringToColor(CString string, COLORREF &cr);
// default background drawer
static void DrawBackground(CDC *pDC, RECT rect, BOOL bAnimate, DWORD lParam);
// drawing routines
void TransparentBlt(CDC *pSrcDC, CDC* pDestDC,COLORREF crTrans,const CRect& rcDest,const CRect& rcSrc);
void DrawTransparentBitmap(CBitmap *pBitmap, CDC* pDC,COLORREF crTrans,const CRect& rcDest,const CRect& rcSrc);
////// Stuff you really shouldn't touch ////////////////////////////////
protected:
// Internally used variables
CRect m_rcClient;
CRect m_rcHotRect;
BOOL m_bIsScrolling;
int m_nScrollStart;
int m_nBitmapHeight;
CBitmap m_bmpHot;
CBitmap m_bmpNormal;
// Generated message map functions
protected:
//{{AFX_MSG(CCreditsCtrl)
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CREDITSCTRL_H__0D506182_3886_4D4C_A609_DA8914C17718__INCLUDED_)