00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWCoreWidget.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWCoreWidget - a core widget. 00015 // .SECTION Description 00016 // A superclass for all core widgets, i.e. C++ wrappers around simple 00017 // Tk widgets. 00018 // .SECTION Thanks 00019 // This work is part of the National Alliance for Medical Image 00020 // Computing (NAMIC), funded by the National Institutes of Health 00021 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00022 // Information on the National Centers for Biomedical Computing 00023 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00024 00025 #ifndef __vtkKWCoreWidget_h 00026 #define __vtkKWCoreWidget_h 00027 00028 #include "vtkKWWidget.h" 00029 00030 class vtkKWCoreWidgetInternals; 00031 00032 class KWWidgets_EXPORT vtkKWCoreWidget : public vtkKWWidget 00033 { 00034 public: 00035 static vtkKWCoreWidget* New(); 00036 vtkTypeRevisionMacro(vtkKWCoreWidget, vtkKWWidget); 00037 void PrintSelf(ostream& os, vtkIndent indent); 00038 00039 // Description: 00040 // Set/Get the -state option to "normal" (1) or "disabled" (0) or "readonly" 00041 // (2, if supported). 00042 // Valid constants can be found in vtkKWOptions::StateType. 00043 // This should not be used directly, this is done by 00044 // SetEnabled()/UpdateEnableState(). 00045 // TODO: should be in protected: 00046 virtual void SetState(int); 00047 virtual int GetState(); 00048 virtual void SetStateToDisabled(); 00049 virtual void SetStateToNormal(); 00050 virtual void SetStateToReadOnly(); 00051 00052 // Description: 00053 // Arranges for window to be displayed above all of its siblings in the 00054 // stacking order. 00055 virtual void Raise(); 00056 00057 // Description: 00058 // Set/Get a Tk configuration option (ex: "-bg"). 00059 // Make *sure* you check the class (and subclasses) API for a 00060 // C++ method that would already act as a front-end to the Tk option. 00061 // For example, the SetBackgroundColor() method should be used instead of 00062 // accessing the -bg Tk option. 00063 // Note that SetConfigurationOption will enclose the value inside 00064 // curly braces {} as a convenience. 00065 // SetConfigurationOption returns 1 on success, 0 otherwise. 00066 virtual int SetConfigurationOption(const char* option, const char *value); 00067 virtual int HasConfigurationOption(const char* option); 00068 virtual const char* GetConfigurationOption(const char* option); 00069 virtual int GetConfigurationOptionAsInt(const char* option); 00070 virtual int SetConfigurationOptionAsInt(const char* option, int value); 00071 virtual double GetConfigurationOptionAsDouble(const char* option); 00072 virtual int SetConfigurationOptionAsDouble(const char* option, double value); 00073 virtual void GetConfigurationOptionAsColor( 00074 const char* option, double *r, double *g, double *b); 00075 virtual double* GetConfigurationOptionAsColor(const char* option); 00076 virtual void SetConfigurationOptionAsColor( 00077 const char* option, double r, double g, double b); 00078 virtual void SetConfigurationOptionAsColor(const char* option, double rgb[3]) 00079 { this->SetConfigurationOptionAsColor(option, rgb[0], rgb[1], rgb[2]); }; 00080 virtual void GetDefaultConfigurationOptionAsColor( 00081 const char* option, double *r, double *g, double *b); 00082 virtual double* GetDefaultConfigurationOptionAsColor(const char* option); 00083 00084 protected: 00085 vtkKWCoreWidget(); 00086 ~vtkKWCoreWidget(); 00087 00088 // Description: 00089 // Create the widget. 00090 virtual void CreateWidget(); 00091 00092 // Description: 00093 // Get the Tk string type of the widget. 00094 virtual const char* GetType(); 00095 00096 // Description: 00097 // Convert a Tcl string (stored internally as UTF-8/Unicode) to another 00098 // internal format (given the widget's application CharacterEncoding), 00099 // and vice-versa. 00100 // The 'source' string is the source to convert. 00101 // It returns a pointer to where the converted string can be found 00102 // (copy the result to safe storage immediately). 00103 // The 'options' can be set to perform some replacements/escaping. 00104 // ConvertStringEscapeInterpretable will attempt to escape all characters 00105 // that can be interpreted (when found between a pair of quotes for 00106 // example): $ [ ] " 00107 //BTX 00108 enum 00109 { 00110 ConvertStringEscapeCurlyBraces = 1, 00111 ConvertStringEscapeInterpretable = 2 00112 }; 00113 const char* ConvertTclStringToInternalString( 00114 const char *source, int options = 0); 00115 const char* ConvertInternalStringToTclString( 00116 const char *source, int options = 0); 00117 //ETX 00118 00119 // Description: 00120 // Set/Get a textual Tk configuration option (ex: "-bg"). 00121 // This should be used instead of SetConfigurationOption as it performs 00122 // various characted encoding and escaping tricks. 00123 // The characted encoding used in the string will be retrieved by querying 00124 // the widget's application CharacterEncoding ivar. Conversion from that 00125 // encoding to Tk internal encoding will be performed automatically. 00126 virtual void SetTextOption(const char *option, const char *value); 00127 virtual const char* GetTextOption(const char *option); 00128 00129 // PIMPL Encapsulation for STL containers 00130 00131 vtkKWCoreWidgetInternals *Internals; 00132 00133 private: 00134 00135 vtkKWCoreWidget(const vtkKWCoreWidget&); // Not implemented 00136 void operator=(const vtkKWCoreWidget&); // Not implemented 00137 }; 00138 00139 #endif