From dff2e350246d462dd8a70fb211e08554bcf95723 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 3 Oct 2012 08:42:03 +0200 Subject: Main Bar improvements Configuration fixed --- .../asit/pdfover/gui/controls/MainBarButton.java | 125 ++++++++++++++------- .../pdfover/gui/controls/MainBarEndButton.java | 11 +- .../pdfover/gui/controls/MainBarMiddleButton.java | 5 +- .../gui/controls/MainBarRectangleButton.java | 73 +++++++++++- .../pdfover/gui/controls/MainBarStartButton.java | 74 +++++++++++- 5 files changed, 237 insertions(+), 51 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index d67ecfc3..e0e33427 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/trunk/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; @@ -311,8 +342,20 @@ 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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java index 1b749883..636de621 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java +++ b/trunk/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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java index e6d469b6..6d992799 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java +++ b/trunk/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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java index 6f8b8340..102d2c07 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java +++ b/trunk/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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java index cbdfc05d..489f17b3 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java +++ b/trunk/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); + } } -- cgit v1.2.3 From 4dd054cc2ff1a8533645b19d09caa43700941b48 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 4 Oct 2012 11:59:45 +0200 Subject: + Implemented behavior with set default output folder + centralized font sizes + added comments for documentation --- .../at/asit/pdfover/gui/controls/MainBarButton.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index e0e33427..4992ef1a 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -32,12 +32,23 @@ import org.eclipse.swt.widgets.Listener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.composites.StateComposite; + /** * Main Bar Button implementation */ public abstract class MainBarButton extends Canvas { + /** + * If borders are drawn with a gradient effect this sets the size + */ public static final int GradientFactor = 4; + + /** + * Number of pixel of the altitude of the triangle representing the arrow within the button shapes + * + * This should be a multiple of 2! + */ public static final int SplitFactor = 10; /** @@ -73,7 +84,7 @@ public abstract class MainBarButton extends Canvas { this.textColor = this.getForeground(); this.borderColor = new Color(getDisplay(), 0x7E, 0x9F, 0xA5); this.inactiveText = new Color(getDisplay(), 0x6E, 0x6C, 0x6E); - this.textsize = 12; + this.textsize = StateComposite.TEXT_SIZE_BUTTON; } @@ -98,7 +109,7 @@ public abstract class MainBarButton extends Canvas { /** * the text size */ - protected int textsize = 12; + protected int textsize = StateComposite.TEXT_SIZE_BUTTON; /** * @return the textsize @@ -236,8 +247,8 @@ public abstract class MainBarButton extends Canvas { int width = size.x; - e.gc.setForeground(activeBackground); - e.gc.setBackground(inactiveBackground); + e.gc.setForeground(this.activeBackground); + e.gc.setBackground(this.inactiveBackground); e.gc.fillGradientRectangle(0, height, width, -1 * height, true); -- cgit v1.2.3 From 8a08fb663f3034e8368c407a6780336080ea77dd Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 9 Oct 2012 15:50:00 +0200 Subject: Not scaling config image --- .../src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index 4992ef1a..576c1216 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -346,8 +346,7 @@ public abstract class MainBarButton extends Canvas { e.gc.setForeground(current); } else { int imgx = (width - height) / 2; - Image tmp = new Image(getDisplay(), this.image.getImageData() - .scaledTo(height, height)); + Image tmp = new Image(getDisplay(), this.image.getImageData()); e.gc.drawImage(tmp, imgx, 0); } -- cgit v1.2.3 From 00a903a6afda07526e6c123cb8b758b609e6ad5b Mon Sep 17 00:00:00 2001 From: vkrnjic Date: Wed, 17 Oct 2012 14:07:52 +0200 Subject: new colors based on buergerkarte.at --- .../at/asit/pdfover/gui/controls/MainBarButton.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index 576c1216..5ee261f1 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -42,7 +42,7 @@ public abstract class MainBarButton extends Canvas { /** * If borders are drawn with a gradient effect this sets the size */ - public static final int GradientFactor = 4; + public static final int GradientFactor = 5; /** * Number of pixel of the altitude of the triangle representing the arrow within the button shapes @@ -79,16 +79,19 @@ public abstract class MainBarButton extends Canvas { this.setCursor(hand); - this.inactiveBackground = new Color(getDisplay(), 0xC7, 0xDD, 0xE7); - this.activeBackground = new Color(getDisplay(), 0x7A, 0xC2, 0xD3); + + this.inactiveBackground = new Color(getDisplay(),0xD4, 0xE7, 0xF1); + this.activeBackground1 = new Color(getDisplay(),0x6B, 0xA5, 0xD9); + this.activeBackground = new Color(getDisplay(),0xB4, 0xCD, 0xEC); this.textColor = this.getForeground(); - this.borderColor = new Color(getDisplay(), 0x7E, 0x9F, 0xA5); - this.inactiveText = new Color(getDisplay(), 0x6E, 0x6C, 0x6E); + this.borderColor = new Color(getDisplay(), 0xf9, 0xf9, 0xf9); + this.inactiveText = new Color(getDisplay(), 0x40, 0x40, 0x40); this.textsize = StateComposite.TEXT_SIZE_BUTTON; } private Color inactiveBackground = null; + private Color activeBackground1 = null; /** * @param inactiveBackground @@ -153,6 +156,7 @@ public abstract class MainBarButton extends Canvas { public void setBorderColor(Color borderColor) { this.borderColor = borderColor; } + private Color borderColor = null; @@ -243,12 +247,12 @@ public abstract class MainBarButton extends Canvas { */ protected void paintBackground(PaintEvent e) { Point size = this.getSize(); - int height = size.y - 2; + int height = size.y - 4; int width = size.x; - e.gc.setForeground(this.activeBackground); - e.gc.setBackground(this.inactiveBackground); + e.gc.setForeground(this.activeBackground1); + e.gc.setBackground(this.activeBackground); e.gc.fillGradientRectangle(0, height, width, -1 * height, true); -- cgit v1.2.3