-
Notifications
You must be signed in to change notification settings - Fork 1
/
lcdwindow.h
executable file
·89 lines (67 loc) · 2.16 KB
/
lcdwindow.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
#ifndef __LCDWINDOW_H__
#define __LCDWINDOW_H__
//#include <wx/event.h>
#include <wx/dcclient.h>
#include <wx/window.h>
// This structure is used internally by the window.
struct wxDigitData
{
char value;
bool comma;
};
class wxLCDWindow : public wxWindow
{
protected:
int mSegmentLen;
int mSegmentWidth;
int mSpace;
int mNumberDigits;
wxString mValue;
wxColour mLightColour;
wxColour mGrayColour;
protected:
// Internal functions used by the control.
// No time for documentation yet. Sorry.
int GetDigitWidth();
int GetDigitHeight();
int GetBitmapWidth();
int GetBitmapHeight();
int DigitX(int digit);
int DigitY(int digit);
void DoDrawing( wxDC *dc );
void DrawSegment( wxDC *dc, int digit, int segment, bool state );
void DrawDot( wxDC *dc, int digit, bool state );
void DrawDigit( wxDC *dc, int digit, wxDigitData *data );
void DrawTwoDots( wxDC *dc, int digit );
unsigned char Decode( char c );
void OnPaint( wxPaintEvent &event );
void OnSize( wxSizeEvent &event );
public:
wxLCDWindow( wxWindow *parent, wxPoint pos, wxSize size );
virtual ~wxLCDWindow();
// Sets the desired number of digits our 7seg display.
// The default is 4.
void SetNumberDigits( int ndigits );
// Gets the current number of digits.
int GetNumberDigits();
/* Print a value on the display. The accepted characters are :
- All the hexadecimal digits ( 0-F )
- The characters :,.-EroC and space
- The character ^ is displayed as an o, but displayed at the top. ( The symbol of degrees )
*/
void SetValue( wxString value );
// Gets the value currently displayed.
wxString GetValue();
// Sets the colour which the lighted parts of the display should have.
void SetLightColour( wxColour c );
// Sets the colour that the grayed parts of the display will have.
void SetGrayColour( wxColour c );
wxColour GetLightColour();
wxColour GetGrayColour();
// Returns the amount of digits required to display the current value.
// The amount of digits needed is not necessarily the length of the string.
// For example, a dot does not require an extra space in order to be displayed.
int GetDigitsNeeded( wxString value );
DECLARE_EVENT_TABLE()
};
#endif // __LCDWINDOW_H__