61 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
67 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
68 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
71 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
73 FXIMPLEMENT(
FXLCDLabel, FXHorizontalFrame, FXLCDLabelMap, ARRAYNUMBER(FXLCDLabelMap))
75 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) {
77 fxerror(
"%s: must have at least one figure.\n", getClassName());
83 for (FXint i = 0; i < nfigures; i++) {
88 FXLCDLabel::~FXLCDLabel() {
97 void FXLCDLabel::create() {
98 FXHorizontalFrame::create();
99 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
105 void FXLCDLabel::detach() {
106 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
109 FXHorizontalFrame::detach();
113 void FXLCDLabel::destroy() {
114 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
117 FXHorizontalFrame::destroy();
121 FXColor FXLCDLabel::getFgColor()
const {
127 void FXLCDLabel::setFgColor(FXColor clr) {
137 FXColor FXLCDLabel::getBgColor()
const {
143 void FXLCDLabel::setBgColor(FXColor clr) {
153 void FXLCDLabel::setText(FXString lbl) {
162 FXint FXLCDLabel::getHorizontal()
const {
168 void FXLCDLabel::setHorizontal(
const FXint len) {
180 FXint FXLCDLabel::getVertical()
const {
186 void FXLCDLabel::setVertical(
const FXint len) {
198 FXint FXLCDLabel::getThickness()
const {
204 void FXLCDLabel::setThickness(
const FXint width) {
216 FXint FXLCDLabel::getGroove()
const {
222 void FXLCDLabel::setGroove(
const FXint width) {
234 long FXLCDLabel::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
235 setText((
const FXchar*)ptr);
240 long FXLCDLabel::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
241 setText(FXStringVal(*((FXint*)ptr)));
246 long FXLCDLabel::onCmdSetRealValue(FXObject*, FXSelector,
void* ptr) {
247 setText(FXStringVal(*((FXdouble*)ptr)));
252 long FXLCDLabel::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
253 setText(*((FXString*)ptr));
258 long FXLCDLabel::onCmdGetIntValue(FXObject*, FXSelector,
void* ptr) {
259 *((FXint*)ptr) = FXIntVal(getText());
264 long FXLCDLabel::onCmdGetRealValue(FXObject*, FXSelector,
void* ptr) {
265 *((FXdouble*)ptr) = FXDoubleVal(getText());
270 long FXLCDLabel::onCmdGetStringValue(FXObject*, FXSelector,
void* ptr) {
271 *((FXString*)ptr) = getText();
276 long FXLCDLabel::onPaint(FXObject*, FXSelector,
void* ptr) {
277 FXEvent*
event = (FXEvent*) ptr;
278 FXDCWindow dc(
this, event);
279 drawFrame(dc, 0, 0, width, height);
283 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
291 void FXLCDLabel::drawString(
const FXString& lbl) {
293 FXString displayString(
' ', nfigures);
297 displayString.replace(0,
'-');
301 for (; (i + txt.length()) < nfigures; i++) {
302 displayString.replace(i,
'0');
304 displayString.insert(i, txt);
305 }
else if (options & JUSTIFY_RIGHT) {
306 for (; (i + lbl.length()) < nfigures; i++) {}
307 displayString.insert(i, lbl);
309 displayString.insert(0, lbl);
311 displayString.trunc(nfigures);
319 if (options & LAYOUT_FILL) {
320 FXint width = this->width - padleft - padright - (border << 1);
321 FXint height = this->height - padtop - padbottom - (border << 1);
322 hspacing = FXMAX(width, height) / 50;
326 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
330 FXint vsl = height >> 1;
334 FXint st = FXMIN(hsl, vsl) / 4;
338 FXint groove = st / 4;
342 if (options & LAYOUT_FILL_X) {
349 if (options & LAYOUT_FILL_Y) {
357 child->
setText(displayString[i++]);
363 child->
setText(displayString[i++]);
369 long FXLCDLabel::onRedirectEvent(FXObject*, FXSelector sel,
void* ptr) {
370 FXuint seltype = FXSELTYPE(sel);
373 target->handle(
this, FXSEL(seltype, message), ptr);
380 FXint FXLCDLabel::getDefaultWidth() {
381 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
385 FXint FXLCDLabel::getDefaultHeight() {
386 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
390 void FXLCDLabel::save(FXStream& store)
const {
391 FXHorizontalFrame::save(store);
397 void FXLCDLabel::load(FXStream& store) {
398 FXHorizontalFrame::load(store);
404 long FXLCDLabel::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
406 return getParent()->handle(sender, sel, ptr);
412 long FXLCDLabel::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
414 return getParent()->handle(sender, sel, ptr);
FXint getVertical() const
void setThickness(const FXint width)
get/set segment thickness
FXColor getFgColor() const
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
FXColor getBgColor() const
FXint getThickness() const
void setBgColor(const FXColor clr)
get/set background color
#define FXMAPKEY(key, func)
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]
void setText(const FXchar val)
set the text on the display