From 65e051fe93d12d0cc53258e047b6bf86f47c9ce7 Mon Sep 17 00:00:00 2001 From: Darkvater Date: Tue, 7 Nov 2006 13:06:02 +0000 Subject: (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable buttons depending on calling window, game-mode); handle it by broadcasting messages to the calling window, because that knows how and what buttons to set. --- main_gui.c | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'main_gui.c') diff --git a/main_gui.c b/main_gui.c index 7a9c06969..8009f28e8 100644 --- a/main_gui.c +++ b/main_gui.c @@ -855,15 +855,8 @@ static void ToolbarAirClick(Window *w) bool DoZoomInOutWindow(int how, Window *w) { ViewPort *vp; - int button; - - switch (_game_mode) { - case GM_EDITOR: button = 9; break; - case GM_NORMAL: button = 17; break; - default: return false; - } - assert(w); + assert(w != NULL); vp = w->viewport; switch (how) { @@ -890,31 +883,8 @@ bool DoZoomInOutWindow(int how, Window *w) } SetWindowDirty(w); - - // routine to disable/enable the zoom buttons. Didn't know where to place these otherwise - { - Window *wt = NULL; - - switch (w->window_class) { - case WC_MAIN_WINDOW: - wt = FindWindowById(WC_MAIN_TOOLBAR, 0); - break; - - case WC_EXTRA_VIEW_PORT: - wt = FindWindowById(WC_EXTRA_VIEW_PORT, w->window_number); - button = 5; - break; - } - - assert(wt); - - // update the toolbar button too - SetWindowWidgetDisabledState(wt, button, vp->zoom == 0); - SetWindowWidgetDisabledState(wt, button + 1, vp->zoom == 2); - - SetWindowDirty(wt); - } - + /* Update the windows that have zoom-buttons to perhaps disable their buttons */ + SendWindowMessageClass(w->window_class, how, w->window_number, 0); return true; } @@ -1891,6 +1861,10 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) } break; } + + case WE_MESSAGE: + HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18); + break; } } @@ -2078,6 +2052,9 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) } break; + case WE_MESSAGE: + HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10); + break; } } @@ -2380,6 +2357,11 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) case WE_MOUSEWHEEL: ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); break; + + case WE_MESSAGE: + /* Forward the message to the appropiate toolbar (ingame or scenario editor) */ + SendWindowMessage(WC_MAIN_TOOLBAR, 0, e->we.message.msg, e->we.message.wparam, e->we.message.lparam); + break; } } -- cgit v1.2.3-54-g00ecf