Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX7Segment.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * 7 - S e g m e n t D i s p l a y W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2004,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FX7Segment.h,v 1.12 2006/03/01 02:13:21 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FX7SEGMENT_H
25 #define FX7SEGMENT_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 /// 7 Segment styles
35 enum {
36  SEVENSEGMENT_NORMAL = 0, /// Draw segments normally
37  SEVENSEGMENT_SHADOW = 0x00080000 /// Draw shadow under the segments
38  };
39 
40 
41 /**
42 * Seven-segment (eg LCD/watch style) widget, useful for making
43 * indicators and timers. Besides numbers, the seven-segment
44 * display widget can also display some letters and punctuations.
45 */
46 class FXAPI FX7Segment : public FXFrame {
48 protected:
49  FXString label; // Text being shown
50  FXColor textColor; // Text color
51  FXint thickness; // Segment thickness
52  FXint cellwidth; // Width of cell
53  FXint cellheight; // height of cell
54  FXString tip; // Tooltip
55  FXString help; // Help message
56 protected:
57  FX7Segment();
58 private:
59  FX7Segment(const FX7Segment&);
60  FX7Segment &operator=(const FX7Segment&);
61  void drawCells(FXDCWindow &dc,FXint x,FXint y,FXint cw,FXint ch);
62  void drawSegments(FXDCWindow &dc,FXint x,FXint y,FXint w,FXint h,FXuint segments);
63 public:
64  long onPaint(FXObject*,FXSelector,void*);
65  long onCmdSetValue(FXObject*,FXSelector,void*);
66  long onCmdSetIntValue(FXObject*,FXSelector,void*);
67  long onCmdSetRealValue(FXObject*,FXSelector,void*);
68  long onCmdSetStringValue(FXObject*,FXSelector,void*);
69  long onCmdGetIntValue(FXObject*,FXSelector,void*);
70  long onCmdGetRealValue(FXObject*,FXSelector,void*);
71  long onCmdGetStringValue(FXObject*,FXSelector,void*);
72  long onCmdSetHelp(FXObject*,FXSelector,void*);
73  long onCmdGetHelp(FXObject*,FXSelector,void*);
74  long onCmdSetTip(FXObject*,FXSelector,void*);
75  long onCmdGetTip(FXObject*,FXSelector,void*);
76  long onQueryHelp(FXObject*,FXSelector,void*);
77  long onQueryTip(FXObject*,FXSelector,void*);
78 public:
79 
80  /// Create a seven segment display
82 
83  /// Return default width
84  virtual FXint getDefaultWidth();
85 
86  /// Return default height
87  virtual FXint getDefaultHeight();
88 
89  /// Set the text for this label
90  void setText(const FXString& text);
91 
92  /// Get the text for this label
93  FXString getText() const { return label; }
94 
95  /// Change text color
96  void setTextColor(FXColor clr);
97 
98  /// Return text color
99  FXColor getTextColor() const { return textColor; }
100 
101  /// Get/set cell width
102  void setCellWidth(FXint w);
103  FXint getCellWidth() const { return cellwidth; }
104 
105  /// Get/set cell height
106  void setCellHeight(FXint h);
107  FXint getCellHeight() const { return cellheight; }
108 
109  /// Get/set segment thickness
110  void setThickness(FXint t);
111  FXint getThickness() const { return thickness; }
112 
113  /// Change 7 segment style
114  void set7SegmentStyle(FXuint style);
115 
116  /// Get current 7 segment style
117  FXuint get7SegmentStyle() const;
119  /// Set the current text-justification mode.
120  void setJustify(FXuint mode);
122  /// Get the current text-justification mode.
123  FXuint getJustify() const;
125  /// Set the status line help text
126  void setHelpText(const FXString& text){ help=text; }
128  /// Get the status line help text
129  const FXString& getHelpText() const { return help; }
130 
131  /// Set the tool tip message
132  void setTipText(const FXString& text){ tip=text; }
133 
134  /// Get the tool tip message
135  const FXString& getTipText() const { return tip; }
136 
137  /// Save to a stream
138  virtual void save(FXStream &store) const;
139 
140  /// Load from a stream
141  virtual void load(FXStream &store);
142  };
143 
144 }
145 
146 #endif
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
unsigned int FXuint
Definition: fxdefs.h:389
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
Base composite.
Definition: FXComposite.h:35
Draw segments normally.
Definition: FX7Segment.h:39
FXuint FXColor
Definition: fxdefs.h:447
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Seven-segment (eg LCD/watch style) widget, useful for making indicators and timers.
Definition: FX7Segment.h:53
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Window Device Context.
Definition: FXDCWindow.h:52
Draw shadow under the segments.
Definition: FX7Segment.h:40
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp