debian/tmp/usr/include/KWWidgets/vtkKWTkUtilities.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWTkUtilities.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 vtkKWTkUtilities - class that supports basic Tk functions
00015 // .SECTION Description
00016 // vtkKWTkUtilities provides methods to perform common Tk operations.
00017 
00018 #ifndef __vtkKWTkUtilities_h
00019 #define __vtkKWTkUtilities_h
00020 
00021 #include "vtkObject.h"
00022 #include "vtkKWWidgets.h" // Needed for export symbols directives
00023 
00024 // This has to be here because on HP varargs are included in 
00025 // tcl.h and they have different prototypes for va_start so
00026 // the build fails. Defining HAS_STDARG prevents that.
00027 
00028 #if defined(__hpux) && !defined(HAS_STDARG)
00029 #define HAS_STDARG
00030 #endif
00031 
00032 #include <stdarg.h> // Needed for "va_list" argument of EstimateFormatLength.
00033 
00034 class vtkKWWidget;
00035 class vtkKWCoreWidget;
00036 class vtkKWApplication;
00037 class vtkKWIcon;
00038 class vtkRenderWindow;
00039 struct Tcl_Interp;
00040 
00041 class KWWidgets_EXPORT vtkKWTkUtilities : public vtkObject
00042 {
00043 public:
00044   static vtkKWTkUtilities* New();
00045   vtkTypeRevisionMacro(vtkKWTkUtilities,vtkObject);
00046   void PrintSelf(ostream& os, vtkIndent indent);
00047 
00048   // Description:
00049   // Return the Tcl name of a VTK object
00050   static const char* GetTclNameFromPointer(
00051     Tcl_Interp *interp, vtkObject *obj);
00052   static const char* GetTclNameFromPointer(
00053     vtkKWApplication *app, vtkObject *obj);
00054     
00055   // Description:
00056   // Evaluate a Tcl string. The string is passed to printf() first (as format
00057   // specifier) along with the remaining arguments.
00058   // The second prototype can be used by similar variable arguments method: it
00059   // needs to walk through the var_args list twice though. The only
00060   // portable way to do this is to pass two copies of the list's start
00061   // pointer.
00062   // Convenience methods are provided to specify a vtkKWApplication
00063   // instead of the Tcl interpreter.
00064   // Return a pointer to the Tcl interpreter result buffer.
00065   //BTX
00066   static const char* EvaluateString(
00067     Tcl_Interp *interp, const char *format, ...);
00068   static const char* EvaluateString(
00069     vtkKWApplication *app, const char *format, ...);
00070   //ETX
00071   static const char* EvaluateStringFromArgs(
00072     Tcl_Interp *interp, const char *format, 
00073     va_list var_args1, va_list var_args2);
00074   static const char* EvaluateStringFromArgs(
00075     vtkKWApplication *app, const char *format, 
00076     va_list var_args1, va_list var_args2);
00077   static const char* EvaluateSimpleString(
00078     Tcl_Interp *interp, const char *str);
00079   static const char* EvaluateSimpleString(
00080     vtkKWApplication *app, const char *str);
00081 
00082   // Description:
00083   // Evaluate a Tcl string that was encoded in a buffer using zlib 
00084   // and/or base64. 
00085   static const char* EvaluateEncodedString(
00086     Tcl_Interp *interp, 
00087     const unsigned char *buffer, 
00088     unsigned long length,
00089     unsigned long decoded_length);
00090   
00091   // Description:
00092   // Create a Tcl callback command.
00093   // The 'command' argument is a pointer to the command to be created.
00094   // The 'object' argument is the object that will have the method called on
00095   // it. The 'method' argument is the name of the method to be called and any
00096   // arguments in string form. If the object is NULL, the method is still
00097   // evaluated as a simple command. 
00098   // Note that 'command' is allocated automatically using the 'new' 
00099   // operator. If it is not NULL, it is deallocated first using 'delete []'.
00100   static void CreateObjectMethodCommand(
00101     vtkKWApplication *app, 
00102     char **command, vtkObject *object, const char *method);
00103   static void CreateObjectMethodCommand(
00104     Tcl_Interp *interp, 
00105     char **command, vtkObject *object, const char *method);
00106 
00107   // Description:
00108   // Get the RGB components that correspond to 'color' (say, #223344)
00109   // in the widget given by 'widget' (say, .foo.bar). Color may be specified
00110   // in any of the forms acceptable for a Tk color option.
00111   // A convenience method is provided to query a vtkKWWidget directly.
00112   static void GetRGBColor(Tcl_Interp *interp,
00113                           const char *widget, 
00114                           const char *color, 
00115                           double *r, double *g, double *b);
00116   static void GetRGBColor(vtkKWWidget *widget, 
00117                           const char *color, 
00118                           double *r, double *g, double *b);
00119 
00120   // Description:
00121   // Get the RGB components that correspond to the color 'option'
00122   // (say -bg, -fg, etc.) of the widget given by 'widget' (say, .foo.bar).
00123   // A convenience method is provided to query a vtkKWWidget directly.
00124   static void GetOptionColor(Tcl_Interp *interp,
00125                              const char *widget, 
00126                              const char *option, 
00127                              double *r, double *g, double *b);
00128   static void GetOptionColor(vtkKWWidget *widget,
00129                              const char *option, 
00130                              double *r, double *g, double *b);
00131   static double* GetOptionColor(vtkKWWidget *widget,
00132                                 const char *option);
00133   
00134   // Description:
00135   // Get the RGB components that correspond to the default color 'option'
00136   // (say the default value for -bg, -fg, etc.) of the widget given by
00137   // 'widget' (say, .foo.bar).
00138   // A convenience method is provided to query a vtkKWWidget directly.
00139   static void GetDefaultOptionColor(Tcl_Interp *interp,
00140                                     const char *widget, 
00141                                     const char *option, 
00142                                     double *r, double *g, double *b);
00143   static void GetDefaultOptionColor(vtkKWWidget *widget,
00144                                     const char *option, 
00145                                     double *r, double *g, double *b);
00146   static double* GetDefaultOptionColor(vtkKWWidget *widget,
00147                                        const char *option);
00148   
00149   // Description:
00150   // Set the RGB components of the color 'option'
00151   // (say -bg, -fg, etc.) of the widget given by 'widget' (say, .foo.bar).
00152   // A convenience method is provided to query a vtkKWWidget directly.
00153   static void SetOptionColor(Tcl_Interp *interp,
00154                              const char *widget, 
00155                              const char *option, 
00156                              double r, double g, double b);
00157   static void SetOptionColor(vtkKWWidget *widget,
00158                              const char *option, 
00159                              double r, double g, double b);
00160   
00161   // Description:
00162   // Query user for color using a Tk color dialog
00163   // Return 1 on success, 0 otherwise.
00164   static int QueryUserForColor(vtkKWApplication *app,
00165                                vtkKWWidget *dialog_parent,
00166                                const char *dialog_title,
00167                                double in_r, double in_g, double in_b,
00168                                double *out_r, double *out_g, double *out_b);
00169 
00170   // Description:
00171   // Get the geometry of a widget given by 'widget' (say, .foo.bar).
00172   // The geometry is the width, height and position of the widget. 
00173   // Any of them can be a NULL pointer, they will be safely ignored.
00174   // Return 1 on success, 0 otherwise.
00175   // A convenience method is provided to query a vtkKWWidget directly.
00176   static int GetGeometry(Tcl_Interp *interp,
00177                          const char *widget, 
00178                          int *width, int *height, int *x, int *y);
00179   static int GetGeometry(vtkKWWidget *widget,
00180                          int *width, int *height, int *x, int *y);
00181 
00182   // Description:
00183   // Check if a pair of screen coordinates (x, y) are within the area defined
00184   // by the widget given by 'widget' (say, .foo.bar).
00185   // Return 1 if inside, 0 otherwise.
00186   // A convenience method is provided to query a vtkKWWidget directly.
00187   // ContainsCoordinatesForSpecificType will check if 'widget' is of a
00188   // specific type (or a subclass of that type), and if not will inspect
00189   // its children. It will return the widget that contains the coordinates
00190   // or NULL if not found.
00191   static int ContainsCoordinates(Tcl_Interp *interp,
00192                                  const char *widget, 
00193                                  int x, int y);
00194   static int ContainsCoordinates(vtkKWWidget *widget,
00195                                  int x, int y);
00196   static vtkKWWidget* ContainsCoordinatesForSpecificType(
00197     vtkKWWidget *widget, int x, int y, const char *classname);
00198   
00199   // Description:
00200   // Update a Tk photo given by its name 'photo_name' using pixels stored in
00201   // 'pixels' and structured as a 'width' x 'height' x 'pixel_size' (number
00202   // of bytes per pixel, 3 for RGB for example).
00203   // If 'buffer_length' is 0, compute it automatically by multiplying
00204   // 'pixel_size', 'width' and 'height' together.
00205   // If UPDATE_PHOTO_OPTION_FLIP_V is set in 'update_option', flip the image
00206   // buffer vertically.
00207   // A convenience method is provided to specify the vtkKWApplication this
00208   // photo belongs to, instead of the Tcl interpreter.
00209   // Return 1 on success, 0 otherwise.
00210   //BTX
00211   enum 
00212   { 
00213     UpdatePhotoOptionFlipVertical = 1
00214   };
00215   //ETX
00216   static int UpdatePhoto(Tcl_Interp *interp,
00217                          const char *photo_name,
00218                          const unsigned char *pixels, 
00219                          int width, int height,
00220                          int pixel_size,
00221                          unsigned long buffer_length = 0,
00222                          int update_options = 0);
00223   static int UpdatePhoto(vtkKWApplication *app,
00224                          const char *photo_name,
00225                          const unsigned char *pixels, 
00226                          int width, int height,
00227                          int pixel_size,
00228                          unsigned long buffer_length = 0,
00229                          int update_options = 0);
00230 
00231   // Description:
00232   // Update a Tk photo given by its name 'photo_name' using pixels stored in
00233   // the icon 'icon'. 
00234   static int UpdatePhotoFromIcon(vtkKWApplication *app,
00235                                  const char *photo_name,
00236                                  vtkKWIcon *icon,
00237                                  int update_options = 0);
00238   static int UpdatePhotoFromPredefinedIcon(vtkKWApplication *app,
00239                                            const char *photo_name,
00240                                            int icon_index,
00241                                            int update_options = 0);
00242 
00243   // Description:
00244   // Update a Tk photo given by its name 'photo_name' using pixels stored in
00245   // 'pixels' and structured as a 'width' x 'height' x 'pixel_size' (number
00246   // of bytes per pixel, 3 for RGB for example).
00247   // If a file 'file_name'.png is found in 'directory' or 
00248   // 'directory/Resources' then an attempt is made to update the photo using
00249   // this file. If no file is found, the remaining parameters are used
00250   // to update the photo by calling UpdatePhoto().
00251   // As a convenience, if 'photo_name' is NULL, 'file_name' is used instead.
00252   // Note that only the PNG file format is supported so far (do not provide
00253   // the .png extension to 'file_name').
00254   // Return 1 on success, 0 otherwise.
00255   // A convenience method is provided to specify the vtkKWApplication this
00256   // photo belongs to, instead of the Tcl interpreter.
00257   static int UpdateOrLoadPhoto(Tcl_Interp *interp,
00258                                const char *photo_name,
00259                                const char *file_name,
00260                                const char *directory,
00261                                const unsigned char *pixels, 
00262                                int width, int height,
00263                                int pixel_size,
00264                                unsigned long buffer_length = 0);
00265   static int UpdateOrLoadPhoto(vtkKWApplication *app,
00266                                const char *photo_name,
00267                                const char *file_name,
00268                                const char *directory,
00269                                const unsigned char *pixels, 
00270                                int width, int height,
00271                                int pixel_size,
00272                                unsigned long buffer_length = 0);
00273 
00274   // Description:
00275   // Specifies an image to display in a widget. Typically, if the image
00276   // is specified then it overrides other options that specify a bitmap or
00277   // textual value to display in the widget.
00278   // Set the image option using pixel data. The parameters are the same
00279   // as the one used in UpdatePhoto().
00280   // An image is created and associated to the Tk -image option or 
00281   // image_option if not NULL (ex: -selectimage).
00282   static void SetImageOptionToPixels(
00283     vtkKWCoreWidget *widget,
00284     const unsigned char *pixels, 
00285     int width, int height, 
00286     int pixel_size = 4,
00287     unsigned long buffer_length = 0,
00288     const char *image_option = 0);
00289 
00290   // Description:
00291   // Query if a Tk photo given by its name 'photo_name' exists.
00292   // A convenience method is provided to specify the vtkKWApplication this
00293   // photo belongs to, instead of the Tcl interpreter.
00294   static int FindPhoto(Tcl_Interp *interp, const char *photo_name);
00295   static int FindPhoto(vtkKWApplication *app, const char *photo_name);
00296 
00297   // Description:
00298   // Get the height of a Tk photo given by its name 'photo_name'.
00299   // If the photo does not exist, return 0 and issue a warning.
00300   // A convenience method is provided to specify the vtkKWApplication this
00301   // photo belongs to, instead of the Tcl interpreter.
00302   // A convenience method is provided to specify a vtkKWWidget this photo
00303   // has been assigned to using the -image Tk option.
00304   static int GetPhotoHeight(Tcl_Interp *interp, const char *photo_name);
00305   static int GetPhotoHeight(vtkKWApplication *app, const char *photo_name);
00306   static int GetPhotoHeight(vtkKWWidget *widget);
00307 
00308   // Description:
00309   // Get the width of a Tk photo given by its name 'photo_name'.
00310   // If the photo does not exist, return 0 and issue a warning.
00311   // A convenience method is provided to specify the vtkKWApplication this
00312   // photo belongs to, instead of the Tcl interpreter.
00313   static int GetPhotoWidth(Tcl_Interp *interp, const char *photo_name);
00314   static int GetPhotoWidth(vtkKWApplication *app, const char *photo_name);
00315 
00316   // Description:
00317   // Change the weight attribute of a Tk font specification given by 'font'.
00318   // The new font specification is copied to 'new_font'. 
00319   // It is up to the caller to allocate enough space in 'new_font'.
00320   // Return 1 on success, 0 otherwise.
00321   static int ChangeFontWeightToBold(
00322     Tcl_Interp *interp, const char *font, char *new_font);
00323   static int ChangeFontWeightToNormal(
00324     Tcl_Interp *interp, const char *font, char *new_font);
00325 
00326   // Description:
00327   // Change the weight attribute of a 'widget' -font option.
00328   // A convenience method is provided to query a vtkKWWidget directly.
00329   // Return 1 on success, 0 otherwise.
00330   static int ChangeFontWeightToBold(Tcl_Interp *interp, const char *widget);
00331   static int ChangeFontWeightToBold(vtkKWWidget *widget);
00332   static int ChangeFontWeightToNormal(Tcl_Interp *interp, const char *widget);
00333   static int ChangeFontWeightToNormal(vtkKWWidget *widget);
00334 
00335   // Description:
00336   // Change the slant attribute of a Tk font specification given by 'font'.
00337   // The new font specification is copied to 'new_font'. 
00338   // It is up to the caller to allocate enough space in 'new_font'.
00339   // Return 1 on success, 0 otherwise.
00340   static int ChangeFontSlantToItalic(
00341     Tcl_Interp *interp, const char *font, char *new_font);
00342   static int ChangeFontSlantToRoman(
00343     Tcl_Interp *interp, const char *font, char *new_font);
00344 
00345   // Description:
00346   // Change the slant attribute of a 'widget' -font option.
00347   // A convenience method is provided to query a vtkKWWidget directly.
00348   // Return 1 on success, 0 otherwise.
00349   static int ChangeFontSlantToItalic(Tcl_Interp *interp, const char *widget);
00350   static int ChangeFontSlantToItalic(vtkKWWidget *widget);
00351   static int ChangeFontSlantToRoman(Tcl_Interp *interp, const char *widget);
00352   static int ChangeFontSlantToRoman(vtkKWWidget *widget);
00353 
00354   // Description:
00355   // Change the size attribute of a Tk font specification given by 'font'.
00356   // The new font specification is copied to 'new_font'. 
00357   // It is up to the caller to allocate enough space in 'new_font'.
00358   // Return 1 on success, 0 otherwise.
00359   static int ChangeFontSize(
00360     Tcl_Interp *interp, const char *font, int new_size, char *new_font);
00361 
00362   // Description:
00363   // Change the size attribute of a 'widget' -font option.
00364   // A convenience method is provided to query a vtkKWWidget directly.
00365   // Return 1 on success, 0 otherwise.
00366   static int ChangeFontSize(
00367     Tcl_Interp *interp, const char *widget, int new_size);
00368   static int ChangeFontSize(vtkKWWidget *widget, int new_size);
00369 
00370   // Description:
00371   // Get the real actual font (i.e. its list of attributes) given a font, 
00372   // font name, or incomplete font specification.
00373   // It is up to the caller to allocate enough space in 'real_font'.
00374   // Return 1 on success, 0 otherwise.
00375   static int GetRealActualFont(
00376     Tcl_Interp *interp, const char *font, char *real_font);
00377 
00378   // Description:
00379   // Get the amount of space the string txt when displayed in widget (using
00380   // the default widget's -font parameter). Store the result in 'w'.
00381   // Return 1 on success, 0 otherwise.
00382   static int GetFontMeasure(vtkKWWidget *widget, const char *txt, int *w);
00383 
00384   // Description:
00385   // Get the number of colums and rows defined in the grid layout of
00386   // the widget given by 'widget' (say, .foo.bar).
00387   // A convenience method is provided to query a vtkKWWidget directly.
00388   // Return 1 on success, 0 otherwise.
00389   static int GetGridSize(Tcl_Interp *interp,
00390                          const char *widget,
00391                          int *nb_of_cols,
00392                          int *nb_of_rows);
00393   static int GetGridSize(vtkKWWidget *widget,
00394                          int *nb_of_cols,
00395                          int *nb_of_rows);
00396 
00397   // Description:
00398   // Get the grid position (column, row) of the widget given by 'widget'
00399   // (say, .foo.bar).
00400   // We assume that the current widget layout is a Tk grid.
00401   // A convenience method is provided to query a vtkKWWidget directly.
00402   // Return 1 on success, 0 otherwise.
00403   static int GetWidgetPositionInGrid(Tcl_Interp *interp,
00404                                      const char *widget,
00405                                      int *col,
00406                                      int *row);
00407   static int GetWidgetPositionInGrid(vtkKWWidget *widget,
00408                                      int *col,
00409                                      int *row);
00410 
00411   // Description:
00412   // Get the bounding box size (width, height) of the slaves packed in the
00413   // widget given by 'widget' (say, .foo.bar), i.e. the largest width
00414   // and height of the slaves packed in the widget, including padding options.
00415   // We assume that the current widget layout is a Tk pack.
00416   // A convenience method is provided to query a vtkKWWidget directly.
00417   // Return 1 on success, 0 otherwise.
00418   static int GetSlavesBoundingBoxInPack(Tcl_Interp *interp,
00419                                         const char *widget,
00420                                         int *width,
00421                                         int *height);
00422   static int GetSlavesBoundingBoxInPack(vtkKWWidget *widget,
00423                                         int *width,
00424                                         int *height);
00425 
00426   // Description:
00427   // Get the horizontal position 'x' in pixels of a slave widget given by
00428   // 'slave' (say .foo.bar.sl) in the widget given by 'widget' (say .foo.bar).
00429   // This can be used in case 'winfo x' does not work because the widget
00430   // has not been mapped yet.
00431   // We assume that the current widget layout is a Tk pack.
00432   // A convenience method is provided to query vtkKWWidget(s) directly.
00433   // Return 1 on success, 0 otherwise.
00434   static int GetSlaveHorizontalPositionInPack(Tcl_Interp *interp,
00435                                               const char *widget,
00436                                               const char *slave,
00437                                               int *x);
00438   static int GetSlaveHorizontalPositionInPack(vtkKWWidget *widget,
00439                                               vtkKWWidget *slave,
00440                                               int *x);
00441 
00442   // Description:
00443   // Get the padding values of the widget given by 'widget' (say .foo.bar)
00444   // in its layout.
00445   // We assume that the current widget layout is a Tk pack.
00446   // Return 1 on success, 0 otherwise.
00447   static int GetWidgetPaddingInPack(Tcl_Interp *interp,
00448                                     const char *widget,
00449                                     int *ipadx,
00450                                     int *ipady,
00451                                     int *padx,
00452                                     int *pady);
00453 
00454   // Description:
00455   // Get the container a widget given by 'widget' (say .foo.bar) is packed in.
00456   // This is similar to the Tk -in pack option.
00457   // Write the container widget name to the output stream 'in'.
00458   // We assume that the current widget layout is a Tk pack.
00459   // A convenience method is provided to query a vtkKWWidget directly.
00460   // Return 1 on success, 0 otherwise.
00461   static int GetMasterInPack(Tcl_Interp *interp,
00462                              const char *widget,
00463                              ostream &in);
00464   static int GetMasterInPack(vtkKWWidget *widget,
00465                              ostream &in);
00466 
00467   // Description:
00468   // Get the column widths of a grid (i.e. a master widget that has been grid).
00469   // If 'allocate' is true, the resulting array (col_widths) is allocated
00470   // by the function to match the number of columns.
00471   // The function iterates over cells to request the width of
00472   // each slave (winfo reqwidth).
00473   static int GetGridColumnWidths(Tcl_Interp *interp,
00474                                  const char *widget,
00475                                  int *nb_of_cols,
00476                                  int **col_widths,
00477                                  int allocate = 0);
00478 
00479   // Description:
00480   // Synchronize the columns minimum size of different widgets that have
00481   // been grid. If 'factors' is non-null, it is used as an array of
00482   // multiplication factor to apply to each column minimum size.
00483   // If 'weights' is non-null, it is used as an array of weight
00484   // to apply to each column through columnconfigure -weight.
00485   static int SynchroniseGridsColumnMinimumSize(Tcl_Interp *interp,
00486                                                int nb_of_widgets,
00487                                                const char **widgets,
00488                                                const float *factors = 0,
00489                                                const int *weights = 0);
00490 
00491   // Description:
00492   // Synchronize the width of a set of labels given by an array
00493   // of 'nb_of_widgets' widgets stored in 'widgets'. The maximum size of
00494   // the labels is found and assigned to each label. 
00495   // Additionally it will apply the 'options' to/ each widget (if any).
00496   // A convenience method is provided to specify the vtkKWApplication these
00497   // widgets belongs to, instead of the Tcl interpreter.
00498   // Return 1 on success, 0 otherwise.
00499   static int SynchroniseLabelsMaximumWidth(Tcl_Interp *interp,
00500                                            int nb_of_widgets,
00501                                            const char **widgets,
00502                                            const char *options = 0);
00503   static int SynchroniseLabelsMaximumWidth(vtkKWApplication *app,
00504                                            int nb_of_widgets,
00505                                            const char **widgets,
00506                                            const char *options = 0);
00507 
00508   // Description:
00509   // Store the slaves packed in the widget given by 'widget' (say, .foo.bar)
00510   // in the array 'slaves'. This array is  allocated automatically.
00511   // We assume that the current widget layout is a Tk pack.
00512   // A convenience method is provided to query a vtkKWWidget directly.
00513   // Return the number of slaves.
00514   static int GetSlavesInPack(Tcl_Interp *interp,
00515                              const char *widget,
00516                              char ***slaves);
00517   static int GetSlavesInPack(vtkKWWidget *widget,
00518                              char ***slaves);
00519 
00520   // Description:
00521   // Browse all the slaves of the widget given by 'widget' (say, .foo.bar)
00522   // and store the slave packed before 'slave' in 'previous_slave', and the
00523   // slave packed after 'slave' in 'next_slave'
00524   // We assume that the current widget layout is a Tk pack.
00525   // A convenience method is provided to query a vtkKWWidget directly.
00526   // Return 1 if 'slave' was found, 0 otherwise
00527   static int GetPreviousAndNextSlaveInPack(Tcl_Interp *interp,
00528                                            const char *widget,
00529                                            const char *slave,
00530                                            ostream &previous_slave,
00531                                            ostream &next_slave);
00532   static int GetPreviousAndNextSlaveInPack(vtkKWWidget *widget,
00533                                            vtkKWWidget *slave,
00534                                            ostream &previous_slave,
00535                                            ostream &next_slave);
00536   // Description:
00537   // Take screendump of the widget given by 'widget' (say, .foo.bar) and store
00538   // it into a png file given by 'fname'.
00539   // A convenience method is provided to query a vtkKWWidget directly.
00540   // Return 1 on success, 0 otherwise.
00541   static int TakeScreenDump(Tcl_Interp *interp,
00542                             const char *wname, 
00543                             const char *fname, 
00544                             int top = 0, int bottom = 0, 
00545                             int left = 0, int right = 0);
00546   static int TakeScreenDump(vtkKWWidget *widget,
00547                             const char *fname, 
00548                             int top = 0, int bottom = 0, 
00549                             int left = 0, int right = 0);
00550 
00551   // Description:
00552   // Set widget's toplevel mouse cursor.
00553   // Provide a NULL or empty cursor to reset it to default.
00554   static int SetTopLevelMouseCursor(Tcl_Interp *interp,
00555                                     const char *widget,
00556                                     const char *cursor);
00557   static int SetTopLevelMouseCursor(vtkKWWidget *widget,
00558                                     const char *cursor);
00559 
00560   // Description:
00561   // Return 1 if window is a toplevel, 0 otherwise
00562   static int IsTopLevel(Tcl_Interp *interp,
00563                         const char *widget);
00564   static int IsTopLevel(vtkKWWidget *widget);
00565 
00566   // Description:
00567   // Withdraw toplevel
00568   static void WithdrawTopLevel(Tcl_Interp *interp,
00569                               const char *widget);
00570   static void WithdrawTopLevel(vtkKWWidget *widget);
00571 
00572   // Description:
00573   // If a Tcl script file is currently being evaluated (i.e. there is a call
00574   // to Tcl_EvalFile active or there is an active invocation of the source 
00575   // command), then this command returns the name of the innermost file
00576   // being processed.
00577   static const char *GetCurrentScript(Tcl_Interp *interp);
00578   static const char *GetCurrentScript(vtkKWApplication *app);
00579 
00580   // Description:
00581   // Create a timer handler, i.e. arranges for a command to be executed
00582   // exactly once 'ms' milliseconds later, or when the application is idle,
00583   // i.e. the next time the event loop is entered and there are no events to
00584   // process.
00585   // The 'object' argument is the object that will have the method called on
00586   // it. The 'method' argument is the name of the method to be called and any
00587   // arguments in string form. If the object is NULL, the method is still
00588   // evaluated as a simple command. 
00589   // Returns a string identifier that can be used to cancel the timer.
00590   static const char* CreateTimerHandler(
00591     Tcl_Interp *interp, 
00592     unsigned long ms, 
00593     vtkObject *object, const char *method);
00594   static const char* CreateTimerHandler(
00595     vtkKWApplication *app, 
00596     unsigned long ms, 
00597     vtkObject *object, const char *method);
00598   static const char* CreateIdleTimerHandler(
00599     Tcl_Interp *interp, 
00600     vtkObject *object, const char *method);
00601   static const char* CreateIdleTimerHandler(
00602     vtkKWApplication *app, 
00603     vtkObject *object, const char *method);
00604 
00605   // Description:
00606   // Cancel one or all event handlers, i.e. cancel all delayed command that
00607   // were registered using the 'after' command or CreateTimerHandler methods.
00608   static void CancelTimerHandler(Tcl_Interp *interp, const char *id);
00609   static void CancelTimerHandler(vtkKWApplication *app, const char *id);
00610   static void CancelAllTimerHandlers(Tcl_Interp *interp);
00611   static void CancelAllTimerHandlers(vtkKWApplication *app);
00612 
00613   // Description:
00614   // Rings the bell on the display of the application's main window
00615   static void Bell(Tcl_Interp *interp);
00616   static void Bell(vtkKWApplication *app);
00617 
00618   // Description:
00619   // Process/update pending events. This command is used to bring the 
00620   // application "up to date" by entering the event loop repeatedly until
00621   // all pending events (including idle callbacks) have been processed. 
00622   static void ProcessPendingEvents(Tcl_Interp *interp);
00623   static void ProcessPendingEvents(vtkKWApplication *app);
00624 
00625   // Description:
00626   // Process/update idle tasks. This causes operations that are normally 
00627   // deferred, such as display updates and window layout calculations, to be
00628   // performed immediately. 
00629   static void ProcessIdleTasks(Tcl_Interp *interp);
00630   static void ProcessIdleTasks(vtkKWApplication *app);
00631 
00632   // Description:
00633   // Check for pending interaction events, i.e. mouse button up/down, window
00634   // being dragged/resized/moved, paint, window activation, etc.
00635   // On Unix, one needs to pass a vtkRenderWindow (on Win32, NULL is fine)
00636   // Return 1 if events are pending, 0 otherwise
00637   static int CheckForPendingInteractionEvents(vtkRenderWindow *win);
00638 
00639   // Description:
00640   // Get the coordinates of the mouse pointer in the screen widget is in.
00641   // Return 1 on success, 0 otherwise.
00642   static int GetMousePointerCoordinates(
00643     Tcl_Interp *interp, const char *widget, int *x, int *y);
00644   static int GetMousePointerCoordinates(
00645     vtkKWWidget *widget, int *x, int *y);
00646 
00647   // Description:
00648   // Get the coordinates of the upper-left corner of widget in its screen.
00649   // Return 1 on success, 0 otherwise.
00650   static int GetWidgetCoordinates(
00651     Tcl_Interp *interp, const char *widget, int *x, int *y);
00652   static int GetWidgetCoordinates(
00653     vtkKWWidget *widget, int *x, int *y);
00654 
00655   // Description:
00656   // Get the relative coordinates of the upper-left corner of widget in its
00657   // widget's parent.
00658   // Return 1 on success, 0 otherwise.
00659   static int GetWidgetRelativeCoordinates(
00660     Tcl_Interp *interp, const char *widget, int *x, int *y);
00661   static int GetWidgetRelativeCoordinates(
00662     vtkKWWidget *widget, int *x, int *y);
00663 
00664   // Description:
00665   // Get the width and height of widget in its screen.
00666   // When a window is first created its width will be 1 pixel; the width will
00667   // eventually be changed by a geometry manager to fulfill the window's needs.
00668   // If you need the true width immediately after creating a widget, invoke
00669   // ProcessPendingEvents to force the geometry manager to arrange it, or use
00670   // GetWidgetRequestedSize to get the window's requested size instead of its
00671   // actual size. 
00672   // Return 1 on success, 0 otherwise.
00673   static int GetWidgetSize(
00674     Tcl_Interp *interp, const char *widget, int *w, int *h);
00675   static int GetWidgetSize(
00676     vtkKWWidget *widget, int *w, int *h);
00677 
00678   // Description:
00679   // Get the requested width and height of widget in its screen.
00680   // This is the value used by window's geometry manager to compute its
00681   // geometry.
00682   // Return 1 on success, 0 otherwise.
00683   static int GetWidgetRequestedSize(
00684     Tcl_Interp *interp, const char *widget, int *w, int *h);
00685   static int GetWidgetRequestedSize(
00686     vtkKWWidget *widget, int *w, int *h);
00687 
00688   // Description:
00689   // Get the widget class (i.e. Tk type).
00690   static const char* GetWidgetClass(
00691     Tcl_Interp *interp, const char *widget);
00692   static const char* GetWidgetClass(
00693     vtkKWWidget *widget);
00694 
00695   // Description:
00696   // Get the width and height (in pixels) of the screen the widget is in.
00697   // Return 1 on success, 0 otherwise.
00698   static int GetScreenSize(
00699     Tcl_Interp *interp, const char *widget, int *w, int *h);
00700   static int GetScreenSize(
00701     vtkKWWidget *widget, int *w, int *h);
00702 
00703   // Description:
00704   // Get windowing system.
00705   // Returns the current Tk windowing system, one of x11 (X11-based), 
00706   // win32 (MS Windows), classic (Mac OS Classic), or aqua (Mac OS X Aqua). 
00707   static const char* GetWindowingSystem(vtkKWApplication *app);
00708   static const char* GetWindowingSystem(Tcl_Interp *interp);
00709 
00710 protected:
00711   vtkKWTkUtilities() {};
00712   ~vtkKWTkUtilities() {};
00713 
00714   //BTX  
00715   //ETX
00716 
00717   static int ChangeFontWeight(
00718     Tcl_Interp *interp, const char *widget, int bold);
00719   static int ChangeFontWeight(
00720     Tcl_Interp *interp, const char *font, int bold, char *new_font);
00721   static int ChangeFontSlant(
00722     Tcl_Interp *interp, const char *widget, int italic);
00723   static int ChangeFontSlant(
00724     Tcl_Interp *interp, const char *font, int italic, char *new_font);
00725   
00726   static const char* EvaluateStringFromArgsInternal(
00727     Tcl_Interp *interp, vtkObject *obj, const char *format, 
00728     va_list var_args1, va_list var_args2);
00729   static const char* EvaluateSimpleStringInternal(
00730     Tcl_Interp *interp, vtkObject *obj, const char *str);
00731 
00732 private:
00733   vtkKWTkUtilities(const vtkKWTkUtilities&); // Not implemented
00734   void operator=(const vtkKWTkUtilities&); // Not implemented
00735 };
00736 
00737 #endif
00738 

Generated by  doxygen 1.6.2