mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-13 17:54:14 +02:00
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:
@@ -1,18 +1,18 @@
|
||||
namespace phoenix {
|
||||
namespace hiro {
|
||||
|
||||
static const unsigned Windows2000 = 0x0500;
|
||||
static const unsigned WindowsXP = 0x0501;
|
||||
static const unsigned WindowsVista = 0x0600;
|
||||
static const unsigned Windows7 = 0x0601;
|
||||
|
||||
static unsigned OsVersion() {
|
||||
static auto OsVersion() -> unsigned {
|
||||
OSVERSIONINFO versionInfo = {0};
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&versionInfo);
|
||||
return (versionInfo.dwMajorVersion << 8) + (versionInfo.dwMajorVersion << 0);
|
||||
}
|
||||
|
||||
static HBITMAP CreateBitmap(const image& image) {
|
||||
static auto CreateBitmap(const image& image) -> HBITMAP {
|
||||
HDC hdc = GetDC(0);
|
||||
BITMAPINFO bitmapInfo;
|
||||
memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
|
||||
@@ -30,12 +30,16 @@ static HBITMAP CreateBitmap(const image& image) {
|
||||
return hbitmap;
|
||||
}
|
||||
|
||||
static lstring DropPaths(WPARAM wparam) {
|
||||
static auto CreateRGB(const Color& color) -> COLORREF {
|
||||
return RGB(color.red(), color.green(), color.blue());
|
||||
}
|
||||
|
||||
static auto DropPaths(WPARAM wparam) -> lstring {
|
||||
auto dropList = HDROP(wparam);
|
||||
auto fileCount = DragQueryFile(dropList, ~0u, nullptr, 0);
|
||||
|
||||
lstring paths;
|
||||
for(unsigned n = 0; n < fileCount; n++) {
|
||||
for(auto n : range(fileCount)) {
|
||||
auto length = DragQueryFile(dropList, n, nullptr, 0);
|
||||
auto buffer = new wchar_t[length + 1];
|
||||
|
||||
@@ -52,29 +56,13 @@ static lstring DropPaths(WPARAM wparam) {
|
||||
return paths;
|
||||
}
|
||||
|
||||
static Layout* GetParentWidgetLayout(Sizable* sizable) {
|
||||
while(sizable) {
|
||||
if(sizable->state.parent && dynamic_cast<TabFrame*>(sizable->state.parent)) return (Layout*)sizable;
|
||||
sizable = sizable->state.parent;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static Widget* GetParentWidget(Sizable* sizable) {
|
||||
while(sizable) {
|
||||
if(sizable->state.parent && dynamic_cast<TabFrame*>(sizable->state.parent)) return (Widget*)sizable->state.parent;
|
||||
sizable = sizable->state.parent;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static unsigned GetWindowZOrder(HWND hwnd) {
|
||||
static auto GetWindowZOrder(HWND hwnd) -> unsigned {
|
||||
unsigned z = 0;
|
||||
for(HWND next = hwnd; next != NULL; next = GetWindow(next, GW_HWNDPREV)) z++;
|
||||
return z;
|
||||
}
|
||||
|
||||
static void ImageList_Append(HIMAGELIST imageList, const nall::image& source, unsigned scale) {
|
||||
static auto ImageList_Append(HIMAGELIST imageList, const image& source, unsigned scale) -> void {
|
||||
auto image = source;
|
||||
if(image.empty()) {
|
||||
image.allocate(scale, scale);
|
||||
@@ -87,128 +75,15 @@ static void ImageList_Append(HIMAGELIST imageList, const nall::image& source, un
|
||||
DeleteObject(bitmap);
|
||||
}
|
||||
|
||||
static Keyboard::Keycode Keysym(unsigned keysym, unsigned keyflags) {
|
||||
#define pressed(keysym) (GetAsyncKeyState(keysym) & 0x8000)
|
||||
#define enabled(keysym) (GetKeyState(keysym))
|
||||
#define shifted() (pressed(VK_LSHIFT) || pressed(VK_RSHIFT))
|
||||
#define extended() (keyflags & (1 << 24))
|
||||
|
||||
switch(keysym) {
|
||||
case VK_ESCAPE: return Keyboard::Keycode::Escape;
|
||||
case VK_F1: return Keyboard::Keycode::F1;
|
||||
case VK_F2: return Keyboard::Keycode::F2;
|
||||
case VK_F3: return Keyboard::Keycode::F3;
|
||||
case VK_F4: return Keyboard::Keycode::F4;
|
||||
case VK_F5: return Keyboard::Keycode::F5;
|
||||
case VK_F6: return Keyboard::Keycode::F6;
|
||||
case VK_F7: return Keyboard::Keycode::F7;
|
||||
case VK_F8: return Keyboard::Keycode::F8;
|
||||
case VK_F9: return Keyboard::Keycode::F9;
|
||||
//Keyboard::Keycode::F10 (should be captured under VK_MENU from WM_SYSKEY(UP,DOWN); but this is not working...)
|
||||
case VK_F11: return Keyboard::Keycode::F11;
|
||||
case VK_F12: return Keyboard::Keycode::F12;
|
||||
|
||||
//Keyboard::Keycode::PrintScreen
|
||||
//Keyboard::Keycode::SysRq
|
||||
case VK_SCROLL: return Keyboard::Keycode::ScrollLock;
|
||||
case VK_PAUSE: return Keyboard::Keycode::Pause;
|
||||
//Keyboard::Keycode::Break
|
||||
|
||||
case VK_INSERT: return extended() ? Keyboard::Keycode::Insert : Keyboard::Keycode::KeypadInsert;
|
||||
case VK_DELETE: return extended() ? Keyboard::Keycode::Delete : Keyboard::Keycode::KeypadDelete;
|
||||
case VK_HOME: return extended() ? Keyboard::Keycode::Home : Keyboard::Keycode::KeypadHome;
|
||||
case VK_END: return extended() ? Keyboard::Keycode::End : Keyboard::Keycode::KeypadEnd;
|
||||
case VK_PRIOR: return extended() ? Keyboard::Keycode::PageUp : Keyboard::Keycode::KeypadPageUp;
|
||||
case VK_NEXT: return extended() ? Keyboard::Keycode::PageDown : Keyboard::Keycode::KeypadPageDown;
|
||||
|
||||
case VK_UP: return extended() ? Keyboard::Keycode::Up : Keyboard::Keycode::KeypadUp;
|
||||
case VK_DOWN: return extended() ? Keyboard::Keycode::Down : Keyboard::Keycode::KeypadDown;
|
||||
case VK_LEFT: return extended() ? Keyboard::Keycode::Left : Keyboard::Keycode::KeypadLeft;
|
||||
case VK_RIGHT: return extended() ? Keyboard::Keycode::Right : Keyboard::Keycode::KeypadRight;
|
||||
|
||||
case VK_OEM_3: return !shifted() ? Keyboard::Keycode::Grave : Keyboard::Keycode::Tilde;
|
||||
case '1': return !shifted() ? Keyboard::Keycode::Number1 : Keyboard::Keycode::Exclamation;
|
||||
case '2': return !shifted() ? Keyboard::Keycode::Number2 : Keyboard::Keycode::At;
|
||||
case '3': return !shifted() ? Keyboard::Keycode::Number3 : Keyboard::Keycode::Pound;
|
||||
case '4': return !shifted() ? Keyboard::Keycode::Number4 : Keyboard::Keycode::Dollar;
|
||||
case '5': return !shifted() ? Keyboard::Keycode::Number5 : Keyboard::Keycode::Percent;
|
||||
case '6': return !shifted() ? Keyboard::Keycode::Number6 : Keyboard::Keycode::Power;
|
||||
case '7': return !shifted() ? Keyboard::Keycode::Number7 : Keyboard::Keycode::Ampersand;
|
||||
case '8': return !shifted() ? Keyboard::Keycode::Number8 : Keyboard::Keycode::Asterisk;
|
||||
case '9': return !shifted() ? Keyboard::Keycode::Number9 : Keyboard::Keycode::ParenthesisLeft;
|
||||
case '0': return !shifted() ? Keyboard::Keycode::Number0 : Keyboard::Keycode::ParenthesisRight;
|
||||
case VK_OEM_MINUS: return !shifted() ? Keyboard::Keycode::Minus : Keyboard::Keycode::Underscore;
|
||||
case VK_OEM_PLUS: return !shifted() ? Keyboard::Keycode::Equal : Keyboard::Keycode::Plus;
|
||||
case VK_BACK: return Keyboard::Keycode::Backspace;
|
||||
|
||||
case VK_OEM_4: return !shifted() ? Keyboard::Keycode::BracketLeft : Keyboard::Keycode::BraceLeft;
|
||||
case VK_OEM_6: return !shifted() ? Keyboard::Keycode::BracketRight : Keyboard::Keycode::BraceRight;
|
||||
case VK_OEM_5: return !shifted() ? Keyboard::Keycode::Backslash : Keyboard::Keycode::Pipe;
|
||||
case VK_OEM_1: return !shifted() ? Keyboard::Keycode::Semicolon : Keyboard::Keycode::Colon;
|
||||
case VK_OEM_7: return !shifted() ? Keyboard::Keycode::Apostrophe : Keyboard::Keycode::Quote;
|
||||
case VK_OEM_COMMA: return !shifted() ? Keyboard::Keycode::Comma : Keyboard::Keycode::CaretLeft;
|
||||
case VK_OEM_PERIOD: return !shifted() ? Keyboard::Keycode::Period : Keyboard::Keycode::CaretRight;
|
||||
case VK_OEM_2: return !shifted() ? Keyboard::Keycode::Slash : Keyboard::Keycode::Question;
|
||||
|
||||
case VK_TAB: return Keyboard::Keycode::Tab;
|
||||
case VK_CAPITAL: return Keyboard::Keycode::CapsLock;
|
||||
case VK_RETURN: return !extended() ? Keyboard::Keycode::Return : Keyboard::Keycode::Enter;
|
||||
case VK_SHIFT: return !pressed(VK_RSHIFT) ? Keyboard::Keycode::ShiftLeft : Keyboard::Keycode::ShiftRight;
|
||||
case VK_CONTROL: return !pressed(VK_RCONTROL) ? Keyboard::Keycode::ControlLeft : Keyboard::Keycode::ControlRight;
|
||||
case VK_LWIN: return Keyboard::Keycode::SuperLeft;
|
||||
case VK_RWIN: return Keyboard::Keycode::SuperRight;
|
||||
case VK_MENU:
|
||||
if(keyflags & (1 << 24)) return Keyboard::Keycode::AltRight;
|
||||
return Keyboard::Keycode::AltLeft;
|
||||
case VK_SPACE: return Keyboard::Keycode::Space;
|
||||
case VK_APPS: return Keyboard::Keycode::Menu;
|
||||
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M':
|
||||
case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
||||
if(enabled(VK_CAPITAL)) {
|
||||
if(shifted()) {
|
||||
return (Keyboard::Keycode)((unsigned)Keyboard::Keycode::a + keysym - 'A');
|
||||
} else {
|
||||
return (Keyboard::Keycode)((unsigned)Keyboard::Keycode::A + keysym - 'A');
|
||||
}
|
||||
} else {
|
||||
if(shifted()) {
|
||||
return (Keyboard::Keycode)((unsigned)Keyboard::Keycode::A + keysym - 'A');
|
||||
} else {
|
||||
return (Keyboard::Keycode)((unsigned)Keyboard::Keycode::a + keysym - 'A');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_NUMLOCK: return Keyboard::Keycode::NumLock;
|
||||
case VK_DIVIDE: return Keyboard::Keycode::Divide;
|
||||
case VK_MULTIPLY: return Keyboard::Keycode::Multiply;
|
||||
case VK_SUBTRACT: return Keyboard::Keycode::Subtract;
|
||||
case VK_ADD: return Keyboard::Keycode::Add;
|
||||
case VK_DECIMAL: return Keyboard::Keycode::Point;
|
||||
case VK_NUMPAD1: return Keyboard::Keycode::Keypad1;
|
||||
case VK_NUMPAD2: return Keyboard::Keycode::Keypad2;
|
||||
case VK_NUMPAD3: return Keyboard::Keycode::Keypad3;
|
||||
case VK_NUMPAD4: return Keyboard::Keycode::Keypad4;
|
||||
case VK_NUMPAD5: return Keyboard::Keycode::Keypad5;
|
||||
case VK_NUMPAD6: return Keyboard::Keycode::Keypad6;
|
||||
case VK_NUMPAD7: return Keyboard::Keycode::Keypad7;
|
||||
case VK_NUMPAD8: return Keyboard::Keycode::Keypad8;
|
||||
case VK_NUMPAD9: return Keyboard::Keycode::Keypad9;
|
||||
case VK_NUMPAD0: return Keyboard::Keycode::Keypad0;
|
||||
|
||||
case VK_CLEAR: return Keyboard::Keycode::KeypadCenter;
|
||||
//post message only if said message is not already pending in the queue
|
||||
static auto PostMessageOnce(HWND hwnd, UINT id, WPARAM wparam, LPARAM lparam) -> void {
|
||||
MSG msg;
|
||||
if(!PeekMessage(&msg, hwnd, id, id, PM_NOREMOVE)) {
|
||||
PostMessage(hwnd, id, wparam, lparam);
|
||||
}
|
||||
|
||||
return Keyboard::Keycode::None;
|
||||
|
||||
#undef pressed
|
||||
#undef enabled
|
||||
#undef shifted
|
||||
#undef extended
|
||||
}
|
||||
|
||||
static unsigned ScrollEvent(HWND hwnd, WPARAM wparam) {
|
||||
static auto ScrollEvent(HWND hwnd, WPARAM wparam) -> unsigned {
|
||||
SCROLLINFO info;
|
||||
memset(&info, 0, sizeof(SCROLLINFO));
|
||||
info.cbSize = sizeof(SCROLLINFO);
|
||||
@@ -233,121 +108,261 @@ static unsigned ScrollEvent(HWND hwnd, WPARAM wparam) {
|
||||
return info.nPos;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK Shared_windowProc(WindowProc 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;
|
||||
//separate because PopupMenu HWND does not contain GWLP_USERDATA pointing at Window needed for Shared_windowProc
|
||||
static auto CALLBACK Menu_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
switch(msg) {
|
||||
case WM_MENUCOMMAND: {
|
||||
MENUITEMINFO mii{sizeof(MENUITEMINFO)};
|
||||
mii.fMask = MIIM_DATA;
|
||||
GetMenuItemInfo((HMENU)lparam, wparam, true, &mii);
|
||||
|
||||
auto object = (mObject*)mii.dwItemData;
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_MenuItem)
|
||||
if(auto menuItem = dynamic_cast<mMenuItem*>(object)) {
|
||||
return menuItem->self()->onActivate(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_MenuCheckItem)
|
||||
if(auto menuCheckItem = dynamic_cast<mMenuCheckItem*>(object)) {
|
||||
return menuCheckItem->self()->onToggle(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_MenuRadioItem)
|
||||
if(auto menuRadioItem = dynamic_cast<mMenuRadioItem*>(object)) {
|
||||
return menuRadioItem->self()->onActivate(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
static auto CALLBACK Shared_windowProc(WindowProc 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);
|
||||
if(!window) window = object->parentWindow(true);
|
||||
if(!window) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
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_CTLCOLORBTN:
|
||||
case WM_CTLCOLOREDIT:
|
||||
case WM_CTLCOLORSTATIC: {
|
||||
Object* object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA);
|
||||
if(object == nullptr) break;
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
//allow custom colors for various widgets
|
||||
//note that this happens always: default colors are black text on a white background, unless overridden
|
||||
//this intentionally overrides the default behavior of Windows to paint disabled controls with the window background color
|
||||
if(dynamic_cast<Console*>(object)) {
|
||||
Console& console = *(Console*)object;
|
||||
Color& background = console.state.backgroundColor;
|
||||
Color& foreground = console.state.foregroundColor;
|
||||
SetTextColor((HDC)wparam, RGB(foreground.red, foreground.green, foreground.blue));
|
||||
SetBkColor((HDC)wparam, RGB(background.red, background.green, background.blue));
|
||||
return (LRESULT)console.p.backgroundBrush;
|
||||
} else if(dynamic_cast<HexEdit*>(object)) {
|
||||
HexEdit& hexEdit = *(HexEdit*)object;
|
||||
Color& background = hexEdit.state.backgroundColor;
|
||||
Color& foreground = hexEdit.state.foregroundColor;
|
||||
SetTextColor((HDC)wparam, RGB(foreground.red, foreground.green, foreground.blue));
|
||||
SetBkColor((HDC)wparam, RGB(background.red, background.green, background.blue));
|
||||
return (LRESULT)hexEdit.p.backgroundBrush;
|
||||
} else if(dynamic_cast<LineEdit*>(object)) {
|
||||
LineEdit& lineEdit = *(LineEdit*)object;
|
||||
Color& background = lineEdit.state.backgroundColor;
|
||||
Color& foreground = lineEdit.state.foregroundColor;
|
||||
SetTextColor((HDC)wparam, RGB(foreground.red, foreground.green, foreground.blue));
|
||||
SetBkColor((HDC)wparam, RGB(background.red, background.green, background.blue));
|
||||
return (LRESULT)lineEdit.p.backgroundBrush;
|
||||
} else if(dynamic_cast<TextEdit*>(object)) {
|
||||
TextEdit& textEdit = *(TextEdit*)object;
|
||||
Color& background = textEdit.state.backgroundColor;
|
||||
Color& foreground = textEdit.state.foregroundColor;
|
||||
SetTextColor((HDC)wparam, RGB(foreground.red, foreground.green, foreground.blue));
|
||||
SetBkColor((HDC)wparam, RGB(background.red, background.green, background.blue));
|
||||
return (LRESULT)textEdit.p.backgroundBrush;
|
||||
} else if(!GetParentWidget((Sizable*)object) && window.p.brush) {
|
||||
SetBkColor((HDC)wparam, window.p.brushColor);
|
||||
return (INT_PTR)window.p.brush;
|
||||
|
||||
#if defined(Hiro_Window) && defined(Hiro_TabFrame)
|
||||
if(!object->parentTabFrame(true) && window->self()->hbrush) {
|
||||
SetBkColor((HDC)wparam, window->self()->hbrushColor);
|
||||
return (LRESULT)window->self()->hbrush;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_HexEdit)
|
||||
if(auto hexEdit = dynamic_cast<mHexEdit*>(object)) {
|
||||
if(auto background = hexEdit->backgroundColor()) SetBkColor((HDC)wparam, CreateRGB(background));
|
||||
if(auto foreground = hexEdit->foregroundColor()) SetTextColor((HDC)wparam, CreateRGB(foreground));
|
||||
return (LRESULT)hexEdit->self()->backgroundBrush;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_LineEdit)
|
||||
if(auto lineEdit = dynamic_cast<mLineEdit*>(object)) {
|
||||
if(auto background = lineEdit->backgroundColor()) SetBkColor((HDC)wparam, CreateRGB(background));
|
||||
if(auto foreground = lineEdit->foregroundColor()) SetTextColor((HDC)wparam, CreateRGB(foreground));
|
||||
return (LRESULT)lineEdit->self()->backgroundBrush;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_TextEdit)
|
||||
if(auto textEdit = dynamic_cast<mTextEdit*>(object)) {
|
||||
if(auto background = textEdit->backgroundColor()) SetBkColor((HDC)wparam, CreateRGB(background));
|
||||
if(auto foreground = textEdit->foregroundColor()) SetTextColor((HDC)wparam, CreateRGB(foreground));
|
||||
return (LRESULT)textEdit->self()->backgroundBrush;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DRAWITEM: {
|
||||
unsigned id = LOWORD(wparam);
|
||||
HWND control = GetDlgItem(hwnd, id);
|
||||
Object* object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
|
||||
if(object == nullptr) break;
|
||||
if(dynamic_cast<TabFrame*>(object)) { ((TabFrame*)object)->p.onDrawItem(lparam); return TRUE; }
|
||||
auto drawItem = (LPDRAWITEMSTRUCT)lparam;
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)drawItem->hwndItem, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_TabFrame)
|
||||
if(auto tabFrame = dynamic_cast<mTabFrame*>(object)) {
|
||||
return tabFrame->self()->onDrawItem(lparam), true;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MENUCOMMAND: {
|
||||
return Menu_windowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
case WM_COMMAND: {
|
||||
unsigned id = LOWORD(wparam);
|
||||
HWND control = GetDlgItem(hwnd, id);
|
||||
Object* object = control ? (Object*)GetWindowLongPtr(control, GWLP_USERDATA) : pObject::find(id);
|
||||
if(object == nullptr) break;
|
||||
if(dynamic_cast<Item*>(object)) { ((Item*)object)->p.onActivate(); return FALSE; }
|
||||
if(dynamic_cast<CheckItem*>(object)) { ((CheckItem*)object)->p.onToggle(); return FALSE; }
|
||||
if(dynamic_cast<RadioItem*>(object)) { ((RadioItem*)object)->p.onActivate(); return FALSE; }
|
||||
if(dynamic_cast<Button*>(object)) { ((Button*)object)->p.onActivate(); return FALSE; }
|
||||
if(dynamic_cast<CheckButton*>(object)) { ((CheckButton*)object)->p.onToggle(); return FALSE; }
|
||||
if(dynamic_cast<CheckLabel*>(object)) { ((CheckLabel*)object)->p.onToggle(); return FALSE; }
|
||||
if(dynamic_cast<ComboButton*>(object) && HIWORD(wparam) == CBN_SELCHANGE) { ((ComboButton*)object)->p.onChange(); return FALSE; }
|
||||
if(dynamic_cast<LineEdit*>(object) && HIWORD(wparam) == EN_CHANGE) { ((LineEdit*)object)->p.onChange(); return FALSE; }
|
||||
if(dynamic_cast<RadioButton*>(object)) { ((RadioButton*)object)->p.onActivate(); return FALSE; }
|
||||
if(dynamic_cast<RadioLabel*>(object)) { ((RadioLabel*)object)->p.onActivate(); return FALSE; }
|
||||
if(dynamic_cast<TextEdit*>(object) && HIWORD(wparam) == EN_CHANGE) { ((TextEdit*)object)->p.onChange(); return FALSE; }
|
||||
if(!lparam) break;
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_Button)
|
||||
if(auto button = dynamic_cast<mButton*>(object)) {
|
||||
return button->self()->onActivate(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_CheckButton)
|
||||
if(auto checkButton = dynamic_cast<mCheckButton*>(object)) {
|
||||
return checkButton->self()->onToggle(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_CheckLabel)
|
||||
if(auto checkLabel = dynamic_cast<mCheckLabel*>(object)) {
|
||||
return checkLabel->self()->onToggle(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_ComboButton)
|
||||
if(auto comboButton = dynamic_cast<mComboButton*>(object)) {
|
||||
if(HIWORD(wparam) == CBN_SELCHANGE) {
|
||||
return comboButton->self()->onChange(), false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_LineEdit)
|
||||
if(auto lineEdit = dynamic_cast<mLineEdit*>(object)) {
|
||||
if(HIWORD(wparam) == EN_CHANGE) {
|
||||
return lineEdit->self()->onChange(), false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_RadioButton)
|
||||
if(auto radioButton = dynamic_cast<mRadioButton*>(object)) {
|
||||
return radioButton->self()->onActivate(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_RadioLabel)
|
||||
if(auto radioLabel = dynamic_cast<mRadioLabel*>(object)) {
|
||||
return radioLabel->self()->onActivate(), false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_TextEdit)
|
||||
if(auto textEdit = dynamic_cast<mTextEdit*>(object)) {
|
||||
if(HIWORD(wparam) == EN_CHANGE) {
|
||||
return textEdit->self()->onChange(), false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY: {
|
||||
unsigned id = LOWORD(wparam);
|
||||
HWND control = GetDlgItem(hwnd, id);
|
||||
Object* object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
|
||||
if(object == nullptr) break;
|
||||
if(dynamic_cast<ListView*>(object) && ((LPNMHDR)lparam)->code == LVN_ITEMACTIVATE) { ((ListView*)object)->p.onActivate(lparam); break; }
|
||||
if(dynamic_cast<ListView*>(object) && ((LPNMHDR)lparam)->code == LVN_ITEMCHANGED) { ((ListView*)object)->p.onChange(lparam); break; }
|
||||
if(dynamic_cast<ListView*>(object) && ((LPNMHDR)lparam)->code == NM_CUSTOMDRAW) { return ((ListView*)object)->p.onCustomDraw(lparam); }
|
||||
if(dynamic_cast<TabFrame*>(object) && ((LPNMHDR)lparam)->code == TCN_SELCHANGE) { ((TabFrame*)object)->p.onChange(); break; }
|
||||
auto header = (LPNMHDR)lparam;
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)header->hwndFrom, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
if(auto listView = dynamic_cast<mListView*>(object)) {
|
||||
if(header->code == LVN_ITEMACTIVATE) {
|
||||
listView->self()->onActivate(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == LVN_ITEMCHANGED) {
|
||||
listView->self()->onChange(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == LVN_COLUMNCLICK) {
|
||||
listView->self()->onSort(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == NM_RCLICK) {
|
||||
listView->self()->onContext(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == NM_CUSTOMDRAW) {
|
||||
return listView->self()->onCustomDraw(lparam);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_TabFrame)
|
||||
if(auto tabFrame = dynamic_cast<mTabFrame*>(object)) {
|
||||
if(header->code == TCN_SELCHANGE) {
|
||||
tabFrame->self()->onChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_APP + AppMessage::ListView_onActivate: {
|
||||
ListView* listView = (ListView*)lparam;
|
||||
if(listView && listView->onActivate) listView->onActivate();
|
||||
#if defined(Hiro_ListView)
|
||||
case AppMessage::ListView_onActivate: {
|
||||
if(auto listView = (mListView*)lparam) listView->doActivate();
|
||||
break;
|
||||
}
|
||||
|
||||
case AppMessage::ListView_onChange: {
|
||||
if(auto listView = (mListView*)lparam) listView->doChange();
|
||||
}
|
||||
#endif
|
||||
|
||||
case WM_HSCROLL:
|
||||
case WM_VSCROLL: {
|
||||
Object* object = nullptr;
|
||||
if(lparam) {
|
||||
object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA);
|
||||
} else {
|
||||
unsigned id = LOWORD(wparam);
|
||||
HWND control = GetDlgItem(hwnd, id);
|
||||
object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
|
||||
if(!lparam) break;
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_HorizontalScroller)
|
||||
if(auto horizontalScroller = dynamic_cast<mHorizontalScroller*>(object)) {
|
||||
return horizontalScroller->self()->onChange(wparam), true;
|
||||
}
|
||||
if(object == nullptr) break;
|
||||
if(dynamic_cast<HorizontalScroller*>(object)) { ((HorizontalScroller*)object)->p.onChange(wparam); return TRUE; }
|
||||
if(dynamic_cast<VerticalScroller*>(object)) { ((VerticalScroller*)object)->p.onChange(wparam); return TRUE; }
|
||||
if(dynamic_cast<HorizontalSlider*>(object)) { ((HorizontalSlider*)object)->p.onChange(); return TRUE; }
|
||||
if(dynamic_cast<VerticalSlider*>(object)) { ((VerticalSlider*)object)->p.onChange(); return TRUE; }
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_HorizontalSlider)
|
||||
if(auto horizontalSlider = dynamic_cast<mHorizontalSlider*>(object)) {
|
||||
return horizontalSlider->self()->onChange(), true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_VerticalScroller)
|
||||
if(auto verticalScroller = dynamic_cast<mVerticalScroller*>(object)) {
|
||||
return verticalScroller->self()->onChange(wparam), true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_VerticalSlider)
|
||||
if(auto verticalSlider = dynamic_cast<mVerticalSlider*>(object)) {
|
||||
return verticalSlider->self()->onChange(), true;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user