mirror of https://github.com/buggins/dlangui.git
commit
bde4b0d44e
|
@ -172,10 +172,10 @@ class Win32Window : Window {
|
||||||
HWND parenthwnd = w32parent ? w32parent._hwnd : null;
|
HWND parenthwnd = w32parent ? w32parent._hwnd : null;
|
||||||
_dx = width;
|
_dx = width;
|
||||||
_dy = height;
|
_dy = height;
|
||||||
if (!_dx)
|
if (!_dx)
|
||||||
_dx = 600;
|
_dx = 600;
|
||||||
if (!_dy)
|
if (!_dy)
|
||||||
_dy = 400;
|
_dy = 400;
|
||||||
_platform = platform;
|
_platform = platform;
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
_gl = new GLSupport();
|
_gl = new GLSupport();
|
||||||
|
@ -317,46 +317,46 @@ class Win32Window : Window {
|
||||||
_hwnd = null;
|
_hwnd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// post event to handle in UI thread (this method can be used from background thread)
|
/// post event to handle in UI thread (this method can be used from background thread)
|
||||||
override void postEvent(CustomEvent event) {
|
override void postEvent(CustomEvent event) {
|
||||||
super.postEvent(event);
|
super.postEvent(event);
|
||||||
PostMessageW(_hwnd, CUSTOM_MESSAGE_ID, 0, event.uniqueId);
|
PostMessageW(_hwnd, CUSTOM_MESSAGE_ID, 0, event.uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set handler for files dropped to app window
|
/// set handler for files dropped to app window
|
||||||
override @property Window onFilesDropped(void delegate(string[]) handler) {
|
override @property Window onFilesDropped(void delegate(string[]) handler) {
|
||||||
super.onFilesDropped(handler);
|
super.onFilesDropped(handler);
|
||||||
DragAcceptFiles(_hwnd, handler ? TRUE : FALSE);
|
DragAcceptFiles(_hwnd, handler ? TRUE : FALSE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long _nextExpectedTimerTs;
|
private long _nextExpectedTimerTs;
|
||||||
private UINT_PTR _timerId = 1;
|
private UINT_PTR _timerId = 1;
|
||||||
|
|
||||||
/// schedule timer for interval in milliseconds - call window.onTimer when finished
|
/// schedule timer for interval in milliseconds - call window.onTimer when finished
|
||||||
override protected void scheduleSystemTimer(long intervalMillis) {
|
override protected void scheduleSystemTimer(long intervalMillis) {
|
||||||
if (intervalMillis < 10)
|
if (intervalMillis < 10)
|
||||||
intervalMillis = 10;
|
intervalMillis = 10;
|
||||||
long nextts = currentTimeMillis + intervalMillis;
|
long nextts = currentTimeMillis + intervalMillis;
|
||||||
if (_timerId && _nextExpectedTimerTs && _nextExpectedTimerTs < nextts + 10)
|
if (_timerId && _nextExpectedTimerTs && _nextExpectedTimerTs < nextts + 10)
|
||||||
return; // don't reschedule timer, timer event will be received soon
|
return; // don't reschedule timer, timer event will be received soon
|
||||||
if (_hwnd) {
|
if (_hwnd) {
|
||||||
//_timerId =
|
//_timerId =
|
||||||
SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null);
|
SetTimer(_hwnd, _timerId, cast(uint)intervalMillis, null);
|
||||||
_nextExpectedTimerTs = nextts;
|
_nextExpectedTimerTs = nextts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleTimer(UINT_PTR timerId) {
|
void handleTimer(UINT_PTR timerId) {
|
||||||
//Log.d("handleTimer id=", timerId);
|
//Log.d("handleTimer id=", timerId);
|
||||||
if (timerId == _timerId) {
|
if (timerId == _timerId) {
|
||||||
KillTimer(_hwnd, timerId);
|
KillTimer(_hwnd, timerId);
|
||||||
//_timerId = 0;
|
//_timerId = 0;
|
||||||
_nextExpectedTimerTs = 0;
|
_nextExpectedTimerTs = 0;
|
||||||
onTimer();
|
onTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Win32ColorDrawBuf getDrawBuf() {
|
Win32ColorDrawBuf getDrawBuf() {
|
||||||
//RECT rect;
|
//RECT rect;
|
||||||
|
@ -738,9 +738,9 @@ class Win32Platform : Platform {
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HDC dc = CreateCompatibleDC(NULL);
|
HDC dc = CreateCompatibleDC(NULL);
|
||||||
SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
|
SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
DeleteObject(dc);
|
DeleteObject(dc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ class Win32Platform : Platform {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
return msg.wParam;
|
return cast(int)msg.wParam;
|
||||||
}
|
}
|
||||||
private Win32Window[ulong] _windowMap;
|
private Win32Window[ulong] _windowMap;
|
||||||
/// add window to window map
|
/// add window to window map
|
||||||
|
@ -836,7 +836,7 @@ class Win32Platform : Platform {
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
wstring w = toUTF16(text);
|
wstring w = toUTF16(text);
|
||||||
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
||||||
(w.length + 1) * TCHAR.sizeof);
|
cast(uint)((w.length + 1) * TCHAR.sizeof));
|
||||||
if (hglbCopy == NULL) {
|
if (hglbCopy == NULL) {
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
return;
|
return;
|
||||||
|
@ -1023,33 +1023,33 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
|
||||||
int result = UIAppMain(args);
|
int result = UIAppMain(args);
|
||||||
Log.i("UIAppMain returned ", result);
|
Log.i("UIAppMain returned ", result);
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
if (DrawBuf.instanceCount > 0) {
|
if (DrawBuf.instanceCount > 0) {
|
||||||
Log.e("Non-zero DrawBuf instance count when exiting: ", DrawBuf.instanceCount);
|
Log.e("Non-zero DrawBuf instance count when exiting: ", DrawBuf.instanceCount);
|
||||||
}
|
}
|
||||||
if (Style.instanceCount > 0) {
|
if (Style.instanceCount > 0) {
|
||||||
Log.e("Non-zero Style instance count when exiting: ", Style.instanceCount);
|
Log.e("Non-zero Style instance count when exiting: ", Style.instanceCount);
|
||||||
}
|
}
|
||||||
if (Widget.instanceCount() > 0) {
|
if (Widget.instanceCount() > 0) {
|
||||||
Log.e("Non-zero Widget instance count when exiting: ", Widget.instanceCount);
|
Log.e("Non-zero Widget instance count when exiting: ", Widget.instanceCount);
|
||||||
}
|
}
|
||||||
if (ImageDrawable.instanceCount > 0) {
|
if (ImageDrawable.instanceCount > 0) {
|
||||||
Log.e("Non-zero ImageDrawable instance count when exiting: ", ImageDrawable.instanceCount);
|
Log.e("Non-zero ImageDrawable instance count when exiting: ", ImageDrawable.instanceCount);
|
||||||
}
|
}
|
||||||
if (Drawable.instanceCount > 0) {
|
if (Drawable.instanceCount > 0) {
|
||||||
Log.e("Non-zero Drawable instance count when exiting: ", Drawable.instanceCount);
|
Log.e("Non-zero Drawable instance count when exiting: ", Drawable.instanceCount);
|
||||||
}
|
}
|
||||||
version (USE_FREETYPE) {
|
version (USE_FREETYPE) {
|
||||||
import dlangui.graphics.ftfonts;
|
import dlangui.graphics.ftfonts;
|
||||||
if (FreeTypeFontFile.instanceCount > 0) {
|
if (FreeTypeFontFile.instanceCount > 0) {
|
||||||
Log.e("Non-zero FreeTypeFontFile instance count when exiting: ", FreeTypeFontFile.instanceCount);
|
Log.e("Non-zero FreeTypeFontFile instance count when exiting: ", FreeTypeFontFile.instanceCount);
|
||||||
}
|
}
|
||||||
if (FreeTypeFont.instanceCount > 0) {
|
if (FreeTypeFont.instanceCount > 0) {
|
||||||
Log.e("Non-zero FreeTypeFont instance count when exiting: ", FreeTypeFont.instanceCount);
|
Log.e("Non-zero FreeTypeFont instance count when exiting: ", FreeTypeFont.instanceCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d("Exiting main");
|
Log.d("Exiting main");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1151,14 +1151,14 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
if (window !is null) {
|
if (window !is null) {
|
||||||
int repeatCount = lParam & 0xFFFF;
|
int repeatCount = lParam & 0xFFFF;
|
||||||
if (window.onKey(message == WM_KEYDOWN || message == WM_SYSKEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, wParam, repeatCount, 0, message == WM_SYSKEYUP || message == WM_SYSKEYDOWN))
|
if (window.onKey(message == WM_KEYDOWN || message == WM_SYSKEYDOWN ? KeyAction.KeyDown : KeyAction.KeyUp, cast(uint)wParam, repeatCount, 0, message == WM_SYSKEYUP || message == WM_SYSKEYDOWN))
|
||||||
return 0; // processed
|
return 0; // processed
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_UNICHAR:
|
case WM_UNICHAR:
|
||||||
if (window !is null) {
|
if (window !is null) {
|
||||||
int repeatCount = lParam & 0xFFFF;
|
int repeatCount = lParam & 0xFFFF;
|
||||||
if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
|
if (window.onKey(KeyAction.Text, cast(uint)wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : cast(uint)wParam))
|
||||||
return 1; // processed
|
return 1; // processed
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1166,7 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
if (window !is null) {
|
if (window !is null) {
|
||||||
int repeatCount = lParam & 0xFFFF;
|
int repeatCount = lParam & 0xFFFF;
|
||||||
if (window.onKey(KeyAction.Text, wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : wParam))
|
if (window.onKey(KeyAction.Text, cast(uint)wParam, repeatCount, wParam == UNICODE_NOCHAR ? 0 : cast(uint)wParam))
|
||||||
return 1; // processed
|
return 1; // processed
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue