57 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
58 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
59 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
60 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
61 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
67 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
69 FXIMPLEMENT(
FXLCDLabel, FXHorizontalFrame, FXLCDLabelMap, ARRAYNUMBER(FXLCDLabelMap))
71 FXLCDLabel::
FXLCDLabel(FXComposite* p, FXuint nfig, FXObject* tgt, FXSelector sel, FXuint opts, FXint pl, FXint pr, FXint pt, FXint pb, FXint hs) : FXHorizontalFrame(p, opts, 0, 0, 0, 0, pl, pr, pt, pb, hs, 0) {
73 fxerror(
"%s: must have at least one figure.\n", getClassName());
79 for (FXint i = 0; i < nfigures; i++) {
84 FXLCDLabel::~FXLCDLabel() {
93 void FXLCDLabel::create() {
94 FXHorizontalFrame::create();
95 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
101 void FXLCDLabel::detach() {
102 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
105 FXHorizontalFrame::detach();
109 void FXLCDLabel::destroy() {
110 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
113 FXHorizontalFrame::destroy();
117 FXColor FXLCDLabel::getFgColor()
const {
123 void FXLCDLabel::setFgColor(FXColor clr) {
133 FXColor FXLCDLabel::getBgColor()
const {
139 void FXLCDLabel::setBgColor(FXColor clr) {
149 void FXLCDLabel::setText(FXString lbl) {
158 FXint FXLCDLabel::getHorizontal()
const {
164 void FXLCDLabel::setHorizontal(
const FXint len) {
176 FXint FXLCDLabel::getVertical()
const {
182 void FXLCDLabel::setVertical(
const FXint len) {
194 FXint FXLCDLabel::getThickness()
const {
200 void FXLCDLabel::setThickness(
const FXint width) {
212 FXint FXLCDLabel::getGroove()
const {
218 void FXLCDLabel::setGroove(
const FXint width) {
230 long FXLCDLabel::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
231 setText((
const FXchar*)ptr);
236 long FXLCDLabel::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
237 setText(FXStringVal(*((FXint*)ptr)));
242 long FXLCDLabel::onCmdSetRealValue(FXObject*, FXSelector,
void* ptr) {
243 setText(FXStringVal(*((FXdouble*)ptr)));
248 long FXLCDLabel::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
249 setText(*((FXString*)ptr));
254 long FXLCDLabel::onCmdGetIntValue(FXObject*, FXSelector,
void* ptr) {
255 *((FXint*)ptr) = FXIntVal(getText());
260 long FXLCDLabel::onCmdGetRealValue(FXObject*, FXSelector,
void* ptr) {
261 *((FXdouble*)ptr) = FXDoubleVal(getText());
266 long FXLCDLabel::onCmdGetStringValue(FXObject*, FXSelector,
void* ptr) {
267 *((FXString*)ptr) = getText();
272 long FXLCDLabel::onPaint(FXObject*, FXSelector,
void* ptr) {
273 FXEvent*
event = (FXEvent*) ptr;
274 FXDCWindow dc(
this, event);
275 drawFrame(dc, 0, 0, width, height);
279 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
287 void FXLCDLabel::drawString(
const FXString& lbl) {
289 FXString displayString(
' ', nfigures);
293 displayString.replace(0,
'-');
297 for (; (i + txt.length()) < nfigures; i++) {
298 displayString.replace(i,
'0');
300 displayString.insert(i, txt);
301 }
else if (options & JUSTIFY_RIGHT) {
302 for (; (i + lbl.length()) < nfigures; i++) {}
303 displayString.insert(i, lbl);
305 displayString.insert(0, lbl);
307 displayString.trunc(nfigures);
315 if (options & LAYOUT_FILL) {
316 FXint width = this->width - padleft - padright - (border << 1);
317 FXint height = this->height - padtop - padbottom - (border << 1);
318 hspacing = FXMAX(width, height) / 50;
322 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
326 FXint vsl = height >> 1;
330 FXint st = FXMIN(hsl, vsl) / 4;
334 FXint groove = st / 4;
338 if (options & LAYOUT_FILL_X) {
345 if (options & LAYOUT_FILL_Y) {
353 child->
setText(displayString[i++]);
359 child->
setText(displayString[i++]);
365 long FXLCDLabel::onRedirectEvent(FXObject*, FXSelector sel,
void* ptr) {
366 FXuint seltype = FXSELTYPE(sel);
369 target->handle(
this, FXSEL(seltype, message), ptr);
376 FXint FXLCDLabel::getDefaultWidth() {
377 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
381 FXint FXLCDLabel::getDefaultHeight() {
382 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
386 void FXLCDLabel::save(FXStream& store)
const {
387 FXHorizontalFrame::save(store);
393 void FXLCDLabel::load(FXStream& store) {
394 FXHorizontalFrame::load(store);
400 long FXLCDLabel::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
402 return getParent()->handle(sender, sel, ptr);
408 long FXLCDLabel::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
410 return getParent()->handle(sender, sel, ptr);
#define FXMAPKEY(key, func)
FXColor getBgColor() const
FXColor getFgColor() const
void setGroove(const FXint width)
get/set groove thickness
void setText(const FXchar val)
set the text on the display
FXint getHorizontal() const
FXint getThickness() const
void setVertical(const FXint len)
get/set vertical segment length
FXint getVertical() const
void setFgColor(const FXColor clr)
get/set foreground color
void setThickness(const FXint width)
get/set segment thickness
void setHorizontal(const FXint len)
get/set horizontal segment length
void setBgColor(const FXColor clr)
get/set background color
FXDEFMAP(FXLCDLabel) FXLCDLabelMap[]