From 6d81b2dfa1a2ddb9192b864cc8f4585469bddadd Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 1 Oct 2012 08:30:40 +0000 Subject: Configuration and Main Bar Buttons git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12534 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../at/asit/pdfover/gui/controls/ErrorDialog.java | 176 ++++++++++++++++++++ .../at/asit/pdfover/gui/controls/ErrorMarker.java | 26 ++- .../asit/pdfover/gui/controls/MainBarButton.java | 183 +++++++++++++++++++++ .../pdfover/gui/controls/MainBarEndButton.java | 97 +++++++++++ .../pdfover/gui/controls/MainBarMiddleButton.java | 100 +++++++++++ .../gui/controls/MainBarRectangleButton.java | 87 ++++++++++ .../pdfover/gui/controls/MainBarStartButton.java | 91 ++++++++++ 7 files changed, 756 insertions(+), 4 deletions(-) create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java (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/ErrorDialog.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java new file mode 100644 index 00000000..1025c1fe --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java @@ -0,0 +1,176 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import java.io.InputStream; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class ErrorDialog extends Dialog { + /** + * @param parent + * @param style + * @param message + * @param exception + */ + public ErrorDialog(Shell parent, int style, String message, + Throwable exception) { + super(parent, style); + this.message = message; + + final StringBuilder result = new StringBuilder(); + result.append(exception.getLocalizedMessage()); + final String NEW_LINE = System.getProperty("line.separator"); //$NON-NLS-1$ + result.append(NEW_LINE); + result.append(NEW_LINE); + result.append(NEW_LINE); + + // add each element of the stack trace + for (StackTraceElement element : exception.getStackTrace()) { + result.append(element); + result.append(NEW_LINE); + } + this.details = result.toString(); + } + + /** + * @param parent + * @param style + * @param message + * @param details + */ + public ErrorDialog(Shell parent, int style, String message, String details) { + super(parent, style); + this.message = message; + this.details = details; + } + + private String message = null; + + private String details = null; + + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(ErrorDialog.class); + + /** + * Open error dialog + */ + public void open() { + Shell parent = getParent(); + final Shell shell = new Shell(parent, SWT.DIALOG_TRIM + | SWT.APPLICATION_MODAL); + shell.setText(getText()); + shell.setLayout(new FormLayout()); + + Label lblErrorImage = new Label(shell, SWT.NONE); + FormData fd_lblErrorImage = new FormData(); + fd_lblErrorImage.top = new FormAttachment(50, -16); + fd_lblErrorImage.left = new FormAttachment(0, 5); + lblErrorImage.setLayoutData(fd_lblErrorImage); + lblErrorImage.setText(""); //$NON-NLS-1$ + + String imgPath = "/img/error.png"; //$NON-NLS-1$ + + InputStream stream = this.getClass().getResourceAsStream(imgPath); + + Image orig = new Image(Display.getCurrent(), + new ImageData(stream).scaledTo(32, 32)); + + lblErrorImage.setImage(orig); + + Label lblerrorMessage = new Label(shell, SWT.NONE); + FormData fd_lblerrorMessage = new FormData(); + fd_lblerrorMessage.top = new FormAttachment(0, 5); + fd_lblerrorMessage.left = new FormAttachment(0, 42); + lblerrorMessage.setLayoutData(fd_lblerrorMessage); + lblerrorMessage.setText(this.message); + + Group group = new Group(shell, SWT.NONE); + group.setLayout(new FormLayout()); + FormData fd_group = new FormData(); + + fd_group.right = new FormAttachment(100, -5); + fd_group.top = new FormAttachment(lblerrorMessage, 5); + fd_group.left = new FormAttachment(lblErrorImage, 5); + group.setLayoutData(fd_group); + group.setText("Details"); + Button btnOk = new Button(shell, SWT.NONE); + btnOk.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + shell.dispose(); + } + }); + fd_group.bottom = new FormAttachment(btnOk, -5); + + ScrolledComposite scrolledComposite = new ScrolledComposite(group, + SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + FormData fd_scrolledComposite = new FormData(); + fd_scrolledComposite.top = new FormAttachment(0, 5); + fd_scrolledComposite.left = new FormAttachment(0, 5); + fd_scrolledComposite.bottom = new FormAttachment(100, -5); + fd_scrolledComposite.right = new FormAttachment(100, -5); + scrolledComposite.setLayoutData(fd_scrolledComposite); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + + Label lblDetails = new Label(scrolledComposite, SWT.NONE); + + lblDetails.setText(this.details); + + scrolledComposite.setContent(lblDetails); + scrolledComposite.setMinSize(lblDetails.computeSize(SWT.DEFAULT, + SWT.DEFAULT)); + FormData fd_btnOk = new FormData(); + fd_btnOk.bottom = new FormAttachment(100, -5); + fd_btnOk.right = new FormAttachment(100, -5); + btnOk.setLayoutData(fd_btnOk); + btnOk.setText("Ok"); + + shell.pack(); + shell.open(); + shell.pack(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java index 11cefa13..01505895 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java @@ -18,13 +18,9 @@ package at.asit.pdfover.gui.controls; // Imports import java.io.InputStream; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; @@ -39,6 +35,7 @@ public class ErrorMarker { /** * SLF4J Logger instance **/ + @SuppressWarnings("unused") private static final Logger log = LoggerFactory .getLogger(ErrorMarker.class); @@ -49,6 +46,7 @@ public class ErrorMarker { * @param style * @param exception * @param message + * @param control */ public ErrorMarker(Composite parent, int style, Throwable exception, String message, Control control) { @@ -74,19 +72,35 @@ public class ErrorMarker { this.lbl.setImage(this.orig); } + /** + * Sets the layout data + * @param object the layout data + */ public void setLayoutData(Object object) { this.lbl.setLayoutData(object); } + /** + * Sets the visibilty + * @param visible the visibilty + */ public void setVisible(boolean visible) { this.lbl.setVisible(visible); } + /** + * Sets the tooltip text + * @param msg the tooltip text + */ public void setToolTipText(String msg) { this.lbl.setToolTipText(msg); } + /** + * Scales the image to the new size + * @param size + */ public void resize(Point size) { String imgPath = "/img/error.png"; //$NON-NLS-1$ @@ -101,6 +115,10 @@ public class ErrorMarker { this.lbl.setImage(this.orig); } + /** + * Gets the size of the underlying label + * @return the size + */ public Point getSize() { return this.lbl.getSize(); } 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 new file mode 100644 index 00000000..631ee3e8 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -0,0 +1,183 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public abstract class MainBarButton extends Canvas { + /** + * @param parent + * @param style + */ + public MainBarButton(Composite parent, int style) { + super(parent, style); + this.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + MainBarButton.this.paintButton(e); + } + }); + + this.addListener(SWT.Resize, new Listener() { + + @Override + public void handleEvent(Event event) { + MainBarButton.this.setRegion(MainBarButton.this + .getCustomRegion()); + MainBarButton.this.redraw(); + } + }); + + this.inactiveBackground = new Color(getDisplay(), 0x4B, 0x95, 0x00); + this.activeBackground = new Color(getDisplay(), 0x98, 0xF2, 0x3D); + + } + + private Color inactiveBackground = null; + + /** + * @param inactiveBackground + * the inactiveBackground to set + */ + public void setInactiveBackground(Color inactiveBackground) { + this.inactiveBackground = inactiveBackground; + } + + /** + * @param activeBackground + * the activeBackground to set + */ + public void setActiveBackground(Color activeBackground) { + this.activeBackground = activeBackground; + } + + private Color activeBackground = null; + + private String text = ""; //$NON-NLS-1$ + + private boolean active = true; + + private Image image = null; + + /** + * @return the imgage + */ + public Image getImage() { + return this.image; + } + + /** + * @param imgage + * the imgage to set + */ + public void setImage(Image image) { + this.image = image; + } + + /** + * Sets if this button is active + * + * @param active + * the active state + */ + public void setActive(boolean active) { + this.active = active; + if (this.active) { + this.setBackground(this.activeBackground); + } else { + this.setBackground(this.inactiveBackground); + } + } + + /** + * Gets if this button is active + * + * @return the active state + */ + public boolean getActive() { + return this.active; + } + + /** + * @return the text + */ + public String getText() { + return this.text; + } + + /** + * @param text + * the text to set + */ + public void setText(String text) { + this.text = text; + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MainBarButton.class); + + /** + * @param e + */ + protected void paintButton(PaintEvent e) { + Point size = this.getSize(); + int height = size.y - 2; + + int width = size.x; + + if (this.image == null) { + int textlen = 0; + + if (this.getText() != null) { + textlen = this.getText().length(); + } + + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; + int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() + * textlen) / 2; + e.gc.drawText(this.getText(), textx, texty); + } else { + int imgx = (width - height) / 2; + Image tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(height, height)); + e.gc.drawImage(tmp, imgx, 0); + } + } + + /** + * @return + */ + 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 new file mode 100644 index 00000000..b80b9645 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java @@ -0,0 +1,97 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class MainBarEndButton extends MainBarButton { + /** + * @param parent + * @param style + */ + public MainBarEndButton(Composite parent, int style) { + super(parent, style); + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MainBarEndButton.class); + + /* + * (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 - 2; + + int split = 10; + int width = size.x; + + int textlen = 0; + + if(this.getText() != null) { + textlen = this.getText().length(); + } + + e.gc.drawLine(0, 0, width, 0); + e.gc.drawLine(width, 0, width+split, (height) / 2); + e.gc.drawLine(width, height, 0, height); + e.gc.drawLine(0, height, 0+split, (height) / 2); + e.gc.drawLine(0+split, (height) / 2, 0, 0); + + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; + int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() * textlen) / 2; + e.gc.drawText(this.getText(), textx, texty); + }*/ + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion() + */ + @Override + protected Region getCustomRegion() { + Point size = this.getSize(); + + int height = size.y - 2; + + int split = 10; + + int width = size.x; + + Region reg = new Region(); + reg.add(new int[] { 0, 0, width, 0, width, height, 0, height, + 0 + split, (height) / 2, 0, 0 }); + return reg; + } + +} 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 new file mode 100644 index 00000000..5b9b580f --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java @@ -0,0 +1,100 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class MainBarMiddleButton extends MainBarButton { + /** + * @param parent + * @param style + */ + public MainBarMiddleButton(Composite parent, int style) { + super(parent, style); + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MainBarMiddleButton.class); + + /* (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 - 2; + + int split = 10; + int width = size.x - split; + + e.gc.drawLine(0, 0, width, 0); + e.gc.drawLine(width, 0, width+split, (height) / 2); + e.gc.drawLine(width+split, (height) / 2, width, height); + e.gc.drawLine(width, height, 0, height); + e.gc.drawLine(0, height, 0+split, (height) / 2); + e.gc.drawLine(0+split, (height) / 2, 0, 0); + + int textlen = 0; + + if(getText() != null) { + textlen = this.getText().length(); + } + + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; + int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() * textlen) / 2; + e.gc.drawText(this.getText(), textx, texty); + }*/ + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion() + */ + @Override + protected Region getCustomRegion() { + Point size = this.getSize(); + + int height = size.y - 2; + + int split = 10; + + int width = size.x - split; + + Region reg = new Region(); + reg.add(new int[] { + 0, 0, + width, 0, + width + split, (height) / 2, + width, height, + 0, height, + 0+split, (height) / 2, + 0, 0 }); + + return reg; + } + +} 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 new file mode 100644 index 00000000..edac29e5 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java @@ -0,0 +1,87 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class MainBarRectangleButton extends MainBarButton { + /** + * @param parent + * @param style + */ + public MainBarRectangleButton(Composite parent, int style) { + super(parent, style); + this.setActiveBackground(null); + this.setInactiveBackground(null); + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MainBarRectangleButton.class); + + /* (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 - 2; + + int width = size.x; + + int textlen = 0; + if(getText() != null) { + textlen = getText().length(); + } + + 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); + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; + int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() * textlen) / 2; + e.gc.drawText(getText(), textx, texty); + }*/ + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion() + */ + @Override + protected Region getCustomRegion() { + Point size = this.getSize(); + + int height = size.y - 2; + + int width = size.x; + + Region reg = new Region(); + reg.add(new int[] { 0, 0, width, 0, width, height, 0, height, 0, 0 }); + return reg; + } + +} 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 new file mode 100644 index 00000000..2577ce40 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java @@ -0,0 +1,91 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class MainBarStartButton extends MainBarButton { + /** + * @param parent + * @param style + */ + public MainBarStartButton(Composite parent, int style) { + super(parent, style); + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MainBarStartButton.class); + + /* (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 - 2; + + int split = 10; + int width = size.x - split; + + int textlen = 0; + if(getText() != null) { + textlen = getText().length(); + } + + e.gc.drawLine(0, 0, width, 0); + e.gc.drawLine(width, 0, width + split, (height) / 2); + e.gc.drawLine(width + split, (height) / 2, width, height); + e.gc.drawLine(width, height, 0, height); + e.gc.drawLine(0, height, 0, 0); + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; + int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() * textlen) / 2; + e.gc.drawText(getText(), textx, texty); + }*/ + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.controls.MainBarButton#getRegion() + */ + @Override + protected Region getCustomRegion() { + Point size = this.getSize(); + + int height = size.y - 2; + + int split = 10; + + int width = size.x - split; + + Region reg = new Region(); + reg.add(new int[] { 0, 0, width, 0, width + split, + (height) / 2, width, height, 0, height, 0, 0 }); + return reg; + } + +} -- cgit v1.2.3