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();
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()) {
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)
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) {
}
buffer->setScaleRatio(scale_ratio);
if (repaint) InvalidateRect(frameHandle, 0, TRUE);
+ if (isToolbarEnabled()) refreshToolbarButtons();
}
void
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(); }
// - 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);