示例#1
0
/**************************************************************************
 this is properly a bad way to append to a text widget. Using the 
 "useStringInPlace" resource and doubling mem alloc'ing would be better.  
**************************************************************************/
void append_output_window(char *astring)
{
  String theoutput;
  char *newout, *rmcr;
  
  XtVaGetValues(outputwindow_text, XtNstring, &theoutput, NULL);

  newout=malloc(strlen(astring)+strlen(theoutput)+2);
  strcpy(newout, theoutput);
  strcat(newout, "\n");
  strcat(newout, astring);

  /* calc carret position - last line, first pos */ 
  for(rmcr=newout+strlen(newout); rmcr>newout; rmcr--)
    if(*rmcr=='\n')
      break;

  /* shit happens when setting both values at the same time */
  XtVaSetValues(outputwindow_text, XtNstring, newout, NULL);
  XtVaSetValues(outputwindow_text, XtNinsertPosition, rmcr-newout+1, NULL);

  xaw_expose_now(outputwindow_text);
  
  free(newout);
}
示例#2
0
/**************************************************************************
...
**************************************************************************/
void xaw_set_label(Widget w, const char *text)
{
  String str;

  XtVaGetValues(w, XtNlabel, &str, NULL);
  if (strcmp(str, text) != 0) {
    XtVaSetValues(w, XtNlabel, (XtArgVal)text, NULL);
    xaw_expose_now(w);
  }
  
}
示例#3
0
/****************************************************************
...
*****************************************************************/
void city_dialog_update_present_units(struct city_dialog *pdialog, int unitid)
{
  int i;
  struct genlist_iterator myiter;
  struct unit *punit;

  if(unitid) {
    for(i=0; i<NO_UNITS_SHOWN; i++)
      if(pdialog->present_unit_ids[i]==unitid)
	break;
    if(i==NO_UNITS_SHOWN)
      unitid=0;
  }

  genlist_iterator_init(&myiter, 
	&map_get_tile(pdialog->pcity->x, pdialog->pcity->y)->units.list, 0);
  
  for(i=0; ITERATOR_PTR(myiter); ITERATOR_NEXT(myiter), i++) {
    punit=(struct unit*)ITERATOR_PTR(myiter);
    
    if(unitid && punit->id!=unitid)
      continue;
    
    
    put_unit_pixmap(punit, XawPixcommPixmap(pdialog->present_unit_pixcomms[i]),
		    0, 0);
    
    put_unit_pixmap_city_overlays(punit, 
			  XawPixcommPixmap(pdialog->present_unit_pixcomms[i]),
				  0,0);
    xaw_expose_now(pdialog->present_unit_pixcomms[i]);
    pdialog->present_unit_ids[i]=punit->id;
    
    XtRemoveAllCallbacks(pdialog->present_unit_pixcomms[i], XtNcallback);
    XtAddCallback(pdialog->present_unit_pixcomms[i], XtNcallback, 
		  present_units_callback, (XtPointer)punit->id);
    XtSetSensitive(pdialog->present_unit_pixcomms[i], TRUE);
  }
  
  for(; i<NO_UNITS_SHOWN; i++) {
    XawPixcommClear(pdialog->present_unit_pixcomms[i]);
    pdialog->present_unit_ids[i]=0;
    XtSetSensitive(pdialog->present_unit_pixcomms[i], FALSE);
  }
}
示例#4
0
/**************************************************************************
  Set one of the unit icons in information area based on punit.
  Use punit==NULL to clear icon.
  Index 'idx' is -1 for "active unit", or 0 to (num_units_below-1) for
  units below.  Also updates unit_ids[idx] for idx>=0.
**************************************************************************/
void set_unit_icon(int idx, struct unit *punit)
{
  Widget w;
  
  assert(idx>=-1 && idx<num_units_below);
  if (idx == -1) {
    w = unit_pix_canvas;
  } else {
    w = unit_below_canvas[idx];
    unit_ids[idx] = punit ? punit->id : 0;
  }
  
  XawPixcommClear(w);
  if (punit) {
    struct canvas store = {XawPixcommPixmap(w)};

    put_unit(punit, &store, 0, 0);
    xaw_expose_now(w);
  }
}
示例#5
0
/**************************************************************************
...
**************************************************************************/
void xaw_set_bitmap(Widget w, Pixmap pm)
{
  XtVaSetValues(w, XtNbitmap, (XtArgVal)pm, NULL);
  xaw_expose_now(w);
}