private String displayDPI = "";
private Skin skin = null;
+ boolean isCustomResolution = false;
+
private void createDisplayInfomation() {
Composite comp = createSubComp(1, TITLE_RESOLUTION);
// resolution label
resolutionCombo.addItem(res.toString());
}
- // select resolution
- // TODO default resolution
+ selectResolutionCombo();
+ setResolutionTextBox();
+
+
+ // close popup if it is opened.
+ resolutionCombo.closeComboBox();
+ }
+
+ private void selectResolutionCombo() {
+
+
String re = null;
if (resolution != null) {
re = resolution.toString();
}
}
if (index == -1) {
+ // add resolution
+ resList.add(0, resolution);
+ resolutionCombo.addItem(0, resolution.toString());
resolutionCombo.select(0);
- resolution = resList.get(0);
+
} else {
resolutionCombo.select(index);
+ resolutionCombo.redraw();
}
-
- resolutionComboSelected(re);
-
- // close popup if it is opened.
- resolutionCombo.closeComboBox();
}
switch(event.type) {
case SWT.Selection:
resolutionComboSelected(resolutionCombo.getSelectedItem());
+ isCustomResolution = false;
default:
break;
@Override
public void modifyText(ModifyEvent e) {
displayWidth = widthTextBox.getValue();
+ setCustomResolution();
getDialog().checkValid();
}
});
@Override
public void modifyText(ModifyEvent e) {
displayHeight = heightTextBox.getValue();
+ setCustomResolution();
getDialog().checkValid();
}
});
}
+ private void setCustomResolution() {
+ if (!checkDisplayWidthHeight()) {
+ return;
+ }
+ int width = Integer.parseInt(displayWidth);
+ int height = Integer.parseInt(displayHeight);
+ if (width == resolution.getResolution().getWidth()
+ && height == resolution.getResolution().getHeight()) {
+ if (isCustomResolution) {
+ isCustomResolution = false;
+ selectResolutionCombo();
+ }
+ return;
+ }
+
+ // is in res list ?
+ for (RESOLUTION res : resList) {
+ if (width == res.getResolution().getWidth()
+ && height == res.getResolution().getHeight()) {
+ if (!isCustomResolution) {
+ return;
+ }
+ resolution = res;
+ selectResolutionCombo();
+ isCustomResolution = false;
+ return;
+ }
+ }
+
+ // set "custom" in combobox
+ resolutionCombo.setText("(custom)");
+ resolutionCombo.setToolTipText("(custom)");
+ isCustomResolution = true;
+ }
+
private void createSkinItem() {
@Override
public void setValue(PropertyValue value) {
// set resolution
+ if (isCustomResolution) {
+ resolution = new RESOLUTION(
+ Integer.parseInt(displayWidth),
+ Integer.parseInt(displayHeight),
+ "custom", 0);
+ }
+
value.setResolution(resolution);
+
try {
// set display size (inch)
value.setDisplaySize(Double.parseDouble(displaySize));
return false;
}
+ if (!checkDisplayWidthHeight()) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ private boolean checkDisplayWidthHeight() {
// TODO check display width/height
if (displayWidth.isEmpty() || displayHeight.isEmpty()) {
return false;
// change size
DisplayItem srcItem = (DisplayItem)srcDialogItem;
- resList = srcItem.getResolutionList();
+ resList.clear();
+ for (RESOLUTION res : srcItem.getResolutionList()) {
+ resList.add(res);
+ }
initResolutionCombo();
// change size
}
public void addItem(String item) {
- items.add(item);
- datas.add(null);
+ addItem(items.size(), item);
}
+
+ public void addItem(int index, String item) {
+ addItem(index, item, null);
+ }
+
+
public void addItem(String item, Object data) {
- items.add(item);
- datas.add(data);
+ addItem(items.size(), item, data);
}
+
+ public void addItem(int index, String item, Object data) {
+ try {
+ items.add(index, item);
+ } catch (IndexOutOfBoundsException e) {
+ items.add(item);
+ }
+
+ try {
+ datas.add(index, data);
+ } catch (IndexOutOfBoundsException e) {
+ datas.add(data);
+ }
+ }
+
+
@Override
public void redraw() {
textCanvas.redraw();
});
}
+ public void setText(String text) {
+ selectedItem = text;
+ redraw();
+ }
+
@Override
protected void draw(PaintEvent e) {