예제 #1
0
파일: ssX.c 프로젝트: q3k/ski
void runIt_setupX(void)
{
    firstTime = YES;
    stopsimWP = XtAppAddWorkProc(app_context, runItX, (XtPointer)NULL);
    stopPressed = NO;
    execcnt = 0;
}
예제 #2
0
void 
RoamInterruptibleCmd::execute()
{
    char *name_str;
    
    name_str = (char *) name();

    _done  = FALSE;  // Initialize flag

    // Let the derived class post the dialog.
    // Updates happen when derived classes call update() or 
    // updateMessage().

    post_dialog();
    
    // Call the Cmd execute function to handle the Undo, and other
    // general mechanisms supported by Cmd. 
    // execute() calls doit() of derived class.
    
    Cmd::execute();  

    // If the task was completed in a single call,
    // don't bother to set up a work procedure. Just
    // give derived classes a chance to cleanup and
    // call the application's callback function

    // If it was interrupted, the interruptCallback would have been
    // called already and the dialog would have been unposted...

    // We need to focus on only two cases here:  what if the task was
    // was completed in one call without interruptions (unpost dialog 
    // and call callback indicating task completed), and what if the 
    // task was not completed in one call (install a workProc...)
    // 

    // if it done but not interrupted, it was genuinely done.
    if (_done && !_interrupted)
      {
	  unpost_dialog();  // derived classes implement this
	  cleanup();
	  
	  if ( _callback )  // the FALSE is to say it was not interrupted.
	      ( *_callback )( this, FALSE, _clientData );
      }

    // If the task is not done and it was not interrupted and there is
    // a callback to install, install a work procedure to continue the 
    // task as soon as possible.  Call the callback via the work proc
    // after completion.
    // 
    
    else if ((!_done && !_interrupted && _callback)) 
      {
	  
	  _wpId = XtAppAddWorkProc ( theApplication->appContext(), 
				  &RoamInterruptibleCmd::workProcCallback,
 				  (XtPointer) this );
      }
}
예제 #3
0
파일: plot1d.c 프로젝트: rashadkm/xgobi
/* ARGSUSED */
static void
turn_on_plot1d_animation(xgobidata *xg, XtIntervalId id)
{
  xg->is_plot1d_cycle = True;
  (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);

  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}
예제 #4
0
/****************************************************************************
  Enqueue a callback to be called during an idle moment.  The 'callback'
  function should be called sometimes soon, and passed the 'data' pointer
  as its data.
****************************************************************************/
void add_idle_callback(void (callback)(void *), void *data)
{
  struct callback *cb = fc_malloc(sizeof(*cb));

  cb->callback = callback;
  cb->data = data;
  XtAppAddWorkProc(app_context, idle_callback_wrapper, cb);
}
예제 #5
0
파일: ssX.c 프로젝트: q3k/ski
void stepUntil_setupX(const char *expr)
{
    (void)strcpy(stepexpr, expr);
    firstTime = YES;
    stopsimWP = XtAppAddWorkProc(app_context, stepUntilX, (XtPointer)NULL);
    stopPressed = NO;
    execcnt = 0;
}
예제 #6
0
파일: ssX.c 프로젝트: q3k/ski
void stepIt_setupX(CTR cnt)
{
    stepcnt = tmpcnt = cnt;
    firstTime = YES;
    stopsimWP = XtAppAddWorkProc(app_context, stepItX, (XtPointer)NULL);
    stopPressed = NO;
    execcnt = 0;
}
예제 #7
0
파일: paperplane.c 프로젝트: yhsesq/yhs
void toggle(void)
{
    moving = !moving; /* toggle */
    if (moving)
        workId = XtAppAddWorkProc(app, animate, NULL);
    else
        XtRemoveWorkProc(workId);
}
예제 #8
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);
    }
}
예제 #9
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;
    }
}
예제 #10
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;
    }
}
예제 #11
0
파일: Path.c 프로젝트: ellert/graphviz
static int SFcheckDir (int n, SFDir *dir) {
    struct stat statBuf;
    int         i;

    if ((!stat (".", &statBuf)) && (statBuf.st_mtime != dir->mtime)) {
        /*  If the pointer is currently in the window that we are about
            to update, we must warp it to prevent the user from
            accidentally selecting the wrong file.
        */
        if (SFcurrentInvert[n] != -1) {
            XWarpPointer (
                SFdisplay, None, XtWindow (selFileLists[n]), 0, 0, 0, 0, 0, 0
            );
        }
        for (i = dir->nEntries - 1; i >= 0; i--) {
            if (dir->entries[i].shown != dir->entries[i].real) {
                XtFree (dir->entries[i].shown);
            }
            XtFree (dir->entries[i].real);
        }
        XtFree ((char *) dir->entries);
        if (SFgetDir (dir)) {
            SFunreadableDir (dir);
        }
        if (dir->vOrigin > dir->nEntries - SFlistSize) {
            dir->vOrigin = dir->nEntries - SFlistSize;
        }
        if (dir->vOrigin < 0) {
            dir->vOrigin = 0;
        }
        if (dir->hOrigin > dir->nChars - SFcharsPerEntry) {
            dir->hOrigin = dir->nChars - SFcharsPerEntry;
        }
        if (dir->hOrigin < 0) {
            dir->hOrigin = 0;
        }
        dir->beginSelection = -1;
        dir->endSelection = -1;
        SFdoNotTouchVorigin = 1;
        if ((dir + 1)->dir) {
            SFfindFile (dir, (dir + 1)->dir);
        } else {
            SFfindFile (dir, dir->path);
        }
        if (!SFworkProcAdded) {
            SFworkProcId = XtAppAddWorkProc (SFapp, SFworkProc, NULL);
            SFworkProcAdded = 1;
        }
        return 1;
    }
    return 0;
}
예제 #12
0
파일: SelFile.c 프로젝트: ellert/graphviz
void SFtextChanged (void) {
    if ((SFtextBuffer[0] == '/') || (SFtextBuffer[0] == '~')) {
        strcpy (SFcurrentPath, SFtextBuffer);
        SFtextPos = XawTextGetInsertionPoint (selFileField);
    } else {
        strcat (strcpy (SFcurrentPath, SFstartDir), SFtextBuffer);
        SFtextPos = XawTextGetInsertionPoint (
            selFileField
        ) + strlen (SFstartDir);
    }
    if (!SFworkProcAdded) {
        SFworkProcId = XtAppAddWorkProc (SFapp, SFworkProc, NULL);
        SFworkProcAdded = 1;
    }
    SFupdatePath ();
}
예제 #13
0
파일: plot1d.c 프로젝트: rashadkm/xgobi
/* ARGSUSED */
XtCallbackProc
plot1d_cycle_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
 * Turn on cycling.
*/
{
  if (!xg->is_plot1d_cycle && cycle_timeout_id == 0L) {
    xg->is_plot1d_cycle = True;
    (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
  }
  else {
    XtRemoveTimeOut(cycle_timeout_id);
    cycle_timeout_id = 0L;
    xg->is_plot1d_cycle = False;
  }

  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}
예제 #14
0
void XNavMotif::pop()
{
  Widget parent, top;

  parent = XtParent(parent_wid);
  while (parent) {
    top = parent;
    if (flow_IsShell(top))
      break;
    parent = XtParent(parent);
  }
  displayed = 0;
  flow_UnmapWidget(top);
  flow_MapWidget(top);

  // A fix to avoid a krash in setinputfocus
  XtAppAddWorkProc(XtWidgetToApplicationContext(top), (XtWorkProc)set_displayed,
      (XtPointer)this);
}
예제 #15
0
void move_points_on (xgobidata *xg)
{
/*
 *  If this mode is currently selected, turn it off.
*/
  if (xg->prev_plot_mode == MOVEPTS_MODE && xg->plot_mode != MOVEPTS_MODE)
  {
    xg->is_point_moving = False;
    XtRemoveEventHandler(xg->workspace,
      XtAllEvents, TRUE,
      (XtEventHandler) mp_button, (XtPointer) xg);
    map_move_points(xg, False);
    xg->nearest_point = -1;
    plot_once(xg);
  }
  /* Else -- if xyplotting -- turn it on */
  else if (xg->plot_mode == MOVEPTS_MODE &&
           xg->prev_plot_mode != MOVEPTS_MODE)
  {
    if (xg->is_xyplotting || xg->is_spinning ||
      (xg->is_touring && !xg->is_pp) ||
      (xg->is_corr_touring && !xg->is_corr_pursuit))
    {
      xg->is_point_moving = True;
      map_move_points(xg, True);
      XtAddEventHandler(xg->workspace,
        ButtonPressMask | ButtonReleaseMask, FALSE,
        (XtEventHandler) mp_button, (XtPointer) xg);
      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
      /* Should use a different cursor ... */

    } else {
      show_message("Moving points won\'t work in this mode; sorry\n", xg);

      /*
       * It may be necessary to disable point moving if xg->std_type != 0
      */
    }
  }
}
예제 #16
0
/* 
 * Initializes the /dev/midi listener in the Xt
 * event loop. Public method.
 */
void init_midi(XtAppContext a) {
	int i;
	
	app = a;

	
	for (i = 0; i < NUM_DEVICES; ++i) {
		if ((file = fopen(devices[i], "r")) == NULL) {
			perror(devices[i]);
			
			if (errno == ENOENT) {
				continue;
			} else {
				printf("Tried to open %i MIDI devices, but all failed. Please check that alsa-oss is installed.", NUM_DEVICES);
				exit(1);
			}
		} else {
			break;
		}
	}
	
	XtAppAddWorkProc(app, check_for_input, NULL);
}
예제 #17
0
파일: Main.c 프로젝트: juddy/edcde
/*++++++++++++++++++++++++++++++++++++++*/
int 
main(
        int argc,
        char **argv )
{
    int             n;
    Arg             args[MAX_ARGS];
    XEvent          event;
    XPropertyEvent *pEvent=(XPropertyEvent *)&event;
    long            mwmFunc;
    Boolean         useMaskRtn, useIconFileCacheRtn;    
    char           *dirs = NULL;
    char           *string;
	Visual         *visual;

#ifdef USERHELP
malloc_check(1);
malloc_trace(0);
#endif

    XtSetLanguageProc(NULL, NULL, NULL);
    _DtEnvControl(DT_ENV_SET); 
    

    /* Initialize the toolkit and open the display */
    style.shell = 
        XtInitialize(argv[0], XMCLASS, option_list, 1, (int *)&argc, argv);

#ifdef __osf__
    _XmColorObjCreate(style.shell, NULL, NULL);
#endif

    /* Allow all WS manipulation functions except resize and maximize */
    mwmFunc = MWM_FUNC_ALL ^ (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); 

    n = 0;
    XtSetArg(args[n], XmNmwmFunctions, mwmFunc); n++;
    XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
    XtSetValues(style.shell, args, n);

    /* initialize global style data */

    style.display    = XtDisplay(style.shell);
    style.screen     = DefaultScreenOfDisplay(style.display);
    style.screenNum  = DefaultScreen(style.display);
    style.colormap   = DefaultColormap(style.display, style.screenNum);
    style.root       = DefaultRootWindow(style.display);
    style.execName   = argv[0];
    style.errDialog  = NULL;
    style.tmpXmStr   = NULL;
    style.home = (char *) XtMalloc(strlen((char *) getenv("HOME")) + 1);
    strcpy(style.home, (char *) getenv("HOME"));
    style.colorDialog = NULL;
    style.backdropDialog = NULL;
    style.fontDialog = NULL;
    style.kbdDialog = NULL;
    style.mouseDialog = NULL;
    style.audioDialog = NULL;
    style.screenDialog = NULL;
    style.startupDialog = NULL;
    style.dtwmDialog = NULL;
    style.i18nDialog = NULL;
	visual = XDefaultVisual(style.display,style.screenNum);
	style.visualClass = visual->class;
    
    if (progName = DtStrrchr(argv[0], '/')) progName++;
    else progName = argv[0];

    /* Get the lock established to ensure only one dtstyle process
     * is running per screen .. first malloc enough space*/

    if (_DtGetLock (style.display, STYLE_LOCK) == 0)
    {
        _DtSimpleError (progName, DtError, NULL, "%s",
	     ((char *)GETMESSAGE(2, 5, "Style Manager is already running, second attempt aborted.")));
        exit(1);
    }

    InitDtstyleProtocol();
    SetWindowProperties();

    /* Register error handlers */
    XSetErrorHandler(ErrorHandler);
    XSetIOErrorHandler(IOErrorHandler);
    XtAppSetErrorHandler(XtWidgetToApplicationContext(style.shell),
                         ToolkitErrorHandler);
    XtAddEventHandler(style.shell, StructureNotifyMask, 0,
                         (XtEventHandler)MwmReparentNotify, NULL);

    /* set up resolution dependent layout variables */
    switch (_DtGetDisplayResolution(style.display, style.screenNum))
    {
        case LOW_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 3;
            break;
            
        case MED_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 5;
            break;
            
        case HIGH_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 8;
            break;
    }
    
    GetApplicationResources();
    
    XmeGetIconControlInfo(style.screen, &useMaskRtn,
			  &style.useMultiColorIcons, &useIconFileCacheRtn);
    
    
    /* add the directory $HOME/.dt/backdrops */
    
    string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops:") + 1);
    sprintf(string, "%s/.dt/backdrops:", style.home);

    dirs = (char *)XtCalloc(1, strlen("/etc/dt/backdrops:/usr/dt/backdrops") + 
			    (style.xrdb.backdropDir == NULL ? 2 :
			    strlen(style.xrdb.backdropDir)) + 
			    strlen(string) + 2);
  

    strcpy(dirs, string);
    if (style.xrdb.backdropDir) 
      {
	strcat(dirs, style.xrdb.backdropDir);
	strcat(dirs, ":"); 
      }
    strcat(dirs, "/etc/dt/backdrops:/usr/dt/backdrops");

    _DtWsmSetBackdropSearchPath(style.screen, dirs, style.useMultiColorIcons);

    if (string != NULL)
      XtFree((char *)string);
    
    if (dirs != NULL)
      XtFree((char *)dirs); 
    
    

    style.count = 0;
    /* if this is started from save session we need to set up the BMS
       first, otherwise do it after making the window. (for user perception
       for how long it takes for the dtstyle to come up) */
    if(style.xrdb.session != NULL) {
      DtInitialize (style.display, style.shell, progName, progName);
      /*Restore a session or build and display the main Window.*/
      if(!restoreSession(style.shell,style.xrdb.session))
	init_mainWindow(style.shell);
    }
    else {
      init_mainWindow(style.shell);
      DtInitialize (style.display, style.shell, progName, progName);
      InitializeAtoms();
      CheckMonitor(style.shell);
      GetDefaultPal(style.shell);
    }
    
    signal(SIGINT,(void (*)())activateCB_exitBtn); 
    signal(SIGTERM,(void (*)())activateCB_exitBtn); 

    /* to avoid defunct screen saver processes */    
    signal(SIGCHLD, (void (*)())WaitChildDeath);

    /* backdrop dialog  needs to know when the workspace changes to recolor 
       the bitmap displayed in the dialog */
    ListenForWorkspaceChange();

    /* if using COLOR builtin, style.workProcs is True */

    if ((XmeUseColorObj() != FALSE) && style.workProcs)

        XtAppAddWorkProc(XtWidgetToApplicationContext(style.shell), 
                        NewCreateD, style.shell);

    XtAppMainLoop(XtWidgetToApplicationContext(style.shell));

    return 0;
}
예제 #18
0
/*
 * ------------------------------------------------------------------------
 * Name: main
 *
 * Description:
 *
 *     main function for the DtPrint Dialog Manager.
 *
 * Return value:
 *
 *     This function never returns.
 *
 */
int main(int argc, char* argv[])
{
    PdmShell* pdm_shell;
    PdmMainWin* pdm_main_window;
    String* fallback_resources;
    int status;
    XEvent event;

    /*
     * Initialize environment so we can find message catalog.
     */
    _DtEnvControl(DT_ENV_SET);

    /*
     * ensure we can convert Xp attributes for this locale
     */
    if(!XSupportsLocale())
    {
	fprintf(stderr, "%s\n", PDM_MSG_ERR_X_LOCALE);
	exit(PDM_EXIT_ERROR);
    }
    /*
     * create the PDM objects for the app shell, the main window, and the
     * setup boxes
     */
    pdm_shell = PdmShellNew();
    pdm_main_window = PdmMainWinNew();
    PdmMainWinAddSetupBox(pdm_main_window, PdmPrinterBoxNew());
    PdmMainWinAddSetupBox(pdm_main_window, PdmJobBoxNew());
    /*
     * create the application shell widget
     */
    fallback_resources =
	PdmMainWinMergeFallbacks(pdm_main_window,
				 PdmShellFallbackResources,
				 XtNumber(PdmShellFallbackResources));
    status = PdmShellCreate(pdm_shell, fallback_resources, &argc, argv);
    if(0 != status)
    {
	PdmMainWinDelete(pdm_main_window);
	exit(status);
    }
    XtFree((char*)fallback_resources);
    /*
     * create the main PDM window widget hierarchy
     */
    PdmMainWinCreate(pdm_main_window,
		     pdm_shell->widget,
		     pdm_shell->print_display_spec,
		     pdm_shell->print_context_str);
    /*
     * display the PDM
     */
    PdmShellPresent(pdm_shell);
    /*
     * signal the PDM is up following startup event processing
     */
    XtAppAddWorkProc(pdm_shell->app_context,
		     PdmStartOkWorkProc, (XtPointer)NULL);
    /*
     * main loop
     */
    for(;;)
    {
	/*
	 * get the next event
	 */
	XtAppNextEvent(pdm_shell->app_context, &event);
	/*
	 * check to see if the parent video window has been destroyed
	 */
	if(event.xany.display == pdm_shell->display
	   &&
	   event.xany.window == pdm_shell->parent_window
	   &&
	   event.xany.type == DestroyNotify)
	{
	    PdmMainWinDelete(pdm_main_window);
	    exit(PDM_EXIT_CANCEL);
	}
	else
	    XtDispatchEvent(&event);
    }
    /*
     * not reached
     */
    return 0;
}
예제 #19
0
int
main(int argc, char **argv)
{
    struct { char x; void *y; } z;
    char b[256];
    char *f, *s, *t;
#if MP_GUI_SUPPORT
    XGCValues g;
#endif /* MP_GUI_SUPPORT */
    long n;
    int c, e, h, v;

#if MP_GUI_SUPPORT
    appwidget = XtVaAppInitialize(&appcontext, "MPTrace", options,
                                  XtNumber(options), &argc, argv, NULL, NULL);
    XtVaGetApplicationResources(appwidget, NULL, resources, XtNumber(resources),
                                NULL);
#endif /* MP_GUI_SUPPORT */
    s = t = NULL;
    e = h = v = 0;
    progname = __mp_basename(argv[0]);
    while ((c = __mp_getopt(argc, argv, __mp_shortopts(b, options_table),
             options_table)) != EOF)
        switch (c)
        {
          case OF_GUI:
#if MP_GUI_SUPPORT
            usegui = 1;
#endif /* MP_GUI_SUPPORT */
            break;
          case OF_HATFFILE:
            t = __mp_optarg;
            break;
          case OF_HELP:
            h = 1;
            break;
          case OF_SIMFILE:
            s = __mp_optarg;
            break;
          case OF_SOURCE:
            displaysource = 1;
            break;
          case OF_VERBOSE:
            verbose = 1;
            break;
          case OF_VERSION:
            v = 1;
            break;
          default:
            e = 1;
            break;
        }
    argc -= __mp_optindex;
    argv += __mp_optindex;
    if (v == 1)
    {
        fprintf(stdout, "%s %s\n%s %s\n\n", progname, PROGVERSION,
                __mp_copyright, __mp_author);
        fputs("This is free software, and you are welcome to redistribute it "
              "under certain\n", stdout);
        fputs("conditions; see the GNU Lesser General Public License for "
              "details.\n\n", stdout);
        fputs("For the latest mpatrol release and documentation,\n", stdout);
        fprintf(stdout, "visit %s.\n\n", __mp_homepage);
    }
    if (argc > 1)
        e = 1;
    if ((e == 1) || (h == 1))
    {
        fprintf(stdout, "Usage: %s [options] [file]\n\n", progname);
        if (h == 0)
            fprintf(stdout, "Type `%s --help' for a complete list of "
                    "options.\n", progname);
        else
            __mp_showopts(options_table);
        if (e == 1)
            exit(EXIT_FAILURE);
        exit(EXIT_SUCCESS);
    }
    if (argc == 1)
        f = argv[0];
    else
        f = MP_TRACEFILE;
    __mp_newtree(&alloctree);
    if (strcmp(f, "-") == 0)
        tracefile = stdin;
    else if ((tracefile = fopen(f, "rb")) == NULL)
    {
        fprintf(stderr, "%s: Cannot open file `%s'\n", progname, f);
        exit(EXIT_FAILURE);
    }
    currentevent = 0;
    bufferpos = buffer;
    bufferlen = 0;
    n = (char *) &z.y - &z.x;
    __mp_newslots(&table, sizeof(void *), __mp_poweroftwo(n));
    __mp_initslots(&table, tableslots, sizeof(tableslots));
    maxslots = 1;
    if (s != NULL)
    {
        if (strcmp(s, "stdout") == 0)
            simfile = stdout;
        else if (strcmp(s, "stderr") == 0)
            simfile = stderr;
        else if ((simfile = fopen(s, "w")) == NULL)
        {
            fprintf(stderr, "%s: Cannot open file `%s'\n", progname, s);
            exit(EXIT_FAILURE);
        }
        fprintf(simfile, "/* produced by %s %s from %s */\n\n\n", progname,
                PROGVERSION, f);
        fputs("#include <stdio.h>\n", simfile);
        fputs("#include <stdlib.h>\n\n\n", simfile);
        fputs("typedef struct event\n{\n", simfile);
        fputs("    unsigned long index;\n", simfile);
        fputs("    unsigned long size;\n", simfile);
        fputs("    char resize;\n", simfile);
        fputs("}\nevent;\n\n\n", simfile);
        fputs("static event events[] =\n{\n", simfile);
    }
    if (t != NULL)
    {
        if (strcmp(t, "stdout") == 0)
            hatffile = stdout;
        else if (strcmp(t, "stderr") == 0)
            hatffile = stderr;
        else if ((hatffile = fopen(t, "w")) == NULL)
        {
            fprintf(stderr, "%s: Cannot open file `%s'\n", progname, t);
            exit(EXIT_FAILURE);
        }
        fprintf(hatffile, "## Tracename: %s\n", t);
        fputs("## Author: Unknown\n", hatffile);
        fputs("## Date: Unknown\n", hatffile);
        fputs("## DTDURL: hatf.dtd\n", hatffile);
        fprintf(hatffile, "## Description: Converted to HATF by %s %s.\n\n",
                progname, PROGVERSION);
    }
    readfile();
#if MP_GUI_SUPPORT
    if (usegui)
    {
        appdisplay = XtDisplay(appwidget);
        appscreen = XtScreen(appwidget);
        addrscale = (((addrspace * 1048576) - 1) / (width * height)) + 1;
        /* Set up the main application window and scrollable drawing area.
         * Also set up a pixmap to backup the drawing area.
         */
        mainwidget = XtVaCreateManagedWidget("main",
                                             xmScrolledWindowWidgetClass,
                                             appwidget, XmNwidth, vwidth,
                                             XmNheight, vheight,
                                             XmNscrollingPolicy, XmAUTOMATIC,
                                             XmNscrollBarDisplayPolicy,
                                             XmAS_NEEDED, NULL);
        drawwidget = XtVaCreateManagedWidget("draw", xmDrawingAreaWidgetClass,
                                             mainwidget, XmNwidth, width,
                                             XmNheight, height, NULL);
        pixmap = XCreatePixmap(appdisplay, RootWindowOfScreen(appscreen), width,
                               height, DefaultDepthOfScreen(appscreen));
        /* Set up the graphics contexts that are used for drawing in different
         * colours.
         */
        g.foreground = uncol;
        ungc = XCreateGC(appdisplay, RootWindowOfScreen(appscreen),
                         GCForeground, &g);
        g.foreground = incol;
        ingc = XCreateGC(appdisplay, RootWindowOfScreen(appscreen),
                         GCForeground, &g);
        g.foreground = frcol;
        frgc = XCreateGC(appdisplay, RootWindowOfScreen(appscreen),
                         GCForeground, &g);
        g.foreground = alcol;
        algc = XCreateGC(appdisplay, RootWindowOfScreen(appscreen),
                         GCForeground, &g);
        /* Add a callback procedure to handle the refreshing of the drawing
         * area and also a work procedure to read events from the tracing
         * output file.  Then initialise the drawing area and enter the main X
         * application loop.
         */
        XtAddCallback(drawwidget, XmNexposeCallback,
                      (XtCallbackProc) redrawmemory, NULL);
        XtAppAddWorkProc(appcontext, (XtWorkProc) readevent, NULL);
        XtRealizeWidget(appwidget);
        XFillRectangle(appdisplay, XtWindow(drawwidget), ungc, 0, 0, width - 1,
                       height - 1);
        XFillRectangle(appdisplay, pixmap, ungc, 0, 0, width - 1, height - 1);
        XtAppMainLoop(appcontext);
    }
#endif /* MP_GUI_SUPPORT */
    return EXIT_SUCCESS;
}
예제 #20
0
파일: xmovie.c 프로젝트: JOravetz/SeisUnix
int
main (int argc, char **argv)
{
	int n1,n2,nz,iz,verbose,looping,nTic1,nTic2,width,height,interp;
	float d1,f1,d2,f2,*z,
		clip,bclip,wclip,white,wfrac,
		perc,bperc,wperc,*temp,
		bhue,whue,sat,bright,
		x1beg,x2beg,x1end,x2end,
		x1min,x1max,x2min,x2max,
		fframe,dframe;
	char *label1="",*label2="",*format="",*windowtitle="",
		*labelFont="",*titleFont="",
		*axesColor="",*gridColor="",*titleColor="",
		*style="normal",*grid1="none",*grid2="none",
		*cmap;
	ClientData cd;
	XrmValue from,to;
	Widget toplevel,axes;
	XtAppContext ac;
	Display *dpy;
	Window win;
	Arg args[98];
	int nargs;
	int scr;
	unsigned int depth;

	/* initialize getpar */
	initargs(argc,argv);
	requestdoc(1);

	/* get parameters describing colormaps */
	cmap = "gray";  getparstring("cmap",&cmap);
	if (STREQ("saturation",cmap)) cmap = "sat";
	bhue = 0;  getparfloat("bhue",&bhue);  bhue /= 360.0;
	whue = 240;  getparfloat("whue",&whue); whue /= 360.0;
	sat = 1.0; getparfloat("sat",&sat);
	if (sat<0.0 || sat>1.0) err("sat must be in range [0,1]!\n");
	bright = 1.0; getparfloat("bright",&bright);
	if (bright<0.0 || bright>1.0) err("bright must be in range [0,1]!\n");

	/* get parameters describing 1st dimension sampling */
	if (!getparint("n1",&n1))
		err("Must specify number of samples in 1st dimension!\n");
	if (!getparfloat("d1",&d1)) d1 = 1.0;
	if (!getparfloat("f1",&f1)) f1 = 0.0;
	x1min = (d1>0.0)?f1:f1+(n1-1)*d1;
	x1max = (d1<0.0)?f1:f1+(n1-1)*d1;
	if (!getparfloat("x1beg",&x1beg)) x1beg = x1min;
	if (!getparfloat("x1end",&x1end)) x1end = x1max;

	/* get parameters describing 2nd dimension sampling */
	if (!getparint("n2",&n2))
		err("Must specify number of samples in 2nd dimension!\n");
	if (!getparfloat("d2",&d2)) d2 = 1.0;
	if (!getparfloat("f2",&f2)) f2 = 0.0;
	x2min = (d2>0.0)?f2:f2+(n2-1)*d2;
	x2max = (d2<0.0)?f2:f2+(n2-1)*d2;
	if (!getparfloat("x2beg",&x2beg)) x2beg = x2min;
	if (!getparfloat("x2end",&x2end)) x2end = x2max;

	/* read first frame of float data */
	nz = n1*n2;
	z = ealloc1float(nz);
	if (fread(z,sizeof(float),nz,stdin)!=nz)
		err("error reading input file");

	/* if necessary, determine clips from percentiles */
	if (getparfloat("clip",&clip)) {
		bclip = clip;
		wclip = -clip;
	}
	if ((!getparfloat("bclip",&bclip) || !getparfloat("wclip",&wclip)) &&
		!getparfloat("clip",&clip)) {
		perc = 100.0;  getparfloat("perc",&perc);
		temp = ealloc1float(nz);
		for (iz=0; iz<nz; iz++)
			temp[iz] = z[iz];
		if (!getparfloat("bclip",&bclip)) {
			bperc = perc;	getparfloat("bperc",&bperc);
			iz = (nz*bperc/100.0);
			if (iz<0) iz = 0;
			if (iz>nz-1) iz = nz-1;
			qkfind(iz,nz,temp);
			bclip = temp[iz];
		}
		if (!getparfloat("wclip",&wclip)) {
			wperc = 100.0-perc;  getparfloat("wperc",&wperc);
			iz = (nz*wperc/100.0);
			if (iz<0) iz = 0;
			if (iz>nz-1) iz = nz-1;
			qkfind(iz,nz,temp);
			wclip = temp[iz];
		}
		free1float(temp);
	}
	if (!getparfloat("white",&white)) white = (bclip+wclip)/2.0;
	if (!getparint("verbose",&verbose)) verbose = 1;
	if (!getparint("sleep",&cd.sleep)) cd.sleep=0 ;
	if (!getparint("loop",&looping)) looping = 0;
	if (verbose) {
		if(STREQ(cmap,"sat") || STREQ(cmap,"customsat")) {
			warn("bclip=%g wclip=%g white=%g",bclip,wclip,white);
		} else {
			warn("bclip=%g wclip=%g",bclip,wclip);
		}
	}
	wfrac = (bclip!=wclip) ? (bclip-white)/(bclip-wclip) : 1.0;

	/* initialize toolkit and set toplevel parameters */
 	toplevel = XtAppInitialize(&ac,"XMovie_XAPP_DEF",NULL,0,&argc,argv,NULL,NULL,0);
	dpy = XtDisplay(toplevel);
	nargs = 0;
	if (getparstring("windowtitle",&windowtitle))
		{XtSetArg(args[nargs],XtNtitle,windowtitle); nargs++;}
	if (getparstring("windowtitle",&windowtitle))
		{XtSetArg(args[nargs],XtNiconName,windowtitle); nargs++;}
	if (getparint("width",&width))
		{XtSetArg(args[nargs],XtNwidth,width); nargs++;}
	if (getparint("height",&height))
		{XtSetArg(args[nargs],XtNheight,height); nargs++;}
	XtSetArg(args[nargs],XtNinput,TRUE);nargs++; 
	XtSetValues(toplevel,args,nargs);

	/* if necessary, make private colormap */
	win = XRootWindowOfScreen(XtScreen(toplevel));
	nargs = 0;

	scr=DefaultScreen(dpy);
	depth=(unsigned int)DefaultDepth(dpy,scr);

	if (depth<=8) {
	  if (STREQ(cmap,"gray")) {
	    Colormap cm=XtcwpCreateGrayColormap(dpy,win);
	    XtSetArg(args[nargs],XtNcolormap,cm); nargs++;
	  } else if (STREQ(cmap,"hue")) {
	    Colormap cm=XtcwpCreateHueColormap(dpy,win,
					       bhue,whue,sat,bright);
	    XtSetArg(args[nargs],XtNcolormap,cm); nargs++;
	  } else if (STREQ(cmap,"sat")) {
	    Colormap cm=XtcwpCreateSatColormap(dpy,win,
					       bhue,whue,wfrac,bright);

	    XtSetArg(args[nargs],XtNcolormap,cm); nargs++;
	  }
	  XtSetValues(toplevel,args,nargs);
	}

	/* create axes and set axes parameters */
	axes = XtCreateManagedWidget("axes",xtcwpAxesWidgetClass, 
		toplevel,NULL,0);
		
	nargs = 0;

	if (getparstring("grid1",&grid1)) {
		from.addr = (char *)grid1;
		XtConvertAndStore(axes,XtRString,&from,XtcwpRAxesGrid,&to);
		if (to.addr) XtSetArg(args[nargs],XtNgrid1,*((int*)to.addr));
		nargs++;
	}
	if (getparstring("grid2",&grid2)) {
		from.addr = (char *)grid2;
		XtConvertAndStore(axes,XtRString,&from,XtcwpRAxesGrid,&to);
		if (to.addr) XtSetArg(args[nargs],XtNgrid2,*((int*)to.addr));
		nargs++;
	}

	if (getparint("nTic1",&nTic1))
		{XtSetArg(args[nargs],XtNnTic1,nTic1); nargs++;}
	if (getparint("nTic2",&nTic2))
		{XtSetArg(args[nargs],XtNnTic2,nTic2); nargs++;}
	if (getparstring("label1",&label1))
		{XtSetArg(args[nargs],XtNlabel1,label1); nargs++;}
	if (getparstring("label2",&label2))
		{XtSetArg(args[nargs],XtNlabel2,label2); nargs++;}
	if (getparstring("title",&format))
		{XtSetArg(args[nargs],XtNtitle,format); nargs++;}
	if (getparstring("style",&style)) {
		from.size = (unsigned int) strlen(style);  from.addr = (char *)style;
		XtConvertAndStore(axes,XtRString,&from,XtcwpRAxesStyle,&to);
		if (to.addr) XtSetArg(args[nargs],XtNstyle,*((int*)to.addr));
		nargs++;
	}
	if (getparstring("axesColor",&axesColor)) {
		from.addr = (char *)axesColor;
		XtConvertAndStore(axes,XtRString,&from,XtRPixel,&to);
		if (to.addr) XtSetArg(args[nargs],XtNaxesColor,
			*((unsigned long*)to.addr));
		nargs++;
	}
	if (getparstring("gridColor",&gridColor)) {
		from.addr = (char *)gridColor;
		XtConvertAndStore(axes,XtRString,&from,XtRPixel,&to);
		if (to.addr) XtSetArg(args[nargs],XtNgridColor,
			*((unsigned long*)to.addr));
		nargs++;
	}
	if (getparstring("titleColor",&titleColor)) {
		from.addr = (char *)titleColor;
		XtConvertAndStore(axes,XtRString,&from,XtRPixel,&to);
		if (to.addr) XtSetArg(args[nargs],XtNtitleColor,
			*((unsigned long*)to.addr));
		nargs++;
	}
	if (getparstring("labelFont",&labelFont)) {
		from.addr = (char *)labelFont;
		XtConvertAndStore(axes,XtRString,&from,XtRFont,&to);
		if (to.addr) XtSetArg(args[nargs],XtNlabelFont,
			*((Font*)to.addr));
		nargs++;
	}
	if (getparstring("titleFont",&titleFont)) {
		from.addr = (char *)titleFont;
		XtConvertAndStore(axes,XtRString,&from,XtRFont,&to);
		if (to.addr) XtSetArg(args[nargs],XtNtitleFont,
			*((Font*)to.addr));
		nargs++;
	}
	XtSetValues(axes,args,nargs);
	x1beg = x1min; getparfloat("x1beg",&x1beg);
	x1end = x1max; getparfloat("x1end",&x1end);
	x2beg = x2min; getparfloat("x2beg",&x2beg);
	x2end = x2max; getparfloat("x2end",&x2end);
	adjustAxesValues(n1,d1,f1,n2,d2,f2,&x1beg,&x1end,&x2beg,&x2end);
	XtcwpSetAxesValues(axes,x1beg,x1end,x2beg,x2end);

	/* frame sampling */
	if (!getparfloat("fframe",&fframe)) fframe = 1.0;
	if (!getparfloat("dframe",&dframe)) dframe = 1.0;

	/* interpolation */
	if (!getparint("interp",&interp)) interp = 1;

	/* initial display mode: cont or step */
	if (!getparint("idm", &displayMode)) displayMode = DM_CONT;

	checkpars();

	/* initialize client data */
	cd.n1 = n1;  cd.d1 = d1;  cd.f1 = f1;
	cd.n2 = n2;  cd.d2 = d2;  cd.f2 = f2;
	cd.floats = z;
	cd.fmin = bclip;
	cd.fmax = wclip;
	cd.bmin = (unsigned char) (XtcwpGetFirstPixel(dpy));
	cd.bmax = (unsigned char) (XtcwpGetLastPixel(dpy));
	if(cd.bmax==0)cd.bmax=255;
	warn("bmin=%d bmax=%d",cd.bmin,cd.bmax);
	cd.x1bega = x1beg;
	cd.x1enda = x1end;
	cd.x2bega = x2beg;
	cd.x2enda = x2end;
	cd.abytes = NULL;
	cd.bbytes = NULL;
	cd.image = NULL;
	cd.exposed = 0;
	cd.noframes = 1;
	cd.axes = axes;
	cd.looping = looping;
	cd.frame = NULL;
	cd.format = format;
	cd.iframe = 0;
	cd.fframe = fframe;
	cd.dframe = dframe;
	cd.interp = interp;
	cd.forward = 1;
	cd.ac = ac;

	/* adjust axes title if formatted */
	if (strchr(cd.format,'%') && !strstr(cd.format,"%%")) {
		sprintf(cd.title,cd.format,cd.fframe+cd.iframe*cd.dframe);
		XtVaSetValues(cd.axes,XtNtitle,cd.title,NULL);
	}

	/* add work procedure */
	cd.wpid = XtAppAddWorkProc(ac,(XtWorkProc) readFrame,&cd);

	/* add callbacks to axes widget */
	XtAddCallback(axes,XtNresizeCallback,(XtCallbackProc) resizeCB,&cd);
	XtAddCallback(axes,XtNexposeCallback,(XtCallbackProc) exposeCB,&cd);
	XtAddCallback(axes,XtNinputCallback,(XtCallbackProc) inputCB,&cd);

	/* add Button2 translation for reversing the movie */
	XtOverrideTranslations(axes,
		XtParseTranslationTable("<Btn2Up>: input()"));

	/* add Button3 translation for pausing the movie */
	XtOverrideTranslations(axes,
		XtParseTranslationTable("<Btn3Up>: input()"));

	/* set up keypress */
	XtAddEventHandler(axes, KeyPress, FALSE,
			  (XtEventHandler) key_pressed, &cd);

	/* realize everything */
	XtRealizeWidget(toplevel);

	/* go */
	XtAppMainLoop(ac);

	return EXIT_SUCCESS;
}
예제 #21
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);
}
예제 #22
0
/**************************************************************************
  Entry point for GUI specific portion. Called from client_main()
**************************************************************************/
void ui_main(int argc, char *argv[])
{
  int i;
  struct sprite *icon; 

  parse_options(argc, argv);

  /* include later - pain to see the warning at every run */
  XtSetLanguageProc(NULL, NULL, NULL);
  
  toplevel = XtVaAppInitialize(
	       &app_context,               /* Application context */
	       "Freeciv",                  /* application class name */
#ifdef UNUSED
	       cmd_options, XtNumber(cmd_options),
#else
	       NULL, 0,
#endif
	                                   /* command line option list */
	       &argc, argv,                /* command line args */
	       &fallback_resources[1],     /* for missing app-defaults file */
	       XtNallowShellResize, True,
	       NULL);              

  XtGetApplicationResources(toplevel, &appResources, resources,
                            XtNumber(resources), NULL, 0);

/*  XSynchronize(display, 1); 
  XSetErrorHandler(myerr);*/

  if(appResources.version==NULL)  {
    freelog(LOG_FATAL, _("No version number in resources."));
    freelog(LOG_FATAL, _("You probably have an old (circa V1.0)"
			 " Freeciv resource file somewhere."));
    exit(EXIT_FAILURE);
  }

  /* TODO: Use capabilities here instead of version numbers */
  if (0 != strncmp(appResources.version, VERSION_STRING,
		   strlen(appResources.version))) {
    freelog(LOG_FATAL, _("Game version does not match Resource version."));
    freelog(LOG_FATAL, _("Game version: %s - Resource version: %s"), 
	    VERSION_STRING, appResources.version);
    freelog(LOG_FATAL, _("You might have an old Freeciv resourcefile"
			 " in /usr/lib/X11/app-defaults"));
    exit(EXIT_FAILURE);
  }
  
  if(!appResources.gotAppDefFile) {
    freelog(LOG_NORMAL, _("Using fallback resources - which is OK"));
  }

  display = XtDisplay(toplevel);
  screen_number=XScreenNumberOfScreen(XtScreen(toplevel));
  display_depth=DefaultDepth(display, screen_number);
  root_window=DefaultRootWindow(display);

  display_color_type=get_visual(); 
  
  if(display_color_type!=COLOR_DISPLAY) {
    freelog(LOG_FATAL, _("Only color displays are supported for now..."));
    /*    exit(EXIT_FAILURE); */
  }

  {
    XGCValues values;
    char **missing_charset_list_return;
    int missing_charset_count_return;
    char *def_string_return;
    char *city_names_font, *city_productions_font_name;

    values.graphics_exposures = False;
    civ_gc = XCreateGC(display, root_window, GCGraphicsExposures, &values);

    city_names_font = mystrdup("-*-*-*-*-*-*-14-*");

    city_productions_font_name = mystrdup("-*-*-*-*-*-*-14-*");

    main_font_set = XCreateFontSet(display, city_names_font,
	&missing_charset_list_return,
	&missing_charset_count_return,
	&def_string_return);
    if (!main_font_set) {
      freelog(LOG_FATAL, _("Unable to open fontset: %s"),
	      city_names_font);
      freelog(LOG_FATAL,
	      _("Doing 'xset fp rehash' may temporarily solve a problem."));
      exit(EXIT_FAILURE);
    }
    for (i = 0; i < missing_charset_count_return; i++) {
      freelog(LOG_ERROR, _("Font for charset %s is lacking"),
	      missing_charset_list_return[i]);
    }
    values.foreground = get_color(tileset, COLOR_MAPVIEW_CITYTEXT)->color.pixel;
    values.background = get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel;
    font_gc= XCreateGC(display, root_window, 
		       GCForeground|GCBackground|GCGraphicsExposures, 
		       &values);

    prod_font_set = XCreateFontSet(display, city_productions_font_name,
	&missing_charset_list_return,
	&missing_charset_count_return,
	&def_string_return);
    if (!prod_font_set) {
      freelog(LOG_FATAL, _("Unable to open fontset: %s"),
	      city_productions_font_name);
      freelog(LOG_FATAL,
	      _("Doing 'xset fp rehash' may temporarily solve a problem."));
      exit(EXIT_FAILURE);
    }
    for (i = 0; i < missing_charset_count_return; i++) {
      freelog(LOG_ERROR, _("Font for charset %s is lacking"),
	      missing_charset_list_return[i]);
    }
    values.foreground = get_color(tileset, COLOR_MAPVIEW_CITYTEXT)->color.pixel;
    values.background = get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel;
    prod_font_gc= XCreateGC(display, root_window,
			    GCForeground|GCBackground|GCGraphicsExposures,
			    &values);

    values.line_width = BORDER_WIDTH;
    values.line_style = LineOnOffDash;
    values.cap_style = CapNotLast;
    values.join_style = JoinMiter;
    values.fill_style = FillSolid;
    border_line_gc = XCreateGC(display, root_window,
			       GCGraphicsExposures|GCLineWidth|GCLineStyle
			       |GCCapStyle|GCJoinStyle|GCFillStyle, &values);

    values.foreground = 0;
    values.background = 0;
    fill_bg_gc= XCreateGC(display, root_window, 
			  GCForeground|GCBackground|GCGraphicsExposures,
			  &values);

    values.fill_style=FillStippled;
    fill_tile_gc= XCreateGC(display, root_window, 
    			    GCForeground|GCBackground|GCFillStyle|GCGraphicsExposures,
			    &values);
  }

  {
    char d1[]={0x03,0x0c,0x03,0x0c};
    char d2[]={0x08,0x02,0x08,0x02};
    gray50 = XCreateBitmapFromData(display, root_window, d1, 4, 4);
    gray25 = XCreateBitmapFromData(display, root_window, d2, 4, 4);
  }
  
  /* 135 below is rough value (could be more intelligent) --dwp */
  num_units_below = 135 / tileset_full_tile_width(tileset);
  num_units_below = MIN(num_units_below,MAX_NUM_UNITS_BELOW);
  num_units_below = MAX(num_units_below,1);
  
  /* do setup_widgets before loading the rest of graphics to ensure that
     setup_widgets() has enough colors available:  (on 256-colour systems)
  */
  setup_widgets();
  tileset_init(tileset);
  tileset_load_tiles(tileset);
  load_intro_gfx();
  load_cursors();

  /* FIXME: what about the mask? */
  icon = get_icon_sprite(tileset, ICON_FREECIV);
  XtVaSetValues(toplevel, XtNiconPixmap, icon->pixmap, NULL);

  XtSetKeyboardFocus(bottom_form, inputline_text);
  XtSetKeyboardFocus(below_menu_form, map_canvas);

  InitializeActions(app_context);

  /* Do this outside setup_widgets() so after tiles are loaded */
  fill_econ_label_pixmaps();
		
  XtAddCallback(map_horizontal_scrollbar, XtNjumpProc, 
		scrollbar_jump_callback, NULL);
  XtAddCallback(map_vertical_scrollbar, XtNjumpProc, 
		scrollbar_jump_callback, NULL);
  XtAddCallback(map_horizontal_scrollbar, XtNscrollProc, 
		scrollbar_scroll_callback, NULL);
  XtAddCallback(map_vertical_scrollbar, XtNscrollProc, 
		scrollbar_scroll_callback, NULL);
  XtAddCallback(turn_done_button, XtNcallback, end_turn_callback, NULL);

  XtAppAddWorkProc(app_context, toplevel_work_proc, NULL);

  XtRealizeWidget(toplevel);

  x_interval_id = XtAppAddTimeOut(app_context, TIMER_INTERVAL,
				  timer_callback, NULL);

  init_mapcanvas_and_overview();

  fill_unit_below_pixmaps();

  set_indicator_icons(client_research_sprite(),
		      client_warming_sprite(),
		      client_cooling_sprite(),
		      client_government_sprite());

  wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", 0);
  XSetWMProtocols(display, XtWindow(toplevel), &wm_delete_window, 1);
  XtOverrideTranslations(toplevel,
    XtParseTranslationTable ("<Message>WM_PROTOCOLS: msg-quit-freeciv()"));

  XtSetSensitive(toplevel, FALSE);

  XtAppMainLoop(app_context);
}
예제 #23
0
파일: plot1d.c 프로젝트: rashadkm/xgobi
void
plot1d_on(xgobidata *xg)
/*
 * Turn on and off the plot1d mode.
*/
{
  int j;
  Boolean cycle_on;
  extern xgobidata xgobi;
  int jvar = (plot1d_vertically) ? xg->plot1d_vars.y : xg->plot1d_vars.x;

/*
 *  If this mode is currently selected, turn it off.
*/
  if (xg->prev_plot_mode == PLOT1D_MODE && xg->plot_mode != PLOT1D_MODE) {
    map_plot1d(False);

    xg->is_plot1d_cycle = False;
    if (cycle_timeout_id)
    {
      XtRemoveTimeOut(cycle_timeout_id);
      cycle_timeout_id = 0L;
    }
  }
  /* Else turn it on */
  else if (xg->plot_mode == PLOT1D_MODE &&
           xg->prev_plot_mode != PLOT1D_MODE)
  {
    map_plot1d(True);

    if (!xg->is_plotting1d) {
      if (xg->is_touring && xg->is_princ_comp) {
	set_sph_labs(xg, xg->nsph_vars);
        xg->is_touring = False;
/*        reset_var_labels(xg, PRINCCOMP_OFF);i think not needed anymore
                                             sphering transformation*/
      }

      if (xg->carry_vars)
        carry_plot1d_vars(xg);

      xg->is_xyplotting = xg->is_spinning = xg->is_touring = False;
      xg->is_plotting1d = True;
      xg->is_corr_touring = False;

      plot1d_data = (float *) XtMalloc( (Cardinal)
        xg->nrows_in_plot * sizeof(float));

      plot1d_texture_var(xg);

      update_lims(xg);
      update_world(xg);
      world_to_plane(xg);
      plane_to_screen(xg);

      init_ticks(&xg->plot1d_vars, xg);

      plot_once(xg);
      /*
       * Reinitialize the sin and cos variables.  Why???
      */
      init_trig(xg);

      for (j=0; j<xg->ncols; j++) {
        if (j == jvar)
          xg->varchosen[j] = True;
        else
          xg->varchosen[j] = False;
      }

      set_varsel_label(xg);
      refresh_vboxes(xg);
    }
    /*
     * If the cycle button is activated, start cycling.
    */
    XtVaGetValues(plot1d_cycle_cmd, XtNstate, &cycle_on, NULL);

    if (cycle_on) {
      xg->is_plot1d_cycle = True;
      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
    }
  }

  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}