Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2004-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file MFXSevenSegment.cpp
15 : /// @author Mathew Robertson
16 : /// @author Daniel Krajzewicz
17 : /// @author Michael Behrisch
18 : /// @date 2004-03-19
19 : ///
20 : //
21 : /****************************************************************************/
22 : #include <config.h>
23 :
24 : #include "MFXSevenSegment.h"
25 :
26 :
27 : /// @brief note: this class may change into FXLCDsegment, so as to support 7 or 14 segment display
28 : #define ASCII_ZERO 48
29 :
30 : // ===========================================================================
31 : // FOX callback mapping
32 : // ===========================================================================
33 :
34 : FXDEFMAP(MFXSevenSegment) MFXSevenSegmentMap[] = {
35 : FXMAPFUNC(SEL_PAINT, 0, MFXSevenSegment::onPaint),
36 : FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, MFXSevenSegment::onCmdSetValue),
37 : FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, MFXSevenSegment::onCmdSetIntValue),
38 : FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, MFXSevenSegment::onCmdGetIntValue),
39 : FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, MFXSevenSegment::onCmdSetStringValue),
40 : FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, MFXSevenSegment::onCmdGetStringValue),
41 : //FXMAPFUNC(SEL_UPDATE, FXWindow::ID_QUERY_TIP, MFXSevenSegment::onQueryTip),
42 : //FXMAPFUNC(SEL_UPDATE, FXWindow::ID_QUERY_HELP, MFXSevenSegment::onQueryHelp),
43 : };
44 :
45 : // Object implementation
46 113567313 : FXIMPLEMENT(MFXSevenSegment, FXFrame, MFXSevenSegmentMap, ARRAYNUMBER(MFXSevenSegmentMap))
47 :
48 :
49 : // ===========================================================================
50 : // method definitions
51 : // ===========================================================================
52 :
53 492320 : MFXSevenSegment::MFXSevenSegment(FXComposite* p, FXObject* tgt, FXSelector sel, FXuint opts, FXint pl, FXint pr, FXint pt, FXint pb) :
54 : FXFrame(p, opts, 0, 0, 0, 0, pl, pr, pt, pb),
55 492320 : myValue(' '),
56 492320 : myLCDTextColor(FXRGB(0, 255, 0)),
57 492320 : myBackGroundColor(FXRGB(0, 0, 0)),
58 492320 : myHorizontalSegmentLength(8),
59 492320 : myVerticalSegmentLength(8),
60 492320 : mySegmentThickness(3),
61 492320 : myGroove(1) {
62 : setTarget(tgt);
63 : setSelector(sel);
64 492320 : enable();
65 492320 : }
66 :
67 :
68 : FXint
69 5513398 : MFXSevenSegment::getDefaultWidth() {
70 5513398 : return padleft + (myGroove << 1) + myHorizontalSegmentLength + padright + (border << 1);
71 : }
72 :
73 :
74 : FXint
75 5251950 : MFXSevenSegment::getDefaultHeight() {
76 5251950 : return padtop + (myGroove << 2) + (myVerticalSegmentLength << 1) + padbottom + (border << 1);
77 : }
78 :
79 :
80 : void
81 11873824 : MFXSevenSegment::setText(FXchar val) {
82 11873824 : if (FXString(val, 1).upper() != FXString(myValue, 1).upper()) {
83 1013779 : myValue = val;
84 1013779 : recalc();
85 1013779 : update();
86 : }
87 11873824 : }
88 :
89 :
90 : void
91 0 : MFXSevenSegment::setFgColor(const FXColor clr) {
92 0 : if (myLCDTextColor != clr) {
93 0 : myLCDTextColor = clr;
94 0 : recalc();
95 0 : update();
96 : }
97 0 : }
98 :
99 :
100 : void
101 0 : MFXSevenSegment::setBgColor(const FXColor clr) {
102 0 : if (myBackGroundColor != clr) {
103 0 : myBackGroundColor = clr;
104 0 : recalc();
105 0 : update();
106 : }
107 0 : }
108 :
109 :
110 : void
111 492320 : MFXSevenSegment::setHorizontal(const FXint len) {
112 492320 : if (len != myHorizontalSegmentLength) {
113 492320 : myHorizontalSegmentLength = (FXshort)len;
114 492320 : checkSize();
115 492320 : recalc();
116 492320 : update();
117 : }
118 492320 : }
119 :
120 :
121 : void
122 492320 : MFXSevenSegment::setVertical(const FXint len) {
123 492320 : if (len != myVerticalSegmentLength) {
124 492320 : myVerticalSegmentLength = (FXshort)len;
125 492320 : checkSize();
126 492320 : recalc();
127 492320 : update();
128 : }
129 492320 : }
130 :
131 :
132 : void
133 492320 : MFXSevenSegment::setThickness(const FXint w) {
134 492320 : if (w != mySegmentThickness) {
135 492320 : mySegmentThickness = (FXshort)w;
136 492320 : checkSize();
137 492320 : recalc();
138 492320 : update();
139 : }
140 492320 : }
141 :
142 :
143 : void
144 492320 : MFXSevenSegment::setGroove(const FXint w) {
145 492320 : if (w != myGroove) {
146 492320 : myGroove = (FXshort)w;
147 492320 : checkSize();
148 492320 : recalc();
149 492320 : update();
150 : }
151 492320 : }
152 :
153 :
154 : long
155 1005510 : MFXSevenSegment::onPaint(FXObject*, FXSelector, void* ptr) {
156 : FXEvent* event = (FXEvent*) ptr;
157 1005510 : FXDCWindow dc(this, event);
158 1005510 : drawFrame(dc, 0, 0, width, height);
159 1005510 : dc.setForeground(myBackGroundColor);
160 1005510 : dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
161 1005510 : dc.setForeground(myLCDTextColor);
162 1005510 : drawFigure(dc, myValue);
163 1005510 : return 1;
164 1005510 : }
165 :
166 :
167 : long
168 0 : MFXSevenSegment::onCmdSetValue(FXObject*, FXSelector, void* ptr) {
169 : FXchar* c = (FXchar*)ptr;
170 0 : if (c[0] != '\0') {
171 0 : setText(c[0]);
172 : }
173 0 : return 1;
174 : }
175 :
176 :
177 : long
178 0 : MFXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector, void*) {
179 0 : FXint i = myValue - ASCII_ZERO;
180 0 : if (i < 0) {
181 0 : i = 0;
182 : }
183 0 : if (i > 9) {
184 0 : i = 9;
185 : }
186 0 : sender->handle(this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (void*)&i);
187 0 : return 1;
188 : }
189 :
190 :
191 : long
192 0 : MFXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector, void* ptr) {
193 0 : FXint i = *((FXint*)ptr);
194 : if (i < 0) {
195 : i = 0;
196 : }
197 : if (i > 9) {
198 : i = 9;
199 : }
200 0 : setText((FXchar)(i + ASCII_ZERO));
201 0 : return 1;
202 : }
203 :
204 :
205 : long
206 0 : MFXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector, void*) {
207 0 : FXString s(myValue, 1);
208 0 : sender->handle(this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (void*)&s);
209 0 : return 1;
210 0 : }
211 :
212 :
213 : long
214 0 : MFXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector, void* ptr) {
215 : FXString* s = (FXString*)ptr;
216 0 : if (s->length()) {
217 0 : setText(s->at(0));
218 : }
219 0 : return 1;
220 : }
221 :
222 :
223 : void
224 0 : MFXSevenSegment::save(FXStream& store) const {
225 0 : FXFrame::save(store);
226 0 : store << myValue;
227 0 : store << myLCDTextColor;
228 0 : store << myBackGroundColor;
229 0 : store << myHorizontalSegmentLength;
230 0 : store << myVerticalSegmentLength;
231 0 : store << mySegmentThickness;
232 0 : store << myGroove;
233 0 : }
234 :
235 :
236 : void
237 0 : MFXSevenSegment::load(FXStream& store) {
238 0 : FXFrame::load(store);
239 0 : store >> myValue;
240 0 : store >> myLCDTextColor;
241 0 : store >> myBackGroundColor;
242 0 : store >> myHorizontalSegmentLength;
243 0 : store >> myVerticalSegmentLength;
244 0 : store >> mySegmentThickness;
245 0 : store >> myGroove;
246 0 : }
247 :
248 :
249 : long
250 0 : MFXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel, void* ptr) {
251 0 : if (getParent()) {
252 0 : return getParent()->handle(sender, sel, ptr);
253 : }
254 : return 0;
255 : }
256 :
257 :
258 : long
259 0 : MFXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel, void* ptr) {
260 0 : if (getParent()) {
261 0 : return getParent()->handle(sender, sel, ptr);
262 : }
263 : return 0;
264 : }
265 :
266 :
267 : void
268 658670 : MFXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
269 : FXPoint points[4];
270 658670 : points[0].x = x;
271 658670 : points[0].y = y;
272 658670 : points[1].x = x + myHorizontalSegmentLength;
273 658670 : points[1].y = y;
274 658670 : points[2].x = x + myHorizontalSegmentLength - mySegmentThickness;
275 658670 : points[2].y = y + mySegmentThickness;
276 658670 : points[3].x = x + mySegmentThickness;
277 658670 : points[3].y = y + mySegmentThickness;
278 658670 : dc.fillPolygon(points, 4);
279 658670 : }
280 :
281 :
282 : void
283 505049 : MFXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
284 : FXPoint points[4];
285 505049 : points[0].x = x;
286 505049 : points[0].y = y;
287 505049 : points[1].x = x + mySegmentThickness;
288 505049 : points[1].y = y + mySegmentThickness;
289 505049 : points[2].x = x + mySegmentThickness;
290 505049 : points[2].y = y + myVerticalSegmentLength - (mySegmentThickness >> 1);
291 505049 : points[3].x = x;
292 505049 : points[3].y = y + myVerticalSegmentLength;
293 505049 : dc.fillPolygon(points, 4);
294 505049 : }
295 :
296 :
297 : void
298 643431 : MFXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
299 : FXPoint points[4];
300 643431 : points[0].x = x + mySegmentThickness;
301 643431 : points[0].y = y;
302 643431 : points[1].x = x + mySegmentThickness;
303 643431 : points[1].y = y + myVerticalSegmentLength;
304 643431 : points[2].x = x;
305 643431 : points[2].y = y + myVerticalSegmentLength - (mySegmentThickness >> 1);
306 643431 : points[3].x = x;
307 643431 : points[3].y = y + mySegmentThickness;
308 643431 : dc.fillPolygon(points, 4);
309 643431 : }
310 :
311 :
312 : void
313 663915 : MFXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
314 : FXPoint points[6];
315 663915 : points[0].x = x + mySegmentThickness;
316 663915 : points[0].y = y;
317 663915 : points[1].x = x + myHorizontalSegmentLength - mySegmentThickness;
318 663915 : points[1].y = y;
319 663915 : points[2].x = x + myHorizontalSegmentLength;
320 663915 : points[2].y = y + (mySegmentThickness >> 1);
321 663915 : points[3].x = x + myHorizontalSegmentLength - mySegmentThickness;
322 663915 : points[3].y = y + mySegmentThickness;
323 663915 : points[4].x = x + mySegmentThickness;
324 663915 : points[4].y = y + mySegmentThickness;
325 663915 : points[5].x = x;
326 663915 : points[5].y = y + (mySegmentThickness >> 1);
327 663915 : dc.fillPolygon(points, 6);
328 663915 : }
329 :
330 :
331 : void
332 346870 : MFXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
333 : FXPoint points[4];
334 346870 : points[0].x = x;
335 346870 : points[0].y = y;
336 346870 : points[1].x = x + mySegmentThickness;
337 346870 : points[1].y = y + (mySegmentThickness >> 1);
338 346870 : points[2].x = x + mySegmentThickness;
339 346870 : points[2].y = y + myVerticalSegmentLength - mySegmentThickness;
340 346870 : points[3].x = x;
341 346870 : points[3].y = y + myVerticalSegmentLength;
342 346870 : dc.fillPolygon(points, 4);
343 346870 : }
344 :
345 :
346 : void
347 727895 : MFXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
348 : FXPoint points[4];
349 727895 : points[0].x = x + mySegmentThickness;
350 727895 : points[0].y = y;
351 727895 : points[1].x = x + mySegmentThickness;
352 727895 : points[1].y = y + myVerticalSegmentLength;
353 727895 : points[2].x = x;
354 727895 : points[2].y = y + myVerticalSegmentLength - mySegmentThickness;
355 727895 : points[3].x = x;
356 727895 : points[3].y = y + (mySegmentThickness >> 1);
357 727895 : dc.fillPolygon(points, 4);
358 727895 : }
359 :
360 :
361 : void
362 583033 : MFXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
363 : FXPoint points[4];
364 583033 : points[0].x = x + mySegmentThickness;
365 583033 : points[0].y = y;
366 583033 : points[1].x = x + myHorizontalSegmentLength - mySegmentThickness;
367 583033 : points[1].y = y;
368 583033 : points[2].x = x + myHorizontalSegmentLength;
369 583033 : points[2].y = y + mySegmentThickness;
370 583033 : points[3].x = x;
371 583033 : points[3].y = y + mySegmentThickness;
372 583033 : dc.fillPolygon(points, 4);
373 583033 : }
374 :
375 :
376 : void
377 1005510 : MFXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
378 1005510 : FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
379 : FXshort x, y;
380 1005510 : if (options & LAYOUT_FILL) {
381 0 : if (options & LAYOUT_FILL_X) {
382 0 : myHorizontalSegmentLength = (FXshort)(width - padleft - padright - (border << 1));
383 0 : if (myHorizontalSegmentLength < 4) {
384 0 : myHorizontalSegmentLength = 4;
385 : }
386 : }
387 0 : if (options & LAYOUT_FILL_Y) {
388 0 : myVerticalSegmentLength = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
389 0 : if (myVerticalSegmentLength < 4) {
390 0 : myVerticalSegmentLength = 4;
391 : }
392 : }
393 0 : mySegmentThickness = FXMIN(myHorizontalSegmentLength, myVerticalSegmentLength) / 4;
394 0 : myGroove = mySegmentThickness / 4;
395 0 : if (mySegmentThickness < 1) {
396 0 : mySegmentThickness = 1;
397 : }
398 0 : if (myGroove < 1) {
399 0 : myGroove = 1;
400 : }
401 0 : if (options & LAYOUT_FILL_X) {
402 0 : myHorizontalSegmentLength -= myGroove << 1;
403 : }
404 0 : if (options & LAYOUT_FILL_Y) {
405 0 : myVerticalSegmentLength -= myGroove << 1;
406 : }
407 : }
408 1005510 : if (s1) {
409 658670 : x = sx + myGroove;
410 : y = sy;
411 658670 : drawTopSegment(dc, x, y);
412 : }
413 1005510 : if (s2) {
414 : x = sx;
415 505049 : y = sy + myGroove;
416 505049 : drawLeftTopSegment(dc, x, y);
417 : }
418 1005510 : if (s3) {
419 643431 : x = sx + myGroove + myHorizontalSegmentLength - mySegmentThickness + myGroove;
420 643431 : y = sy + myGroove;
421 643431 : drawRightTopSegment(dc, x, y);
422 : }
423 1005510 : if (s4) {
424 663915 : x = sx + myGroove;
425 663915 : y = sy + myGroove + myVerticalSegmentLength - (mySegmentThickness >> 1) + myGroove;
426 663915 : drawMiddleSegment(dc, x, y);
427 : }
428 1005510 : if (s5) {
429 : x = sx;
430 346870 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove;
431 346870 : drawLeftBottomSegment(dc, x, y);
432 : }
433 1005510 : if (s6) {
434 727895 : x = sx + myGroove + myHorizontalSegmentLength - mySegmentThickness + myGroove;
435 727895 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove;
436 727895 : drawRightBottomSegment(dc, x, y);
437 : }
438 1005510 : if (s7) {
439 583033 : x = sx + myGroove;
440 583033 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove + myVerticalSegmentLength + myGroove - mySegmentThickness;
441 583033 : drawBottomSegment(dc, x, y);
442 : }
443 1005510 : }
444 :
445 :
446 : void
447 1005510 : MFXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
448 1005510 : switch (figure) {
449 80971 : case ' ' :
450 80971 : drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
451 80971 : break;
452 0 : case '(' :
453 0 : drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
454 0 : break;
455 0 : case ')' :
456 0 : drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
457 0 : break;
458 0 : case '[' :
459 0 : drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
460 0 : break;
461 0 : case ']' :
462 0 : drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
463 0 : break;
464 0 : case '=' :
465 0 : drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE);
466 0 : break;
467 : // case '+' : drawSegments (dc, FALSE,FALSE,FALSE,TRUE ,FALSE,FALSE,FALSE); break;
468 113086 : case '-' :
469 : case ':' :
470 113086 : drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
471 113086 : break;
472 663 : case '_' :
473 : case '.' :
474 : case ',' :
475 663 : drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
476 663 : break;
477 109351 : case '0' :
478 109351 : drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
479 109351 : break;
480 74310 : case '1' :
481 74310 : drawSegments(dc, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
482 74310 : break;
483 82895 : case '2' :
484 82895 : drawSegments(dc, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE);
485 82895 : break;
486 72236 : case '3' :
487 72236 : drawSegments(dc, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE);
488 72236 : break;
489 77810 : case '4' :
490 77810 : drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
491 77810 : break;
492 90330 : case '5' :
493 90330 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
494 90330 : break;
495 77029 : case '6' :
496 77029 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
497 77029 : break;
498 76300 : case '7' :
499 76300 : drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
500 76300 : break;
501 77595 : case '8' :
502 77595 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
503 77595 : break;
504 72934 : case '9' :
505 72934 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
506 72934 : break;
507 0 : case 'a' :
508 : case 'A' :
509 0 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
510 0 : break;
511 0 : case 'b' :
512 : case 'B' :
513 0 : drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
514 0 : break;
515 0 : case 'c' :
516 : case 'C' :
517 0 : drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
518 0 : break;
519 0 : case 'd' :
520 : case 'D' :
521 0 : drawSegments(dc, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE);
522 0 : break;
523 0 : case 'e' :
524 : case 'E' :
525 0 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE);
526 0 : break;
527 0 : case 'f' :
528 : case 'F' :
529 0 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
530 0 : break;
531 0 : case 'g' :
532 : case 'G' :
533 0 : drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE);
534 0 : break;
535 0 : case 'h' :
536 : case 'H' :
537 0 : drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE);
538 0 : break;
539 0 : case 'i' :
540 : case 'I' :
541 0 : drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
542 0 : break;
543 0 : case 'j' :
544 : case 'J' :
545 0 : drawSegments(dc, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE);
546 0 : break;
547 : // case 'k' :
548 : // case 'k' : drawSegments (dc, FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE); break;
549 0 : case 'l' :
550 : case 'L' :
551 0 : drawSegments(dc, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
552 0 : break;
553 : // case 'm' :
554 : // case 'M' : drawSegments (dc, FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE); break;
555 0 : case 'n' :
556 : case 'N' :
557 0 : drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE);
558 0 : break;
559 0 : case 'o' :
560 : case 'O' :
561 0 : drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
562 0 : break;
563 0 : case 'p' :
564 : case 'P' :
565 0 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE);
566 0 : break;
567 0 : case 'q' :
568 : case 'Q' :
569 0 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
570 0 : break;
571 0 : case 'r' :
572 : case 'R' :
573 0 : drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE);
574 0 : break;
575 0 : case 's' :
576 : case 'S' :
577 0 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
578 0 : break;
579 0 : case 't' :
580 : case 'T' :
581 0 : drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
582 0 : break;
583 0 : case 'u' :
584 : case 'U' :
585 0 : drawSegments(dc, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
586 0 : break;
587 : // case 'v' :
588 : // case 'V' : drawSegments (dc, FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE); break;
589 : // case 'w' :
590 : // case 'W' : drawSegments (dc, FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE); break;
591 0 : case 'x' :
592 : case 'X' :
593 0 : drawSegments(dc, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
594 0 : break;
595 0 : case 'y' :
596 : case 'Y' :
597 0 : drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
598 0 : break;
599 : // case 'z' :
600 : // case 'Z' :
601 0 : default :
602 0 : fxerror("MFXSevenSegment doesn't support: %c\n", figure);
603 : }
604 1005510 : }
605 :
606 :
607 : void
608 1969280 : MFXSevenSegment::checkSize() {
609 1969280 : if (myHorizontalSegmentLength < 3) {
610 492320 : myHorizontalSegmentLength = 3;
611 492320 : mySegmentThickness = 1;
612 : }
613 1969280 : if (myVerticalSegmentLength < 3) {
614 0 : myVerticalSegmentLength = 3;
615 0 : mySegmentThickness = 1;
616 : }
617 1969280 : if (mySegmentThickness < 1) {
618 0 : mySegmentThickness = 1;
619 : }
620 1969280 : if (myHorizontalSegmentLength < (mySegmentThickness << 1)) {
621 492320 : myHorizontalSegmentLength = (mySegmentThickness << 1) + 1;
622 : }
623 1969280 : if (myVerticalSegmentLength < (mySegmentThickness << 1)) {
624 0 : myVerticalSegmentLength = (mySegmentThickness << 1) + 1;
625 : }
626 1969280 : if (myHorizontalSegmentLength < 8 || myVerticalSegmentLength < 8) {
627 1969280 : myGroove = 2;
628 : }
629 1969280 : if (myHorizontalSegmentLength < 1 || myVerticalSegmentLength < 3 || mySegmentThickness < 3) {
630 1969280 : myGroove = 1;
631 : }
632 1969280 : if (myGroove >= mySegmentThickness) {
633 984640 : myGroove = mySegmentThickness - 1;
634 : }
635 1969280 : }
|