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 );
386 plFramePtr->
tkwin =
new;
387 plFramePtr->
display = Tk_Display(
new );
389 plFramePtr->
xorGC = NULL;
390 plFramePtr->
border = NULL;
391 plFramePtr->
cursor = None;
393 plFramePtr->
flags = 0;
394 plFramePtr->
width = Tk_Width( plFramePtr->
tkwin );
395 plFramePtr->
height = Tk_Height( plFramePtr->
tkwin );
399 plFramePtr->
ipls = 0;
404 plFramePtr->
bopCmd = NULL;
405 plFramePtr->
eopCmd = NULL;
408 plFramePtr->
rband = 0;
423 plr = plFramePtr->
plr;
438 Tk_GetCursor( plFramePtr->
interp, plFramePtr->
tkwin,
"crosshair" );
450 plFramePtr->
devDesc = (
char **) ckalloc(
NDEV *
sizeof (
char ** ) );
451 plFramePtr->
devName = (
char **) ckalloc(
NDEV *
sizeof (
char ** ) );
452 for ( i = 0; i <
NDEV; i++ )
462 Tk_SetClass(
new,
"Plframe" );
464 Tk_CreateEventHandler( plFramePtr->
tkwin, StructureNotifyMask,
467 Tk_CreateEventHandler( plFramePtr->tkwin, ExposureMask,
471 plFramePtr->widgetCmd =
473 Tcl_CreateCommand( interp, Tk_PathName( plFramePtr->tkwin ),
474 (Tcl_CmdProc *)
PlFrameWidgetCmd, (ClientData) plFramePtr, (Tcl_CmdDeleteProc *) NULL );
476 Itk_SetWidgetCommand( plFramePtr->tkwin, plFramePtr->widgetCmd );
479 if (
ConfigurePlFrame( interp, plFramePtr, argc - 2, argv + 2, 0 ) != TCL_OK )
482 Itk_SetWidgetCommand( plFramePtr->tkwin, (Tcl_Command) NULL );
484 Tk_DestroyWindow( plFramePtr->tkwin );
487 Tcl_SetResult( interp, Tk_PathName( plFramePtr->tkwin ), TCL_VOLATILE );
527 printf(
"Current stream %d, frame stream %d\n",
529 printf(
"PlFrameWidgetCmd: " );
530 for ( i = 0; i <
argc; i++ )
531 printf(
" %s", argv[i] );
538 Tcl_AppendResult( interp,
"wrong # args: should be \"",
539 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
542 Tk_Preserve( (ClientData) plFramePtr );
544 length = (int) strlen( argv[1] );
552 if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cmd", (
size_t) length ) == 0 ) )
554 result =
Cmd( interp, plFramePtr, argc - 2, argv + 2 );
559 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cget", (
size_t) length ) == 0 ) )
563 Tcl_AppendResult( interp,
"wrong # args: should be \"",
564 argv[0],
" cget <option>\"", (
char *) NULL );
570 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
571 (
char *) plFramePtr, (
char *) NULL, 0 );
577 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"configure", (
size_t) length ) == 0 ) )
581 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
582 (
char *) plFramePtr, (
char *) NULL, 0 );
584 else if ( argc == 3 )
586 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
587 (
char *) plFramePtr, argv[2], 0 );
592 TK_CONFIG_ARGV_ONLY );
598 else if ( ( c ==
'd' ) &&
599 ( ( strncmp( argv[1],
"db", (
size_t) length ) == 0 ) ||
600 ( strncmp( argv[1],
"doublebuffering", (
size_t) length == 0 ) ) ) )
606 if ( strcmp( argv[2],
"on" ) == 0 )
611 if ( strcmp( argv[2],
"off" ) == 0 )
616 if ( strcmp( argv[2],
"query" ) == 0 )
621 Tcl_SetResult( interp, res, TCL_VOLATILE );
630 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"closelink", (
size_t) length ) == 0 ) )
634 Tcl_AppendResult( interp,
"wrong # args: should be \"",
635 argv[0], (
char *) NULL );
641 result =
Closelink( interp, plFramePtr, argc - 2, argv + 2 );
647 else if ( ( c ==
'd' ) && ( strncmp( argv[1],
"draw", (
size_t) length ) == 0 ) )
651 Tcl_AppendResult( interp,
"wrong # args: should be \"",
652 argv[0],
" draw op ?options?\"", (
char *) NULL );
658 result =
Draw( interp, plFramePtr, argc - 2, argv + 2 );
664 else if ( ( ( c ==
'g' ) && ( ( strncmp( argv[1],
"gcmap0", (
size_t) length ) == 0 ) ||
665 ( strncmp( argv[1],
"gcmap1", (
size_t) length ) == 0 ) ) ) ||
666 ( ( c ==
's' ) && ( ( strncmp( argv[1],
"scmap0", (
size_t) length ) == 0 ) ||
667 ( strncmp( argv[1],
"scmap1", (
size_t) length ) == 0 ) ||
668 ( strncmp( argv[1],
"scol0", (
size_t) length ) == 0 ) ||
669 ( strncmp( argv[1],
"scol1", (
size_t) length ) == 0 ) ) ) )
670 result =
ColorManip( interp, plFramePtr, argc - 1, argv + 1 );
674 else if ( ( c ==
'i' ) && ( strncmp( argv[1],
"info", (
size_t) length ) == 0 ) )
676 result =
Info( interp, plFramePtr, argc - 2, argv + 2 );
681 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"orient", (
size_t) length ) == 0 ) )
683 result =
Orient( interp, plFramePtr, argc - 2, argv + 2 );
688 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"openlink", (
size_t) length ) == 0 ) )
692 Tcl_AppendResult( interp,
"wrong # args: should be \"",
693 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
699 result =
Openlink( interp, plFramePtr, argc - 2, argv + 2 );
705 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"page", (
size_t) length ) == 0 ) )
707 result =
Page( interp, plFramePtr, argc - 2, argv + 2 );
712 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"print", (
size_t) length ) == 0 ) )
714 result =
Print( interp, plFramePtr, argc - 2, argv + 2 );
719 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"redraw", (
size_t) length ) == 0 ) )
723 Tcl_AppendResult( interp,
"wrong # args: should be \"",
724 argv[0],
" redraw\"", (
char *) NULL );
730 result =
Redraw( interp, plFramePtr, argc - 2, argv + 2 );
736 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"report", (
size_t) length ) == 0 ) )
738 result =
report( interp, plFramePtr, argc - 2, argv + 2 );
743 else if ( ( c ==
's' ) && ( strncmp( argv[1],
"save", (
size_t) length ) == 0 ) )
745 result =
Save( interp, plFramePtr, argc - 2, argv + 2 );
750 else if ( ( c ==
'v' ) && ( strncmp( argv[1],
"view", (
size_t) length ) == 0 ) )
752 result =
View( interp, plFramePtr, argc - 2, argv + 2 );
757 else if ( ( c ==
'x' ) && ( strncmp( argv[1],
"xscroll", (
size_t) length ) == 0 ) )
759 if ( argc == 2 || argc > 3 )
761 Tcl_AppendResult( interp,
"wrong # args: should be \"",
762 argv[0],
" xscroll pixel\"", (
char *) NULL );
768 result =
xScroll( interp, plFramePtr, argc - 2, argv + 2 );
774 else if ( ( c ==
'y' ) && ( strncmp( argv[1],
"yscroll", (
size_t) length ) == 0 ) )
776 if ( argc == 2 || argc > 3 )
778 Tcl_AppendResult( interp,
"wrong # args: should be \"",
779 argv[0],
" yscroll pixel\"", (
char *) NULL );
785 result =
yScroll( interp, plFramePtr, argc - 2, argv + 2 );
793 Tcl_AppendResult( interp,
"bad option \"", argv[1],
794 "\": must be closelink, cmd, configure, draw, ",
796 "info, openlink, orient, page, print, redraw, save, ",
797 "scmap0, scmap1, scol0, scol1, ",
798 "view, xscroll, or yscroll", (
char *) NULL );
802 printf(
"bad option!\n" );
807 printf(
"result=%d current stream=%d\n", result, plsc->ipls );
811 Tk_Release( (ClientData) plFramePtr );
841 if ( plFramePtr->
border != NULL )
843 Tk_Free3DBorder( plFramePtr->
border );
845 if ( plFramePtr->
bgColor != NULL )
847 Tk_FreeColor( plFramePtr->
bgColor );
851 ckfree( (
char *) plFramePtr->
plpr_cmd );
853 if ( plFramePtr->
cursor != None )
861 if ( plFramePtr->
xorGC != NULL )
875 ckfree( (
char *) plFramePtr->
SaveFnam );
877 if ( plFramePtr->
devDesc != NULL )
879 ckfree( (
char *) plFramePtr->
devDesc );
881 if ( plFramePtr->
devName != NULL )
883 ckfree( (
char *) plFramePtr->
devName );
889 ckfree( (
char *) plFramePtr->
plr->
iodev );
898 ckfree( (
char *) plFramePtr->
plr );
899 ckfree( (
char *) plFramePtr );
923 register Tk_Window tkwin = plFramePtr->
tkwin;
927 switch ( eventPtr->type )
929 case ConfigureNotify:
930 pldebug(
"PLFrameConfigureEH",
"ConfigureNotify\n" );
932 plFramePtr->
width = Tk_Width( tkwin );
933 plFramePtr->
height = Tk_Height( tkwin );
943 pldebug(
"PLFrameConfigureEH",
"DestroyNotify\n" );
945 Itk_SetWidgetCommand( plFramePtr->
tkwin, (Tcl_Command) NULL );
946 Tcl_DeleteCommand2( plFramePtr->
interp, plFramePtr->widgetCmd );
948 Tcl_DeleteCommand( plFramePtr->
interp, Tk_PathName( tkwin ) );
950 plFramePtr->
tkwin = NULL;
959 pldebug(
"PLFrameConfigureEH",
"MapNotify\n" );
970 if ( !plFramePtr->tkwin_initted )
972 Tcl_VarEval( plFramePtr->interp,
"update", (
char *) NULL );
974 Tk_DoWhenIdle(
PlFrameInit, (ClientData) plFramePtr );
1004 XExposeEvent *
event = (XExposeEvent *) eventPtr;
1005 register Tk_Window tkwin = plFramePtr->
tkwin;
1009 pldebug(
"PLFrameExposeEH",
"Expose\n" );
1015 int x0_old, x1_old, y0_old, y1_old, x0_new, x1_new, y0_new, y1_new;
1017 x0_old = (int) plFramePtr->
pldis.
x;
1018 y0_old = (
int) plFramePtr->
pldis.
y;
1019 x1_old = x0_old + (int) plFramePtr->
pldis.
width;
1024 x1_new = x0_new +
event->width;
1025 y1_new = y0_new +
event->height;
1027 plFramePtr->
pldis.
x = (
unsigned int)
MIN( x0_old, x0_new );
1028 plFramePtr->
pldis.
y = (
unsigned int)
MIN( y0_old, y0_new );
1035 if ( event->count == 0 )
1040 plFramePtr->width = Tk_Width( tkwin );
1041 plFramePtr->height = Tk_Height( tkwin );
1068 XMotionEvent *
event = (XMotionEvent *) eventPtr;
1074 DrawXhairs( plFramePtr, event->x, event->y );
1078 DrawRband( plFramePtr, event->x, event->y );
1102 XCrossingEvent *crossingEvent = (XCrossingEvent *) eventPtr;
1106 if ( plFramePtr->
xhairs )
1108 DrawXhairs( plFramePtr, crossingEvent->x, crossingEvent->y );
1111 if ( plFramePtr->
rband )
1115 DrawRband( plFramePtr, crossingEvent->x, crossingEvent->y );
1178 XKeyEvent *
event = (XKeyEvent *) eventPtr;
1179 register Tk_Window tkwin = plFramePtr->
tkwin;
1188 nchars = XLookupString( event,
string, 10, &keysym, &cs );
1189 string[nchars] =
'\0';
1190 pldebug(
"PlFrameKeyEH",
"Keysym %x, translation: %s\n", keysym,
string );
1192 if ( IsModifierKey( keysym ) )
1196 else if ( IsCursorKey( keysym ) )
1198 int x1, y1,
dx = 0,
dy = 0;
1199 int x0 =
event->x, y0 =
event->y;
1200 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
1201 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
1223 if ( event->state & 0x01 )
1231 if ( event->state & 0x02 )
1239 if ( event->state & 0x04 )
1247 if ( event->state & 0x08 )
1269 XWarpPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1270 None, 0, 0, 0, 0, dx, dy );
1284 register Tk_Window tkwin = plFramePtr->
tkwin;
1286 int root_x, root_y, win_x, win_y;
1296 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1297 &root, &child, &root_x, &root_y, &win_x, &win_y,
1300 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1301 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1312 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1315 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1318 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1324 Tk_CreateEventHandler( tkwin, KeyPressMask,
1337 register Tk_Window tkwin = plFramePtr->
tkwin;
1341 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
1347 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1350 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1353 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1357 Tk_DeleteEventHandler( tkwin, KeyPressMask,
1363 plFramePtr->drawing_xhairs = 0;
1375 register Tk_Window tkwin = plFramePtr->
tkwin;
1376 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
1377 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
1382 plFramePtr->
xhair_x[0].x = (short) xmin; plFramePtr->
xhair_x[0].y = (short) y0;
1385 plFramePtr->
xhair_y[0].x = (short) x0; plFramePtr->
xhair_y[0].y = (short) ymin;
1400 register Tk_Window tkwin = plFramePtr->
tkwin;
1402 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1406 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1420 register Tk_Window tkwin = plFramePtr->
tkwin;
1422 int root_x, root_y, win_x, win_y;
1427 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1428 &root, &child, &root_x, &root_y, &win_x, &win_y,
1431 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1432 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1435 plFramePtr->
rband_pt[0].x = (short) win_x;
1436 plFramePtr->
rband_pt[0].y = (short) win_y;
1459 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1462 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1465 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1479 register Tk_Window tkwin = plFramePtr->
tkwin;
1485 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1488 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1491 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1515 plFramePtr->
rband_pt[1].x = (short) x0; plFramePtr->
rband_pt[1].y = (short) y0;
1529 register Tk_Window tkwin = plFramePtr->
tkwin;
1531 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1556 register Tk_Window tkwin = plFramePtr->
tkwin;
1577 if ( plFramePtr->
bopCmd != NULL )
1579 if ( plFramePtr->
eopCmd != NULL )
1585 plFramePtr->
width = Tk_Width( tkwin );
1586 plFramePtr->
height = Tk_Height( tkwin );
1595 if ( plFramePtr->
xhairs )
1598 if ( plFramePtr->
rband )
1624 #define INSTALL_COLORMAP_IN_TK
1625 #ifdef INSTALL_COLORMAP_IN_TK
1627 Tk_SetWindowColormap( Tk_MainWindow( plFramePtr->
interp ), dev->
xwd->
map );
1639 Window top, colormap_windows[5];
1641 top = Tk_WindowId( Tk_MainWindow( plFramePtr->
interp ) );
1643 colormap_windows[count++] = Tk_WindowId( plFramePtr->
tkwin );
1644 colormap_windows[count++] = top;
1646 if ( !XSetWMColormapWindows( plFramePtr->
display,
1647 top, colormap_windows, count ) )
1648 fprintf( stderr,
"Unable to set color map property!\n" );
1673 register Tk_Window tkwin = plFramePtr->
tkwin;
1691 if ( ( plFramePtr->
tkwin == NULL ) || !Tk_IsMapped( tkwin ) )
1699 if ( ( plFramePtr->
border != NULL ) &&
1700 ( plFramePtr->
relief != TK_RELIEF_FLAT ) )
1702 #if TK_MAJOR_VERSION >= 4 && TK_MINOR_VERSION >= 0
1703 Tk_Draw3DRectangle( plFramePtr->
tkwin, Tk_WindowId( tkwin ),
1704 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1707 Tk_Draw3DRectangle( plFramePtr->
display, Tk_WindowId( tkwin ),
1708 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1760 XClearWindow( plFramePtr->
display, Tk_WindowId( tkwin ) );
1761 XFlush( plFramePtr->
display );
1771 plFramePtr->
pldis.
x = (
unsigned int) ( Tk_X( tkwin ) + Tk_Width( tkwin ) );
1772 plFramePtr->
pldis.
y = (
unsigned int) ( Tk_Y( tkwin ) + Tk_Height( tkwin ) );
1773 plFramePtr->
pldis.
width = (
unsigned int) ( -Tk_Width( tkwin ) );
1774 plFramePtr->
pldis.
height = (
unsigned int) ( -Tk_Height( tkwin ) );
1805 int i,
const char *col,
int *p_changed )
1813 Tcl_AppendResult( interp,
"color value not specified",
1818 if ( !XParseColor( plFramePtr->
display,
1819 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1821 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1826 r = (unsigned) ( xcol.red & 0xFF00 ) >> 8;
1827 g = (unsigned) ( xcol.green & 0xFF00 ) >> 8;
1828 b = (unsigned) ( xcol.blue & 0xFF00 ) >> 8;
1830 if ( ( pls->
cmap0[i].
r != r ) ||
1831 ( pls->
cmap0[i].
g != g ) ||
1832 ( pls->
cmap0[i].
b != b ) )
1834 pls->
cmap0[i].
r = (
unsigned char) r;
1835 pls->
cmap0[i].
g = (
unsigned char) g;
1836 pls->
cmap0[i].
b = (
unsigned char) b;
1851 int i,
const char *col,
const char *pos,
const char *rev,
int *p_changed )
1855 PLFLT h, l, s, r, g, b, p;
1860 Tcl_AppendResult( interp,
"color value not specified",
1867 Tcl_AppendResult( interp,
"control point position not specified",
1874 Tcl_AppendResult( interp,
"interpolation sense not specified",
1879 if ( !XParseColor( plFramePtr->
display,
1880 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1882 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1887 r = ( (unsigned) ( xcol.red & 0xFF00 ) >> 8 ) / 255.0;
1888 g = ( (unsigned) ( xcol.green & 0xFF00 ) >> 8 ) / 255.0;
1889 b = ( (unsigned) ( xcol.blue & 0xFF00 ) >> 8 ) / 255.0;
1893 p = atof( pos ) / 100.0;
1894 reverse = atoi( rev );
1937 int result = TCL_OK;
1944 fprintf( stderr,
"There are %d arguments to ColorManip:", argc );
1945 for ( i = 0; i <
argc; i++ )
1947 fprintf( stderr,
" %s", argv[i] );
1949 fprintf( stderr,
"\n" );
1959 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
1967 length = (int) strlen( argv[0] );
1972 if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap0", (
size_t) length ) == 0 ) )
1975 unsigned long plcolor;
1978 sprintf( str,
"%d", (
int) pls->
ncol0 );
1979 Tcl_AppendElement( interp, str );
1980 for ( i = 0; i < pls->
ncol0; i++ )
1982 plcolor = (
unsigned long) ( ( pls->
cmap0[i].
r << 16 ) |
1983 ( pls->
cmap0[i].
g << 8 ) |
1986 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
1987 Tcl_AppendElement( interp, str );
1996 else if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap1", (
size_t) length ) == 0 ) )
1999 unsigned long plcolor;
2001 PLFLT h, l, s, r, g, b;
2004 sprintf( str,
"%d", (
int) pls->
ncp1 );
2005 Tcl_AppendElement( interp, str );
2006 for ( i = 0; i < pls->
ncp1; i++ )
2014 r1 =
MAX( 0,
MIN( 255, (
int) ( 256. * r ) ) );
2015 g1 =
MAX( 0,
MIN( 255, (
int) ( 256. * g ) ) );
2016 b1 =
MAX( 0,
MIN( 255, (
int) ( 256. * b ) ) );
2018 plcolor = (
unsigned long) ( ( r1 << 16 ) | ( g1 << 8 ) | ( b1 ) );
2020 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
2021 Tcl_AppendElement( interp, str );
2023 sprintf( str,
"%02d", (
int) ( 100 * pls->
cmap1cp[i].
p ) );
2024 Tcl_AppendElement( interp, str );
2027 Tcl_AppendElement( interp, str );
2035 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap0", (
size_t) length ) == 0 ) )
2037 int i, changed = 1, ncol0 = atoi( argv[1] );
2040 if ( ncol0 > 16 || ncol0 < 1 )
2042 Tcl_AppendResult( interp,
"illegal number of colors in cmap0: ",
2043 argv[1], (
char *) NULL );
2048 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2049 strcpy( tmpstring, argv[2] );
2050 col = strtok( tmpstring,
" " );
2051 for ( i = 0; i < pls->
ncol0; i++ )
2056 if (
scol0( interp, plFramePtr, i, col, &changed ) != TCL_OK )
2059 col = strtok( NULL,
" " );
2070 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap1", (
size_t) length ) == 0 ) )
2072 int i, changed = 1, ncp1 = atoi( argv[1] );
2073 char *col, *pos, *rev;
2075 if ( ncp1 > 32 || ncp1 < 1 )
2077 Tcl_AppendResult( interp,
2078 "illegal number of control points in cmap1: ",
2079 argv[1], (
char *) NULL );
2083 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2084 strcpy( tmpstring, argv[2] );
2085 col = strtok( tmpstring,
" " );
2086 pos = strtok( NULL,
" " );
2087 rev = strtok( NULL,
" " );
2088 for ( i = 0; i < ncp1; i++ )
2093 if (
scol1( interp, plFramePtr,
2094 i, col, pos, rev, &changed ) != TCL_OK )
2097 col = strtok( NULL,
" " );
2098 pos = strtok( NULL,
" " );
2099 rev = strtok( NULL,
" " );
2113 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol0", (
size_t) length ) == 0 ) )
2115 int i = atoi( argv[1] ), changed = 1;
2117 if ( i > pls->
ncol0 || i < 0 )
2119 Tcl_AppendResult( interp,
"illegal color number in cmap0: ",
2120 argv[1], (
char *) NULL );
2124 if (
scol0( interp, plFramePtr, i, argv[2], &changed ) != TCL_OK )
2134 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol1", (
size_t) length ) == 0 ) )
2136 int i = atoi( argv[1] ), changed = 1;
2138 if ( i > pls->
ncp1 || i < 0 )
2140 Tcl_AppendResult( interp,
"illegal control point number in cmap1: ",
2141 argv[1], (
char *) NULL );
2145 if (
scol1( interp, plFramePtr,
2146 i, argv[2], argv[3], argv[4], &changed ) != TCL_OK )
2169 int result = TCL_OK;
2170 char cmdlist[] =
"";
2177 fprintf( stderr,
"There are %d arguments to Cmd:", argc );
2178 for ( i = 0; i <
argc; i++ )
2180 fprintf( stderr,
" %s", argv[i] );
2182 fprintf( stderr,
"\n" );
2189 return plTclCmd( cmdlist, interp, argc, argv );
2195 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2204 result =
plTclCmd( cmdlist, interp, argc, argv );
2233 int argc,
const char **
argv,
int flags )
2235 register Tk_Window tkwin = plFramePtr->
tkwin;
2241 int need_redisplay = 0;
2247 fprintf( stderr,
"Arguments to configure are:" );
2248 for ( i = 0; i <
argc; i++ )
2250 fprintf( stderr,
" %s", argv[i] );
2252 fprintf( stderr,
"\n" );
2258 if ( Tk_ConfigureWidget( interp, tkwin,
configSpecs,
2259 argc, (CONST
char **) argv, (
char *) plFramePtr, flags ) != TCL_OK )
2275 Tk_SetWindowBackground( tkwin, xwd->cmap0[0].pixel );
2276 Tk_SetWindowBorder( tkwin, xwd->cmap0[0].pixel );
2280 gcValues.background = xwd->cmap0[0].pixel;
2281 gcValues.foreground = 0xFF;
2282 gcValues.function = GXxor;
2283 mask = GCForeground | GCBackground | GCFunction;
2285 if ( plFramePtr->
xorGC != NULL )
2288 plFramePtr->
xorGC = Tk_GetGC( plFramePtr->
tkwin, mask, &gcValues );
2292 Tk_SetInternalBorder( tkwin, plFramePtr->
borderWidth );
2293 if ( ( plFramePtr->
width > 0 ) || ( plFramePtr->
height > 0 ) )
2295 Tk_GeometryRequest( tkwin, plFramePtr->
width, plFramePtr->
height );
2303 if ( Tk_IsMapped( tkwin ) )
2305 if ( plFramePtr->
xhairs )
2319 if ( Tk_IsMapped( tkwin ) )
2321 if ( plFramePtr->
rband )
2335 if ( need_redisplay && Tk_IsMapped( tkwin )
2357 register Tk_Window tkwin = plFramePtr->
tkwin;
2358 int result = TCL_OK;
2359 char c = argv[0][0];
2360 int length = (int) strlen( argv[0] );
2366 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2371 if ( ( c ==
'i' ) && ( strncmp( argv[0],
"init", (
size_t) length ) == 0 ) )
2378 else if ( ( c ==
'e' ) && ( strncmp( argv[0],
"end", (
size_t) length ) == 0 ) )
2380 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
2383 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2384 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2386 XSync( Tk_Display( tkwin ), 0 );
2395 else if ( ( c ==
'r' ) && ( strncmp( argv[0],
"rect", (
size_t) length ) == 0 ) )
2399 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2400 " draw rect x0 y0 x1 y1\"", (
char *) NULL );
2406 int xmin = 0,
xmax = Tk_Width( tkwin ) - 1;
2407 int ymin = 0,
ymax = Tk_Height( tkwin ) - 1;
2409 x0 = atoi( argv[1] );
2410 y0 = atoi( argv[2] );
2411 x1 = atoi( argv[3] );
2412 y1 = atoi( argv[4] );
2421 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2422 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2424 XSync( Tk_Display( tkwin ), 0 );
2427 plFramePtr->
pts[0].x = (short) x0; plFramePtr->
pts[0].y = (short) y0;
2428 plFramePtr->
pts[1].x = (short) x1; plFramePtr->
pts[1].y = (short) y0;
2429 plFramePtr->
pts[2].x = (short) x1; plFramePtr->
pts[2].y = (short) y1;
2430 plFramePtr->
pts[3].x = (short) x0; plFramePtr->
pts[3].y = (short) y1;
2431 plFramePtr->
pts[4].x = (short) x0; plFramePtr->
pts[4].y = (short) y0;
2433 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2434 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2436 XSync( Tk_Display( tkwin ), 0 );
2458 int result = TCL_OK;
2464 Tcl_SetResult( interp,
"devkeys devnames", TCL_STATIC );
2469 length = (int) strlen( argv[0] );
2473 if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devkeys", (
size_t) length ) == 0 ) )
2476 while ( plFramePtr->
devName[i] != NULL )
2477 Tcl_AppendElement( interp, plFramePtr->
devName[i++] );
2484 else if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devnames", (
size_t) length ) == 0 ) )
2487 while ( plFramePtr->
devDesc[i] != NULL )
2488 Tcl_AppendElement( interp, plFramePtr->
devDesc[i++] );
2497 Tcl_AppendResult( interp,
"bad option to \"info\": must be ",
2498 "devkeys, devnames", (
char *) NULL );
2521 char c = argv[0][0];
2522 int length = (int) strlen( argv[0] );
2528 if ( ( c ==
'f' ) && ( strncmp( argv[0],
"fifo", (
size_t) length ) == 0 ) )
2532 Tcl_AppendResult( interp,
"bad command -- must be: ",
2533 "openlink fifo <pathname>",
2537 if ( ( iodev->
fd = open( argv[1], O_RDONLY ) ) == -1 )
2539 Tcl_AppendResult( interp,
"cannot open fifo ", argv[1],
2540 " for read", (
char *) NULL );
2545 iodev->
file = fdopen( iodev->
fd,
"rb" );
2550 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"socket", (
size_t) length ) == 0 ) )
2554 Tcl_AppendResult( interp,
"bad command -- must be: ",
2555 "openlink socket <sock-id>",
2563 #if TCL_MAJOR_VERSION < 7 || ( TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION == 4 )
2566 #define FILECAST ( ClientData )
2570 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2571 if ( Tcl_GetOpenFile( interp, iodev->
fileHandle,
2577 iodev->
fd = fileno( iodev->
file );
2584 Tcl_AppendResult( interp,
"bad option to \"openlink\": must be ",
2585 "fifo or socket", (
char *) NULL );
2593 #if TK_MAJOR_VERSION < 4 || \
2594 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2595 TK_MAJOR_VERSION > 7
2596 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2597 Tk_CreateFileHandler( iodev->
fd, TK_READABLE, (Tk_FileProc *)
ReadData,
2598 (ClientData) plFramePtr );
2601 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2602 Tcl_CreateFileHandler( Tcl_GetFile( (ClientData) iodev->
fd, TCL_UNIX_FD ),
2603 TK_READABLE, (Tk_FileProc *)
ReadData,
2604 (ClientData) plFramePtr );
2627 if ( iodev->
fd == 0 )
2629 Tcl_AppendResult( interp,
"no link currently open", (
char *) NULL );
2633 #if TK_MAJOR_VERSION < 4 || \
2634 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2635 TK_MAJOR_VERSION > 7
2636 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2637 Tk_DeleteFileHandler( iodev->
fd );
2641 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2642 Tcl_DeleteFileHandler( Tcl_GetFile( (ClientData) iodev->
fd,
2663 int result = TCL_OK;
2669 Tcl_AppendResult( interp,
"unable to read from ", iodev->
typeName,
2679 if ( Tcl_Eval( interp, plFramePtr->
bopCmd ) != TCL_OK )
2680 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2681 plFramePtr->
bopCmd, Tcl_GetStringResult( interp ) );
2689 if ( Tcl_Eval( interp, plFramePtr->
eopCmd ) != TCL_OK )
2690 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2691 plFramePtr->
eopCmd, Tcl_GetStringResult( interp ) );
2708 register Tcl_Interp *interp = plFramePtr->
interp;
2713 int result = TCL_OK;
2715 if ( mask & TK_READABLE )
2722 Tcl_AppendResult( interp,
"Packet receive failed:\n\t %s\n",
2731 if ( pdfs->
bp == 0 )
2753 int result = TCL_OK;
2762 char result_str[128];
2764 sprintf( result_str,
"%f", rot );
2765 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2773 result =
Redraw( interp, plFramePtr, argc - 1, argv + 1 );
2797 int result = TCL_OK;
2806 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2816 Tcl_AppendResult( interp,
"Error -- cannot create stream",
2827 Tcl_AppendResult( interp,
2828 "Error -- cannot open plot file for writing",
2831 if ( sfnam != NULL )
2853 if ( plFramePtr->
plpr_cmd == NULL )
2856 if ( ( plFramePtr->
plpr_cmd == NULL ) || ( pid = fork() ) < 0 )
2858 Tcl_AppendResult( interp,
2859 "Error -- cannot fork print process",
2863 else if ( pid == 0 )
2868 fprintf( stderr,
"Unable to exec print command.\n" );
2897 PLFLT mar, aspect, jx, jy;
2898 char result_str[128];
2900 plgdidev( &mar, &aspect, &jx, &jy );
2901 sprintf( result_str,
"%g %g %g %g", mar, aspect, jx, jy );
2902 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2910 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2911 " page mar aspect jx jy\"", (
char *) NULL );
2915 plsdidev( atof( argv[0] ), atof( argv[1] ), atof( argv[2] ), atof( argv[3] ) );
2916 return (
Redraw( interp, plFramePtr, argc - 1, argv + 1 ) );
2934 if ( ( plFramePtr->
tkwin != NULL ) &&
2963 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2974 Tcl_AppendResult( interp,
"Error -- no current save file",
2990 length = (int) strlen( argv[0] );
2994 if ( ( c ==
'a' ) && ( strncmp( argv[0],
"as", (
size_t) length ) == 0 ) )
2998 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2999 " save as device file\"", (
char *) NULL );
3016 Tcl_AppendResult( interp,
"Error -- cannot create stream",
3024 if ( ( sfile = fopen( argv[2],
"wb+" ) ) == NULL )
3026 Tcl_AppendResult( interp,
"Error -- cannot open file ", argv[2],
3027 " for writing", (
char *) NULL );
3051 else if ( ( c ==
'c' ) && ( strncmp( argv[0],
"close", (
size_t) length ) == 0 ) )
3055 Tcl_AppendResult( interp,
"Error -- no current save file",
3072 Tcl_AppendResult( interp,
"bad option to \"save\": must be ",
3073 "as or close", (
char *) NULL );
3102 char result_str[128];
3104 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3105 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3110 length = (int) strlen( argv[0] );
3115 if ( ( c ==
'b' ) && ( strncmp( argv[0],
"bounds", (
size_t) length ) == 0 ) )
3117 char result_str[128];
3121 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3122 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3128 if ( ( c ==
'r' ) && ( strncmp( argv[0],
"reset", (
size_t) length ) == 0 ) )
3138 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"select", (
size_t) length ) == 0 ) )
3142 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3143 " view select xmin ymin xmax ymax\"",
3149 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3157 else if ( ( c ==
'z' ) && ( strncmp( argv[0],
"zoom", (
size_t) length ) == 0 ) )
3161 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3162 " view zoom xmin ymin xmax ymax\"",
3168 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3178 Tcl_AppendResult( interp,
"bad option \"", argv[1],
3179 "\": options to \"view\" are: bounds, reset, select, or zoom",
3188 plFramePtr->
xl =
xl;
3189 plFramePtr->
yl =
yl;
3190 plFramePtr->
xr =
xr;
3191 plFramePtr->
yr =
yr;
3194 return (
Redraw( interp, plFramePtr, argc, argv ) );
3208 int x0, width = Tk_Width( plFramePtr->
tkwin );
3213 xlen = plFramePtr->
xr - plFramePtr->
xl;
3214 x0 = atoi( argv[0] );
3215 xl = x0 / (double) width;
3216 xl =
MAX( 0.,
MIN( ( 1. - xlen ), xl ) );
3219 yl = plFramePtr->
yl;
3220 yr = plFramePtr->
yr;
3222 plFramePtr->
xl =
xl;
3223 plFramePtr->
xr =
xr;
3228 return (
Redraw( interp, plFramePtr, argc, argv ) );
3242 int y0, height = Tk_Height( plFramePtr->
tkwin );
3247 ylen = plFramePtr->
yr - plFramePtr->
yl;
3248 y0 = atoi( argv[0] );
3249 yr = 1. - y0 / (double) height;
3250 yr =
MAX( 0. + ylen,
MIN( 1., yr ) );
3253 xl = plFramePtr->
xl;
3254 xr = plFramePtr->
xr;
3256 plFramePtr->
yl =
yl;
3257 plFramePtr->
yr =
yr;
3262 return (
Redraw( interp, plFramePtr, argc, argv ) );
3282 Tcl_SetResult( interp,
"report what?", TCL_STATIC );
3286 if ( !strcmp( argv[0],
"wc" ) )
3293 Tcl_SetResult( interp,
"Wrong # of args: report wc x y", TCL_STATIC );
3297 x = atof( argv[1] );
3298 y = atof( argv[2] );
3307 snprintf( tmpstring, 50,
"%f %f", gin->wX, gin->wY );
3308 Tcl_SetResult( interp, tmpstring, TCL_VOLATILE );
3312 Tcl_SetResult( interp,
"Cannot locate", TCL_STATIC );
3316 Tcl_SetResult( interp,
"nonsensical request.", TCL_STATIC );
3330 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
bopCmd ) != TCL_OK )
3331 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3332 plFramePtr->
bopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3345 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
eopCmd ) != TCL_OK )
3346 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3347 plFramePtr->
eopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3363 int height = Tk_Height( plFramePtr->
tkwin );
3365 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3370 totalUnits = height;
3371 firstUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yr ) );
3372 lastUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yl ) );
3373 windowUnits = lastUnit - firstUnit;
3374 sprintf(
string,
" %d %d %d %d",
3375 totalUnits, windowUnits, firstUnit, lastUnit );
3380 if ( result != TCL_OK )
3382 Tk_BackgroundError( plFramePtr->
interp );
3395 int width = Tk_Width( plFramePtr->
tkwin );
3397 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3403 firstUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xl );
3404 lastUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xr );
3405 windowUnits = lastUnit - firstUnit;
3406 sprintf(
string,
" %d %d %d %d",
3407 totalUnits, windowUnits, firstUnit, lastUnit );
3412 if ( result != TCL_OK )
3414 Tk_BackgroundError( plFramePtr->
interp );
3428 PLFLT x0, y0, x1, y1;
3430 x0 = atof( argv[0] );
3431 y0 = atof( argv[1] );
3432 x1 = atof( argv[2] );
3433 y1 = atof( argv[3] );
3435 x0 =
MAX( 0.,
MIN( 1., x0 ) );
3436 y0 =
MAX( 0.,
MIN( 1., y0 ) );
3437 x1 =
MAX( 0.,
MIN( 1., x1 ) );
3438 y1 =
MAX( 0.,
MIN( 1., y1 ) );
3442 *xl =
MIN( x0, x1 );
3443 *yl =
MIN( y0, y1 );
3444 *xr =
MAX( x0, x1 );
3445 *yr =
MAX( y0, y1 );
PLDLLIMPEXP_TCLTK int plTclCmd(char *cmdlist, Tcl_Interp *interp, int argc, const char **argv)
PLControlPt cmap1cp[PL_MAX_CMAP1CP]
#define DEF_PLFRAME_HEIGHT
int plr_process(PLRDev *plr)
#define PLESC_DOUBLEBUFFERING_ENABLE
#define UPDATE_H_SCROLLBAR
#define PLESC_DOUBLEBUFFERING_QUERY
void plP_esc(PLINT op, void *ptr)
PDFstrm * pdf_bopen(U_CHAR *buffer, size_t bufmax)
void pl_cpcolor(PLColor *to, PLColor *from)
static int Closelink(Tcl_Interp *, PlFrame *, int, const char **)
#define DEF_PLFRAME_BORDER_WIDTH
#define PLESC_DOUBLEBUFFERING
static int Orient(Tcl_Interp *, PlFrame *, int, const char **)
void pldid2pc(PLFLT *xmin, PLFLT *ymin, PLFLT *xmax, PLFLT *ymax)
int plFrameCmd(ClientData, Tcl_Interp *, int, const char **)
static int Draw(Tcl_Interp *, PlFrame *, int, const char **)
static int PlFrameWidgetCmd(ClientData, Tcl_Interp *, int, const char **)
static void PlFrameMotionEH(ClientData, register XEvent *)
void plseopH(void(*handler)(void *, int *), void *handler_data)
static int Redraw(Tcl_Interp *, PlFrame *, int, const char **)
static void PlFrameEnterEH(ClientData, register XEvent *)
static void DestroyPlFrame(FreeProcArg)
FILE * pl_create_tempfile(char **fname)
static void CreateRband(PlFrame *)
static void UpdateRband(PlFrame *)
void plr_start(PLRDev *plr)
static int Cmd(Tcl_Interp *, PlFrame *, int, const char **)
static void process_bop(void *, int *)
void PLFLT PLINT PLINT PLFLT x
void pldip2dc(PLFLT *xmin, PLFLT *ymin, PLFLT *xmax, PLFLT *ymax)
static int ConfigurePlFrame(Tcl_Interp *, PlFrame *, int, const char **, int)
static void Install_cmap(PlFrame *plFramePtr)
static void PlFrameLeaveEH(ClientData, register XEvent *)
static int xScroll(Tcl_Interp *, PlFrame *, int, const char **)
static void DestroyRband(PlFrame *)
#define UPDATE_V_SCROLLBAR
char * plFindCommand(const char *fn)
static void CreateXhairs(PlFrame *)
static void process_eop(void *, int *)
#define DEF_PLFRAME_WIDTH
int plTranslateCursor(PLGraphicsIn *plg)
static void DestroyXhairs(PlFrame *)
static void PlFrameExposeEH(ClientData, XEvent *)
static void UpdateHScrollbar(register PlFrame *)
static int scol1(Tcl_Interp *interp, register PlFrame *plFramePtr, int i, const char *col, const char *pos, const char *rev, int *p_changed)
static void PlFrameConfigureEH(ClientData, XEvent *)
static int report(Tcl_Interp *, PlFrame *, int, const char **)
xl
set sign_dx [expr ($dx > 0) ? 1 : -1] set sign_dy [expr ($dy > 0) ? 1 : -1]
#define DEF_PLFRAME_RELIEF
void PLFLT PLINT PLINT PLFLT PLFLT y
static void PlFrameInit(ClientData)
static void gbox(PLFLT *, PLFLT *, PLFLT *, PLFLT *, const char **)
static int Page(Tcl_Interp *, PlFrame *, int, const char **)
static Tk_ConfigSpec configSpecs[]
static void DrawRband(PlFrame *, int, int)
static void DrawXhairs(PlFrame *, int, int)
void pl_cmd(PLINT op, void *ptr)
#define DEF_PLFRAME_BG_MONO
void plgFileDevs(const char ***p_menustr, const char ***p_devname, int *p_ndev)
static int ReadData(ClientData, int)
static int View(Tcl_Interp *, PlFrame *, int, const char **)
static void PlFrameKeyEH(ClientData, register XEvent *)
PLDLLIMPEXP_TCLTK int pl_PacketReceive(Tcl_Interp *interp, PLiodev *iodev, PDFstrm *pdfs)
static void UpdateXhairs(PlFrame *)
int pdf_close(PDFstrm *pdfs)
static void DisplayPlFrame(ClientData)
#define PLESC_DOUBLEBUFFERING_DISABLE
static int scol0(Tcl_Interp *interp, register PlFrame *plFramePtr, int i, const char *col, int *p_changed)
static int Openlink(Tcl_Interp *, PlFrame *, int, const char **)
void plsbopH(void(*handler)(void *, int *), void *handler_data)
#define DEF_PLFRAME_CURSOR
static int yScroll(Tcl_Interp *, PlFrame *, int, const char **)
static void UpdateVScrollbar(register PlFrame *)
static int process_data(Tcl_Interp *interp, register PlFrame *plFramePtr)
#define DEF_PLFRAME_BG_COLOR
static int Info(Tcl_Interp *, PlFrame *, int, const char **)
static int Save(Tcl_Interp *, PlFrame *, int, const char **)
static Tcl_Interp * interp
dx
if { $zoomopts($this,1) == 0 } then {
static int ColorManip(Tcl_Interp *, PlFrame *, int, const char **)
void plgpls(PLStream **p_pls)
static int Print(Tcl_Interp *, PlFrame *, int, const char **)