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 124041095 : FXIMPLEMENT(MFXSevenSegment, FXFrame, MFXSevenSegmentMap, ARRAYNUMBER(MFXSevenSegmentMap))
49 :
50 :
51 : // ===========================================================================
52 : // method definitions
53 : // ===========================================================================
54 :
55 546040 : 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 546040 : myValue(' '),
58 546040 : myLCDTextColor(FXRGB(0, 255, 0)),
59 546040 : myBackGroundColor(GUIDesignTextColorBlack),
60 546040 : myHorizontalSegmentLength(8),
61 546040 : myVerticalSegmentLength(8),
62 546040 : mySegmentThickness(3),
63 546040 : myGroove(1) {
64 : setTarget(tgt);
65 : setSelector(sel);
66 546040 : enable();
67 546040 : }
68 :
69 :
70 : FXint
71 6861990 : MFXSevenSegment::getDefaultWidth() {
72 6861990 : return padleft + (myGroove << 1) + myHorizontalSegmentLength + padright + (border << 1);
73 : }
74 :
75 :
76 : FXint
77 6536532 : MFXSevenSegment::getDefaultHeight() {
78 6536532 : return padtop + (myGroove << 2) + (myVerticalSegmentLength << 1) + padbottom + (border << 1);
79 : }
80 :
81 :
82 : void
83 15991216 : MFXSevenSegment::setText(FXchar val) {
84 15991216 : if (FXString(val, 1).upper() != FXString(myValue, 1).upper()) {
85 1350772 : myValue = val;
86 1350772 : recalc();
87 1350772 : update();
88 : }
89 15991216 : }
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 546040 : MFXSevenSegment::setHorizontal(const FXint len) {
114 546040 : if (len != myHorizontalSegmentLength) {
115 546040 : myHorizontalSegmentLength = (FXshort)len;
116 546040 : checkSize();
117 546040 : recalc();
118 546040 : update();
119 : }
120 546040 : }
121 :
122 :
123 : void
124 546040 : MFXSevenSegment::setVertical(const FXint len) {
125 546040 : if (len != myVerticalSegmentLength) {
126 546040 : myVerticalSegmentLength = (FXshort)len;
127 546040 : checkSize();
128 546040 : recalc();
129 546040 : update();
130 : }
131 546040 : }
132 :
133 :
134 : void
135 546040 : MFXSevenSegment::setThickness(const FXint w) {
136 546040 : if (w != mySegmentThickness) {
137 546040 : mySegmentThickness = (FXshort)w;
138 546040 : checkSize();
139 546040 : recalc();
140 546040 : update();
141 : }
142 546040 : }
143 :
144 :
145 : void
146 546040 : MFXSevenSegment::setGroove(const FXint w) {
147 546040 : if (w != myGroove) {
148 546040 : myGroove = (FXshort)w;
149 546040 : checkSize();
150 546040 : recalc();
151 546040 : update();
152 : }
153 546040 : }
154 :
155 :
156 : long
157 1341886 : MFXSevenSegment::onPaint(FXObject*, FXSelector, void* ptr) {
158 : FXEvent* event = (FXEvent*) ptr;
159 1341886 : FXDCWindow dc(this, event);
160 1341886 : drawFrame(dc, 0, 0, width, height);
161 1341886 : dc.setForeground(myBackGroundColor);
162 1341886 : dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
163 1341886 : dc.setForeground(myLCDTextColor);
164 1341886 : drawFigure(dc, myValue);
165 1341886 : return 1;
166 1341886 : }
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 905982 : MFXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
271 : FXPoint points[4];
272 905982 : points[0].x = x;
273 905982 : points[0].y = y;
274 905982 : points[1].x = x + myHorizontalSegmentLength;
275 905982 : points[1].y = y;
276 905982 : points[2].x = x + myHorizontalSegmentLength - mySegmentThickness;
277 905982 : points[2].y = y + mySegmentThickness;
278 905982 : points[3].x = x + mySegmentThickness;
279 905982 : points[3].y = y + mySegmentThickness;
280 905982 : dc.fillPolygon(points, 4);
281 905982 : }
282 :
283 :
284 : void
285 693259 : MFXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
286 : FXPoint points[4];
287 693259 : points[0].x = x;
288 693259 : points[0].y = y;
289 693259 : points[1].x = x + mySegmentThickness;
290 693259 : points[1].y = y + mySegmentThickness;
291 693259 : points[2].x = x + mySegmentThickness;
292 693259 : points[2].y = y + myVerticalSegmentLength - (mySegmentThickness >> 1);
293 693259 : points[3].x = x;
294 693259 : points[3].y = y + myVerticalSegmentLength;
295 693259 : dc.fillPolygon(points, 4);
296 693259 : }
297 :
298 :
299 : void
300 889181 : MFXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
301 : FXPoint points[4];
302 889181 : points[0].x = x + mySegmentThickness;
303 889181 : points[0].y = y;
304 889181 : points[1].x = x + mySegmentThickness;
305 889181 : points[1].y = y + myVerticalSegmentLength;
306 889181 : points[2].x = x;
307 889181 : points[2].y = y + myVerticalSegmentLength - (mySegmentThickness >> 1);
308 889181 : points[3].x = x;
309 889181 : points[3].y = y + mySegmentThickness;
310 889181 : dc.fillPolygon(points, 4);
311 889181 : }
312 :
313 :
314 : void
315 890334 : MFXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
316 : FXPoint points[6];
317 890334 : points[0].x = x + mySegmentThickness;
318 890334 : points[0].y = y;
319 890334 : points[1].x = x + myHorizontalSegmentLength - mySegmentThickness;
320 890334 : points[1].y = y;
321 890334 : points[2].x = x + myHorizontalSegmentLength;
322 890334 : points[2].y = y + (mySegmentThickness >> 1);
323 890334 : points[3].x = x + myHorizontalSegmentLength - mySegmentThickness;
324 890334 : points[3].y = y + mySegmentThickness;
325 890334 : points[4].x = x + mySegmentThickness;
326 890334 : points[4].y = y + mySegmentThickness;
327 890334 : points[5].x = x;
328 890334 : points[5].y = y + (mySegmentThickness >> 1);
329 890334 : dc.fillPolygon(points, 6);
330 890334 : }
331 :
332 :
333 : void
334 473695 : MFXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
335 : FXPoint points[4];
336 473695 : points[0].x = x;
337 473695 : points[0].y = y;
338 473695 : points[1].x = x + mySegmentThickness;
339 473695 : points[1].y = y + (mySegmentThickness >> 1);
340 473695 : points[2].x = x + mySegmentThickness;
341 473695 : points[2].y = y + myVerticalSegmentLength - mySegmentThickness;
342 473695 : points[3].x = x;
343 473695 : points[3].y = y + myVerticalSegmentLength;
344 473695 : dc.fillPolygon(points, 4);
345 473695 : }
346 :
347 :
348 : void
349 1005165 : MFXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
350 : FXPoint points[4];
351 1005165 : points[0].x = x + mySegmentThickness;
352 1005165 : points[0].y = y;
353 1005165 : points[1].x = x + mySegmentThickness;
354 1005165 : points[1].y = y + myVerticalSegmentLength;
355 1005165 : points[2].x = x;
356 1005165 : points[2].y = y + myVerticalSegmentLength - mySegmentThickness;
357 1005165 : points[3].x = x;
358 1005165 : points[3].y = y + (mySegmentThickness >> 1);
359 1005165 : dc.fillPolygon(points, 4);
360 1005165 : }
361 :
362 :
363 : void
364 800979 : MFXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
365 : FXPoint points[4];
366 800979 : points[0].x = x + mySegmentThickness;
367 800979 : points[0].y = y;
368 800979 : points[1].x = x + myHorizontalSegmentLength - mySegmentThickness;
369 800979 : points[1].y = y;
370 800979 : points[2].x = x + myHorizontalSegmentLength;
371 800979 : points[2].y = y + mySegmentThickness;
372 800979 : points[3].x = x;
373 800979 : points[3].y = y + mySegmentThickness;
374 800979 : dc.fillPolygon(points, 4);
375 800979 : }
376 :
377 :
378 : void
379 1341886 : MFXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
380 1341886 : FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
381 : FXshort x, y;
382 1341886 : 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 1341886 : if (s1) {
411 905982 : x = sx + myGroove;
412 : y = sy;
413 905982 : drawTopSegment(dc, x, y);
414 : }
415 1341886 : if (s2) {
416 : x = sx;
417 693259 : y = sy + myGroove;
418 693259 : drawLeftTopSegment(dc, x, y);
419 : }
420 1341886 : if (s3) {
421 889181 : x = sx + myGroove + myHorizontalSegmentLength - mySegmentThickness + myGroove;
422 889181 : y = sy + myGroove;
423 889181 : drawRightTopSegment(dc, x, y);
424 : }
425 1341886 : if (s4) {
426 890334 : x = sx + myGroove;
427 890334 : y = sy + myGroove + myVerticalSegmentLength - (mySegmentThickness >> 1) + myGroove;
428 890334 : drawMiddleSegment(dc, x, y);
429 : }
430 1341886 : if (s5) {
431 : x = sx;
432 473695 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove;
433 473695 : drawLeftBottomSegment(dc, x, y);
434 : }
435 1341886 : if (s6) {
436 1005165 : x = sx + myGroove + myHorizontalSegmentLength - mySegmentThickness + myGroove;
437 1005165 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove;
438 1005165 : drawRightBottomSegment(dc, x, y);
439 : }
440 1341886 : if (s7) {
441 800979 : x = sx + myGroove;
442 800979 : y = sy + (myGroove << 1) + myVerticalSegmentLength + myGroove + myVerticalSegmentLength + myGroove - mySegmentThickness;
443 800979 : drawBottomSegment(dc, x, y);
444 : }
445 1341886 : }
446 :
447 :
448 : void
449 1341886 : MFXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
450 1341886 : switch (figure) {
451 95667 : case ' ' :
452 95667 : drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
453 95667 : 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 126469 : case '-' :
471 : case ':' :
472 126469 : drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
473 126469 : break;
474 740 : case '_' :
475 : case '.' :
476 : case ',' :
477 740 : drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
478 740 : break;
479 144659 : case '0' :
480 144659 : drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
481 144659 : break;
482 104743 : case '1' :
483 104743 : drawSegments(dc, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
484 104743 : break;
485 113845 : case '2' :
486 113845 : drawSegments(dc, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE);
487 113845 : break;
488 101420 : case '3' :
489 101420 : drawSegments(dc, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE);
490 101420 : break;
491 108285 : case '4' :
492 108285 : drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
493 108285 : break;
494 122551 : case '5' :
495 122551 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
496 122551 : break;
497 107278 : case '6' :
498 107278 : drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
499 107278 : break;
500 105743 : case '7' :
501 105743 : drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
502 105743 : break;
503 107913 : case '8' :
504 107913 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
505 107913 : break;
506 102573 : case '9' :
507 102573 : drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
508 102573 : 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 1341886 : }
607 :
608 :
609 : void
610 2184160 : MFXSevenSegment::checkSize() {
611 2184160 : if (myHorizontalSegmentLength < 3) {
612 546040 : myHorizontalSegmentLength = 3;
613 546040 : mySegmentThickness = 1;
614 : }
615 2184160 : if (myVerticalSegmentLength < 3) {
616 0 : myVerticalSegmentLength = 3;
617 0 : mySegmentThickness = 1;
618 : }
619 2184160 : if (mySegmentThickness < 1) {
620 0 : mySegmentThickness = 1;
621 : }
622 2184160 : if (myHorizontalSegmentLength < (mySegmentThickness << 1)) {
623 546040 : myHorizontalSegmentLength = (mySegmentThickness << 1) + 1;
624 : }
625 2184160 : if (myVerticalSegmentLength < (mySegmentThickness << 1)) {
626 0 : myVerticalSegmentLength = (mySegmentThickness << 1) + 1;
627 : }
628 2184160 : if (myHorizontalSegmentLength < 8 || myVerticalSegmentLength < 8) {
629 2184160 : myGroove = 2;
630 : }
631 2184160 : if (myHorizontalSegmentLength < 1 || myVerticalSegmentLength < 3 || mySegmentThickness < 3) {
632 2184160 : myGroove = 1;
633 : }
634 2184160 : if (myGroove >= mySegmentThickness) {
635 1092080 : myGroove = mySegmentThickness - 1;
636 : }
637 2184160 : }
|