mirror of https://github.com/adamdruppe/arsd.git
more minigui work
This commit is contained in:
parent
ba0894a453
commit
adbebc7771
40
minigui.d
40
minigui.d
|
@ -1,8 +1,26 @@
|
|||
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775498%28v=vs.85%29.aspx
|
||||
|
||||
/// FOR BEST RESULTS: be sure to link with the appropriate subsystem command
|
||||
/// -L/SUBSYSTEM:WINDOWS:5.0
|
||||
/// otherwise you'll get a console and other visual bugs.
|
||||
/++
|
||||
minigui is a smallish GUI widget library, aiming to be on par with at least
|
||||
HTML4 forms and a few other expected gui components. It uses native controls
|
||||
on Windows and does its own thing on Linux (Mac is not currently supported but
|
||||
may be later, and should use native controls) to keep size down.
|
||||
|
||||
Its #1 goal is to be useful without being large and complicated like GTK and Qt.
|
||||
I love Qt, if you want something full featured, use it! But if you want something
|
||||
you can just drop into a small project and expect the basics to work without outside
|
||||
dependencies, hopefully minigui will work for you.
|
||||
|
||||
The event model is similar to what you use in the browser with Javascript and the
|
||||
layout engine tries to automatically fit things in.
|
||||
|
||||
|
||||
FOR BEST RESULTS: be sure to link with the appropriate subsystem command
|
||||
`-L/SUBSYSTEM:WINDOWS:5.0`, for example, because otherwise you'll get a
|
||||
console and other visual bugs.
|
||||
|
||||
Examples:
|
||||
+/
|
||||
module arsd.minigui;
|
||||
|
||||
/*
|
||||
|
@ -213,9 +231,11 @@ class Action {
|
|||
static Action[int] mapping;
|
||||
}
|
||||
|
||||
this(string label, ushort icon = 0) {
|
||||
this(string label, ushort icon = 0, void delegate() triggered = null) {
|
||||
this.label = label;
|
||||
this.iconId = icon;
|
||||
if(triggered !is null)
|
||||
this.triggered ~= triggered;
|
||||
version(win32_widgets) {
|
||||
id = ++lastId;
|
||||
mapping[id] = this;
|
||||
|
@ -1156,16 +1176,17 @@ class MainWindow : Window {
|
|||
|
||||
MenuBar _menu;
|
||||
MenuBar menu() { return _menu; }
|
||||
void menu(MenuBar m) {
|
||||
MenuBar menu(MenuBar m) {
|
||||
if(_menu !is null) {
|
||||
// make sure it is sanely removed
|
||||
// FIXME
|
||||
}
|
||||
|
||||
_menu = m;
|
||||
|
||||
version(win32_widgets) {
|
||||
SetMenu(parentWindow.win.impl.hwnd, m.handle);
|
||||
} else {
|
||||
_menu = m;
|
||||
super.addChild(m, 0);
|
||||
|
||||
// clientArea.y = menu.height;
|
||||
|
@ -1173,6 +1194,8 @@ class MainWindow : Window {
|
|||
|
||||
recomputeChildLayout();
|
||||
}
|
||||
|
||||
return _menu;
|
||||
}
|
||||
private Widget _clientArea;
|
||||
@property Widget clientArea() { return _clientArea; }
|
||||
|
@ -1186,6 +1209,9 @@ class MainWindow : Window {
|
|||
_statusBar = bar;
|
||||
super.addChild(_statusBar);
|
||||
}
|
||||
|
||||
@property string title() { return parentWindow.win.title; }
|
||||
@property void title(string title) { parentWindow.win.title = title; }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2116,10 +2142,12 @@ class TextEdit : Widget {
|
|||
};
|
||||
|
||||
caratTimer = new Timer(500, {
|
||||
if(parentWindow.focusedWidget is this) {
|
||||
auto painter = this.draw();
|
||||
painter.pen = Pen(Color.white, 1);
|
||||
painter.rasterOp = RasterOp.xor;
|
||||
painter.drawLine(Point(16, 0), Point(16, 16));
|
||||
}
|
||||
});
|
||||
|
||||
defaultEventHandlers["click"] = delegate (Widget _this, Event ev) {
|
||||
|
|
|
@ -966,9 +966,23 @@ class SimpleWindow : CapableOfHandlingNativeEvent {
|
|||
You may call this function at any time.
|
||||
+/
|
||||
@property void title(string title) {
|
||||
_title = title;
|
||||
impl.setTitle(title);
|
||||
}
|
||||
|
||||
private string _title;
|
||||
|
||||
@property string title() {
|
||||
return _title;
|
||||
/*
|
||||
version(Windows) {
|
||||
|
||||
} else version(X11) {
|
||||
|
||||
} else static assert(0);
|
||||
*/
|
||||
}
|
||||
|
||||
/// Set the icon that is seen in the title bar or taskbar, etc., for the user.
|
||||
@property void icon(MemoryImage icon) {
|
||||
auto tci = icon.getAsTrueColorImage();
|
||||
|
|
Loading…
Reference in New Issue