55 #ifdef PL_HAVE_UNISTD_H
62 #define NDEV 100 // Max number of output device types in menu
74 #define plframe_cmd( code ) \
75 if ( ( code ) == TCL_ERROR ) return ( TCL_ERROR );
79 #if TCL_MAJOR_VERSION <= 7 && TCL_MINOR_VERSION <= 4
80 #define Tk_Cursor Cursor
103 Tcl_Command widgetCmd;
192 #define REFRESH_PENDING 1
193 #define RESIZE_PENDING 2
194 #define REDRAW_PENDING 4
195 #define UPDATE_V_SCROLLBAR 8
196 #define UPDATE_H_SCROLLBAR 16
200 #define DEF_PLFRAME_BG_COLOR "Black"
201 #define DEF_PLFRAME_BG_MONO "White"
202 #define DEF_PLFRAME_BORDER_WIDTH "0"
203 #define DEF_PLFRAME_CURSOR ( (char *) NULL )
204 #define DEF_PLFRAME_HEIGHT "0"
205 #define DEF_PLFRAME_RELIEF "flat"
206 #define DEF_PLFRAME_WIDTH "0"
211 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
213 TK_CONFIG_COLOR_ONLY, NULL },
220 { TK_CONFIG_COLOR,
"-plbg",
"plbackground",
"Plbackground",
222 TK_CONFIG_COLOR_ONLY, NULL },
224 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
226 TK_CONFIG_MONO_ONLY, NULL },
233 { TK_CONFIG_COLOR,
"-plbg", (
char *) NULL, (
char *) NULL,
235 TK_CONFIG_MONO_ONLY, NULL },
237 { TK_CONFIG_SYNONYM,
"-bd",
"borderWidth", (
char *) NULL,
238 (
char *) NULL, 0, 0, NULL },
239 { TK_CONFIG_SYNONYM,
"-bg",
"background", (
char *) NULL,
240 (
char *) NULL, 0, 0, NULL },
241 { TK_CONFIG_PIXELS,
"-borderwidth",
"borderWidth",
"BorderWidth",
243 { TK_CONFIG_ACTIVE_CURSOR,
"-cursor",
"cursor",
"Cursor",
245 { TK_CONFIG_STRING,
"-bopcmd",
"bopcmd",
"PgCommand",
246 (
char *) NULL, Tk_Offset(
PlFrame, bopCmd ), TK_CONFIG_NULL_OK, NULL },
247 { TK_CONFIG_STRING,
"-eopcmd",
"eopcmd",
"PgCommand",
248 (
char *) NULL, Tk_Offset(
PlFrame, eopCmd ), TK_CONFIG_NULL_OK, NULL },
249 { TK_CONFIG_PIXELS,
"-height",
"height",
"Height",
251 { TK_CONFIG_RELIEF,
"-relief",
"relief",
"Relief",
253 { TK_CONFIG_PIXELS,
"-width",
"width",
"Width",
255 { TK_CONFIG_BOOLEAN,
"-xhairs", (
char *) NULL, (
char *) NULL,
256 "0", Tk_Offset(
PlFrame, xhairs ), TK_CONFIG_DONT_SET_DEFAULT, NULL },
257 { TK_CONFIG_BOOLEAN,
"-rubberband", (
char *) NULL, (
char *) NULL,
258 "0", Tk_Offset(
PlFrame, rband ), TK_CONFIG_DONT_SET_DEFAULT, NULL },
259 { TK_CONFIG_STRING,
"-xscrollcommand",
"xScrollCommand",
"ScrollCommand",
260 (
char *) NULL, Tk_Offset(
PlFrame, xScrollCmd ), TK_CONFIG_NULL_OK, NULL },
261 { TK_CONFIG_STRING,
"-yscrollcommand",
"yScrollCommand",
"ScrollCommand",
262 (
char *) NULL, Tk_Offset(
PlFrame, yScrollCmd ), TK_CONFIG_NULL_OK, NULL },
263 { TK_CONFIG_END, (
char *) NULL, (
char *) NULL, (
char *) NULL,
264 (
char *) NULL, 0, 0, NULL }
271 int plFrameCmd( ClientData, Tcl_Interp *,
int,
const char ** );
275 #if TK_MAJOR_VERSION < 4 || ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 )
276 #define FreeProcArg ClientData
278 #define FreeProcArg char *
289 static void PlFrameKeyEH( ClientData,
register XEvent * );
290 static int PlFrameWidgetCmd( ClientData, Tcl_Interp *,
int,
const char ** );
291 static int ReadData( ClientData,
int );
297 static int Cmd( Tcl_Interp *,
PlFrame *,
int,
const char ** );
300 static int Draw( Tcl_Interp *,
PlFrame *,
int,
const char ** );
301 static int Info( Tcl_Interp *,
PlFrame *,
int,
const char ** );
303 static int Orient( Tcl_Interp *,
PlFrame *,
int,
const char ** );
304 static int Page( Tcl_Interp *,
PlFrame *,
int,
const char ** );
305 static int Print( Tcl_Interp *,
PlFrame *,
int,
const char ** );
306 static int Redraw( Tcl_Interp *,
PlFrame *,
int,
const char ** );
307 static int Save( Tcl_Interp *,
PlFrame *,
int,
const char ** );
308 static int View( Tcl_Interp *,
PlFrame *,
int,
const char ** );
309 static int xScroll( Tcl_Interp *,
PlFrame *,
int,
const char ** );
310 static int yScroll( Tcl_Interp *,
PlFrame *,
int,
const char ** );
311 static int report( Tcl_Interp *,
PlFrame *,
int,
const char ** );
369 Tcl_AppendResult( interp,
"wrong # args: should be \"",
370 argv[0],
" pathName ?options?\"", (
char *) NULL );
376 new = Tk_CreateWindowFromPath( interp, Tk_MainWindow( interp ),
377 argv[1], (
char *) NULL );
388 plFramePtr->
tkwin =
new;
389 plFramePtr->
display = Tk_Display(
new );
392 plFramePtr->
border = NULL;
395 plFramePtr->
width = Tk_Width( plFramePtr->
tkwin );
396 plFramePtr->
height = Tk_Height( plFramePtr->
tkwin );
397 plFramePtr->
cursor = None;
398 plFramePtr->
flags = 0;
416 plFramePtr->
xorGC = NULL;
426 plFramePtr->
bopCmd = NULL;
427 plFramePtr->
eopCmd = NULL;
432 plFramePtr->
rband = 0;
436 plr = plFramePtr->
plr;
446 Tk_GetCursor( plFramePtr->
interp, plFramePtr->
tkwin,
"crosshair" );
458 plFramePtr->
devDesc = (
const char **) ckalloc(
NDEV *
sizeof (
char ** ) );
459 plFramePtr->
devName = (
const char **) ckalloc(
NDEV *
sizeof (
char ** ) );
460 for ( i = 0; i <
NDEV; i++ )
470 Tk_SetClass( plFramePtr->
tkwin,
"Plframe" );
472 Tk_CreateEventHandler( plFramePtr->
tkwin, StructureNotifyMask,
475 Tk_CreateEventHandler( plFramePtr->tkwin, ExposureMask,
479 plFramePtr->widgetCmd =
481 Tcl_CreateCommand( interp, Tk_PathName( plFramePtr->tkwin ),
482 (Tcl_CmdProc *)
PlFrameWidgetCmd, (ClientData) plFramePtr, (Tcl_CmdDeleteProc *) NULL );
484 Itk_SetWidgetCommand( plFramePtr->tkwin, plFramePtr->widgetCmd );
487 if (
ConfigurePlFrame( interp, plFramePtr, argc - 2, argv + 2, 0 ) != TCL_OK )
490 Itk_SetWidgetCommand( plFramePtr->tkwin, (Tcl_Command) NULL );
492 Tk_DestroyWindow( plFramePtr->tkwin );
495 Tcl_SetResult( interp, Tk_PathName( plFramePtr->tkwin ), TCL_VOLATILE );
535 printf(
"Current stream %d, frame stream %d\n",
537 printf(
"PlFrameWidgetCmd: " );
538 for ( i = 0; i <
argc; i++ )
539 printf(
" %s", argv[i] );
546 Tcl_AppendResult( interp,
"wrong # args: should be \"",
547 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
550 Tk_Preserve( (ClientData) plFramePtr );
552 length = (int) strlen( argv[1] );
560 if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cmd", (
size_t) length ) == 0 ) )
562 result =
Cmd( interp, plFramePtr, argc - 2, argv + 2 );
567 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cget", (
size_t) length ) == 0 ) )
571 Tcl_AppendResult( interp,
"wrong # args: should be \"",
572 argv[0],
" cget <option>\"", (
char *) NULL );
578 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
579 (
char *) plFramePtr, (
char *) NULL, 0 );
585 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"configure", (
size_t) length ) == 0 ) )
589 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
590 (
char *) plFramePtr, (
char *) NULL, 0 );
592 else if ( argc == 3 )
594 result = Tk_ConfigureInfo( interp, plFramePtr->tkwin,
configSpecs,
595 (
char *) plFramePtr, argv[2], 0 );
600 TK_CONFIG_ARGV_ONLY );
606 else if ( ( c ==
'd' ) &&
607 ( ( strncmp( argv[1],
"db", (
size_t) length ) == 0 ) ||
608 ( strncmp( argv[1],
"doublebuffering", (
size_t) length == 0 ) ) ) )
614 if ( strcmp( argv[2],
"on" ) == 0 )
619 if ( strcmp( argv[2],
"off" ) == 0 )
624 if ( strcmp( argv[2],
"query" ) == 0 )
629 Tcl_SetResult( interp, res, TCL_VOLATILE );
638 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"closelink", (
size_t) length ) == 0 ) )
642 Tcl_AppendResult( interp,
"wrong # args: should be \"",
643 argv[0], (
char *) NULL );
649 result =
Closelink( interp, plFramePtr, argc - 2, argv + 2 );
655 else if ( ( c ==
'd' ) && ( strncmp( argv[1],
"draw", (
size_t) length ) == 0 ) )
659 Tcl_AppendResult( interp,
"wrong # args: should be \"",
660 argv[0],
" draw op ?options?\"", (
char *) NULL );
666 result =
Draw( interp, plFramePtr, argc - 2, argv + 2 );
672 else if ( ( ( c ==
'g' ) && ( ( strncmp( argv[1],
"gcmap0", (
size_t) length ) == 0 ) ||
673 ( strncmp( argv[1],
"gcmap1", (
size_t) length ) == 0 ) ) ) ||
674 ( ( c ==
's' ) && ( ( strncmp( argv[1],
"scmap0", (
size_t) length ) == 0 ) ||
675 ( strncmp( argv[1],
"scmap1", (
size_t) length ) == 0 ) ||
676 ( strncmp( argv[1],
"scol0", (
size_t) length ) == 0 ) ||
677 ( strncmp( argv[1],
"scol1", (
size_t) length ) == 0 ) ) ) )
678 result =
ColorManip( interp, plFramePtr, argc - 1, argv + 1 );
682 else if ( ( c ==
'i' ) && ( strncmp( argv[1],
"info", (
size_t) length ) == 0 ) )
684 result =
Info( interp, plFramePtr, argc - 2, argv + 2 );
689 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"orient", (
size_t) length ) == 0 ) )
691 result =
Orient( interp, plFramePtr, argc - 2, argv + 2 );
696 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"openlink", (
size_t) length ) == 0 ) )
700 Tcl_AppendResult( interp,
"wrong # args: should be \"",
701 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
707 result =
Openlink( interp, plFramePtr, argc - 2, argv + 2 );
713 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"page", (
size_t) length ) == 0 ) )
715 result =
Page( interp, plFramePtr, argc - 2, argv + 2 );
720 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"print", (
size_t) length ) == 0 ) )
722 result =
Print( interp, plFramePtr, argc - 2, argv + 2 );
727 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"redraw", (
size_t) length ) == 0 ) )
731 Tcl_AppendResult( interp,
"wrong # args: should be \"",
732 argv[0],
" redraw\"", (
char *) NULL );
738 result =
Redraw( interp, plFramePtr, argc - 2, argv + 2 );
744 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"report", (
size_t) length ) == 0 ) )
746 result =
report( interp, plFramePtr, argc - 2, argv + 2 );
751 else if ( ( c ==
's' ) && ( strncmp( argv[1],
"save", (
size_t) length ) == 0 ) )
753 result =
Save( interp, plFramePtr, argc - 2, argv + 2 );
758 else if ( ( c ==
'v' ) && ( strncmp( argv[1],
"view", (
size_t) length ) == 0 ) )
760 result =
View( interp, plFramePtr, argc - 2, argv + 2 );
765 else if ( ( c ==
'x' ) && ( strncmp( argv[1],
"xscroll", (
size_t) length ) == 0 ) )
767 if ( argc == 2 || argc > 3 )
769 Tcl_AppendResult( interp,
"wrong # args: should be \"",
770 argv[0],
" xscroll pixel\"", (
char *) NULL );
776 result =
xScroll( interp, plFramePtr, argc - 2, argv + 2 );
782 else if ( ( c ==
'y' ) && ( strncmp( argv[1],
"yscroll", (
size_t) length ) == 0 ) )
784 if ( argc == 2 || argc > 3 )
786 Tcl_AppendResult( interp,
"wrong # args: should be \"",
787 argv[0],
" yscroll pixel\"", (
char *) NULL );
793 result =
yScroll( interp, plFramePtr, argc - 2, argv + 2 );
801 Tcl_AppendResult( interp,
"bad option \"", argv[1],
802 "\": must be closelink, cmd, configure, draw, ",
804 "info, openlink, orient, page, print, redraw, save, ",
805 "scmap0, scmap1, scol0, scol1, ",
806 "view, xscroll, or yscroll", (
char *) NULL );
810 printf(
"bad option!\n" );
815 printf(
"result=%d current stream=%d\n", result, plsc->ipls );
819 Tk_Release( (ClientData) plFramePtr );
849 if ( plFramePtr->
border != NULL )
851 Tk_Free3DBorder( plFramePtr->
border );
853 if ( plFramePtr->
bgColor != NULL )
855 Tk_FreeColor( plFramePtr->
bgColor );
859 ckfree( (
char *) plFramePtr->
plpr_cmd );
861 if ( plFramePtr->
cursor != None )
869 if ( plFramePtr->
xorGC != NULL )
883 ckfree( (
char *) plFramePtr->
SaveFnam );
885 if ( plFramePtr->
devDesc != NULL )
887 ckfree( (
char *) plFramePtr->
devDesc );
889 if ( plFramePtr->
devName != NULL )
891 ckfree( (
char *) plFramePtr->
devName );
897 ckfree( (
char *) plFramePtr->
plr->
iodev );
906 ckfree( (
char *) plFramePtr->
plr );
907 ckfree( (
char *) plFramePtr );
931 register Tk_Window tkwin = plFramePtr->
tkwin;
935 switch ( eventPtr->type )
937 case ConfigureNotify:
938 pldebug(
"PLFrameConfigureEH",
"ConfigureNotify\n" );
940 plFramePtr->
width = Tk_Width( tkwin );
941 plFramePtr->
height = Tk_Height( tkwin );
951 pldebug(
"PLFrameConfigureEH",
"DestroyNotify\n" );
953 Itk_SetWidgetCommand( plFramePtr->
tkwin, (Tcl_Command) NULL );
954 Tcl_DeleteCommand2( plFramePtr->
interp, plFramePtr->widgetCmd );
956 Tcl_DeleteCommand( plFramePtr->
interp, Tk_PathName( tkwin ) );
958 plFramePtr->
tkwin = NULL;
967 pldebug(
"PLFrameConfigureEH",
"MapNotify\n" );
978 if ( !plFramePtr->tkwin_initted )
980 Tcl_VarEval( plFramePtr->interp,
"update", (
char *) NULL );
982 Tk_DoWhenIdle(
PlFrameInit, (ClientData) plFramePtr );
1012 XExposeEvent *
event = (XExposeEvent *) eventPtr;
1013 register Tk_Window tkwin = plFramePtr->
tkwin;
1017 pldebug(
"PLFrameExposeEH",
"Expose\n" );
1023 int x0_old, x1_old, y0_old, y1_old, x0_new, x1_new, y0_new, y1_new;
1025 x0_old = (int) plFramePtr->
pldis.
x;
1026 y0_old = (
int) plFramePtr->
pldis.
y;
1027 x1_old = x0_old + (int) plFramePtr->
pldis.
width;
1032 x1_new = x0_new +
event->width;
1033 y1_new = y0_new +
event->height;
1035 plFramePtr->
pldis.
x = (
unsigned int)
MIN( x0_old, x0_new );
1036 plFramePtr->
pldis.
y = (
unsigned int)
MIN( y0_old, y0_new );
1043 if ( event->count == 0 )
1048 plFramePtr->width = Tk_Width( tkwin );
1049 plFramePtr->height = Tk_Height( tkwin );
1076 XMotionEvent *
event = (XMotionEvent *) eventPtr;
1082 DrawXhairs( plFramePtr, event->x, event->y );
1086 DrawRband( plFramePtr, event->x, event->y );
1110 XCrossingEvent *crossingEvent = (XCrossingEvent *) eventPtr;
1114 if ( plFramePtr->
xhairs )
1116 DrawXhairs( plFramePtr, crossingEvent->x, crossingEvent->y );
1119 if ( plFramePtr->
rband )
1123 DrawRband( plFramePtr, crossingEvent->x, crossingEvent->y );
1186 XKeyEvent *
event = (XKeyEvent *) eventPtr;
1187 register Tk_Window tkwin = plFramePtr->
tkwin;
1196 #if !defined ( __WIN32__ )
1197 nchars = XLookupString( event,
string, 10, &keysym, &cs );
1201 string[nchars] =
'\0';
1202 pldebug(
"PlFrameKeyEH",
"Keysym %x, translation: %s\n", keysym,
string );
1204 if ( IsModifierKey( keysym ) )
1208 else if ( IsCursorKey( keysym ) )
1210 int x1, y1, dx = 0, dy = 0;
1211 int x0 =
event->x, y0 =
event->y;
1212 int xmin = 0, xmax = Tk_Width( tkwin ) - 1;
1213 int ymin = 0, ymax = Tk_Height( tkwin ) - 1;
1235 if ( event->state & 0x01 )
1243 if ( event->state & 0x02 )
1251 if ( event->state & 0x04 )
1259 if ( event->state & 0x08 )
1281 XWarpPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1282 None, 0, 0, 0, 0, dx, dy );
1296 register Tk_Window tkwin = plFramePtr->
tkwin;
1298 int root_x, root_y, win_x, win_y;
1308 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1309 &root, &child, &root_x, &root_y, &win_x, &win_y,
1312 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1313 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1324 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1327 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1330 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1336 Tk_CreateEventHandler( tkwin, KeyPressMask,
1349 register Tk_Window tkwin = plFramePtr->
tkwin;
1353 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
1359 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1362 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1365 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1369 Tk_DeleteEventHandler( tkwin, KeyPressMask,
1375 plFramePtr->drawing_xhairs = 0;
1387 register Tk_Window tkwin = plFramePtr->
tkwin;
1388 int xmin = 0, xmax = Tk_Width( tkwin ) - 1;
1389 int ymin = 0, ymax = Tk_Height( tkwin ) - 1;
1394 plFramePtr->
xhair_x[0].x = (short) xmin; plFramePtr->
xhair_x[0].y = (short) y0;
1395 plFramePtr->
xhair_x[1].x = (short) xmax; plFramePtr->
xhair_x[1].y = (short) y0;
1397 plFramePtr->
xhair_y[0].x = (short) x0; plFramePtr->
xhair_y[0].y = (short) ymin;
1398 plFramePtr->
xhair_y[1].x = (short) x0; plFramePtr->
xhair_y[1].y = (short) ymax;
1412 register Tk_Window tkwin = plFramePtr->
tkwin;
1414 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1418 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1432 register Tk_Window tkwin = plFramePtr->
tkwin;
1434 int root_x, root_y, win_x, win_y;
1439 if ( XQueryPointer( plFramePtr->
display, Tk_WindowId( tkwin ),
1440 &root, &child, &root_x, &root_y, &win_x, &win_y,
1443 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1444 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1447 plFramePtr->
rband_pt[0].x = (short) win_x;
1448 plFramePtr->
rband_pt[0].y = (short) win_y;
1471 Tk_CreateEventHandler( tkwin, PointerMotionMask,
1474 Tk_CreateEventHandler( tkwin, EnterWindowMask,
1477 Tk_CreateEventHandler( tkwin, LeaveWindowMask,
1491 register Tk_Window tkwin = plFramePtr->
tkwin;
1497 Tk_DeleteEventHandler( tkwin, PointerMotionMask,
1500 Tk_DeleteEventHandler( tkwin, EnterWindowMask,
1503 Tk_DeleteEventHandler( tkwin, LeaveWindowMask,
1527 plFramePtr->
rband_pt[1].x = (short) x0; plFramePtr->
rband_pt[1].y = (short) y0;
1541 register Tk_Window tkwin = plFramePtr->
tkwin;
1543 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1568 register Tk_Window tkwin = plFramePtr->
tkwin;
1589 if ( plFramePtr->
bopCmd != NULL )
1591 if ( plFramePtr->
eopCmd != NULL )
1597 plFramePtr->
width = Tk_Width( tkwin );
1598 plFramePtr->
height = Tk_Height( tkwin );
1607 if ( plFramePtr->
xhairs )
1610 if ( plFramePtr->
rband )
1636 #define INSTALL_COLORMAP_IN_TK
1637 #ifdef INSTALL_COLORMAP_IN_TK
1639 Tk_SetWindowColormap( Tk_MainWindow( plFramePtr->
interp ), dev->
xwd->
map );
1651 Window top, colormap_windows[5];
1653 top = Tk_WindowId( Tk_MainWindow( plFramePtr->
interp ) );
1655 colormap_windows[count++] = Tk_WindowId( plFramePtr->
tkwin );
1656 colormap_windows[count++] = top;
1658 if ( !XSetWMColormapWindows( plFramePtr->
display,
1659 top, colormap_windows, count ) )
1660 fprintf( stderr,
"Unable to set color map property!\n" );
1685 register Tk_Window tkwin = plFramePtr->
tkwin;
1703 if ( ( plFramePtr->
tkwin == NULL ) || !Tk_IsMapped( tkwin ) )
1711 if ( ( plFramePtr->
border != NULL ) &&
1712 ( plFramePtr->
relief != TK_RELIEF_FLAT ) )
1714 #if TK_MAJOR_VERSION >= 4 && TK_MINOR_VERSION >= 0
1715 Tk_Draw3DRectangle( plFramePtr->
tkwin, Tk_WindowId( tkwin ),
1716 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1719 Tk_Draw3DRectangle( plFramePtr->
display, Tk_WindowId( tkwin ),
1720 plFramePtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1772 XClearWindow( plFramePtr->
display, Tk_WindowId( tkwin ) );
1773 XFlush( plFramePtr->
display );
1783 plFramePtr->
pldis.
x = (
unsigned int) ( Tk_X( tkwin ) + Tk_Width( tkwin ) );
1784 plFramePtr->
pldis.
y = (
unsigned int) ( Tk_Y( tkwin ) + Tk_Height( tkwin ) );
1785 plFramePtr->
pldis.
width = (
unsigned int) ( -Tk_Width( tkwin ) );
1786 plFramePtr->
pldis.
height = (
unsigned int) ( -Tk_Height( tkwin ) );
1817 int i,
const char *col,
int *p_changed )
1825 Tcl_AppendResult( interp,
"color value not specified",
1830 if ( !XParseColor( plFramePtr->
display,
1831 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1833 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1838 r = (unsigned) ( xcol.red & 0xFF00 ) >> 8;
1839 g = (unsigned) ( xcol.green & 0xFF00 ) >> 8;
1840 b = (unsigned) ( xcol.blue & 0xFF00 ) >> 8;
1842 if ( ( pls->
cmap0[i].
r != r ) ||
1843 ( pls->
cmap0[i].
g != g ) ||
1844 ( pls->
cmap0[i].
b != b ) )
1846 pls->
cmap0[i].
r = (
unsigned char) r;
1847 pls->
cmap0[i].
g = (
unsigned char) g;
1848 pls->
cmap0[i].
b = (
unsigned char) b;
1863 int i,
const char *col,
const char *pos,
const char *rev,
int *p_changed )
1867 PLFLT h, l, s, r, g, b, p;
1872 Tcl_AppendResult( interp,
"color value not specified",
1879 Tcl_AppendResult( interp,
"control point position not specified",
1886 Tcl_AppendResult( interp,
"interpolation sense not specified",
1891 if ( !XParseColor( plFramePtr->
display,
1892 Tk_Colormap( plFramePtr->
tkwin ), col, &xcol ) )
1894 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1899 r = ( (unsigned) ( xcol.red & 0xFF00 ) >> 8 ) / 255.0;
1900 g = ( (unsigned) ( xcol.green & 0xFF00 ) >> 8 ) / 255.0;
1901 b = ( (unsigned) ( xcol.blue & 0xFF00 ) >> 8 ) / 255.0;
1905 p = atof( pos ) / 100.0;
1906 reverse = atoi( rev );
1949 int result = TCL_OK;
1956 fprintf( stderr,
"There are %d arguments to ColorManip:", argc );
1957 for ( i = 0; i <
argc; i++ )
1959 fprintf( stderr,
" %s", argv[i] );
1961 fprintf( stderr,
"\n" );
1971 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
1979 length = (int) strlen( argv[0] );
1984 if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap0", (
size_t) length ) == 0 ) )
1987 unsigned long plcolor;
1990 sprintf( str,
"%d", (
int) pls->
ncol0 );
1991 Tcl_AppendElement( interp, str );
1992 for ( i = 0; i < pls->
ncol0; i++ )
1994 plcolor = (
unsigned long) ( ( pls->
cmap0[i].
r << 16 ) |
1995 ( pls->
cmap0[i].
g << 8 ) |
1998 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
1999 Tcl_AppendElement( interp, str );
2008 else if ( ( c ==
'g' ) && ( strncmp( argv[0],
"gcmap1", (
size_t) length ) == 0 ) )
2011 unsigned long plcolor;
2013 PLFLT h, l, s, r, g, b;
2016 sprintf( str,
"%d", (
int) pls->
ncp1 );
2017 Tcl_AppendElement( interp, str );
2018 for ( i = 0; i < pls->
ncp1; i++ )
2026 r1 =
MAX( 0,
MIN( 255, (
int) ( 256. * r ) ) );
2027 g1 =
MAX( 0,
MIN( 255, (
int) ( 256. * g ) ) );
2028 b1 =
MAX( 0,
MIN( 255, (
int) ( 256. * b ) ) );
2030 plcolor = (
unsigned long) ( ( r1 << 16 ) | ( g1 << 8 ) | ( b1 ) );
2032 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
2033 Tcl_AppendElement( interp, str );
2035 sprintf( str,
"%02d", (
int) ( 100 * pls->
cmap1cp[i].
p ) );
2036 Tcl_AppendElement( interp, str );
2039 Tcl_AppendElement( interp, str );
2047 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap0", (
size_t) length ) == 0 ) )
2049 int i, changed = 1, ncol0 = atoi( argv[1] );
2052 if ( ncol0 > 16 || ncol0 < 1 )
2054 Tcl_AppendResult( interp,
"illegal number of colors in cmap0: ",
2055 argv[1], (
char *) NULL );
2060 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2061 strcpy( tmpstring, argv[2] );
2062 col = strtok( tmpstring,
" " );
2063 for ( i = 0; i < pls->
ncol0; i++ )
2068 if (
scol0( interp, plFramePtr, i, col, &changed ) != TCL_OK )
2071 col = strtok( NULL,
" " );
2082 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scmap1", (
size_t) length ) == 0 ) )
2084 int i, changed = 1, ncp1 = atoi( argv[1] );
2085 char *col, *pos, *rev;
2087 if ( ncp1 > 32 || ncp1 < 1 )
2089 Tcl_AppendResult( interp,
2090 "illegal number of control points in cmap1: ",
2091 argv[1], (
char *) NULL );
2095 tmpstring = (
char *) malloc( strlen( argv[2] ) + 1 );
2096 strcpy( tmpstring, argv[2] );
2097 col = strtok( tmpstring,
" " );
2098 pos = strtok( NULL,
" " );
2099 rev = strtok( NULL,
" " );
2100 for ( i = 0; i < ncp1; i++ )
2105 if (
scol1( interp, plFramePtr,
2106 i, col, pos, rev, &changed ) != TCL_OK )
2109 col = strtok( NULL,
" " );
2110 pos = strtok( NULL,
" " );
2111 rev = strtok( NULL,
" " );
2125 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol0", (
size_t) length ) == 0 ) )
2127 int i = atoi( argv[1] ), changed = 1;
2129 if ( i > pls->
ncol0 || i < 0 )
2131 Tcl_AppendResult( interp,
"illegal color number in cmap0: ",
2132 argv[1], (
char *) NULL );
2136 if (
scol0( interp, plFramePtr, i, argv[2], &changed ) != TCL_OK )
2146 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"scol1", (
size_t) length ) == 0 ) )
2148 int i = atoi( argv[1] ), changed = 1;
2150 if ( i > pls->
ncp1 || i < 0 )
2152 Tcl_AppendResult( interp,
"illegal control point number in cmap1: ",
2153 argv[1], (
char *) NULL );
2157 if (
scol1( interp, plFramePtr,
2158 i, argv[2], argv[3], argv[4], &changed ) != TCL_OK )
2181 int result = TCL_OK;
2182 char cmdlist[] =
"";
2189 fprintf( stderr,
"There are %d arguments to Cmd:", argc );
2190 for ( i = 0; i <
argc; i++ )
2192 fprintf( stderr,
" %s", argv[i] );
2194 fprintf( stderr,
"\n" );
2201 return plTclCmd( cmdlist, interp, argc, argv );
2207 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2216 result =
plTclCmd( cmdlist, interp, argc, argv );
2245 int argc,
const char **
argv,
int flags )
2247 register Tk_Window tkwin = plFramePtr->
tkwin;
2253 int need_redisplay = 0;
2259 fprintf( stderr,
"Arguments to configure are:" );
2260 for ( i = 0; i <
argc; i++ )
2262 fprintf( stderr,
" %s", argv[i] );
2264 fprintf( stderr,
"\n" );
2270 if ( Tk_ConfigureWidget( interp, tkwin,
configSpecs,
2271 argc, (CONST
char **) argv, (
char *) plFramePtr, flags ) != TCL_OK )
2287 Tk_SetWindowBackground( tkwin, xwd->cmap0[0].pixel );
2288 Tk_SetWindowBorder( tkwin, xwd->cmap0[0].pixel );
2292 gcValues.background = xwd->cmap0[0].pixel;
2293 gcValues.foreground = 0xFF;
2294 gcValues.function = GXxor;
2295 mask = GCForeground | GCBackground | GCFunction;
2297 if ( plFramePtr->
xorGC != NULL )
2300 plFramePtr->
xorGC = Tk_GetGC( plFramePtr->
tkwin, mask, &gcValues );
2304 Tk_SetInternalBorder( tkwin, plFramePtr->
borderWidth );
2305 if ( ( plFramePtr->
width > 0 ) || ( plFramePtr->
height > 0 ) )
2307 Tk_GeometryRequest( tkwin, plFramePtr->
width, plFramePtr->
height );
2315 if ( Tk_IsMapped( tkwin ) )
2317 if ( plFramePtr->
xhairs )
2331 if ( Tk_IsMapped( tkwin ) )
2333 if ( plFramePtr->
rband )
2347 if ( need_redisplay && Tk_IsMapped( tkwin )
2369 register Tk_Window tkwin = plFramePtr->
tkwin;
2370 int result = TCL_OK;
2371 char c = argv[0][0];
2372 int length = (int) strlen( argv[0] );
2378 Tcl_VarEval( plFramePtr->
interp,
"update", (
char *) NULL );
2383 if ( ( c ==
'i' ) && ( strncmp( argv[0],
"init", (
size_t) length ) == 0 ) )
2390 else if ( ( c ==
'e' ) && ( strncmp( argv[0],
"end", (
size_t) length ) == 0 ) )
2392 Tk_DefineCursor( tkwin, plFramePtr->
cursor );
2395 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2396 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2398 XSync( Tk_Display( tkwin ), 0 );
2407 else if ( ( c ==
'r' ) && ( strncmp( argv[0],
"rect", (
size_t) length ) == 0 ) )
2411 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2412 " draw rect x0 y0 x1 y1\"", (
char *) NULL );
2418 int xmin = 0, xmax = Tk_Width( tkwin ) - 1;
2419 int ymin = 0, ymax = Tk_Height( tkwin ) - 1;
2421 x0 = atoi( argv[1] );
2422 y0 = atoi( argv[2] );
2423 x1 = atoi( argv[3] );
2424 y1 = atoi( argv[4] );
2426 x0 =
MAX( xmin,
MIN( xmax, x0 ) );
2427 y0 =
MAX( ymin,
MIN( ymax, y0 ) );
2428 x1 =
MAX( xmin,
MIN( xmax, x1 ) );
2429 y1 =
MAX( ymin,
MIN( ymax, y1 ) );
2433 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2434 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2436 XSync( Tk_Display( tkwin ), 0 );
2439 plFramePtr->
pts[0].x = (short) x0; plFramePtr->
pts[0].y = (short) y0;
2440 plFramePtr->
pts[1].x = (short) x1; plFramePtr->
pts[1].y = (short) y0;
2441 plFramePtr->
pts[2].x = (short) x1; plFramePtr->
pts[2].y = (short) y1;
2442 plFramePtr->
pts[3].x = (short) x0; plFramePtr->
pts[3].y = (short) y1;
2443 plFramePtr->
pts[4].x = (short) x0; plFramePtr->
pts[4].y = (short) y0;
2445 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2446 plFramePtr->
xorGC, plFramePtr->
pts, 5,
2448 XSync( Tk_Display( tkwin ), 0 );
2470 int result = TCL_OK;
2476 Tcl_SetResult( interp,
"devkeys devnames", TCL_STATIC );
2481 length = (int) strlen( argv[0] );
2485 if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devkeys", (
size_t) length ) == 0 ) )
2488 while ( plFramePtr->
devName[i] != NULL )
2489 Tcl_AppendElement( interp, plFramePtr->
devName[i++] );
2496 else if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devnames", (
size_t) length ) == 0 ) )
2499 while ( plFramePtr->
devDesc[i] != NULL )
2500 Tcl_AppendElement( interp, plFramePtr->
devDesc[i++] );
2509 Tcl_AppendResult( interp,
"bad option to \"info\": must be ",
2510 "devkeys, devnames", (
char *) NULL );
2533 char c = argv[0][0];
2534 int length = (int) strlen( argv[0] );
2540 if ( ( c ==
'f' ) && ( strncmp( argv[0],
"fifo", (
size_t) length ) == 0 ) )
2544 Tcl_AppendResult( interp,
"bad command -- must be: ",
2545 "openlink fifo <pathname>",
2549 #if !defined ( __WIN32__ )
2550 if ( ( iodev->
fd = open( argv[1], O_RDONLY ) ) == -1 )
2555 Tcl_AppendResult( interp,
"cannot open fifo ", argv[1],
2556 " for read", (
char *) NULL );
2561 #if !defined ( __WIN32__ )
2562 iodev->
file = fdopen( iodev->
fd,
"rb" );
2570 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"socket", (
size_t) length ) == 0 ) )
2574 Tcl_AppendResult( interp,
"bad command -- must be: ",
2575 "openlink socket <sock-id>",
2583 #if TCL_MAJOR_VERSION < 7 || ( TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION == 4 )
2586 #define FILECAST ( ClientData )
2590 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2591 if ( Tcl_GetOpenFile( interp, iodev->
fileHandle,
2597 iodev->
fd = fileno( iodev->
file );
2604 Tcl_AppendResult( interp,
"bad option to \"openlink\": must be ",
2605 "fifo or socket", (
char *) NULL );
2613 #if TK_MAJOR_VERSION < 4 || \
2614 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2615 TK_MAJOR_VERSION > 7
2616 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2617 Tk_CreateFileHandler( iodev->
fd, TK_READABLE, (Tk_FileProc *)
ReadData,
2618 (ClientData) plFramePtr );
2621 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2622 Tcl_CreateFileHandler( Tcl_GetFile( (ClientData) iodev->
fd, TCL_UNIX_FD ),
2623 TK_READABLE, (Tk_FileProc *)
ReadData,
2624 (ClientData) plFramePtr );
2647 if ( iodev->
fd == 0 )
2649 Tcl_AppendResult( interp,
"no link currently open", (
char *) NULL );
2653 #if TK_MAJOR_VERSION < 4 || \
2654 ( TK_MAJOR_VERSION == 4 && TK_MINOR_VERSION == 0 ) || \
2655 TK_MAJOR_VERSION > 7
2656 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2657 Tk_DeleteFileHandler( iodev->
fd );
2661 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ ) && !defined ( __CYGWIN__ )
2662 Tcl_DeleteFileHandler( Tcl_GetFile( (ClientData) iodev->
fd,
2683 int result = TCL_OK;
2689 Tcl_AppendResult( interp,
"unable to read from ", iodev->
typeName,
2699 if ( Tcl_Eval( interp, plFramePtr->
bopCmd ) != TCL_OK )
2700 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2701 plFramePtr->
bopCmd, Tcl_GetStringResult( interp ) );
2709 if ( Tcl_Eval( interp, plFramePtr->
eopCmd ) != TCL_OK )
2710 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2711 plFramePtr->
eopCmd, Tcl_GetStringResult( interp ) );
2728 register Tcl_Interp *interp = plFramePtr->
interp;
2733 int result = TCL_OK;
2735 if ( mask & TK_READABLE )
2742 Tcl_AppendResult( interp,
"Packet receive failed:\n\t %s\n",
2751 if ( pdfs->
bp == 0 )
2773 int result = TCL_OK;
2782 char result_str[128];
2784 sprintf( result_str,
"%f", rot );
2785 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2793 result =
Redraw( interp, plFramePtr, argc - 1, argv + 1 );
2817 int result = TCL_OK;
2826 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2836 Tcl_AppendResult( interp,
"Error -- cannot create stream",
2847 Tcl_AppendResult( interp,
2848 "Error -- cannot open plot file for writing",
2851 if ( sfnam != NULL )
2873 if ( plFramePtr->
plpr_cmd == NULL )
2876 #if !defined ( __WIN32__ )
2877 if ( ( plFramePtr->
plpr_cmd == NULL ) || ( pid = fork() ) < 0 )
2882 Tcl_AppendResult( interp,
2883 "Error -- cannot fork print process",
2887 else if ( pid == 0 )
2889 #if !defined ( __WIN32__ )
2896 fprintf( stderr,
"Unable to exec print command.\n" );
2925 PLFLT mar, aspect, jx, jy;
2926 char result_str[128];
2928 plgdidev( &mar, &aspect, &jx, &jy );
2929 sprintf( result_str,
"%g %g %g %g", mar, aspect, jx, jy );
2930 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2938 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2939 " page mar aspect jx jy\"", (
char *) NULL );
2943 plsdidev( atof( argv[0] ), atof( argv[1] ), atof( argv[2] ), atof( argv[3] ) );
2944 return (
Redraw( interp, plFramePtr, argc - 1, argv + 1 ) );
2962 if ( ( plFramePtr->
tkwin != NULL ) &&
2991 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
3002 Tcl_AppendResult( interp,
"Error -- no current save file",
3018 length = (int) strlen( argv[0] );
3022 if ( ( c ==
'a' ) && ( strncmp( argv[0],
"as", (
size_t) length ) == 0 ) )
3026 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3027 " save as device file\"", (
char *) NULL );
3044 Tcl_AppendResult( interp,
"Error -- cannot create stream",
3052 if ( ( sfile = fopen( argv[2],
"wb+" ) ) == NULL )
3054 Tcl_AppendResult( interp,
"Error -- cannot open file ", argv[2],
3055 " for writing", (
char *) NULL );
3079 else if ( ( c ==
'c' ) && ( strncmp( argv[0],
"close", (
size_t) length ) == 0 ) )
3083 Tcl_AppendResult( interp,
"Error -- no current save file",
3100 Tcl_AppendResult( interp,
"bad option to \"save\": must be ",
3101 "as or close", (
char *) NULL );
3122 PLFLT xl, xr, yl, yr;
3130 char result_str[128];
3132 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3133 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3138 length = (int) strlen( argv[0] );
3143 if ( ( c ==
'b' ) && ( strncmp( argv[0],
"bounds", (
size_t) length ) == 0 ) )
3145 char result_str[128];
3149 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
3150 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
3156 if ( ( c ==
'r' ) && ( strncmp( argv[0],
"reset", (
size_t) length ) == 0 ) )
3166 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"select", (
size_t) length ) == 0 ) )
3170 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3171 " view select xmin ymin xmax ymax\"",
3177 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3185 else if ( ( c ==
'z' ) && ( strncmp( argv[0],
"zoom", (
size_t) length ) == 0 ) )
3189 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3190 " view zoom xmin ymin xmax ymax\"",
3196 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3206 Tcl_AppendResult( interp,
"bad option \"", argv[1],
3207 "\": options to \"view\" are: bounds, reset, select, or zoom",
3216 plFramePtr->
xl = xl;
3217 plFramePtr->
yl = yl;
3218 plFramePtr->
xr = xr;
3219 plFramePtr->
yr = yr;
3222 return (
Redraw( interp, plFramePtr, argc, argv ) );
3236 int x0, width = Tk_Width( plFramePtr->
tkwin );
3237 PLFLT xl, xr, yl, yr, xlen;
3241 xlen = plFramePtr->
xr - plFramePtr->
xl;
3242 x0 = atoi( argv[0] );
3243 xl = x0 / (double) width;
3244 xl =
MAX( 0.,
MIN( ( 1. - xlen ), xl ) );
3247 yl = plFramePtr->
yl;
3248 yr = plFramePtr->
yr;
3250 plFramePtr->
xl = xl;
3251 plFramePtr->
xr = xr;
3256 return (
Redraw( interp, plFramePtr, argc, argv ) );
3270 int y0, height = Tk_Height( plFramePtr->
tkwin );
3271 PLFLT xl, xr, yl, yr, ylen;
3275 ylen = plFramePtr->
yr - plFramePtr->
yl;
3276 y0 = atoi( argv[0] );
3277 yr = 1. - y0 / (double) height;
3278 yr =
MAX( 0. + ylen,
MIN( 1., yr ) );
3281 xl = plFramePtr->
xl;
3282 xr = plFramePtr->
xr;
3284 plFramePtr->
yl = yl;
3285 plFramePtr->
yr = yr;
3290 return (
Redraw( interp, plFramePtr, argc, argv ) );
3310 Tcl_SetResult( interp,
"report what?", TCL_STATIC );
3314 if ( !strcmp( argv[0],
"wc" ) )
3321 Tcl_SetResult( interp,
"Wrong # of args: report wc x y", TCL_STATIC );
3325 x = atof( argv[1] );
3326 y = atof( argv[2] );
3335 snprintf( tmpstring, 50,
"%f %f", gin->wX, gin->wY );
3336 Tcl_SetResult( interp, tmpstring, TCL_VOLATILE );
3340 Tcl_SetResult( interp,
"Cannot locate", TCL_STATIC );
3344 Tcl_SetResult( interp,
"nonsensical request.", TCL_STATIC );
3358 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
bopCmd ) != TCL_OK )
3359 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3360 plFramePtr->
bopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3373 if ( Tcl_Eval( plFramePtr->
interp, plFramePtr->
eopCmd ) != TCL_OK )
3374 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
3375 plFramePtr->
eopCmd, Tcl_GetStringResult( plFramePtr->
interp ) );
3391 int height = Tk_Height( plFramePtr->
tkwin );
3393 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3398 totalUnits = height;
3399 firstUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yr ) );
3400 lastUnit = (int) ( 0.5 + (
PLFLT) height * ( 1. - plFramePtr->
yl ) );
3401 windowUnits = lastUnit - firstUnit;
3402 sprintf(
string,
" %d %d %d %d",
3403 totalUnits, windowUnits, firstUnit, lastUnit );
3408 if ( result != TCL_OK )
3410 Tk_BackgroundError( plFramePtr->
interp );
3423 int width = Tk_Width( plFramePtr->
tkwin );
3425 int totalUnits, windowUnits, firstUnit, lastUnit, result;
3431 firstUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xl );
3432 lastUnit = (int) ( 0.5 + (
PLFLT) width * plFramePtr->
xr );
3433 windowUnits = lastUnit - firstUnit;
3434 sprintf(
string,
" %d %d %d %d",
3435 totalUnits, windowUnits, firstUnit, lastUnit );
3440 if ( result != TCL_OK )
3442 Tk_BackgroundError( plFramePtr->
interp );
3456 PLFLT x0, y0, x1, y1;
3458 x0 = atof( argv[0] );
3459 y0 = atof( argv[1] );
3460 x1 = atof( argv[2] );
3461 y1 = atof( argv[3] );
3463 x0 =
MAX( 0.,
MIN( 1., x0 ) );
3464 y0 =
MAX( 0.,
MIN( 1., y0 ) );
3465 x1 =
MAX( 0.,
MIN( 1., x1 ) );
3466 y1 =
MAX( 0.,
MIN( 1., y1 ) );
3470 *xl =
MIN( x0, x1 );
3471 *yl =
MIN( y0, y1 );
3472 *xr =
MAX( x0, x1 );
3473 *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 **)
PLINT plTranslateCursor(PLGraphicsIn *plg)
static void process_bop(void *, int *)
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
static void CreateXhairs(PlFrame *)
static void process_eop(void *, int *)
#define DEF_PLFRAME_WIDTH
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 **)
#define DEF_PLFRAME_RELIEF
static void PlFrameInit(ClientData)
static void gbox(PLFLT *, PLFLT *, PLFLT *, PLFLT *, const char **)
char * plFindCommand(PLCHAR_VECTOR fn)
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 PLStream * pls[PL_NSTREAMS]
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
static int ColorManip(Tcl_Interp *, PlFrame *, int, const char **)
void plgpls(PLStream **p_pls)
static int Print(Tcl_Interp *, PlFrame *, int, const char **)