53 FXMAPFUNC(SEL_PAINT, 0, FXSevenSegment::onPaint),
54 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXSevenSegment::onCmdSetValue),
55 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXSevenSegment::onCmdSetIntValue),
56 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXSevenSegment::onCmdGetIntValue),
57 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXSevenSegment::onCmdSetStringValue),
58 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXSevenSegment::onCmdGetStringValue),
62 FXIMPLEMENT(
FXSevenSegment, FXFrame, FXSevenSegmentMap, ARRAYNUMBER(FXSevenSegmentMap))
65 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) {
72 FXint FXSevenSegment::getDefaultWidth() {
73 return padleft + (groove << 1) + hsl + padright + (border << 1);
77 FXint FXSevenSegment::getDefaultHeight() {
78 return padtop + (groove << 2) + (vsl << 1) + padbottom + (border << 1);
82 void FXSevenSegment::setText(FXchar val) {
83 if (FXString(val, 1).upper() != FXString(value, 1).upper()) {
91 void FXSevenSegment::setFgColor(
const FXColor clr) {
100 void FXSevenSegment::setBgColor(
const FXColor clr) {
101 if (bgcolor != clr) {
109 void FXSevenSegment::setHorizontal(
const FXint len) {
119 void FXSevenSegment::setVertical(
const FXint len) {
129 void FXSevenSegment::setThickness(
const FXint width) {
139 void FXSevenSegment::setGroove(
const FXint width) {
140 if (width != groove) {
141 groove = (FXshort)width;
149 long FXSevenSegment::onPaint(FXObject*, FXSelector,
void* ptr) {
150 FXEvent*
event = (FXEvent*) ptr;
151 FXDCWindow dc(
this, event);
152 drawFrame(dc, 0, 0, width, height);
153 dc.setForeground(bgcolor);
154 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
155 dc.setForeground(fgcolor);
156 drawFigure(dc, value);
161 long FXSevenSegment::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
162 FXchar* c = (FXchar*)ptr;
170 long FXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector,
void*) {
178 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (
void*)&i);
183 long FXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
184 FXint i = *((FXint*)ptr);
196 long FXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector,
void*) {
197 FXString s(value, 1);
198 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&s);
203 long FXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
204 FXString* s = (FXString*)ptr;
212 void FXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
215 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
218 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
221 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
224 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
227 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
230 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE);
235 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
240 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
243 drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
246 drawSegments(dc, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
249 drawSegments(dc, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE);
252 drawSegments(dc, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE);
255 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
258 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
261 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
264 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
267 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
270 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
274 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
278 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
282 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
286 drawSegments(dc, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE);
290 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE);
294 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
298 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE);
302 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE);
306 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
310 drawSegments(dc, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE);
316 drawSegments(dc, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
322 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE);
326 drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
330 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE);
334 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
338 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE);
342 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
346 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
350 drawSegments(dc, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
358 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
362 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
367 fxerror(
"FXSevenSegment doesnt support: %c\n", figure);
372 void FXSevenSegment::checkSize() {
384 if (hsl < (st << 1)) {
387 if (vsl < (st << 1)) {
390 if (hsl < 8 || vsl < 8) {
393 if (hsl < 1 || vsl < 3 || st < 3) {
403 void FXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
404 FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
406 if (options & LAYOUT_FILL) {
407 if (options & LAYOUT_FILL_X) {
408 hsl = (FXshort)(width - padleft - padright - (border << 1));
413 if (options & LAYOUT_FILL_Y) {
414 vsl = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
419 st = FXMIN(hsl, vsl) / 4;
427 if (options & LAYOUT_FILL_X) {
430 if (options & LAYOUT_FILL_Y) {
437 drawTopSegment(dc, x, y);
442 drawLeftTopSegment(dc, x, y);
445 x = sx + groove + hsl - st + groove;
447 drawRightTopSegment(dc, x, y);
451 y = sy + groove + vsl - (st >> 1) + groove;
452 drawMiddleSegment(dc, x, y);
456 y = sy + (groove << 1) + vsl + groove;
457 drawLeftBottomSegment(dc, x, y);
460 x = sx + groove + hsl - st + groove;
461 y = sy + (groove << 1) + vsl + groove;
462 drawRightBottomSegment(dc, x, y);
466 y = sy + (groove << 1) + vsl + groove + vsl + groove - st;
467 drawBottomSegment(dc, x, y);
471 void FXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
475 points[1].x = x + hsl;
477 points[2].x = x + hsl - st;
478 points[2].y = y + st;
479 points[3].x = x + st;
480 points[3].y = y + st;
481 dc.fillPolygon(points, 4);
484 void FXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
488 points[1].x = x + st;
489 points[1].y = y + st;
490 points[2].x = x + st;
491 points[2].y = y + vsl - (st >> 1);
493 points[3].y = y + vsl;
494 dc.fillPolygon(points, 4);
497 void FXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
499 points[0].x = x + st;
501 points[1].x = x + st;
502 points[1].y = y + vsl;
504 points[2].y = y + vsl - (st >> 1);
506 points[3].y = y + st;
507 dc.fillPolygon(points, 4);
510 void FXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
512 points[0].x = x + st;
514 points[1].x = x + hsl - st;
516 points[2].x = x + hsl;
517 points[2].y = y + (st >> 1);
518 points[3].x = x + hsl - st;
519 points[3].y = y + st;
520 points[4].x = x + st;
521 points[4].y = y + st;
523 points[5].y = y + (st >> 1);
524 dc.fillPolygon(points, 6);
527 void FXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
531 points[1].x = x + st;
532 points[1].y = y + (st >> 1);
533 points[2].x = x + st;
534 points[2].y = y + vsl - st;
536 points[3].y = y + vsl;
537 dc.fillPolygon(points, 4);
540 void FXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
542 points[0].x = x + st;
544 points[1].x = x + st;
545 points[1].y = y + vsl;
547 points[2].y = y + vsl - st;
549 points[3].y = y + (st >> 1);
550 dc.fillPolygon(points, 4);
553 void FXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
555 points[0].x = x + st;
557 points[1].x = x + hsl - st;
559 points[2].x = x + hsl;
560 points[2].y = y + st;
562 points[3].y = y + st;
563 dc.fillPolygon(points, 4);
566 void FXSevenSegment::save(FXStream& store)
const {
567 FXFrame::save(store);
577 void FXSevenSegment::load(FXStream& store) {
578 FXFrame::load(store);
589 long FXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
591 return getParent()->handle(sender, sel, ptr);
597 long FXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
599 return getParent()->handle(sender, sel, ptr);