2 * The graphical user interface for the main menu
4 qx.OO.defineClass("swat.main.Gui");
7 qx.Class.buildGui = function(modules)
12 var topColor = new qx.renderer.color.Color("#ffff64");
13 var bottomColor = new qx.renderer.color.Color("#3878cd");
15 // Create the yellow bar at the top
16 o = new qx.ui.basic.Terminator();
23 o.setBackgroundColor(topColor);
26 // Create the tag line
27 var title = new qx.ui.basic.Label("Samba Web Administration Tool");
32 title.setBackgroundColor(topColor);
33 title.setFont("bold");
34 title.addToDocument();
36 // Create a small black separator between the yellow and blue bars
37 o = new qx.ui.basic.Terminator();
44 o.setBackgroundColor("black");
47 // Create the yellow bar at the top
48 o = new qx.ui.basic.Terminator();
55 o.setBackgroundColor(bottomColor);
58 // Create the "Samba" image
59 o = new qx.ui.basic.Image("../../../images/logo.png");
64 o.setZIndex(100000000);
68 var menubar = new qx.ui.toolbar.ToolBar();
75 menubar.addToDocument();
77 // Create a menu item for selecting the requested module
78 var menubutton = new qx.ui.toolbar.MenuButton("Modules");
79 menubar.add(menubutton);
81 // Create a Command to be executed upon any menu selection
82 var command = new qx.client.Command();
83 // command.addEventListener("execute", fsm.eventListener, fsm);
85 // Create a radio manager for selecting one of the modules
86 var moduleManager = new qx.manager.selection.RadioManager("main.gui.Module");
88 // Create a menu containing the subitems
89 var menu = new qx.ui.menu.Menu();
91 // We'll also track the current module's canvas in the modules object
92 modules.currentCanvas = null;
94 // For each menu item...
95 for (moduleName in modules.list)
97 // create a radio button menu item
98 o = new qx.ui.menu.RadioButton(moduleName, null, command);
100 // Associate this button menu item with the module list
101 o.moduleName = moduleName;
103 // Associate the menu item with the radio manager
104 moduleManager.add(o);
106 // Create this module's canvas
107 var canvas = new qx.ui.layout.CanvasLayout();
114 canvas.setBackgroundColor("white");
115 canvas.setDisplay(false); // initially not displayed
117 var fsm = modules.list[moduleName].fsm;
118 fsm.addObject("swat.module.canvas", canvas);
119 canvas.addEventListener("appear", fsm.eventListener, fsm);
120 canvas.addEventListener("disappear", fsm.eventListener, fsm);
123 modules.list[moduleName].canvas = canvas;
125 // Add the canvas to the document
126 canvas.addToDocument();
128 // When a Module menu item is selected:
129 o.addEventListener("changeChecked", function(e)
131 // If there's a current canvas, ...
132 if (modules.currentCanvas)
134 // ... then remove display of it.
135 modules.currentCanvas.setDisplay(false);
137 // Dispatch an event on the canvas to notify old
138 // module it's coming into disuse.
139 canvas.createDispatchEvent("disappear");
142 // If we are being selected...
145 // then display our canvas
146 var canvas = modules.list[this.moduleName].canvas;
147 canvas.setDisplay(true);
149 // Track the current canvas (now ours)
150 modules.currentCanvas = canvas;
152 // Set the application title
153 title.setHtml("<span>" +
154 "Samba Web Administration Tool" +
159 // Dispatch an event on the canvas to notify new
160 // module it's coming into use.
161 canvas.createDispatchEvent("appear");
165 // Add the menu item to the menu
169 // We've built a complete menu. Add it to the document.
170 menu.addToDocument();
172 // Specify that the menu is to be displayed upon menu button selection
173 menubutton.setMenu(menu);
175 // Create a menu item for selecting debug options
176 var menubutton = new qx.ui.toolbar.MenuButton("Debug");
177 menubar.add(menubutton);
179 // Create a menu containing the subitems
180 var menu = new qx.ui.menu.Menu;
181 var menu_01 = new qx.ui.menu.Button("Show Debug Window", null, command);
183 menu.addToDocument();
185 // Specify that the menu is to be displayed upon menu button selection
186 menubutton.setMenu(menu);