Mercurial > hg > Applications > TightVNC_orginal
diff src/viewer_swing/java/com/glavsoft/viewer/swing/gui/OptionsDialog.java @ 52:472a9bcacb21 draft default tip
TightVNC 2.7.1.0
author | you@cr.ie.u-ryukyu.ac.jp |
---|---|
date | Wed, 07 Aug 2013 19:01:17 +0900 |
parents | 4689cc86d6cb |
children |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/OptionsDialog.java Tue Jul 03 13:20:49 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/OptionsDialog.java Wed Aug 07 19:01:17 2013 +0900 @@ -1,4 +1,4 @@ -// Copyright (C) 2010, 2011 GlavSoft LLC. +// Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. // All rights reserved. // //------------------------------------------------------------------------- @@ -27,6 +27,8 @@ import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.protocol.LocalPointer; import com.glavsoft.rfb.protocol.ProtocolSettings; +import com.glavsoft.viewer.swing.LocalMouseCursorShape; +import com.glavsoft.viewer.UiSettings; import javax.swing.*; import java.awt.*; @@ -43,14 +45,11 @@ private JSlider compressionLevel; private JCheckBox viewOnlyCheckBox; private ProtocolSettings settings; - private JCheckBox sharedSession; + private UiSettings uiSettings; + private JCheckBox sharedSession; private RadioButtonSelectedState<LocalPointer> mouseCursorTrackSelected; private Map<LocalPointer, JRadioButton> mouseCursorTrackMap; - -// private RadioButtonSelectedState<Integer> colorDepthSelected; -// private Map<Integer, JRadioButton> colorDepthMap; - private JCheckBox useCompressionLevel; private JCheckBox useJpegQuality; private JLabel jpegQualityPoorLabel; @@ -61,9 +60,11 @@ private JComboBox encodings; private JCheckBox disableClipboardTransfer; private JComboBox colorDepth; + private RadioButtonSelectedState<LocalMouseCursorShape> mouseCursorShapeSelected; + private HashMap<LocalMouseCursorShape, JRadioButton> mouseCursorShapeMap; - public OptionsDialog(Window owner) { - super(owner, "Connection Options", ModalityType.MODELESS); + public OptionsDialog(Window owner) { + super(owner, "Connection Options", ModalityType.DOCUMENT_MODAL); final WindowAdapter onClose = new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { @@ -83,25 +84,11 @@ pack(); } - public void initControlsFromSettings(ProtocolSettings settings, boolean isOnConnect) { + public void initControlsFromSettings(ProtocolSettings settings, UiSettings uiSettings, boolean isOnConnect) { this.settings = settings; - - viewOnlyCheckBox.setSelected(settings.isViewOnly()); + this.uiSettings = uiSettings; -// String scaling = String.valueOf((int)(settings.scaling * 100)); -// int i = 0; boolean isNotSetScale = true; -// while ( scaleCombo.getItemAt(i) != null) { -// String item = (String)scaleCombo.getItemAt(i); -// if (item.equals(scaling)) { -// scaleCombo.setSelectedIndex(i); -// isNotSetScale = false; -// break; -// } -// ++i; -// } -// if (isNotSetScale) { -// scaleCombo.setSelectedItem(SCALE_100); -// } + viewOnlyCheckBox.setSelected(settings.isViewOnly()); int i = 0; boolean isNotSetEncoding = true; while ( encodings.getItemAt(i) != null) { @@ -122,19 +109,14 @@ mouseCursorTrackMap.get(settings.getMouseCursorTrack()).setSelected(true); mouseCursorTrackSelected.setSelected(settings.getMouseCursorTrack()); + mouseCursorShapeMap.get(uiSettings.getMouseCursorShape()).setSelected(true); + mouseCursorShapeSelected.setSelected(uiSettings.getMouseCursorShape()); -// settings.setBitsPerPixel(settings.getBitsPerPixel()); // when 0 set default bpp value -// final JRadioButton colorDepthRadioButton = colorDepthMap.get(settings.getBitsPerPixel()); -// if (colorDepthRadioButton != null) { -// colorDepthRadioButton.setSelected(true); -// } -// colorDepthSelected.setSelected(settings.getBitsPerPixel()); - - int bpp = settings.getBitsPerPixel(); + int depth = settings.getColorDepth(); i = 0; boolean isNotSet = true; while ( colorDepth.getItemAt(i) != null) { - int itemBpp = ((ColorDepthSelectItem)colorDepth.getItemAt(i)).bpp; - if (itemBpp == bpp) { + int itemDepth = ((ColorDepthSelectItem)colorDepth.getItemAt(i)).depth; + if (itemDepth == depth) { colorDepth.setSelectedIndex(i); isNotSet = false; break; @@ -163,8 +145,9 @@ settings.setSharedFlag(sharedSession.isSelected()); settings.setMouseCursorTrack(mouseCursorTrackSelected.getSelected()); + uiSettings.setMouseCursorShape(mouseCursorShapeSelected.getSelected()); - settings.setBitsPerPixel(((ColorDepthSelectItem)colorDepth.getSelectedItem()).bpp); + settings.setColorDepth(((ColorDepthSelectItem) colorDepth.getSelectedItem()).depth); settings.setCompressionLevel(useCompressionLevel.isSelected() ? compressionLevel.getValue() : @@ -192,9 +175,8 @@ box.setAlignmentX(LEFT_ALIGNMENT); box.add(createRestrictionsPanel()); -// box.add(createDisplayPanel()); box.add(createMouseCursorPanel()); -// box.add(createLocalShapePanel()); + box.add(createLocalShapePanel()); sharedSession = new JCheckBox("Request shared session"); box.add(new JPanel(new FlowLayout(FlowLayout.LEFT)).add(sharedSession)); @@ -205,7 +187,6 @@ private JPanel createRestrictionsPanel() { JPanel restrictionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); -// restrictionsPanel.setAlignmentX(LEFT_ALIGNMENT); restrictionsPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Restrictions")); @@ -272,10 +253,10 @@ } private static class ColorDepthSelectItem { - final int bpp; + final int depth; final String title; - public ColorDepthSelectItem(int bpp, String title) { - this.bpp = bpp; + public ColorDepthSelectItem(int depth, String title) { + this.depth = depth; this.title = title; } @Override @@ -290,32 +271,24 @@ colorDepthPanel.add(new JLabel("Color format: ")); colorDepth = new JComboBox(); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_SERVER_SETTINGS, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_SERVER_SETTINGS, "Server's default")); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_32, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_24, "16 777 216 colors")); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_16, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_16, "65 536 colors")); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_8, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_8, "256 colors")); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_6, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_6, "64 colors")); - colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.BPP_3, + colorDepth.addItem(new ColorDepthSelectItem(ProtocolSettings.COLOR_DEPTH_3, "8 colors")); colorDepthPanel.add(colorDepth); colorDepth.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - final ColorDepthSelectItem selectedItem = - (ColorDepthSelectItem) colorDepth.getSelectedItem(); - setEnabled(selectedItem.bpp > ProtocolSettings.BPP_8 || - selectedItem.bpp == ProtocolSettings.BPP_SERVER_SETTINGS, - useJpegQuality); - setEnabled(useJpegQuality.isSelected() && - (selectedItem.bpp > ProtocolSettings.BPP_8 || - selectedItem.bpp == ProtocolSettings.BPP_SERVER_SETTINGS), - jpegQuality, jpegQualityPoorLabel, jpegQualityBestLabel); + setJpegQualityPaneEnable(); } }); return colorDepthPanel; @@ -356,17 +329,20 @@ protected void setJpegQualityPaneEnable() { if (useJpegQuality != null && colorDepth != null) { - int bpp = ((ColorDepthSelectItem)colorDepth.getSelectedItem()).bpp; - setEnabled( - bpp > ProtocolSettings.BPP_8 || bpp == ProtocolSettings.BPP_SERVER_SETTINGS, - useJpegQuality); - setEnabled(useJpegQuality.isSelected() && - (bpp > ProtocolSettings.BPP_8 || bpp == ProtocolSettings.BPP_SERVER_SETTINGS), + int depth = ((ColorDepthSelectItem)colorDepth.getSelectedItem()).depth; + setEnabled(whetherJpegQualityPaneBeEnabled(depth), useJpegQuality); + setEnabled(useJpegQuality.isSelected() && whetherJpegQualityPaneBeEnabled(depth), jpegQuality, jpegQualityPoorLabel, jpegQualityBestLabel); } } - private void addCompressionLevelPane(JPanel encodingsPanel) { + private boolean whetherJpegQualityPaneBeEnabled(int depth) { + return ProtocolSettings.COLOR_DEPTH_16 == depth || + ProtocolSettings.COLOR_DEPTH_24 == depth || + ProtocolSettings.COLOR_DEPTH_SERVER_SETTINGS == depth; + } + + private void addCompressionLevelPane(JPanel encodingsPanel) { useCompressionLevel = new JCheckBox("Custom compression level:"); useCompressionLevel.setAlignmentX(LEFT_ALIGNMENT); encodingsPanel.add(useCompressionLevel); @@ -410,7 +386,6 @@ } } - /* private JPanel createLocalShapePanel() { JPanel localCursorShapePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); // localCursorShapePanel.setLayout(new BoxLayout(localCursorShapePanel, BoxLayout.Y_AXIS)); @@ -420,23 +395,29 @@ Box localCursorShapeBox = Box.createVerticalBox(); localCursorShapePanel.add(localCursorShapeBox); - JRadioButton dotCursorRadio = new JRadioButton("Dot cursor"); - JRadioButton smallDotCursorRadio = new JRadioButton("Small dot cursor"); - JRadioButton arrowCursorRadio = new JRadioButton("Default cursor"); - JRadioButton noCursorRadio = new JRadioButton("No local cursor"); - localCursorShapeBox.add(dotCursorRadio); - localCursorShapeBox.add(smallDotCursorRadio); - localCursorShapeBox.add(arrowCursorRadio); - localCursorShapeBox.add(noCursorRadio); - ButtonGroup localCursorButtonGroup = new ButtonGroup(); - localCursorButtonGroup.add(dotCursorRadio); - localCursorButtonGroup.add(smallDotCursorRadio); - localCursorButtonGroup.add(arrowCursorRadio); - localCursorButtonGroup.add(noCursorRadio); + ButtonGroup mouseCursorShapeTrackGroup = new ButtonGroup(); + mouseCursorShapeSelected = new RadioButtonSelectedState<LocalMouseCursorShape>(); + mouseCursorShapeMap = new HashMap<LocalMouseCursorShape, JRadioButton>(); + + addRadioButton("Dot cursor", LocalMouseCursorShape.DOT, + mouseCursorShapeSelected, mouseCursorShapeMap, localCursorShapeBox, + mouseCursorShapeTrackGroup); + + addRadioButton("Small dot cursor", LocalMouseCursorShape.SMALL_DOT, + mouseCursorShapeSelected, mouseCursorShapeMap, localCursorShapeBox, + mouseCursorShapeTrackGroup); + + addRadioButton("System default cursor", LocalMouseCursorShape.SYSTEM_DEFAULT, + mouseCursorShapeSelected, mouseCursorShapeMap, localCursorShapeBox, + mouseCursorShapeTrackGroup); + + addRadioButton("No local cursor", LocalMouseCursorShape.NO_CURSOR, + mouseCursorShapeSelected, mouseCursorShapeMap, localCursorShapeBox, + mouseCursorShapeTrackGroup); + return localCursorShapePanel; } -*/ - + private JPanel createMouseCursorPanel() { JPanel mouseCursorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mouseCursorPanel.setBorder(