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