59 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
60 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
61 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
69 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
71 FXIMPLEMENT(
FXLCDLabel, FXHorizontalFrame, FXLCDLabelMap, ARRAYNUMBER(FXLCDLabelMap))
73 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) {
75 fxerror(
"%s: must have at least one figure.\n", getClassName());
81 for (FXint i = 0; i < nfigures; i++) {
86 FXLCDLabel::~FXLCDLabel() {
95 void FXLCDLabel::create() {
96 FXHorizontalFrame::create();
97 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
103 void FXLCDLabel::detach() {
104 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
107 FXHorizontalFrame::detach();
111 void FXLCDLabel::destroy() {
112 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
115 FXHorizontalFrame::destroy();
119 FXColor FXLCDLabel::getFgColor()
const {
125 void FXLCDLabel::setFgColor(FXColor clr) {
135 FXColor FXLCDLabel::getBgColor()
const {
141 void FXLCDLabel::setBgColor(FXColor clr) {
151 void FXLCDLabel::setText(FXString lbl) {
160 FXint FXLCDLabel::getHorizontal()
const {
166 void FXLCDLabel::setHorizontal(
const FXint len) {
178 FXint FXLCDLabel::getVertical()
const {
184 void FXLCDLabel::setVertical(
const FXint len) {
196 FXint FXLCDLabel::getThickness()
const {
202 void FXLCDLabel::setThickness(
const FXint width) {
214 FXint FXLCDLabel::getGroove()
const {
220 void FXLCDLabel::setGroove(
const FXint width) {
232 long FXLCDLabel::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
233 setText((
const FXchar*)ptr);
238 long FXLCDLabel::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
239 setText(FXStringVal(*((FXint*)ptr)));
244 long FXLCDLabel::onCmdSetRealValue(FXObject*, FXSelector,
void* ptr) {
245 setText(FXStringVal(*((FXdouble*)ptr)));
250 long FXLCDLabel::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
251 setText(*((FXString*)ptr));
256 long FXLCDLabel::onCmdGetIntValue(FXObject*, FXSelector,
void* ptr) {
257 *((FXint*)ptr) = FXIntVal(getText());
262 long FXLCDLabel::onCmdGetRealValue(FXObject*, FXSelector,
void* ptr) {
263 *((FXdouble*)ptr) = FXDoubleVal(getText());
268 long FXLCDLabel::onCmdGetStringValue(FXObject*, FXSelector,
void* ptr) {
269 *((FXString*)ptr) = getText();
274 long FXLCDLabel::onPaint(FXObject*, FXSelector,
void* ptr) {
275 FXEvent*
event = (FXEvent*) ptr;
276 FXDCWindow dc(
this, event);
277 drawFrame(dc, 0, 0, width, height);
281 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
289 void FXLCDLabel::drawString(
const FXString& lbl) {
291 FXString displayString(
' ', nfigures);
295 displayString.replace(0,
'-');
299 for (; (i + txt.length()) < nfigures; i++) {
300 displayString.replace(i,
'0');
302 displayString.insert(i, txt);
303 }
else if (options & JUSTIFY_RIGHT) {
304 for (; (i + lbl.length()) < nfigures; i++) {}
305 displayString.insert(i, lbl);
307 displayString.insert(0, lbl);
309 displayString.trunc(nfigures);
317 if (options & LAYOUT_FILL) {
318 FXint width = this->width - padleft - padright - (border << 1);
319 FXint height = this->height - padtop - padbottom - (border << 1);
320 hspacing = FXMAX(width, height) / 50;
324 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
328 FXint vsl = height >> 1;
332 FXint st = FXMIN(hsl, vsl) / 4;
336 FXint groove = st / 4;
340 if (options & LAYOUT_FILL_X) {
347 if (options & LAYOUT_FILL_Y) {
355 child->
setText(displayString[i++]);
361 child->
setText(displayString[i++]);
367 long FXLCDLabel::onRedirectEvent(FXObject*, FXSelector sel,
void* ptr) {
368 FXuint seltype = FXSELTYPE(sel);
371 target->handle(
this, FXSEL(seltype, message), ptr);
378 FXint FXLCDLabel::getDefaultWidth() {
379 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
383 FXint FXLCDLabel::getDefaultHeight() {
384 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
388 void FXLCDLabel::save(FXStream& store)
const {
389 FXHorizontalFrame::save(store);
395 void FXLCDLabel::load(FXStream& store) {
396 FXHorizontalFrame::load(store);
402 long FXLCDLabel::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
404 return getParent()->handle(sender, sel, ptr);
410 long FXLCDLabel::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
412 return getParent()->handle(sender, sel, ptr);
FXColor getBgColor() const
void setThickness(const FXint width)
get/set segment thickness
FXint getHorizontal() const
void setGroove(const FXint width)
get/set groove thickness
void setVertical(const FXint len)
get/set vertical segment length
void setHorizontal(const FXint len)
get/set horizontal segment length
void setFgColor(const FXColor clr)
get/set foreground color
void setBgColor(const FXColor clr)
get/set background color
FXint getVertical() const
FXColor getFgColor() const
FXint getThickness() const
#define FXMAPKEY(key, func)
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]
void setText(const FXchar val)
set the text on the display