00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __vtkKWTkUtilities_h
00019 #define __vtkKWTkUtilities_h
00020
00021 #include "vtkObject.h"
00022 #include "vtkKWWidgets.h"
00023
00024
00025
00026
00027
00028 #if defined(__hpux) && !defined(HAS_STDARG)
00029 #define HAS_STDARG
00030 #endif
00031
00032 #include <stdarg.h>
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
00049
00050 static const char* GetTclNameFromPointer(
00051 Tcl_Interp *interp, vtkObject *obj);
00052 static const char* GetTclNameFromPointer(
00053 vtkKWApplication *app, vtkObject *obj);
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 static const char* EvaluateString(
00067 Tcl_Interp *interp, const char *format, ...);
00068 static const char* EvaluateString(
00069 vtkKWApplication *app, const char *format, ...);
00070
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
00083
00084
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
00092
00093
00094
00095
00096
00097
00098
00099
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
00108
00109
00110
00111
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
00121
00122
00123
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
00135
00136
00137
00138
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
00150
00151
00152
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
00162
00163
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
00171
00172
00173
00174
00175
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
00183
00184
00185
00186
00187
00188
00189
00190
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
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 enum
00212 {
00213 UpdatePhotoOptionFlipVertical = 1
00214 };
00215
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
00232
00233
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
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
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
00275
00276
00277
00278
00279
00280
00281
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
00291
00292
00293
00294 static int FindPhoto(Tcl_Interp *interp, const char *photo_name);
00295 static int FindPhoto(vtkKWApplication *app, const char *photo_name);
00296
00297
00298
00299
00300
00301
00302
00303
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
00309
00310
00311
00312
00313 static int GetPhotoWidth(Tcl_Interp *interp, const char *photo_name);
00314 static int GetPhotoWidth(vtkKWApplication *app, const char *photo_name);
00315
00316
00317
00318
00319
00320
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
00327
00328
00329
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
00336
00337
00338
00339
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
00346
00347
00348
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
00355
00356
00357
00358
00359 static int ChangeFontSize(
00360 Tcl_Interp *interp, const char *font, int new_size, char *new_font);
00361
00362
00363
00364
00365
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
00371
00372
00373
00374
00375 static int GetRealActualFont(
00376 Tcl_Interp *interp, const char *font, char *real_font);
00377
00378
00379
00380
00381
00382 static int GetFontMeasure(vtkKWWidget *widget, const char *txt, int *w);
00383
00384
00385
00386
00387
00388
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
00398
00399
00400
00401
00402
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
00412
00413
00414
00415
00416
00417
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
00427
00428
00429
00430
00431
00432
00433
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
00443
00444
00445
00446
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
00455
00456
00457
00458
00459
00460
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
00468
00469
00470
00471
00472
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
00480
00481
00482
00483
00484
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
00492
00493
00494
00495
00496
00497
00498
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
00509
00510
00511
00512
00513
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
00521
00522
00523
00524
00525
00526
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
00537
00538
00539
00540
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
00552
00553
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
00561
00562 static int IsTopLevel(Tcl_Interp *interp,
00563 const char *widget);
00564 static int IsTopLevel(vtkKWWidget *widget);
00565
00566
00567
00568 static void WithdrawTopLevel(Tcl_Interp *interp,
00569 const char *widget);
00570 static void WithdrawTopLevel(vtkKWWidget *widget);
00571
00572
00573
00574
00575
00576
00577 static const char *GetCurrentScript(Tcl_Interp *interp);
00578 static const char *GetCurrentScript(vtkKWApplication *app);
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
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
00606
00607
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
00614
00615 static void Bell(Tcl_Interp *interp);
00616 static void Bell(vtkKWApplication *app);
00617
00618
00619
00620
00621
00622 static void ProcessPendingEvents(Tcl_Interp *interp);
00623 static void ProcessPendingEvents(vtkKWApplication *app);
00624
00625
00626
00627
00628
00629 static void ProcessIdleTasks(Tcl_Interp *interp);
00630 static void ProcessIdleTasks(vtkKWApplication *app);
00631
00632
00633
00634
00635
00636
00637 static int CheckForPendingInteractionEvents(vtkRenderWindow *win);
00638
00639
00640
00641
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
00648
00649
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
00656
00657
00658
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
00665
00666
00667
00668
00669
00670
00671
00672
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
00679
00680
00681
00682
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
00689
00690 static const char* GetWidgetClass(
00691 Tcl_Interp *interp, const char *widget);
00692 static const char* GetWidgetClass(
00693 vtkKWWidget *widget);
00694
00695
00696
00697
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
00704
00705
00706
00707 static const char* GetWindowingSystem(vtkKWApplication *app);
00708 static const char* GetWindowingSystem(Tcl_Interp *interp);
00709
00710 protected:
00711 vtkKWTkUtilities() {};
00712 ~vtkKWTkUtilities() {};
00713
00714
00715
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&);
00734 void operator=(const vtkKWTkUtilities&);
00735 };
00736
00737 #endif
00738