FXEX::FXLCDLabel Class Reference

#include <FXLCDLabel.h>

Inheritance diagram for FXEX::FXLCDLabel:

FXHorizontalFrame

Detailed Description

A widget which has the seven-segment display used as the drawing object for each letter in the label. Supports display of leading zeros, such as when you need to display a number. Also supports the 'JUSTIFY_RIGHT' option, for right alignment.

Definition at line 54 of file FXLCDLabel.h.


Public Types

enum  { ID_SEVENSEGMENT = FXHorizontalFrame::ID_LAST, ID_LAST }

Public Member Functions

virtual void create ()
 create resrouces
virtual void destroy ()
 destroy resources
virtual void detach ()
 detach resources
 FXLCDLabel (FXComposite *p, FXuint nfig=1, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=LCDLABEL_NORMAL, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD, FXint hs=DEFAULT_PAD)
 make me a label
FXColor getBgColor () const
virtual FXint getDefaultHeight ()
 return minimum height
virtual FXint getDefaultWidth ()
 return minimum width
FXColor getFgColor () const
FXint getGroove () const
FXint getHorizontal () const
FXString getText () const
FXint getThickness () const
FXint getVertical () const
virtual void load (FXStream &store)
 load resources
long onCmdGetIntValue (FXObject *, FXSelector, void *ptr)
long onCmdGetRealValue (FXObject *, FXSelector, void *ptr)
long onCmdGetStringValue (FXObject *, FXSelector, void *ptr)
long onCmdSetIntValue (FXObject *, FXSelector, void *ptr)
long onCmdSetRealValue (FXObject *, FXSelector, void *ptr)
long onCmdSetStringValue (FXObject *, FXSelector, void *ptr)
long onCmdSetValue (FXObject *, FXSelector, void *ptr)
long onPaint (FXObject *, FXSelector, void *)
long onQueryHelp (FXObject *, FXSelector, void *ptr)
long onQueryTip (FXObject *, FXSelector, void *ptr)
long onRedirectEvent (FXObject *, FXSelector, void *ptr)
virtual void save (FXStream &store) const
 save resources
void setBgColor (FXColor clr)
 set/get background color
void setFgColor (FXColor clr)
 set/get forground color
void setGroove (const FXint width)
 set/get groove width - must be less than segment width
void setHorizontal (const FXint len)
 set/get segment horizontal length - must be more than twice the segment width
void setText (FXString lbl)
 manipulate text in LCD label
void setThickness (const FXint width)
 set/get segment width - must be less than half the segment length
void setVertical (const FXint len)
 set/get segment vertical length - must be more than twice the segment width
virtual ~FXLCDLabel ()
 dtor

Protected Member Functions

virtual void drawString (const FXString &lbl)
 The number of shown figuresi, greater than zero.
 FXLCDLabel ()

Protected Attributes

FXString label
FXint nfigures
 The currently shown label.

Member Enumeration Documentation

anonymous enum

Enumerator:
ID_SEVENSEGMENT 
ID_LAST 

Definition at line 68 of file FXLCDLabel.h.

00068          {
00069         ID_SEVENSEGMENT=FXHorizontalFrame::ID_LAST,
00070         ID_LAST
00071     };


Constructor & Destructor Documentation

FXEX::FXLCDLabel::FXLCDLabel (  )  [inline, protected]

Definition at line 59 of file FXLCDLabel.h.

00059 {}

FXEX::FXLCDLabel::FXLCDLabel ( FXComposite *  p,
FXuint  nfig = 1,
FXObject tgt = NULL,
FXSelector  sel = 0,
FXuint  opts = LCDLABEL_NORMAL,
FXint  pl = DEFAULT_PAD,
FXint  pr = DEFAULT_PAD,
FXint  pt = DEFAULT_PAD,
FXint  pb = DEFAULT_PAD,
FXint  hs = DEFAULT_PAD 
)

make me a label

FXEX::FXLCDLabel::~FXLCDLabel (  )  [virtual]

dtor

Definition at line 85 of file FXLCDLabel.cpp.

00085                         {
00086     /*
00087       for (FXSevenSegment *child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()){
00088         delete child;
00089         }
00090     */
00091 }


Member Function Documentation

void FXEX::FXLCDLabel::create (  )  [virtual]

create resrouces

Definition at line 94 of file FXLCDLabel.cpp.

00094                         {
00095     FXHorizontalFrame::create();
00096     for (FXWindow *child=getFirst(); child; child=child->getNext()) {
00097         child->create();
00098     }
00099 }

void FXEX::FXLCDLabel::destroy (  )  [virtual]

destroy resources

Definition at line 110 of file FXLCDLabel.cpp.

00110                          {
00111     for (FXWindow *child=getFirst(); child; child=child->getNext()) {
00112         child->destroy();
00113     }
00114     FXHorizontalFrame::destroy();
00115 }

void FXEX::FXLCDLabel::detach (  )  [virtual]

detach resources

Definition at line 102 of file FXLCDLabel.cpp.

00102                         {
00103     for (FXWindow *child=getFirst(); child; child=child->getNext()) {
00104         child->detach();
00105     }
00106     FXHorizontalFrame::detach();
00107 }

void FXEX::FXLCDLabel::drawString ( const FXString &  lbl  )  [protected, virtual]

The number of shown figuresi, greater than zero.

Definition at line 288 of file FXLCDLabel.cpp.

References FXEX::LCDLABEL_LEADING_ZEROS, nfigures, FXEX::FXSevenSegment::setGroove(), FXEX::FXSevenSegment::setHorizontal(), FXEX::FXSevenSegment::setText(), FXEX::FXSevenSegment::setThickness(), and FXEX::FXSevenSegment::setVertical().

Referenced by onPaint().

00288                                                {
00289     FXint i=0;
00290     FXString displayString(' ',nfigures);
00291     if (options&LCDLABEL_LEADING_ZEROS && (FXIntVal(lbl) || lbl=="0")) {
00292         FXString txt = lbl;
00293         if (txt[0]=='-') {
00294             displayString.replace(0,'-');
00295             txt.erase(0);
00296             i=1;
00297         }
00298         for (; (i+txt.length())<nfigures; i++) {
00299             displayString.replace(i,'0');
00300         }
00301         displayString.insert(i,txt);
00302     } else if (options&JUSTIFY_RIGHT) {
00303         for (; (i+lbl.length())<nfigures; i++) {}
00304         displayString.insert(i,lbl);
00305     } else {
00306         displayString.insert(0,lbl);
00307     }
00308     displayString.trunc(nfigures);
00309     i=0;
00310 
00311     // FIXME: at the moment, if we resize the parent widget, we must use integer multiples
00312     //        of the SevenSegment width.  The problem is that it makes the padding on the
00313     //        RHS look wrong.  What we need to do is to extend the horizontal segment width
00314     //        for the last sevensegment, so as to fill the remaining space.
00315     FXSevenSegment *child=(FXSevenSegment*)getFirst();
00316     if (options&LAYOUT_FILL) {
00317         FXint width=this->width-padleft-padright-(border<<1);
00318         FXint height=this->height-padtop-padbottom-(border<<1);
00319         hspacing=FXMAX(width,height)/50;
00320         if (hspacing<1) hspacing=1;
00321         FXint hsl=(width-(nfigures-1)*hspacing)/nfigures;
00322         if (hsl<5) hsl=5;
00323         FXint vsl=height>>1;
00324         if (vsl<5) vsl=5;
00325         FXint st=FXMIN(hsl,vsl)/4;
00326         if (st<1) st=1;
00327         FXint groove=st/4;
00328         if (groove<1) groove=1;
00329         if (options&LAYOUT_FILL_X) {
00330             hsl-=groove<<1;
00331             for (; child; child=(FXSevenSegment*)child->getNext()) {
00332                 child->setHorizontal(hsl);
00333             }
00334             child=(FXSevenSegment*)getFirst();
00335         }
00336         if (options&LAYOUT_FILL_Y) {
00337             vsl-=groove<<1;
00338             for (; child; child=(FXSevenSegment*)child->getNext()) {
00339                 child->setVertical(vsl);
00340             }
00341             child=(FXSevenSegment*)getFirst();
00342         }
00343         for (; child; child=(FXSevenSegment*)child->getNext()) {
00344             child->setText(displayString[i++]);
00345             child->setGroove(groove);
00346             child->setThickness(st);
00347         }
00348     } else {
00349         for (; child; child=(FXSevenSegment*)child->getNext()) {
00350             child->setText(displayString[i++]);
00351         }
00352     }
00353 }

FXColor FXEX::FXLCDLabel::getBgColor (  )  const

Definition at line 134 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getBgColor().

00134                                      {
00135     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00136     return child->getBgColor();
00137 }

FXint FXEX::FXLCDLabel::getDefaultHeight (  )  [virtual]

return minimum height

Definition at line 370 of file FXLCDLabel.cpp.

00370                                    {
00371     return padtop + getFirst()->getDefaultHeight() + padbottom + (border<<1);
00372 }

FXint FXEX::FXLCDLabel::getDefaultWidth (  )  [virtual]

return minimum width

Definition at line 365 of file FXLCDLabel.cpp.

References nfigures.

00365                                   {
00366     return padleft + getFirst()->getDefaultWidth()*nfigures + hspacing*(nfigures-1) + padright + (border<<1);
00367 }

FXColor FXEX::FXLCDLabel::getFgColor (  )  const

Definition at line 118 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getFgColor().

00118                                      {
00119     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00120     return child->getFgColor();
00121 }

FXint FXEX::FXLCDLabel::getGroove (  )  const

Definition at line 213 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getGroove().

00213                                   {
00214     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00215     return child->getGroove();
00216 }

FXint FXEX::FXLCDLabel::getHorizontal (  )  const

Definition at line 159 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getHorizontal().

00159                                       {
00160     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00161     return child->getHorizontal();
00162 }

FXString FXEX::FXLCDLabel::getText (  )  const [inline]

Definition at line 101 of file FXLCDLabel.h.

References label.

Referenced by onCmdGetIntValue(), onCmdGetRealValue(), and onCmdGetStringValue().

00101                              {
00102         return label;
00103     }

FXint FXEX::FXLCDLabel::getThickness (  )  const

Definition at line 195 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getThickness().

00195                                      {
00196     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00197     return child->getThickness();
00198 }

FXint FXEX::FXLCDLabel::getVertical (  )  const

Definition at line 177 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getVertical().

00177                                     {
00178     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00179     return child->getVertical();
00180 }

void FXEX::FXLCDLabel::load ( FXStream &  store  )  [virtual]

load resources

Definition at line 382 of file FXLCDLabel.cpp.

References label, load(), and nfigures.

00382                                      {
00383     FXHorizontalFrame::load(store);
00384     store >> label;
00385     store >> nfigures;
00386 }

long FXEX::FXLCDLabel::onCmdGetIntValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 255 of file FXLCDLabel.cpp.

References getText().

00255                                                                 {
00256     *((FXint*)ptr)=FXIntVal(getText());
00257     return 1;
00258 }

long FXEX::FXLCDLabel::onCmdGetRealValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 261 of file FXLCDLabel.cpp.

References getText().

00261                                                                  {
00262     *((FXdouble*)ptr)=FXDoubleVal(getText());
00263     return 1;
00264 }

long FXEX::FXLCDLabel::onCmdGetStringValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 267 of file FXLCDLabel.cpp.

References getText().

00267                                                                    {
00268     *((FXString*)ptr)=getText();
00269     return 1;
00270 }

long FXEX::FXLCDLabel::onCmdSetIntValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 237 of file FXLCDLabel.cpp.

References setText().

00237                                                                 {
00238     setText(FXStringVal(*((FXint*)ptr)));
00239     return 1;
00240 }

long FXEX::FXLCDLabel::onCmdSetRealValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 243 of file FXLCDLabel.cpp.

References setText().

00243                                                                  {
00244     setText(FXStringVal(*((FXdouble*)ptr)));
00245     return 1;
00246 }

long FXEX::FXLCDLabel::onCmdSetStringValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 249 of file FXLCDLabel.cpp.

References setText().

00249                                                                    {
00250     setText(*((FXString*)ptr));
00251     return 1;
00252 }

long FXEX::FXLCDLabel::onCmdSetValue ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 231 of file FXLCDLabel.cpp.

References setText().

00231                                                              {
00232     setText((const FXchar*)ptr);
00233     return 1;
00234 }

long FXEX::FXLCDLabel::onPaint ( FXObject ,
FXSelector  ,
void *  ptr 
)

Definition at line 273 of file FXLCDLabel.cpp.

References drawString(), FXEX::FXSevenSegment::getBgColor(), FXEX::FXSevenSegment::getFgColor(), and label.

00273                                                        {
00274     FXEvent *event= (FXEvent*) ptr;
00275     FXDCWindow dc(this, event);
00276     drawFrame(dc,0,0,width,height);
00277     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00278     // Fill the background
00279     dc.setForeground(child->getBgColor());
00280     dc.fillRectangle(border, border, width-(border<<1), height-(border<<1));
00281     // Draw the current string
00282     dc.setForeground(child->getFgColor());
00283     drawString(label);
00284     return 1;
00285 }

long FXEX::FXLCDLabel::onQueryHelp ( FXObject sender,
FXSelector  sel,
void *  ptr 
)

Definition at line 395 of file FXLCDLabel.cpp.

00395                                                                       {
00396     if (getParent()) return getParent()->handle(sender,sel,ptr);
00397     return 0;
00398 }

long FXEX::FXLCDLabel::onQueryTip ( FXObject sender,
FXSelector  sel,
void *  ptr 
)

Definition at line 389 of file FXLCDLabel.cpp.

00389                                                                      {
00390     if (getParent()) return getParent()->handle(sender,sel,ptr);
00391     return 0;
00392 }

long FXEX::FXLCDLabel::onRedirectEvent ( FXObject ,
FXSelector  sel,
void *  ptr 
)

Definition at line 356 of file FXLCDLabel.cpp.

00356                                                                    {
00357     FXuint seltype = FXSELTYPE(sel);
00358     if (isEnabled()) {
00359         if (target) target->handle(this,FXSEL(seltype,message),ptr);
00360     }
00361     return 1;
00362 }

void FXEX::FXLCDLabel::save ( FXStream &  store  )  const [virtual]

save resources

Definition at line 375 of file FXLCDLabel.cpp.

References label, and nfigures.

00375                                            {
00376     FXHorizontalFrame::save(store);
00377     store << label;
00378     store << nfigures;
00379 }

void FXEX::FXLCDLabel::setBgColor ( FXColor  clr  ) 

set/get background color

Definition at line 140 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getBgColor(), and FXEX::FXSevenSegment::setBgColor().

00140                                        {
00141     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00142     if (clr!=child->getBgColor()) {
00143         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00144             child->setBgColor(clr);
00145         }
00146     }
00147 }

void FXEX::FXLCDLabel::setFgColor ( FXColor  clr  ) 

set/get forground color

Definition at line 124 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getFgColor(), and FXEX::FXSevenSegment::setFgColor().

00124                                        {
00125     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00126     if (clr!=child->getFgColor()) {
00127         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00128             child->setFgColor(clr);
00129         }
00130     }
00131 }

void FXEX::FXLCDLabel::setGroove ( const FXint  width  ) 

set/get groove width - must be less than segment width

Definition at line 219 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getGroove(), and FXEX::FXSevenSegment::setGroove().

Referenced by GUIApplicationWindow::buildToolBars().

00219                                             {
00220     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00221     if (width!=child->getGroove()) {
00222         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00223             child->setGroove(width);
00224         }
00225         recalc();
00226         update();
00227     }
00228 }

void FXEX::FXLCDLabel::setHorizontal ( const FXint  len  ) 

set/get segment horizontal length - must be more than twice the segment width

Definition at line 165 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getHorizontal(), and FXEX::FXSevenSegment::setHorizontal().

Referenced by GUIApplicationWindow::buildToolBars().

00165                                               {
00166     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00167     if (len!=child->getHorizontal()) {
00168         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00169             child->setHorizontal(len);
00170         }
00171         recalc();
00172         update();
00173     }
00174 }

void FXEX::FXLCDLabel::setText ( FXString  lbl  ) 

manipulate text in LCD label

Definition at line 150 of file FXLCDLabel.cpp.

References label.

Referenced by GUIApplicationWindow::buildToolBars(), GUIApplicationWindow::closeAllWindows(), GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), onCmdSetIntValue(), onCmdSetRealValue(), onCmdSetStringValue(), and onCmdSetValue().

00150                                      {
00151     if (lbl!=label) {
00152         label=lbl;
00153         recalc();
00154         update();
00155     }
00156 }

void FXEX::FXLCDLabel::setThickness ( const FXint  width  ) 

set/get segment width - must be less than half the segment length

Definition at line 201 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getThickness(), and FXEX::FXSevenSegment::setThickness().

Referenced by GUIApplicationWindow::buildToolBars().

00201                                                {
00202     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00203     if (width!=child->getThickness()) {
00204         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00205             child->setThickness(width);
00206         }
00207         recalc();
00208         update();
00209     }
00210 }

void FXEX::FXLCDLabel::setVertical ( const FXint  len  ) 

set/get segment vertical length - must be more than twice the segment width

Definition at line 183 of file FXLCDLabel.cpp.

References FXEX::FXSevenSegment::getVertical(), and FXEX::FXSevenSegment::setVertical().

Referenced by GUIApplicationWindow::buildToolBars().

00183                                             {
00184     FXSevenSegment *child = (FXSevenSegment*)getFirst();
00185     if (len!=child->getVertical()) {
00186         for (child=(FXSevenSegment*)getFirst(); child; child=(FXSevenSegment*)child->getNext()) {
00187             child->setVertical(len);
00188         }
00189         recalc();
00190         update();
00191     }
00192 }


Field Documentation

FXString FXEX::FXLCDLabel::label [protected]

Definition at line 61 of file FXLCDLabel.h.

Referenced by getText(), load(), onPaint(), save(), and setText().

FXint FXEX::FXLCDLabel::nfigures [protected]

The currently shown label.

Definition at line 62 of file FXLCDLabel.h.

Referenced by drawString(), getDefaultWidth(), load(), and save().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:07:01 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6