57 #ifdef PL_HAVE_UNISTD_H
64 #define NDEV 100 // Max number of output device types in menu
76 #define plframe_cmd( code ) \
77 if ( ( code ) == TCL_ERROR ) return ( TCL_ERROR );
81 #if TCL_MAJOR_VERSION <= 7 && TCL_MINOR_VERSION <= 4
82 #define Tk_Cursor Cursor
105 Tcl_Command widgetCmd;
194 #define REFRESH_PENDING 1
195 #define RESIZE_PENDING 2
196 #define REDRAW_PENDING 4
197 #define UPDATE_V_SCROLLBAR 8
198 #define UPDATE_H_SCROLLBAR 16
202 #define DEF_PLFRAME_BG_COLOR "Black"
203 #define DEF_PLFRAME_BG_MONO "White"
204 #define DEF_PLFRAME_BORDER_WIDTH "0"
205 #define DEF_PLFRAME_CURSOR ( (char *) NULL )
206 #define DEF_PLFRAME_HEIGHT "0"
207 #define DEF_PLFRAME_RELIEF "flat"
208 #define DEF_PLFRAME_WIDTH "0"
213 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
215 TK_CONFIG_COLOR_ONLY, NULL },
222 { TK_CONFIG_COLOR,
"-plbg",
"plbackground",
"Plbackground",
224 TK_CONFIG_COLOR_ONLY, NULL },
226 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
228 TK_CONFIG_MONO_ONLY, NULL },
235 { TK_CONFIG_COLOR,
"-plbg", (
char *) NULL, (
char *) NULL,
237 TK_CONFIG_MONO_ONLY, NULL },
239 { TK_CONFIG_SYNONYM,
"-bd",
"borderWidth", (
char *) NULL,
240 (
char *) NULL, 0, 0, NULL },
241 { TK_CONFIG_SYNONYM,
"-bg",
"background", (
char *) NULL,
242 (
char *) NULL, 0, 0, NULL },
243 { TK_CONFIG_PIXELS,
"-borderwidth",
"borderWidth",
"BorderWidth",
245 { TK_CONFIG_ACTIVE_CURSOR,
"-cursor",
"cursor",
"Cursor",
247 { TK_CONFIG_STRING,
"-bopcmd",
"bopcmd",
"PgCommand",
248 (
char *) NULL, Tk_Offset(
PlFrame, bopCmd ), TK_CONFIG_NULL_OK, NULL },
249 { TK_CONFIG_STRING,
"-eopcmd",
"eopcmd",
"PgCommand",
250 (
char *) NULL, Tk_Offset(
PlFrame, eopCmd ), TK_CONFIG_NULL_OK, NULL },
251 { TK_CONFIG_PIXELS,
"-height",
"height",
"Height",
253 { TK_CONFIG_RELIEF,
"-relief",
"relief",
"Relief",
255 { TK_CONFIG_PIXELS,
"-width",
"width",
"Width",
257 { TK_CONFIG_BOOLEAN,
"-xhairs", (
char *) NULL, (
char *) NULL,
258 "0", Tk_Offset(
PlFrame, xhairs ), TK_CONFIG_DONT_SET_DEFAULT, NULL },
259 { TK_CONFIG_BOOLEAN,
"-rubberband", (
char *) NULL, (
char *) NULL,
260 "0", Tk_Offset(
PlFrame, rband ), TK_CONFIG_DONT_SET_DEFAULT, NULL },
261 { TK_CONFIG_STRING,
"-xscrollcommand",
"xScrollCommand",
"ScrollCommand",
262 (
char *) NULL, Tk_Offset(
PlFrame, xScrollCmd ), TK_CONFIG_NULL_OK, NULL },
263 { TK_CONFIG_STRING,
"-yscrollcommand",
"yScrollCommand",
"ScrollCommand",
264 (
char *) NULL, Tk_Offset(
PlFrame, yScrollCmd ), TK_CONFIG_NULL_OK, NULL },
265 { TK_CONFIG_END, (
char *) NULL, (
char *) NULL, (
char *) NULL,
266 (
char *) NULL, 0, 0, NULL }
273 int plFrameCmd( ClientData, Tcl_Interp *,
int,
const char ** );
277 #if TK_MAJOR_VERSION < 4 || ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 )
278 #define FreeProcArg ClientData
280 #define FreeProcArg char *
291 static void PlFrameKeyEH( ClientData,
register XEvent * );
292 static int PlFrameWidgetCmd( ClientData, Tcl_Interp *,
int,
const char ** );
293 static int ReadData( ClientData,
int );
299 static int Cmd( Tcl_Interp *,
PlFrame *,
int,
const char ** );
302 static int Draw( Tcl_Interp *,
PlFrame *,
int,
const char ** );
303 static int Info( Tcl_Interp *,
PlFrame *,
int,
const char ** );
305 static int Orient( Tcl_Interp *,
PlFrame *,
int,
const char ** );
306 static int Page( Tcl_Interp *,
PlFrame *,
int,
const char ** );
307 static int Print( Tcl_Interp *,
PlFrame *,
int,
const char ** );
308 static int Redraw( Tcl_Interp *,
PlFrame *,
int,
const char ** );
309 static int Save( Tcl_Interp *,
PlFrame *,
int,
const char ** );
310 static int View( Tcl_Interp *,
PlFrame *,
int,
const char ** );
311 static int xScroll( Tcl_Interp *,
PlFrame *,
int,
const char ** );
312 static int yScroll( Tcl_Interp *,
PlFrame *,
int,
const char ** );
313 static int report( Tcl_Interp *,
PlFrame *,
int,
const char ** );
371 Tcl_AppendResult( interp,
"wrong # args: should be \"",
372 argv[0],
" pathName ?options?\"", (
char *) NULL );
378 new = Tk_CreateWindowFromPath( interp, Tk_MainWindow( interp ),
379 argv[1], (
char *) NULL );
390 plFramePtr->
tkwin =
new;
391 plFramePtr->
display = Tk_Display(
new );
394 plFramePtr->
border = NULL;
397 plFramePtr->
width = Tk_Width( plFramePtr->
tkwin );
398 plFramePtr->
height = Tk_Height( plFramePtr->
tkwin );
399 plFramePtr->
cursor = None;
400 plFramePtr->
flags = 0;
418 plFramePtr->
xorGC = NULL;
428 plFramePtr->
bopCmd = NULL;
429 plFramePtr->
eopCmd = NULL;
434 plFramePtr->
rband = 0;
438 plr = plFramePtr->
plr;
448 Tk_GetCursor( plFramePtr->
interp, plFramePtr->
tkwin,
"crosshair" );
460 plFramePtr->
devDesc = (
const char **) ckalloc(
NDEV *
sizeof (
char ** ) );
461 plFramePtr->
devName = (
const char **) ckalloc(
NDEV *
sizeof (
char ** ) );
462 for ( i = 0; i <
NDEV; i++ )
472 Tk_SetClass( plFramePtr->
tkwin,
"Plframe" );
474 Tk_CreateEventHandler( plFramePtr->
tkwin, StructureNotifyMask,
477 Tk_CreateEventHandler( plFramePtr->tkwin, ExposureMask,
481 plFramePtr->widgetCmd =
483 Tcl_CreateCommand( interp, Tk_PathName( plFramePtr->tkwin ),
484 (Tcl_CmdProc *)
PlFrameWidgetCmd, (ClientData) plFramePtr, (Tcl_CmdDeleteProc *) NULL );
486 Itk_SetWidgetCommand( plFramePtr->tkwin, plFramePtr->widgetCmd );
489 if (
ConfigurePlFrame( interp, plFramePtr, argc - 2, argv + 2, 0 ) != TCL_OK )
492 Itk_SetWidgetCommand( plFramePtr->tkwin, (Tcl_Command) NULL );
494 Tk_DestroyWindow( plFramePtr->tkwin );
497 Tcl_SetResult( interp, Tk_PathName( plFramePtr->tkwin ), TCL_VOLATILE );
537 printf(
"Current stream %d, frame stream %d\n",
539 printf(
"PlFrameWidgetCmd: " );
540 for ( i = 0; i <
argc; i++ )
541 printf(
" %s", argv[i] );
548 Tcl_AppendResult( interp,
"wrong # args: should be \"",
549 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
552 Tk_Preserve( (ClientData) plFramePtr );
554 length = (int) strlen( argv[1] );
562 if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cmd", (
size_t) length ) == 0 ) )
564 result =
Cmd( interp, plFramePtr, argc - 2, argv + 2 );
569 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cget", (
size_t) length ) == 0 ) )
573 Tcl_AppendResult( interp,
"wrong # args: should be \"",
574 argv[0],
" cget <option>\"", (
char *) NULL );
580 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
581 (
char *) plFramePtr, (
char *) NULL, 0 );
587 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"configure", (
size_t) length ) == 0 ) )
591 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
592 (
char *) plFramePtr, (
char *) NULL, 0 );
594 else if ( argc == 3 )
596 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
597 (
char *) plFramePtr, argv[2], 0 );
602 TK_CONFIG_ARGV_ONLY );
608 else if ( ( c ==
'd' ) &&
609 ( ( strncmp( argv[1],
"db", (
size_t) length ) == 0 ) ||
610 ( strncmp( argv[1],
"doublebuffering", (
size_t) length == 0 ) ) ) )
616 if ( strcmp( argv[2],
"on" ) == 0 )
621 if ( strcmp( argv[2],
"off" ) == 0 )
626 if ( strcmp( argv[2],
"query" ) == 0 )
631 Tcl_SetResult( interp, res, TCL_VOLATILE );
640 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"closelink", (
size_t) length ) == 0 ) )
644 Tcl_AppendResult( interp,
"wrong # args: should be \"",
645 argv[0], (
char *) NULL );
651 result =
Closelink( interp, plFramePtr, argc - 2, argv + 2 );
657 else if ( ( c ==
'd' ) && ( strncmp( argv[1],
"draw", (
size_t) length ) == 0 ) )
661 Tcl_AppendResult( interp,
"wrong # args: should be \"",
662 argv[0],
" draw op ?options?\"", (
char *) NULL );
668 result =
Draw( interp, plFramePtr, argc - 2, argv + 2 );
674 else if ( ( ( c ==
'g' ) && ( ( strncmp( argv[1],
"gcmap0", (
size_t) length ) == 0 ) ||
675 ( strncmp( argv[1],
"gcmap1", (
size_t) length ) == 0 ) ) ) ||
676 ( ( c ==
's' ) && ( ( strncmp( argv[1],
"scmap0", (
size_t) length ) == 0 ) ||
677 ( strncmp( argv[1],
"scmap1", (
size_t) length ) == 0 ) ||
678 ( strncmp( argv[1],
"scol0", (
size_t) length ) == 0 ) ||
679 ( strncmp( argv[1],
"scol1", (
size_t) length ) == 0 ) ) ) )
680 result =
ColorManip( interp, plFramePtr, argc - 1, argv + 1 );
684 else if ( ( c ==
'i' ) && ( strncmp( argv[1],
"info", (
size_t) length ) == 0 ) )
686 result =
Info( interp, plFramePtr, argc - 2, argv + 2 );
691 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"orient", (
size_t) length ) == 0 ) )
693 result =
Orient( interp, plFramePtr, argc - 2, argv + 2 );
698 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"openlink", (
size_t) length ) == 0 ) )
702 Tcl_AppendResult( interp,
"wrong # args: should be \"",
703 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
709 result =
Openlink( interp, plFramePtr, argc - 2, argv + 2 );
715 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"page", (
size_t) length ) == 0 ) )
717 result =
Page( interp, plFramePtr, argc - 2, argv + 2 );
722 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"print", (
size_t) length ) == 0 ) )
724 result =
Print( interp, plFramePtr, argc - 2, argv + 2 );
729 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"redraw", (
size_t) length ) == 0 ) )
733 Tcl_AppendResult( interp,
"wrong # args: should be \"",
734 argv[0],
" redraw\"", (
char *) NULL );
740 result =
Redraw( interp, plFramePtr, argc - 2, argv + 2 );
746 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"report", (
size_t) length ) == 0 ) )
748 result =
report( interp, plFramePtr, argc - 2, argv + 2 );
753 else if ( ( c ==
's' ) && ( strncmp( argv[1],
"save", (
size_t) length ) == 0 ) )
755 result =
Save( interp, plFramePtr, argc - 2, argv + 2 );
760 else if ( ( c ==
'v' ) && ( strncmp( argv[1],
"view", (
size_t) length ) == 0 ) )
762 result =
View( interp, plFramePtr, argc - 2, argv + 2 );
767 else if ( ( c ==
'x' ) && ( strncmp( argv[1],
"xscroll", (
size_t) length ) == 0 ) )
769 if ( argc == 2 || argc > 3 )
771 Tcl_AppendResult( interp,
"wrong # args: should be \"",
772 argv[0],
" xscroll pixel\"", (
char *) NULL );
778 result =
xScroll( interp, plFramePtr, argc - 2, argv + 2 );
784 else if ( ( c ==
'y' ) && ( strncmp( argv[1],
"yscroll", (
size_t) length ) == 0 ) )
786 if ( argc == 2 || argc > 3 )
788 Tcl_AppendResult( interp,
"wrong # args: should be \"",
789 argv[0],
" yscroll pixel\"", (
char *) NULL );
795 result =
yScroll( interp, plFramePtr, argc - 2, argv + 2 );
803 Tcl_AppendResult( interp,
"bad option \"", argv[1],
804 "\": must be closelink, cmd, configure, draw, ",
806 "info, openlink, orient, page, print, redraw, save, ",
807 "scmap0, scmap1, scol0, scol1, ",
808 "view, xscroll, or yscroll", (
char *) NULL );
812 printf(
"bad option!\n" );
817 printf(
"result=%d current stream=%d\n", result, plsc->ipls );
821 Tk_Release( (ClientData) plFramePtr );
851 if ( plFramePtr->
border != NULL )
853 Tk_Free3DBorder( plFramePtr->
border );
855 if ( plFramePtr->
bgColor != NULL )
857 Tk_FreeColor( plFramePtr->
bgColor );
861 ckfree( (
char *) plFramePtr->
plpr_cmd );
863 if ( plFramePtr->
cursor != None )
871 if ( plFramePtr->
xorGC != NULL )
885 ckfree( (
char *) plFramePtr->
SaveFnam );
887 if ( plFramePtr->
devDesc != NULL )
889 ckfree( (
char *) plFramePtr->
devDesc );
891 if ( plFramePtr->
devName != NULL )
893 ckfree( (
char *) plFramePtr->
devName );
899 ckfree( (
char *) plFramePtr->
plr->
iodev );
908 ckfree( (
char *) plFramePtr->
plr );
909 ckfree( (
char *) plFramePtr );
933 register Tk_Window tkwin = plFramePtr->
tkwin;
937 switch ( eventPtr->type )
939 case ConfigureNotify:
940 pldebug(
"PLFrameConfigureEH",
"ConfigureNotify\n" );
942 plFramePtr->
width = Tk_Width( tkwin );
943 plFramePtr->
height = Tk_Height( tkwin );
953 pldebug(
"PLFrameConfigureEH",
"DestroyNotify\n" );
955 Itk_SetWidgetCommand( plFramePtr->
tkwin, (Tcl_Command) NULL );
956 Tcl_DeleteCommand2( plFramePtr->
interp, plFramePtr->widgetCmd );
958 Tcl_DeleteCommand( plFramePtr->
interp, Tk_PathName( tkwin ) );
960 plFramePtr->
tkwin = NULL;
969 pldebug(
"PLFrameConfigureEH",
"MapNotify\n" );
980 if ( !plFramePtr->tkwin_initted )
982 Tcl_VarEval( plFramePtr->interp,
"update", (
char *) NULL );
984 Tk_DoWhenIdle(
PlFrameInit, (ClientData) plFramePtr );
1014 XExposeEvent *
event = (XExposeEvent *) eventPtr;
1015 register Tk_Window tkwin = plFramePtr->
tkwin;
1019 pldebug(
"PLFrameExposeEH",
"Expose\n" );
1025 int x0_old, x1_old, y0_old, y1_old, x0_new, x1_new, y0_new, y1_new;
1027 x0_old = (int) plFramePtr->
pldis.
x;
1028 y0_old = (
int) plFramePtr->
pldis.
y;
1029 x1_old = x0_old + (int) plFramePtr->
pldis.
width;
1034 x1_new = x0_new +
event->width;
1035 y1_new = y0_new +
event->height;
1037 plFramePtr->
pldis.
x = (
unsigned int)
MIN( x0_old, x0_new );
1038 plFramePtr->
pldis.
y = (
unsigned int)
MIN( y0_old, y0_new );
1045 if ( event->count == 0 )
1050 plFramePtr->width = Tk_Width( tkwin );
1051 plFramePtr->height = Tk_Height( tkwin );
1078 XMotionEvent *
event = (XMotionEvent *) eventPtr;
1084 DrawXhairs( plFramePtr, event->x, event->y );
1088 DrawRband( plFramePtr, event->x, event->y );
1112 XCrossingEvent *crossingEvent = (XCrossingEvent *) eventPtr;
1116 if ( plFramePtr->
xhairs )
1118 DrawXhairs( plFramePtr, crossingEvent->x, crossingEvent->y );
1121 if ( plFramePtr->
rband )
1125 DrawRband( plFramePtr, crossingEvent->x, crossingEvent->y );
1188 XKeyEvent *
event = (XKeyEvent *) eventPtr;
1189 register Tk_Window tkwin = plFramePtr->
tkwin;
1198 #if !defined ( __WIN32__ )
1199 nchars = XLookupString( event,
string, 10, &keysym, &cs );
1203 string[nchars] =
'\0';
1204 pldebug(
"PlFrameKeyEH",
"Keysym %x, translation: %s\n", keysym,
string );
1206 if ( IsModifierKey( keysym ) )
1210 else if ( IsCursorKey( keysym ) )
1212 int x1, y1,
dx = 0,
dy = 0;
1213 int x0 =
event->x, y0 =
event->y;
1214 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
1215 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
1237 if ( event->state & 0x01 )
1245 if ( event->state & 0x02 )
1253 if ( event->state & 0x04 )
1261 if ( event->state & 0x08 )
1283 XWarpPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1284 None, 0, 0, 0, 0, dx, dy );
1298 register Tk_Window tkwin = plFramePtr->
tkwin;
1300 int root_x, root_y, win_x, win_y;
1310 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1311 &root, &child, &root_x, &root_y, &win_x, &win_y,
1314 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1315 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1326 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1329 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1332 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1338 Tk_CreateEventHandler( tkwin, KeyPressMask,
1351 register Tk_Window tkwin = plFramePtr->
tkwin;
1355 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
1361 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1364 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1367 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1371 Tk_DeleteEventHandler( tkwin, KeyPressMask,
1377 plFramePtr->drawing_xhairs = 0;
1389 register Tk_Window tkwin = plFramePtr->
tkwin;
1390 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
1391 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
1396 plFramePtr->
xhair_x[0].x = (short) xmin; plFramePtr->
xhair_x[0].y = (short) y0;
1399 plFramePtr->
xhair_y[0].x = (short) x0; plFramePtr->
xhair_y[0].y = (short) ymin;
1414 register Tk_Window tkwin = plFramePtr->
tkwin;
1416 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1420 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1434 register Tk_Window tkwin = plFramePtr->
tkwin;
1436 int root_x, root_y, win_x, win_y;
1441 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1442 &root, &child, &root_x, &root_y, &win_x, &win_y,
1445 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1446 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1449 plFramePtr->
rband_pt[0].x = (short) win_x;
1450 plFramePtr->
rband_pt[0].y = (short) win_y;
1473 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1476 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1479 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1493 register Tk_Window tkwin = plFramePtr->
tkwin;
1499 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1502 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1505 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1529 plFramePtr->
rband_pt[1].x = (short) x0; plFramePtr->
rband_pt[1].y = (short) y0;
1543 register Tk_Window tkwin = plFramePtr->
tkwin;
1545 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1570 register Tk_Window tkwin = plFramePtr->
tkwin;
1591 if ( plFramePtr->
bopCmd != NULL )
1593 if ( plFramePtr->
eopCmd != NULL )
1599 plFramePtr->
width = Tk_Width( tkwin );
1600 plFramePtr->
height = Tk_Height( tkwin );
1609 if ( plFramePtr->
xhairs )
1612 if ( plFramePtr->
rband )
1638 #define INSTALL_COLORMAP_IN_TK
1639 #ifdef INSTALL_COLORMAP_IN_TK
1641 Tk_SetWindowColormap( Tk_MainWindow( plFramePtr->
interp ), dev->
xwd->
map );
1653 Window top, colormap_windows[5];
1655 top = Tk_WindowId( Tk_MainWindow( plFramePtr->
interp ) );
1657 colormap_windows[count++] = Tk_WindowId( plFramePtr->
tkwin );
1658 colormap_windows[count++] = top;
1660 if ( !XSetWMColormapWindows( plFramePtr->
display,
1661 top, colormap_windows, count ) )
1662 fprintf( stderr,
"Unable to set color map property!\n" );
1687 register Tk_Window tkwin = plFramePtr->
tkwin;
1705 if ( ( plFramePtr->
tkwin == NULL ) || !Tk_IsMapped( tkwin ) )
1713 if ( ( plFramePtr->
border != NULL ) &&
1714 ( plFramePtr->
relief != TK_RELIEF_FLAT ) )
1716 #if TK_MAJOR_VERSION >= 4 && TK_MINOR_VERSION >= 0
1717 Tk_Draw3DRectangle( plFramePtr->
tkwin, Tk_WindowId( tkwin ),
1718 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1721 Tk_Draw3DRectangle( plFramePtr->
display, Tk_WindowId( tkwin ),
1722 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1774 XClearWindow( plFramePtr->
display, Tk_WindowId( tkwin ) );
1775 XFlush( plFramePtr->
display );
1785 plFramePtr->
pldis.
x = (
unsigned int) ( Tk_X( tkwin ) + Tk_Width( tkwin ) );
1786 plFramePtr->
pldis.
y = (
unsigned int) ( Tk_Y( tkwin ) + Tk_Height( tkwin ) );
1787 plFramePtr->
pldis.
width = (
unsigned int) ( -Tk_Width( tkwin ) );
1788 plFramePtr->
pldis.
height = (
unsigned int) ( -Tk_Height( tkwin ) );
1819 int i,
const char *col,
int *p_changed )
1827 Tcl_AppendResult( interp,
"color value not specified",
1832 if ( !XParseColor( plFramePtr->
display,
1833 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1835 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1840 r = (unsigned) ( xcol.red & 0xFF00 ) >> 8;
1841 g = (unsigned) ( xcol.green & 0xFF00 ) >> 8;
1842 b = (unsigned) ( xcol.blue & 0xFF00 ) >> 8;
1844 if ( ( pls->
cmap0[i].
r != r ) ||
1845 ( pls->
cmap0[i].
g != g ) ||
1846 ( pls->
cmap0[i].
b != b ) )
1848 pls->
cmap0[i].
r = (
unsigned char) r;
1849 pls->
cmap0[i].
g = (
unsigned char) g;
1850 pls->
cmap0[i].
b = (
unsigned char) b;
1865 int i,
const char *col,
const char *pos,
const char *rev,
int *p_changed )
1869 PLFLT h, l, s, r, g, b, p;
1874 Tcl_AppendResult( interp,
"color value not specified",
1881 Tcl_AppendResult( interp,
"control point position not specified",
1888 Tcl_AppendResult( interp,
"interpolation sense not specified",
1893 if ( !XParseColor( plFramePtr->
display,
1894 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1896 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1901 r = ( (unsigned) ( xcol.red & 0xFF00 ) >> 8 ) / 255.0;
1902 g = ( (unsigned) ( xcol.green & 0xFF00 ) >> 8 ) / 255.0;
1903 b = ( (unsigned) ( xcol.blue & 0xFF00 ) >> 8 ) / 255.0;
1907 p = atof( pos ) / 100.0;
1908 reverse = atoi( rev );
1951 int result = TCL_OK;
1958 fprintf( stderr,
"There are %d arguments to ColorManip:", argc );
1959 for ( i = 0; i <
argc; i++ )
1961 fprintf( stderr,
" %s", argv[i] );
1963 fprintf( stderr,
"\n" );
1973 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
1981 length = (int) strlen( argv[0] );
1986 if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap0", (
size_t) length ) == 0 ) )
1989 unsigned long plcolor;
1992 sprintf( str,
"%d", (
int) pls->
ncol0 );
1993 Tcl_AppendElement( interp, str );
1994 for ( i = 0; i < pls->
ncol0; i++ )
1996 plcolor = (
unsigned long) ( ( pls->
cmap0[i].
r << 16 ) |
1997 ( pls->
cmap0[i].
g << 8 ) |
2000 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
2001 Tcl_AppendElement( interp, str );
2010 else if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap1", (
size_t) length ) == 0 ) )
2013 unsigned long plcolor;
2015 PLFLT h, l, s, r, g, b;
2018 sprintf( str,
"%d", (
int) pls->
ncp1 );
2019 Tcl_AppendElement( interp, str );
2020 for ( i = 0; i < pls->
ncp1; i++ )
2028 r1 =
MAX( 0,
MIN( 255, (
int) ( 256. * r ) ) );
2029 g1 =
MAX( 0,
MIN( 255, (
int) ( 256. * g ) ) );
2030 b1 =
MAX( 0,
MIN( 255, (
int) ( 256. * b ) ) );
2032 plcolor = (
unsigned long) ( ( r1 << 16 ) | ( g1 << 8 ) | ( b1 ) );
2034 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
2035 Tcl_AppendElement( interp, str );
2037 sprintf( str,
"%02d", (
int) ( 100 * pls->
cmap1cp[i].
p ) );
2038 Tcl_AppendElement( interp, str );
2041 Tcl_AppendElement( interp, str );
2049 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap0", (
size_t) length ) == 0 ) )
2051 int i, changed = 1, ncol0 = atoi( argv[1] );
2054 if ( ncol0 > 16 || ncol0 < 1 )
2056 Tcl_AppendResult( interp,
"illegal number of colors in cmap0: ",
2057 argv[1], (
char *) NULL );
2062 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2063 strcpy( tmpstring, argv[2] );
2064 col = strtok( tmpstring,
" " );
2065 for ( i = 0; i < pls->
ncol0; i++ )
2070 if (
scol0( interp, plFramePtr, i, col, &changed ) != TCL_OK )
2073 col = strtok( NULL,
" " );
2084 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap1", (
size_t) length ) == 0 ) )
2086 int i, changed = 1, ncp1 = atoi( argv[1] );
2087 char *col, *pos, *rev;
2089 if ( ncp1 > 32 || ncp1 < 1 )
2091 Tcl_AppendResult( interp,
2092 "illegal number of control points in cmap1: ",
2093 argv[1], (
char *) NULL );
2097 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2098 strcpy( tmpstring, argv[2] );
2099 col = strtok( tmpstring,
" " );
2100 pos = strtok( NULL,
" " );
2101 rev = strtok( NULL,
" " );
2102 for ( i = 0; i < ncp1; i++ )
2107 if (
scol1( interp, plFramePtr,
2108 i, col, pos, rev, &changed ) != TCL_OK )
2111 col = strtok( NULL,
" " );
2112 pos = strtok( NULL,
" " );
2113 rev = strtok( NULL,
" " );
2127 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol0", (
size_t) length ) == 0 ) )
2129 int i = atoi( argv[1] ), changed = 1;
2131 if ( i > pls->
ncol0 || i < 0 )
2133 Tcl_AppendResult( interp,
"illegal color number in cmap0: ",
2134 argv[1], (
char *) NULL );
2138 if (
scol0( interp, plFramePtr, i, argv[2], &changed ) != TCL_OK )
2148 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol1", (
size_t) length ) == 0 ) )
2150 int i = atoi( argv[1] ), changed = 1;
2152 if ( i > pls->
ncp1 || i < 0 )
2154 Tcl_AppendResult( interp,
"illegal control point number in cmap1: ",
2155 argv[1], (
char *) NULL );
2159 if (
scol1( interp, plFramePtr,
2160 i, argv[2], argv[3], argv[4], &changed ) != TCL_OK )
2183 int result = TCL_OK;
2184 char cmdlist[] =
"";
2191 fprintf( stderr,
"There are %d arguments to Cmd:", argc );
2192 for ( i = 0; i <
argc; i++ )
2194 fprintf( stderr,
" %s", argv[i] );
2196 fprintf( stderr,
"\n" );
2203 return plTclCmd( cmdlist, interp, argc, argv );
2209 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2218 result =
plTclCmd( cmdlist, interp, argc, argv );
2247 int argc,
const char **
argv,
int flags )
2249 register Tk_Window tkwin = plFramePtr->
tkwin;
2255 int need_redisplay = 0;
2261 fprintf( stderr,
"Arguments to configure are:" );
2262 for ( i = 0; i <
argc; i++ )
2264 fprintf( stderr,
" %s", argv[i] );
2266 fprintf( stderr,
"\n" );
2272 if ( Tk_ConfigureWidget( interp, tkwin,
configSpecs,
2273 argc, (CONST
char **) argv, (
char *) plFramePtr, flags ) != TCL_OK )
2289 Tk_SetWindowBackground( tkwin, xwd->cmap0[0].pixel );
2290 Tk_SetWindowBorder( tkwin, xwd->cmap0[0].pixel );
2294 gcValues.background = xwd->cmap0[0].pixel;
2295 gcValues.foreground = 0xFF;
2296 gcValues.function = GXxor;
2297 mask = GCForeground | GCBackground | GCFunction;
2299 if ( plFramePtr->
xorGC != NULL )
2302 plFramePtr->
xorGC = Tk_GetGC( plFramePtr->
tkwin, mask, &gcValues );
2306 Tk_SetInternalBorder( tkwin, plFramePtr->
borderWidth );
2307 if ( ( plFramePtr->
width > 0 ) || ( plFramePtr->
height > 0 ) )
2309 Tk_GeometryRequest( tkwin, plFramePtr->
width, plFramePtr->
height );
2317 if ( Tk_IsMapped( tkwin ) )
2319 if ( plFramePtr->
xhairs )
2333 if ( Tk_IsMapped( tkwin ) )
2335 if ( plFramePtr->
rband )
2349 if ( need_redisplay && Tk_IsMapped( tkwin )
2371 register Tk_Window tkwin = plFramePtr->
tkwin;
2372 int result = TCL_OK;
2373 char c = argv[0][0];
2374 int length = (int) strlen( argv[0] );
2380 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2385 if ( ( c ==
'i' ) && ( strncmp( argv[0],
"init", (
size_t) length ) == 0 ) )
2392 else if ( ( c ==
'e' ) && ( strncmp( argv[0],
"end", (
size_t) length ) == 0 ) )
2394 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
2397 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2398 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2400 XSync( Tk_Display( tkwin ), 0 );
2409 else if ( ( c ==
'r' ) && ( strncmp( argv[0],
"rect", (
size_t) length ) == 0 ) )
2413 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2414 " draw rect x0 y0 x1 y1\"", (
char *) NULL );
2420 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
2421 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
2423 x0 = atoi( argv[1] );
2424 y0 = atoi( argv[2] );
2425 x1 = atoi( argv[3] );
2426 y1 = atoi( argv[4] );
2435 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2436 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2438 XSync( Tk_Display( tkwin ), 0 );
2441 plFramePtr->
pts[0].x = (short) x0; plFramePtr->
pts[0].y = (short) y0;
2442 plFramePtr->
pts[1].x = (short) x1; plFramePtr->
pts[1].y = (short) y0;
2443 plFramePtr->
pts[2].x = (short) x1; plFramePtr->
pts[2].y = (short) y1;
2444 plFramePtr->
pts[3].x = (short) x0; plFramePtr->
pts[3].y = (short) y1;
2445 plFramePtr->
pts[4].x = (short) x0; plFramePtr->
pts[4].y = (short) y0;
2447 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2448 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2450 XSync( Tk_Display( tkwin ), 0 );
2472 int result = TCL_OK;
2478 Tcl_SetResult( interp,
"devkeys devnames", TCL_STATIC );
2483 length = (int) strlen( argv[0] );
2487 if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devkeys", (
size_t) length ) == 0 ) )
2490 while ( plFramePtr->
devName[i] != NULL )
2491 Tcl_AppendElement( interp, plFramePtr->
devName[i++] );
2498 else if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devnames", (
size_t) length ) == 0 ) )
2501 while ( plFramePtr->
devDesc[i] != NULL )
2502 Tcl_AppendElement( interp, plFramePtr->
devDesc[i++] );
2511 Tcl_AppendResult( interp,
"bad option to \"info\": must be ",
2512 "devkeys, devnames", (
char *) NULL );
2535 char c = argv[0][0];
2536 int length = (int) strlen( argv[0] );
2542 if ( ( c ==
'f' ) && ( strncmp( argv[0],
"fifo", (
size_t) length ) == 0 ) )
2546 Tcl_AppendResult( interp,
"bad command -- must be: ",
2547 "openlink fifo <pathname>",
2551 #if !defined ( __WIN32__ )
2552 if ( ( iodev->
fd = open( argv[1], O_RDONLY ) ) == -1 )
2557 Tcl_AppendResult( interp,
"cannot open fifo ", argv[1],
2558 " for read", (
char *) NULL );
2563 #if !defined ( __WIN32__ )
2564 iodev->
file = fdopen( iodev->
fd,
"rb" );
2572 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"socket", (
size_t) length ) == 0 ) )
2576 Tcl_AppendResult( interp,
"bad command -- must be: ",
2577 "openlink socket <sock-id>",
2585 #if TCL_MAJOR_VERSION < 7 || ( TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION == 4 )
2588 #define FILECAST ( ClientData )
2592 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2593 if ( Tcl_GetOpenFile( interp, iodev->
fileHandle,
2599 iodev->
fd = fileno( iodev->
file );
2606 Tcl_AppendResult( interp,
"bad option to \"openlink\": must be ",
2607 "fifo or socket", (
char *) NULL );
2615 #if TK_MAJOR_VERSION < 4 || \
2616 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2617 TK_MAJOR_VERSION > 7
2618 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2619 Tk_CreateFileHandler( iodev->
fd, TK_READABLE, (Tk_FileProc *)
ReadData,
2620 (ClientData) plFramePtr );
2623 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2624 Tcl_CreateFileHandler( Tcl_GetFile( (ClientData) iodev->
fd, TCL_UNIX_FD ),
2625 TK_READABLE, (Tk_FileProc *)
ReadData,
2626 (ClientData) plFramePtr );
2649 if ( iodev->
fd == 0 )
2651 Tcl_AppendResult( interp,
"no link currently open", (
char *) NULL );
2655 #if TK_MAJOR_VERSION < 4 || \
2656 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2657 TK_MAJOR_VERSION > 7
2658 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2659 Tk_DeleteFileHandler( iodev->
fd );
2663 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2664 Tcl_DeleteFileHandler( Tcl_GetFile( (ClientData) iodev->
fd,
2685 int result = TCL_OK;
2691 Tcl_AppendResult( interp,
"unable to read from ", iodev->
typeName,
2701 if ( Tcl_Eval( interp, plFramePtr->
bopCmd ) != TCL_OK )
2702 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2703 plFramePtr->
bopCmd, Tcl_GetStringResult( interp ) );
2711 if ( Tcl_Eval( interp, plFramePtr->
eopCmd ) != TCL_OK )
2712 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2713 plFramePtr->
eopCmd, Tcl_GetStringResult( interp ) );
2730 register Tcl_Interp *interp = plFramePtr->
interp;
2735 int result = TCL_OK;
2737 if ( mask & TK_READABLE )
2744 Tcl_AppendResult( interp,
"Packet receive failed:\n\t %s\n",
2753 if ( pdfs->
bp == 0 )
2775 int result = TCL_OK;
2784 char result_str[128];
2786 sprintf( result_str,
"%f", rot );
2787 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2795 result =
Redraw( interp, plFramePtr, argc - 1, argv + 1 );
2819 int result = TCL_OK;
2828 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2838 Tcl_AppendResult( interp,
"Error -- cannot create stream",
2849 Tcl_AppendResult( interp,
2850 "Error -- cannot open plot file for writing",
2853 if ( sfnam != NULL )
2875 if ( plFramePtr->
plpr_cmd == NULL )
2878 #if !defined ( __WIN32__ )
2879 if ( ( plFramePtr->
plpr_cmd == NULL ) || ( pid = fork() ) < 0 )
2884 Tcl_AppendResult( interp,
2885 "Error -- cannot fork print process",
2889 else if ( pid == 0 )
2891 #if !defined ( __WIN32__ )
2898 fprintf( stderr,
"Unable to exec print command.\n" );
2927 PLFLT mar, aspect, jx, jy;
2928 char result_str[128];
2930 plgdidev( &mar, &aspect, &jx, &jy );
2931 sprintf( result_str,
"%g %g %g %g", mar, aspect, jx, jy );
2932 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2940 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2941 " page mar aspect jx jy\"", (
char *) NULL );
2945 plsdidev( atof( argv[0] ), atof( argv[1] ), atof( argv[2] ), atof( argv[3] ) );
2946 return (
Redraw( interp, plFramePtr, argc - 1, argv + 1 ) );
2964 if ( ( plFramePtr->
tkwin != NULL ) &&
2993 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
3004 Tcl_AppendResult( interp,
"Error -- no current save file",
3020 length = (int) strlen( argv[0] );
3024 if ( ( c ==
'a' ) && ( strncmp( argv[0],
"as", (
size_t) length ) == 0 ) )
3028 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3029 " save as device file\"", (
char *) NULL );
3046 Tcl_AppendResult( interp,
"Error -- cannot create stream",
3054 if ( ( sfile = fopen( argv[2],
"wb+" ) ) == NULL )
3056 Tcl_AppendResult( interp,
"Error -- cannot open file ", argv[2],
3057 " for writing", (
char *) NULL );
3081 else if ( ( c ==
'c' ) && ( strncmp( argv[0],
"close", (
size_t) length ) == 0 ) )
3085 Tcl_AppendResult( interp,
"Error -- no current save file",
3102 Tcl_AppendResult( interp,
"bad option to \"save\": must be ",
3103 "as or close", (
char *) NULL );
3132 char result_str[128];
3134 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3135 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3140 length = (int) strlen( argv[0] );
3145 if ( ( c ==
'b' ) && ( strncmp( argv[0],
"bounds", (
size_t) length ) == 0 ) )
3147 char result_str[128];
3151 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3152 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3158 if ( ( c ==
'r' ) && ( strncmp( argv[0],
"reset", (
size_t) length ) == 0 ) )
3168 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"select", (
size_t) length ) == 0 ) )
3172 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3173 " view select xmin ymin xmax ymax\"",
3179 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3187 else if ( ( c ==
'z' ) && ( strncmp( argv[0],
"zoom", (
size_t) length ) == 0 ) )
3191 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3192 " view zoom xmin ymin xmax ymax\"",
3198 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3208 Tcl_AppendResult( interp,
"bad option \"", argv[1],
3209 "\": options to \"view\" are: bounds, reset, select, or zoom",
3218 plFramePtr->
xl =
xl;
3219 plFramePtr->
yl =
yl;
3220 plFramePtr->
xr =
xr;
3221 plFramePtr->
yr =
yr;
3224 return (
Redraw( interp, plFramePtr, argc, argv ) );
3238 int x0, width = Tk_Width( plFramePtr->
tkwin );
3243 xlen = plFramePtr->
xr - plFramePtr->
xl;
3244 x0 = atoi( argv[0] );
3245 xl = x0 / (double) width;
3246 xl =
MAX( 0.,
MIN( ( 1. - xlen ), xl ) );
3249 yl = plFramePtr->
yl;
3250 yr = plFramePtr->
yr;
3252 plFramePtr->
xl =
xl;
3253 plFramePtr->
xr =
xr;
3258 return (
Redraw( interp, plFramePtr, argc, argv ) );
3272 int y0, height = Tk_Height( plFramePtr->
tkwin );
3277 ylen = plFramePtr->
yr - plFramePtr->
yl;
3278 y0 = atoi( argv[0] );
3279 yr = 1. - y0 / (double) height;
3280 yr =
MAX( 0. + ylen,
MIN( 1., yr ) );
3283 xl = plFramePtr->
xl;
3284 xr = plFramePtr->
xr;
3286 plFramePtr->
yl =
yl;
3287 plFramePtr->
yr =
yr;
3292 return (
Redraw( interp, plFramePtr, argc, argv ) );
3312 Tcl_SetResult( interp,
"report what?", TCL_STATIC );
3316 if ( !strcmp( argv[0],
"wc" ) )
3323 Tcl_SetResult( interp,
"Wrong # of args: report wc x y", TCL_STATIC );
3327 x = atof( argv[1] );
3328 y = atof( argv[2] );
3337 snprintf( tmpstring, 50,
"%f %f", gin->wX, gin->wY );
3338 Tcl_SetResult( interp, tmpstring, TCL_VOLATILE );
3342 Tcl_SetResult( interp,
"Cannot locate", TCL_STATIC );
3346 Tcl_SetResult( interp,
"nonsensical request.", TCL_STATIC );
3360 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
bopCmd ) != TCL_OK )
3361 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3362 plFramePtr->
bopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3375 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
eopCmd ) != TCL_OK )
3376 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3377 plFramePtr->
eopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3393 int height = Tk_Height( plFramePtr->
tkwin );
3395 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3400 totalUnits = height;
3401 firstUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yr ) );
3402 lastUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yl ) );
3403 windowUnits = lastUnit - firstUnit;
3404 sprintf(
string,
" %d %d %d %d",
3405 totalUnits, windowUnits, firstUnit, lastUnit );
3410 if ( result != TCL_OK )
3412 Tk_BackgroundError( plFramePtr->
interp );
3425 int width = Tk_Width( plFramePtr->
tkwin );
3427 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3433 firstUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xl );
3434 lastUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xr );
3435 windowUnits = lastUnit - firstUnit;
3436 sprintf(
string,
" %d %d %d %d",
3437 totalUnits, windowUnits, firstUnit, lastUnit );
3442 if ( result != TCL_OK )
3444 Tk_BackgroundError( plFramePtr->
interp );
3458 PLFLT x0, y0, x1, y1;
3460 x0 = atof( argv[0] );
3461 y0 = atof( argv[1] );
3462 x1 = atof( argv[2] );
3463 y1 = atof( argv[3] );
3465 x0 =
MAX( 0.,
MIN( 1., x0 ) );
3466 y0 =
MAX( 0.,
MIN( 1., y0 ) );
3467 x1 =
MAX( 0.,
MIN( 1., x1 ) );
3468 y1 =
MAX( 0.,
MIN( 1., y1 ) );
3472 *xl =
MIN( x0, x1 );
3473 *yl =
MIN( y0, y1 );
3474 *xr =
MAX( x0, x1 );
3475 *yr =
MAX( y0, y1 );