59 FXMAPFUNC(SEL_PAINT, 0, FXSevenSegment::onPaint),
60 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXSevenSegment::onCmdSetValue),
61 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXSevenSegment::onCmdSetIntValue),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXSevenSegment::onCmdGetIntValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXSevenSegment::onCmdSetStringValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXSevenSegment::onCmdGetStringValue),
68 FXIMPLEMENT(
FXSevenSegment, FXFrame, FXSevenSegmentMap, ARRAYNUMBER(FXSevenSegmentMap))
71 FXSevenSegment::
FXSevenSegment(FXComposite* p, FXObject* tgt, FXSelector sel, FXuint opts, FXint pl, FXint pr, FXint pt, FXint pb) : FXFrame(p, opts, 0, 0, 0, 0, pl, pr, pt, pb), value(' '), fgcolor(FXRGB(0, 255, 0)), bgcolor(FXRGB(0, 0, 0)), hsl(8), vsl(8), st(3), groove(1) {
78 FXint FXSevenSegment::getDefaultWidth() {
79 return padleft + (groove << 1) + hsl + padright + (border << 1);
83 FXint FXSevenSegment::getDefaultHeight() {
84 return padtop + (groove << 2) + (vsl << 1) + padbottom + (border << 1);
88 void FXSevenSegment::setText(FXchar val) {
89 if (FXString(val, 1).upper() != FXString(value, 1).upper()) {
97 void FXSevenSegment::setFgColor(
const FXColor clr) {
106 void FXSevenSegment::setBgColor(
const FXColor clr) {
107 if (bgcolor != clr) {
115 void FXSevenSegment::setHorizontal(
const FXint len) {
125 void FXSevenSegment::setVertical(
const FXint len) {
135 void FXSevenSegment::setThickness(
const FXint width) {
145 void FXSevenSegment::setGroove(
const FXint width) {
146 if (width != groove) {
147 groove = (FXshort)width;
155 long FXSevenSegment::onPaint(FXObject*, FXSelector,
void* ptr) {
156 FXEvent*
event = (FXEvent*) ptr;
157 FXDCWindow dc(
this, event);
158 drawFrame(dc, 0, 0, width, height);
159 dc.setForeground(bgcolor);
160 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
161 dc.setForeground(fgcolor);
162 drawFigure(dc, value);
167 long FXSevenSegment::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
168 FXchar* c = (FXchar*)ptr;
176 long FXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector,
void*) {
184 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (
void*)&i);
189 long FXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
190 FXint i = *((FXint*)ptr);
202 long FXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector,
void*) {
203 FXString s(value, 1);
204 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&s);
209 long FXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
210 FXString* s = (FXString*)ptr;
218 void FXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
221 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
224 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
227 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
230 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
233 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
236 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE);
240 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, FALSE);
244 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
247 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
250 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
253 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE, TRUE);
256 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , FALSE, TRUE , TRUE);
259 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
262 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
265 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
268 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
271 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE);
274 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
278 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
282 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
286 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
290 drawSegments(dc, FALSE, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE);
294 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, TRUE);
298 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
302 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , TRUE , TRUE);
306 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE);
310 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE , FALSE);
314 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE);
320 drawSegments(dc, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
326 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , TRUE , FALSE);
330 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
334 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE, FALSE);
338 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
342 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , FALSE, FALSE);
346 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
350 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
354 drawSegments(dc, FALSE, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
362 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
366 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
371 fxerror(
"FXSevenSegment doesnt support: %c\n", figure);
376 void FXSevenSegment::checkSize() {
388 if (hsl < (st << 1)) {
391 if (vsl < (st << 1)) {
394 if (hsl < 8 || vsl < 8) {
397 if (hsl < 1 || vsl < 3 || st < 3) {
407 void FXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
408 FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
410 if (options & LAYOUT_FILL) {
411 if (options & LAYOUT_FILL_X) {
412 hsl = (FXshort)(width - padleft - padright - (border << 1));
417 if (options & LAYOUT_FILL_Y) {
418 vsl = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
423 st = FXMIN(hsl, vsl) / 4;
431 if (options & LAYOUT_FILL_X) {
434 if (options & LAYOUT_FILL_Y) {
441 drawTopSegment(dc, x, y);
446 drawLeftTopSegment(dc, x, y);
449 x = sx + groove + hsl - st + groove;
451 drawRightTopSegment(dc, x, y);
455 y = sy + groove + vsl - (st >> 1) + groove;
456 drawMiddleSegment(dc, x, y);
460 y = sy + (groove << 1) + vsl + groove;
461 drawLeftBottomSegment(dc, x, y);
464 x = sx + groove + hsl - st + groove;
465 y = sy + (groove << 1) + vsl + groove;
466 drawRightBottomSegment(dc, x, y);
470 y = sy + (groove << 1) + vsl + groove + vsl + groove - st;
471 drawBottomSegment(dc, x, y);
475 void FXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
479 points[1].x = x + hsl;
481 points[2].x = x + hsl - st;
482 points[2].y = y + st;
483 points[3].x = x + st;
484 points[3].y = y + st;
485 dc.fillPolygon(points, 4);
488 void FXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
492 points[1].x = x + st;
493 points[1].y = y + st;
494 points[2].x = x + st;
495 points[2].y = y + vsl - (st >> 1);
497 points[3].y = y + vsl;
498 dc.fillPolygon(points, 4);
501 void FXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
503 points[0].x = x + st;
505 points[1].x = x + st;
506 points[1].y = y + vsl;
508 points[2].y = y + vsl - (st >> 1);
510 points[3].y = y + st;
511 dc.fillPolygon(points, 4);
514 void FXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
516 points[0].x = x + st;
518 points[1].x = x + hsl - st;
520 points[2].x = x + hsl;
521 points[2].y = y + (st >> 1);
522 points[3].x = x + hsl - st;
523 points[3].y = y + st;
524 points[4].x = x + st;
525 points[4].y = y + st;
527 points[5].y = y + (st >> 1);
528 dc.fillPolygon(points, 6);
531 void FXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
535 points[1].x = x + st;
536 points[1].y = y + (st >> 1);
537 points[2].x = x + st;
538 points[2].y = y + vsl - st;
540 points[3].y = y + vsl;
541 dc.fillPolygon(points, 4);
544 void FXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
546 points[0].x = x + st;
548 points[1].x = x + st;
549 points[1].y = y + vsl;
551 points[2].y = y + vsl - st;
553 points[3].y = y + (st >> 1);
554 dc.fillPolygon(points, 4);
557 void FXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
559 points[0].x = x + st;
561 points[1].x = x + hsl - st;
563 points[2].x = x + hsl;
564 points[2].y = y + st;
566 points[3].y = y + st;
567 dc.fillPolygon(points, 4);
570 void FXSevenSegment::save(FXStream& store)
const {
571 FXFrame::save(store);
581 void FXSevenSegment::load(FXStream& store) {
582 FXFrame::load(store);
593 long FXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
595 return getParent()->handle(sender, sel, ptr);
601 long FXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
603 return getParent()->handle(sender, sel, ptr);
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]