summaryrefslogtreecommitdiff
path: root/swat
diff options
context:
space:
mode:
authorDeryck Hodge <deryck@samba.org>2005-08-29 21:15:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:57 -0500
commitc1909be224a39490fded5c2d74b8d84072972303 (patch)
tree6f1d8bea0971055bee66a7c5d2ea3cbe9f133baa /swat
parentc9ace93ce22fed9e1b4e44a853e23bf66cf99184 (diff)
downloadsamba-c1909be224a39490fded5c2d74b8d84072972303.tar.gz
samba-c1909be224a39490fded5c2d74b8d84072972303.tar.bz2
samba-c1909be224a39490fded5c2d74b8d84072972303.zip
r9759: Create some wrappers for QxWidget. This gives us some pre-fabbed
windows, which set size and positioning. To use: var myWin = new Window.large("Some Window Title"); var myWin = new Window.standard("Some Window Title"); var myWin = new Window.small("Some Window Title"); You can omit the title if you don't need one. Also, var myWin = new Window(); will give you the random positioning and no predetermined sizing. deryck (This used to be commit 92d6bb90a64591b13f4d1bec77ebebcd1198914d)
Diffstat (limited to 'swat')
-rw-r--r--swat/desktop/index.esp3
-rw-r--r--swat/scripting/client/desktop.js74
2 files changed, 59 insertions, 18 deletions
diff --git a/swat/desktop/index.esp b/swat/desktop/index.esp
index 71a0a83154..833ed08bba 100644
--- a/swat/desktop/index.esp
+++ b/swat/desktop/index.esp
@@ -44,7 +44,7 @@ function showMessage(m)
function blankW()
{
- var blank = new Window("SWAT");
+ var blank = new Window.standard('SWAT');
w.add(blank);
blank.setVisible(true);
}
@@ -105,7 +105,6 @@ window.application.main = function()
}
w.add(win);
getServerStatus(win);
-
}
window.onresize = function()
diff --git a/swat/scripting/client/desktop.js b/swat/scripting/client/desktop.js
index e6a4230f10..563af4907f 100644
--- a/swat/scripting/client/desktop.js
+++ b/swat/scripting/client/desktop.js
@@ -11,6 +11,7 @@ We'll cover IE 6 for now, but these checks need to be
revisited for fuller browser coverage. */
var browser = QxClient().engine;
+// DocX/Y returns the width/height of the page in browser
function docX()
{
var x;
@@ -34,27 +35,42 @@ function docY()
return y;
}
-function sizeX()
+// If given a number, sizeX/Y returns in pixels a percentage of the browser
+// window. If given a Window object, sizeX/Y returns the size of that object.
+function sizeX(s)
{
- var sX = Math.floor(docX() * .45);
+ var sX;
+
+ if (typeof(s) == 'number') {
+ sX = Math.floor(docX() * s);
+ } else {
+ sX = s.getMinWidth();
+ }
+
return sX;
}
-function sizeY()
+function sizeY(s)
{
- var sY = Math.floor(docY() * .45);
+ var sY;
+ if (typeof(s) == 'number') {
+ sY = Math.floor(docY() * s);
+ } else {
+ sY = s.getMinHeight();
+ }
+
return sY;
}
-function getPosX()
+function getPosX(win)
{
- var y = Math.floor( (docY() - sizeY()) * Math.random() );
+ var y = Math.floor( (docY() - sizeY(win)) * Math.random() );
return y;
}
-function getPosY()
+function getPosY(win)
{
- var x = Math.floor( (docX() - sizeX()) * Math.random() );
+ var x = Math.floor( (docX() - sizeX(win)) * Math.random() );
return x;
}
@@ -85,15 +101,41 @@ function winMenu(e)
inset.setVisible(true);
}
-function Window(title)
+function Window(h, src, s)
{
- var self = new QxWindow(title);
- self.setTop(getPosX());
- self.setLeft(getPosY());
- self.setMinWidth(sizeX());
- self.setMinHeight(sizeY());
- self.addEventListener("contextmenu", winMenu);
- return self;
+ this.self = new QxWindow(h);
+
+ // Settings for all windows
+ if (s) {
+ this.self.setMinWidth(sizeX(s));
+ this.self.setMinHeight(sizeY(s));
+ }
+ this.self.setTop(getPosX(this.self));
+ this.self.setLeft(getPosY(this.self));
+
+ this.self.addEventListener("contextmenu", winMenu);
+
+ return this.self;
}
+function SmallWindow(h, src)
+{
+ this.self = new Window(h, src, .20);
+ return this.self;
+}
+
+function StandardWindow(h, src)
+{
+ this.self = new Window(h, src, .45);
+ return this.self;
+}
+
+function LargeWindow(h, src)
+{
+ this.self = new Window(h, src, .70);
+ return this.self;
+}
+Window.small = SmallWindow;
+Window.standard = StandardWindow;
+Window.large = LargeWindow;