예제 #1
0
RoamInterruptibleCmd::~RoamInterruptibleCmd()
{
    // Clean up by removing all callbacks
    
    if ( _wpId)    
	XtRemoveWorkProc ( _wpId );
}
예제 #2
0
파일: paperplane.c 프로젝트: yhsesq/yhs
void toggle(void)
{
    moving = !moving; /* toggle */
    if (moving)
        workId = XtAppAddWorkProc(app, animate, NULL);
    else
        XtRemoveWorkProc(workId);
}
예제 #3
0
void VPERoot::showWorkSpace (int page)
{
    //
    // Store current scroll loc for  current page.
    //
    int x,y;
    this->editor->getWorkspaceWindowPos (&x,&y);
    int pno = this->getCurrentPage();
    if (pno != page) {
	if (pno > 0) {
	    EditorWorkSpace* ews = (EditorWorkSpace*)this->getElement(pno);
	    ews->setRecordedScrollPos(x,y);
	} else {
	    this->setRecordedScrollPos(x,y);
	}
    }

    //
    // By toggling XmNmappedWhenManaged, we can give the scrollbars an opportunity
    // to move and reposition the selected canvas with the contents of the canvas
    // hidden.  This way the user doesn't see the canvas repositioning.  It just
    // appears at the proper location.
    //
    boolean reset_scrollbars = FALSE;
    this->to_be_shown = this;
    if (page) 
	this->to_be_shown = (EditorWorkSpace*)this->getElement(page);
    reset_scrollbars = this->to_be_shown->hasScrollBarPositions();
    if (reset_scrollbars) 
	XtVaSetValues (this->getRootWidget(), XmNmappedWhenManaged, False, NULL);

    this->WorkSpaceRoot::showWorkSpace(page);
    XtAppContext apcxt = theApplication->getApplicationContext();
    XSync (XtDisplay(this->getRootWidget()), False);

    this->selector->selectPage(this->to_be_shown);
    if (reset_scrollbars) {
	if (this->show_wpid)
	    XtRemoveWorkProc(this->show_wpid);
	if (this->move_wpid)
	    XtRemoveWorkProc(this->move_wpid);
	this->show_wpid = XtAppAddWorkProc (apcxt, VPERoot_ShowWindowWP, (XtPointer)this);
	this->move_wpid = XtAppAddWorkProc (apcxt, VPERoot_MoveWindowWP, (XtPointer)this);
    }
}
예제 #4
0
파일: textfun.c 프로젝트: yhsesq/yhs
void 
syncstate(void)
{
    if (motion && (dollying || rotation || wobbling)) {
	if (workId == 0)
	    workId = XtAppAddWorkProc(app, animate, NULL);
    } else if (workId != 0) {
	XtRemoveWorkProc(workId);
	workId = 0;
    }
}
예제 #5
0
파일: ssX.c 프로젝트: q3k/ski
static Boolean runItX(XtPointer client_data)
{
    if (!stopPressed && runIt_loopX(app_data.refreshRate)) {
	displayICnt(app_data.refreshRate, &firstTime);
	return False;			/* call work procedure again */
    }
    cleanup_execLoop(YES);
    XtUnmanageChild(stopsim);
    XtRemoveWorkProc(stopsimWP);
    return True;			/* don't call work proc again */
}
예제 #6
0
파일: ssX.c 프로젝트: q3k/ski
static Boolean stepUntilX(XtPointer client_data)
{
    if (!stopPressed && stepUntil_loopX(app_data.refreshRate/100, stepval, stepexpr)) {
	displayICnt(app_data.refreshRate/100, &firstTime);
	return False;               /* call work procedure again */
    }
    cleanup_execLoop(tmpcnt != 1);
    XtUnmanageChild(stopsim);
    XtRemoveWorkProc(stopsimWP);
    return True;                        /* don't call work proc again */
}
예제 #7
0
파일: paperplane.c 프로젝트: yhsesq/yhs
void map_state_changed(Widget w, XtPointer data, XEvent * event, Boolean * cont)
{
    switch (event->type) {
    case MapNotify:
        if (moving && workId != 0) workId = XtAppAddWorkProc(app, animate, NULL);
        break;
    case UnmapNotify:
        if (moving) XtRemoveWorkProc(workId);
        break;
    }
}
예제 #8
0
파일: textfun.c 프로젝트: yhsesq/yhs
void 
map_state_changed(Widget w, XtPointer data, XEvent * event, Boolean * cont)
{
    switch (event->type) {
	case MapNotify:
	syncstate();
	break;
    case UnmapNotify:
	if (motion) {
	    XtRemoveWorkProc(workId);
	    workId = 0;
        }
	break;
    }
}
예제 #9
0
파일: ssX.c 프로젝트: q3k/ski
static Boolean stepItX(XtPointer client_data)
{
    if (!stopPressed && stepcnt > app_data.refreshRate) {
	if (stepIt_loop(app_data.refreshRate)) {
	    stepcnt -= app_data.refreshRate;
	    displayICnt(app_data.refreshRate, &firstTime);
	    return False;		/* call work procedure again */
	}
    } else if (!stopPressed && !stepIt_loop(stepcnt))
	return False;
    cleanup_execLoop(tmpcnt != 1);
    XtUnmanageChild(stopsim);
    XtRemoveWorkProc(stopsimWP);
    return True;                        /* don't call work proc again */
}
예제 #10
0
void 
RoamInterruptibleCmd::interrupt()
{
    _interrupted = TRUE;

    if (_wpId) {
	// Remove the work procedure

	XtRemoveWorkProc ( _wpId );
    }
    
    // Remove the working dialog and give derived 
    // classes a chance to clean up 
    
    unpost_dialog();
    cleanup();
    
    // Notify the application that the task was interrupted
    
    if ( _callback )
	( *_callback )( this, TRUE, _clientData);
}
예제 #11
0
파일: SelFile.c 프로젝트: ellert/graphviz
int
XsraSelFile (
    Widget toplevel, char *prompt, char *ok, char *cancel, char *failed,
    char *init_path, char *mode,
    int (*show_entry) (char *, char **, struct stat *),
    char *name_return, int name_size
) {
    static int firstTime = 1;
    Cardinal   i;
    Arg        arglist[20];
    XEvent     event;

    if (!prompt) {
        prompt = "Pathname:";
    }
    if (!ok) {
        ok = "OK";
    }
    if (!cancel) {
        cancel = "Cancel";
    }
    if (firstTime) {
        firstTime = 0;
        SFdisplay = XtDisplay (toplevel);
        SFcreateWidgets (toplevel, prompt, ok, cancel);
    } else {
        i = 0;
        XtSetArg (arglist[i], XtNlabel, prompt); i++;
        XtSetValues (selFilePrompt, arglist, i);

        i = 0;
        XtSetArg (arglist[i], XtNlabel, ok); i++;
        XtSetValues (selFileOK, arglist, i);

        i = 0;
        XtSetArg (arglist[i], XtNlabel, cancel); i++;
        XtSetValues (selFileCancel, arglist, i);
    }
    SFpositionWidget (selFile);
    XtMapWidget (selFile);

    if (!getcwd (SFstartDir, MAXPATHLEN)) {
        XtAppError (SFapp, "XsraSelFile: can't get current directory");
    }
    strcat (SFstartDir, "/");
    strcpy (SFcurrentDir, SFstartDir);

    if (init_path) {
        if (init_path[0] == '/') {
            strcpy (SFcurrentPath, init_path);
            if (strncmp (SFcurrentPath, SFstartDir, strlen (SFstartDir))) {
                SFsetText (SFcurrentPath);
            } else {
                SFsetText (& (SFcurrentPath[strlen (SFstartDir)]));
            }
        } else {
            strcat (strcpy (SFcurrentPath, SFstartDir), init_path);
            SFsetText (& (SFcurrentPath[strlen (SFstartDir)]));
        }
    } else {
        strcpy (SFcurrentPath, SFstartDir);
    }

    SFfunc = show_entry;

    SFtextChanged ();

    XtAddGrab (selFile, True, True);

    SFdirModTimerId = XtAppAddTimeOut (
        SFapp, (unsigned long) 1000, SFdirModTimer, (XtPointer) NULL
    );

    while (1) {
        XtAppNextEvent (SFapp, &event);
        XtDispatchEvent (&event);
        switch (SFstatus) {
        case SEL_FILE_TEXT:
            SFstatus = SEL_FILE_NULL;
            SFtextChanged ();
            break;
        case SEL_FILE_OK:
            strncpy (name_return, SFtextBuffer, name_size);
            SFprepareToReturn ();
            if (SFworkProcAdded) {
                XtRemoveWorkProc (SFworkProcId);
                SFworkProcAdded = 0;
            }
            return 1;
        case SEL_FILE_CANCEL:
            SFprepareToReturn ();
            return 0;
        case SEL_FILE_NULL:
            break;
        }
    }
    return 0;
}
예제 #12
0
VPERoot::~VPERoot()
{
    if (this->show_wpid) XtRemoveWorkProc(this->show_wpid);
    if (this->move_wpid) XtRemoveWorkProc(this->move_wpid);
}
예제 #13
0
파일: xmovie.c 프로젝트: JOravetz/SeisUnix
void inputCB (Widget w, 
	ClientData *cd,
	XtcwpAxesCallbackStruct *ca)
/*****************************************************************************
Input event callback - currently handles rubber zoom box and pause on
button 3 only.  Updates dimensions and start indices of bbytes, based
on user-dragged zoom box, and sets both bbytes and image to NULL, so
that expose callback will make new bbytes and image.
*****************************************************************************/
{
	int nxa=cd->nxa,nya=cd->nya,
		nxb=cd->nxb,nyb=cd->nyb,ixb=cd->ixb,iyb=cd->iyb;
	unsigned char *bbytes=cd->bbytes;
	float x1bega=cd->x1bega,x1enda=cd->x1enda,
		x2bega=cd->x2bega,x2enda=cd->x2enda;
	int x=ca->x,y=ca->y,width=ca->width,height=ca->height;
	float x1beg=ca->x1beg,x1end=ca->x1end,x2beg=ca->x2beg,x2end=ca->x2end;
	int style=ca->style;
	XEvent *event=ca->event;
	int xb,yb,wb,hb;
	int nxbn,nybn,ixbn,iybn;
	float x1begn,x1endn,x2begn,x2endn;
	static int stopflag=0;

	/* check for button 2 */
	if (event->type==ButtonRelease && event->xbutton.button==Button2) {
		cd->forward = !cd->forward;
		return;
	}

	/* check for button 3 */
	if (event->type==ButtonRelease && event->xbutton.button==Button3) {
		stopflag = !stopflag;
		if (stopflag) {
			XtRemoveWorkProc(cd->wpid);
		} else {
			cd->wpid = XtAppAddWorkProc(cd->ac,
					(XtWorkProc) readFrame,cd);
		}
		return;
	}

	/* track pointer and get rubber box */
	XtcwpRubberBox(XtDisplay(w),XtWindow(w),*event,&xb,&yb,&wb,&hb);

	/* if zoom box has tiny width or height */
	if (wb<3 || hb<3) {
	
		/* restore number of samples inside box */
		nxbn = nxa;
		nybn = nya;
		
		/* restore indices of first samples inside box */
		ixbn = 0;
		iybn = 0;
		
		/* restore axes limits */
		x1begn = x1bega;
		x1endn = x1enda;
		x2begn = x2bega;
		x2endn = x2enda;
	
	/* else if valid zoom box */
	} else {
	
		/* clip zoom box to lie within axes rectangle */
		if (xb<x) {
			wb -= x-xb;
			xb = x;
		}
		if (yb<y) {
			hb -= y-yb;
			yb = y;
		}
		if (xb+wb>x+width) wb = x-xb+width;
		if (yb+hb>y+height) hb = y-yb+height;
		
		/* determine number of samples inside box (at least 2 by 2) */
		nxbn = 1+NINT((float)wb/width*(nxb-1));
		if (nxbn<2) nxbn = 2;
		nybn = 1+NINT((float)hb/height*(nyb-1));
		if (nybn<2) nybn = 2;
		
		/* determine indices of first samples inside box */
		ixbn = ixb+NINT((float)(xb-x)/width*(nxb-1));
		if (ixbn+nxbn>ixb+nxb) ixbn = ixb+nxb-nxbn;
		iybn = iyb+NINT((float)(yb-y)/height*(nyb-1));
		if (iybn+nybn>iyb+nyb) iybn = iyb+nyb-nybn;
		
		/* determine axes limits */
		if (style==XtcwpNORMAL) {
			x1begn = x1beg+(ixbn-ixb)*(x1end-x1beg)/(nxb-1);
			x1endn = x1beg+(ixbn+nxbn-ixb-1)*(x1end-x1beg)/(nxb-1);
			x2begn = x2end+(iybn+nybn-iyb-1)*(x2beg-x2end)/(nyb-1);
			x2endn = x2end+(iybn-iyb)*(x2beg-x2end)/(nyb-1);
		} else {
			x1endn = x1beg+(iybn+nybn-iyb-1)*(x1end-x1beg)/(nyb-1);
			x1begn = x1beg+(iybn-iyb)*(x1end-x1beg)/(nyb-1);
			x2begn = x2beg+(ixbn-ixb)*(x2end-x2beg)/(nxb-1);
			x2endn = x2beg+(ixbn+nxbn-ixb-1)*(x2end-x2beg)/(nxb-1);
		}
	}
	
	/* set axes limits */
	XtcwpSetAxesValues(w,x1begn,x1endn,x2begn,x2endn);
	
	/* set client data */
	cd->nxb = nxbn;
	cd->nyb = nybn;
	cd->ixb = ixbn;
	cd->iyb = iybn;

	/* if bytes inside box exist, destroy and set pointer to NULL */
	if (bbytes!=NULL) free1(bbytes);
	cd->bbytes = NULL;
	
	/* if image exists, destroy and set pointer to NULL */
	if (cd->image!=NULL) {
		XDestroyImage(cd->image);
		cd->image = NULL;
	}
	
	/* clear window and force an expose event */
	XClearArea(XtDisplay(w),XtWindow(w),0,0,0,0,True);
}