summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:59:39 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:59:39 +0000
commitd90922ab28157a9ea704e210484953abb06bea6f (patch)
tree415ee4a0321a20d9d55ba86c97976dcf5d8b1f70 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls
parente60e1df5284c93b25cf6f6a477b924850dffb9d5 (diff)
downloadmocca-d90922ab28157a9ea704e210484953abb06bea6f.tar.gz
mocca-d90922ab28157a9ea704e210484953abb06bea6f.tar.bz2
mocca-d90922ab28157a9ea704e210484953abb06bea6f.zip
Main Bar improvements
Configuration fixed git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@70 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java125
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java5
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java73
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java74
5 files changed, 237 insertions, 51 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java
index d67ecfc3..e0e33427 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java
@@ -36,6 +36,10 @@ import org.slf4j.LoggerFactory;
* Main Bar Button implementation
*/
public abstract class MainBarButton extends Canvas {
+
+ public static final int GradientFactor = 4;
+ public static final int SplitFactor = 10;
+
/**
* @param parent
* @param style
@@ -64,11 +68,13 @@ public abstract class MainBarButton extends Canvas {
this.setCursor(hand);
- this.inactiveBackground = new Color(getDisplay(), 0x4B, 0x95, 0x00);
- this.activeBackground = new Color(getDisplay(), 0x98, 0xF2, 0x3D);
+ this.inactiveBackground = new Color(getDisplay(), 0xC7, 0xDD, 0xE7);
+ this.activeBackground = new Color(getDisplay(), 0x7A, 0xC2, 0xD3);
this.textColor = this.getForeground();
- this.borderColor = new Color(getDisplay(), 0x76, 0xC4, 0xC8);
+ this.borderColor = new Color(getDisplay(), 0x7E, 0x9F, 0xA5);
+ this.inactiveText = new Color(getDisplay(), 0x6E, 0x6C, 0x6E);
this.textsize = 12;
+
}
private Color inactiveBackground = null;
@@ -93,7 +99,7 @@ public abstract class MainBarButton extends Canvas {
* the text size
*/
protected int textsize = 12;
-
+
/**
* @return the textsize
*/
@@ -102,7 +108,8 @@ public abstract class MainBarButton extends Canvas {
}
/**
- * @param textsize the textsize to set
+ * @param textsize
+ * the textsize to set
*/
public void setTextsize(int textsize) {
this.textsize = textsize;
@@ -114,7 +121,8 @@ public abstract class MainBarButton extends Canvas {
protected Color textColor = null;
/**
- * @param textColor the textColor to set
+ * @param textColor
+ * the textColor to set
*/
public void setTextColor(Color textColor) {
this.textColor = textColor;
@@ -128,15 +136,18 @@ public abstract class MainBarButton extends Canvas {
}
/**
- * @param borderColor the borderColor to set
+ * @param borderColor
+ * the borderColor to set
*/
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
private Color borderColor = null;
-
+
private Color activeBackground = null;
+
+ private Color inactiveText = null;
private String text = ""; //$NON-NLS-1$
@@ -146,6 +157,7 @@ public abstract class MainBarButton extends Canvas {
/**
* Gets the image
+ *
* @return the image
*/
public Image getImage() {
@@ -154,7 +166,9 @@ public abstract class MainBarButton extends Canvas {
/**
* Sets the Image
- * @param image the imgage to set
+ *
+ * @param image
+ * the imgage to set
*/
public void setImage(Image image) {
this.image = image;
@@ -187,6 +201,7 @@ public abstract class MainBarButton extends Canvas {
/**
* Gets the button text
+ *
* @return the text
*/
public String getText() {
@@ -195,7 +210,9 @@ public abstract class MainBarButton extends Canvas {
/**
* Sets the text for the button
- * @param text the text to set
+ *
+ * @param text
+ * the text to set
*/
public void setText(String text) {
this.text = text;
@@ -214,50 +231,54 @@ public abstract class MainBarButton extends Canvas {
* @param e
*/
protected void paintBackground(PaintEvent e) {
-
- /*
Point size = this.getSize();
int height = size.y - 2;
int width = size.x;
-
- int factor = 4;
-
- // TOP
- e.gc.fillGradientRectangle(0, 0, width, factor, true);
-
- // BOTTOM
- e.gc.fillGradientRectangle(0, height, width, -1 * (factor), true);
- */
+
+ e.gc.setForeground(activeBackground);
+ e.gc.setBackground(inactiveBackground);
+
+ e.gc.fillGradientRectangle(0, height, width, -1 * height, true);
+
+ //e.gc.setBackground(activeBackground);
+
// LEFT
- //e.gc.fillGradientRectangle(0, 0, factor, height, false);
+ // e.gc.fillGradientRectangle(0, 0, factor, height, false);
// RIGTH
- //e.gc.fillGradientRectangle(width, 0, -1 * (width / factor), height,
- // false);
+ // e.gc.fillGradientRectangle(width, 0, -1 * (width / factor), height,
+ // false);
}
/**
* Main painting method
+ *
* @param e
*/
void paintControl(PaintEvent e) {
- this.paintBackground(e);
-
- Color current = e.gc.getForeground();
+ Color forecurrent = e.gc.getForeground();
+ Color backcurrent = e.gc.getBackground();
e.gc.setForeground(getBorderColor());
+ if(this.getActive()) {
+ this.paintBackground(e);
+ }
+
+ e.gc.setForeground(getBorderColor());
this.paintButton(e);
-
- e.gc.setForeground(current);
-
+
+ e.gc.setForeground(forecurrent);
+ e.gc.setBackground(backcurrent);
+
this.paintText(e);
}
/**
* paint the inner button
+ *
* @param e
*/
protected void paintButton(PaintEvent e) {
@@ -266,6 +287,7 @@ public abstract class MainBarButton extends Canvas {
/**
* Paint the text or image on the button
+ *
* @param e
*/
protected void paintText(PaintEvent e) {
@@ -282,25 +304,34 @@ public abstract class MainBarButton extends Canvas {
if (this.getText() != null) {
textlen = this.getText().length();
}
-
+
Color current = e.gc.getForeground();
-
- e.gc.setForeground(this.textColor);
-
+
+ if(this.getActive() && this.isEnabled()) {
+ e.gc.setForeground(this.textColor);
+ } else {
+ e.gc.setForeground(this.inactiveText);
+ }
+
String font_name = e.gc.getFont().getFontData()[0].getName();
-
- Font font = new Font(this.getDisplay(), font_name, this.getTextsize(), e.gc.getFont().getFontData()[0].getStyle() );
-
+
+ Font font = new Font(this.getDisplay(), font_name,
+ this.getTextsize(),
+ e.gc.getFont().getFontData()[0].getStyle());
+
e.gc.setFont(font);
-
+
int texty = (height - e.gc.getFontMetrics().getHeight()) / 2;
+
int textx = (width - e.gc.getFontMetrics().getAverageCharWidth()
* textlen) / 2;
+
+ textx = this.changeTextPosition(textx);
- e.gc.drawText(this.getText(), textx, texty);
-
+ e.gc.drawText(this.getText(), textx, texty, true);
+
font.dispose();
-
+
e.gc.setForeground(current);
} else {
int imgx = (width - height) / 2;
@@ -312,7 +343,19 @@ public abstract class MainBarButton extends Canvas {
}
/**
+ * change the text position
+ *
+ * @param positionX
+ * the position
+ * @return the new position
+ */
+ protected int changeTextPosition(int positionX) {
+ return positionX;
+ }
+
+ /**
* Gets the region of the button
+ *
* @return the button region
*/
protected abstract Region getCustomRegion();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java
index 1b749883..636de621 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java
@@ -76,7 +76,7 @@ public class MainBarEndButton extends MainBarButton {
int height = size.y - 2;
- int split = 10;
+ int split = SplitFactor;
int width = size.x;
@@ -86,4 +86,13 @@ public class MainBarEndButton extends MainBarButton {
return reg;
}
+ /**
+ * change the text position
+ * @param positionX the position
+ * @return the new position
+ */
+ @Override
+ protected int changeTextPosition(int positionX) {
+ return positionX + (SplitFactor / 2);
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java
index e6d469b6..6d992799 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java
@@ -52,7 +52,7 @@ public class MainBarMiddleButton extends MainBarButton {
int height = size.y - 3;
- int split = 10;
+ int split = SplitFactor;
int width = size.x - split;
e.gc.drawLine(0, 0, width, 0);
@@ -64,6 +64,7 @@ public class MainBarMiddleButton extends MainBarButton {
}
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion()
*/
@@ -73,7 +74,7 @@ public class MainBarMiddleButton extends MainBarButton {
int height = size.y - 2;
- int split = 10;
+ int split = SplitFactor;
int width = size.x - split;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java
index 6f8b8340..102d2c07 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java
@@ -44,26 +44,89 @@ public class MainBarRectangleButton extends MainBarButton {
private static final Logger log = LoggerFactory
.getLogger(MainBarRectangleButton.class);
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt.events.PaintEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt
+ * .events.PaintEvent)
*/
@Override
protected void paintButton(PaintEvent e) {
-
+
Point size = this.getSize();
int height = size.y - 3;
int width = size.x;
-
+
e.gc.drawLine(0, 0, width, 0);
e.gc.drawLine(width, 0, width, height);
e.gc.drawLine(width, height, 0, height);
e.gc.drawLine(0, height, 0, 0);
+
+ }
+
+ @Override
+ protected void paintBackground(PaintEvent e) {
+ Point size = this.getSize();
+ int height = size.y - 2;
+
+ int width = size.x;
+
+ int factor = GradientFactor;
+
+ Region left_reg = new Region();
+ left_reg.add(new int[] { 0, 0, factor, factor, factor, height-factor, 0, height, 0, 0 });
+
+ Region right_reg = new Region();
+ right_reg.add(new int[] { width, 0,
+ width - factor, factor,
+ width - factor, height-factor, width, height, width, 0 });
+
+ Region top_reg = new Region();
+ top_reg.add(new int[] {
+ 0, 0,
+ factor, factor,
+ width - factor, factor,
+ width, 0,
+ 0, 0 });
+
+ Region bottom_reg = new Region();
+ bottom_reg.add(new int[] {
+ 0, height,
+ factor, height-factor,
+ width - factor, height-factor,
+ width, height, 0, height });
+
+ e.gc.setClipping(top_reg);
+
+ //TOP
+ e.gc.fillGradientRectangle(0, 0, width, factor, true);
+
+ e.gc.setClipping(bottom_reg);
+
+ //BOTTOM
+ e.gc.fillGradientRectangle(0, height, width, -1 * (factor),
+ true);
+
+ e.gc.setClipping(left_reg);
+
+ // LEFT
+ e.gc.fillGradientRectangle(0, 0, factor, height, false);
+
+
+ e.gc.setClipping(right_reg);
+ // RIGTH
+ e.gc.fillGradientRectangle(width, 0, -1 * factor, height,
+ false);
+ e.gc.setClipping((Region)null);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java
index cbdfc05d..489f17b3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java
@@ -42,6 +42,66 @@ public class MainBarStartButton extends MainBarButton {
private static final Logger log = LoggerFactory
.getLogger(MainBarStartButton.class);
+ @Override
+ protected void paintBackground(PaintEvent e) {
+ super.paintBackground(e);
+ /*
+ Point size = this.getSize();
+ int height = size.y - 2;
+
+ int split = SplitFactor;
+ int width = size.x - split;
+
+ int factor = GradientFactor;
+
+ Region left_reg = new Region();
+ left_reg.add(new int[] { 0, 0, factor, factor, factor, height-factor, 0, height, 0, 0 });
+
+ Region right1_reg = new Region();
+ right1_reg.add(new int[] { width, 0,
+ width - factor, factor,
+ width - factor, height-factor, width, height, width, 0 });
+
+ Region top_reg = new Region();
+ top_reg.add(new int[] {
+ 0, 0,
+ factor, factor,
+ width - factor, factor,
+ width, 0,
+ 0, 0 });
+
+ Region bottom_reg = new Region();
+ bottom_reg.add(new int[] {
+ 0, height,
+ factor, height-factor,
+ width - factor, height-factor,
+ width, height, 0, height });
+
+ e.gc.setClipping(top_reg);
+
+ //TOP
+ e.gc.fillGradientRectangle(0, 0, width, factor, true);
+
+ e.gc.setClipping(bottom_reg);
+
+ //BOTTOM
+ e.gc.fillGradientRectangle(0, height, width, -1 * (factor),
+ true);
+
+ e.gc.setClipping(left_reg);
+
+ // LEFT
+ e.gc.fillGradientRectangle(0, 0, factor, height, false);
+
+
+ e.gc.setClipping(right1_reg);
+ // RIGTH
+ e.gc.fillGradientRectangle(width, 0, -1 * factor, height,
+ false);
+
+ e.gc.setClipping((Region)null);*/
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt.events.PaintEvent)
*/
@@ -52,7 +112,7 @@ public class MainBarStartButton extends MainBarButton {
int height = size.y - 3;
- int split = 10;
+ int split = SplitFactor;
int width = size.x - split;
e.gc.drawLine(0, 0, width, 0);
@@ -72,7 +132,7 @@ public class MainBarStartButton extends MainBarButton {
int height = size.y - 2;
- int split = 10;
+ int split = SplitFactor;
int width = size.x - split;
@@ -82,4 +142,14 @@ public class MainBarStartButton extends MainBarButton {
return reg;
}
+
+ /**
+ * change the text position
+ * @param positionX the position
+ * @return the new position
+ */
+ @Override
+ protected int changeTextPosition(int positionX) {
+ return positionX - (SplitFactor / 2);
+ }
}