00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00020 #ifndef __vtkKWTkUtilities_h
00021 #define __vtkKWTkUtilities_h
00022
00023 #include "vtkObject.h"
00024 #include "vtkKWWidgets.h"
00025
00026
00027
00028
00029
00030 #if defined(__hpux) && !defined(HAS_STDARG)
00031 #define HAS_STDARG
00032 #endif
00033
00034 #include <stdarg.h>
00035
00036 class vtkKWWidget;
00037 class vtkKWCoreWidget;
00038 class vtkKWApplication;
00039 class vtkKWIcon;
00040 class vtkRenderWindow;
00041 struct Tcl_Interp;
00042
00043 class KWWidgets_EXPORT vtkKWTkUtilities : public vtkObject
00044 {
00045
00046 public:
00047 static vtkKWTkUtilities* New();
00048 vtkTypeRevisionMacro(vtkKWTkUtilities,vtkObject);
00049 void PrintSelf(ostream& os, vtkIndent indent);
00050
00052
00053 static const char* GetTclNameFromPointer(
00054 Tcl_Interp *interp, vtkObject *obj);
00055 static const char* GetTclNameFromPointer(
00056 vtkKWApplication *app, vtkObject *obj);
00058
00060
00068 static const char* EvaluateString(
00069 Tcl_Interp *interp, const char *format, ...);
00070 static const char* EvaluateString(
00071 vtkKWApplication *app, const char *format, ...);
00072
00073 static const char* EvaluateStringFromArgs(
00074 Tcl_Interp *interp, const char *format,
00075 va_list var_args1, va_list var_args2);
00076 static const char* EvaluateStringFromArgs(
00077 vtkKWApplication *app, const char *format,
00078 va_list var_args1, va_list var_args2);
00079 static const char* EvaluateSimpleString(
00080 Tcl_Interp *interp, const char *str);
00081 static const char* EvaluateSimpleString(
00082 vtkKWApplication *app, const char *str);
00084
00086
00088 static const char* EvaluateEncodedString(
00089 Tcl_Interp *interp,
00090 const unsigned char *buffer,
00091 unsigned long length,
00092 unsigned long decoded_length);
00094
00096
00104 static void CreateObjectMethodCommand(
00105 vtkKWApplication *app,
00106 char **command, vtkObject *object, const char *method);
00107 static void CreateObjectMethodCommand(
00108 Tcl_Interp *interp,
00109 char **command, vtkObject *object, const char *method);
00111
00113
00117 static void GetRGBColor(Tcl_Interp *interp,
00118 const char *widget,
00119 const char *color,
00120 double *r, double *g, double *b);
00121 static void GetRGBColor(vtkKWWidget *widget,
00122 const char *color,
00123 double *r, double *g, double *b);
00125
00127
00130 static void GetOptionColor(Tcl_Interp *interp,
00131 const char *widget,
00132 const char *option,
00133 double *r, double *g, double *b);
00134 static void GetOptionColor(vtkKWWidget *widget,
00135 const char *option,
00136 double *r, double *g, double *b);
00137 static double* GetOptionColor(vtkKWWidget *widget,
00138 const char *option);
00140
00142
00146 static void GetDefaultOptionColor(Tcl_Interp *interp,
00147 const char *widget,
00148 const char *option,
00149 double *r, double *g, double *b);
00150 static void GetDefaultOptionColor(vtkKWWidget *widget,
00151 const char *option,
00152 double *r, double *g, double *b);
00153 static double* GetDefaultOptionColor(vtkKWWidget *widget,
00154 const char *option);
00156
00158
00161 static void SetOptionColor(Tcl_Interp *interp,
00162 const char *widget,
00163 const char *option,
00164 double r, double g, double b);
00165 static void SetOptionColor(vtkKWWidget *widget,
00166 const char *option,
00167 double r, double g, double b);
00169
00171
00173 static int QueryUserForColor(vtkKWApplication *app,
00174 vtkKWWidget *dialog_parent,
00175 const char *dialog_title,
00176 double in_r, double in_g, double in_b,
00177 double *out_r, double *out_g, double *out_b);
00179
00181
00186 static int GetGeometry(Tcl_Interp *interp,
00187 const char *widget,
00188 int *width, int *height, int *x, int *y);
00189 static int GetGeometry(vtkKWWidget *widget,
00190 int *width, int *height, int *x, int *y);
00192
00194
00201 static int ContainsCoordinates(Tcl_Interp *interp,
00202 const char *widget,
00203 int x, int y);
00204 static int ContainsCoordinates(vtkKWWidget *widget,
00205 int x, int y);
00206 static vtkKWWidget* ContainsCoordinatesForSpecificType(
00207 vtkKWWidget *widget, int x, int y, const char *classname);
00209
00211
00220 enum
00221 {
00222 UpdatePhotoOptionFlipVertical = 1
00223 };
00224
00225 static int UpdatePhoto(Tcl_Interp *interp,
00226 const char *photo_name,
00227 const unsigned char *pixels,
00228 int width, int height,
00229 int pixel_size,
00230 unsigned long buffer_length = 0,
00231 int update_options = 0);
00232 static int UpdatePhoto(vtkKWApplication *app,
00233 const char *photo_name,
00234 const unsigned char *pixels,
00235 int width, int height,
00236 int pixel_size,
00237 unsigned long buffer_length = 0,
00238 int update_options = 0);
00240
00242
00244 static int UpdatePhotoFromIcon(vtkKWApplication *app,
00245 const char *photo_name,
00246 vtkKWIcon *icon,
00247 int update_options = 0);
00248 static int UpdatePhotoFromPredefinedIcon(vtkKWApplication *app,
00249 const char *photo_name,
00250 int icon_index,
00251 int update_options = 0);
00253
00255
00267 static int UpdateOrLoadPhoto(Tcl_Interp *interp,
00268 const char *photo_name,
00269 const char *file_name,
00270 const char *directory,
00271 const unsigned char *pixels,
00272 int width, int height,
00273 int pixel_size,
00274 unsigned long buffer_length = 0);
00275 static int UpdateOrLoadPhoto(vtkKWApplication *app,
00276 const char *photo_name,
00277 const char *file_name,
00278 const char *directory,
00279 const unsigned char *pixels,
00280 int width, int height,
00281 int pixel_size,
00282 unsigned long buffer_length = 0);
00284
00286
00292 static void SetImageOptionToPixels(
00293 vtkKWCoreWidget *widget,
00294 const unsigned char *pixels,
00295 int width, int height,
00296 int pixel_size = 4,
00297 unsigned long buffer_length = 0,
00298 const char *image_option = 0);
00300
00302
00305 static int FindPhoto(Tcl_Interp *interp, const char *photo_name);
00306 static int FindPhoto(vtkKWApplication *app, const char *photo_name);
00308
00310
00316 static int GetPhotoHeight(Tcl_Interp *interp, const char *photo_name);
00317 static int GetPhotoHeight(vtkKWApplication *app, const char *photo_name);
00318 static int GetPhotoHeight(vtkKWWidget *widget);
00320
00322
00326 static int GetPhotoWidth(Tcl_Interp *interp, const char *photo_name);
00327 static int GetPhotoWidth(vtkKWApplication *app, const char *photo_name);
00329
00331
00335 static int ChangeFontWeightToBold(
00336 Tcl_Interp *interp, const char *font, char *new_font);
00337 static int ChangeFontWeightToNormal(
00338 Tcl_Interp *interp, const char *font, char *new_font);
00340
00342
00345 static int ChangeFontWeightToBold(Tcl_Interp *interp, const char *widget);
00346 static int ChangeFontWeightToBold(vtkKWWidget *widget);
00347 static int ChangeFontWeightToNormal(Tcl_Interp *interp, const char *widget);
00348 static int ChangeFontWeightToNormal(vtkKWWidget *widget);
00350
00352
00356 static int ChangeFontSlantToItalic(
00357 Tcl_Interp *interp, const char *font, char *new_font);
00358 static int ChangeFontSlantToRoman(
00359 Tcl_Interp *interp, const char *font, char *new_font);
00361
00363
00366 static int ChangeFontSlantToItalic(Tcl_Interp *interp, const char *widget);
00367 static int ChangeFontSlantToItalic(vtkKWWidget *widget);
00368 static int ChangeFontSlantToRoman(Tcl_Interp *interp, const char *widget);
00369 static int ChangeFontSlantToRoman(vtkKWWidget *widget);
00371
00373
00377 static int ChangeFontSize(
00378 Tcl_Interp *interp, const char *font, int new_size, char *new_font);
00380
00382
00385 static int ChangeFontSize(
00386 Tcl_Interp *interp, const char *widget, int new_size);
00387 static int ChangeFontSize(vtkKWWidget *widget, int new_size);
00389
00391
00395 static int GetRealActualFont(
00396 Tcl_Interp *interp, const char *font, char *real_font);
00398
00402 static int GetFontMeasure(vtkKWWidget *widget, const char *txt, int *w);
00403
00405
00409 static int GetGridSize(Tcl_Interp *interp,
00410 const char *widget,
00411 int *nb_of_cols,
00412 int *nb_of_rows);
00413 static int GetGridSize(vtkKWWidget *widget,
00414 int *nb_of_cols,
00415 int *nb_of_rows);
00417
00419
00423 static int GetWidgetPositionInGrid(Tcl_Interp *interp,
00424 const char *widget,
00425 int *col,
00426 int *row);
00427 static int GetWidgetPositionInGrid(vtkKWWidget *widget,
00428 int *col,
00429 int *row);
00431
00433
00439 static int GetSlavesBoundingBoxInPack(Tcl_Interp *interp,
00440 const char *widget,
00441 int *width,
00442 int *height);
00443 static int GetSlavesBoundingBoxInPack(vtkKWWidget *widget,
00444 int *width,
00445 int *height);
00447
00449
00455 static int GetSlaveHorizontalPositionInPack(Tcl_Interp *interp,
00456 const char *widget,
00457 const char *slave,
00458 int *x);
00459 static int GetSlaveHorizontalPositionInPack(vtkKWWidget *widget,
00460 vtkKWWidget *slave,
00461 int *x);
00463
00465
00468 static int GetWidgetPaddingInPack(Tcl_Interp *interp,
00469 const char *widget,
00470 int *ipadx,
00471 int *ipady,
00472 int *padx,
00473 int *pady);
00475
00477
00482 static int GetMasterInPack(Tcl_Interp *interp,
00483 const char *widget,
00484 ostream &in);
00485 static int GetMasterInPack(vtkKWWidget *widget,
00486 ostream &in);
00488
00490
00495 static int GetGridColumnWidths(Tcl_Interp *interp,
00496 const char *widget,
00497 int *nb_of_cols,
00498 int **col_widths,
00499 int allocate = 0);
00501
00503
00508 static int SynchroniseGridsColumnMinimumSize(Tcl_Interp *interp,
00509 int nb_of_widgets,
00510 const char **widgets,
00511 const float *factors = 0,
00512 const int *weights = 0);
00514
00516
00522 static int SynchroniseLabelsMaximumWidth(Tcl_Interp *interp,
00523 int nb_of_widgets,
00524 const char **widgets,
00525 const char *options = 0);
00526 static int SynchroniseLabelsMaximumWidth(vtkKWApplication *app,
00527 int nb_of_widgets,
00528 const char **widgets,
00529 const char *options = 0);
00531
00533
00538 static int GetSlavesInPack(Tcl_Interp *interp,
00539 const char *widget,
00540 char ***slaves);
00541 static int GetSlavesInPack(vtkKWWidget *widget,
00542 char ***slaves);
00544
00546
00552 static int GetPreviousAndNextSlaveInPack(Tcl_Interp *interp,
00553 const char *widget,
00554 const char *slave,
00555 ostream &previous_slave,
00556 ostream &next_slave);
00557 static int GetPreviousAndNextSlaveInPack(vtkKWWidget *widget,
00558 vtkKWWidget *slave,
00559 ostream &previous_slave,
00560 ostream &next_slave);
00561
00562
00563
00564
00565
00566 static int TakeScreenDump(Tcl_Interp *interp,
00567 const char *wname,
00568 const char *fname,
00569 int top = 0, int bottom = 0,
00570 int left = 0, int right = 0);
00571 static int TakeScreenDump(vtkKWWidget *widget,
00572 const char *fname,
00573 int top = 0, int bottom = 0,
00574 int left = 0, int right = 0);
00576
00578
00580 static int SetTopLevelMouseCursor(Tcl_Interp *interp,
00581 const char *widget,
00582 const char *cursor);
00583 static int SetTopLevelMouseCursor(vtkKWWidget *widget,
00584 const char *cursor);
00586
00588
00589 static int IsTopLevel(Tcl_Interp *interp,
00590 const char *widget);
00591 static int IsTopLevel(vtkKWWidget *widget);
00593
00595
00596 static void WithdrawTopLevel(Tcl_Interp *interp,
00597 const char *widget);
00598 static void WithdrawTopLevel(vtkKWWidget *widget);
00600
00602
00606 static const char *GetCurrentScript(Tcl_Interp *interp);
00607 static const char *GetCurrentScript(vtkKWApplication *app);
00609
00611
00619 static const char* CreateTimerHandler(
00620 Tcl_Interp *interp,
00621 unsigned long ms,
00622 vtkObject *object, const char *method);
00623 static const char* CreateTimerHandler(
00624 vtkKWApplication *app,
00625 unsigned long ms,
00626 vtkObject *object, const char *method);
00627 static const char* CreateIdleTimerHandler(
00628 Tcl_Interp *interp,
00629 vtkObject *object, const char *method);
00630 static const char* CreateIdleTimerHandler(
00631 vtkKWApplication *app,
00632 vtkObject *object, const char *method);
00634
00636
00639 static void CancelTimerHandler(Tcl_Interp *interp, const char *id);
00640 static void CancelTimerHandler(vtkKWApplication *app, const char *id);
00641 static void CancelAllTimerHandlers(Tcl_Interp *interp);
00642 static void CancelAllTimerHandlers(vtkKWApplication *app);
00644
00646
00647 static void Bell(Tcl_Interp *interp);
00648 static void Bell(vtkKWApplication *app);
00650
00652
00655 static void ProcessPendingEvents(Tcl_Interp *interp);
00656 static void ProcessPendingEvents(vtkKWApplication *app);
00658
00660
00663 static void ProcessIdleTasks(Tcl_Interp *interp);
00664 static void ProcessIdleTasks(vtkKWApplication *app);
00666
00671 static int CheckForPendingInteractionEvents(vtkRenderWindow *win);
00672
00674
00676 static int GetMousePointerCoordinates(
00677 Tcl_Interp *interp, const char *widget, int *x, int *y);
00678 static int GetMousePointerCoordinates(
00679 vtkKWWidget *widget, int *x, int *y);
00681
00683
00685 static int GetWidgetCoordinates(
00686 Tcl_Interp *interp, const char *widget, int *x, int *y);
00687 static int GetWidgetCoordinates(
00688 vtkKWWidget *widget, int *x, int *y);
00690
00692
00694 static int GetWidgetRelativeCoordinates(
00695 Tcl_Interp *interp, const char *widget, int *x, int *y);
00696 static int GetWidgetRelativeCoordinates(
00697 vtkKWWidget *widget, int *x, int *y);
00699
00701
00708 static int GetWidgetSize(
00709 Tcl_Interp *interp, const char *widget, int *w, int *h);
00710 static int GetWidgetSize(
00711 vtkKWWidget *widget, int *w, int *h);
00713
00715
00718 static int GetWidgetRequestedSize(
00719 Tcl_Interp *interp, const char *widget, int *w, int *h);
00720 static int GetWidgetRequestedSize(
00721 vtkKWWidget *widget, int *w, int *h);
00723
00725
00726 static const char* GetWidgetClass(
00727 Tcl_Interp *interp, const char *widget);
00728 static const char* GetWidgetClass(
00729 vtkKWWidget *widget);
00731
00733
00735 static int GetScreenSize(
00736 Tcl_Interp *interp, const char *widget, int *w, int *h);
00737 static int GetScreenSize(
00738 vtkKWWidget *widget, int *w, int *h);
00740
00742
00745 static const char* GetWindowingSystem(vtkKWApplication *app);
00746 static const char* GetWindowingSystem(Tcl_Interp *interp);
00748
00749
00750
00751 protected:
00752 vtkKWTkUtilities() {};
00753 ~vtkKWTkUtilities() {};
00754
00755
00756
00757
00758 static int ChangeFontWeight(
00759 Tcl_Interp *interp, const char *widget, int bold);
00760 static int ChangeFontWeight(
00761 Tcl_Interp *interp, const char *font, int bold, char *new_font);
00762 static int ChangeFontSlant(
00763 Tcl_Interp *interp, const char *widget, int italic);
00764 static int ChangeFontSlant(
00765 Tcl_Interp *interp, const char *font, int italic, char *new_font);
00766
00767 static const char* EvaluateStringFromArgsInternal(
00768 Tcl_Interp *interp, vtkObject *obj, const char *format,
00769 va_list var_args1, va_list var_args2);
00770 static const char* EvaluateSimpleStringInternal(
00771 Tcl_Interp *interp, vtkObject *obj, const char *str);
00772
00773
00774
00775 private:
00776 vtkKWTkUtilities(const vtkKWTkUtilities&);
00777 void operator=(const vtkKWTkUtilities&);
00778 };
00779
00780 #endif
00781
00782