From 74ea5f3cd7a1bb6b2e3d865def15ebf44416cbc8 Mon Sep 17 00:00:00 2001 From: george82 Date: Mon, 11 Sep 2006 11:40:12 +0000 Subject: [PATCH] Now status of ZOOM IN, ZOOM OUT, ACTUAL SIZE, AUTO SIZE toolbar buttons depend on scale values and scale mode (scale, auto scale). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@662 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- win/vncviewer/CConn.cxx | 5 +++-- win/vncviewer/DesktopWindow.cxx | 26 ++++++++++++++++++++++++++ win/vncviewer/DesktopWindow.h | 6 ++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/win/vncviewer/CConn.cxx b/win/vncviewer/CConn.cxx index 388014ff..0d95180c 100644 --- a/win/vncviewer/CConn.cxx +++ b/win/vncviewer/CConn.cxx @@ -223,8 +223,9 @@ CConn::sysCommand(WPARAM wParam, LPARAM lParam) { window->setDesktopScale(100); return true; case IDM_AUTO_SIZE: - options.autoScaling = true; - window->setAutoScaling(true); + options.autoScaling = !options.autoScaling; + window->setAutoScaling(options.autoScaling); + if (!options.autoScaling) options.scale = window->getDesktopScale(); return true; case IDM_SHOW_TOOLBAR: options.showToolbar = !window->isToolbarEnabled(); diff --git a/win/vncviewer/DesktopWindow.cxx b/win/vncviewer/DesktopWindow.cxx index 517d3ab1..8460f581 100644 --- a/win/vncviewer/DesktopWindow.cxx +++ b/win/vncviewer/DesktopWindow.cxx @@ -308,6 +308,7 @@ void DesktopWindow::setShowToolbar(bool st) bool maximized = GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE; if (showToolbar && !tb.isVisible()) { + refreshToolbarButtons(); tb.show(); if (!maximized) r.bottom += tb.getHeight(); } else if (!showToolbar && tb.isVisible()) { @@ -320,6 +321,24 @@ void DesktopWindow::setShowToolbar(bool st) else SetWindowPos(handle, NULL, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOMOVE | SWP_NOZORDER); } +void DesktopWindow::refreshToolbarButtons() { + int scale = getDesktopScale(); + if (scale == 100) tb.enableButton(ID_ACTUAL_SIZE, false); + else tb.enableButton(ID_ACTUAL_SIZE, true); + if (scale <= 10) { + tb.enableButton(ID_ZOOM_IN, true); + tb.enableButton(ID_ZOOM_OUT, false); + } else if (scale >= 200) { + tb.enableButton(ID_ZOOM_IN, false); + tb.enableButton(ID_ZOOM_OUT, true); + } else { + tb.enableButton(ID_ZOOM_IN, true); + tb.enableButton(ID_ZOOM_OUT, true); + } + if (isAutoScaling()) tb.pressButton(ID_AUTO_SIZE, true); + else tb.pressButton(ID_AUTO_SIZE, false); +} + void DesktopWindow::setDisableWinKeys(bool dwk) { // Enable low-level event hooking, so we get special keys directly if (dwk) @@ -949,10 +968,16 @@ DesktopWindow::setSize(int w, int h) { calculateScrollBars(); } +void DesktopWindow::setAutoScaling(bool as) { + autoScaling = as; + if (as) fitBufferToWindow(); +} + void DesktopWindow::setDesktopScale(int scale) { buffer->setScale(scale); InvalidateRect(frameHandle, 0, FALSE); calculateScrollBars(); + if (isToolbarEnabled()) refreshToolbarButtons(); } void DesktopWindow::fitBufferToWindow(bool repaint) { @@ -975,6 +1000,7 @@ void DesktopWindow::fitBufferToWindow(bool repaint) { } buffer->setScaleRatio(scale_ratio); if (repaint) InvalidateRect(frameHandle, 0, TRUE); + if (isToolbarEnabled()) refreshToolbarButtons(); } void diff --git a/win/vncviewer/DesktopWindow.h b/win/vncviewer/DesktopWindow.h index 8e82083e..e8f87bc6 100644 --- a/win/vncviewer/DesktopWindow.h +++ b/win/vncviewer/DesktopWindow.h @@ -82,10 +82,7 @@ namespace rfb { PixelFormat getPF() const { return buffer->getPF(); } void setSize(int w, int h); void setColour(int i, int r, int g, int b) {buffer->setColour(i, r, g, b);} - void setAutoScaling(bool as) { - autoScaling = as; - if (as) fitBufferToWindow(); - } + void setAutoScaling(bool as); bool isAutoScaling() const { return autoScaling; } void setDesktopScale(int scale); int getDesktopScale() const { return buffer->getScale(); } @@ -102,6 +99,7 @@ namespace rfb { // - Set/get the toolbar's state void setShowToolbar(bool st); bool isToolbarEnabled() { return showToolbar; } + void refreshToolbarButtons(); // - Set whether to disable special Windows keys & pass them straight to server void setDisableWinKeys(bool dwk); -- 2.39.5