working on a gui app

This commit is contained in:
Adam D. Ruppe 2015-09-08 09:21:31 -04:00
parent 5f9f465ae7
commit 1260bbcc76
3 changed files with 43 additions and 15 deletions

View File

@ -40,11 +40,9 @@
return window;
}
/*
final void fillAudioBuffer(short[] buffer) {
}
*/
}
void main() {

View File

@ -711,6 +711,18 @@ class Widget {
protected void privatePaint(ScreenPainter painter, int lox, int loy) {
painter.originX = lox + x;
painter.originY = loy + y;
static if(UsingSimpledisplayX11) {
XRectangle[1] rects;
rects[0] = XRectangle(cast(short)(lox + x), cast(short)(loy + y), cast(short) width, cast(short) height);
XSetClipRectangles(XDisplayConnection.get, painter.impl.gc, 0, 0, rects.ptr, 1, 0);
} else {
version(Windows) {
auto region = CreateRectRgn(lox + x, loy + y, lox + x + width, loy + y + height);
SelectClipRgn(painter.impl.hdc, region);
DeleteObject(region);
}
}
if(paint !is null)
paint(painter);
foreach(child; children)
@ -810,6 +822,15 @@ class Window : Widget {
this.width = win.width;
this.height = win.height;
this.parentWindow = this;
win.windowResized = (int w, int h) {
this.width = w;
this.height = h;
recomputeChildLayout();
redraw();
};
win.setEventHandlers(
(MouseEvent e) {
dispatchMouseEvent(e);
@ -931,6 +952,7 @@ class Window : Widget {
else
this.paint = (ScreenPainter painter) {
painter.fillColor = windowBackgroundColor;
painter.outlineColor = windowBackgroundColor;
painter.drawRectangle(Point(0, 0), this.width, this.height);
};
}
@ -1047,15 +1069,8 @@ class Window : Widget {
}
class MainWindow : Window {
this() {
super(500, 500);
win.windowResized = (int w, int h) {
this.width = w;
this.height = h;
recomputeChildLayout();
redraw();
};
this(string title = null) {
super(500, 500, title);
defaultEventHandlers["mouseover"] = delegate void(Widget _this, Event event) {
if(this.statusBar !is null && event.target.statusTip.length)
@ -1383,11 +1398,13 @@ class StatusBar : Widget {
_content = s;
SendMessageA(owner.hwnd, SB_SETTEXT, idx, cast(LPARAM) toStringzInternal(s));
} else {
if(_content != s) {
_content = s;
owner.redraw();
}
}
}
}
string simpleModeContent;
bool inSimpleMode;
@ -1975,7 +1992,8 @@ class TextLabel : Widget {
super(parent);
parentWindow = parent.parentWindow;
paint = (ScreenPainter painter) {
painter.drawText(Point(0, 0), this.label);
painter.outlineColor = Color.black;
painter.drawText(Point(0, 0), this.label, Point(width,height), TextAlignment.Right);
};
}

View File

@ -2155,7 +2155,9 @@ version(Windows) {
rect.bottom = y2;
uint mode = DT_LEFT;
if(alignment & TextAlignment.Center)
if(alignment & TextAlignment.Right)
mode = DT_RIGHT;
else if(alignment & TextAlignment.Center)
mode = DT_CENTER;
// FIXME: vcenter on windows only works with single line, but I want it to work in all cases
@ -2769,6 +2771,7 @@ version(X11) {
// FIXME: this.window.width/height is probably wrong
// src x,y then dest x, y
XSetClipMask(display, gc, None);
XCopyArea(display, d, destiny, gc, 0, 0, this.window.width, this.window.height, 0, 0);
XFreeGC(display, gc);
@ -5354,6 +5357,15 @@ struct Visual
int XSetClipMask(Display*, GC, Pixmap);
int XSetClipOrigin(Display*, GC, int, int);
void XSetClipRectangles(Display*, GC, int, int, XRectangle*, int, int);
struct XRectangle {
short x;
short y;
ushort width;
ushort height;
}
void XSetWMName(Display*, Window, XTextProperty*);
enum ClipByChildren = 0;