r9779: Add a contextmenu function to be used by all window/widget objects.
[samba.git] / swat / scripting / client / desktop.js
index 563af4907fbeaad6951d3d939d470e049e5e3089..bddd38b60c8bfea88eae1faa030edd9284bababf 100644 (file)
@@ -6,6 +6,15 @@
 */
 
 
+// The global widget we attach everything to
+var w = new QxWidget();
+with(w) {
+       setTop(0);
+       setLeft(0);
+       setWidth(docX());
+       setHeight(docY());
+}
+
 /* Qooxdoo's browser sniffer doesn't distinguish IE version.
 We'll cover IE 6 for now, but these checks need to be
 revisited for fuller browser coverage. */
@@ -26,9 +35,8 @@ function docX()
 function docY()
 {
        var y;
-       // Less 25px to not cover the toolbar
        if (browser != "mshtml") {
-               y = window.innerHeight - 25;
+               y = window.innerHeight;
        } else {
                y = document.documentElement.clientHeight;
        }
@@ -81,26 +89,6 @@ function openIn(e)
        blank.setVisible(true);
 }
        
-function winMenu(e)
-{
-       var self = this;
-       var WinWin = new QxCommand();
-       WinWin.addEventListener("execute", function() {
-               var blank = new QxWindow();
-               self.add(blank);
-               blank.setVisible(true);
-       }); 
-
-       var inset = new QxMenu;
-       var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
-
-       inset.add(sub1);
-       self.add(inset)
-
-       cmenu.setVisible(false);
-       inset.setVisible(true);
-}
-
 function Window(h, src, s)
 {
        this.self = new QxWindow(h);
@@ -113,7 +101,7 @@ function Window(h, src, s)
        this.self.setTop(getPosX(this.self));
        this.self.setLeft(getPosY(this.self));
 
-       this.self.addEventListener("contextmenu", winMenu);
+       this.self.addEventListener("contextmenu", contextMenu);
 
        return this.self;
 }
@@ -139,3 +127,47 @@ function LargeWindow(h, src)
 Window.small = SmallWindow;
 Window.standard = StandardWindow;
 Window.large = LargeWindow;
+
+function contextMenu(e)
+{      
+       var t = e.getTarget()
+       var tObj = t.getHtmlAttribute("class")
+
+       if (tObj == 'QxWidget') {
+               clientContextMenu(e);
+       } else if (tObj == 'QxWindowPane') {
+               windowContextMenu(t, e);
+       }
+}
+
+
+window.application.main = function()
+{
+       var doc = this.getClientWindow().getClientDocument();
+       doc.addEventListener("contextmenu", contextMenu);
+       doc.add(w);
+
+       var bar = new QxMenuBar;
+       with (bar) {
+               setBottom(0);
+               setLeft(0);
+               setWidth("100%");
+               setHeight(25);
+               setBackgroundColor("ThreeDFace");
+       }
+
+       var start = new QxMenuButton("START");
+       start.addEventListener("click", function() {
+               startMenu();
+       });
+       bar.add(start);
+
+       w.add(bar);
+}
+
+window.onresize = function() 
+{
+       w.setWidth(docX());
+       w.setHeight(docY());
+}
+