54 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
55 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
56 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
57 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
58 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
59 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
60 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
61 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
64 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
66 FXIMPLEMENT(
FXLCDLabel, FXHorizontalFrame, FXLCDLabelMap, ARRAYNUMBER(FXLCDLabelMap))
68 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) {
70 fxerror(
"%s: must have at least one figure.\n", getClassName());
76 for (FXint i = 0; i < nfigures; i++) {
81 FXLCDLabel::~FXLCDLabel() {
90 void FXLCDLabel::create() {
91 FXHorizontalFrame::create();
92 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
98 void FXLCDLabel::detach() {
99 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
102 FXHorizontalFrame::detach();
106 void FXLCDLabel::destroy() {
107 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
110 FXHorizontalFrame::destroy();
114 FXColor FXLCDLabel::getFgColor()
const {
120 void FXLCDLabel::setFgColor(FXColor clr) {
130 FXColor FXLCDLabel::getBgColor()
const {
136 void FXLCDLabel::setBgColor(FXColor clr) {
146 void FXLCDLabel::setText(FXString lbl) {
155 FXint FXLCDLabel::getHorizontal()
const {
161 void FXLCDLabel::setHorizontal(
const FXint len) {
173 FXint FXLCDLabel::getVertical()
const {
179 void FXLCDLabel::setVertical(
const FXint len) {
191 FXint FXLCDLabel::getThickness()
const {
197 void FXLCDLabel::setThickness(
const FXint width) {
209 FXint FXLCDLabel::getGroove()
const {
215 void FXLCDLabel::setGroove(
const FXint width) {
227 long FXLCDLabel::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
228 setText((
const FXchar*)ptr);
233 long FXLCDLabel::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
234 setText(FXStringVal(*((FXint*)ptr)));
239 long FXLCDLabel::onCmdSetRealValue(FXObject*, FXSelector,
void* ptr) {
240 setText(FXStringVal(*((FXdouble*)ptr)));
245 long FXLCDLabel::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
246 setText(*((FXString*)ptr));
251 long FXLCDLabel::onCmdGetIntValue(FXObject*, FXSelector,
void* ptr) {
252 *((FXint*)ptr) = FXIntVal(getText());
257 long FXLCDLabel::onCmdGetRealValue(FXObject*, FXSelector,
void* ptr) {
258 *((FXdouble*)ptr) = FXDoubleVal(getText());
263 long FXLCDLabel::onCmdGetStringValue(FXObject*, FXSelector,
void* ptr) {
264 *((FXString*)ptr) = getText();
269 long FXLCDLabel::onPaint(FXObject*, FXSelector,
void* ptr) {
270 FXEvent*
event = (FXEvent*) ptr;
271 FXDCWindow dc(
this, event);
272 drawFrame(dc, 0, 0, width, height);
276 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
284 void FXLCDLabel::drawString(
const FXString& lbl) {
286 FXString displayString(
' ', nfigures);
290 displayString.replace(0,
'-');
294 for (; (i + txt.length()) < nfigures; i++) {
295 displayString.replace(i,
'0');
297 displayString.insert(i, txt);
298 }
else if (options & JUSTIFY_RIGHT) {
299 for (; (i + lbl.length()) < nfigures; i++) {}
300 displayString.insert(i, lbl);
302 displayString.insert(0, lbl);
304 displayString.trunc(nfigures);
312 if (options & LAYOUT_FILL) {
313 FXint width = this->width - padleft - padright - (border << 1);
314 FXint height = this->height - padtop - padbottom - (border << 1);
315 hspacing = FXMAX(width, height) / 50;
319 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
323 FXint vsl = height >> 1;
327 FXint st = FXMIN(hsl, vsl) / 4;
331 FXint groove = st / 4;
335 if (options & LAYOUT_FILL_X) {
342 if (options & LAYOUT_FILL_Y) {
350 child->
setText(displayString[i++]);
356 child->
setText(displayString[i++]);
362 long FXLCDLabel::onRedirectEvent(FXObject*, FXSelector sel,
void* ptr) {
363 FXuint seltype = FXSELTYPE(sel);
366 target->handle(
this, FXSEL(seltype, message), ptr);
373 FXint FXLCDLabel::getDefaultWidth() {
374 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
378 FXint FXLCDLabel::getDefaultHeight() {
379 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
383 void FXLCDLabel::save(FXStream& store)
const {
384 FXHorizontalFrame::save(store);
390 void FXLCDLabel::load(FXStream& store) {
391 FXHorizontalFrame::load(store);
397 long FXLCDLabel::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
399 return getParent()->handle(sender, sel, ptr);
405 long FXLCDLabel::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
407 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
FXDEFMAP(FXLCDLabel) FXLCDLabelMap[]
#define FXMAPKEY(key, func)
void setText(const FXchar val)
set the text on the display