Example #1
0
int
MemoProc (Option *opt, int n, int x, int y, char *text, int index)
{   // user callback for mouse events in memo
    static int pressed; // keep track of button 3 state
    int start, end, currentPV = (opt != &engoutOptions[5]);

    switch(n) {
      case 0: // pointer motion
	if(!pressed) return FALSE; // only motion with button 3 down is of interest
	MovePV(x, y, 500/*lineGap + BOARD_HEIGHT * (squareSize + lineGap)*/);
	break;
      case 3: // press button 3
	pressed = 1;
	if(LoadMultiPV(x, y, text, index, &start, &end, currentPV)) {
	    highTextStart[currentPV] = start; highTextEnd[currentPV] = end;
	    HighlightText(&engoutOptions[currentPV ? 12 : 5], start, end, TRUE);
	}
	break;
      case -3: // release button 3
	pressed = 0;
        if(highTextStart[currentPV] != highTextEnd[currentPV])
            HighlightText(&engoutOptions[currentPV ? 12 : 5], highTextStart[currentPV], highTextEnd[currentPV], FALSE);
        highTextStart[currentPV] = highTextEnd[currentPV] = 0;
        UnLoadPV();
	break;
      default:
	return FALSE; // not meant for us; do regular event handler
    }
    return TRUE;
}
Example #2
0
VOID
GetMemoLine(HWND hDlg, int x, int y)
{	// [HGM] pv: translate click to PV line, and load it for display
	char buf[10000];
	int index, start, end, memo;
	POINT pt;

	pt.x = x; pt.y = y;
	memo = currentPV ? IDC_EngineMemo2 : IDC_EngineMemo1;
	index = SendDlgItemMessage( hDlg, memo, EM_CHARFROMPOS, 0, (LPARAM) &pt );
	GetDlgItemText(hDlg, memo, buf, sizeof(buf));
	if(LoadMultiPV(x, y, buf, index, &start, &end)) {
	    SetCapture(hDlg);
	    SendMessage( outputField[currentPV][nMemo], EM_SETSEL, (WPARAM)start, (LPARAM)end );
	    highTextStart[currentPV] = start; highTextEnd[currentPV] = end;
	    SetFocus(outputField[currentPV][nMemo]);
	}
}
Example #3
0
void
SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams)
{	// [HGM] pv: translate click to PV line, and load it for display
	String val;
	int start, end;
	XawTextPosition index, dummy;
	int x, y;
	Arg arg;

	x = event->xmotion.x; y = event->xmotion.y;
	currentPV = (w == outputField[1][nMemo]);
	XawTextGetSelectionPos(w, &index, &dummy);
	XtSetArg(arg, XtNstring, &val);
	XtGetValues(w, &arg, 1);
	if(LoadMultiPV(x, y, val, index, &start, &end)) {
	    XawTextSetSelection( outputField[currentPV][nMemo], start, end );
	    highTextStart[currentPV] = start; highTextEnd[currentPV] = end;
	}
}