![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Seven segment display widget * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 *********************************************************************************/ 00022 #ifndef FXSEVENSEGMENT_H 00023 #define FXSEVENSEGMENT_H 00024 00025 #ifndef FXFRAME_H 00026 #include <fox/FXFrame.h> 00027 using namespace FX; 00028 #endif 00029 namespace FXEX { 00030 00031 /** 00032 * Seven-segment (eg LCD/watch style) widget 00033 */ 00034 class FXAPI FXSevenSegment : public FXFrame { 00035 FXDECLARE(FXSevenSegment) 00036 00037 private: 00038 FXchar value; // The currently shown character 00039 FXColor fgcolor; // The color of the LCD text 00040 FXColor bgcolor; // The color of the LCD background 00041 FXint hsl; // This is pixel length of a horizontal segment 00042 FXint vsl; // This is pixel length of a vertical segment 00043 FXint st; // This is segment thickness, in pixels 00044 FXint groove; // Groove between segments 00045 00046 private: 00047 void checkSize(); 00048 00049 protected: 00050 FXSevenSegment () {} 00051 00052 // Draws the individual segment types 00053 void drawTopSegment (FXDCWindow &dc,FXshort x,FXshort y); 00054 void drawLeftTopSegment (FXDCWindow &dc,FXshort x,FXshort y); 00055 void drawRightTopSegment (FXDCWindow &dc,FXshort x,FXshort y); 00056 void drawMiddleSegment (FXDCWindow &dc,FXshort x,FXshort y); 00057 void drawLeftBottomSegment (FXDCWindow &dc,FXshort x,FXshort y); 00058 void drawRightBottomSegment (FXDCWindow &dc,FXshort x,FXshort y); 00059 void drawBottomSegment (FXDCWindow &dc,FXshort x,FXshort y); 00060 00061 // Draw a seven-segment unit (each segment can be set indepentantly) 00062 void drawSegments (FXDCWindow &dc,FXbool s1,FXbool s2,FXbool s3,FXbool s4,FXbool s5,FXbool s6,FXbool s7); 00063 00064 // Draw an alphanumeric figure (consisting of seven segments) 00065 virtual void drawFigure (FXDCWindow &dc, FXchar figure); 00066 00067 public: 00068 long onPaint(FXObject*,FXSelector,void*); 00069 long onCmdSetValue(FXObject*,FXSelector,void*); 00070 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00071 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00072 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00073 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00074 long onQueryTip(FXObject*,FXSelector,void*); 00075 long onQueryHelp(FXObject*,FXSelector,void*); 00076 00077 public: 00078 /// create a seven segment display 00079 FXSevenSegment(FXComposite* p,FXObject *tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_NONE,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 00080 00081 /// set the text on the display 00082 void setText(const FXchar val); 00083 00084 /// get the text on the display 00085 FXchar getText() const { return value; } 00086 00087 /// get/set foreground color 00088 void setFgColor(const FXColor clr); 00089 FXColor getFgColor() const { return fgcolor; } 00090 00091 /// get/set background color 00092 void setBgColor(const FXColor clr); 00093 FXColor getBgColor() const { return bgcolor; } 00094 00095 /// get/set horizontal segment length 00096 void setHorizontal(const FXint len); 00097 FXint getHorizontal() const { return hsl; } 00098 00099 /// get/set vertical segment length 00100 void setVertical(const FXint len); 00101 FXint getVertical() const { return vsl; } 00102 00103 /// get/set segment thickness 00104 void setThickness(const FXint width); 00105 FXint getThickness() const { return st; } 00106 00107 /// get/set groove thickness 00108 void setGroove(const FXint width); 00109 FXint getGroove() const { return groove; } 00110 00111 /// Return minimum width 00112 virtual FXint getDefaultWidth(); 00113 00114 /// Return minimum height 00115 virtual FXint getDefaultHeight(); 00116 00117 /// save resources 00118 virtual void save(FXStream &store) const; 00119 00120 /// load resources 00121 virtual void load(FXStream &store); 00122 00123 /// dtor 00124 virtual ~FXSevenSegment() {} 00125 }; 00126 00127 } // namespace FXEX 00128 #endif // FXSEVENSEGMENT_H