54 FXMAPFUNC(SEL_PAINT, 0, FXSevenSegment::onPaint),
55 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXSevenSegment::onCmdSetValue),
56 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXSevenSegment::onCmdSetIntValue),
57 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXSevenSegment::onCmdGetIntValue),
58 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXSevenSegment::onCmdSetStringValue),
59 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXSevenSegment::onCmdGetStringValue),
63 FXIMPLEMENT(
FXSevenSegment, FXFrame, FXSevenSegmentMap, ARRAYNUMBER(FXSevenSegmentMap))
66 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) {
73 FXint FXSevenSegment::getDefaultWidth() {
74 return padleft + (groove << 1) + hsl + padright + (border << 1);
78 FXint FXSevenSegment::getDefaultHeight() {
79 return padtop + (groove << 2) + (vsl << 1) + padbottom + (border << 1);
83 void FXSevenSegment::setText(FXchar val) {
84 if (FXString(val, 1).upper() != FXString(value, 1).upper()) {
92 void FXSevenSegment::setFgColor(
const FXColor clr) {
101 void FXSevenSegment::setBgColor(
const FXColor clr) {
102 if (bgcolor != clr) {
110 void FXSevenSegment::setHorizontal(
const FXint len) {
120 void FXSevenSegment::setVertical(
const FXint len) {
130 void FXSevenSegment::setThickness(
const FXint width) {
140 void FXSevenSegment::setGroove(
const FXint width) {
141 if (width != groove) {
142 groove = (FXshort)width;
150 long FXSevenSegment::onPaint(FXObject*, FXSelector,
void* ptr) {
151 FXEvent*
event = (FXEvent*) ptr;
152 FXDCWindow dc(
this, event);
153 drawFrame(dc, 0, 0, width, height);
154 dc.setForeground(bgcolor);
155 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
156 dc.setForeground(fgcolor);
157 drawFigure(dc, value);
162 long FXSevenSegment::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
163 FXchar* c = (FXchar*)ptr;
171 long FXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector,
void*) {
179 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (
void*)&i);
184 long FXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
185 FXint i = *((FXint*)ptr);
197 long FXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector,
void*) {
198 FXString s(value, 1);
199 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&s);
204 long FXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
205 FXString* s = (FXString*)ptr;
213 void FXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
216 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
219 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
222 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
225 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
228 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE);
231 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE);
236 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
241 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
244 drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
247 drawSegments(dc, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
250 drawSegments(dc, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE);
253 drawSegments(dc, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE);
256 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
259 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
262 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
265 drawSegments(dc, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
268 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
271 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
275 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
279 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE);
283 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
287 drawSegments(dc, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE);
291 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE);
295 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
299 drawSegments(dc, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE);
303 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE);
307 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
311 drawSegments(dc, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE);
317 drawSegments(dc, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE);
323 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE);
327 drawSegments(dc, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
331 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE);
335 drawSegments(dc, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE);
339 drawSegments(dc, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE);
343 drawSegments(dc, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE);
347 drawSegments(dc, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
351 drawSegments(dc, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE);
359 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
363 drawSegments(dc, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE);
368 fxerror(
"FXSevenSegment doesnt support: %c\n", figure);
373 void FXSevenSegment::checkSize() {
385 if (hsl < (st << 1)) {
388 if (vsl < (st << 1)) {
391 if (hsl < 8 || vsl < 8) {
394 if (hsl < 1 || vsl < 3 || st < 3) {
404 void FXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
405 FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
407 if (options & LAYOUT_FILL) {
408 if (options & LAYOUT_FILL_X) {
409 hsl = (FXshort)(width - padleft - padright - (border << 1));
414 if (options & LAYOUT_FILL_Y) {
415 vsl = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
420 st = FXMIN(hsl, vsl) / 4;
428 if (options & LAYOUT_FILL_X) {
431 if (options & LAYOUT_FILL_Y) {
438 drawTopSegment(dc, x, y);
443 drawLeftTopSegment(dc, x, y);
446 x = sx + groove + hsl - st + groove;
448 drawRightTopSegment(dc, x, y);
452 y = sy + groove + vsl - (st >> 1) + groove;
453 drawMiddleSegment(dc, x, y);
457 y = sy + (groove << 1) + vsl + groove;
458 drawLeftBottomSegment(dc, x, y);
461 x = sx + groove + hsl - st + groove;
462 y = sy + (groove << 1) + vsl + groove;
463 drawRightBottomSegment(dc, x, y);
467 y = sy + (groove << 1) + vsl + groove + vsl + groove - st;
468 drawBottomSegment(dc, x, y);
472 void FXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
476 points[1].x = x + hsl;
478 points[2].x = x + hsl - st;
479 points[2].y = y + st;
480 points[3].x = x + st;
481 points[3].y = y + st;
482 dc.fillPolygon(points, 4);
485 void FXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
489 points[1].x = x + st;
490 points[1].y = y + st;
491 points[2].x = x + st;
492 points[2].y = y + vsl - (st >> 1);
494 points[3].y = y + vsl;
495 dc.fillPolygon(points, 4);
498 void FXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
500 points[0].x = x + st;
502 points[1].x = x + st;
503 points[1].y = y + vsl;
505 points[2].y = y + vsl - (st >> 1);
507 points[3].y = y + st;
508 dc.fillPolygon(points, 4);
511 void FXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
513 points[0].x = x + st;
515 points[1].x = x + hsl - st;
517 points[2].x = x + hsl;
518 points[2].y = y + (st >> 1);
519 points[3].x = x + hsl - st;
520 points[3].y = y + st;
521 points[4].x = x + st;
522 points[4].y = y + st;
524 points[5].y = y + (st >> 1);
525 dc.fillPolygon(points, 6);
528 void FXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
532 points[1].x = x + st;
533 points[1].y = y + (st >> 1);
534 points[2].x = x + st;
535 points[2].y = y + vsl - st;
537 points[3].y = y + vsl;
538 dc.fillPolygon(points, 4);
541 void FXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
543 points[0].x = x + st;
545 points[1].x = x + st;
546 points[1].y = y + vsl;
548 points[2].y = y + vsl - st;
550 points[3].y = y + (st >> 1);
551 dc.fillPolygon(points, 4);
554 void FXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
556 points[0].x = x + st;
558 points[1].x = x + hsl - st;
560 points[2].x = x + hsl;
561 points[2].y = y + st;
563 points[3].y = y + st;
564 dc.fillPolygon(points, 4);
567 void FXSevenSegment::save(FXStream& store)
const {
568 FXFrame::save(store);
578 void FXSevenSegment::load(FXStream& store) {
579 FXFrame::load(store);
590 long FXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
592 return getParent()->handle(sender, sel, ptr);
598 long FXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
600 return getParent()->handle(sender, sel, ptr);
FXDEFMAP(FXSevenSegment) FXSevenSegmentMap[]