All of the various menu types are actually XmRowColumn
s, so those
links all go to that man page. Likewise, the scrolled list is a list in a
scrolled window, so those links go to the scrolled window documentation.
module sortgui
! declare the procedures in sort.c that I'm going to use.
procedure
quit();
enter_item();
! I've put an extra button into the interface that has absolutely
! nothing to do with sorting, but shows how icons can be defined and used.
! First, I declare a color map to use for the button. Since the button
! will display either `PANIC' or `DONT PANIC' I'm calling the color
! table panic_ct. The color table defines four colors, and for each
! color tells how it's mapped to foreground/background on a monochrome
! screen. It also maps each color to a character, for defining the icons
! in a minute...
value
panic_ct : color_table(color('green', background)='X',
color('white', foreground)=' ',
color('black', background)='#',
color('red', foreground)='.');
! Now I define the two icons: one is called dontpanic, and the other is
! called panic. They both use the color table I just defined; while each
! of them only happens to use two colors, notice that they could use four
! with no problem. In fact, by using a suitably enlarged colortable,
! I could use pretty much as many colors as I want! As for the actual
! icon contents... it's just ASCII art. Pretty slick... The next place
! to look for these is down at the bottom, when I define panic_button.
dontpanic : icon(color_table=panic_ct,
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXX XXXX XX XX X XXXXX",
"XXXXX X XX X X XX XXX XXXXXXX",
"XXXXX XX X XXX X X XXX XXXXXXX",
"XXXXX XXX X XXX X X X XXX XXXXXXX",
"XXXXX XX X XXX X X XXX XXXXXXX",
"XXXXX X XX X X XX XXX XXXXXXX",
"XXXXX XXXX XX XX XXX XXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XX XXXX XXX XX X XX XXX",
"XX XX XX XX XX XXX XXX X XX",
"XX XX X X X X XXX XXX XXX XX",
"XX XX X X X X XXX XXX XXXXXX",
"XX XXXXX XXX X X XXX XXX XXX XX",
"XX XXXXX X XX XXX XXX X XX",
"XX XXXXX XXX X XX X XX XXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
);
panic : icon(color_table=panic_ct,
"#################################",
"#################################",
"#################################",
"#################################",
"#################################",
"#################################",
"##....####.###..##.#.....##...###",
"##.##..##...##..##.###.###..#..##",
"##.##..#..#..#...#.###.###.###.##",
"##....##..#..#.#.#.###.###.######",
"##.#####.###.#.#...###.###.###.##",
"##.#####.....#.##..###.###..#..##",
"##.#####.###.#.##..#.....##...###",
"#################################",
"#################################",
"#################################",
"#################################",
"#################################",
"#################################"
);
! declare all the objects -- just remember that the ``controls'' stuff
! defines the object hierarchy. I can't think of any more comments that
! would be clearer than the code...
object
mainWindow : XmMainWindow {
controls {
XmMenuBar menuBar;
XmRowColumn workArea;
};
};
menuBar : XmMenuBar {
controls {
XmCascadeButton fileButton;
};
};
fileButton : XmCascadeButton {
arguments {
XmNlabelString = "File";
};
controls {
XmPulldownMenu fileMenu;
};
};
fileMenu : XmPulldownMenu {
controls {
XmPushButton quitButton;
};
};
quitButton : XmPushButton {
arguments {
XmNlabelString = "Quit";
};
callbacks {
XmNactivateCallback = procedure quit();
};
};
workArea : XmRowColumn {
arguments {
XmNorientation = XmVERTICAL;
};
controls {
XmTextField inputArea;
XmScrolledList sortedList;
XmToggleButton panicButton;
};
};
inputArea : XmTextField {
arguments {
XmNcolumns = 80;
};
callbacks {
XmNactivateCallback = procedure enter_item();
};
};
sortedList: XmScrolledList {
arguments {
XmNvisibleItemCount = 5;
};
};
! Here's my panic button: it doesn't actually *do* anything, but it does
! show how to set up a toggle button with pixmaps.
panicButton: XmToggleButton {
arguments{
XmNindicatorOn = XmINDICATOR_NONE;
XmNlabelType = XmPIXMAP;
XmNlabelPixmap = dontpanic;
XmNselectPixmap = panic;
};
};
end module;