mirror of https://github.com/buggins/dlangui.git
Implemented #422 - Possibility to set default window icon for new windows.
This commit is contained in:
parent
ce633a7675
commit
20e42ccfac
|
@ -65,7 +65,7 @@ class Dialog : VerticalLayout {
|
|||
_caption = caption;
|
||||
_parentWindow = parentWindow;
|
||||
_flags = flags;
|
||||
_icon = "dlangui-logo1";
|
||||
_icon = "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,8 +88,12 @@ class Dialog : VerticalLayout {
|
|||
@property Dialog windowIcon(string iconResourceId) {
|
||||
_icon = iconResourceId;
|
||||
static if (BACKEND_GUI) {
|
||||
if (_window && _icon)
|
||||
_window.windowIcon = drawableCache.getImage(_icon);
|
||||
if (_window) {
|
||||
if (_icon.length == 0)
|
||||
_window.windowIcon = drawableCache.getImage(Platform.instance.defaultWindowIcon);
|
||||
else
|
||||
_window.windowIcon = drawableCache.getImage(_icon);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -211,10 +215,7 @@ class Dialog : VerticalLayout {
|
|||
if (_initialWidth == 0 && _initialHeight == 0)
|
||||
wflags |= WindowFlag.MeasureSize;
|
||||
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight);
|
||||
static if (BACKEND_GUI) {
|
||||
if (_window && _icon)
|
||||
_window.windowIcon = drawableCache.getImage(_icon);
|
||||
}
|
||||
windowIcon = _icon;
|
||||
_window.backgroundColor = currentTheme.customColor("dialog_background");
|
||||
_window.mainWidget = this;
|
||||
_window.show();
|
||||
|
|
|
@ -1884,6 +1884,20 @@ class Platform {
|
|||
// override and call dispatchThemeChange for all windows
|
||||
}
|
||||
|
||||
/// default icon for new created windows
|
||||
private string _defaultWindowIcon = "dlangui-logo1";
|
||||
|
||||
/// sets default icon for new created windows
|
||||
@property void defaultWindowIcon(string newIcon) {
|
||||
_defaultWindowIcon = newIcon;
|
||||
}
|
||||
|
||||
/// gets default icon for new created windows
|
||||
@property string defaultWindowIcon() {
|
||||
return _defaultWindowIcon;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// get current platform object instance
|
||||
|
|
|
@ -99,6 +99,9 @@ class SDLWindow : Window {
|
|||
create(flags);
|
||||
_children.reserve(20);
|
||||
Log.i(_enableOpengl ? "OpenGL is enabled" : "OpenGL is disabled");
|
||||
|
||||
if (platform.defaultWindowIcon.length != 0)
|
||||
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||
}
|
||||
|
||||
~this() {
|
||||
|
|
|
@ -303,10 +303,13 @@ class Win32Window : Window {
|
|||
useOpengl = sharedGLContext.init(hDC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(_hwnd, &rect);
|
||||
handleWindowStateChange(WindowState.unspecified, Rect(rect.left, rect.top, _dx, _dy));
|
||||
|
||||
if (platform.defaultWindowIcon.length != 0)
|
||||
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||
}
|
||||
|
||||
static if (ENABLE_OPENGL) {
|
||||
|
|
|
@ -373,6 +373,9 @@ class X11Window : DWindow {
|
|||
//XFlush(x11display);
|
||||
|
||||
handleWindowStateChange(WindowState.unspecified, Rect(0, 0, _dx, _dy));
|
||||
|
||||
if (platform.defaultWindowIcon.length != 0)
|
||||
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||
}
|
||||
|
||||
~this() {
|
||||
|
|
Loading…
Reference in New Issue