61 FXMAPFUNC(SEL_PAINT, 0, FXSevenSegment::onPaint),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXSevenSegment::onCmdSetValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXSevenSegment::onCmdSetIntValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXSevenSegment::onCmdGetIntValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXSevenSegment::onCmdSetStringValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXSevenSegment::onCmdGetStringValue),
70 FXIMPLEMENT(
FXSevenSegment, FXFrame, FXSevenSegmentMap, ARRAYNUMBER(FXSevenSegmentMap))
73 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) {
80 FXint FXSevenSegment::getDefaultWidth() {
81 return padleft + (groove << 1) + hsl + padright + (border << 1);
85 FXint FXSevenSegment::getDefaultHeight() {
86 return padtop + (groove << 2) + (vsl << 1) + padbottom + (border << 1);
90 void FXSevenSegment::setText(FXchar val) {
91 if (FXString(val, 1).upper() != FXString(value, 1).upper()) {
99 void FXSevenSegment::setFgColor(
const FXColor clr) {
100 if (fgcolor != clr) {
108 void FXSevenSegment::setBgColor(
const FXColor clr) {
109 if (bgcolor != clr) {
117 void FXSevenSegment::setHorizontal(
const FXint len) {
127 void FXSevenSegment::setVertical(
const FXint len) {
137 void FXSevenSegment::setThickness(
const FXint width) {
147 void FXSevenSegment::setGroove(
const FXint width) {
148 if (width != groove) {
149 groove = (FXshort)width;
157 long FXSevenSegment::onPaint(FXObject*, FXSelector,
void* ptr) {
158 FXEvent*
event = (FXEvent*) ptr;
159 FXDCWindow dc(
this, event);
160 drawFrame(dc, 0, 0, width, height);
161 dc.setForeground(bgcolor);
162 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
163 dc.setForeground(fgcolor);
164 drawFigure(dc, value);
169 long FXSevenSegment::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
170 FXchar* c = (FXchar*)ptr;
178 long FXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector,
void*) {
186 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (
void*)&i);
191 long FXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
192 FXint i = *((FXint*)ptr);
204 long FXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector,
void*) {
205 FXString s(value, 1);
206 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&s);
211 long FXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
212 FXString* s = (FXString*)ptr;
220 void FXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
223 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
226 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
229 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
232 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
235 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
238 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE);
242 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, FALSE);
246 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
249 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
252 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
255 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE, TRUE);
258 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , FALSE, TRUE , TRUE);
261 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
264 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
267 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
270 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
273 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE);
276 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
280 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
284 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
288 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
292 drawSegments(dc, FALSE, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE);
296 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, TRUE);
300 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
304 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , TRUE , TRUE);
308 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE);
312 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE , FALSE);
316 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE);
322 drawSegments(dc, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
328 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , TRUE , FALSE);
332 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
336 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE, FALSE);
340 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
344 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , FALSE, FALSE);
348 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
352 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
356 drawSegments(dc, FALSE, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
364 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
368 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
373 fxerror(
"FXSevenSegment doesnt support: %c\n", figure);
378 void FXSevenSegment::checkSize() {
390 if (hsl < (st << 1)) {
393 if (vsl < (st << 1)) {
396 if (hsl < 8 || vsl < 8) {
399 if (hsl < 1 || vsl < 3 || st < 3) {
409 void FXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
410 FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
412 if (options & LAYOUT_FILL) {
413 if (options & LAYOUT_FILL_X) {
414 hsl = (FXshort)(width - padleft - padright - (border << 1));
419 if (options & LAYOUT_FILL_Y) {
420 vsl = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
425 st = FXMIN(hsl, vsl) / 4;
433 if (options & LAYOUT_FILL_X) {
436 if (options & LAYOUT_FILL_Y) {
443 drawTopSegment(dc, x, y);
448 drawLeftTopSegment(dc, x, y);
451 x = sx + groove + hsl - st + groove;
453 drawRightTopSegment(dc, x, y);
457 y = sy + groove + vsl - (st >> 1) + groove;
458 drawMiddleSegment(dc, x, y);
462 y = sy + (groove << 1) + vsl + groove;
463 drawLeftBottomSegment(dc, x, y);
466 x = sx + groove + hsl - st + groove;
467 y = sy + (groove << 1) + vsl + groove;
468 drawRightBottomSegment(dc, x, y);
472 y = sy + (groove << 1) + vsl + groove + vsl + groove - st;
473 drawBottomSegment(dc, x, y);
477 void FXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
481 points[1].x = x + hsl;
483 points[2].x = x + hsl - st;
484 points[2].y = y + st;
485 points[3].x = x + st;
486 points[3].y = y + st;
487 dc.fillPolygon(points, 4);
490 void FXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
494 points[1].x = x + st;
495 points[1].y = y + st;
496 points[2].x = x + st;
497 points[2].y = y + vsl - (st >> 1);
499 points[3].y = y + vsl;
500 dc.fillPolygon(points, 4);
503 void FXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
505 points[0].x = x + st;
507 points[1].x = x + st;
508 points[1].y = y + vsl;
510 points[2].y = y + vsl - (st >> 1);
512 points[3].y = y + st;
513 dc.fillPolygon(points, 4);
516 void FXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
518 points[0].x = x + st;
520 points[1].x = x + hsl - st;
522 points[2].x = x + hsl;
523 points[2].y = y + (st >> 1);
524 points[3].x = x + hsl - st;
525 points[3].y = y + st;
526 points[4].x = x + st;
527 points[4].y = y + st;
529 points[5].y = y + (st >> 1);
530 dc.fillPolygon(points, 6);
533 void FXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
537 points[1].x = x + st;
538 points[1].y = y + (st >> 1);
539 points[2].x = x + st;
540 points[2].y = y + vsl - st;
542 points[3].y = y + vsl;
543 dc.fillPolygon(points, 4);
546 void FXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
548 points[0].x = x + st;
550 points[1].x = x + st;
551 points[1].y = y + vsl;
553 points[2].y = y + vsl - st;
555 points[3].y = y + (st >> 1);
556 dc.fillPolygon(points, 4);
559 void FXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
561 points[0].x = x + st;
563 points[1].x = x + hsl - st;
565 points[2].x = x + hsl;
566 points[2].y = y + st;
568 points[3].y = y + st;
569 dc.fillPolygon(points, 4);
572 void FXSevenSegment::save(FXStream& store)
const {
573 FXFrame::save(store);
583 void FXSevenSegment::load(FXStream& store) {
584 FXFrame::load(store);
595 long FXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
597 return getParent()->handle(sender, sel, ptr);
603 long FXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
605 return getParent()->handle(sender, sel, ptr);
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]