=== modified file 'src/misc_gui.cpp' --- src/misc_gui.cpp 2008-04-25 15:20:40 +0000 +++ src/misc_gui.cpp 2008-04-30 14:14:45 +0000 @@ -1164,7 +1164,7 @@ WindowEvent e; e.event = WE_ON_EDIT_TEXT; e.we.edittext.str = qs->text.buf; - parent->wndproc(parent, &e); + parent->HandleWindowEvent(&e); } else { HandleOnEditText(qs->text.buf); } @@ -1194,7 +1194,7 @@ qs->handled = true; e.event = WE_ON_EDIT_TEXT_CANCEL; - parent->wndproc(parent, &e); + parent->HandleWindowEvent(&e); } ClrBit(_no_scroll, SCROLL_EDIT); break; === modified file 'src/osk_gui.cpp' --- src/osk_gui.cpp 2008-04-13 19:46:15 +0000 +++ src/osk_gui.cpp 2008-04-30 14:24:49 +0000 @@ -161,7 +161,7 @@ WindowEvent e; e.event = WE_CLICK; e.we.click.widget = WP(w, osk_d).ok_btn; - parent->wndproc(parent, &e); + parent->HandleWindowEvent(&e); } } DeleteWindow(w); @@ -173,7 +173,7 @@ WindowEvent e; e.event = WE_CLICK; e.we.click.widget = WP(w, osk_d).cancel_btn; - parent->wndproc(parent, &e); + parent->HandleWindowEvent(&e); } else { // or reset to original string strcpy(qs->text.buf, WP(w, osk_d).orig); UpdateTextBufferSize(&qs->text); === modified file 'src/viewport.cpp' --- src/viewport.cpp 2008-04-19 13:39:00 +0000 +++ src/viewport.cpp 2008-04-30 14:25:24 +0000 @@ -2061,7 +2061,7 @@ e.event = WE_PLACE_OBJ; e.we.place.pt = pt; e.we.place.tile = TileVirtXY(pt.x, pt.y); - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } } @@ -2712,7 +2712,7 @@ if (_left_button_down) { e.event = WE_PLACE_DRAG; e.we.place.pt = GetTileBelowCursor(); - w->wndproc(w, &e); + w->HandleWindowEvent(&e); return false; } @@ -2737,7 +2737,7 @@ e.we.place.pt = _thd.selend; e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y); e.we.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); - w->wndproc(w, &e); + w->HandleWindowEvent(&e); return false; } === modified file 'src/widgets/dropdown.cpp' --- src/widgets/dropdown.cpp 2008-04-13 19:46:15 +0000 +++ src/widgets/dropdown.cpp 2008-04-30 14:13:50 +0000 @@ -179,7 +179,7 @@ e.event = WE_DROPDOWN_SELECT; e.we.dropdown.button = WP(w, dropdown_d).parent_button; e.we.dropdown.index = WP(w, dropdown_d).selected_index; - w2->wndproc(w2, &e); + w2->HandleWindowEvent(&e); DeleteWindow(w); return; } === modified file 'src/window.cpp' --- src/window.cpp 2008-04-30 14:12:33 +0000 +++ src/window.cpp 2008-04-30 14:21:25 +0000 @@ -60,6 +60,17 @@ return wndproc == proc; } +/** + * Call the window event handler for handling event \a e + * @param e Window event to handle + */ +void Window::HandleWindowEvent(WindowEvent *e) +{ + if (wndproc != NULL) { + wndproc(this, e); + } +} + void CDECL Window::SetWidgetsDisabledState(bool disab_stat, int widgets, ...) { va_list wdg_list; @@ -197,7 +208,7 @@ } } - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /** @@ -225,7 +236,7 @@ e.event = WE_RCLICK; e.we.click.pt.x = x; e.we.click.pt.y = y; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /** @@ -365,7 +376,7 @@ WindowEvent e; e.event = event; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /** @@ -747,7 +758,7 @@ WindowEvent e; e.event = WE_CREATE; e.we.create.data = data; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); /* Try to make windows smaller when our window is too small. * w->(width|height) is normally the same as min_(width|height), @@ -779,7 +790,7 @@ e.we.sizing.size.y = w->height; e.we.sizing.diff.x = enlarge_x; e.we.sizing.diff.y = enlarge_y; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } int nx = w->left; @@ -1137,7 +1148,7 @@ } e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y); e.event = WE_PLACE_PRESIZE; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } static bool HandleDragDrop() @@ -1157,7 +1168,7 @@ e.we.dragdrop.pt.x = _cursor.pos.x - w->left; e.we.dragdrop.pt.y = _cursor.pos.y - w->top; e.we.dragdrop.widget = GetWidgetFromPos(w, e.we.dragdrop.pt.x, e.we.dragdrop.pt.y); - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } ResetObjectToPlace(); @@ -1187,7 +1198,7 @@ e.we.popupmenu.pt = _cursor.pos; } - w->wndproc(w, &e); + w->HandleWindowEvent(&e); return false; } @@ -1204,7 +1215,7 @@ e.event = WE_MOUSEOVER; e.we.mouseover.pt.x = -1; e.we.mouseover.pt.y = -1; - if (_mouseover_last_w->wndproc != NULL) _mouseover_last_w->wndproc(_mouseover_last_w, &e); + _mouseover_last_w->HandleWindowEvent(&e); } /* _mouseover_last_w will get reset when the window is deleted, see DeleteWindow() */ @@ -1218,7 +1229,7 @@ if (w->widget != NULL) { e.we.mouseover.widget = GetWidgetFromPos(w, e.we.mouseover.pt.x, e.we.mouseover.pt.y); } - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /* Mouseover never stops execution */ @@ -1470,7 +1481,7 @@ e.we.sizing.size.y = y + w->height; e.we.sizing.diff.x = x; e.we.sizing.diff.y = y; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); return false; } } @@ -1601,7 +1612,7 @@ /* Create a scroll-event and send it to the window */ e.event = WE_SCROLL; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); _cursor.delta.x = 0; _cursor.delta.y = 0; @@ -1676,7 +1687,7 @@ e.we.message.wparam = wparam; e.we.message.lparam = lparam; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /** Send a message from one window to another. The receiving window is found by @@ -1774,14 +1785,14 @@ w->window_class != WC_COMPANY_PASSWORD_WINDOW) { continue; } - w->wndproc(w, &e); + w->HandleWindowEvent(&e); if (!e.we.keypress.cont) break; } if (e.we.keypress.cont) { Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); /* When there is no toolbar w is null, check for that */ - if (w != NULL) w->wndproc(w, &e); + if (w != NULL) w->HandleWindowEvent(&e); } } @@ -1798,7 +1809,7 @@ /* Call the event, start with the uppermost window. */ for (Window* const *wz = _last_z_window; wz != _z_windows;) { Window *w = *--wz; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); if (!e.we.ctrl.cont) break; } } @@ -1905,7 +1916,7 @@ /* Send WE_MOUSEWHEEL event to window */ e.event = WE_MOUSEWHEEL; e.we.wheel.wheel = mousewheel; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ @@ -2290,7 +2301,7 @@ e.we.sizing.size.y = w->height; e.we.sizing.diff.x = neww - w->width; e.we.sizing.diff.y = 0; - w->wndproc(w, &e); + w->HandleWindowEvent(&e); } top = w->top; === modified file 'src/window_gui.h' --- src/window_gui.h 2008-04-30 14:12:33 +0000 +++ src/window_gui.h 2008-04-30 14:29:18 +0000 @@ -307,7 +307,7 @@ byte caption_color; ///< Background color of the window caption, contains PlayerID - WindowProc *wndproc; ///< Event handler function for the window + WindowProc *wndproc; ///< Event handler function for the window. Do not use directly, call HandleWindowEvent() instead. ViewPort *viewport; ///< Pointer to viewport, if present const Widget *original_widget; ///< Original widget layout, copied from WindowDesc Widget *widget; ///< Widgets of the window @@ -341,6 +341,7 @@ void InvalidateWidget(byte widget_index) const; bool CompareWndprocEqual(WindowProc *proc); + virtual void HandleWindowEvent(WindowEvent *e); }; struct menu_d {