KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWLabel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWLabel.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWLabel - label widget
15 // .SECTION Description
16 // A simple widget that represents a label. A label is a widget that displays
17 // a textual string (or image). If text is displayed, it must all be in
18 // a single font, but it can occupy multiple lines on the screen (if it
19 // contains newlines or if wrapping occurs because of the WrapLength option).
20 // For longer text and more justification options, see vtkKWMessage.
21 // .SECTION See Also
22 // vtkKWMessage
23 
24 #ifndef __vtkKWLabel_h
25 #define __vtkKWLabel_h
26 
27 #include "vtkKWCoreWidget.h"
28 
29 class vtkKWIcon;
30 
32 {
33 public:
34  static vtkKWLabel* New();
35  vtkTypeRevisionMacro(vtkKWLabel,vtkKWCoreWidget);
36  void PrintSelf(ostream& os, vtkIndent indent);
37 
38  // Description:
39  // Set the text on the label.
40  virtual void SetText(const char*);
41  vtkGetStringMacro(Text);
42 
43  // Description:
44  // Set/Get the width of the label.
45  // If an image is being displayed in the label then the value is in screen
46  // units; for text it is in characters.
47  virtual void SetWidth(int);
48  virtual int GetWidth();
49 
50  // Description:
51  // Set/Get the height of the label.
52  // If an image is being displayed in the label then the value is in screen
53  // units; for text it is in lines of text.
54  virtual void SetHeight(int);
55  virtual int GetHeight();
56 
57  // Description:
58  // Set/Get the justification mode.
59  // When there are multiple lines of text displayed in a widget, this option
60  // determines how the lines line up with each other.
61  // Valid constants can be found in vtkKWOptions::JustificationType.
62  virtual void SetJustification(int);
63  virtual int GetJustification();
64  virtual void SetJustificationToLeft();
65  virtual void SetJustificationToCenter();
66  virtual void SetJustificationToRight();
67 
68  // Description:
69  // Set/Get the anchoring.
70  // Specifies how the information in a widget (e.g. text or a bitmap) is to
71  // be displayed in the widget.
72  // Valid constants can be found in vtkKWOptions::AnchorType.
73  virtual void SetAnchor(int);
74  virtual int GetAnchor();
75  virtual void SetAnchorToNorth();
76  virtual void SetAnchorToNorthEast();
77  virtual void SetAnchorToEast();
78  virtual void SetAnchorToSouthEast();
79  virtual void SetAnchorToSouth();
80  virtual void SetAnchorToSouthWest();
81  virtual void SetAnchorToWest();
82  virtual void SetAnchorToNorthWest();
83  virtual void SetAnchorToCenter();
84 
85  // Description:
86  // Set/Get the background color of the widget.
87  virtual void GetBackgroundColor(double *r, double *g, double *b);
88  virtual double* GetBackgroundColor();
89  virtual void SetBackgroundColor(double r, double g, double b);
90  virtual void SetBackgroundColor(double rgb[3])
91  { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
92 
93  // Description:
94  // Set/Get the foreground color of the widget (or the default color).
95  virtual void GetForegroundColor(double *r, double *g, double *b);
96  virtual double* GetForegroundColor();
97  virtual void SetForegroundColor(double r, double g, double b);
98  virtual void SetForegroundColor(double rgb[3])
99  { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
100  virtual void GetDefaultForegroundColor(double *r, double *g, double *b);
101  virtual double* GetDefaultForegroundColor();
102 
103  // Description:
104  // Set/Get the highlight thickness, a non-negative value indicating the
105  // width of the highlight rectangle to draw around the outside of the
106  // widget when it has the input focus.
107  virtual void SetHighlightThickness(int);
108  virtual int GetHighlightThickness();
109 
110  // Description:
111  // Set/Get the active background color of the widget. An element
112  // (a widget or portion of a widget) is active if the mouse cursor is
113  // positioned over the element and pressing a mouse button will cause some
114  // action to occur.
115  virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
116  virtual double* GetActiveBackgroundColor();
117  virtual void SetActiveBackgroundColor(double r, double g, double b);
118  virtual void SetActiveBackgroundColor(double rgb[3])
119  { this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
120 
121  // Description:
122  // Set/Get the active foreground color of the widget. An element
123  // (a widget or portion of a widget) is active if the mouse cursor is
124  // positioned over the element and pressing a mouse button will cause some
125  // action to occur.
126  virtual void GetActiveForegroundColor(double *r, double *g, double *b);
127  virtual double* GetActiveForegroundColor();
128  virtual void SetActiveForegroundColor(double r, double g, double b);
129  virtual void SetActiveForegroundColor(double rgb[3])
130  { this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
131 
132  // Description:
133  // Set/Get the foreground color of the widget when it is disabled.
134  virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
135  virtual double* GetDisabledForegroundColor();
136  virtual void SetDisabledForegroundColor(double r, double g, double b);
137  virtual void SetDisabledForegroundColor(double rgb[3])
138  { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
139 
140  // Description:
141  // Set/Get the border width, a non-negative value indicating the width of
142  // the 3-D border to draw around the outside of the widget (if such a border
143  // is being drawn; the Relief option typically determines this).
144  virtual void SetBorderWidth(int);
145  virtual int GetBorderWidth();
146 
147  // Description:
148  // Set/Get the 3-D effect desired for the widget.
149  // The value indicates how the interior of the widget should appear
150  // relative to its exterior.
151  // Valid constants can be found in vtkKWOptions::ReliefType.
152  virtual void SetRelief(int);
153  virtual int GetRelief();
154  virtual void SetReliefToRaised();
155  virtual void SetReliefToSunken();
156  virtual void SetReliefToFlat();
157  virtual void SetReliefToRidge();
158  virtual void SetReliefToSolid();
159  virtual void SetReliefToGroove();
160 
161  // Description:
162  // Set/Get the padding that will be applied around each widget (in pixels).
163  // Specifies a non-negative value indicating how much extra space to request
164  // for the widget in the X and Y-direction. When computing how large a
165  // window it needs, the widget will add this amount to the width it would
166  // normally need (as determined by the width of the things displayed
167  // in the widget); if the geometry manager can satisfy this request, the
168  // widget will end up with extra internal space around what it displays
169  // inside.
170  virtual void SetPadX(int);
171  virtual int GetPadX();
172  virtual void SetPadY(int);
173  virtual int GetPadY();
174 
175  // Description:
176  // Set/Get the wrap length mode.
177  // For widgets that can perform word-wrapping, this option specifies the
178  // maximum line length. Lines that would exceed this length are wrapped onto
179  // the next line, so that no line is longer than the specified length.
180  // The value may be specified in any of the standard forms for screen
181  // distances (i.e, "2i" means 2 inches).
182  // If this value is less than or equal to 0 then no wrapping is done: lines
183  // will break only at newline characters in the text.
184  virtual void SetWrapLength(const char *length);
185  virtual const char* GetWrapLength();
186 
187  // Description:
188  // Adjust the -wraplength argument so that it matches the width of
189  // the widget automatically (through the Configure event).
190  virtual void SetAdjustWrapLengthToWidth(int);
191  vtkGetMacro(AdjustWrapLengthToWidth, int);
192  vtkBooleanMacro(AdjustWrapLengthToWidth, int);
193 
194  // Description:
195  // Specifies the font to use when drawing text inside the widget.
196  // You can use predefined font names (e.g. 'system'), or you can specify
197  // a set of font attributes with a platform-independent name, for example,
198  // 'times 12 bold'. In this example, the font is specified with a three
199  // element list: the first element is the font family, the second is the
200  // size, the third is a list of style parameters (normal, bold, roman,
201  // italic, underline, overstrike). Example: 'times 12 {bold italic}'.
202  // The Times, Courier and Helvetica font families are guaranteed to exist
203  // and will be matched to the corresponding (closest) font on your system.
204  // If you are familiar with the X font names specification, you can also
205  // describe the font that way (say, '*times-medium-r-*-*-12*').
206  virtual void SetFont(const char *font);
207  virtual const char* GetFont();
208 
209  // Description:
210  // Specifies an image to display in the widget. Typically, if the image
211  // is specified then it overrides other options that specify a bitmap or
212  // textual value to display in the widget. Invoke vtkKWWidget's
213  // SetConfigurationOption("-image", imagename) to use a specific
214  // pre-existing Tk image, or call one of the following functions:
215  // The SetImageToPredefinedIcon method accepts an index to one of the
216  // predefined icon listed in vtkKWIcon.
217  // The SetImageToPixels method sets the image using pixel data. It expects
218  // a pointer to the pixels and the structure of the image, i.e. its width,
219  // height and the pixel_size (how many bytes per pixel, say 3 for RGB, or
220  // 1 for grayscale). If buffer_length = 0, it is computed automatically
221  // from the previous parameters. If it is not, it will most likely indicate
222  // that the buffer has been encoded using base64 and/or zlib.
223  // If pixel_size > 3 (i.e. RGBA), the image is blend the with background
224  // color of the widget.
225  // Check the SetCompoundMode method if you want to display both the
226  // image and the label at the same time.
227  virtual void SetImageToIcon(vtkKWIcon *icon);
228  virtual void SetImageToPredefinedIcon(int icon_index);
229  virtual void SetImageToPixels(
230  const unsigned char *pixels, int width, int height, int pixel_size,
231  unsigned long buffer_length = 0);
232 
233  // Description:
234  // Specifies if the widget should display text and bitmaps/images at the
235  // same time, and if so, where the bitmap/image should be placed relative
236  // to the text.
237  // Valid constants can be found in vtkKWOptions::CompoundModeType.
238  // The (default) value CompoundModeNone specifies that the bitmap or image
239  // should (if defined) be displayed instead of the text.
240  virtual void SetCompoundMode(int);
241  virtual int GetCompoundMode();
242  virtual void SetCompoundModeToNone();
243  virtual void SetCompoundModeToLeft();
244  virtual void SetCompoundModeToCenter();
245  virtual void SetCompoundModeToRight();
246  virtual void SetCompoundModeToTop();
247  virtual void SetCompoundModeToBottom();
248 
249  // Description:
250  // Update the "enable" state of the object and its internal parts.
251  // Depending on different Ivars (this->Enabled, the application's
252  // Limited Edition Mode, etc.), the "enable" state of the object is updated
253  // and propagated to its internal parts/subwidgets. This will, for example,
254  // enable/disable parts of the widget UI, enable/disable the visibility
255  // of 3D widgets, etc.
256  virtual void UpdateEnableState();
257 
258  // Description:
259  // Callbacks. Internal, do not use.
260  virtual void AdjustWrapLengthToWidthCallback();
261 
262 protected:
263  vtkKWLabel();
264  ~vtkKWLabel();
265 
266  // Description:
267  // Create the widget.
268  virtual void CreateWidget();
269 
270  virtual void UpdateBindings();
271  virtual void UpdateText();
272 
273 private:
274  char* Text;
275  int AdjustWrapLengthToWidth;
276  vtkKWIcon *Icon;
277 
278  vtkKWLabel(const vtkKWLabel&); // Not implemented
279  void operator=(const vtkKWLabel&); // Not implemented
280 };
281 
282 #endif