Term-Gnuplot
view release on metacpan or search on metacpan
pm_exec/gclient.c view on Meta::CPAN
case WM_USER_PRINT_QBUSY :
return( PrintCmdProc( hWnd, message, mp1, mp2 ) ) ;
case WM_GNUPLOT:
/* display the plot */
lock_mouse = 1;
if( bPopFront ) {
SWP swp; /* pop to front only if the window is not minimized */
if ( (WinQueryWindowPos( hwndFrame, (PSWP)&swp) == TRUE)
&& ((swp.fl & SWP_MINIMIZE) == 0) )
WinSetWindowPos( hwndFrame, HWND_TOP, 0,0,0,0, SWP_ACTIVATE|SWP_ZORDER ) ;
}
if( iPaintCount > 0 ) { /* if outstanding paint messages, repaint */
WinInvalidateRect( hWnd, &rectlPaint, TRUE ) ;
iPaintCount = 0 ;
}
lock_mouse = 0;
return 0L ;
case WM_PAUSEPLOT:
{
SWP swp; /* restore the window if it has been minimized */
if( (WinQueryWindowPos( hwndFrame, &swp) == TRUE)
&& ((swp.fl & SWP_MINIMIZE) != 0) )
WinSetWindowPos( hwndFrame, HWND_TOP, 0,0,0,0, SWP_RESTORE|SWP_SHOW|SWP_ACTIVATE ) ;
}
/* put pause message on screen, or enable 'continue' button */
if( ulPauseMode == PAUSE_DLG ) {
pausedata.pszMessage = (char*)mp1 ;
WinLoadDlg( HWND_DESKTOP,
hWnd,
(PFNWP)PauseMsgDlgProc,
0L,
IDD_PAUSEBOX,
&pausedata ) ;
}
else {
WinEnableMenuItem( WinWindowFromID(
WinQueryWindow( hWnd, QW_PARENT ), FID_MENU ),
IDM_CONTINUE,
TRUE ) ;
}
return 0L ;
case WM_PAUSEEND:
/* resume plotting */
ulPauseReply = (ULONG) mp1 ;
DosPostEventSem( semPause ) ;
return 0L ;
/* New event handles for mouse processing */
#if 0 /* already defined */
case WM_MOUSEMOVE:
return 0L;
#endif
case WM_BUTTON1DBLCLK:
if (IGNORE_MOUSE) return 0L;
/* put the mouse coordinates to the clipboard */
{
SHORT mx = MOUSEMSG(&message)->x;
SHORT my = MOUSEMSG(&message)->y;
double x,y;
char s[256];
int frm = ulMouseSprintfFormatItem-IDM_MOUSE_FORMAT_X_Y;
/*
Note:
Another solution of getting mouse position (available at any
method, not just in this handle event) is the following one:
ok = WinQueryPointerPos(HWND_DESKTOP, &pt); // pt contains pos wrt desktop
WinMapWindowPoints(HWND_DESKTOP, hWnd, &pt, 1); // pt contains pos wrt our hwnd window
sprintf(s,"[%li,%li]",pt.x,pt.y);
*/
}
return 0L; /* end of case WM_BUTTON1DBLCLK */
case WM_BUTTON2CLICK: /* WM_BUTTON2UP: */
if (IGNORE_MOUSE) return 0L;
/* make zoom */
{
POINTL tmp;
HPS hps = WinGetPS(hWnd);
if (pausing) { /* zoom is not allowed during pause */
DosBeep(440,111); break;
}
DosBeep(555,155);
zoomrect_from.x = MOUSEMSG(&message)->x;
zoomrect_from.y = MOUSEMSG(&message)->y;
tmp.x = zoomrect_now.x = zoomrect_from.x + 50; /* set opposite corner */
tmp.y = zoomrect_now.y = zoomrect_from.y + 50;
WinMapWindowPoints( hWnd, HWND_DESKTOP, &tmp, 1); /* move mouse to opposite corner */
WinSetPointerPos( HWND_DESKTOP, tmp.x, tmp.y);
WinReleasePS(hps);
zooming = 1;
}
return 0; /* return from: case WM_BUTTON3DOWN (zoom) */
case WM_BUTTON3UP: /* WM_BUTTON3DBLCLK: */
/* write mouse position to screen */
if (IGNORE_MOUSE) return 0L;
{
SHORT mx=MOUSEMSG(&message)->x; /* mouse position */
SHORT my=MOUSEMSG(&message)->y;
char s[256];
POINTL pt;
double x,y;
HPS hps = WinGetPS(hWnd);
GpiSetColor( hps, CLR_WHITE ); /* set color of the text */
GpiSetMix(hps,FM_XOR);
GpiSetCharMode(hps,CM_MODE1);
pt.x = mx; pt.y = my+4;
GpiCharStringAt(hps,&pt,(long)strlen(s),s);
DosBeep(440,111);
/* draw a cross at the clicked position */
pt.x = mx-3; pt.y = my; GpiMove(hps,&pt);
pt.x += 7; GpiLine(hps,&pt);
pm_exec/gclient.c view on Meta::CPAN
}
break ;
case IDM_PRINTSETUP : /* select printer */
WinDlgBox( HWND_DESKTOP,
hWnd ,
(PFNWP)QPrintersDlgProc,
0L,
IDD_QUERYPRINT,
qPrintData.szPrinterName ) ;
break ;
case IDM_LINES_THICK:
/* change line setting */
bWideLines = !bWideLines ;
ChangeCheck( hWnd, IDM_LINES_THICK, bWideLines?IDM_LINES_THICK:0 ) ;
WinInvalidateRect( hWnd, NULL, TRUE ) ;
break ;
case IDM_LINES_SOLID:
/* change line setting */
bLineTypes = !bLineTypes ;
ChangeCheck( hWnd, IDM_LINES_SOLID, bLineTypes?0:IDM_LINES_SOLID ) ;
EditLineTypes( hWnd, hpsScreen, bLineTypes ) ;
WinInvalidateRect( hWnd, NULL, TRUE ) ;
break ;
case IDM_COLOURS:
/* change colour setting */
bColours = !bColours ;
ChangeCheck( hWnd, IDM_COLOURS, bColours?IDM_COLOURS:0 ) ;
WinInvalidateRect( hWnd, NULL, TRUE ) ;
break ;
case IDM_FRONT:
/* toggle z-order forcing */
bPopFront = !bPopFront ;
ChangeCheck( hWnd, IDM_FRONT, bPopFront?IDM_FRONT:0 ) ;
break ;
case IDM_KEEPRATIO:
/* toggle keep aspect ratio */
bKeepRatio = !bKeepRatio ;
ChangeCheck( hWnd, IDM_KEEPRATIO, bKeepRatio?IDM_KEEPRATIO:0 ) ;
WinInvalidateRect( hWnd, NULL, TRUE ) ; /* redraw screen */
break ;
case IDM_FONTS:
if( GetNewFont( hWnd, hpsScreen ) ) {
bNewFont = TRUE ;
WinInvalidateRect( hWnd, NULL, TRUE ) ;
}
break ;
case IDM_SAVE :
SaveIni( hWnd ) ;
break ;
case IDM_COPY : /* copy to clipboard */
if( WinOpenClipbrd( hab ) ) {
CopyToClipBrd( hWnd ) ;
}
else {
WinMessageBox( HWND_DESKTOP,
hWnd,
"Can't open clipboard",
APP_NAME,
0,
MB_OK | MB_ICONEXCLAMATION ) ;
}
break ;
case IDM_CLEARCLIP : /* clear clipboard */
if( WinOpenClipbrd( hab ) ) {
WinEmptyClipbrd( hab ) ;
WinCloseClipbrd( hab ) ;
}
else {
WinMessageBox( HWND_DESKTOP,
hWnd,
"Can't open clipboard",
APP_NAME,
0,
MB_OK | MB_ICONEXCLAMATION ) ;
}
break ;
case IDM_COMMAND: /* go back to GNUPLOT command window */
WinSwitchToProgram( hSwitch ) ;
break ;
case IDM_CONTINUE:
WinPostMsg( hWnd, WM_PAUSEEND, (MPARAM)1L, (MPARAM)0L ) ;
WinEnableMenuItem( WinWindowFromID(
WinQueryWindow( hWnd, QW_PARENT ), FID_MENU ),
IDM_CONTINUE,
FALSE ) ;
break ;
case IDM_PAUSEGNU: /* gnuplot handles pause */
ChangeCheck( hWnd, ulPauseItem, IDM_PAUSEGNU ) ;
ulPauseItem = IDM_PAUSEGNU ;
ulPauseMode = PAUSE_GNU ;
break ;
case IDM_PAUSEDLG: /* pause message in dlg box */
ChangeCheck( hWnd, ulPauseItem, IDM_PAUSEDLG ) ;
ulPauseItem = IDM_PAUSEDLG ;
ulPauseMode = PAUSE_DLG ;
break ;
case IDM_PAUSEBTN: /* pause uses menu button, no message */
ChangeCheck( hWnd, ulPauseItem, IDM_PAUSEBTN ) ;
ulPauseItem = IDM_PAUSEBTN ;
ulPauseMode = PAUSE_BTN ;
break ;
case IDM_HELPFORHELP:
WinSendMsg(WinQueryHelpInstance(hWnd),
HM_DISPLAY_HELP, 0L, 0L ) ;
return 0L ;
case IDM_EXTENDEDHELP:
WinSendMsg(WinQueryHelpInstance(hWnd),
HM_EXT_HELP, 0L, 0L);
return 0L ;
case IDM_KEYSHELP:
WinSendMsg(WinQueryHelpInstance(hWnd),
HM_KEYS_HELP, 0L, 0L);
return 0L ;
case IDM_HELPINDEX:
WinSendMsg(WinQueryHelpInstance(hWnd),
HM_HELP_INDEX, 0L, 0L);
return 0L ;
/* Now new mousing stuff: */
case IDM_USEMOUSE: /* toggle using/not using mouse cursor tracking */
useMouse = !useMouse ;
ChangeCheck( hWnd, IDM_USEMOUSE, useMouse?IDM_USEMOUSE:0 ) ;
gp_execute( useMouse ? "set mouse" : "unset mouse");
if (!mouseTerminal && gp4mouse.graph == graph2d && !useMouse)
UpdateStatusLine(hpsScreen, 0, ""); /* Erase the info */
#if 0
if(!useMouse) /* redraw screen */
WinInvalidateRect( hWnd, NULL, TRUE ) ;
#endif
return 0L;
case IDM_MOUSE_COORDINATES_REAL:
cur_mouse_mode = MOUSE_COORDINATES_REAL;
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_REAL ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_REAL;
return 0L;
case IDM_MOUSE_COORDINATES_PIXELS:
cur_mouse_mode = MOUSE_COORDINATES_PIXELS;
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_PIXELS ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_PIXELS;
return 0L;
case IDM_MOUSE_COORDINATES_SCREEN:
cur_mouse_mode = MOUSE_COORDINATES_SCREEN;
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_SCREEN ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_SCREEN;
return 0L;
case IDM_MOUSE_COORDINATES_XDATE:
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_XDATE ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_XDATE;
return 0L;
case IDM_MOUSE_COORDINATES_XTIME:
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_XTIME ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_XTIME;
return 0L;
case IDM_MOUSE_COORDINATES_XDATETIME:
ChangeCheck( hWnd, ulMouseCoordItem, IDM_MOUSE_COORDINATES_XDATETIME ) ;
ulMouseCoordItem = IDM_MOUSE_COORDINATES_XDATETIME;
return 0L;
case IDM_MOUSE_CMDS2CLIP:
/* toggle copying the command sent to gnuplot to clipboard */
bSend2gp = !bSend2gp ;
ChangeCheck( hWnd, IDM_MOUSE_CMDS2CLIP, bSend2gp?IDM_MOUSE_CMDS2CLIP:0 ) ;
break ;
case IDM_MOUSE_FORMAT_X_Y:
case IDM_MOUSE_FORMAT_XcY:
case IDM_MOUSE_FORMAT_XsY:
case IDM_MOUSE_FORMAT_XcYc:
case IDM_MOUSE_FORMAT_XcYs:
case IDM_MOUSE_FORMAT_pXdYp:
case IDM_MOUSE_FORMAT_pXcYp:
case IDM_MOUSE_FORMAT_pXsYp:
case IDM_MOUSE_FORMAT_LABEL:
{
char s[100];
ChangeCheck( hWnd, ulMouseSprintfFormatItem, SHORT1FROMMP( mp1 ) ) ;
ulMouseSprintfFormatItem = SHORT1FROMMP( mp1 );
sprintf(s,"set mouse mouseformat \"%s\"",MouseSprintfFormats[ulMouseSprintfFormatItem-IDM_MOUSE_FORMAT_X_Y]);
sprintf(s,"set mouse clipboardformat \"%s\"",MouseSprintfFormats[ulMouseSprintfFormatItem-IDM_MOUSE_FORMAT_X_Y]);
gp_execute(s);
}
return 0L;
case IDM_MOUSE_POLAR_DISTANCE: /* toggle using/not using polar coords of distance */
gp_execute( gpPMmenu.polar_distance ? "set mouse nopolardistance" : "set mouse polardistance" );
return 0L;
case IDM_MOUSE_ZOOMNEXT: /* zoom to next level */
{
char s[80]; gp_exec_event ( GE_keypress, mx, my, 'n', 1);
}
return 0L;
case IDM_MOUSE_UNZOOM: /* unzoom one level back */
{
char s[80]; gp_exec_event ( GE_keypress, mx, my, 'p', 1);
}
return 0L;
case IDM_MOUSE_UNZOOMALL: /* unzoom to the first level */
{ char s[80]; gp_exec_event ( GE_keypress, mx, my, 'u', 1); }
return 0L;
case IDM_MOUSE_RULER:
{
int mx, my;
char s[80];
GetMousePosViewport(hWnd,&mx,&my);
gp_exec_event ( GE_keypress, mx, my, 'r', 1);
}
return 0L;
case IDM_BREAK_DRAWING:
breakDrawing = 1;
return 0L;
case IDM_SET_GRID:
{ char s[80]; gp_exec_event ( GE_keypress, mx, my, 'g', 1); }
return 0L;
case IDM_SET_LINLOGY:
{ char s[80]; gp_exec_event ( GE_keypress, mx, my, 'l', 1); }
return 0L;
case IDM_SET_AUTOSCALE:
gp_execute("set autoscale; replot");
return 0L;
case IDM_DO_REPLOT:
gp_execute("replot");
return 0L;
case IDM_DO_RELOAD:
gp_execute("history !load");
return 0L;
case IDM_DO_SENDCOMMAND:
if (input_from_PM_Terminal) {
if (pausing) DosBeep(440,111);
pm_exec/gclient.c view on Meta::CPAN
case IDM_SET_D_S_HISTEPS:
case IDM_SET_D_S_IMPULSES:
case IDM_SET_D_S_LINES:
case IDM_SET_D_S_LINESPOINTS:
case IDM_SET_D_S_POINTS:
case IDM_SET_D_S_STEPS:
if (input_from_PM_Terminal)
sprintf(input_from_PM_Terminal, "set style data %s; replot",
SetDataStyles[ (USHORT) SHORT1FROMMP( mp1 ) - IDM_SET_D_S_BOXES ] );
gp_execute(0);
return 0L;
case IDM_SET_F_S_BOXES:
case IDM_SET_F_S_DOTS:
case IDM_SET_F_S_FSTEPS:
case IDM_SET_F_S_HISTEPS:
case IDM_SET_F_S_IMPULSES:
case IDM_SET_F_S_LINES:
case IDM_SET_F_S_LINESPOINTS:
case IDM_SET_F_S_POINTS:
case IDM_SET_F_S_STEPS:
if (input_from_PM_Terminal)
sprintf(input_from_PM_Terminal, "set style function %s; replot",
SetDataStyles[ (USHORT) SHORT1FROMMP( mp1 ) - IDM_SET_F_S_BOXES ] );
gp_execute(0);
return 0L;
default :
return WinDefWindowProc( hWnd, message, mp1, mp2 ) ;
}
return( NULL ) ;
}
void ChangeCheck( HWND hWnd , USHORT wItem1 , USHORT wItem2 )
/*
** Utility function:
**
** move check mark from menu item 1 to item 2
*/
{
HWND hMenu ;
hMenu = WinWindowFromID( WinQueryWindow( hWnd, QW_PARENT ),
FID_MENU ) ;
if( wItem1 != 0 )
WinSendMsg( hMenu,
MM_SETITEMATTR,
MPFROM2SHORT( wItem1, TRUE ),
MPFROM2SHORT( MIA_CHECKED, 0 ) ) ;
if( wItem2 != 0 )
WinSendMsg( hMenu,
MM_SETITEMATTR,
MPFROM2SHORT( wItem2, TRUE ),
MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED ) ) ;
}
static void CopyToClipBrd( HWND hWnd )
/*
** Copy window to clipboard as bitmap.
*/
{
HAB hab ;
HBITMAP hbm ;
HMF hmf ;
hab = WinQueryAnchorBlock( hWnd ) ;
WinEmptyClipbrd( hab ) ;
hbm = CopyToBitmap( hpsScreen ) ;
WinSetClipbrdData( hab, (ULONG) hbm, CF_BITMAP, CFI_HANDLE) ;
hmf = CopyToMetaFile( hpsScreen ) ;
WinSetClipbrdData( hab, (ULONG) hmf, CF_METAFILE, CFI_HANDLE) ;
WinCloseClipbrd( hab ) ;
}
HBITMAP CopyToBitmap( HPS hps )
/*
** Copy ps to a bitmap.
*/
{
HPS hpsMem ;
HWND hwnd ;
HAB hab ;
PSZ psz[4] = {NULL,"Display",NULL,NULL} ;
HDC hdcMem, hdcScr ;
SIZEL sizel ;
BITMAPINFOHEADER2 bmp ;
PBITMAPINFO2 pbmi ;
HBITMAP hbm ;
BYTE abBmp[80] ;
LONG alData[2] ;
RECTL rectl ;
POINTL aptl[6] ;
HMF hmf ;
hdcScr = GpiQueryDevice( hps ) ;
hwnd = WinWindowFromDC( hdcScr ) ;
hab = WinQueryAnchorBlock( hwnd ) ;
hdcMem = DevOpenDC( hab,
OD_MEMORY,
"*",
4L,
(PDEVOPENDATA) psz,
hdcScr ) ;
sizel.cx = 0/*GNUPAGE*/ ; sizel.cy = 0/*GNUPAGE*/ ;
hpsMem = GpiCreatePS( hab, hdcMem, &sizel, PU_PELS|GPIA_ASSOC|GPIT_MICRO ) ;
GpiQueryDeviceBitmapFormats( hpsMem, 2L, alData ) ;
WinQueryWindowRect( hwnd, &rectl ) ;
memset( &bmp, 0, sizeof(bmp) ) ;
bmp.cbFix = (ULONG) sizeof( bmp ) ;
bmp.cx = (SHORT) (rectl.xRight-rectl.xLeft) ;
bmp.cy = (SHORT) (rectl.yTop-rectl.yBottom) ;
bmp.cPlanes = alData[0] ;
bmp.cBitCount = alData[1] ;
hbm = GpiCreateBitmap( hpsMem, &bmp, 0, NULL, NULL ) ;
GpiSetBitmap( hpsMem, hbm ) ;
aptl[0].x = 0 ; aptl[0].y = 0 ;
aptl[1].x = (LONG)bmp.cx ; aptl[1].y = (LONG)bmp.cy ;
aptl[2].x = 0 ; aptl[2].y = 0 ;
GpiBitBlt( hpsMem, hps, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE ) ;
pm_exec/gclient.c view on Meta::CPAN
}
break ;
#endif /* PM3D */
case 'u' : { /* set_ruler(int x, int y) term API: x<0 switches ruler off */
int x, y;
BufRead(hRead,&x, sizeof(x), &cbR);
BufRead(hRead,&y, sizeof(y), &cbR);
DrawRuler(); /* remove previous drawing, if any */
if (x < 0) {
ruler.on = 0; break; }
ruler.on = 1;
ruler.x = x; ruler.y = y;
DrawRuler();
}
break ;
case 'c' : { /* set_cursor(int c, int x, int y) term API */
int c, x, y;
BufRead(hRead,&c, sizeof(x), &cbR);
BufRead(hRead,&x, sizeof(x), &cbR);
BufRead(hRead,&y, sizeof(y), &cbR);
switch (c) {
case -2: { /* move mouse to the given point */
RECTL rc;
POINTL pt;
GpiQueryPageViewport(hpsScreen,&rc);
rc.xRight -= rc.xLeft; rc.yTop -= rc.yBottom; /* only distance is important */
/* window => pixels coordinates */
pt.x = (long int)((x*(double)rc.xRight) / 19500.0);
pt.y = (long int)((x*(double)rc.yTop) / 12500.0);
WinMapWindowPoints( hApp, HWND_DESKTOP, &pt, 1);
WinSetPointerPos( HWND_DESKTOP, pt.x, pt.y);
}
break;
case -1: /* start zooming; zooming cursor */
zoombox.on = 1;
zoombox.from.x = zoombox.to.x = x;
zoombox.from.y = zoombox.to.y = y;
break;
case 0: /* standard cross-hair cursor */
WinSetPointer( HWND_DESKTOP, hptrCurrent = (useMouse?hptrCrossHair:hptrDefault) );
break;
case 1: /* cursor during rotation */
WinSetPointer( HWND_DESKTOP, hptrCurrent = hptrRotating);
break;
case 2: /* cursor during scaling */
WinSetPointer( HWND_DESKTOP, hptrCurrent = hptrScaling );
break;
case 3: /* cursor during zooming */
WinSetPointer( HWND_DESKTOP, hptrCurrent = hptrZooming );
break;
}
if (c>=0 && zoombox.on) { /* erase zoom box */
DrawZoomBox();
zoombox.on = 0;
}
}
break ;
case 'l' : { /* set_clipboard(const char s[]) term API */
int len;
char *s;
BufRead(hRead,&len, sizeof(int), &cbR);
s = malloc( len + 1 );
BufRead(hRead,s, len+1, &cbR);
TextToClipboard(s);
free(s);
break ;
}
case '#' : /* update menu according to the gnuplot core settings,
e.g. (un)checking menu items
*/
if (mouseTerminal) { /* we are connected to mouseable terminal */
BufRead(hRead,&gpPMmenu, sizeof(gpPMmenu), &cbR);
if (useMouse != gpPMmenu.use_mouse)
WinSetPointer( HWND_DESKTOP, hptrCurrent = (gpPMmenu.use_mouse?hptrCrossHair:hptrDefault) );
useMouse = gpPMmenu.use_mouse;
gpPMmenu_update_req = 1;
}
break ;
case 'm' :
/* notification of being connected to a mouse-enabled terminal */
mouseTerminal = 1;
#ifdef USE_ACTIVE_EVENTS
# ifdef DEBUG_MOUSE
WinMessageBox( HWND_DESKTOP,
HWND_DESKTOP,
"Terminal is mouse-enabled?!",
APP_NAME,
0,
MB_OK | MB_ICONEXCLAMATION ) ;
# endif
#endif
fprintf(stderr, "drv: mouseTerminal = 1\n");
break ;
default : /* should handle error */
break ;
}
}
}
exitserver:
DosDisConnectNPipe( hRead ) ;
WinPostMsg( hApp, WM_CLOSE, 0L, 0L ) ;
}
static void EditLineTypes( HWND hwnd, HPS hps, BOOL bDashed )
/*
*/
{
int i, rc ;
char buf[64] ;
GpiSetDrawingMode( hps, DM_RETAIN ) ;
GpiOpenSegment( hps, iSeg ) ;
GpiSetEditMode( hps, SEGEM_REPLACE ) ;
for( i=0; i<7; i++ ) {
while( GpiSetElementPointerAtLabel( hps, lLineTypes[i] ) ) {
pm_exec/gclient.c view on Meta::CPAN
iState = 0 ;
}
else togo = iPatt[iLtype][iState] ;
}
}
}
}
void LLine( HPS hps, POINTL *p )
{
double ds, dx, dy ;
if( iLinebegin ) iLinebegin = 0 ;
if( iLtype == 0 ) GpiLine( hps, p ) ;
else {
dx = p->x - pCur.x ;
dy = p->y - pCur.y ;
ds = sqrt( dx*dx + dy*dy ) ;
dx /= ds ; dy /= ds ;
while( ds > 0.0 ) {
if( ds < togo ) {
togo -= ds ;
ds = 0.0 ;
if( iState&1 ) GpiMove( hps, p ) ;
else GpiLine( hps, p ) ;
pCur = *p ;
}
else {
POINTL pn ;
pn.x = pCur.x + togo * dx ;
pn.y = pCur.y + togo * dy ;
if( iState&1 ) GpiMove( hps, &pn ) ;
else GpiLine( hps, &pn ) ;
pCur = pn ;
ds -= togo ;
iState++ ;
if( iPatt[iLtype][iState] < 0 ) {
togo = iPatt[iLtype][0] ;
iState = 0 ;
}
else togo = iPatt[iLtype][iState] ;
}
}
}
}
void LType( int iType )
{
iLinebegin = 1 ;
if( iType > 7 ) iType = 0 ;
iLtype = iType ;
iState = 0 ;
togo = iPatt[iLtype][0] ;
}
/* Now routines for mouse etc. */
static void TextToClipboard ( PCSZ szTextIn )
{
/* copy string given by szTextIn to the clipboard */
PSZ szTextOut = NULL;
ULONG ulRC = DosAllocSharedMem( (PVOID*)&szTextOut, NULL,
strlen( szTextIn ) + 1,
PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE );
if( !ulRC ) {
HAB hab = 0;
strcpy( szTextOut, szTextIn );
WinOpenClipbrd(hab);
WinEmptyClipbrd(hab);
WinSetClipbrdData( hab, (ULONG) szTextOut, CF_TEXT, CFI_POINTER );
WinCloseClipbrd(hab);
}
}
/* Draw the ruler
*/
static void DrawRuler ()
{
POINTL p;
if (!ruler.on || ruler.x < 0) return;
/* GpiSetColor( hpsScreen, COLOR_RULER ); */
GpiSetColor( hpsScreen, CLR_RED );
GpiSetLineWidth(hpsScreen, LINEWIDTH_THICK);
GpiSetMix(hpsScreen,FM_INVERT);
/*GpiBeginPath( hpsScreen, 1 ) ; // will this help? I don't know, but makes thic cross */
p.x = 0; p.y = ruler.y; GpiMove( hpsScreen, &p ) ;
p.x = 19500; GpiLine( hpsScreen, &p ) ;
p.x = ruler.x; p.y = 0; GpiMove( hpsScreen, &p ) ;
p.y = 12500; GpiLine( hpsScreen, &p ) ;
/*GpiEndPath( hpsScreen ) ; */
/*GpiStrokePath( hpsScreen, 1, 0 ) ; */
}
#if 0
/* This routine recalculates mouse/pointer position [mx,my] in [in pixels]
current window to the real/true [x,y] coordinates of the plotted graph.
*/
void MousePosToGraphPos ( double *x, double *y,
HWND hWnd, SHORT mx, SHORT my, ULONG mouse_mode )
{
RECTL rc;
if (mouse_mode==MOUSE_COORDINATES_PIXELS) {
*x = mx; *y = my;
return;
}
/* Rectangle where we are moving: viewport, not the full window! */
GpiQueryPageViewport(hpsScreen,&rc);
rc.xRight -= rc.xLeft; rc.yTop -= rc.yBottom; /* only distance is important */
if (mouse_mode==MOUSE_COORDINATES_SCREEN) {
*x = (double)mx/rc.xRight; *y = (double)my/rc.yTop;
return;
}
*x = mx * 19500.0/rc.xRight; /* px=px(mx); mouse=>gnuplot driver coordinates */
( run in 1.900 second using v1.01-cache-2.11-cpan-2398b32b56e )