Ejemplo n.º 1
0
/****************************************************************
...
*****************************************************************/
void city_dialog_update_title(struct city_dialog *pdialog)
{
  char buf[512];
  String now;
  
  sprintf(buf, "%s - %s citizens",
	  pdialog->pcity->name, int_to_text(city_population(pdialog->pcity)));

  XtVaGetValues(pdialog->cityname_label, XtNlabel, &now, NULL);
  if(strcmp(now, buf)) {
    XtVaSetValues(pdialog->cityname_label, XtNlabel, (XtArgVal)buf, NULL);
    xaw_horiz_center(pdialog->cityname_label);
  }
}
Ejemplo n.º 2
0
/****************************************************************
...
*****************************************************************/
void create_option_dialog(void)
{
  Widget option_form, option_label, option_bg_label, option_bell_label;
  Widget option_ok_command;
  
  option_dialog_shell = XtCreatePopupShell("optionpopup", 
					  transientShellWidgetClass,
					  toplevel, NULL, 0);

  option_form = XtVaCreateManagedWidget("optionform", 
				        formWidgetClass, 
				        option_dialog_shell, NULL);   

  option_label = XtVaCreateManagedWidget("optionlabel", 
					 labelWidgetClass, 
					 option_form, NULL);   
  
  option_bg_label = XtVaCreateManagedWidget("optionbglabel", 
					    labelWidgetClass, 
					    option_form, NULL);
  
  option_bg_toggle = XtVaCreateManagedWidget("optionbgtoggle", 
					     toggleWidgetClass, 
					     option_form,
					     NULL);

  option_bell_label = XtVaCreateManagedWidget("optionbelllabel", 
					      labelWidgetClass, 
					      option_form, NULL);

  
  option_bell_toggle = XtVaCreateManagedWidget("optionbelltoggle", 
					       toggleWidgetClass, 
					       option_form,
					       NULL);
    
  
  option_ok_command = XtVaCreateManagedWidget("optionokcommand", 
					      commandWidgetClass,
					      option_form,
					      NULL);
  
  XtAddCallback(option_ok_command, XtNcallback, 
		option_ok_command_callback, NULL);

  XtRealizeWidget(option_dialog_shell);

  xaw_horiz_center(option_label);
}
Ejemplo n.º 3
0
/**************************************************************************
...
**************************************************************************/
Widget create_messageopt_dialog(void)
{
  Widget shell, form, title, scrolled, explanation, ok, cancel, col;
  Widget colhead, space_head;
  Widget label[E_LAST];
  Widget longest_label = 0;
  Widget toggle = 0;
  int i, longest_len = 0;
  Dimension width;
  
  shell = I_T(XtCreatePopupShell("messageoptpopup", transientShellWidgetClass,
				 toplevel, NULL, 0));

  form = XtVaCreateManagedWidget("messageoptform", formWidgetClass, 
				 shell, NULL);   

  title = I_L(XtVaCreateManagedWidget("messageopttitle", labelWidgetClass,
				      form, NULL));

  explanation = I_L(XtVaCreateManagedWidget("messageoptexpl", labelWidgetClass,
					    form, NULL));

  scrolled = XtVaCreateManagedWidget("messageoptscroll", viewportWidgetClass, 
                                     form, NULL);

  col = XtVaCreateManagedWidget("messageoptcol", formWidgetClass, 
                                scrolled, NULL);

  /* space_head labels are "empty" labels in column heading which are
   * used so that we can arrange the constraints without loops.
   * They essentially act as vertical filler.
   */
  space_head = XtVaCreateManagedWidget("messageoptspacehead", labelWidgetClass,
                                       col, NULL);
  
  colhead = I_L(XtVaCreateManagedWidget("messageoptcolhead", labelWidgetClass,
                                        col, NULL));

  for(i = 0; i < E_LAST; i++)  {
    const char *text = get_event_message_text(sorted_events[i]);
    int len = strlen(text);

    label[i] = XtVaCreateManagedWidget("label", labelWidgetClass, col,
				       XtNlabel, text, XtNfromVert,
				       (i == 0) ? space_head : label[i - 1],
				       NULL);

    if (len > longest_len) {
      longest_len = len;
      longest_label = label[i];
    }

    /* 
     * The addition of a scrollbar screws things up. There must be a
     * better way to do this.
     */
    XtVaGetValues(label[i], XtNwidth, &width, NULL);
    XtVaSetValues(label[i], XtNwidth, width + 15, NULL);
  }

  XtVaGetValues(longest_label, XtNwidth, &width, NULL);
  XtVaSetValues(space_head, XtNwidth, width + 15, NULL);
  XtVaSetValues(colhead, XtNfromHoriz, space_head, NULL);

  for (i = 0; i < E_LAST; i++) {
    int j;

    for (j = 0; j < NUM_MW; j++) {
      toggle = XtVaCreateManagedWidget("toggle", toggleWidgetClass, col,
				       XtNfromHoriz,
				       (j == 0 ? space_head : toggle),
				       XtNfromVert,
				       (i == 0) ? space_head : label[i - 1],
				       NULL);
      XtAddCallback(toggle, XtNcallback, toggle_callback, NULL);
      messageopt_toggles[sorted_events[i]][j] = toggle;
    }
  }

  ok = I_L(XtVaCreateManagedWidget("messageoptokcommand",
				   commandWidgetClass,
				   form, NULL));
  
  cancel = I_L(XtVaCreateManagedWidget("messageoptcancelcommand",
				       commandWidgetClass,
				       form, NULL));
	       
  XtAddCallback(ok, XtNcallback, messageopt_ok_command_callback, 
                (XtPointer)shell);
  XtAddCallback(cancel, XtNcallback, messageopt_cancel_command_callback, 
                (XtPointer)shell);
  
  XtRealizeWidget(shell);

  xaw_horiz_center(title);
  xaw_horiz_center(explanation);

  return shell;
}