Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 309:31d86f0ee977
create fit screen button
author | oc |
---|---|
date | Thu, 22 Jan 2015 11:17:50 +0900 |
parents | d1d6c7306281 |
children | 9b70bfdef8bd |
files | src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java |
diffstat | 3 files changed, 50 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Thu Jan 22 01:02:19 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Thu Jan 22 11:17:50 2015 +0900 @@ -108,10 +108,10 @@ fireListeners(); } - public void adjustHdSize(int width) { + public void adjustHdSize(int singleWidth) { double hdWidth = 1920.0; double defaultScaleFactor = 100.0; - double scaleFactor = (hdWidth / width) * defaultScaleFactor; + double scaleFactor = (hdWidth / singleWidth) * defaultScaleFactor; if (scaleFactor > MAX_SCALE_PERCENT) { scaleFactor = MAX_SCALE_PERCENT; } @@ -197,4 +197,27 @@ '}'; } + public void fitScreen(int thisScreenWidth, int thisScreenHeight, int singleWidth, int singleHeight) { + double doubleThisWidth = (double) thisScreenWidth; + double doubleThisHeight = (double) thisScreenHeight; + + double widthScale = (doubleThisWidth/singleWidth); + double heightScale = (doubleThisHeight/singleHeight); + double defaultScaleFactor = 100.0; + double scaleFactor = 100.0; + + double diff = widthScale - heightScale; + + if(diff == 0) { + scaleFactor = defaultScaleFactor * widthScale; + setScalePercent(scaleFactor); + } else if(diff > 0) { + scaleFactor = defaultScaleFactor * heightScale; + } + if (scaleFactor > MAX_SCALE_PERCENT) { + scaleFactor = MAX_SCALE_PERCENT; + } + setScalePercent(scaleFactor); + fireListeners(); + } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Thu Jan 22 01:02:19 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Thu Jan 22 11:17:50 2015 +0900 @@ -322,8 +322,10 @@ } } // set full size + /* dim.width = workareaRectangle.width; dim.height = workareaRectangle.height; + */ if ( ! location.equals(frame.getLocation())) { frame.setLocation(location); } @@ -908,6 +910,28 @@ }); kbdButtons.add(adjustHdSizeButton); + final JButton fitScreenButton = buttonsBar.createButton("fit-screen", "Fit Screen", new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); + int leftScreenNumber = 0; + int thisScreenWidth = (int) rectangles.get(leftScreenNumber).getWidth(); + int thisScreenHeight = (int) rectangles.get(leftScreenNumber).getHeight(); + + int singleWidth = viewer.getRfb().getSingleWidth(); + int singleHeight = viewer.getRfb().getSingleHeight(); + if (viewer.getRfb().isTreeManager()) { + System.out.println(singleWidth); + uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, singleWidth, singleHeight); + return; + } + context.sendMessage(new RequestSingleDisplayWidth()); + System.out.println(singleWidth); + uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, singleWidth, singleHeight); + } + }); + kbdButtons.add(fitScreenButton); + ModifierButtonEventListener modifierButtonListener = new ModifierButtonEventListener(); modifierButtonListener.addButton(KeyEvent.VK_CONTROL, ctrlButton); modifierButtonListener.addButton(KeyEvent.VK_ALT, altButton);
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java Thu Jan 22 01:02:19 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java Thu Jan 22 11:17:50 2015 +0900 @@ -261,7 +261,7 @@ if (uiSettingsData != null) { uiSettingsDataMap.put(new ConnectionParams(connectionParams), new UiSettingsData(uiSettingsData)); } -// uiSettingsData.setScalePercent(100); +// uiSettingsData.setScalePercent(50); } /**