diff --git a/dlanguilib.dproj b/dlanguilib.dproj
index 7b173fb1..225f39d6 100644
--- a/dlanguilib.dproj
+++ b/dlanguilib.dproj
@@ -3,7 +3,7 @@
Debug
AnyCPU
- 10.0.0
+ 8.0.30703
2.0
{440816C8-DBD6-454C-A0D7-B6E59CA1ED86}
true
@@ -12,11 +12,11 @@
DMD2
- /home/lve/src/d/DerelictFT/source
- /home/lve/src/d/DerelictGL3/source
- /home/lve/src/d/DerelictUtil/source
- /home/lve/src/d/dlangui/3rdparty/X11
- /home/lve/src/d/dlangui/3rdparty/X11/xcb
+ \home\lve\src\d\DerelictFT\source
+ \home\lve\src\d\DerelictGL3\source
+ \home\lve\src\d\DerelictUtil\source
+ \home\lve\src\d\dlangui\3rdparty\X11
+ \home\lve\src\d\dlangui\3rdparty\X11\xcb
@@ -217,6 +217,7 @@
3rdparty\FreetypeSDL2\types.d
+
diff --git a/dlanguilib.visualdproj b/dlanguilib.visualdproj
index e31a8e86..4495839e 100644
--- a/dlanguilib.visualdproj
+++ b/dlanguilib.visualdproj
@@ -89,6 +89,7 @@
$(OutDir)\$(ProjectName).lib
1
+ 2
@@ -183,6 +184,7 @@
$(OutDir)\$(ProjectName).lib
1
+ 1
diff --git a/src/dlangui/core/i18n.d b/src/dlangui/core/i18n.d
index 809f9097..4c910c69 100644
--- a/src/dlangui/core/i18n.d
+++ b/src/dlangui/core/i18n.d
@@ -167,7 +167,7 @@ private shared class UIStringList {
private dstring[string] _map;
/// remove all items
void clear() {
- _map.clear();
+ _map.destroy();
}
/// set item value
void set(string id, dstring value) {
diff --git a/src/dlangui/dialogs/dialog.d b/src/dlangui/dialogs/dialog.d
index 0ee5f8ae..b1e36289 100644
--- a/src/dlangui/dialogs/dialog.d
+++ b/src/dlangui/dialogs/dialog.d
@@ -15,43 +15,43 @@ Copyright: Vadim Lopatin, 2014
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
-module dlangui.dialogs.dialog;
-
-import dlangui.core.i18n;
+module dlangui.dialogs.dialog;
+
+import dlangui.core.i18n;
import dlangui.core.signals;
-import dlangui.widgets.layouts;
-import dlangui.widgets.controls;
+import dlangui.widgets.layouts;
+import dlangui.widgets.controls;
import dlangui.platforms.common.platform;
-
+
import std.conv;
-
-/// dialog flag bits
-enum DialogFlag : uint {
- /// dialog is modal
- Modal = 1,
- /// dialog can be resized
- Resizable = 2,
-}
+
+/// dialog flag bits
+enum DialogFlag : uint {
+ /// dialog is modal
+ Modal = 1,
+ /// dialog can be resized
+ Resizable = 2,
+}
interface DialogResultHandler {
public void onDialogResult(Dialog dlg, Action result);
}
-
-/// base for all dialogs
-class Dialog : VerticalLayout {
- protected Window _window;
- protected Window _parentWindow;
- protected UIString _caption;
+
+/// base for all dialogs
+class Dialog : VerticalLayout {
+ protected Window _window;
+ protected Window _parentWindow;
+ protected UIString _caption;
protected uint _flags;
- Signal!DialogResultHandler onDialogResult;
-
- this(UIString caption, Window parentWindow = null, uint flags = DialogFlag.Modal) {
- super("dlg");
- _caption = caption;
- _parentWindow = parentWindow;
- }
-
+ Signal!DialogResultHandler onDialogResult;
+
+ this(UIString caption, Window parentWindow = null, uint flags = DialogFlag.Modal) {
+ super("dlg");
+ _caption = caption;
+ _parentWindow = parentWindow;
+ }
+
@property UIString windowCaption() {
return _caption;
}
@@ -62,7 +62,7 @@ class Dialog : VerticalLayout {
_window.windowCaption = caption;
return this;
}
-
+
@property Dialog windowCaption(UIString caption) {
_caption = caption;
if (_window)
@@ -93,17 +93,17 @@ class Dialog : VerticalLayout {
/// override to implement creation of dialog controls
void init() {
}
-
- /// shows dialog
+
+ /// shows dialog
void show() {
- init();
- uint wflags = 0;
- if (_flags & DialogFlag.Modal)
- wflags |= WindowFlag.Modal;
- if (_flags & DialogFlag.Resizable)
- wflags |= WindowFlag.Resizable;
- _window = Platform.instance.createWindow(_caption, _parentWindow, wflags);
- _window.mainWidget = this;
- _window.show();
- }
-}
+ init();
+ uint wflags = 0;
+ if (_flags & DialogFlag.Modal)
+ wflags |= WindowFlag.Modal;
+ if (_flags & DialogFlag.Resizable)
+ wflags |= WindowFlag.Resizable;
+ _window = Platform.instance.createWindow(_caption, _parentWindow, wflags);
+ _window.mainWidget = this;
+ _window.show();
+ }
+}
diff --git a/src/dlangui/graphics/fonts.d b/src/dlangui/graphics/fonts.d
index c1ed472d..ac499f52 100644
--- a/src/dlangui/graphics/fonts.d
+++ b/src/dlangui/graphics/fonts.d
@@ -151,8 +151,13 @@ class Font : RefCountedObject {
/// returns true if font is fixed
@property int spaceWidth() {
- if (_spaceWidth < 0)
+ if (_spaceWidth < 0) {
_spaceWidth = charWidth(' ');
+ if (_spaceWidth <= 0)
+ _spaceWidth = charWidth('0');
+ if (_spaceWidth <= 0)
+ _spaceWidth = size;
+ }
return _spaceWidth;
}
diff --git a/src/dlangui/graphics/ftfonts.d b/src/dlangui/graphics/ftfonts.d
index ee985bcd..b1098792 100644
--- a/src/dlangui/graphics/ftfonts.d
+++ b/src/dlangui/graphics/ftfonts.d
@@ -126,8 +126,8 @@ private class FreeTypeFontFile {
private static string familyName(FT_Face face)
{
- string faceName = cast(string)fromStringz(face.family_name);
- string styleName = cast(string)fromStringz(face.style_name);
+ string faceName = fromStringz(face.family_name).dup;
+ string styleName = fromStringz(face.style_name).dup;
if (faceName.equal("Arial") && styleName.equal("Narrow"))
faceName ~= " Narrow";
else if (styleName.equal("Condensed"))
@@ -147,7 +147,7 @@ private class FreeTypeFontFile {
} else if (exists(kernFile ~ ".pfm" )) {
kernFile ~= ".pfm";
} else {
- kernFile.clear();
+ kernFile.destroy();
}
if (kernFile.length > 0)
error = FT_Attach_File(_face, kernFile.toStringz);
diff --git a/src/dlangui/graphics/resources.d b/src/dlangui/graphics/resources.d
index 132cd97d..78202ff2 100644
--- a/src/dlangui/graphics/resources.d
+++ b/src/dlangui/graphics/resources.d
@@ -654,7 +654,7 @@ class ImageCache {
destroy(item);
item = null;
}
- _map.clear();
+ _map.destroy();
}
}
@@ -705,7 +705,7 @@ class DrawableCache {
_drawable.clear();
foreach(ref t; _transformed)
t.clear();
- _transformed.clear();
+ _transformed.destroy();
debug(resalloc) Log.d("Destroyed DrawableCacheItem, count=", --_instanceCount);
}
/// remove from memory, will cause reload on next access
@@ -714,7 +714,7 @@ class DrawableCache {
_drawable.clear();
foreach(t; _transformed)
t.clear();
- _transformed.clear();
+ _transformed.destroy();
}
/// mark as not used
void checkpoint() {
@@ -800,10 +800,10 @@ class DrawableCache {
}
void clear() {
Log.d("DrawableCache.clear()");
- _idToFileMap.clear();
+ _idToFileMap.destroy();
foreach(DrawableCacheItem item; _idToDrawableMap)
item.drawable.clear();
- _idToDrawableMap.clear();
+ _idToDrawableMap.destroy();
}
// clear usage flags for all entries
void checkpoint() {
@@ -925,7 +925,7 @@ class DrawableCache {
destroy(item);
item = null;
}
- _idToDrawableMap.clear();
+ _idToDrawableMap.destroy();
debug(resalloc) Log.e("Drawable instace count after destroying of DrawableCache: ", ImageDrawable.instanceCount);
}
}
diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d
index ab801b28..817b1613 100644
--- a/src/dlangui/platforms/sdl/sdlapp.d
+++ b/src/dlangui/platforms/sdl/sdlapp.d
@@ -598,7 +598,7 @@ version(USE_SDL) {
}
bool processTextInput(const char * s) {
- string str = cast(string)fromStringz(s);
+ string str = fromStringz(s).dup;
dstring ds = toUTF32(str);
uint flags = convertKeyFlags(SDL_GetModState());
bool res = dispatchKeyEvent(new KeyEvent(KeyAction.Text, 0, flags, ds));
@@ -910,7 +910,7 @@ version(USE_SDL) {
char * txt = SDL_GetClipboardText();
if (!txt)
return ""d;
- string s = cast(string)fromStringz(txt);
+ string s = fromStringz(txt).dup;
SDL_free(txt);
return toUTF32(s);
}
@@ -988,7 +988,7 @@ version(USE_SDL) {
Log.d("myWinMain()");
string basePath = exePath();
Log.i("Current executable: ", exePath());
- string cmdline = cast(string)fromStringz(lpCmdLine);
+ string cmdline = fromStringz(lpCmdLine).dup;
Log.i("Command line: ", cmdline);
string[] args = splitCmdLine(cmdline);
Log.i("Command line params: ", args);
diff --git a/src/dlangui/platforms/windows/win32fonts.d b/src/dlangui/platforms/windows/win32fonts.d
index c108561a..e6bfbf6f 100644
--- a/src/dlangui/platforms/windows/win32fonts.d
+++ b/src/dlangui/platforms/windows/win32fonts.d
@@ -119,7 +119,7 @@ class Win32Font : Font {
0,
null,
&identity );
- if (res==GDI_ERROR)
+ if (res == GDI_ERROR)
return null;
int gs = GetGlyphOutlineW( _drawbuf.dc, cast(wchar)ch,
GGO_GRAY8_BITMAP, //GGO_METRICS
@@ -287,6 +287,7 @@ class Win32FontManager : FontManager {
override ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face) {
//Log.i("getFont()");
FontDef * def = findFace(family, face);
+ Log.i("getFont() found face ", def.face, " by requested face ", face);
if (def !is null) {
int index = _activeFonts.find(size, weight, italic, def.family, def.face);
if (index >= 0)
@@ -415,7 +416,7 @@ extern(Windows) {
{
void * p = cast(void*)lParam;
Win32FontManager fontman = cast(Win32FontManager)p;
- string face = cast(string)fromStringz(lf.lfFaceName.ptr);
+ string face = fromStringz(lf.lfFaceName.ptr).dup;
FontFamily family = pitchAndFamilyToFontFamily(lf.lfPitchAndFamily);
if (face.length < 2 || face[0] == '@')
return 1;
diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d
index 42c931e0..0bf4cfb0 100644
--- a/src/dlangui/platforms/windows/winapp.d
+++ b/src/dlangui/platforms/windows/winapp.d
@@ -1,40 +1,40 @@
-module dlangui.platforms.windows.winapp;
-version (USE_SDL) { }
-else version (Windows) {
-
-import core.runtime;
-import win32.windows;
-import std.string;
-import std.utf;
-import std.stdio;
-import std.algorithm;
+module dlangui.platforms.windows.winapp;
+version (USE_SDL) { }
+else version (Windows) {
+
+import core.runtime;
+import win32.windows;
+import std.string;
+import std.utf;
+import std.stdio;
+import std.algorithm;
import std.file;
-import dlangui.platforms.common.platform;
-import dlangui.platforms.windows.win32fonts;
-import dlangui.platforms.windows.win32drawbuf;
-import dlangui.widgets.styles;
-import dlangui.widgets.widget;
-import dlangui.graphics.drawbuf;
-import dlangui.graphics.images;
-import dlangui.graphics.fonts;
-import dlangui.core.logger;
-
-version (USE_OPENGL) {
- import dlangui.graphics.glsupport;
-}
-
-pragma(lib, "gdi32.lib");
-pragma(lib, "user32.lib");
-
-/// this function should be defined in user application!
-extern (C) int UIAppMain(string[] args);
-
-immutable WIN_CLASS_NAME = "DLANGUI_APP";
-
-__gshared HINSTANCE _hInstance;
-__gshared int _cmdShow;
-
-version (USE_OPENGL) {
+import dlangui.platforms.common.platform;
+import dlangui.platforms.windows.win32fonts;
+import dlangui.platforms.windows.win32drawbuf;
+import dlangui.widgets.styles;
+import dlangui.widgets.widget;
+import dlangui.graphics.drawbuf;
+import dlangui.graphics.images;
+import dlangui.graphics.fonts;
+import dlangui.core.logger;
+
+version (USE_OPENGL) {
+ import dlangui.graphics.glsupport;
+}
+
+pragma(lib, "gdi32.lib");
+pragma(lib, "user32.lib");
+
+/// this function should be defined in user application!
+extern (C) int UIAppMain(string[] args);
+
+immutable WIN_CLASS_NAME = "DLANGUI_APP";
+
+__gshared HINSTANCE _hInstance;
+__gshared int _cmdShow;
+
+version (USE_OPENGL) {
bool setupPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd = {
@@ -123,48 +123,48 @@ version (USE_OPENGL) {
return hPalette;
}
- private __gshared bool DERELICT_GL3_RELOADED = false;
-}
-
-class Win32Window : Window {
- Win32Platform _platform;
- HWND _hwnd;
- version (USE_OPENGL) {
+ private __gshared bool DERELICT_GL3_RELOADED = false;
+}
+
+class Win32Window : Window {
+ Win32Platform _platform;
+ HWND _hwnd;
+ version (USE_OPENGL) {
HGLRC _hGLRC; // opengl context
- HPALETTE _hPalette;
- }
- dstring _caption;
- Win32ColorDrawBuf _drawbuf;
- bool useOpengl;
- uint _flags;
- this(Win32Platform platform, dstring windowCaption, Window parent, uint flags) {
- Win32Window w32parent = cast(Win32Window)parent;
- HWND parenthwnd = w32parent ? w32parent._hwnd : null;
- _platform = platform;
- _caption = windowCaption;
- _flags = flags;
- uint ws = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
- if (flags & WindowFlag.Resizable)
- ws |= WS_OVERLAPPEDWINDOW;
- else
- ws |= WS_OVERLAPPED | WS_CAPTION | WS_CAPTION | WS_BORDER | WS_SYSMENU;
- //if (flags & WindowFlag.Fullscreen)
- // ws |= SDL_WINDOW_FULLSCREEN;
- _hwnd = CreateWindow(toUTF16z(WIN_CLASS_NAME), // window class name
- toUTF16z(windowCaption), // window caption
- ws, // window style
- CW_USEDEFAULT, // initial x position
- CW_USEDEFAULT, // initial y position
- CW_USEDEFAULT, // initial x size
- CW_USEDEFAULT, // initial y size
- parenthwnd, // parent window handle
- null, // window menu handle
- _hInstance, // program instance handle
- cast(void*)this); // creation parameters
-
- version (USE_OPENGL) {
- import derelict.opengl3.wgl;
-
+ HPALETTE _hPalette;
+ }
+ dstring _caption;
+ Win32ColorDrawBuf _drawbuf;
+ bool useOpengl;
+ uint _flags;
+ this(Win32Platform platform, dstring windowCaption, Window parent, uint flags) {
+ Win32Window w32parent = cast(Win32Window)parent;
+ HWND parenthwnd = w32parent ? w32parent._hwnd : null;
+ _platform = platform;
+ _caption = windowCaption;
+ _flags = flags;
+ uint ws = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ if (flags & WindowFlag.Resizable)
+ ws |= WS_OVERLAPPEDWINDOW;
+ else
+ ws |= WS_OVERLAPPED | WS_CAPTION | WS_CAPTION | WS_BORDER | WS_SYSMENU;
+ //if (flags & WindowFlag.Fullscreen)
+ // ws |= SDL_WINDOW_FULLSCREEN;
+ _hwnd = CreateWindow(toUTF16z(WIN_CLASS_NAME), // window class name
+ toUTF16z(windowCaption), // window caption
+ ws, // window style
+ CW_USEDEFAULT, // initial x position
+ CW_USEDEFAULT, // initial y position
+ CW_USEDEFAULT, // initial x size
+ CW_USEDEFAULT, // initial y size
+ parenthwnd, // parent window handle
+ null, // window menu handle
+ _hInstance, // program instance handle
+ cast(void*)this); // creation parameters
+
+ version (USE_OPENGL) {
+ import derelict.opengl3.wgl;
+
/* initialize OpenGL rendering */
HDC hDC = GetDC(_hwnd);
@@ -173,65 +173,65 @@ class Win32Window : Window {
_hPalette = setupPalette(hDC);
_hGLRC = wglCreateContext(hDC);
if (_hGLRC) {
- wglMakeCurrent(hDC, _hGLRC);
-
- if (!DERELICT_GL3_RELOADED) {
- // run this code only once
- DERELICT_GL3_RELOADED = true;
- try {
- import derelict.opengl3.gl3;
- DerelictGL3.reload();
- // successful
- if (initShaders()) {
- setOpenglEnabled();
- useOpengl = true;
- } else {
- Log.e("Failed to compile shaders");
- }
- } catch (Exception e) {
- Log.e("Derelict exception", e);
- }
- } else {
- if (initShaders()) {
- setOpenglEnabled();
- useOpengl = true;
- } else {
- Log.e("Failed to compile shaders");
- }
- }
- }
- } else {
- Log.e("Pixelformat failed");
- // disable GL
- DERELICT_GL3_RELOADED = true;
- }
- }
- }
- }
-
- version (USE_OPENGL) {
- private void paintUsingOpenGL() {
- // hack to stop infinite WM_PAINT loop
- PAINTSTRUCT ps;
- HDC hdc2 = BeginPaint(_hwnd, &ps);
- EndPaint(_hwnd, &ps);
-
-
- import derelict.opengl3.gl3;
- import derelict.opengl3.wgl;
- import dlangui.graphics.gldrawbuf;
- //Log.d("onPaint() start drawing opengl viewport: ", _dx, "x", _dy);
- //PAINTSTRUCT ps;
- //HDC hdc = BeginPaint(_hwnd, &ps);
- //scope(exit) EndPaint(_hwnd, &ps);
+ wglMakeCurrent(hDC, _hGLRC);
+
+ if (!DERELICT_GL3_RELOADED) {
+ // run this code only once
+ DERELICT_GL3_RELOADED = true;
+ try {
+ import derelict.opengl3.gl3;
+ DerelictGL3.reload();
+ // successful
+ if (initShaders()) {
+ setOpenglEnabled();
+ useOpengl = true;
+ } else {
+ Log.e("Failed to compile shaders");
+ }
+ } catch (Exception e) {
+ Log.e("Derelict exception", e);
+ }
+ } else {
+ if (initShaders()) {
+ setOpenglEnabled();
+ useOpengl = true;
+ } else {
+ Log.e("Failed to compile shaders");
+ }
+ }
+ }
+ } else {
+ Log.e("Pixelformat failed");
+ // disable GL
+ DERELICT_GL3_RELOADED = true;
+ }
+ }
+ }
+ }
+
+ version (USE_OPENGL) {
+ private void paintUsingOpenGL() {
+ // hack to stop infinite WM_PAINT loop
+ PAINTSTRUCT ps;
+ HDC hdc2 = BeginPaint(_hwnd, &ps);
+ EndPaint(_hwnd, &ps);
+
+
+ import derelict.opengl3.gl3;
+ import derelict.opengl3.wgl;
+ import dlangui.graphics.gldrawbuf;
+ //Log.d("onPaint() start drawing opengl viewport: ", _dx, "x", _dy);
+ //PAINTSTRUCT ps;
+ //HDC hdc = BeginPaint(_hwnd, &ps);
+ //scope(exit) EndPaint(_hwnd, &ps);
HDC hdc = GetDC(_hwnd);
- wglMakeCurrent(hdc, _hGLRC);
- glDisable(GL_DEPTH_TEST);
- glViewport(0, 0, _dx, _dy);
- float a = 1.0f;
- float r = ((_backgroundColor >> 16) & 255) / 255.0f;
- float g = ((_backgroundColor >> 8) & 255) / 255.0f;
- float b = ((_backgroundColor >> 0) & 255) / 255.0f;
+ wglMakeCurrent(hdc, _hGLRC);
+ glDisable(GL_DEPTH_TEST);
+ glViewport(0, 0, _dx, _dy);
+ float a = 1.0f;
+ float r = ((_backgroundColor >> 16) & 255) / 255.0f;
+ float g = ((_backgroundColor >> 8) & 255) / 255.0f;
+ float b = ((_backgroundColor >> 0) & 255) / 255.0f;
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
@@ -249,375 +249,375 @@ class Win32Window : Window {
FontRef fnt = currentTheme.font;
fnt.drawText(buf, 40, 40, "Some Text 1234567890 !@#$^*", 0x80FF0000);
} else {
- onDraw(buf);
- }
+ onDraw(buf);
+ }
buf.afterDrawing();
- SwapBuffers(hdc);
- wglMakeCurrent(hdc, null);
- }
- }
-
- ~this() {
- debug Log.d("Window destructor");
- version (USE_OPENGL) {
- import derelict.opengl3.wgl;
- if (_hGLRC) {
- uninitShaders();
- wglMakeCurrent (null, null) ;
- wglDeleteContext(_hGLRC);
- _hGLRC = null;
- }
- }
- if (_hwnd)
- DestroyWindow(_hwnd);
- _hwnd = null;
- }
- Win32ColorDrawBuf getDrawBuf() {
- //RECT rect;
- //GetClientRect(_hwnd, &rect);
- //int dx = rect.right - rect.left;
- //int dy = rect.bottom - rect.top;
- if (_drawbuf is null)
- _drawbuf = new Win32ColorDrawBuf(_dx, _dy);
- else
- _drawbuf.resize(_dx, _dy);
- return _drawbuf;
- }
- override void show() {
- ReleaseCapture();
- if (!(_flags & WindowFlag.Resizable) && _mainWidget) {
- _mainWidget.measure(SIZE_UNSPECIFIED, SIZE_UNSPECIFIED);
- int dx = _mainWidget.measuredWidth;
- int dy = _mainWidget.measuredHeight;
- dx += 2 * GetSystemMetrics(SM_CXDLGFRAME);
- dy += GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYDLGFRAME);
- // TODO: ensure size less than screen size
- SetWindowPos(_hwnd, HWND_TOP, 0, 0, dx, dy, SWP_NOMOVE| SWP_SHOWWINDOW);
- } else {
- ShowWindow(_hwnd, SW_SHOWNORMAL);
- }
- SetFocus(_hwnd);
- //UpdateWindow(_hwnd);
- }
-
- override @property dstring windowCaption() {
- return _caption;
- }
-
- override @property void windowCaption(dstring caption) {
- _caption = caption;
- if (_hwnd)
- SetWindowTextW(_hwnd, toUTF16z(_caption));
- }
- void onCreate() {
- Log.d("Window onCreate");
- _platform.onWindowCreated(_hwnd, this);
- }
- void onDestroy() {
- Log.d("Window onDestroy");
- _platform.onWindowDestroyed(_hwnd, this);
- }
-
- /// close window
- override void close() {
- Log.d("Window.close()");
- _platform.closeWindow(this);
- }
-
- HICON _icon;
-
- /// sets window icon
- @property override void windowIcon(DrawBufRef buf) {
- if (_icon)
- DestroyIcon(_icon);
- _icon = null;
- ColorDrawBuf icon = cast(ColorDrawBuf)buf.get;
- if (!icon) {
- Log.e("Trying to set null icon for window");
- return;
- }
- Win32ColorDrawBuf resizedicon = new Win32ColorDrawBuf(icon, 32, 32);
- resizedicon.invertAlpha();
- ICONINFO ii;
- HBITMAP mask = resizedicon.createTransparencyBitmap();
- HBITMAP color = resizedicon.destoryLeavingBitmap();
- ii.fIcon = TRUE;
- ii.xHotspot = 0;
- ii.yHotspot = 0;
- ii.hbmMask = mask;
- ii.hbmColor = color;
- _icon = CreateIconIndirect(&ii);
- if (_icon) {
- SendMessage(_hwnd, WM_SETICON, ICON_SMALL, cast(int)_icon);
- SendMessage(_hwnd, WM_SETICON, ICON_BIG, cast(int)_icon);
- } else {
- Log.e("failed to create icon");
- }
- if (mask)
- DeleteObject(mask);
- DeleteObject(color);
- }
-
- private void paintUsingGDI() {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(_hwnd, &ps);
- scope(exit) EndPaint(_hwnd, &ps);
-
- Win32ColorDrawBuf buf = getDrawBuf();
- buf.fill(_backgroundColor);
- onDraw(buf);
- buf.drawTo(hdc, 0, 0);
- }
-
- void onPaint() {
- Log.d("onPaint()");
- long paintStart = currentTimeMillis;
- version (USE_OPENGL) {
- if (useOpengl && _hGLRC) {
- paintUsingOpenGL();
- } else {
- paintUsingGDI();
- }
- } else {
- paintUsingGDI();
- }
- long paintEnd = currentTimeMillis;
- Log.d("WM_PAINT handling took ", paintEnd - paintStart, " ms");
- }
-
+ SwapBuffers(hdc);
+ wglMakeCurrent(hdc, null);
+ }
+ }
+
+ ~this() {
+ debug Log.d("Window destructor");
+ version (USE_OPENGL) {
+ import derelict.opengl3.wgl;
+ if (_hGLRC) {
+ uninitShaders();
+ wglMakeCurrent (null, null) ;
+ wglDeleteContext(_hGLRC);
+ _hGLRC = null;
+ }
+ }
+ if (_hwnd)
+ DestroyWindow(_hwnd);
+ _hwnd = null;
+ }
+ Win32ColorDrawBuf getDrawBuf() {
+ //RECT rect;
+ //GetClientRect(_hwnd, &rect);
+ //int dx = rect.right - rect.left;
+ //int dy = rect.bottom - rect.top;
+ if (_drawbuf is null)
+ _drawbuf = new Win32ColorDrawBuf(_dx, _dy);
+ else
+ _drawbuf.resize(_dx, _dy);
+ return _drawbuf;
+ }
+ override void show() {
+ ReleaseCapture();
+ if (!(_flags & WindowFlag.Resizable) && _mainWidget) {
+ _mainWidget.measure(SIZE_UNSPECIFIED, SIZE_UNSPECIFIED);
+ int dx = _mainWidget.measuredWidth;
+ int dy = _mainWidget.measuredHeight;
+ dx += 2 * GetSystemMetrics(SM_CXDLGFRAME);
+ dy += GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYDLGFRAME);
+ // TODO: ensure size less than screen size
+ SetWindowPos(_hwnd, HWND_TOP, 0, 0, dx, dy, SWP_NOMOVE| SWP_SHOWWINDOW);
+ } else {
+ ShowWindow(_hwnd, SW_SHOWNORMAL);
+ }
+ SetFocus(_hwnd);
+ //UpdateWindow(_hwnd);
+ }
+
+ override @property dstring windowCaption() {
+ return _caption;
+ }
+
+ override @property void windowCaption(dstring caption) {
+ _caption = caption;
+ if (_hwnd)
+ SetWindowTextW(_hwnd, toUTF16z(_caption));
+ }
+ void onCreate() {
+ Log.d("Window onCreate");
+ _platform.onWindowCreated(_hwnd, this);
+ }
+ void onDestroy() {
+ Log.d("Window onDestroy");
+ _platform.onWindowDestroyed(_hwnd, this);
+ }
+
+ /// close window
+ override void close() {
+ Log.d("Window.close()");
+ _platform.closeWindow(this);
+ }
+
+ HICON _icon;
+
+ /// sets window icon
+ @property override void windowIcon(DrawBufRef buf) {
+ if (_icon)
+ DestroyIcon(_icon);
+ _icon = null;
+ ColorDrawBuf icon = cast(ColorDrawBuf)buf.get;
+ if (!icon) {
+ Log.e("Trying to set null icon for window");
+ return;
+ }
+ Win32ColorDrawBuf resizedicon = new Win32ColorDrawBuf(icon, 32, 32);
+ resizedicon.invertAlpha();
+ ICONINFO ii;
+ HBITMAP mask = resizedicon.createTransparencyBitmap();
+ HBITMAP color = resizedicon.destoryLeavingBitmap();
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0;
+ ii.yHotspot = 0;
+ ii.hbmMask = mask;
+ ii.hbmColor = color;
+ _icon = CreateIconIndirect(&ii);
+ if (_icon) {
+ SendMessage(_hwnd, WM_SETICON, ICON_SMALL, cast(int)_icon);
+ SendMessage(_hwnd, WM_SETICON, ICON_BIG, cast(int)_icon);
+ } else {
+ Log.e("failed to create icon");
+ }
+ if (mask)
+ DeleteObject(mask);
+ DeleteObject(color);
+ }
+
+ private void paintUsingGDI() {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(_hwnd, &ps);
+ scope(exit) EndPaint(_hwnd, &ps);
+
+ Win32ColorDrawBuf buf = getDrawBuf();
+ buf.fill(_backgroundColor);
+ onDraw(buf);
+ buf.drawTo(hdc, 0, 0);
+ }
+
+ void onPaint() {
+ Log.d("onPaint()");
+ long paintStart = currentTimeMillis;
+ version (USE_OPENGL) {
+ if (useOpengl && _hGLRC) {
+ paintUsingOpenGL();
+ } else {
+ paintUsingGDI();
+ }
+ } else {
+ paintUsingGDI();
+ }
+ long paintEnd = currentTimeMillis;
+ Log.d("WM_PAINT handling took ", paintEnd - paintStart, " ms");
+ }
+
protected ButtonDetails _lbutton;
protected ButtonDetails _mbutton;
protected ButtonDetails _rbutton;
-
- private bool _mouseTracking;
- private bool onMouse(uint message, uint flags, short x, short y) {
- //Log.d("Win32 Mouse Message ", message, " flags=", flags, " x=", x, " y=", y);
- MouseButton button = MouseButton.None;
- MouseAction action = MouseAction.ButtonDown;
- ButtonDetails * pbuttonDetails = null;
- short wheelDelta = 0;
- switch (message) {
- case WM_MOUSEMOVE:
- action = MouseAction.Move;
- break;
- case WM_LBUTTONDOWN:
- action = MouseAction.ButtonDown;
- button = MouseButton.Left;
- pbuttonDetails = &_lbutton;
- break;
- case WM_RBUTTONDOWN:
- action = MouseAction.ButtonDown;
- button = MouseButton.Right;
- pbuttonDetails = &_rbutton;
- break;
- case WM_MBUTTONDOWN:
- action = MouseAction.ButtonDown;
- button = MouseButton.Middle;
- pbuttonDetails = &_mbutton;
- break;
- case WM_LBUTTONUP:
- action = MouseAction.ButtonUp;
- button = MouseButton.Left;
- pbuttonDetails = &_lbutton;
- break;
- case WM_RBUTTONUP:
- action = MouseAction.ButtonUp;
- button = MouseButton.Right;
- pbuttonDetails = &_rbutton;
- break;
- case WM_MBUTTONUP:
- action = MouseAction.ButtonUp;
- button = MouseButton.Middle;
- pbuttonDetails = &_mbutton;
- break;
- case WM_MOUSELEAVE:
- Log.d("WM_MOUSELEAVE");
- action = MouseAction.Leave;
- break;
- case WM_MOUSEWHEEL:
- {
- action = MouseAction.Wheel;
- wheelDelta = (cast(short)(flags >> 16)) / 120;
- POINT pt;
- pt.x = x;
- pt.y = y;
- ScreenToClient(_hwnd, &pt);
- x = cast(short)pt.x;
- y = cast(short)pt.y;
- }
- break;
- default:
- // unsupported event
- return false;
- }
- if (action == MouseAction.ButtonDown) {
- pbuttonDetails.down(x, y, cast(ushort)flags);
- } else if (action == MouseAction.ButtonUp) {
- pbuttonDetails.up(x, y, cast(ushort)flags);
- }
- if (((message == WM_MOUSELEAVE) || (x < 0 || y < 0 || x > _dx || y > _dy)) && _mouseTracking) {
- action = MouseAction.Leave;
- Log.d("WM_MOUSELEAVE - releasing capture");
- _mouseTracking = false;
- ReleaseCapture();
- }
- if (message != WM_MOUSELEAVE && !_mouseTracking) {
- if (x >=0 && y >= 0 && x < _dx && y < _dy) {
- Log.d("Setting capture");
- _mouseTracking = true;
- SetCapture(_hwnd);
- }
- }
- MouseEvent event = new MouseEvent(action, button, cast(ushort)flags, x, y, wheelDelta);
- event.lbutton = _lbutton;
- event.rbutton = _rbutton;
- event.mbutton = _mbutton;
- bool res = dispatchMouseEvent(event);
- if (res) {
- Log.d("Calling update() after mouse event");
- update();
- }
- return res;
- }
-
-
- protected uint _keyFlags;
-
- protected void updateKeyFlags(KeyAction action, KeyFlag flag) {
- if (action == KeyAction.KeyDown)
- _keyFlags |= flag;
- else
- _keyFlags &= ~flag;
- }
-
- bool onKey(KeyAction action, uint keyCode, int repeatCount, dchar character = 0) {
- KeyEvent event;
- if (action == KeyAction.KeyDown || action == KeyAction.KeyUp) {
- switch(keyCode) {
- case KeyCode.SHIFT:
- updateKeyFlags(action, KeyFlag.Shift);
- break;
- case KeyCode.CONTROL:
- updateKeyFlags(action, KeyFlag.Control);
- break;
- case KeyCode.ALT:
- updateKeyFlags(action, KeyFlag.Alt);
- break;
- default:
- break;
- }
- event = new KeyEvent(action, keyCode, _keyFlags);
- } else if (action == KeyAction.Text && character != 0) {
- dchar[] text;
- text ~= character;
- event = new KeyEvent(action, 0, _keyFlags, cast(dstring)text);
- }
- bool res = false;
- if (event !is null) {
- res = dispatchKeyEvent(event);
- }
- if (res) {
- Log.d("Calling update() after key event");
- update();
- }
- return res;
- }
-
- /// request window redraw
- override void invalidate() {
- InvalidateRect(_hwnd, null, FALSE);
- //UpdateWindow(_hwnd);
- }
-
- /// after drawing, call to schedule redraw if animation is active
- override void scheduleAnimation() {
- invalidate();
- }
-
-}
-
-class Win32Platform : Platform {
- this() {
- }
- bool registerWndClass() {
- //MSG msg;
- WNDCLASS wndclass;
-
- wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wndclass.lpfnWndProc = &WndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = _hInstance;
- wndclass.hIcon = LoadIcon(null, IDI_APPLICATION);
- wndclass.hCursor = LoadCursor(null, IDC_ARROW);
- wndclass.hbrBackground = cast(HBRUSH)GetStockObject(WHITE_BRUSH);
- wndclass.lpszMenuName = null;
- wndclass.lpszClassName = toUTF16z(WIN_CLASS_NAME);
-
- if(!RegisterClass(&wndclass))
- {
- return false;
- }
- return true;
- }
- override int enterMessageLoop() {
- MSG msg;
- while (GetMessage(&msg, null, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
- private Win32Window[ulong] _windowMap;
- /// add window to window map
- void onWindowCreated(HWND hwnd, Win32Window window) {
- _windowMap[cast(ulong)hwnd] = window;
- }
- /// remove window from window map, returns true if there are some more windows left in map
- bool onWindowDestroyed(HWND hwnd, Win32Window window) {
- Win32Window wnd = getWindow(hwnd);
- if (wnd) {
- _windowMap.remove(cast(ulong)hwnd);
- destroy(window);
- }
- return _windowMap.length > 0;
- }
- /// returns number of currently active windows
- @property int windowCount() {
- return cast(int)_windowMap.length;
- }
- /// returns window instance by HWND
- Win32Window getWindow(HWND hwnd) {
- if ((cast(ulong)hwnd) in _windowMap)
- return _windowMap[cast(ulong)hwnd];
- return null;
- }
- override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable) {
- return new Win32Window(this, windowCaption, parent, flags);
- }
-
- /// calls request layout for all windows
- override void requestLayout() {
- foreach(w; _windowMap) {
- w.requestLayout();
- w.invalidate();
- }
- }
-
- Win32Window _windowToClose;
-
- /// close window
- override void closeWindow(Window w) {
- Win32Window window = cast(Win32Window)w;
- _windowToClose = window;
- }
-
- /// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
- override dstring getClipboardText(bool mouseBuffer = false) {
- dstring res = null;
- if (mouseBuffer)
- return res; // not supporetd under win32
+
+ private bool _mouseTracking;
+ private bool onMouse(uint message, uint flags, short x, short y) {
+ //Log.d("Win32 Mouse Message ", message, " flags=", flags, " x=", x, " y=", y);
+ MouseButton button = MouseButton.None;
+ MouseAction action = MouseAction.ButtonDown;
+ ButtonDetails * pbuttonDetails = null;
+ short wheelDelta = 0;
+ switch (message) {
+ case WM_MOUSEMOVE:
+ action = MouseAction.Move;
+ break;
+ case WM_LBUTTONDOWN:
+ action = MouseAction.ButtonDown;
+ button = MouseButton.Left;
+ pbuttonDetails = &_lbutton;
+ break;
+ case WM_RBUTTONDOWN:
+ action = MouseAction.ButtonDown;
+ button = MouseButton.Right;
+ pbuttonDetails = &_rbutton;
+ break;
+ case WM_MBUTTONDOWN:
+ action = MouseAction.ButtonDown;
+ button = MouseButton.Middle;
+ pbuttonDetails = &_mbutton;
+ break;
+ case WM_LBUTTONUP:
+ action = MouseAction.ButtonUp;
+ button = MouseButton.Left;
+ pbuttonDetails = &_lbutton;
+ break;
+ case WM_RBUTTONUP:
+ action = MouseAction.ButtonUp;
+ button = MouseButton.Right;
+ pbuttonDetails = &_rbutton;
+ break;
+ case WM_MBUTTONUP:
+ action = MouseAction.ButtonUp;
+ button = MouseButton.Middle;
+ pbuttonDetails = &_mbutton;
+ break;
+ case WM_MOUSELEAVE:
+ Log.d("WM_MOUSELEAVE");
+ action = MouseAction.Leave;
+ break;
+ case WM_MOUSEWHEEL:
+ {
+ action = MouseAction.Wheel;
+ wheelDelta = (cast(short)(flags >> 16)) / 120;
+ POINT pt;
+ pt.x = x;
+ pt.y = y;
+ ScreenToClient(_hwnd, &pt);
+ x = cast(short)pt.x;
+ y = cast(short)pt.y;
+ }
+ break;
+ default:
+ // unsupported event
+ return false;
+ }
+ if (action == MouseAction.ButtonDown) {
+ pbuttonDetails.down(x, y, cast(ushort)flags);
+ } else if (action == MouseAction.ButtonUp) {
+ pbuttonDetails.up(x, y, cast(ushort)flags);
+ }
+ if (((message == WM_MOUSELEAVE) || (x < 0 || y < 0 || x > _dx || y > _dy)) && _mouseTracking) {
+ action = MouseAction.Leave;
+ Log.d("WM_MOUSELEAVE - releasing capture");
+ _mouseTracking = false;
+ ReleaseCapture();
+ }
+ if (message != WM_MOUSELEAVE && !_mouseTracking) {
+ if (x >=0 && y >= 0 && x < _dx && y < _dy) {
+ Log.d("Setting capture");
+ _mouseTracking = true;
+ SetCapture(_hwnd);
+ }
+ }
+ MouseEvent event = new MouseEvent(action, button, cast(ushort)flags, x, y, wheelDelta);
+ event.lbutton = _lbutton;
+ event.rbutton = _rbutton;
+ event.mbutton = _mbutton;
+ bool res = dispatchMouseEvent(event);
+ if (res) {
+ Log.d("Calling update() after mouse event");
+ update();
+ }
+ return res;
+ }
+
+
+ protected uint _keyFlags;
+
+ protected void updateKeyFlags(KeyAction action, KeyFlag flag) {
+ if (action == KeyAction.KeyDown)
+ _keyFlags |= flag;
+ else
+ _keyFlags &= ~flag;
+ }
+
+ bool onKey(KeyAction action, uint keyCode, int repeatCount, dchar character = 0) {
+ KeyEvent event;
+ if (action == KeyAction.KeyDown || action == KeyAction.KeyUp) {
+ switch(keyCode) {
+ case KeyCode.SHIFT:
+ updateKeyFlags(action, KeyFlag.Shift);
+ break;
+ case KeyCode.CONTROL:
+ updateKeyFlags(action, KeyFlag.Control);
+ break;
+ case KeyCode.ALT:
+ updateKeyFlags(action, KeyFlag.Alt);
+ break;
+ default:
+ break;
+ }
+ event = new KeyEvent(action, keyCode, _keyFlags);
+ } else if (action == KeyAction.Text && character != 0) {
+ dchar[] text;
+ text ~= character;
+ event = new KeyEvent(action, 0, _keyFlags, cast(dstring)text);
+ }
+ bool res = false;
+ if (event !is null) {
+ res = dispatchKeyEvent(event);
+ }
+ if (res) {
+ Log.d("Calling update() after key event");
+ update();
+ }
+ return res;
+ }
+
+ /// request window redraw
+ override void invalidate() {
+ InvalidateRect(_hwnd, null, FALSE);
+ //UpdateWindow(_hwnd);
+ }
+
+ /// after drawing, call to schedule redraw if animation is active
+ override void scheduleAnimation() {
+ invalidate();
+ }
+
+}
+
+class Win32Platform : Platform {
+ this() {
+ }
+ bool registerWndClass() {
+ //MSG msg;
+ WNDCLASS wndclass;
+
+ wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wndclass.lpfnWndProc = &WndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = _hInstance;
+ wndclass.hIcon = LoadIcon(null, IDI_APPLICATION);
+ wndclass.hCursor = LoadCursor(null, IDC_ARROW);
+ wndclass.hbrBackground = cast(HBRUSH)GetStockObject(WHITE_BRUSH);
+ wndclass.lpszMenuName = null;
+ wndclass.lpszClassName = toUTF16z(WIN_CLASS_NAME);
+
+ if(!RegisterClass(&wndclass))
+ {
+ return false;
+ }
+ return true;
+ }
+ override int enterMessageLoop() {
+ MSG msg;
+ while (GetMessage(&msg, null, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return msg.wParam;
+ }
+ private Win32Window[ulong] _windowMap;
+ /// add window to window map
+ void onWindowCreated(HWND hwnd, Win32Window window) {
+ _windowMap[cast(ulong)hwnd] = window;
+ }
+ /// remove window from window map, returns true if there are some more windows left in map
+ bool onWindowDestroyed(HWND hwnd, Win32Window window) {
+ Win32Window wnd = getWindow(hwnd);
+ if (wnd) {
+ _windowMap.remove(cast(ulong)hwnd);
+ destroy(window);
+ }
+ return _windowMap.length > 0;
+ }
+ /// returns number of currently active windows
+ @property int windowCount() {
+ return cast(int)_windowMap.length;
+ }
+ /// returns window instance by HWND
+ Win32Window getWindow(HWND hwnd) {
+ if ((cast(ulong)hwnd) in _windowMap)
+ return _windowMap[cast(ulong)hwnd];
+ return null;
+ }
+ override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable) {
+ return new Win32Window(this, windowCaption, parent, flags);
+ }
+
+ /// calls request layout for all windows
+ override void requestLayout() {
+ foreach(w; _windowMap) {
+ w.requestLayout();
+ w.invalidate();
+ }
+ }
+
+ Win32Window _windowToClose;
+
+ /// close window
+ override void closeWindow(Window w) {
+ Win32Window window = cast(Win32Window)w;
+ _windowToClose = window;
+ }
+
+ /// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
+ override dstring getClipboardText(bool mouseBuffer = false) {
+ dstring res = null;
+ if (mouseBuffer)
+ return res; // not supporetd under win32
if (!IsClipboardFormatAvailable(CF_UNICODETEXT))
return res;
if (!OpenClipboard(NULL))
@@ -637,120 +637,120 @@ class Win32Platform : Platform {
}
CloseClipboard();
- //Log.d("getClipboardText(", res, ")");
- return res;
- }
-
- /// sets text to clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
- override void setClipboardText(dstring text, bool mouseBuffer = false) {
- //Log.d("setClipboardText(", text, ")");
- if (text.length < 1 || mouseBuffer)
- return;
+ //Log.d("getClipboardText(", res, ")");
+ return res;
+ }
+
+ /// sets text to clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
+ override void setClipboardText(dstring text, bool mouseBuffer = false) {
+ //Log.d("setClipboardText(", text, ")");
+ if (text.length < 1 || mouseBuffer)
+ return;
if (!OpenClipboard(NULL))
return;
- EmptyClipboard();
- wstring w = toUTF16(text);
+ EmptyClipboard();
+ wstring w = toUTF16(text);
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
(w.length + 1) * TCHAR.sizeof);
if (hglbCopy == NULL) {
CloseClipboard();
return;
- }
- LPTSTR lptstrCopy = cast(LPTSTR)GlobalLock(hglbCopy);
- for (int i = 0; i < w.length; i++) {
- lptstrCopy[i] = w[i];
- }
- lptstrCopy[w.length] = 0;
- GlobalUnlock(hglbCopy);
- SetClipboardData(CF_UNICODETEXT, hglbCopy);
+ }
+ LPTSTR lptstrCopy = cast(LPTSTR)GlobalLock(hglbCopy);
+ for (int i = 0; i < w.length; i++) {
+ lptstrCopy[i] = w[i];
+ }
+ lptstrCopy[w.length] = 0;
+ GlobalUnlock(hglbCopy);
+ SetClipboardData(CF_UNICODETEXT, hglbCopy);
CloseClipboard();
- }
-
-}
-
-extern(Windows)
-int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow) {
- int result;
-
- try
- {
- Runtime.initialize();
- result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
- Runtime.terminate();
- }
- catch (Throwable e) // catch any uncaught exceptions
- {
- MessageBox(null, toUTF16z(e.toString()), "Error",
- MB_OK | MB_ICONEXCLAMATION);
- result = 0; // failed
- }
-
- return result;
-}
-
-string[] splitCmdLine(string line) {
- string[] res;
- int start = 0;
- bool insideQuotes = false;
- for (int i = 0; i <= line.length; i++) {
- char ch = i < line.length ? line[i] : 0;
- if (ch == '\"') {
- if (insideQuotes) {
- if (i > start)
- res ~= line[start .. i];
- start = i + 1;
- insideQuotes = false;
- } else {
- insideQuotes = true;
- start = i + 1;
- }
- } else if (!insideQuotes && (ch == ' ' || ch == '\t' || ch == 0)) {
- if (i > start) {
- res ~= line[start .. i];
- }
- start = i + 1;
- }
- }
- return res;
-}
-
-private __gshared Win32Platform w32platform;
-
-int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
-{
- setFileLogger(std.stdio.File("ui.log", "w"));
- debug {
- Log.setLogLevel(LogLevel.Trace);
- } else {
- Log.setLogLevel(LogLevel.Info);
- }
- Log.d("myWinMain()");
- string basePath = exePath();
- Log.i("Current executable: ", exePath());
- string cmdline = fromStringz(lpCmdLine);
- Log.i("Command line: ", cmdline);
- string[] args = splitCmdLine(cmdline);
- Log.i("Command line params: ", args);
-
- _cmdShow = iCmdShow;
- _hInstance = hInstance;
-
- w32platform = new Win32Platform();
- if (!w32platform.registerWndClass()) {
- MessageBoxA(null, "This program requires Windows NT!", "DLANGUI App".toStringz, MB_ICONERROR);
- return 0;
- }
- Platform.setInstance(w32platform);
-
-
- /// testing freetype font manager
- static if (false) {
- import dlangui.graphics.ftfonts;
- import win32.shlobj;
- FreeTypeFontManager ftfontMan = new FreeTypeFontManager();
- string fontsPath = "c:\\Windows\\Fonts\\";
- static if (false) { // SHGetFolderPathW not found in shell32.lib
+ }
+
+}
+
+extern(Windows)
+int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow) {
+ int result;
+
+ try
+ {
+ Runtime.initialize();
+ result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+ Runtime.terminate();
+ }
+ catch (Throwable e) // catch any uncaught exceptions
+ {
+ MessageBox(null, toUTF16z(e.toString()), "Error",
+ MB_OK | MB_ICONEXCLAMATION);
+ result = 0; // failed
+ }
+
+ return result;
+}
+
+string[] splitCmdLine(string line) {
+ string[] res;
+ int start = 0;
+ bool insideQuotes = false;
+ for (int i = 0; i <= line.length; i++) {
+ char ch = i < line.length ? line[i] : 0;
+ if (ch == '\"') {
+ if (insideQuotes) {
+ if (i > start)
+ res ~= line[start .. i];
+ start = i + 1;
+ insideQuotes = false;
+ } else {
+ insideQuotes = true;
+ start = i + 1;
+ }
+ } else if (!insideQuotes && (ch == ' ' || ch == '\t' || ch == 0)) {
+ if (i > start) {
+ res ~= line[start .. i];
+ }
+ start = i + 1;
+ }
+ }
+ return res;
+}
+
+private __gshared Win32Platform w32platform;
+
+int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
+{
+ Log.setFileLogger(std.stdio.File("ui.log", "w"));
+ debug {
+ Log.setLogLevel(LogLevel.Trace);
+ } else {
+ Log.setLogLevel(LogLevel.Info);
+ }
+ Log.d("myWinMain()");
+ string basePath = exePath();
+ Log.i("Current executable: ", exePath());
+ string cmdline = fromStringz(lpCmdLine).dup;
+ Log.i("Command line: ", cmdline);
+ string[] args = splitCmdLine(cmdline);
+ Log.i("Command line params: ", args);
+
+ _cmdShow = iCmdShow;
+ _hInstance = hInstance;
+
+ w32platform = new Win32Platform();
+ if (!w32platform.registerWndClass()) {
+ MessageBoxA(null, "This program requires Windows NT!", "DLANGUI App".toStringz, MB_ICONERROR);
+ return 0;
+ }
+ Platform.setInstance(w32platform);
+
+
+ /// testing freetype font manager
+ static if (false) {
+ import dlangui.graphics.ftfonts;
+ import win32.shlobj;
+ FreeTypeFontManager ftfontMan = new FreeTypeFontManager();
+ string fontsPath = "c:\\Windows\\Fonts\\";
+ static if (false) { // SHGetFolderPathW not found in shell32.lib
WCHAR szPath[MAX_PATH];
const CSIDL_FLAG_NO_ALIAS = 0x1000;
const CSIDL_FLAG_DONT_UNEXPAND = 0x2000;
@@ -775,156 +775,156 @@ int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
ftfontMan.registerFont(fontsPath ~ "timesbd.ttf", FontFamily.Serif, "Times New Roman", false, FontWeight.Bold);
ftfontMan.registerFont(fontsPath ~ "timesbi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Bold);
ftfontMan.registerFont(fontsPath ~ "timesi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Normal);
- FontManager.instance = ftfontMan;
- }
-
- // use Win32 font manager
- if (FontManager.instance is null) {
- //Win32FontManager fontMan = new Win32FontManager();
- FontManager.instance = new Win32FontManager();
- }
-
- currentTheme = createDefaultTheme();
-
- version (USE_OPENGL) {
- import derelict.opengl3.gl3;
- DerelictGL3.load();
-
- // just to check OpenGL context
+ FontManager.instance = ftfontMan;
+ }
+
+ // use Win32 font manager
+ if (FontManager.instance is null) {
+ //Win32FontManager fontMan = new Win32FontManager();
+ FontManager.instance = new Win32FontManager();
+ }
+
+ currentTheme = createDefaultTheme();
+
+ version (USE_OPENGL) {
+ import derelict.opengl3.gl3;
+ DerelictGL3.load();
+
+ // just to check OpenGL context
Log.i("Trying to setup OpenGL context");
- Win32Window tmpWindow = new Win32Window(w32platform, ""d, null, 0);
- destroy(tmpWindow);
- if (openglEnabled)
- Log.i("OpenGL support is enabled");
- else
- Log.w("OpenGL support is disabled");
- // process messages
+ Win32Window tmpWindow = new Win32Window(w32platform, ""d, null, 0);
+ destroy(tmpWindow);
+ if (openglEnabled)
+ Log.i("OpenGL support is enabled");
+ else
+ Log.w("OpenGL support is disabled");
+ // process messages
platform.enterMessageLoop();
}
// Load versions 1.2+ and all supported ARB and EXT extensions.
-
- Log.i("Entering UIAppMain: ", args);
- int result = UIAppMain(args);
- Log.i("UIAppMain returned ", result);
- return result;
-}
-
-
-extern(Windows)
-LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- HDC hdc;
- RECT rect;
-
- void * p = cast(void*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- Win32Window windowParam = p is null ? null : cast(Win32Window)(p);
- Win32Window window = w32platform.getWindow(hwnd);
- if (windowParam !is null && window !is null)
- assert(window is windowParam);
- if (window is null && windowParam !is null) {
- Log.e("Cannot find window in map by HWND");
- }
-
- switch (message)
- {
- case WM_CREATE:
- {
- CREATESTRUCT * pcreateStruct = cast(CREATESTRUCT*)lParam;
- window = cast(Win32Window)pcreateStruct.lpCreateParams;
- void * ptr = cast(void*) window;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, cast(LONG_PTR)ptr);
- window._hwnd = hwnd;
- window.onCreate();
- }
- return 0;
- case WM_DESTROY:
- if (window !is null)
- window.onDestroy();
- if (w32platform.windowCount == 0)
- PostQuitMessage(0);
- return 0;
- case WM_WINDOWPOSCHANGED:
- {
- if (window !is null) {
- WINDOWPOS * pos = cast(WINDOWPOS*)lParam;
- GetClientRect(hwnd, &rect);
- int dx = rect.right - rect.left;
- int dy = rect.bottom - rect.top;
- //window.onResize(pos.cx, pos.cy);
- window.onResize(dx, dy);
- InvalidateRect(hwnd, null, FALSE);
- }
- }
- return 0;
- case WM_ERASEBKGND:
- // processed
- return 1;
- case WM_PAINT:
- {
- if (window !is null)
- window.onPaint();
- }
- return 0; // processed
- case WM_MOUSELEAVE:
- case WM_MOUSEMOVE:
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_MBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MOUSEWHEEL:
- if (window !is null) {
- if (window.onMouse(message, cast(uint)wParam, cast(short)(lParam & 0xFFFF), cast(short)((lParam >> 16) & 0xFFFF)))
- return 0; // processed
- }
- // not processed - default handling
- return DefWindowProc(hwnd, message, wParam, lParam);
- case WM_KEYDOWN:
- case WM_KEYUP:
- if (window !is null) {
- int repeatCount = lParam & 0xFFFF;
- if (window.onKey(message == WM_KEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, wParam, repeatCount))
- return 0; // processed
- }
- break;
- case WM_UNICHAR:
- if (window !is null) {
- int repeatCount = lParam & 0xFFFF;
- if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
- return 1; // processed
- return 1;
- }
- break;
- case WM_CHAR:
- if (window !is null) {
- int repeatCount = lParam & 0xFFFF;
- if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
- return 1; // processed
- return 1;
- }
- break;
- case WM_GETMINMAXINFO:
- case WM_NCCREATE:
- case WM_NCCALCSIZE:
- default:
- //Log.d("Unhandled message ", message);
- break;
- }
- if (w32platform._windowToClose) {
- Win32Window wnd = w32platform._windowToClose;
- w32platform._windowToClose = null;
- destroy(wnd);
- //HWND w = w32platform._windowToClose._hwnd;
- //CloseWindow(w);
- }
- return DefWindowProc(hwnd, message, wParam, lParam);
-}
-
-//===========================================
-// end of version(Windows)
-//===========================================
-}
-
-
+
+ Log.i("Entering UIAppMain: ", args);
+ int result = UIAppMain(args);
+ Log.i("UIAppMain returned ", result);
+ return result;
+}
+
+
+extern(Windows)
+LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ HDC hdc;
+ RECT rect;
+
+ void * p = cast(void*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ Win32Window windowParam = p is null ? null : cast(Win32Window)(p);
+ Win32Window window = w32platform.getWindow(hwnd);
+ if (windowParam !is null && window !is null)
+ assert(window is windowParam);
+ if (window is null && windowParam !is null) {
+ Log.e("Cannot find window in map by HWND");
+ }
+
+ switch (message)
+ {
+ case WM_CREATE:
+ {
+ CREATESTRUCT * pcreateStruct = cast(CREATESTRUCT*)lParam;
+ window = cast(Win32Window)pcreateStruct.lpCreateParams;
+ void * ptr = cast(void*) window;
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, cast(LONG_PTR)ptr);
+ window._hwnd = hwnd;
+ window.onCreate();
+ }
+ return 0;
+ case WM_DESTROY:
+ if (window !is null)
+ window.onDestroy();
+ if (w32platform.windowCount == 0)
+ PostQuitMessage(0);
+ return 0;
+ case WM_WINDOWPOSCHANGED:
+ {
+ if (window !is null) {
+ WINDOWPOS * pos = cast(WINDOWPOS*)lParam;
+ GetClientRect(hwnd, &rect);
+ int dx = rect.right - rect.left;
+ int dy = rect.bottom - rect.top;
+ //window.onResize(pos.cx, pos.cy);
+ window.onResize(dx, dy);
+ InvalidateRect(hwnd, null, FALSE);
+ }
+ }
+ return 0;
+ case WM_ERASEBKGND:
+ // processed
+ return 1;
+ case WM_PAINT:
+ {
+ if (window !is null)
+ window.onPaint();
+ }
+ return 0; // processed
+ case WM_MOUSELEAVE:
+ case WM_MOUSEMOVE:
+ case WM_LBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MOUSEWHEEL:
+ if (window !is null) {
+ if (window.onMouse(message, cast(uint)wParam, cast(short)(lParam & 0xFFFF), cast(short)((lParam >> 16) & 0xFFFF)))
+ return 0; // processed
+ }
+ // not processed - default handling
+ return DefWindowProc(hwnd, message, wParam, lParam);
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ if (window !is null) {
+ int repeatCount = lParam & 0xFFFF;
+ if (window.onKey(message == WM_KEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, wParam, repeatCount))
+ return 0; // processed
+ }
+ break;
+ case WM_UNICHAR:
+ if (window !is null) {
+ int repeatCount = lParam & 0xFFFF;
+ if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
+ return 1; // processed
+ return 1;
+ }
+ break;
+ case WM_CHAR:
+ if (window !is null) {
+ int repeatCount = lParam & 0xFFFF;
+ if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
+ return 1; // processed
+ return 1;
+ }
+ break;
+ case WM_GETMINMAXINFO:
+ case WM_NCCREATE:
+ case WM_NCCALCSIZE:
+ default:
+ //Log.d("Unhandled message ", message);
+ break;
+ }
+ if (w32platform._windowToClose) {
+ Win32Window wnd = w32platform._windowToClose;
+ w32platform._windowToClose = null;
+ destroy(wnd);
+ //HWND w = w32platform._windowToClose._hwnd;
+ //CloseWindow(w);
+ }
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+//===========================================
+// end of version(Windows)
+//===========================================
+}
+
+
diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d
index c0387fcc..076a1c70 100644
--- a/src/dlangui/widgets/grid.d
+++ b/src/dlangui/widgets/grid.d
@@ -527,61 +527,61 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
return false; // same position
if (col < _headerCols || row < _headerRows || col >= _cols || row >= _rows)
return false; // out of range
- _col = col;
- _row = row;
- invalidate();
+ _col = col;
+ _row = row;
+ invalidate();
calcScrollableAreaPos();
- if (makeVisible)
- makeCellVisible(_col, _row);
- return true;
+ if (makeVisible)
+ makeCellVisible(_col, _row);
+ return true;
}
- /// handle mouse wheel events
- override bool onMouseEvent(MouseEvent event) {
- if (visibility != Visibility.Visible)
- return false;
- int c, r; // col, row
- Rect rc;
- bool cellFound = false;
- bool normalCell = false;
- // convert coordinates
- if (event.action == MouseAction.ButtonUp || event.action == MouseAction.ButtonDown || event.action == MouseAction.Move) {
- int x = event.x;
- int y = event.y;
- x -= _clientRect.left;
- y -= _clientRect.top;
- cellFound = pointToCell(x, y, c, r, rc);
- normalCell = c >= _headerCols && r >= _headerRows;
- }
- if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
- if (cellFound && normalCell) {
- selectCell(c, r);
- }
- return true;
- }
- if (event.action == MouseAction.Move && (event.flags & MouseFlag.LButton)) {
- // TODO: selection
- if (cellFound && normalCell) {
- selectCell(c, r);
- }
- return true;
- }
- if (event.action == MouseAction.Wheel) {
- if (event.flags & MouseFlag.Shift)
- scrollBy(-event.wheelDelta, 0);
- else
- scrollBy(0, -event.wheelDelta);
- return true;
- }
- return super.onMouseEvent(event);
- }
-
-
- /// calculate scrollable area info
- protected void calcScrollableAreaPos() {
- _maxScrollCol = _maxScrollRow = 0;
- _fullyVisibleCells.left = _headerCols + _fixedCols + _scrollCol;
- _fullyVisibleCells.top = _headerRows + _fixedRows + _scrollRow;
+ /// handle mouse wheel events
+ override bool onMouseEvent(MouseEvent event) {
+ if (visibility != Visibility.Visible)
+ return false;
+ int c, r; // col, row
+ Rect rc;
+ bool cellFound = false;
+ bool normalCell = false;
+ // convert coordinates
+ if (event.action == MouseAction.ButtonUp || event.action == MouseAction.ButtonDown || event.action == MouseAction.Move) {
+ int x = event.x;
+ int y = event.y;
+ x -= _clientRect.left;
+ y -= _clientRect.top;
+ cellFound = pointToCell(x, y, c, r, rc);
+ normalCell = c >= _headerCols && r >= _headerRows;
+ }
+ if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
+ if (cellFound && normalCell) {
+ selectCell(c, r);
+ }
+ return true;
+ }
+ if (event.action == MouseAction.Move && (event.flags & MouseFlag.LButton)) {
+ // TODO: selection
+ if (cellFound && normalCell) {
+ selectCell(c, r);
+ }
+ return true;
+ }
+ if (event.action == MouseAction.Wheel) {
+ if (event.flags & MouseFlag.Shift)
+ scrollBy(-event.wheelDelta, 0);
+ else
+ scrollBy(0, -event.wheelDelta);
+ return true;
+ }
+ return super.onMouseEvent(event);
+ }
+
+
+ /// calculate scrollable area info
+ protected void calcScrollableAreaPos() {
+ _maxScrollCol = _maxScrollRow = 0;
+ _fullyVisibleCells.left = _headerCols + _fixedCols + _scrollCol;
+ _fullyVisibleCells.top = _headerRows + _fixedRows + _scrollRow;
Rect rc;
int xx = 0;
for (int i = 0; i < _cols && xx < _clientRect.width; i++) {
@@ -607,12 +607,12 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
yy += w;
}
- int maxVisibleScrollWidth = _clientRect.width - _fullyVisibleCellsRect.left;
- int maxVisibleScrollHeight = _clientRect.height - _fullyVisibleCellsRect.top;
- if (maxVisibleScrollWidth < 0)
- maxVisibleScrollWidth = 0;
- if (maxVisibleScrollHeight < 0)
- maxVisibleScrollHeight = 0;
+ int maxVisibleScrollWidth = _clientRect.width - _fullyVisibleCellsRect.left;
+ int maxVisibleScrollHeight = _clientRect.height - _fullyVisibleCellsRect.top;
+ if (maxVisibleScrollWidth < 0)
+ maxVisibleScrollWidth = 0;
+ if (maxVisibleScrollHeight < 0)
+ maxVisibleScrollHeight = 0;
// calc scroll area in pixels
@@ -632,17 +632,17 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
if (i >= _fullyVisibleCells.left) {
_visibleScrollableArea.right = xx;
}
- }
- xx = 0;
- for (int i = _cols - 1; i >= _headerCols + _fixedCols; i--) {
- int w = _colWidths[i];
- if (xx + w > maxVisibleScrollWidth) {
- _fullScrollableArea.right += maxVisibleScrollWidth - xx;
- break;
- }
- _maxScrollCol = i - _headerCols - _fixedCols;
- xx += w;
- }
+ }
+ xx = 0;
+ for (int i = _cols - 1; i >= _headerCols + _fixedCols; i--) {
+ int w = _colWidths[i];
+ if (xx + w > maxVisibleScrollWidth) {
+ _fullScrollableArea.right += maxVisibleScrollWidth - xx;
+ break;
+ }
+ _maxScrollCol = i - _headerCols - _fixedCols;
+ xx += w;
+ }
yy = 0;
for (int i = 0; i < _rows; i++) {
if (i == _headerRows + _fixedRows) {
@@ -659,26 +659,26 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
if (i >= _fullyVisibleCells.top) {
_visibleScrollableArea.bottom = yy;
}
- }
- yy = 0;
- for (int i = _rows - 1; i >= _headerRows + _fixedRows; i--) {
- int w = _rowHeights[i];
- if (yy + w > maxVisibleScrollHeight) {
- _fullScrollableArea.bottom += maxVisibleScrollHeight - yy;
- break;
- }
- _maxScrollRow = i - _headerRows - _fixedRows;
- yy += w;
- }
- // crop scroll area by client rect
- //if (visibleScrollableArea.width > maxVisibleScrollWidth)
- _visibleScrollableArea.right = _visibleScrollableArea.left + maxVisibleScrollWidth;
- //if (visibleScrollableArea.height > maxVisibleScrollHeight)
- _visibleScrollableArea.bottom = _visibleScrollableArea.top + maxVisibleScrollHeight;
- }
-
- protected int _maxScrollCol;
- protected int _maxScrollRow;
+ }
+ yy = 0;
+ for (int i = _rows - 1; i >= _headerRows + _fixedRows; i--) {
+ int w = _rowHeights[i];
+ if (yy + w > maxVisibleScrollHeight) {
+ _fullScrollableArea.bottom += maxVisibleScrollHeight - yy;
+ break;
+ }
+ _maxScrollRow = i - _headerRows - _fixedRows;
+ yy += w;
+ }
+ // crop scroll area by client rect
+ //if (visibleScrollableArea.width > maxVisibleScrollWidth)
+ _visibleScrollableArea.right = _visibleScrollableArea.left + maxVisibleScrollWidth;
+ //if (visibleScrollableArea.height > maxVisibleScrollHeight)
+ _visibleScrollableArea.bottom = _visibleScrollableArea.top + maxVisibleScrollHeight;
+ }
+
+ protected int _maxScrollCol;
+ protected int _maxScrollRow;
protected Rect _fullyVisibleCells;
protected Rect _fullyVisibleCellsRect;
protected Rect _fullScrollableArea;
@@ -711,26 +711,26 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
scrollBy(-1, 0);
return true;
case GridActions.Left:
- selectCell(_col - 1, _row);
+ selectCell(_col - 1, _row);
return true;
case GridActions.ScrollRight:
scrollBy(1, 0);
return true;
case GridActions.Right:
- selectCell(_col + 1, _row);
+ selectCell(_col + 1, _row);
return true;
case GridActions.ScrollUp:
scrollBy(0, -1);
return true;
case GridActions.Up:
- selectCell(_col, _row - 1);
+ selectCell(_col, _row - 1);
return true;
case GridActions.ScrollDown:
if (_fullyVisibleCells.bottom < _rows - 1)
scrollBy(0, 1);
return true;
case GridActions.Down:
- selectCell(_col, _row + 1);
+ selectCell(_col, _row + 1);
return true;
case GridActions.ScrollPageLeft:
// scroll left cell by cell
@@ -766,18 +766,18 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
return true;
case GridActions.LineBegin:
if (_scrollCol > 0 && _col > _headerCols + _fixedCols + _scrollCol && !_rowSelect)
- selectCell(_headerCols + _fixedCols + _scrollCol, _row);
- else {
+ selectCell(_headerCols + _fixedCols + _scrollCol, _row);
+ else {
if (_scrollCol > 0) {
_scrollCol = 0;
updateScrollBars();
invalidate();
}
- selectCell(_headerCols, _row);
- }
+ selectCell(_headerCols, _row);
+ }
return true;
case GridActions.LineEnd:
- selectCell(_cols - 1, _row);
+ selectCell(_cols - 1, _row);
return true;
case GridActions.DocumentBegin:
if (_scrollRow > 0) {
@@ -785,16 +785,16 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
updateScrollBars();
invalidate();
}
- selectCell(_col, _headerRows);
+ selectCell(_col, _headerRows);
return true;
case GridActions.DocumentEnd:
- selectCell(_col, _rows - 1);
+ selectCell(_col, _rows - 1);
return true;
case GridActions.PageBegin:
if (_scrollRow > 0)
- selectCell(_col, _headerRows + _fixedRows + _scrollRow);
- else
- selectCell(_col, _headerRows);
+ selectCell(_col, _headerRows + _fixedRows + _scrollRow);
+ else
+ selectCell(_col, _headerRows);
return true;
case GridActions.PageEnd:
int found = -1;
@@ -806,7 +806,7 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
break;
}
if (found >= 0)
- selectCell(_col, found);
+ selectCell(_col, found);
return true;
case GridActions.PageUp:
if (_row > _fullyVisibleCells.top) {
diff --git a/src/dlangui/widgets/lists.d b/src/dlangui/widgets/lists.d
index 401b557d..f7c2d071 100644
--- a/src/dlangui/widgets/lists.d
+++ b/src/dlangui/widgets/lists.d
@@ -406,7 +406,7 @@ class ListWidget : WidgetGroup, OnScrollHandler {
int sbsize = _orientation == Orientation.Vertical ? _scrollbar.measuredWidth : _scrollbar.measuredHeight;
// measure children
Point sz;
- _sbsz.clear;
+ _sbsz.destroy();
for (int i = 0; i < itemCount; i++) {
Widget w = itemWidget(i);
if (w is null || w.visibility == Visibility.Gone) {
diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d
index d9cf7179..926badc6 100644
--- a/src/dlangui/widgets/styles.d
+++ b/src/dlangui/widgets/styles.d
@@ -558,12 +558,12 @@ class Style {
destroy(item);
item = null;
}
- _substates.clear();
+ _substates.destroy();
foreach(ref Style item; _children) {
destroy(item);
item = null;
}
- _children.clear();
+ _children.destroy();
_backgroundDrawable.clear();
_font.clear();
debug(resalloc) _instanceCount--;
@@ -638,7 +638,7 @@ class Theme : Style {
destroy(item);
item = null;
}
- _byId.clear();
+ _byId.destroy();
}
/// create wrapper style which will have currentTheme.get(id) as parent instead of fixed parent - to modify some base style properties in widget