Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Menu Class Reference

Inherited by MenuBar.

List of all members.


Detailed Description

A menu pseudo-widget.

Like the FileSelector, this is a class that you construct off-line before running on-line (interrupting the thread) and then retrieving the value.

The following partial example creates a standard New/Open/Close menu for a text editor:

class MenuFile : Menu
{
    Program program; // Parent running program

    this (Program program)
    {
        bit document = (program.currentDocument === null);

        super (program);
        this.program = program;
        add ("New...", &New);
        add ("Open...", &Open);
        add ("Close", &Close); disabled (!document);
        separator ();
        add ("Save", &Save); disabled (!document);
        add ("Save As...", &SaveAs); disabled (!document);
        add ("Save All", &SaveAll); disabled (!program.documents.length);
        separator ();
        add ("Exit", &Exit);
        exec ();
    }

    void New     (Event e) { program.createDocument (); }
    void Open    (Event e) { program.openDocument (); }
    void Close   (Event e) { program.closeDocument (); }
    void Save    (Event e) { program.saveDocument (); }
    void SaveAs  (Event e) { program.saveDocumentAs (); }
    void SaveAll (Event e) { program.saveAllDocuments (); }
    void Exit    (Event e) { program.exit (); }
}


Public Member Functions

 this (Control control)
 Create an empty popup menu.

 ~this ()
 Destroy the menu.

Dispatcheradd (char[] name, char[] text)
 Add a textual menu item, get a dispatcher.

Dispatcheradd (char[] text)
 Add a textual menu item, get a dispatcher.

Dispatcheradd (char[] name, char[] text, Dispatcher.Method method)
 Add a textual menu item, add a dispatcher command, return the dispatcher.

Dispatcheradd (char[] name, char[] text, Dispatcher.MethodB method)
 Add a textual menu item, add a dispatcher command, return the dispatcher.

Dispatcheradd (char[] text, Dispatcher.Method method)
 Add a textual menu item, add a dispatcher command, return the dispatcher.

Dispatcheradd (char[] text, Dispatcher.MethodB method)
 Add a textual menu item, add a dispatcher command, return the dispatcher.

void disabled (bit value)
 Set whether the most recently added item should be disabled.

void disabled (char[] name, bit value)
 Set whether the named item should be disabled.

void highlight (bit value)
 Set whether to highlight the most recently added item.

void highlight (char[] name, bit value)
 Set whether to highlight the named item.

void checked (bit value)
 Set whether a checkmark appears beside the most recently added item.

void checked (char[] name, bit value)
 Set whether a checkmark appears beside the named item.

void popup (char[] name, char[] text, Menu menu)
 Add a popup text item.

void popup (char[] text, Menu menu)
 Add a popup menu text item.

void separator ()
 Add a separator.

void exec ()
 Display the menu and don't return until a command has been executed or it has been dismissed.


The documentation for this class was generated from the following file:
Generated on Thu Sep 4 13:12:53 2003 for dig by doxygen 1.3.2