KWWidgets
vtkKWCoreWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWCoreWidget.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 vtkKWCoreWidget - a core widget.
15 // .SECTION Description
16 // A superclass for all core widgets, i.e. C++ wrappers around simple
17 // Tk widgets.
18 // .SECTION Thanks
19 // This work is part of the National Alliance for Medical Image
20 // Computing (NAMIC), funded by the National Institutes of Health
21 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
22 // Information on the National Centers for Biomedical Computing
23 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
24 
25 #ifndef __vtkKWCoreWidget_h
26 #define __vtkKWCoreWidget_h
27 
28 #include "vtkKWWidget.h"
29 
30 class vtkKWCoreWidgetInternals;
31 
33 {
34 public:
35  static vtkKWCoreWidget* New();
36  vtkTypeRevisionMacro(vtkKWCoreWidget, vtkKWWidget);
37  void PrintSelf(ostream& os, vtkIndent indent);
38 
39  // Description:
40  // Set/Get the -state option to "normal" (1) or "disabled" (0) or "readonly"
41  // (2, if supported).
42  // Valid constants can be found in vtkKWOptions::StateType.
43  // This should not be used directly, this is done by
44  // SetEnabled()/UpdateEnableState().
45  // TODO: should be in protected:
46  virtual void SetState(int);
47  virtual int GetState();
48  virtual void SetStateToDisabled();
49  virtual void SetStateToNormal();
50  virtual void SetStateToReadOnly();
51 
52  // Description:
53  // Arranges for window to be displayed above all of its siblings in the
54  // stacking order.
55  virtual void Raise();
56 
57  // Description:
58  // Set/Get a Tk configuration option (ex: "-bg").
59  // Make *sure* you check the class (and subclasses) API for a
60  // C++ method that would already act as a front-end to the Tk option.
61  // For example, the SetBackgroundColor() method should be used instead of
62  // accessing the -bg Tk option.
63  // Note that SetConfigurationOption will enclose the value inside
64  // curly braces {} as a convenience.
65  // SetConfigurationOption returns 1 on success, 0 otherwise.
66  virtual int SetConfigurationOption(const char* option, const char *value);
67  virtual int HasConfigurationOption(const char* option);
68  virtual const char* GetConfigurationOption(const char* option);
69  virtual int GetConfigurationOptionAsInt(const char* option);
70  virtual int SetConfigurationOptionAsInt(const char* option, int value);
71  virtual double GetConfigurationOptionAsDouble(const char* option);
72  virtual int SetConfigurationOptionAsDouble(const char* option, double value);
73  virtual void GetConfigurationOptionAsColor(
74  const char* option, double *r, double *g, double *b);
75  virtual double* GetConfigurationOptionAsColor(const char* option);
76  virtual void SetConfigurationOptionAsColor(
77  const char* option, double r, double g, double b);
78  virtual void SetConfigurationOptionAsColor(const char* option, double rgb[3])
79  { this->SetConfigurationOptionAsColor(option, rgb[0], rgb[1], rgb[2]); };
80  virtual void GetDefaultConfigurationOptionAsColor(
81  const char* option, double *r, double *g, double *b);
82  virtual double* GetDefaultConfigurationOptionAsColor(const char* option);
83 
84 protected:
86  ~vtkKWCoreWidget();
87 
88  // Description:
89  // Create the widget.
90  virtual void CreateWidget();
91 
92  // Description:
93  // Get the Tk string type of the widget.
94  virtual const char* GetType();
95 
96  // Description:
97  // Convert a Tcl string (stored internally as UTF-8/Unicode) to another
98  // internal format (given the widget's application CharacterEncoding),
99  // and vice-versa.
100  // The 'source' string is the source to convert.
101  // It returns a pointer to where the converted string can be found
102  // (copy the result to safe storage immediately).
103  // The 'options' can be set to perform some replacements/escaping.
104  // ConvertStringEscapeInterpretable will attempt to escape all characters
105  // that can be interpreted (when found between a pair of quotes for
106  // example): $ [ ] "
107  //BTX
108  enum
109  {
110  ConvertStringEscapeCurlyBraces = 1,
111  ConvertStringEscapeInterpretable = 2
112  };
113  const char* ConvertTclStringToInternalString(
114  const char *source, int options = 0);
115  const char* ConvertInternalStringToTclString(
116  const char *source, int options = 0);
117  //ETX
118 
119  // Description:
120  // Set/Get a textual Tk configuration option (ex: "-bg").
121  // This should be used instead of SetConfigurationOption as it performs
122  // various characted encoding and escaping tricks.
123  // The characted encoding used in the string will be retrieved by querying
124  // the widget's application CharacterEncoding ivar. Conversion from that
125  // encoding to Tk internal encoding will be performed automatically.
126  virtual void SetTextOption(const char *option, const char *value);
127  virtual const char* GetTextOption(const char *option);
128 
129  // PIMPL Encapsulation for STL containers
130 
131  vtkKWCoreWidgetInternals *Internals;
132 
133 private:
134 
135  vtkKWCoreWidget(const vtkKWCoreWidget&); // Not implemented
136  void operator=(const vtkKWCoreWidget&); // Not implemented
137 };
138 
139 #endif