summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java63
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java47
2 files changed, 62 insertions, 48 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
index 31aed38d..54f177b3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
@@ -15,8 +15,13 @@
*/
package at.asit.pdfover.gui.composites;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
// Imports
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import at.asit.pdfover.gui.workflow.states.State;
@@ -25,7 +30,7 @@ import at.asit.pdfover.gui.workflow.states.State;
*/
public abstract class StateComposite extends Composite {
- /**
+ /**
* Current State
*/
protected State state;
@@ -52,4 +57,60 @@ public abstract class StateComposite extends Composite {
* Reloads the localizeable resources
*/
public abstract void reloadResources();
+
+ public static void setFontHeight(Control c, int height)
+ {
+ FontData[] fD = c.getFont().getFontData();
+ fD[0].setHeight(height);
+ Font font = new Font(c.getDisplay(), fD[0]);
+ c.setFont(font);
+ font.dispose();
+ }
+
+ public static void setFontStyle(Control c, int style)
+ {
+ FontData[] fD = c.getFont().getFontData();
+ fD[0].setStyle(style);
+ Font font = new Font(c.getDisplay(), fD[0]);
+ c.setFont(font);
+ font.dispose();
+ }
+
+ public static class AnchorSetter
+ {
+ private final Control c;
+ private final FormData fd = new FormData();
+ public AnchorSetter(Control c) { this.c = c; }
+
+ public void set() { this.c.setLayoutData(this.fd); }
+
+ public AnchorSetter height(int h) { fd.height = h; return this; }
+ public AnchorSetter width(int w) { fd.width = w; return this; }
+
+ public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
+ public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
+ public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
+ public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
+
+ public AnchorSetter top(Control control, int offset, int alignment) { return top(new FormAttachment(control, offset, alignment)); }
+ public AnchorSetter top(Control control, int offset) { return top(new FormAttachment(control, offset)); }
+ public AnchorSetter top(int num, int offset) { return top(new FormAttachment(num, offset)); }
+ public AnchorSetter top(int num) { return top(new FormAttachment(num)); }
+
+ public AnchorSetter left(Control control, int offset, int alignment) { return left(new FormAttachment(control, offset, alignment)); }
+ public AnchorSetter left(Control control, int offset) { return left(new FormAttachment(control, offset)); }
+ public AnchorSetter left(int num, int offset) { return left(new FormAttachment(num, offset)); }
+ public AnchorSetter left(int num) { return left(new FormAttachment(num)); }
+
+ public AnchorSetter right(Control control, int offset, int alignment) { return right(new FormAttachment(control, offset, alignment)); }
+ public AnchorSetter right(Control control, int offset) { return right(new FormAttachment(control, offset)); }
+ public AnchorSetter right(int num, int offset) { return right(new FormAttachment(num, offset)); }
+ public AnchorSetter right(int num) { return right(new FormAttachment(num)); }
+
+ public AnchorSetter bottom(Control control, int offset, int alignment) { return bottom(new FormAttachment(control, offset, alignment)); }
+ public AnchorSetter bottom(Control control, int offset) { return bottom(new FormAttachment(control, offset)); }
+ public AnchorSetter bottom(int num, int offset) { return bottom(new FormAttachment(num, offset)); }
+ public AnchorSetter bottom(int num) { return bottom(new FormAttachment(num)); }
+ }
+ public static AnchorSetter anchor(Control c) { return new AnchorSetter(c); }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java
index 1721bcf4..c496efef 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java
@@ -16,12 +16,7 @@
package at.asit.pdfover.gui.composites.configuration;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import at.asit.pdfover.gui.composites.StateComposite;
@@ -66,48 +61,6 @@ public abstract class ConfigurationCompositeBase extends StateComposite {
*/
protected abstract void signerChanged();
- protected static void setFontHeight(Control c, int height)
- {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setHeight(height);
- c.setFont(new Font(Display.getCurrent(), fD[0]));
- }
-
- protected static class AnchorSetter
- {
- private final Control c;
- private final FormData fd = new FormData();
- private AnchorSetter(Control c) { this.c = c; }
-
- public void set() { this.c.setLayoutData(this.fd); }
-
- public AnchorSetter height(int h) { fd.height = h; return this; }
- public AnchorSetter width(int w) { fd.width = w; return this; }
-
- public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
- public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
- public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
- public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
-
- public AnchorSetter top(Control control, int offset) { return top(new FormAttachment(control, offset)); }
- public AnchorSetter top(int num, int offset) { return top(new FormAttachment(num, offset)); }
- public AnchorSetter top(int num) { return top(new FormAttachment(num)); }
-
- public AnchorSetter left(Control control, int offset) { return left(new FormAttachment(control, offset)); }
- public AnchorSetter left(int num, int offset) { return left(new FormAttachment(num, offset)); }
- public AnchorSetter left(int num) { return left(new FormAttachment(num)); }
-
- public AnchorSetter right(Control control, int offset) { return right(new FormAttachment(control, offset)); }
- public AnchorSetter right(int num, int offset) { return right(new FormAttachment(num, offset)); }
- public AnchorSetter right(int num) { return right(new FormAttachment(num)); }
-
- public AnchorSetter bottom(Control control, int offset) { return bottom(new FormAttachment(control, offset)); }
- public AnchorSetter bottom(int num, int offset) { return bottom(new FormAttachment(num, offset)); }
- public AnchorSetter bottom(int num) { return bottom(new FormAttachment(num)); }
- }
-
- protected static AnchorSetter anchor(Control c) { return new AnchorSetter(c); }
-
/**
* @param parent
* @param style