53 #ifdef CHECK_MEMORY_LEAKS
55 #endif // CHECK_MEMORY_LEAKS
60 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
61 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
62 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
67 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
70 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
74 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) {
76 fxerror(
"%s: must have at least one figure.\n", getClassName());
82 for (FXint i = 0; i < nfigures; i++) {
87 FXLCDLabel::~FXLCDLabel() {
96 void FXLCDLabel::create() {
97 FXHorizontalFrame::create();
98 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
104 void FXLCDLabel::detach() {
105 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
108 FXHorizontalFrame::detach();
112 void FXLCDLabel::destroy() {
113 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
116 FXHorizontalFrame::destroy();
120 FXColor FXLCDLabel::getFgColor()
const {
126 void FXLCDLabel::setFgColor(FXColor clr) {
136 FXColor FXLCDLabel::getBgColor()
const {
142 void FXLCDLabel::setBgColor(FXColor clr) {
152 void FXLCDLabel::setText(FXString lbl) {
161 FXint FXLCDLabel::getHorizontal()
const {
167 void FXLCDLabel::setHorizontal(
const FXint len) {
179 FXint FXLCDLabel::getVertical()
const {
185 void FXLCDLabel::setVertical(
const FXint len) {
197 FXint FXLCDLabel::getThickness()
const {
203 void FXLCDLabel::setThickness(
const FXint width) {
215 FXint FXLCDLabel::getGroove()
const {
221 void FXLCDLabel::setGroove(
const FXint width) {
233 long FXLCDLabel::onCmdSetValue(
FXObject*, FXSelector,
void* ptr) {
234 setText((
const FXchar*)ptr);
239 long FXLCDLabel::onCmdSetIntValue(
FXObject*, FXSelector,
void* ptr) {
240 setText(FXStringVal(*((FXint*)ptr)));
245 long FXLCDLabel::onCmdSetRealValue(
FXObject*, FXSelector,
void* ptr) {
246 setText(FXStringVal(*((FXdouble*)ptr)));
251 long FXLCDLabel::onCmdSetStringValue(
FXObject*, FXSelector,
void* ptr) {
252 setText(*((FXString*)ptr));
257 long FXLCDLabel::onCmdGetIntValue(
FXObject*, FXSelector,
void* ptr) {
258 *((FXint*)ptr) = FXIntVal(getText());
263 long FXLCDLabel::onCmdGetRealValue(
FXObject*, FXSelector,
void* ptr) {
264 *((FXdouble*)ptr) = FXDoubleVal(getText());
269 long FXLCDLabel::onCmdGetStringValue(
FXObject*, FXSelector,
void* ptr) {
270 *((FXString*)ptr) = getText();
275 long FXLCDLabel::onPaint(
FXObject*, FXSelector,
void* ptr) {
276 FXEvent*
event = (FXEvent*) ptr;
277 FXDCWindow dc(
this, event);
278 drawFrame(dc, 0, 0, width, height);
282 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
290 void FXLCDLabel::drawString(
const FXString& lbl) {
292 FXString displayString(
' ', nfigures);
296 displayString.replace(0,
'-');
300 for (; (i + txt.length()) < nfigures; i++) {
301 displayString.replace(i,
'0');
303 displayString.insert(i, txt);
304 }
else if (options & JUSTIFY_RIGHT) {
305 for (; (i + lbl.length()) < nfigures; i++) {}
306 displayString.insert(i, lbl);
308 displayString.insert(0, lbl);
310 displayString.trunc(nfigures);
318 if (options & LAYOUT_FILL) {
319 FXint width = this->width - padleft - padright - (border << 1);
320 FXint height = this->height - padtop - padbottom - (border << 1);
321 hspacing = FXMAX(width, height) / 50;
325 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
329 FXint vsl = height >> 1;
333 FXint st = FXMIN(hsl, vsl) / 4;
337 FXint groove = st / 4;
341 if (options & LAYOUT_FILL_X) {
348 if (options & LAYOUT_FILL_Y) {
356 child->
setText(displayString[i++]);
362 child->
setText(displayString[i++]);
368 long FXLCDLabel::onRedirectEvent(
FXObject*, FXSelector sel,
void* ptr) {
369 FXuint seltype = FXSELTYPE(sel);
372 target->handle(
this, FXSEL(seltype, message), ptr);
379 FXint FXLCDLabel::getDefaultWidth() {
380 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
384 FXint FXLCDLabel::getDefaultHeight() {
385 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
389 void FXLCDLabel::save(FXStream& store)
const {
390 FXHorizontalFrame::save(store);
403 long FXLCDLabel::onQueryTip(
FXObject* sender, FXSelector sel,
void* ptr) {
405 return getParent()->handle(sender, sel, ptr);
411 long FXLCDLabel::onQueryHelp(
FXObject* sender, FXSelector sel,
void* ptr) {
413 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[]
MSNet * load(OptionsCont &oc)
void setText(const FXchar val)
set the text on the display