Update to v094r24 release.

byuu says:

Finally!! Compilation works once again on Windows.

However, it's pretty buggy. Modality isn't really working right, you can
still poke at other windows, but when you select ListView items, they
redraw as empty boxes (need to process WM_DRAWITEM before checking
modality.)

The program crashes when you close it (probably a ruby driver's term()
function, that's what it usually is.)

The Layout::setEnabled(false) call isn't working right, so you get that
annoying chiming sound and cursor movement when mapping keyboard keys to
game inputs.

The column sizing seems off a bit on first display for the Hotkeys tab.

And probably lots more.
This commit is contained in:
Tim Allen
2015-06-12 23:14:38 +10:00
parent 314aee8c5c
commit f0c17ffc0d
188 changed files with 5474 additions and 3834 deletions

View File

@@ -1,14 +1,16 @@
namespace phoenix {
#if defined(Hiro_Application)
static bool Application_keyboardProc(HWND, UINT, WPARAM, LPARAM);
static void Application_processDialogMessage(MSG&);
static LRESULT CALLBACK Application_windowProc(HWND, UINT, WPARAM, LPARAM);
namespace hiro {
void pApplication::run() {
static auto Application_keyboardProc(HWND, UINT, WPARAM, LPARAM) -> bool;
static auto Application_processDialogMessage(MSG&) -> void;
static auto CALLBACK Application_windowProc(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
auto pApplication::run() -> void {
MSG msg;
if(Application::main) {
while(applicationState.quit == false) {
Application::main();
if(Application::state.onMain) {
while(!Application::state.quit) {
Application::doMain();
processEvents();
}
} else {
@@ -19,12 +21,12 @@ void pApplication::run() {
}
}
bool pApplication::pendingEvents() {
auto pApplication::pendingEvents() -> bool {
MSG msg;
return PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE);
}
void pApplication::processEvents() {
auto pApplication::processEvents() -> void {
while(pendingEvents()) {
MSG msg;
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
@@ -33,7 +35,7 @@ void pApplication::processEvents() {
}
}
void Application_processDialogMessage(MSG& msg) {
auto Application_processDialogMessage(MSG& msg) -> void {
if(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP
|| msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP) {
if(Application_keyboardProc(msg.hwnd, msg.message, msg.wParam, msg.lParam)) {
@@ -48,15 +50,17 @@ void Application_processDialogMessage(MSG& msg) {
}
}
void pApplication::quit() {
auto pApplication::quit() -> void {
PostQuitMessage(0);
}
void pApplication::initialize() {
auto pApplication::initialize() -> void {
CoInitialize(0);
InitCommonControls();
WNDCLASS wc;
#if defined(Hiro_Window)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
@@ -64,11 +68,27 @@ void pApplication::initialize() {
wc.hIcon = LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(2));
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Application_windowProc;
wc.lpszClassName = L"phoenix_window";
wc.lpszClassName = L"hiroWindow";
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
#endif
#if defined(Hiro_PopupMenu)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(2));
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Menu_windowProc;
wc.lpszClassName = L"hiroPopupMenu";
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
#endif
#if defined(Hiro_Canvas)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
@@ -76,11 +96,13 @@ void pApplication::initialize() {
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Canvas_windowProc;
wc.lpszClassName = L"phoenix_canvas";
wc.lpszClassName = L"hiroCanvas";
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
#endif
#if defined(Hiro_Label)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
@@ -88,11 +110,13 @@ void pApplication::initialize() {
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Label_windowProc;
wc.lpszClassName = L"phoenix_label";
wc.lpszClassName = L"hiroLabel";
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
#endif
#if defined(Hiro_Viewport)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
@@ -100,76 +124,80 @@ void pApplication::initialize() {
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Viewport_windowProc;
wc.lpszClassName = L"phoenix_viewport";
wc.lpszClassName = L"hiroViewport";
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
#endif
settings = new Settings;
pKeyboard::initialize();
}
static bool Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
static auto Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> bool {
if(msg != WM_KEYDOWN && msg != WM_SYSKEYDOWN && msg != WM_KEYUP && msg != WM_SYSKEYUP) return false;
GUITHREADINFO info;
memset(&info, 0, sizeof(GUITHREADINFO));
info.cbSize = sizeof(GUITHREADINFO);
GetGUIThreadInfo(GetCurrentThreadId(), &info);
Object* object = (Object*)GetWindowLongPtr(info.hwndFocus, GWLP_USERDATA);
if(object == nullptr) return false;
auto object = (mObject*)GetWindowLongPtr(info.hwndFocus, GWLP_USERDATA);
if(!object) return false;
if(dynamic_cast<Window*>(object)) {
Window& window = (Window&)*object;
if(pWindow::modal.size() > 0 && !pWindow::modal.find(&window.p)) return false;
Keyboard::Keycode keysym = Keysym(wparam, lparam);
if(keysym != Keyboard::Keycode::None) {
if((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) && window.onKeyPress) window.onKeyPress(keysym);
if((msg == WM_KEYUP || msg == WM_SYSKEYUP) && window.onKeyRelease) window.onKeyRelease(keysym);
if(auto window = dynamic_cast<mWindow*>(object)) {
if(pWindow::modal && !pWindow::modal.find(window->self())) return false;
if(auto code = pKeyboard::_translate(wparam, lparam)) {
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) window->doKeyPress(code);
if(msg == WM_KEYUP || msg == WM_SYSKEYUP) window->doKeyRelease(code);
}
return false;
}
if(msg == WM_KEYDOWN) {
if(dynamic_cast<ListView*>(object)) {
ListView& listView = (ListView&)*object;
if(0);
#if defined(Hiro_ListView)
else if(auto listView = dynamic_cast<mListView*>(object)) {
if(wparam == VK_RETURN) {
if(listView.selected()) return true; //returning true generates LVN_ITEMACTIVATE message
if(listView->selected()) return true; //returning true generates LVN_ITEMACTIVATE message
}
} else if(dynamic_cast<LineEdit*>(object)) {
LineEdit& lineEdit = (LineEdit&)*object;
}
#endif
#if defined(Hiro_LineEdit)
else if(auto lineEdit = dynamic_cast<mLineEdit*>(object)) {
if(wparam == VK_RETURN) {
if(lineEdit.onActivate) lineEdit.onActivate();
lineEdit->doActivate();
}
} else if(dynamic_cast<TextEdit*>(object)) {
TextEdit& textEdit = (TextEdit&)*object;
}
#endif
#if defined(Hiro_TextEdit)
else if(auto textEdit = dynamic_cast<mTextEdit*>(object)) {
if(wparam == 'A' && GetKeyState(VK_CONTROL) < 0) {
//Ctrl+A = select all text
//note: this is not a standard accelerator on Windows
Edit_SetSel(textEdit.p.hwnd, 0, ~0);
Edit_SetSel(textEdit->self()->hwnd, 0, ~0);
return true;
} else if(wparam == 'V' && GetKeyState(VK_CONTROL) < 0) {
//Ctrl+V = paste text
//note: this formats Unix (LF) and OS9 (CR) line-endings to Windows (CR+LF) line-endings
//this is necessary as the EDIT control only supports Windows line-endings
OpenClipboard(hwnd);
HANDLE handle = GetClipboardData(CF_UNICODETEXT);
if(handle) {
wchar_t* text = (wchar_t*)GlobalLock(handle);
if(text) {
if(auto handle = GetClipboardData(CF_UNICODETEXT)) {
if(auto text = (wchar_t*)GlobalLock(handle)) {
string data = (const char*)utf8_t(text);
data.replace("\r\n", "\n");
data.replace("\r", "\n");
data.replace("\n", "\r\n");
GlobalUnlock(handle);
utf16_t output(data);
HGLOBAL resource = GlobalAlloc(GMEM_MOVEABLE, (wcslen(output) + 1) * sizeof(wchar_t));
if(resource) {
wchar_t* write = (wchar_t*)GlobalLock(resource);
if(write) {
if(auto resource = GlobalAlloc(GMEM_MOVEABLE, (wcslen(output) + 1) * sizeof(wchar_t))) {
if(auto write = (wchar_t*)GlobalLock(resource)) {
wcscpy(write, output);
GlobalUnlock(write);
if(SetClipboardData(CF_UNICODETEXT, resource) == FALSE) {
if(SetClipboardData(CF_UNICODETEXT, resource) == NULL) {
GlobalFree(resource);
}
}
@@ -180,40 +208,45 @@ static bool Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
return false;
}
}
#endif
}
return false;
}
/*case WM_GETMINMAXINFO: {
MINMAXINFO* mmi = (MINMAXINFO*)lparam;
mmi->ptMinTrackSize.x = 256 + window.p.frameMargin().width;
mmi->ptMinTrackSize.y = 256 + window.p.frameMargin().height;
return TRUE;
break;
}*/
/*
case WM_GETMINMAXINFO: {
MINMAXINFO* mmi = (MINMAXINFO*)lparam;
mmi->ptMinTrackSize.x = 256 + window.p.frameMargin().width;
mmi->ptMinTrackSize.y = 256 + window.p.frameMargin().height;
return TRUE;
break;
}
*/
static LRESULT CALLBACK Application_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
Object* object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if(object == nullptr) return DefWindowProc(hwnd, msg, wparam, lparam);
Window& window = dynamic_cast<Window*>(object) ? (Window&)*object : *((Widget*)object)->Sizable::state.window;
static auto CALLBACK Application_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if(!object) return DefWindowProc(hwnd, msg, wparam, lparam);
auto& window = dynamic_cast<mWindow*>(object) ? (mWindow&)*object : *object->parentWindow(true);
bool process = true;
if(!pWindow::modal.empty() && !pWindow::modal.find(&window.p)) process = false;
if(applicationState.quit) process = false;
if(process == false) return DefWindowProc(hwnd, msg, wparam, lparam);
if(pWindow::modal && !pWindow::modal.find(window.self())) process = false;
if(Application::state.quit) process = false;
if(!process) return DefWindowProc(hwnd, msg, wparam, lparam);
switch(msg) {
case WM_CLOSE: window.p.onClose(); return TRUE;
case WM_MOVE: window.p.onMove(); break;
case WM_SIZE: window.p.onSize(); break;
case WM_DROPFILES: window.p.onDrop(wparam); return FALSE;
case WM_ERASEBKGND: if(window.p.onEraseBackground()) return true; break;
case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: window.p.onModalBegin(); return FALSE;
case WM_EXITMENULOOP: case WM_EXITSIZEMOVE: window.p.onModalEnd(); return FALSE;
case WM_CLOSE: window.self()->onClose(); return TRUE;
case WM_MOVE: window.self()->onMove(); break;
case WM_SIZE: window.self()->onSize(); break;
case WM_DROPFILES: window.self()->onDrop(wparam); return FALSE;
case WM_ERASEBKGND: if(window.self()->onEraseBackground()) return true; break;
case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: window.self()->onModalBegin(); return FALSE;
case WM_EXITMENULOOP: case WM_EXITSIZEMOVE: window.self()->onModalEnd(); return FALSE;
}
return Shared_windowProc(DefWindowProc, hwnd, msg, wparam, lparam);
}
}
#endif