Skip to content

Commit 9a691fc

Browse files
committed
display width and height functions, use them in example boxes
1 parent 7fae03b commit 9a691fc

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

examples/boxes.winxed

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Boxes : TopLevelWindow
6565
var numcolor;
6666
function Boxes(controller)
6767
{
68+
var display = controller.display;
6869
self.boxlist = [];
6970
self.activebox = -1;
7071
self.x = 0;
@@ -73,10 +74,17 @@ class Boxes : TopLevelWindow
7374
self.y1 = 0;
7475
self.pressed = false;
7576
self.numcolor = 0;
76-
self.width = 600;
77-
self.height = 400;
78-
self.TopLevelWindow(controller, "Boxes", 0, 0, 600, 400);
79-
var display = self.display;
77+
int dwidth = display.Width();
78+
int dheight = display.Height();
79+
int width = dwidth - dwidth / 3;
80+
int height = dheight - dheight / 3;
81+
self.width = width;
82+
self.height = height;
83+
// The window manager will probably ignore the position,
84+
// but set it just in case.
85+
int x = (dwidth - width) / 2;
86+
int y = (dheight - height) / 2;
87+
self.TopLevelWindow(controller, "Boxes", x, y, width, height);
8088
self.colors = [
8189
display.ParseColor("yellow"),
8290
display.ParseColor("red"),

src/Guitor.winxed

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ class Display
105105
{
106106
return getfun("XDefaultColormap")(self.xdisplay, scrnum);
107107
}
108+
function Height(int scrnum[optional])
109+
{
110+
return int(getfun("XDisplayHeight")(self.xdisplay, scrnum));
111+
}
112+
function HeightMM(int scrnum[optional])
113+
{
114+
return int(getfun("XDisplayHeightMM")(self.xdisplay, scrnum));
115+
}
116+
function Width(int scrnum[optional])
117+
{
118+
return int(getfun("XDisplayWidth")(self.xdisplay, scrnum));
119+
}
120+
function WidthMM(int scrnum[optional])
121+
{
122+
return int(getfun("XDisplayWidthMM")(self.xdisplay, scrnum));
123+
}
108124
function BlackPixel(int scrnum)
109125
{
110126
return getfun("XBlackPixel")(self.xdisplay, scrnum);

src/GuitorNci.winxed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ function create_function(string funcname)
505505
case "XDefaultDepth":
506506
case "XBlackPixel":
507507
case "XWhitePixel":
508+
case "XDisplayWidth":
509+
case "XDisplayWidthMM":
510+
case "XDisplayHeight":
511+
case "XDisplayHeightMM":
508512
case "XKeysymToKeycode":
509513
sig = "ipi";
510514
break;

0 commit comments

Comments
 (0)