51 #ifdef CHECK_MEMORY_LEAKS
53 #endif // CHECK_MEMORY_LEAKS
62 FXMAPFUNC(SEL_PAINT, 0, FXSevenSegment::onPaint),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXSevenSegment::onCmdSetValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXSevenSegment::onCmdSetIntValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXSevenSegment::onCmdGetIntValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXSevenSegment::onCmdSetStringValue),
67 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXSevenSegment::onCmdGetStringValue),
71 FXIMPLEMENT(
FXSevenSegment, FXFrame, FXSevenSegmentMap, ARRAYNUMBER(FXSevenSegmentMap))
74 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) {
81 FXint FXSevenSegment::getDefaultWidth() {
82 return padleft + (groove << 1) + hsl + padright + (border << 1);
86 FXint FXSevenSegment::getDefaultHeight() {
87 return padtop + (groove << 2) + (vsl << 1) + padbottom + (border << 1);
91 void FXSevenSegment::setText(FXchar val) {
92 if (FXString(val, 1).upper() != FXString(value, 1).upper()) {
100 void FXSevenSegment::setFgColor(
const FXColor clr) {
101 if (fgcolor != clr) {
109 void FXSevenSegment::setBgColor(
const FXColor clr) {
110 if (bgcolor != clr) {
118 void FXSevenSegment::setHorizontal(
const FXint len) {
128 void FXSevenSegment::setVertical(
const FXint len) {
138 void FXSevenSegment::setThickness(
const FXint width) {
148 void FXSevenSegment::setGroove(
const FXint width) {
149 if (width != groove) {
150 groove = (FXshort)width;
158 long FXSevenSegment::onPaint(FXObject*, FXSelector,
void* ptr) {
159 FXEvent*
event = (FXEvent*) ptr;
160 FXDCWindow dc(
this, event);
161 drawFrame(dc, 0, 0, width, height);
162 dc.setForeground(bgcolor);
163 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
164 dc.setForeground(fgcolor);
165 drawFigure(dc, value);
170 long FXSevenSegment::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
171 FXchar* c = (FXchar*)ptr;
179 long FXSevenSegment::onCmdGetIntValue(FXObject* sender, FXSelector,
void*) {
187 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETINTVALUE), (
void*)&i);
192 long FXSevenSegment::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
193 FXint i = *((FXint*)ptr);
205 long FXSevenSegment::onCmdGetStringValue(FXObject* sender, FXSelector,
void*) {
206 FXString s(value, 1);
207 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&s);
212 long FXSevenSegment::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
213 FXString* s = (FXString*)ptr;
221 void FXSevenSegment::drawFigure(FXDCWindow& dc, FXchar figure) {
224 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
227 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
230 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
233 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
236 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , TRUE);
239 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE);
243 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , FALSE, FALSE, FALSE);
247 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
250 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
253 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
256 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE, TRUE);
259 drawSegments(dc, TRUE , FALSE, TRUE , TRUE , FALSE, TRUE , TRUE);
262 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
265 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
268 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
271 drawSegments(dc, TRUE , FALSE, TRUE , FALSE, FALSE, TRUE , FALSE);
274 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE);
277 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
281 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
285 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , TRUE);
289 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
293 drawSegments(dc, FALSE, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE);
297 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, TRUE);
301 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
305 drawSegments(dc, TRUE , TRUE , FALSE, FALSE, TRUE , TRUE , TRUE);
309 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE , FALSE);
313 drawSegments(dc, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE , FALSE);
317 drawSegments(dc, FALSE, FALSE, TRUE , FALSE, TRUE , TRUE , TRUE);
323 drawSegments(dc, FALSE, TRUE , FALSE, FALSE, TRUE , FALSE, TRUE);
329 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , TRUE , FALSE);
333 drawSegments(dc, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
337 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE, FALSE);
341 drawSegments(dc, TRUE , TRUE , TRUE , TRUE , FALSE, TRUE , FALSE);
345 drawSegments(dc, FALSE, FALSE, FALSE, TRUE , TRUE , FALSE, FALSE);
349 drawSegments(dc, TRUE , TRUE , FALSE, TRUE , FALSE, TRUE , TRUE);
353 drawSegments(dc, FALSE, TRUE , FALSE, TRUE , TRUE , FALSE, FALSE);
357 drawSegments(dc, FALSE, TRUE , TRUE , FALSE, TRUE , TRUE , TRUE);
365 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , TRUE , TRUE , FALSE);
369 drawSegments(dc, FALSE, TRUE , TRUE , TRUE , FALSE, TRUE , TRUE);
374 fxerror(
"FXSevenSegment doesnt support: %c\n", figure);
379 void FXSevenSegment::checkSize() {
391 if (hsl < (st << 1)) {
394 if (vsl < (st << 1)) {
397 if (hsl < 8 || vsl < 8) {
400 if (hsl < 1 || vsl < 3 || st < 3) {
410 void FXSevenSegment::drawSegments(FXDCWindow& dc, FXbool s1, FXbool s2, FXbool s3, FXbool s4, FXbool s5, FXbool s6, FXbool s7) {
411 FXshort sx = (FXshort)(border + padleft), sy = (FXshort)(border + padtop);
413 if (options & LAYOUT_FILL) {
414 if (options & LAYOUT_FILL_X) {
415 hsl = (FXshort)(width - padleft - padright - (border << 1));
420 if (options & LAYOUT_FILL_Y) {
421 vsl = (FXshort)(height - padtop - padbottom - (border << 1)) >> 1;
426 st = FXMIN(hsl, vsl) / 4;
434 if (options & LAYOUT_FILL_X) {
437 if (options & LAYOUT_FILL_Y) {
444 drawTopSegment(dc, x, y);
449 drawLeftTopSegment(dc, x, y);
452 x = sx + groove + hsl - st + groove;
454 drawRightTopSegment(dc, x, y);
458 y = sy + groove + vsl - (st >> 1) + groove;
459 drawMiddleSegment(dc, x, y);
463 y = sy + (groove << 1) + vsl + groove;
464 drawLeftBottomSegment(dc, x, y);
467 x = sx + groove + hsl - st + groove;
468 y = sy + (groove << 1) + vsl + groove;
469 drawRightBottomSegment(dc, x, y);
473 y = sy + (groove << 1) + vsl + groove + vsl + groove - st;
474 drawBottomSegment(dc, x, y);
478 void FXSevenSegment::drawTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
482 points[1].x = x + hsl;
484 points[2].x = x + hsl - st;
485 points[2].y = y + st;
486 points[3].x = x + st;
487 points[3].y = y + st;
488 dc.fillPolygon(points, 4);
491 void FXSevenSegment::drawLeftTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
495 points[1].x = x + st;
496 points[1].y = y + st;
497 points[2].x = x + st;
498 points[2].y = y + vsl - (st >> 1);
500 points[3].y = y + vsl;
501 dc.fillPolygon(points, 4);
504 void FXSevenSegment::drawRightTopSegment(FXDCWindow& dc, FXshort x, FXshort y) {
506 points[0].x = x + st;
508 points[1].x = x + st;
509 points[1].y = y + vsl;
511 points[2].y = y + vsl - (st >> 1);
513 points[3].y = y + st;
514 dc.fillPolygon(points, 4);
517 void FXSevenSegment::drawMiddleSegment(FXDCWindow& dc, FXshort x, FXshort y) {
519 points[0].x = x + st;
521 points[1].x = x + hsl - st;
523 points[2].x = x + hsl;
524 points[2].y = y + (st >> 1);
525 points[3].x = x + hsl - st;
526 points[3].y = y + st;
527 points[4].x = x + st;
528 points[4].y = y + st;
530 points[5].y = y + (st >> 1);
531 dc.fillPolygon(points, 6);
534 void FXSevenSegment::drawLeftBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
538 points[1].x = x + st;
539 points[1].y = y + (st >> 1);
540 points[2].x = x + st;
541 points[2].y = y + vsl - st;
543 points[3].y = y + vsl;
544 dc.fillPolygon(points, 4);
547 void FXSevenSegment::drawRightBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
549 points[0].x = x + st;
551 points[1].x = x + st;
552 points[1].y = y + vsl;
554 points[2].y = y + vsl - st;
556 points[3].y = y + (st >> 1);
557 dc.fillPolygon(points, 4);
560 void FXSevenSegment::drawBottomSegment(FXDCWindow& dc, FXshort x, FXshort y) {
562 points[0].x = x + st;
564 points[1].x = x + hsl - st;
566 points[2].x = x + hsl;
567 points[2].y = y + st;
569 points[3].y = y + st;
570 dc.fillPolygon(points, 4);
573 void FXSevenSegment::save(FXStream& store)
const {
574 FXFrame::save(store);
596 long FXSevenSegment::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
598 return getParent()->handle(sender, sel, ptr);
604 long FXSevenSegment::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
606 return getParent()->handle(sender, sel, ptr);
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]
MSNet * load(OptionsCont &oc)