});
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
- if (cc.options.autoScale || cc.options.fixedRatioScale) {
- if (sp.getSize().width != cc.desktop.scaledWidth ||
- sp.getSize().height != cc.desktop.scaledHeight) {
+ if ((getExtendedState() != JFrame.MAXIMIZED_BOTH) &&
+ cc.fullScreen) {
+ cc.toggleFullScreen();
+ }
+ String scaleString = cc.viewer.scalingFactor.getValue();
+ if (scaleString.equals("Auto") || scaleString.equals("FixedRatio")) {
+ if ((sp.getSize().width != cc.desktop.scaledWidth) ||
+ (sp.getSize().height != cc.desktop.scaledHeight)) {
+ int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
+ sp.setHorizontalScrollBarPolicy(policy);
cc.desktop.setScaledSize();
sp.setSize(new Dimension(cc.desktop.scaledWidth,
cc.desktop.scaledHeight));
sp.validate();
- pack();
- update(g);
+ if (getExtendedState() != JFrame.MAXIMIZED_BOTH)
+ pack();
if (cc.desktop.cursor != null) {
Cursor cursor = cc.desktop.cursor;
cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot,
- cursor.data, cursor.mask);
+ cursor.data, cursor.mask);
}
}
- }
+ } else {
+ int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
+ sp.setHorizontalScrollBarPolicy(policy);
+ sp.validate();
+ }
}
});
}
} else {
setSize(w, h);
}
- if (!cc.options.autoScale && !cc.options.fixedRatioScale)
+ if (!cc.fullScreen)
setLocation(x, y);
setBackground(Color.BLACK);
}
if (!pack)
viewport.setPreferredSize(new Dimension(w,h));
- int x = (dpySize.width - w - wmDecorationWidth) / 2;
- int y = (dpySize.height - h - wmDecorationHeight)/2;
-
- viewport.setExtendedState(JFrame.NORMAL);
- viewport.setGeometry(x, y, w, h, pack);
+ if (viewport.getExtendedState() == JFrame.MAXIMIZED_BOTH) {
+ w = viewport.getSize().width;
+ h = viewport.getSize().height;
+ int x = viewport.getLocation().x;
+ int y = viewport.getLocation().y;
+ viewport.setGeometry(x, y, w, h, pack);
+ } else {
+ int x = (dpySize.width - w - wmDecorationWidth) / 2;
+ int y = (dpySize.height - h - wmDecorationHeight)/2;
+ viewport.setExtendedState(JFrame.NORMAL);
+ viewport.setGeometry(x, y, w, h, pack);
+ }
}
viewport.update(viewport.g);
}
options.useLocalCursor.setSelected(viewer.useLocalCursor.getValue());
options.fastCopyRect.setSelected(viewer.fastCopyRect.getValue());
options.acceptBell.setSelected(viewer.acceptBell.getValue());
- options.autoScale = false;
- options.fixedRatioScale = false;
String scaleString = viewer.scalingFactor.getValue();
if (scaleString.equals("Auto")) {
- options.autoScale = true;
options.scalingFactor.setSelectedItem("Auto");
- // FIXME: set scaleFactor?
} else if(scaleString.equals("FixedRatio")) {
- options.fixedRatioScale = true;
options.scalingFactor.setSelectedItem("Fixed Aspect Ratio");
- // FIXME: set scaleFactor?
} else {
digit = Integer.parseInt(scaleString);
if (digit >= 1 && digit <= 1000) {
options.scalingFactor.setSelectedItem(digit+"%");
} else {
- options.scalingFactor.setSelectedItem(Integer.parseInt(viewer.scalingFactor.getDefaultStr())+"%");
+ digit = Integer.parseInt(viewer.scalingFactor.getDefaultStr());
+ options.scalingFactor.setSelectedItem(digit+"%");
}
- scaleFactor =
+ int scaleFactor =
Integer.parseInt(scaleString.substring(0, scaleString.length()));
if (desktop != null)
desktop.setScaledSize();
viewer.sendClipboard.setParam(options.sendClipboard.isSelected());
viewer.fastCopyRect.setParam(options.fastCopyRect.isSelected());
viewer.acceptBell.setParam(options.acceptBell.isSelected());
- if (options.autoScale) {
+ String scaleString =
+ options.scalingFactor.getSelectedItem().toString();
+ if (scaleString.equals("Auto")) {
viewer.scalingFactor.setParam("Auto");
- scaleFactor = -1;
- if (desktop != null) {
+ if (desktop != null)
reconfigureViewport();
- viewport.update(viewport.g);
- }
- } else if(options.fixedRatioScale) {
+ } else if(scaleString.equals("Fixed Aspect Ratio")) {
viewer.scalingFactor.setParam("FixedRatio");
- scaleFactor = -1;
- if (desktop != null) {
+ if (desktop != null)
reconfigureViewport();
- viewport.update(viewport.g);
- }
} else {
- String scaleString =
- options.scalingFactor.getSelectedItem().toString();
- viewer.scalingFactor.setParam(scaleString.substring(0, scaleString.length()-1));
- int oldScaleFactor = scaleFactor;
- scaleFactor =
- Integer.parseInt(scaleString.substring(0, scaleString.length()-1));
- if (oldScaleFactor != scaleFactor && desktop != null) {
+ scaleString=scaleString.substring(0, scaleString.length()-1);
+ String oldScaleFactor = viewer.scalingFactor.getValue();
+ viewer.scalingFactor.setParam(scaleString);
+ if ((desktop != null) && (!oldScaleFactor.equals("Auto") ||
+ !oldScaleFactor.equals("FixedRatio"))) {
reconfigureViewport();
- viewport.update(viewport.g);
}
}
boolean firstUpdate;
boolean pendingUpdate;
- int scaleFactor = 100;
-
static LogWriter vlog = new LogWriter("CConn");
}
}
public void setScaledSize() {
- if (!cc.options.autoScale && !cc.options.fixedRatioScale) {
- scaledWidth = (int)Math.floor((float)cc.cp.width * (float)cc.scaleFactor/100.0);
- scaledHeight = (int)Math.floor((float)cc.cp.height * (float)cc.scaleFactor/100.0);
+ String scaleString = cc.viewer.scalingFactor.getValue();
+ if (!scaleString.equals("Auto") && !scaleString.equals("FixedRatio")) {
+ int scalingFactor = Integer.parseInt(scaleString);
+ scaledWidth =
+ (int)Math.floor((float)cc.cp.width * (float)scalingFactor/100.0);
+ scaledHeight =
+ (int)Math.floor((float)cc.cp.height * (float)scalingFactor/100.0);
} else {
if (cc.viewport == null) {
scaledWidth = cc.cp.width;
vpSize.height - vpInsets.top - vpInsets.bottom);
if (availableSize.width == 0 || availableSize.height == 0)
availableSize = new Dimension(cc.cp.width, cc.cp.height);
- if (cc.options.fixedRatioScale) {
+ if (scaleString.equals("FixedRatio")) {
float widthRatio = (float)availableSize.width / (float)cc.cp.width;
float heightRatio = (float)availableSize.height / (float)cc.cp.height;
float ratio = Math.min(widthRatio, heightRatio);