-
Notifications
You must be signed in to change notification settings - Fork 125
/
Digistring.h
executable file
·187 lines (160 loc) · 5.23 KB
/
Digistring.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
183
184
185
186
187
#if !defined(AFX_DIGISTRING_H__F77484C2_745F_11D3_A718_87712333104C__INCLUDED_)
#define AFX_DIGISTRING_H__F77484C2_745F_11D3_A718_87712333104C__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// Digistring.h : header file
//
// Copyright (C) 2000 by Michel Wassink
// All rights reserved
//
// This is free software.
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name and all copyright
// notices remains intact. If the source code in this file is used in
// any commercial application then a statement along the lines of
// "Portions Copyright © 2000 Michel Wassink" must be included in
// the startup banner, "About" box or printed documentation. An email
// letting me know that you are using it would be nice as well. That's
// not much to ask considering the amount of work that went into this.
//
// No warrantee of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Version: 1.0
// Release: 1 (februari 2000 to www.codeguru.com and www.codeproject.com)
// -----------------------------------------------------------------------
// Notes to changes for release 1 (V1.0):
// - First release.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// [email protected] (private site)
// An email letting me know that you are using it would be nice.
/////////////////////////////////////////////////////////////////////////////
#include <vector>
using namespace std ;
#include "MEMDC.H"
#include "RGBCOLOR.H"
// CRect class with double precision for accurate drawing.
class CDoubleRect
{
public:
void SetRect(double x1, double y1, double x2, double y2)
{ left = x1; top = y1; right = x2; bottom = y2;}
double Width() const{return right - left;}
double Height() const{return bottom - top;}
void SetRectEmpty(){left = top = right = bottom = 0.0;}
public:
double left, top, right, bottom;
};
class CDSegment
{
public:
CDSegment();
CDSegment(const CDSegment& Segment);
~CDSegment();
void DefPoints(const POINT* lpPoints, const BYTE* lpTypes, int nCount);
void Draw(CDC *pDC, CDoubleRect DrawPlace, int iWidth) const;
void FreeSegment();
CDSegment operator=(const CDSegment &Segment);
// Implementation
public:
CPoint * m_paPoints;
BYTE * m_paTypes;
int m_nCount;
};
typedef vector<CDSegment> DSegmentVector;
class CDigiChar
{
// Construction
public:
CDigiChar();
//Attributes:
public:
virtual ~CDigiChar();
virtual void SetElementData(WORD wSegmData, int iDispStyle);
void Draw(CDC *pDC, CDoubleRect DrawPlace, CPen *pOffPen, CPen *pOnpen,
CBrush *pOffBrush, CBrush *pOnBrush);
void SetColor(COLORREF OffColor, COLORREF OnColor);
int GetNormWidth() const;
protected:
int m_Width;
WORD m_wSegmData;
DSegmentVector m_SegmentVector;
int m_NSegments;
COLORREF m_OffColor;
COLORREF m_OnColor;
};
class CDigiColonDotChar : public CDigiChar
{
public:
CDigiColonDotChar();
void SetElementData(WORD wSegmData, int iDispStyle);
};
class CDigi7Segment : public CDigiChar
{
public:
CDigi7Segment();
void SetElementData(WORD wSegmData, int iDispStyle);
};
class CDigi14Segment : public CDigiChar
{
public:
CDigi14Segment();
void SetElementData(WORD wSegmData, int iDispStyle);
};
typedef vector<CDigiChar> DigiCharVector;
/////////////////////////////////////////////////////////////////////////////
// CDigistring class
class CDigistring : public CStatic
{
// Construction
public:
CDigistring();
// Attributes
public:
enum {
DS_SMOOTH = 1, // Pioneer kind of characters
DS_STYLE14 = 2, // use allways 14 segment display.
DS_SZ_PROP = 4 // size proportional
};
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDigistring)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CDigistring();
void SetText(LPCTSTR lpszText);
void Format(LPCTSTR lpszFormat, ...);
void SetColor(COLORREF OffColor, COLORREF OnColor);
void SetBackColor(COLORREF BackColor = BLACK);
BOOL ModifyDigiStyle(DWORD dwRemove, DWORD dwAdd);
// Generated message map functions
protected:
CDigiChar * DefineChar(TCHAR cChar);
void BuildString();
CString m_strText;
BOOL m_Modified;
DigiCharVector m_CharVector;
COLORREF m_OffColor;
COLORREF m_OnColor;
COLORREF m_BackColor;
DWORD m_DispStyle;
//{{AFX_MSG(CDigistring)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DIGISTRING_H__F77484C2_745F_11D3_A718_87712333104C__INCLUDED_)