-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseg7.cpp
159 lines (109 loc) · 3.25 KB
/
seg7.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
/*
Copyright (C) 2021 BrerDawg
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//seg7.cpp
//---- v1.01 25-09-2017
#include "seg7.h"
//----------------------------------------------------------
// a
// ____
// f / / b
// /-g-/
// dpl * e /___/ c * dpr
// d
seg7_wdg::seg7_wdg( int x,int y,int w, int h,const char *label ) : Fl_Widget( x, y, w, h, label )
{
col_bkgd.r = 64;
col_bkgd.g = 64;
col_bkgd.b = 64;
col_seg.r = 200;
col_seg.g = 0;
col_seg.b = 0;
gapx = 8;
gapy = 8;
skew = -4; //lower horiz skew
line_width = 2;
inverted = 0;
diode_a = 1;
diode_b = 1;
diode_c = 1;
diode_d = 1;
diode_e = 1;
diode_f = 1;
diode_g = 1;
diode_dpl = 1;
diode_dpr = 1;
}
seg7_wdg::~seg7_wdg()
{
}
void seg7_wdg::setcolref( seg7_colref col )
{
fl_color( col.r , col.g , col.b );
}
void seg7_wdg::draw()
{
//Fl_Widget::draw();
//return;
int rght,bot;
string s1;
mystr m1;
int xx = x();
int yy = y();
//int iF = fl_font();
//int iS = fl_size();
//fl_font( fonttype, fontsize );
//clear wnd
setcolref( col_bkgd );
fl_rectf( xx , yy , w() , h() );
setcolref( col_seg );
fl_line_style( FL_SOLID, line_width, 0 ); //for windos set lie style after colour
//setcolref( col_mag );
bool da = diode_a;
bool db = diode_b;
bool dc = diode_c;
bool dd = diode_d;
bool de = diode_e;
bool df = diode_f;
bool dg = diode_g;
bool ddpl = diode_dpl;
bool ddpr = diode_dpr;
if( inverted )
{
da = !da;
db = !db;
dc = !dc;
dd = !dd;
de = !de;
df = !df;
dg = !dg;
ddpl = !ddpl;
ddpr = !ddpr;
}
int halfy = h() / 2;
//int gap2x = gapx * 2;
//int gap2y = gapy * 2;
if( da ) fl_line( xx + gapx, yy + gapy, xx + w() - gapx, yy + gapy );
if( db ) fl_line( xx + w() - gapx, yy + gapy, xx + w() - gapx + skew / 2, yy + halfy );
if( dc ) fl_line( xx + w() - gapx + skew / 2, yy + halfy, xx + w() - gapx + skew, yy + h() - gapy );
if( dd ) fl_line( xx + gapx + skew, yy + h() - gapy, xx + w() - gapx + skew, yy + h() - gapy );
if( de ) fl_line( xx + gapx + skew, yy + h() - gapy, xx + gapx + skew / 2, yy + halfy );
if( df ) fl_line( xx + gapx + skew / 2, yy + halfy, xx + gapx, yy + gapy );
if( dg ) fl_line( xx + gapx + skew / 2, yy + halfy, xx + w() - gapx + skew / 2, yy + halfy );
if(ddpl) fl_line( xx + gapx + skew - 3, yy + h() - gapy, xx + gapx + skew - 1, yy + h() - gapy );
if(ddpr) fl_line( xx + w() - gapx + skew + 3, yy + h() - gapy, xx + w() - gapx + skew + 5, yy + h() - gapy );
//if( da ) fl_line( xx + gapx, yy + gapy, xx + w() - gapx , yy + y() - gapy );
//fl_font( iF, iS );
}
//----------------------------------------------------------