55 #ifdef CHECK_MEMORY_LEAKS 57 #endif // CHECK_MEMORY_LEAKS 62 FXMAPFUNC(SEL_PAINT, 0, FXLCDLabel::onPaint),
63 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, FXLCDLabel::onCmdSetValue),
64 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, FXLCDLabel::onCmdSetIntValue),
65 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXLCDLabel::onCmdSetRealValue),
66 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, FXLCDLabel::onCmdSetStringValue),
67 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, FXLCDLabel::onCmdGetIntValue),
68 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, FXLCDLabel::onCmdGetRealValue),
69 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, FXLCDLabel::onCmdGetStringValue),
72 FXMAPKEY(FXLCDLabel::ID_SEVENSEGMENT, FXLCDLabel::onRedirectEvent),
74 FXIMPLEMENT(
FXLCDLabel, FXHorizontalFrame, FXLCDLabelMap, ARRAYNUMBER(FXLCDLabelMap))
76 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) {
78 fxerror(
"%s: must have at least one figure.\n", getClassName());
84 for (FXint i = 0; i < nfigures; i++) {
89 FXLCDLabel::~FXLCDLabel() {
98 void FXLCDLabel::create() {
99 FXHorizontalFrame::create();
100 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
106 void FXLCDLabel::detach() {
107 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
110 FXHorizontalFrame::detach();
114 void FXLCDLabel::destroy() {
115 for (FXWindow* child = getFirst(); child; child = child->getNext()) {
118 FXHorizontalFrame::destroy();
122 FXColor FXLCDLabel::getFgColor()
const {
128 void FXLCDLabel::setFgColor(FXColor clr) {
138 FXColor FXLCDLabel::getBgColor()
const {
144 void FXLCDLabel::setBgColor(FXColor clr) {
154 void FXLCDLabel::setText(FXString lbl) {
163 FXint FXLCDLabel::getHorizontal()
const {
169 void FXLCDLabel::setHorizontal(
const FXint len) {
181 FXint FXLCDLabel::getVertical()
const {
187 void FXLCDLabel::setVertical(
const FXint len) {
199 FXint FXLCDLabel::getThickness()
const {
205 void FXLCDLabel::setThickness(
const FXint width) {
217 FXint FXLCDLabel::getGroove()
const {
223 void FXLCDLabel::setGroove(
const FXint width) {
235 long FXLCDLabel::onCmdSetValue(FXObject*, FXSelector,
void* ptr) {
236 setText((
const FXchar*)ptr);
241 long FXLCDLabel::onCmdSetIntValue(FXObject*, FXSelector,
void* ptr) {
242 setText(FXStringVal(*((FXint*)ptr)));
247 long FXLCDLabel::onCmdSetRealValue(FXObject*, FXSelector,
void* ptr) {
248 setText(FXStringVal(*((FXdouble*)ptr)));
253 long FXLCDLabel::onCmdSetStringValue(FXObject*, FXSelector,
void* ptr) {
254 setText(*((FXString*)ptr));
259 long FXLCDLabel::onCmdGetIntValue(FXObject*, FXSelector,
void* ptr) {
260 *((FXint*)ptr) = FXIntVal(getText());
265 long FXLCDLabel::onCmdGetRealValue(FXObject*, FXSelector,
void* ptr) {
266 *((FXdouble*)ptr) = FXDoubleVal(getText());
271 long FXLCDLabel::onCmdGetStringValue(FXObject*, FXSelector,
void* ptr) {
272 *((FXString*)ptr) = getText();
277 long FXLCDLabel::onPaint(FXObject*, FXSelector,
void* ptr) {
278 FXEvent*
event = (FXEvent*) ptr;
279 FXDCWindow dc(
this, event);
280 drawFrame(dc, 0, 0, width, height);
284 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
292 void FXLCDLabel::drawString(
const FXString& lbl) {
294 FXString displayString(
' ', nfigures);
298 displayString.replace(0,
'-');
302 for (; (i + txt.length()) < nfigures; i++) {
303 displayString.replace(i,
'0');
305 displayString.insert(i, txt);
306 }
else if (options & JUSTIFY_RIGHT) {
307 for (; (i + lbl.length()) < nfigures; i++) {}
308 displayString.insert(i, lbl);
310 displayString.insert(0, lbl);
312 displayString.trunc(nfigures);
320 if (options & LAYOUT_FILL) {
321 FXint width = this->width - padleft - padright - (border << 1);
322 FXint height = this->height - padtop - padbottom - (border << 1);
323 hspacing = FXMAX(width, height) / 50;
327 FXint hsl = (width - (nfigures - 1) * hspacing) / nfigures;
331 FXint vsl = height >> 1;
335 FXint st = FXMIN(hsl, vsl) / 4;
339 FXint groove = st / 4;
343 if (options & LAYOUT_FILL_X) {
350 if (options & LAYOUT_FILL_Y) {
358 child->
setText(displayString[i++]);
364 child->
setText(displayString[i++]);
370 long FXLCDLabel::onRedirectEvent(FXObject*, FXSelector sel,
void* ptr) {
371 FXuint seltype = FXSELTYPE(sel);
374 target->handle(
this, FXSEL(seltype, message), ptr);
381 FXint FXLCDLabel::getDefaultWidth() {
382 return padleft + getFirst()->getDefaultWidth() * nfigures + hspacing * (nfigures - 1) + padright + (border << 1);
386 FXint FXLCDLabel::getDefaultHeight() {
387 return padtop + getFirst()->getDefaultHeight() + padbottom + (border << 1);
391 void FXLCDLabel::save(FXStream& store)
const {
392 FXHorizontalFrame::save(store);
405 long FXLCDLabel::onQueryTip(FXObject* sender, FXSelector sel,
void* ptr) {
407 return getParent()->handle(sender, sel, ptr);
413 long FXLCDLabel::onQueryHelp(FXObject* sender, FXSelector sel,
void* ptr) {
415 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