§1  MENU  MENU BARS AND PULL-DOWN MENUS 1

1. Menu bars and pull-down menus.

These are a set of functions that can be used to implement a menubar with pull-down menus. They have been written to help implement the “Skew Diagram Manipulation into Mathematical Pictures Interface” project by James Faux. It uses the ‘X Windows’ standard libraries, with no help from the ‘XToolkit’ libraries.

2. All C programs are required to include specific standard header files and ‘X Windows’ programs are no exception. #include #include #include #include

3. There is one general header file that does all the includes needed for the graphical interface compilation units, in a proper order. #include

4. The construction of the header file occurs here. It includes all the global definition, macro, typedef and function declaration modules that are mentioned below. ⟨ 4 ⟩ ≡

⟨ Global definitions and macro definitions 6 ⟩

⟨ Global typedefs 7 ⟩

⟨ Global function declarations 13 ⟩

5. Local functions will precede the globally visible ones (which are defined in unnamed section); this slightly facilitates a top-down presentation of the functions. #define local static

format local static

⟨ Local function declarations 20 ⟩

⟨ Global variable declarations 17 ⟩

⟨ Local variable declarations 10 ⟩

⟨ Local functions 15 ⟩

6. For clarity we define here the terminology used for menus. A menu bar is a wide but shallow rectangular area at the top of a window that contains the menu titles. When depressing the mouse button when the pointer is on one of these titles, a pull-down menu appears below it that contains a vertical list of menu entries. Having pressed the mouse button in one of these titles, the other menus can be invoked by entering a different menu title. To select the entry, the mouse pointer must be run down the menu entries and released, when covering the required function.

Since all menu structures are fixed during the program, no harm is done by placing arbitrary limits on the number of menu titles, on the number of entries per menu, and on the number of characters for each menu title or entry. The following definitions define these limits, (called , , and respectively), and can be increased if the menus get so elaborate as to require this. ⟨ Global definitions and macro definitions 6 ⟩ ≡ #define 10 #define 10 #define 20

This code is used in section 4.

2  MENU BARS AND PULL-DOWN MENUS  MENU §7

7. Each individual menu entry has an associated structure of type m entry . Since the menu entry will be highlighted when the mouse moves over it, it is convenient to define a separate window (i.e., rectangle) for each entry, and its window identifier is kept in the win field; the title field holds the name of the entry. ⟨ Global typedefs 7 ⟩ ≡

typedef struct m entry

{ win p win; char title[ ]; void (∗f) (win p); struct m list ∗parent ;

} ∗p m entry;

See also sections 8, 9, and 11. This code is used in section 4.

8. The data associated with a menu title is stored in the structure m list . Like menu entries, a separate window, h win, is reserved for the title, and the string forming the title is called header in this case. There is a window, m win, that contains all the whole list of menu entry windows; this will limit the expose events for the windows below to a minimum. Furthermore the coordinate of the right edge is recorded in end and the width of the menu entries (which will be calculated to be wide enough to hold the widest entry) in width. The boolean open tells whether the menu is currently dropped-down, and the menu field contains the data for the individual menu entries. The final parent field is a link back to the menu bar containing the current title, so that we can check the status of that menu bar when the mouse enters a menu title. ⟨ Global typedefs 7 ⟩ +≡

typedef struct m list

{ win p h win, m win; int end ; int width; bool open; char header [ ]; p m entry menu[ ]; struct m bar ∗parent ;

} ∗p m list;

9. Finally the data structure for the complete menu bar. It too has an associated window, which surrounds all those of the menu titles; no further data other than the records for the menu titles is recorded. ⟨ Global typedefs 7 ⟩ +≡

typedef struct m bar

{ win p win; bool pressed ; p m list bar [ ]; win p parent ; /∗ index of outer window on which menu is mapped ∗/

} ∗p m bar;

10. Whenever we are handling a menu selection we keep track of this centrally, so that we can quickly clear the menu state when the mouse button is released (the window in which this happens can be arbitrary, to it gives us no hint about the proper menu to clear). ⟨ Local variable declarations 10 ⟩ ≡

bool in menu ⇐ false;

p m bar current menu bar ; p m list current menu list ;

See also section 12. This code is used in section 5.

11. To transmit the structure of the menu tree, we can use lists of strings in a regular fashion. The type menu tree can be statically initialised in an obvious way to transmit the information to the routines defined below. After the last real menu, one with the empty string as title should be specified so that the end can be recognised. Each sublist of menu entries will be similarly terminated by a null pointer (which we provide explicitly, to have the compiler check that there is indeed a slot available for the sentinel). ⟨ Global typedefs 7 ⟩ +≡

typedef struct { char title[ ];

struct { char ∗name;

void (∗f) (win p); } entry [ ];

} menu tree[ ];

12. For the moment we define three menu trees, whose structures are given here. The first being the menus for the main window, second being the menus for the diagram windows and the last, being for the picture window menus. ⟨ Local variable declarations 10 ⟩ +≡

local menu tree main m ⇐ { { , { { ␣ , main menu box size func }, { , main menu help func },

{ , main menu quit func }, { ⊙, ⊙ } } }, { , { { ␣ , main menu new diag func }, { ␣ ,

main menu create pict func }, { , main menu robin func }, { ⊙, ⊙ } }, }, { } }; local menu tree diag m ⇐ {

{  , { {  , diag menu select func }, {  , diag menu deselect func },
{  , diag menu clear func }, {  , diag menu dup func },
{  , diag menu iconise func }, {  , diag menu done func }, { ⊙, ⊙ } } },
{  , { {  , diag menu add func }, {  ␣ , diag menu remove br func },
{  ␣ , diag menu remove tl func }, {  , diag menu trans func },
{  , diag menu neg func }, {  , diag menu anti func }, {  ,
diag menu query func }, {  ␣  , diag menu create picture func }, { ⊙, ⊙ } } },
{  , { {  , diag menu find func }, {  , diag menu origin func }, { ⊙, ⊙ } } },

{ } }; local menu tree pict m ⇐ {

{  , { {  , pict menu select func }, {  , pict menu deselect func },
{  , pict menu clear func }, {  , pict menu decons func },
{  , pict menu dup func }, {  , pict menu iconise func },

{ , pict menu done func }, { ⊙, ⊙ } } },

{  , { {  , pict menu inv func }, {  , pict menu neg func },
{  , pict menu trans func }, {  , pict menu robin func },
{  ␣  , pict menu inv RS func }, {  , pict menu schutz func },
{  ␣    ␣  , pict menu full transp func }, { ⊙, ⊙ } } },
{  , { {  ␣  , pict menu d find func }, {  ␣  , pict menu i find func },
{  ␣  , pict menu d origin func },
{  ␣  , pict menu i origin func }, { ⊙, ⊙ } } },

4  FUNCTIONS TO CREATE A MENU  MENU §13

{ } }; 13. Functions to create a menu. The function create main menus , create diag menus and create pict menus are used to create the menu structures, and map the menu bar window with the appropriate associated setup. Presently no menu tree is supplied explicitly. ⟨ Global function declarations 13 ⟩ ≡

extern p m bar create main menus (win p, unsigned int); extern p m bar create diag menus (win p, unsigned int); extern p m bar create pict menus (win p, unsigned int);

See also sections 25, 27, 29, 31, 33, 35, 37, 40, 45, 47, 49, 68, 75, 99, 108, and 133. This code is used in section 4.

14. We call the internal function build menus that does have an addition menu tree parameter. This parameter depends on which menus are required.

p m bar create main menus (win p parent , unsigned int new window width) { return build menus (parent , main m, new window width); } p m bar create diag menus (win p parent , unsigned int new window width) { return build menus (parent , diag m, new window width); } p m bar create pict menus (win p parent , unsigned int new window width) { return build menus (parent , pict m, new window width); }

15. From the menu tree passed to it, this function creates the menubar window, the header windows and the menu entry windows but only maps the first two. ⟨ Local functions 15 ⟩ ≡

local p m bar build menus (win p parent , menu tree m, unsigned int new window width) { int i, cur pos ⇐ 1; /∗ horizontal position on menu bar ∗/

p m bar mb ⇐ new (struct m bar );

⟨ Create and map the menu bar window, setting its attibutes 16 ⟩

for (i ⇐ 0; m[i].title[0] ≠ ; ^{++}i) ⟨ Install menu number i 18 ⟩

mb→bar [i] ⇐ ⊙; /∗ sentinel pointer ∗/

mb→pressed ⇐ false; mb→parent ⇐ parent ; return mb; }

This code is used in section 5.

16. ⟨ Create and map the menu bar window, setting its attibutes 16 ⟩ ≡

{ mb→win ⇐ make window (menu bar win, parent , 0, 0, new window width − 4, bf height + 8); XDefineCursor (display , mb→win→w, XCreateFontCursor (display , XC hand_{2})); map window (mb→win);

}

This code is used in section 15.

17. ⟨ Global variable declarations 17 ⟩ ≡

event handler table menu bar handlers ⇐ { 0, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙ };

See also sections 19 and 24. This code is used in section 5.

§18  MENU  FUNCTIONS TO CREATE A MENU 5

18. This module creates the menu title button for each menu title. The position for each button is found by looking at the end component of the previous buttons structure. A but is added to make it look nice and then the next button is mapped. ⟨ Install menu number i 18 ⟩ ≡

{ p m list menu ⇐ mb→bar [i] ⇐ new (struct m list ); strcpy (menu→header , m[i].title); { int string width ⇐ XTextWidth(button font , menu→header , strlen(menu→header ));

menu→h win ⇐

make thin window (menu title win, mb→win, cur pos , 1, string width + 6, bf height + 4); menu→h win→data.menu ⇐ menu; /∗ menu list ∗/ menu→end ⇐ cur pos +⇐ string width + 10;

}

menu→parent ⇐ mb; map window (menu→h win); create menu list (parent , mb, m, i); }

This code is used in section 15.

19. For menu titles we set the ButtonReleaseMask , and the corresponding event will occur if the mouse button is reased either in a menu title or in a window which does not set this mask; this event is handled directly in event handler (removing the pull-down menu), so that no further handler is needed here. ⟨ Global variable declarations 17 ⟩ +≡

event handler table menu title handlers ⇐ { ExposureMask | EnterWindowMask | ButtonPressMask | ButtonReleaseMask | OwnerGrabButtonMask , menu title expose, menu title enter , ⊙, menu title press , ⊙, ⊙, ⊙, ⊙ };

20. This function creates the menu windows that display that actual entries. The titles array holds all the entries of all the pull-down menus. It first find the maximum length that the entry string could be. Then the windows are created and mapped one below another, with the origin of the first below the menu header. Finally the string is copied into the menu structure and the menu open flag is set to True. ⟨ Local function declarations 20 ⟩ ≡

local void create menu list (win p, p m bar, menu tree, int);

See also sections 43, 52, 55, 57, 59, 61, 63, 65, 71, 73, 77, 79, 81, 84, 86, 88, 90, 92, 94, 96, 102, 104, 106, 110, 112, 114, 116,

118, 120, 122, 124, 126, and 129. This code is used in section 5.

21.

local void create menu list (win p parent , p m bar mb, menu tree m, int i)

{ p m list menu ⇐ mb→bar [i]; int j, longest ⇐ 0, string width; for (j ⇐ 0; m[i].entry [j].name ≠ ⊙; j^{++}) { p m entry e ⇐ menu→menu[j] ⇐ new (struct m entry ); char ∗name ⇐ m[i].entry [j].name;

string width ⇐ XTextWidth(button font , name, strlen(name));

if (string width > longest ) longest ⇐ string width;

strcpy (e→title, name); e→f ⇐ m[i].entry [j].f; e→parent ⇐ menu; } menu→menu[j] ⇐ ⊙; /∗ sentinel ∗/ menu→width ⇐ longest ; ⟨ Create a base window for the menu list 22 ⟩ for (j ⇐ 0; m[i].entry [j].name ≠ ⊙; j^{++}) ⟨ Create a window for this menu entry 23 ⟩ menu→open ⇐ false;

} 22. ⟨ Create a base window for the menu list 22 ⟩ ≡

{ menu→m win ⇐ make thin window (menu list win, parent , i = 0 ? 0 : mb→bar [i − 1]→end ,

bf height + 8, menu→width + 12, (bf height + 5) ∗ j + 1); }

This code is used in section 21.

23. The menu entries are create and mapped onto the menu list window, but they will not become visible until that window is mapped. #define (ExposureMask | ButtonReleaseMask | EnterWindowMask

| LeaveWindowMask )

⟨ Create a window for this menu entry 23 ⟩ ≡

{ menu→menu[j]→win ⇐ make invisible window (menu entry win, menu→m win, 0,

(bf height + 5) ∗ j, menu→width + 10, bf height + 4); menu→menu[j]→win→data.menu entry ⇐ menu→menu[j]; map window (menu→menu[j]→win);

}

This code is used in section 21.

24. ⟨ Global variable declarations 17 ⟩ +≡

event handler table menu list handlers ⇐ { 0, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙, ⊙ };

event handler table menu entry handlers ⇐ { ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonReleaseMask , menu entry expose, menu entry enter , menu entry leave, ⊙, menu entry release, ⊙, ⊙, ⊙ };

§25  MENU  MENU EVENTS 7

25. Menu events. We list here the events handlers for the menu bar, titles, and entries. We start with a function that is called (directly from event handler ) whenever the left mouse button is released. ⟨ Global function declarations 13 ⟩ +≡

void release menu (void);

26.

void release menu (void) { if (in menu)

{ current menu bar →pressed ⇐ in menu ⇐ false; remove menu window (current menu list );

remove highlighted menu(current menu list ); }

}

27. ⟨ Global function declarations 13 ⟩ +≡

void menu title expose (win p);

28.

void menu title expose (win p p) { remove highlighted menu(p→data.menu); }

29. ⟨ Global function declarations 13 ⟩ +≡

void menu title press (win p, XButtonEvent∗);

30.

void menu title press (win p p, XButtonEvent ∗xbutton) { if (xbutton→button = Button_{1})

{ p m list menu ⇐ current menu list ⇐ p→data.menu; p m bar bar ⇐ current menu bar ⇐ menu→parent ; highlight menu(menu); display menu window (menu); bar →pressed ⇐ in menu ⇐ true;

} }

31. ⟨ Global function declarations 13 ⟩ +≡

void menu title enter (win p);

32.

void menu title enter (win p p) { p m list menu ⇐ p→data.menu; p m bar bar ⇐ menu→parent ;

if (in menu ∧ current menu bar = bar )

if (current menu list ≠ menu) /∗ if menu is already dropped, ignore entry ∗/ { remove menu window (current menu list ); remove highlighted menu(current menu list );

highlight menu(current menu list ⇐ menu); display menu window (menu); }

}

8  MENU EVENTS  MENU §33

33. ⟨ Global function declarations 13 ⟩ +≡

void menu entry expose (win p);

34.

void menu entry expose (win p p) { remove highlighted menu option(p); }

35. ⟨ Global function declarations 13 ⟩ +≡

void menu entry release (win p, XButtonEvent∗);

36.

void menu entry release (win p p, XButtonEvent ∗xbutton) { if (xbutton→button = Button_{1})

{ p m entry e ⇐ p→data.menu entry ;

e→f(e→parent →parent →parent ); }

}

37. ⟨ Global function declarations 13 ⟩ +≡

void menu entry enter (win p); void menu entry leave (win p);

38.

void menu entry enter (win p p) { highlight menu option(p); } void menu entry leave (win p p) { remove highlighted menu option(p); }

§39  MENU  HIGHLIGHTING AND MAPPING MENUS 9

39. Highlighting and mapping menus. These functions execute the highlighting and removing of highlighted menu headers and menu entries. There is also a set of functions that map and unmap a set of menu entries. There is also a function that frees the memory used by the menu structure.

40. These functions highlights and remove a highlight from a window header. This is done in exactly the same way as the highlighting function highlight menu option. It prints a filled rectangle in the foreground colour and then displays the string in the background colour. The remove highlight function just reverses the foreground and background colours. ⟨ Global function declarations 13 ⟩ +≡

extern void highlight menu (p m list);

extern void remove highlighted menu (p m list);

41.

extern void highlight menu (p m list mbar )

{ change menu highlight (gc_{1}, gc_{2}, mbar );

}

42.

extern void remove highlighted menu (p m list mbar )

{ change menu highlight (gc_{2}, gc_{1}, mbar );

}

43. This function does the actual printing of the highlights. This function does not actually know whether it is highlighting or removing a highlight - it all depends on which order the graphics contexts are passed in. ⟨ Local function declarations 20 ⟩ +≡

local void change menu highlight (GC, GC, p m list);

44.

local void change menu highlight (GC f gc, GC b gc, p m list mbar )

{ int string length, string width; string length ⇐ (int) strlen(mbar →header ); string width ⇐ XTextWidth(button font , mbar →header , string length); XFillRectangle(display , mbar →h win→w, f gc, 1, 1, string width + 4, bf height + 2); XDrawString (display , mbar →h win→w, b gc, 3, bf height , mbar →header , string length);

}

45. This function displays a menu list, by mapping the base window of the menu list, and setting the menu open flag. ⟨ Global function declarations 13 ⟩ +≡

extern void display menu window (p m list);

46.

extern void display menu window (p m list mbar )

{ XRaiseWindow (display , mbar →m win→w); map window (mbar →m win); mbar →open ⇐ true; }

10  HIGHLIGHTING AND MAPPING MENUS  MENU §47

47. This function removes a menu, by unmapping the base window of the menu list, and resetting the menu open flag. ⟨ Global function declarations 13 ⟩ +≡

extern void remove menu window (p m list);

48.

extern void remove menu window (p m list mbar ) { if (mbar →open)

{ XUnmapWindow (display , mbar →m win→w); mbar →open ⇐ false; }

}

49. This function highlights a menu entry. This is done by displaying a filled rectangle in the foreground pixel colour in the window and printing the string in the background pixel colour. This means that the window does not have to be cleared using the XClearWindow command. ⟨ Global function declarations 13 ⟩ +≡

extern void highlight menu option (win p); extern void remove highlighted menu option (win p);

50.

extern void highlight menu option (win p p) { change menu option highlight (gc_{1}, gc_{2}, p); }

51.

extern void remove highlighted menu option (win p p) { change menu option highlight (gc_{2}, gc_{1}, p); }

52. This function changes the highlight of a menu entry. It also does not know whether it is highlighting or removing a highlight. It all depends on the order the graphics context’s were passed. ⟨ Local function declarations 20 ⟩ +≡

local void change menu option highlight (GC, GC, win p);

53.

local void change menu option highlight (GC f gc, GC b gc, win p p) { p m entry e ⇐ p→data.menu entry ; p m list list ⇐ e→parent ;

XFillRectangle(display , p→w, f gc, 2, 1, list →width + 9, bf height + 3); XDrawString (display , p→w, b gc, 3, bf height , e→title, (int) strlen(e→title));

}

§54  MENU  MENU FUNCTIONS FOR THE MAIN WINDOW 11

54. Menu functions for the main window.

55. This function creates all the windows that are required to add settings into. ⟨ Local function declarations 20 ⟩ +≡

local void main menu box size func (win p);

56.

local void main menu box size func (win p p)

{ if (¬info→scale.mapped ) info→scale.mapped ⇐ true, map window (info→scale.win); }

57. As I feel that full help options in this program is excessive, there is one help window giving information. This window is created here. ⟨ Local function declarations 20 ⟩ +≡

local void main menu help func (win p);

58.

local void main menu help func (win p p)

{ if (¬info→help mapped ) info→help mapped ⇐ true, map window (info→help win); }

59. When the quit button is pressed, all the diagram and picture windows are unmapped. The the fonts and graphics context’s are freed and finally the display is closed. ⟨ Local function declarations 20 ⟩ +≡

local void main menu quit func (win p);

60.

local void main menu quit func (win p p)

{ int i;

for (i ⇐ 0; info→dw [i] ≠ ⊙ ∧ info→dw [i]→pane.visibility ≠ removed ; ^{++}i)

XDestroyWindow (display , info→dw [i]→pane.win→w); for (i ⇐ 0; info→pw [i] ≠ ⊙ ∧ info→pw [i]→pane.visibility ≠ removed ; ^{++}i)

XDestroyWindow (display , info→pw [i]→pane.win→w); XUnloadFont (display , button font →fid ); XUnloadFont (display , coord font →fid ); XFreeGC (display , gc_{1}); XFreeGC (display , gc_{2}); XFreeGC (display , gc_{3}); XFreeGC (display , gc_{4}); XCloseDisplay (display ); exit (1);

}

61. When a new diagram is created, a position in the main structure is found, and a diagram structure is placed in it. Then the initial setting are set and the icon set up. ⟨ Local function declarations 20 ⟩ +≡

local void main menu new diag func (win p);

62.

local void main menu new diag func (win p p)

{ (void) new diagram window ( );

}

12  MENU FUNCTIONS FOR THE MAIN WINDOW  MENU §63

63. When the create picture button is pressed, it will create a picture from the selected diagram, as if it were activated from within the diagram window itself. If no diagram is slected or the diagram is empty, a bell is sounded. ⟨ Local function declarations 20 ⟩ +≡

local void main menu create pict func (win p);

64.

local void main menu create pict func (win p p)

{ if (info→sel diag ≥ 0 ∧ info→dw [info→sel diag ]→d ≠ ⊙)

new picture window (info→dw [info→sel diag ]→d, ⊙); else XBell (display , 100);

}

65. This is the button robin function. ⟨ Local function declarations 20 ⟩ +≡

local void main menu robin func (win p);

66.

local void main menu robin func (win p p)

{ if (info→sel pict = −1) XBell (display , 100); else if (info→pw [info→sel pict ]→p = ⊙) { pict p f ⇐ new (picture);

f ⇐ RS tableau(&info→pw [info→sel pict ]→f); new picture window (⊙, f); XClearWindow (display , info→pw [info→sel pict ]→d.win→w); XClearWindow (display , info→pw [info→sel pict ]→i.win→w); print complete picture(info→pw [info→sel pict ]);

§67  MENU  DIAGRAM MENU FUNCTIONS 13

} } 67. Diagram menu functions. These are the function called directly by the menu entries. When a menu entry is activated the corresponding menu function is executed.

68. The diagram number is used to identify which is selected. This number is stored in info→sel diag . When the diagram is selected, the select icon is displayed in the icon window and the select icon is removed from the other diagram, if any. If no diagram is selected, the info→sel diag ⇐ −1. To remove a selected diagram, the info→sel diag value is used to reprint the icon window and then set to −1. ⟨ Global function declarations 13 ⟩ +≡

void diag menu select func (win p);

void diag menu deselect func (win p);

69.

void diag menu select func (win p p)

{ p diagram window dw ⇐ p→data.diag ; int i; for (i ⇐ 0; info→dw [i] ≠ ⊙; i^{++}) { if (info→dw [i]→pane.visibility ≠ removed ∧ info→dw [i]→pane.win = dw →pane.win)

{ info→sel diag ⇐ i; display select icon(dw →pane.icon);

}

if (info→dw [i]→pane.visibility ≠ removed ∧ info→dw [i]→pane.win ≠ dw →pane.win)

{ XClearWindow (display , info→dw [i]→pane.icon→w);

display icon graphics (info→dw [i]→pane.icon, info→dw [i]→pane.title,

info→dw [i]→pane.visibility ); } }

}

70.

void diag menu deselect func (win p p)

{ p diagram window dw ⇐ p→data.diag ; if (info→sel diag ≠ −1 ∧ info→dw [info→sel diag ]→pane.win = dw →pane.win) { XClearWindow (display , info→dw [info→sel diag ]→pane.icon→w);

display icon graphics (info→dw [info→sel diag ]→pane.icon, info→dw [info→sel diag ]→pane.title,

info→dw [info→sel diag ]→pane.visibility ); info→sel diag ⇐ −1; } else XBell (display , 50);

}

71. When the clear menu entry is activated, the diagram is deleted, the offsets are reset, the window cleared and the origin cross is redrawn. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu clear func (win p);

72.

local void diag menu clear func (win p p)

{ p diagram window dw ⇐ p→data.diag ; del diag (dw →d); dw →d ⇐ ⊙; dw →disp.hor →offset ⇐ 3 ∗ info→scale.box size; dw →disp.vert →offset ⇐ 3 ∗ info→scale.box size; XClearWindow (display , dw →disp.win→w); print outline(dw →disp.win, dw →d, dw →disp.hor →offset , dw →disp.vert →offset );

14  DIAGRAM MENU FUNCTIONS  MENU §73

} 73. This function duplicates and existing diagram, event the mode that is currently set is copied. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu dup func (win p);

74.

local void diag menu dup func (win p p)

{ p diagram window dw ⇐ p→data.diag ; int i ⇐ new diagram window ( ); if (i ≠ −1) { info→dw [i]→d ⇐ dw →d; info→dw [i]→mode ⇐ dw →mode; }

}

75. When the window is iconised, the dw →pane.visibility is set to iconised , all the windows are unmapped except the icon window obviously. Finally the tick icon is displayed in the icon window. ⟨ Global function declarations 13 ⟩ +≡

void diag menu iconise func (win p);

76.

void diag menu iconise func (win p p)

{ p diagram window dw ⇐ p→data.diag ; dw →pane.visibility ⇐ iconised ; XUnmapWindow (display , dw →pane.win→w); display tick icon(dw →pane.icon);

}

77. When the diagram is finished with, the done menu entry is selected. When this is activated all the windows in the diagram are destroyed and the memory allocated to that part of the main structure is freed. The visibility of the diagram window is set to removed and the number of diagrams is decremented. Finally all the icons are moved up next to each other. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu done func (win p);

78.

local void diag menu done func (win p p)

{ p diagram window dw ⇐ p→data.diag ; del diag (dw →d); dw →d ⇐ ⊙; dw →pane.visibility ⇐ removed ; ^{−}info→num diags ; if (info→sel diag ≥ 0 ∧ info→dw [info→sel diag ] = dw )

info→sel diag ⇐ −1; /∗ if selected, cancel selection. ∗/ XUnmapWindow (display , dw →pane.win→w); XUnmapWindow (display , dw →pane.icon→w); adjust icons (inner diag win, 0);

} 79. The add mode is active when the diagram window is created. If the mode is changed and the user wishes to return to the add mode, this menu entry corresponding to this function is selected. It just changed the mode field of the diagram structure and displays a new comment. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu add func (win p);

80.

local void diag menu add func (win p p) { p diagram window dw ⇐ p→data.diag ;

dw →mode ⇐ add mode; strcpy (dw →disp.comment , ␣ ); print comment (&dw →disp); }

81. When the user wants to remove a set of squares, the remove mode is used. When this entry is selected, the mode field in the diagram window is changed and the comment is undated. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu remove br func (win p); local void diag menu remove tl func (win p);

82.

local void diag menu remove br func (win p p) { p diagram window dw ⇐ p→data.diag ;

dw →mode ⇐ remove br mode;

strcpy (dw →disp.comment , ␣ ␣ ␣ ␣ ␣ ␣ );

print comment (&dw →disp); }

83.

local void diag menu remove tl func (win p p) { p diagram window dw ⇐ p→data.diag ;

dw →mode ⇐ remove tl mode;

strcpy (dw →disp.comment , ␣ ␣ ␣ ␣ ␣ ␣ );

print comment (&dw →disp); }

84. When the diagram is to be transposed, the transpose diag function is called and the newly transposed diagram is displayed. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu trans func (win p);

85.

local void diag menu trans func (win p p) { p diagram window dw ⇐ p→data.diag ;

dw →d ⇐ transpose diag (dw →d); XClearWindow (display , dw →disp.win→w);

print outline(dw →disp.win, dw →d, dw →disp.hor →offset , dw →disp.vert →offset ); } 86. Then the diagram is to be negated, all that is done is the diagram is sent to the minus diag function and then the newly negated diagram is displayed. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu neg func (win p);

87.

local void diag menu neg func (win p p)

{ p diagram window dw ⇐ p→data.diag ; minus diag (&dw →d); XClearWindow (display , dw →disp.win→w); print outline(dw →disp.win, dw →d, dw →disp.hor →offset , dw →disp.vert →offset );

}

88. When a anti-diagonal of a square is wanted, then the anti-diagonal mode is set and the comment is undated. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu anti func (win p);

89.

local void diag menu anti func (win p p)

{ p diagram window dw ⇐ p→data.diag ; dw →mode ⇐ anti diagonal mode; strcpy (dw →disp.comment , ␣ ); print comment (&dw →disp);

}

90. When the user want to query the diagram to find out more information about a square, the query mode is set and the comment is undated. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu query func (win p);

91.

local void diag menu query func (win p p)

{ p diagram window dw ⇐ p→data.diag ; dw →mode ⇐ query mode; strcpy (dw →disp.comment , ␣ ); print comment (&dw →disp);

}

92. When a picture is required to be created, if there is no diagram a comment is displayed and a bell, sounded, Otherwise, a function to create the picture is called. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu create picture func (win p);

93.

local void diag menu create picture func (win p p)

{ p diagram window dw ⇐ p→data.diag ; if (dw →d = ⊙) { strcpy (dw →disp.comment , ␣ ␣ ␣ ␣ ␣ );

print comment (&dw →disp); XBell (display , 100); } else new picture window (dw →d, ⊙);

} 94. If the diagram is moved from view, (most likely when the negate function is used) theis function “usually” fings it by finding the top left corner of the rectangle enclosing the diagram and displaying the diagram with this point in the top left corner of the printing window. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu find func (win p);

95.

local void diag menu find func (win p p) { p diagram window dw ⇐ p→data.diag ;

if (dw →d ≠ ⊙) { dw →disp.vert →offset ⇐ (1 − (dw →d→top)) ∗ info→scale.box size;

dw →disp.hor →offset ⇐ (1−(dw →d→r[ (dw →d)−1]→start ))∗info→scale.box size; XClearWindow (display , dw →disp.win→w); print outline(dw →disp.win, dw →d, dw →disp.hor →offset , dw →disp.vert →offset );

} else { dw →disp.vert →offset ⇐ 3 ∗ info→scale.box size; dw →disp.hor →offset ⇐ 3 ∗ info→scale.box size;

XClearWindow (display , dw →disp.win→w);

print origin cross (dw →disp.win, dw →disp.hor →offset , dw →disp.vert →offset ); }

}

96. To find the origin, the originate function is called. This moves the origin into the printing window slightly below and to the right of the top left corner of the window. ⟨ Local function declarations 20 ⟩ +≡

local void diag menu origin func (win p);

97.

local void diag menu origin func (win p p) { p diagram window dw ⇐ p→data.diag ;

dw →disp.hor →offset ⇐ 3 ∗ info→scale.box size; dw →disp.vert →offset ⇐ 3 ∗ info→scale.box size; XClearWindow (display , dw →disp.win→w); if (dw →d ≠ ⊙) print outline(dw →disp.win, dw →d, dw →disp.hor →offset , dw →disp.vert →offset ); else print origin cross (dw →disp.win, dw →disp.hor →offset , dw →disp.vert →offset );

18  PICTURE MENU FUNCTIONS  MENU §98

} 98. Picture menu functions. These are the function called directly by the picture windows menu options. When a menu option is activated the corresponding menu function is executed.

99. The picture number is used to identify which is selected. This number is stored in info→sel pict . When the picture is selected, the select icon is displayed in the icon window and removed from the previously selected picture, if any. If the picture is to be deselected and if no picture is selected, the info→sel pict ⇐ −1. To remove a selected picture, the info→sel pict value is used to reprint the icon window and then set to -1. ⟨ Global function declarations 13 ⟩ +≡

void pict menu select func (win p);

void pict menu deselect func (win p);

100.

void pict menu select func (win p p)

{ p picture window pw ⇐ p→data.pict ; int i; for (i ⇐ 0; info→pw [i] ≠ ⊙; i^{++}) { if (info→pw [i]→pane.visibility ≠ removed )

{ if (info→pw [i]→pane.win = pw →pane.win)

{ info→sel pict ⇐ i; display select icon(pw →pane.icon); } else { XClearWindow (display , info→pw [i]→pane.icon→w);

display icon graphics (info→pw [i]→pane.icon, info→pw [i]→pane.title,

info→pw [i]→pane.visibility ); }

}

} }

101.

void pict menu deselect func (win p p)

{ p picture window pw ⇐ p→data.pict ; if (info→sel pict ≠ −1 ∧ info→pw [info→sel pict ]→pane.win = pw →pane.win) { XClearWindow (display , info→pw [info→sel pict ]→pane.icon→w);

display icon graphics (info→pw [info→sel pict ]→pane.icon, info→pw [info→sel pict ]→pane.title,

info→pw [info→sel pict ]→pane.visibility ); info→sel pict ⇐ −1; } else XBell (display , 50);

§102  MENU  PICTURE MENU FUNCTIONS 19

} 102. To clear a picture, the domain is sent to set up a new partial picture from and all the printing and comment windows are updated. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu clear func (win p);

103.

local void pict menu clear func (win p p) { p picture window pw ⇐ p→data.pict ;

if (pw →p = ⊙) { part pict ∗p ⇐ pw →p ⇐ new (part pict);

setup new pict (p, dup diag (pw →f→domain)); del pict (pw →f), pw →f ⇐ ⊙; strcpy (pw →d.comment , ␣ ); print comment (&pw →d); strcpy (pw →i.comment , ); XClearWindow (display , pw →i.com→w); XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print partial picture(pw );

} }

104. To deconstruct a picture, if the picture is completed, the partial picture is constructed else nothing is done. Then the image is deleted if there is one that does exist. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu decons func (win p);

105.

local void pict menu decons func (win p p) { p picture window pw ⇐ p→data.pict ;

if (pw →p = ⊙) { part pict ∗p ⇐ pw →p ⇐ new (part pict);

p→f ⇐ pw →f; pw →f ⇐ ⊙; p→complete ⇐ true; } XClearWindow (display , pw →d.com→w); XClearWindow (display , pw →i.com→w); strcpy (pw →i.comment , ); if (delete image(pw →p)) { strcpy (pw →d.comment , ␣ ); XClearWindow (display , pw →d.win→w);

XClearWindow (display , pw →i.win→w); print partial picture(pw ); } else XBell (display , 100), strcpy (pw →d.comment , ␣ ␣ ␣ ); print comment (&pw →d);

} 106. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu dup func (win p);

107.

local void pict menu dup func (win p p)

{ p picture window pw ⇐ p→data.pict ; if (pw →p = ⊙) { if (new picture window (⊙, dup pict (pw →f)) < 0)

{ XBell (display , 100), strcpy (pw →d.comment , ␣ ␣ ␣ );

print comment (&pw →d); } }

}

108. When the window is iconised, the pw →pane.visibility field is set to iconised . All the windows are unmapped, except obviously the icon window. Finally the tick icon is displayed in the remaining icon window. ⟨ Global function declarations 13 ⟩ +≡

void pict menu iconise func (win p);

109.

void pict menu iconise func (win p p)

{ p picture window pw ⇐ p→data.pict ; pw →pane.visibility ⇐ iconised ; XUnmapWindow (display , pw →pane.win→w); display tick icon(pw →pane.icon);

}

110. When a user is finished with the done menu option is selected. When this is activated, al;l the windows in the picture are destroyed and the memory allocated to that part of the main structure is freed. The visibility of the picture window is set to removed and the number of pictures is decremented. Finally all the icons are moved up next to each other. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu done func (win p);

111.

local void pict menu done func (win p p)

{ p picture window pw ⇐ p→data.pict ; del pict (pw →f); pw →f ⇐ ⊙; if (pw →p ≠ ⊙) del pict (pw →p→f), free(pw →p), pw →p ⇐ ⊙; pw →pane.visibility ⇐ removed ; ^{−}info→num picts ; if (info→sel pict ≥ 0 ∧ info→pw [info→sel pict ] = pw )

info→sel pict ⇐ −1; /∗ if selected, cancel selection. ∗/ XUnmapWindow (display , pw →pane.win→w); XUnmapWindow (display , pw →pane.icon→w); adjust icons (pict dom win, 0);

} 112. When the picture is to be transposed, the transpose pict function is called and the newly transposed picture is displayed. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu inv func (win p);

113.

local void pict menu inv func (win p p)

{ p picture window pw ⇐ p→data.pict ; if (pw →p = ⊙) { pict p f ⇐ inverse pict (pw →f);

del pict (pw →f), pw →f ⇐ f; XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print complete picture(pw );

} }

114. Then the picture is to be negated, all that is done is the domain and image parts are neagated and then the new picture is displayed. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu neg func (win p);

115.

local void pict menu neg func (win p p)

{ p picture window pw ⇐ p→data.pict ; if (pw →p = ⊙) { minus pict (&pw →f); XClearWindow (display , pw →d.win→w);

XClearWindow (display , pw →i.win→w); print complete picture(pw ); }

}

116. When the picture is to be transposed, the transpose pict function is called and the newly transposed picture is displayed. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu trans func (win p);

117.

local void pict menu trans func (win p p)

{ p picture window pw ⇐ p→data.pict ; if (pw →p = ⊙) { pict p f ⇐ transpose pict (pw →f);

del pict (pw →f), pw →f ⇐ f; XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print complete picture(pw );

} } 118. This is the Robinson-Schensted function. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu robin func (win p);

119.

local void pict menu robin func (win p p) { p picture window pw ⇐ p→data.pict ;

if (pw →p = ⊙) { int i ⇐ new picture window (⊙, ⊙);

if (i = −1) /∗ do nothing if no more windows are available ∗/ { XBell (display , 100), strcpy (pw →d.comment , ␣ ␣ ␣ );

print comment (&pw →d); } else { info→pw [i]→f ⇐ RS tableau(&pw →f); /∗ new window gets P, old Q ∗/

XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print complete picture(pw ); /∗ redisplay old window ∗/

} }

}

120. This is the inverse Robinson-Schensted function. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu inv RS func (win p);

121.

local void pict menu inv RS func (win p p) { p picture window pw ⇐ p→data.pict ; int i ⇐ info→sel pict ;

if (i < 0 ∨ info→pw [i]→p ≠ ⊙) { XBell (display , 100), strcpy (pw →d.comment , ␣ ␣ ␣ ␣ );

print comment (&pw →d); } else if (pw →p = ⊙) { pict p f ⇐ dup pict (info→pw [i]→f), g ⇐ pw →f;

if (¬RS permutation(f, &g)) /∗ then try with pictures interchanged ∗/ { f ⇐ pw →f, g ⇐ dup pict (info→pw [i]→f);

if (RS permutation(f, &g)) pw →f ⇐ g; /∗ old pw →f was destroyed ∗/ else { XBell (display , 100); strcpy (pw →d.comment , ␣ ␣ );

print comment (&pw →d); return; }

} XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print complete picture(pw ); /∗ redisplay old window ∗/

} } 122. This is the Schützenberger function.

⟨ Local function declarations 20 ⟩ +≡ local void pict menu schutz func (win p);

123.

local void pict menu schutz func (win p p) { p picture window pw ⇐ p→data.pict ;

if (pw →p = ⊙)

{ if (¬Schutz dualise(&pw →f))

{ pict p inv ⇐ inverse pict (pw →f);

if (Schutz dualise(&inv )) del pict (pw →f), pw →f ⇐ inverse pict (inv ), del pict (inv ); else { XBell (display , 100); strcpy (pw →d.comment , ␣ ␣ ␣ ␣ ␣ ␣ );

print comment (&pw →d); return; } } XClearWindow (display , pw →d.win→w); XClearWindow (display , pw →i.win→w); print complete picture(pw ); /∗ redisplay old window ∗/

} }

124. Here is the function that transposes both domain and image, using the Robinson-Schensted, Schützenberger, and inverse Robinson-Schensted algorithms.

⟨ Local function declarations 20 ⟩ +≡ local void pict menu full transp func (win p);

125.

local void pict menu full transp func (win p p) { p picture window pw ⇐ p→data.pict ;

if (pw →p = ⊙)

{ transpose both(&pw →f); XClearWindow (display , pw →d.win→w);

XClearWindow (display , pw →i.win→w); print complete picture(pw ); }

} 126. If the pictures domain (image) is moved from view (most likely when the negated function is used) this function “usually” finds it by finding the top left corner of the rectangle enclosing it and displaying the domain (image) with this point in the top left corner of the corresponding diaply window. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu d find func (win p); local void pict menu i find func (win p);

127.

local void pict menu d find func (win p p) { p picture window pw ⇐ p→data.pict ; diag p d ⇐ new (diagram);

if (pw →p ≠ ⊙) d ⇐ pw →p→f→domain; else d ⇐ pw →f→domain; if (d ≠ ⊙) { pw →d.vert →offset ⇐ (1 − (d→top)) ∗ info→scale.box size;

pw →d.hor →offset ⇐ (1 − (d→r[ (d) − 1]→start )) ∗ info→scale.box size; XClearWindow (display , pw →d.win→w); if (pw →p ≠ ⊙) print partial picture(pw ); else print complete domain(pw );

} }

128.

local void pict menu i find func (win p p) { p picture window pw ⇐ p→data.pict ; diag p d ⇐ new (diagram);

if (pw →p ≠ ⊙) d ⇐ pw →p→f→image; else d ⇐ pw →f→image; if (d ≠ ⊙) { pw →i.vert →offset ⇐ (1 − (d→top)) ∗ info→scale.box size;

pw →i.hor →offset ⇐ (1 − (d→r[ (d) − 1]→start )) ∗ info→scale.box size; XClearWindow (display , pw →i.win→w); if (pw →p ≠ ⊙) print partial picture(pw ); else print complete image(pw );

} else { pw →i.vert →offset ⇐ 3 ∗ info→scale.box size; pw →i.hor →offset ⇐ 3 ∗ info→scale.box size;

XClearWindow (display , pw →i.win→w);

print origin cross (pw →i.win, pw →i.hor →offset , pw →i.vert →offset ); }

} 129. To find the origin, the originate function is called. This moves the origin of the domain (image) into the printing window slightly below and to the right of the top left corner of the window. ⟨ Local function declarations 20 ⟩ +≡

local void pict menu d origin func (win p); local void pict menu i origin func (win p);

130.

local void pict menu d origin func (win p p) { p picture window pw ⇐ p→data.pict ;

pw →d.hor →offset ⇐ 3 ∗ info→scale.box size; pw →d.vert →offset ⇐ 3 ∗ info→scale.box size; XClearWindow (display , pw →d.win→w); if (pw →p ≠ ⊙) print partial picture(pw ); else print complete domain(pw );

}

131.

local void pict menu i origin func (win p p) { p picture window pw ⇐ p→data.pict ;

pw →i.hor →offset ⇐ 3 ∗ info→scale.box size; pw →i.vert →offset ⇐ 3 ∗ info→scale.box size; XClearWindow (display , pw →i.win→w); if (pw →p ≠ ⊙) print partial picture(pw ); else print complete image(pw );

}

26  RESIZE FUNCTIONS  MENU §132

132. Resize functions. These functions resize the different aspects of the window when the diagram or picture window is resized.

133. These function resizes the menu bar windows on either the diagram window or the picture window. ⟨ Global function declarations 13 ⟩ +≡

void resize menubar (win p, int);

134.

void resize menubar (win p p, int width)

§135  MENU  INDEX 27

{ XResizeWindow (display , p→w, width − 4, bf height + 8); } 135. Index.

add mode: 80. adjust icons : 78, 111. anti diagonal mode: 89. b gc: \underline{44}, \underline{53}. bar : \underline{9}, 15, 18, 21, 22, \underline{30}, \underline{32}. bf height : 16, 18, 22, 23, 44, 53, 134. bool: 8, 9, 10. box size: 72, 95, 97, 127, 128, 130, 131. build menus : 14, \underline{15}. button: 30, 36. button font : 18, 21, 44, 60. ButtonPressMask : 19. ButtonReleaseMask : 19, 23, 24. Button_{1}: 30, 36. change menu highlight : 41, 42, \underline{43}, \underline{44}. change menu option highlight : 50, 51, \underline{52}, \underline{53}. com: 103, 105. comment : 80, 82, 83, 89, 91, 93, 103, 105, 107,

119, 121, 123. complete: 105. coord font : 60. create diag menus : \underline{13}, \underline{14}. create main menus : \underline{13}, \underline{14}. create menu list : 18, \underline{20}, \underline{21}. create pict menus : \underline{13}, \underline{14}. cur pos : \underline{15}, 18. current menu bar : \underline{10}, 26, 30, 32. current menu list : \underline{10}, 26, 30, 32. d: \underline{127}, \underline{128}. data: 18, 23, 28, 30, 32, 36, 53, 69, 70, 72, 74, 76,

78, 80, 82, 83, 85, 87, 89, 91, 93, 95, 97, 100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 128, 130, 131.

del diag : 72, 78. del pict : 103, 111, 113, 117, 123. delete image: 105. diag : 69, 70, 72, 74, 76, 78, 80, 82, 83, 85, 87,

89, 91, 93, 95, 97. diag m: \underline{12}, 14. diag menu add func: 12, \underline{79}, \underline{80}. diag menu anti func: 12, \underline{88}, \underline{89}. diag menu clear func: 12, \underline{71}, \underline{72}. diag menu create picture func: 12, \underline{92}, \underline{93}. diag menu deselect func: 12, \underline{68}, \underline{70}. diag menu done func: 12, \underline{77}, \underline{78}. diag menu dup func: 12, \underline{73}, \underline{74}. diag menu find func: 12, \underline{94}, \underline{95}. diag menu iconise func: 12, \underline{75}, \underline{76}. diag menu neg func: 12, \underline{86}, \underline{87}. diag menu origin func: 12, \underline{96}, \underline{97}. diag menu query func: 12, \underline{90}, \underline{91}. diag menu remove br func: 12, \underline{81}, \underline{82}. diag menu remove tl func: 12, \underline{81}, \underline{83}. diag menu select func: 12, \underline{68}, \underline{69}. diag menu trans func: 12, \underline{84}, \underline{85}. diag p: 127, 128. diagram: 127, 128. : 95, 127, 128. disp: 72, 80, 82, 83, 85, 87, 89, 91, 93, 95, 97. display : 16, 44, 46, 48, 53, 60, 64, 66, 69, 70, 72, 76, 78, 85, 87, 93, 95, 97, 100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 128, 130, 131, 134. display icon graphics : 69, 70, 100, 101. display menu window : 30, 32, \underline{45}, \underline{46}. display select icon: 69, 100. display tick icon: 76, 109. domain: 103, 127. dup diag : 103. dup pict : 107, 121. dw : 60, 64, \underline{69}, \underline{70}, \underline{72}, \underline{74}, 75, \underline{76}, \underline{78}, \underline{80}, \underline{82}, \underline{83},

\underline{85}, \underline{87}, \underline{89}, \underline{91}, \underline{93}, \underline{95}, \underline{97}.

e: \underline{21}, \underline{36}, \underline{53}. end : \underline{8}, 18, 22. EnterWindowMask : 19, 23, 24. entry : \underline{11}, 21. event handler : 19, 25. event handler table: 17, 19, 24. exit : 60. ExposureMask : 19, 23, 24. f: \underline{7}, \underline{11}, \underline{66}, \underline{113}, \underline{117}, \underline{121}. f gc: \underline{44}, \underline{53}. false: 10, 15, 21, 26, 48. fid : 60. free: 111. g: \underline{121}. GC: 43, 44, 52, 53. gc_{1}: 41, 42, 50, 51, 60. gc_{2}: 41, 42, 50, 51, 60. gc_{3}: 60. gc_{4}: 60. h win: \underline{8}, 18, 44. header : \underline{8}, 18, 44. help mapped : 58. help win: 58. highlight menu: 30, 32, \underline{40}, \underline{41}. highlight menu option: 38, 40, \underline{49}, \underline{50}. hor : 72, 85, 87, 95, 97, 127, 128, 130, 131. i: \underline{15}, \underline{21}, \underline{60}, \underline{69}, \underline{74}, \underline{100}, \underline{119}, \underline{121}. icon: 69, 70, 76, 78, 100, 101, 109, 111. iconised : 75, 76, 108, 109. image: 128.

28  INDEX  MENU §135

in menu: \underline{10}, 26, 30, 32. info: 56, 58, 60, 64, 66, 68, 69, 70, 72, 74, 78,

95, 97, 99, 100, 101, 111, 119, 121, 127, 128, 130, 131.

inner diag win: 78. inv : \underline{123}. inverse pict : 113, 123. j: \underline{21}. LeaveWindowMask : 23, 24. list : \underline{53}. local: \underline{5}. longest : \underline{21}. m: \underline{15}, \underline{21}. m bar : 8, \underline{9}, 15. m entry : \underline{7}, 21. m list : 7, \underline{8}, 18. m win: \underline{8}, 22, 23, 46, 48. main m: \underline{12}, 14. main menu box size func: 12, \underline{55}, \underline{56}. main menu create pict func: 12, \underline{63}, \underline{64}. main menu help func: 12, \underline{57}, \underline{58}. main menu new diag func: 12, \underline{61}, \underline{62}. main menu quit func: 12, \underline{59}, \underline{60}. main menu robin func: 12, \underline{65}, \underline{66}. make invisible window : 23. make thin window : 18, 22. make window : 16. map window : 16, 18, 23, 46, 56, 58. mapped : 56. : 6, 8, 11. : 6, 7, 8, 11. : 6, 9, 11. mb: \underline{15}, 16, 18, \underline{21}, 22. mbar : \underline{41}, \underline{42}, \underline{44}, \underline{46}, \underline{48}. menu: \underline{8}, \underline{18}, \underline{21}, 22, 23, 28, \underline{30}, \underline{32}. menu bar handlers : \underline{17}. menu bar win: 16. menu entry : 23, 36, 53. menu entry enter : 24, \underline{37}, \underline{38}. : \underline{23}. menu entry expose: 24, \underline{33}, \underline{34}. menu entry handlers : \underline{24}. menu entry leave: 24, \underline{37}, \underline{38}. menu entry release: 24, \underline{35}, \underline{36}. menu entry win: 23. menu list handlers : \underline{24}. menu list win: 22. menu title enter : 19, \underline{31}, \underline{32}. menu title expose: 19, \underline{27}, \underline{28}. menu title handlers : \underline{19}. menu title press : 19, \underline{29}, \underline{30}. menu title win: 18. menu tree: \underline{11}, 12, 14, 15, 20, 21. minus diag : 86, 87. minus pict : 115. mode: 74, 79, 80, 81, 82, 83, 89, 91. name: \underline{11}, \underline{21}. new : 15, 18, 21, 66, 103, 105, 127, 128. new diagram window : 62, 74. new picture window : 64, 66, 93, 107, 119. new window width: \underline{14}, \underline{15}, 16. num diags : 78. num picts : 111. offset : 72, 85, 87, 95, 97, 127, 128, 130, 131. open: \underline{8}, 21, 46, 48. OwnerGrabButtonMask : 19. p: \underline{28}, \underline{30}, \underline{32}, \underline{34}, \underline{36}, \underline{38}, \underline{50}, \underline{51}, \underline{53}, \underline{56}, \underline{58}, \underline{60}, \underline{62}, \underline{64}, \underline{66}, \underline{69}, \underline{70}, \underline{72}, \underline{74}, \underline{76}, \underline{78}, \underline{80}, \underline{82}, \underline{83}, \underline{85}, \underline{87}, \underline{89}, \underline{91}, \underline{93}, \underline{95}, \underline{97}, \underline{100}, \underline{101}, \underline{103}, \underline{105}, \underline{107}, \underline{109}, \underline{111}, \underline{113}, \underline{115}, \underline{117}, \underline{119}, \underline{121}, \underline{123},

\underline{125}, \underline{127}, \underline{128}, \underline{130}, \underline{131}, \underline{134}.

p diagram window: 69, 70, 72, 74, 76, 78, 80,

82, 83, 85, 87, 89, 91, 93, 95, 97. p m bar: \underline{9}, 10, 13, 14, 15, 20, 21, 30, 32.

p m entry: \underline{7}, 8, 21, 36, 53.

p m list: \underline{8}, 9, 10, 18, 21, 30, 32, 40, 41, 42,

43, 44, 45, 46, 47, 48, 53. p picture window: 100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 128, 130, 131.

pane: 60, 69, 70, 75, 76, 78, 100, 101, 108, 109, 111. parent : \underline{7}, \underline{8}, \underline{9}, \underline{14}, \underline{15}, 16, 18, \underline{21}, 22, 30, 32, 36, 53. part pict: 103, 105. pict : 100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 128, 130, 131.

pict dom win: 111. pict m: \underline{12}, 14. pict menu clear func: 12, \underline{102}, \underline{103}. pict menu d find func: 12, \underline{126}, \underline{127}. pict menu d origin func: 12, \underline{129}, \underline{130}. pict menu decons func: 12, \underline{104}, \underline{105}. pict menu deselect func: 12, \underline{99}, \underline{101}. pict menu done func: 12, \underline{110}, \underline{111}. pict menu dup func: 12, \underline{106}, \underline{107}. pict menu full transp func: 12, \underline{124}, \underline{125}. pict menu i find func: 12, \underline{126}, \underline{128}. pict menu i origin func: 12, \underline{129}, \underline{131}. pict menu iconise func: 12, \underline{108}, \underline{109}. pict menu inv func: 12, \underline{112}, \underline{113}. pict menu inv RS func: 12, \underline{120}, \underline{121}. pict menu neg func: 12, \underline{114}, \underline{115}. pict menu robin func: 12, \underline{118}, \underline{119}. pict menu schutz func: 12, \underline{122}, \underline{123}. pict menu select func: 12, \underline{99}, \underline{100}. pict menu trans func: 12, \underline{116}, \underline{117}. pict p: 66, 113, 117, 121, 123. picture: 66. pressed : \underline{9}, 15, 26, 30. print comment : 80, 82, 83, 89, 91, 93, 103, 105,

107, 119, 121, 123. print complete domain: 127, 130. print complete image: 128, 131. print complete picture: 66, 113, 115, 117, 119,

121, 123, 125. print origin cross : 95, 97, 128. print outline: 72, 85, 87, 95, 97. print partial picture: 103, 105, 127, 128, 130, 131. pw : 60, 66, \underline{100}, \underline{101}, \underline{103}, \underline{105}, \underline{107}, 108, \underline{109},

\underline{111}, \underline{113}, \underline{115}, \underline{117}, \underline{119}, \underline{121}, \underline{123}, \underline{125}, \underline{127},

\underline{128}, \underline{130}, \underline{131}.

query mode: 91. release menu: \underline{25}, \underline{26}. remove br mode: 82. remove highlighted menu: 26, 28, 32, \underline{40}, \underline{42}. remove highlighted menu option: 34, 38, \underline{49}, \underline{51}. remove menu window : 26, 32, \underline{47}, \underline{48}. remove tl mode: 83. removed : 60, 69, 77, 78, 100, 110, 111. resize menubar : \underline{133}, \underline{134}. RS permutation: 121. RS tableau: 66, 119. scale: 56, 72, 95, 97, 127, 128, 130, 131. Schutz dualise: 123. sel diag : 64, 68, 69, 70, 78. sel pict : 66, 99, 100, 101, 111, 121. setup new pict : 103. start : 95, 127, 128. strcpy : 18, 21, 80, 82, 83, 89, 91, 93, 103, 105,

107, 119, 121, 123. string length: \underline{44}. string width: \underline{18}, \underline{21}, \underline{44}. strlen: 18, 21, 44, 53. title: \underline{7}, \underline{11}, 15, 18, 21, 53, 69, 70, 100, 101. titles : 20. top: 95, 127, 128. transpose both: 125. transpose diag : 84, 85. transpose pict : 112, 116, 117. true: 30, 46, 56, 58, 105. True: 20. vert : 72, 85, 87, 95, 97, 127, 128, 130, 131. visibility : 60, 69, 70, 75, 76, 78, 100, 101,

108, 109, 111. width: \underline{8}, 21, 22, 23, 53, \underline{134}. win: \underline{7}, \underline{9}, 16, 18, 23, 56, 60, 66, 69, 70, 72, 76, 78,

85, 87, 95, 97, 100, 101, 103, 105, 109, 111, 113,

115, 117, 119, 121, 123, 125, 127, 128, 130, 131. win p: 7, 8, 9, 11, 13, 14, 15, 20, 21, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 133, 134. XBell : 64, 66, 70, 93, 101, 105, 107, 119, 121, 123. xbutton: \underline{30}, \underline{36}. XButtonEvent: 29, 30, 35, 36. XC hand_{2}: 16. XClearWindow : 49, 66, 69, 70, 72, 85, 87, 95, 97, 100, 101, 103, 105, 113, 115, 117, 119, 121, 123, 125, 127, 128, 130, 131.

XCloseDisplay : 60. XCreateFontCursor : 16. XDefineCursor : 16. XDestroyWindow : 60. XDrawString : 44, 53. XFillRectangle: 44, 53. XFreeGC : 60. XRaiseWindow : 46. XResizeWindow : 134. XTextWidth: 18, 21, 44. XUnloadFont : 60. XUnmapWindow : 48, 76, 78, 109, 111.

⟨ Create a base window for the menu list 22 ⟩ Used in section 21. ⟨ Create a window for this menu entry 23 ⟩ Used in section 21. ⟨ Create and map the menu bar window, setting its attibutes 16 ⟩ Used in section 15. ⟨ Global definitions and macro definitions 6 ⟩ Used in section 4.

⟨ Global function declarations 13, 25, 27, 29, 31, 33, 35, 37, 40, 45, 47, 49, 68, 75, 99, 108, 133 ⟩ Used in section 4. ⟨ Global typedefs 7, 8, 9, 11 ⟩ Used in section 4.

⟨ Global variable declarations 17, 19, 24 ⟩ Used in section 5. ⟨ Install menu number i 18 ⟩ Used in section 15.

⟨ Local function declarations 20, 43, 52, 55, 57, 59, 61, 63, 65, 71, 73, 77, 79, 81, 84, 86, 88, 90, 92, 94, 96, 102, 104, 106,

110, 112, 114, 116, 118, 120, 122, 124, 126, 129 ⟩ Used in section 5. ⟨ Local functions 15 ⟩ Used in section 5.

⟨ Local variable declarations 10, 12 ⟩ Used in section 5. ⟨ 4 ⟩

MENU

Section Page

Menu bars and pull-down menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 Functions to create a menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4 Menu events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 7 Highlighting and mapping menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9 Menu functions for the main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 11 Diagram menu functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 13 Picture menu functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 18 Resize functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 26 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 27