KWWidgets
vtkKWPushButton.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWPushButton.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 vtkKWPushButton - push button widget
00015 // .SECTION Description
00016 // A simple widget that represents a push button. 
00017 
00018 #ifndef __vtkKWPushButton_h
00019 #define __vtkKWPushButton_h
00020 
00021 #include "vtkKWCoreWidget.h"
00022 
00023 class vtkKWIcon;
00024 
00025 class KWWidgets_EXPORT vtkKWPushButton : public vtkKWCoreWidget
00026 {
00027 public:
00028   static vtkKWPushButton* New();
00029   vtkTypeRevisionMacro(vtkKWPushButton,vtkKWCoreWidget);
00030   void PrintSelf(ostream& os, vtkIndent indent);
00031 
00032   // Description:
00033   // Set the contents label.
00034   virtual void SetText(const char *label);
00035   virtual char *GetText();
00036 
00037   // Description:
00038   // Set/Get the text width (in chars if the button has a text contents, or
00039   // pixels if it has an image contents).
00040   virtual void SetWidth(int width);
00041   virtual int GetWidth();
00042   
00043   // Description:
00044   // Set/Get the text height (in chars if the button has a text contents, or
00045   // pixels if it has an image contents).
00046   virtual void SetHeight(int height);
00047   virtual int GetHeight();
00048 
00049   // Description:
00050   // Specifies a command to associate with the widget. This command is 
00051   // typically invoked when button is pressed.
00052   // The 'object' argument is the object that will have the method called on
00053   // it. The 'method' argument is the name of the method to be called and any
00054   // arguments in string form. If the object is NULL, the method is still
00055   // evaluated as a simple command. 
00056   virtual void SetCommand(vtkObject *object, const char *method);
00057 
00058   // Description:
00059   // Events. The InvokedEvent is triggered when the button is pressed.
00060   //BTX
00061   enum
00062   {
00063     InvokedEvent = 10000
00064   };
00065   //ETX
00066 
00067   // Description:
00068   // Set/Get the background color of the widget
00069   virtual void GetBackgroundColor(double *r, double *g, double *b);
00070   virtual double* GetBackgroundColor();
00071   virtual void SetBackgroundColor(double r, double g, double b);
00072   virtual void SetBackgroundColor(double rgb[3])
00073     { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
00074   
00075   // Description:
00076   // Set/Get the foreground color of the widget
00077   virtual void GetForegroundColor(double *r, double *g, double *b);
00078   virtual double* GetForegroundColor();
00079   virtual void SetForegroundColor(double r, double g, double b);
00080   virtual void SetForegroundColor(double rgb[3])
00081     { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
00082 
00083   // Description:
00084   // Set/Get the highlight thickness, a non-negative value indicating the
00085   // width of the highlight rectangle to draw around the outside of the
00086   // widget when it has the input focus.
00087   virtual void SetHighlightThickness(int);
00088   virtual int GetHighlightThickness();
00089   
00090   // Description:
00091   // Set/Get the active background color of
00092   // the widget. An element (a widget or portion of a widget) is active
00093   // if the mouse cursor is positioned over the element and pressing a mouse
00094   // button will cause some action to occur.
00095   virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
00096   virtual double* GetActiveBackgroundColor();
00097   virtual void SetActiveBackgroundColor(double r, double g, double b);
00098   virtual void SetActiveBackgroundColor(double rgb[3])
00099     { this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
00100   
00101   // Description:
00102   // Set/Get the active foreground color of the widget. An element
00103   // (a widget or portion of a widget) is active if the mouse cursor is
00104   // positioned over the element and pressing a mouse button will cause some
00105   // action to occur.
00106   virtual void GetActiveForegroundColor(double *r, double *g, double *b);
00107   virtual double* GetActiveForegroundColor();
00108   virtual void SetActiveForegroundColor(double r, double g, double b);
00109   virtual void SetActiveForegroundColor(double rgb[3])
00110     { this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
00111   
00112   // Description:
00113   // Set/Get the foreground color of the widget when it is disabled.
00114   virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
00115   virtual double* GetDisabledForegroundColor();
00116   virtual void SetDisabledForegroundColor(double r, double g, double b);
00117   virtual void SetDisabledForegroundColor(double rgb[3])
00118     { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
00119 
00120   // Description:
00121   // Set/Get the border width, a non-negative value indicating the width of
00122   // the 3-D border to draw around the outside of the widget (if such a border
00123   // is being drawn; the Relief option typically determines this).
00124   virtual void SetBorderWidth(int);
00125   virtual int GetBorderWidth();
00126   
00127   // Description:
00128   // Set/Get the 3-D effect desired for the widget. 
00129   // The value indicates how the interior of the widget should appear
00130   // relative to its exterior. 
00131   // Valid constants can be found in vtkKWOptions::ReliefType.
00132   virtual void SetRelief(int);
00133   virtual int GetRelief();
00134   virtual void SetReliefToRaised();
00135   virtual void SetReliefToSunken();
00136   virtual void SetReliefToFlat();
00137   virtual void SetReliefToRidge();
00138   virtual void SetReliefToSolid();
00139   virtual void SetReliefToGroove();
00140 
00141   // Description:
00142   // Set/Get the padding that will be applied around each widget (in pixels).
00143   // Specifies a non-negative value indicating how much extra space to request
00144   // for the widget in the X and Y-direction. When computing how large a
00145   // window it needs, the widget will add this amount to the width it would
00146   // normally need (as determined by the width of the things displayed
00147   // in the widget); if the geometry manager can satisfy this request, the 
00148   // widget will end up with extra internal space around what it displays 
00149   // inside. 
00150   virtual void SetPadX(int);
00151   virtual int GetPadX();
00152   virtual void SetPadY(int);
00153   virtual int GetPadY();
00154 
00155   // Description:
00156   // Set/Get the anchoring.
00157   // Specifies how the information in a widget (e.g. text or a bitmap) is to
00158   // be displayed in the widget.
00159   // Valid constants can be found in vtkKWOptions::AnchorType.
00160   virtual void SetAnchor(int);
00161   virtual int GetAnchor();
00162   virtual void SetAnchorToNorth();
00163   virtual void SetAnchorToNorthEast();
00164   virtual void SetAnchorToEast();
00165   virtual void SetAnchorToSouthEast();
00166   virtual void SetAnchorToSouth();
00167   virtual void SetAnchorToSouthWest();
00168   virtual void SetAnchorToWest();
00169   virtual void SetAnchorToNorthWest();
00170   virtual void SetAnchorToCenter();
00171 
00172   // Description:
00173   // Set/Get the 3-D effect desired for the widget. 
00174   // Specifies an alternative relief for the button, to be used when the mouse
00175   // cursor is over the widget. This option can be used to make toolbar 
00176   // buttons, by configuring SetRelief to Flat and OverRelief to Raised.
00177   // Valid constants can be found in vtkKWOptions::ReliefType.
00178   // If the value of this option is None, then no alternative relief is used
00179   // when the mouse cursor is over the checkbutton. 
00180   virtual void SetOverRelief(int);
00181   virtual int GetOverRelief();
00182   virtual void SetOverReliefToRaised();
00183   virtual void SetOverReliefToSunken();
00184   virtual void SetOverReliefToFlat();
00185   virtual void SetOverReliefToRidge();
00186   virtual void SetOverReliefToSolid();
00187   virtual void SetOverReliefToGroove();
00188   virtual void SetOverReliefToNone();
00189 
00190   // Description:
00191   // Specifies the font to use when drawing text inside the widget. 
00192   // You can use predefined font names (e.g. 'system'), or you can specify
00193   // a set of font attributes with a platform-independent name, for example,
00194   // 'times 12 bold'. In this example, the font is specified with a three
00195   // element list: the first element is the font family, the second is the
00196   // size, the third is a list of style parameters (normal, bold, roman, 
00197   // italic, underline, overstrike). Example: 'times 12 {bold italic}'.
00198   // The Times, Courier and Helvetica font families are guaranteed to exist
00199   // and will be matched to the corresponding (closest) font on your system.
00200   // If you are familiar with the X font names specification, you can also
00201   // describe the font that way (say, '*times-medium-r-*-*-12*').
00202   virtual void SetFont(const char *font);
00203   virtual const char* GetFont();
00204 
00205   // Description:
00206   // Specifies an image to display in the widget. Typically, if the image
00207   // is specified then it overrides other options that specify a bitmap or
00208   // textual value to display in the widget. Invoke vtkKWWidget's 
00209   // SetConfigurationOption("-image", imagename) to use a specific 
00210   // pre-existing Tk image, or call one of the following functions:
00211   // The SetImageToPredefinedIcon method accepts an index to one of the
00212   // predefined icon listed in vtkKWIcon.
00213   // The SetImageToPixels method sets the image using pixel data. It expects
00214   // a pointer to the pixels and the structure of the image, i.e. its width, 
00215   // height and the pixel_size (how many bytes per pixel, say 3 for RGB, or
00216   // 1 for grayscale). If buffer_length = 0, it is computed automatically
00217   // from the previous parameters. If it is not, it will most likely indicate
00218   // that the buffer has been encoded using base64 and/or zlib.
00219   // If pixel_size > 3 (i.e. RGBA), the image is blend the with background
00220   // color of the widget.
00221   // Check the SetCompoundMode method if you want to display both the
00222   // image and the label at the same time.
00223   virtual void SetImageToIcon(vtkKWIcon *icon);
00224   virtual void SetImageToPredefinedIcon(int icon_index);
00225   virtual void SetImageToPixels(
00226     const unsigned char *pixels, int width, int height, int pixel_size,
00227     unsigned long buffer_length = 0);
00228   
00229   // Description:
00230   // Specifies if the widget should display text and bitmaps/images at the
00231   // same time, and if so, where the bitmap/image should be placed relative 
00232   // to the text. 
00233   // Valid constants can be found in vtkKWOptions::CompoundModeType.
00234   // The (default) value CompoundModeNone specifies that the bitmap or image 
00235   // should (if defined) be displayed instead of the text. 
00236   virtual void SetCompoundMode(int);
00237   virtual int GetCompoundMode();
00238   virtual void SetCompoundModeToNone();
00239   virtual void SetCompoundModeToLeft();
00240   virtual void SetCompoundModeToCenter();
00241   virtual void SetCompoundModeToRight();
00242   virtual void SetCompoundModeToTop();
00243   virtual void SetCompoundModeToBottom();
00244 
00245   // Description:
00246   // Update the "enable" state of the object and its internal parts.
00247   // Depending on different Ivars (this->Enabled, the application's 
00248   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00249   // and propagated to its internal parts/subwidgets. This will, for example,
00250   // enable/disable parts of the widget UI, enable/disable the visibility
00251   // of 3D widgets, etc.
00252   virtual void UpdateEnableState();
00253 
00254   // Description:
00255   // Callbacks. Internal, do not use.
00256   virtual void CommandCallback();
00257 
00258 protected:
00259   vtkKWPushButton();
00260   ~vtkKWPushButton();
00261 
00262   // Description:
00263   // Create the widget.
00264   virtual void CreateWidget();
00265 
00266   vtkSetStringMacro(ButtonText);
00267   char* ButtonText;
00268 
00269   char *Command;
00270   virtual void InvokeCommand();
00271 
00272 private:
00273   vtkKWPushButton(const vtkKWPushButton&); // Not implemented
00274   void operator=(const vtkKWPushButton&); // Not implemented
00275 };
00276 
00277 
00278 #endif
00279 
00280 
00281