Freeciv
Advertisement
This is a historic page, please remove the {{historic}} tag if you plan to revive it.

This page is about Xaw client[]


First, small part of doc/HACKING: (written so long ago, I think)

=========================================================================
Client GUI - Athena
=========================================================================
One client GUI is written using athena-widgets. A few comments on this could prove useful for anyone wishing to write new dialogs or improve on the current ones.

Widgets:


When you create new widgets for a dialog, like:

  players_form = XtVaCreateManagedWidget("playersform", 
				       formWidgetClass, 
				       players_dialog_shell, NULL);

then put the widget properties in the app-default file 'Freeciv', instead of hardcoding them. For the widget created above, the following entries in the app-default file applies:

*playersform.background:          lightblue
*playersform.resizable:           true
*playersform.top:                 chainTop
*playersform.bottom:              chainBottom
*playersform.left:                chainLeft
*playersform.right:               chainRight

Pixcomm and Canvas:


The Pixcomm is a subclassed Command-widget, which can displays a Pixmap instead of a string, on top of a button(command). The Pixcomm widget should be used all places where this kind of high-level functionality is required.

The Canvas widget is more low-level. One have to write an expose(redraw) event-handler for each widget. The widget generates events on resize and mousebuttons.

[Reading any Xt documentation, will tell you how powerful widget subclassing is. So I went trough great troubles subclassing the command widget. It was not before long I got mails from unhappy Xaw3d (and derives) users, that the client keeps crashing on them. Turns out that subclassing from any widgets but Core, chains the new widgets to libXaw. In hindsight I should just subclassed the Canvas widget and add more highlevel functionality. -PU]
=========================================================================

Some notes: 1. app-default 'Freeciv' file contains lines like

Freeciv*playersform.background: White

2. Since Vasco wrote multibyte charset support for Xaw client, it is interesting, can we use an entry

Freeciv*playersformlabel.font: ....

and what we have to write here? (Before, it was 'Freeciv*playersformlabel.font: 6x13')


Two things I (evyscr) am trying to do now:

  • 1. Understand the Xaw client code
  • 2. Make some standards (like common dialog model)

And, of course, there should be main goal: to make Xaw client better.


Xaw client code traveler letters[]

Once I found, that closing the 'Wonders of the World' report by window manager (x) button is a trying to close whole civclient. To fix this I deep into freeciv client code.

Letter 1: Modal and non-modal windows

All dialog shells now are of two classes: 'transientShellWidgetClass' or 'topLevelShellWidgetClass'.

transientShellWidgetClass will create modal window (which deactivate main_window). topLevelShellWidgetClass will create, heh, top-level window (without deactivating of main_window).

Several dialogs have 'raise' or 'make_modal' parameter, which determines, what class will be the window. (I think, that all dialogs should have this parameter).

All these things are usually in create_<dialog-name>_dialog funtion.

If window is modal, than in popup_<dialog-name>_dialog should be next line:

XtSetSensitive(main_form, FALSE);

or

XtSetSensitive(toplevel, FALSE);

(I place it just after creating the dialog_shell)

And if window is modal, there should be next in popdown_<dialog-name>_dialog:

XtSetSensitive(main_form, TRUE);

or

XtSetSensitive(toplevel, TRUE);

I don't know, which way (main_form or toplever) is better.

Note, that on current policy all dialogs should be non-modal.

Letter 2. Dialog window (x) button.

In default, if you press (x) button on dialog, it would try to close whole client. To disable this one uses XtOverrideTranslations function (<X11/Intrinsic.h>). Example from plrdlg.c:

  • Place this function in creating dialog code (in current case, in create_players_dialog()):
  XSetWMProtocols(display, XtWindow(players_dialog_shell),
                  &wm_delete_window, 1);
  XtOverrideTranslations(players_dialog_shell,
    XtParseTranslationTable("<Message>WM_PROTOCOLS: msg-close-players()"));
  • Create callback function for action, when (x) button pressed:
void plrdlg_msg_close(Widget w)
{
  players_close_callback(w, NULL, NULL);
}
  • And create overriding function in actions.c:
static void xaw_msg_close_players(Widget w, XEvent *event, String *argv, Cardinal *argc)
{
  plrdlg_msg_close(w);
}
  • Don't forget to update Table of actions in actions.c:
static XtActionsRec Actions[] = {
  ...
  { "msg-close-players", xaw_msg_close_players },
  ...
}
Advertisement