From f39ab43fc0120b7fa97028d40acd7851de8d4a99 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Thu, 24 Nov 2022 14:14:37 +0100 Subject: Repository moved to GitHub: https://github.com/a-sit/pdf-over --- .../asit/pdfover/gui/controls/ClickableCanvas.java | 119 ------- .../java/at/asit/pdfover/gui/controls/Dialog.java | 123 ------- .../at/asit/pdfover/gui/controls/ErrorDialog.java | 36 -- .../at/asit/pdfover/gui/controls/ErrorMarker.java | 79 ----- .../at/asit/pdfover/gui/controls/InputDialog.java | 160 --------- .../asit/pdfover/gui/controls/MainBarButton.java | 370 --------------------- .../pdfover/gui/controls/MainBarEndButton.java | 97 ------ .../pdfover/gui/controls/MainBarMiddleButton.java | 93 ------ .../gui/controls/MainBarRectangleButton.java | 174 ---------- .../pdfover/gui/controls/MainBarStartButton.java | 154 --------- .../pdfover/gui/controls/PasswordInputDialog.java | 36 -- 11 files changed, 1441 deletions(-) delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java deleted file mode 100644 index 0f3f1642..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.Cursor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; - -/** - * - */ -public class ClickableCanvas extends Canvas { - - private Image image = null; - - /** - * @param parent - * @param style - */ - public ClickableCanvas(Composite parent, int style) { - super(parent, style); - - this.addPaintListener(new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - ClickableCanvas.this.paintControl(e); - } - }); - - final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND); - - this.addListener(SWT.Resize, (Event event) -> { - ClickableCanvas.this.redraw(); - }); - - this.setCursor(hand); - - } - - /** - * Gets the image - * - * @return the image - */ - public Image getImage() { - return this.image; - } - - /** - * Sets the Image - * - * @param image - * the imgage to set - */ - public void setImage(Image image) { - this.image = image; - } - - /** - * Main painting method - * - * @param e - */ - void paintControl(PaintEvent e) { - this.paintText(e); - } - - /** - * Paint the text or image on the button - * - * @param e - */ - protected void paintText(PaintEvent e) { - Point size = this.getSize(); - int width = size.x; - - // e.gc.fillGradientRectangle(0, 1, width, height / 4, true); - - if (this.image != null) { - - //log.debug("Width: " + width + " Height: " + height); - - int w = 0; - Image tmp = null; - if(this.image.getImageData().width < width) { - tmp = new Image(getDisplay(), this.image.getImageData()); - w = (width - this.image.getImageData().width) / 2; - } else if(this.image.getImageData().width > width) { - tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(width, width)); - } else { - tmp = new Image(getDisplay(), this.image.getImageData()); - } - - e.gc.drawImage(tmp, w, w); - } - - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java deleted file mode 100644 index de3fb157..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.widgets.MessageBox; -import org.eclipse.swt.widgets.Shell; - -/** - * A Message dialog - */ -public class Dialog { - - private MessageBox box; - - /** - * Message box buttons - */ - public enum BUTTONS { - /** Display only ok button */ - OK, - /** Display buttons ok and cancel */ - OK_CANCEL, - /** Display retry and cancel buttons */ - RETRY_CANCEL, - /** Display abort, retry and ignore buttons */ - ABORT_RETRY_IGNORE, - /** Display yes and no buttons */ - YES_NO - }; - - /** - * Message box icon - */ - public enum ICON { - /** Error icon */ - ERROR, - /** Information icon */ - INFORMATION, - /** Question icon */ - QUESTION, - /** Warning icon */ - WARNING, - /** Working icon */ - WORKING - }; - - /** - * @param parent The parent shell - * @param title The dialog title - * @param message The dialog message - * @param button The BUTTONS to be shown - * @param icon The ICON to be displayed - */ - public Dialog(Shell parent, String title, String message, BUTTONS button, ICON icon) { - this.initialize(parent, title, message, button, icon); - } - - private void initialize(Shell parent, String title, String message, BUTTONS button, ICON icon) { - int boxstyle = 0; - switch (icon) { - case ERROR: - boxstyle |= SWT.ICON_ERROR; - break; - case INFORMATION: - boxstyle |= SWT.ICON_INFORMATION; - break; - case QUESTION: - boxstyle |= SWT.ICON_QUESTION; - break; - case WARNING: - boxstyle |= SWT.ICON_WARNING; - break; - case WORKING: - boxstyle |= SWT.ICON_WORKING; - break; - } - - switch(button) { - case OK: - boxstyle |= SWT.OK; - break; - case OK_CANCEL: - boxstyle |= SWT.OK | SWT.CANCEL; - break; - case RETRY_CANCEL: - boxstyle |= SWT.RETRY | SWT.CANCEL; - break; - case ABORT_RETRY_IGNORE: - boxstyle |= SWT.RETRY | SWT.ABORT | SWT.IGNORE; - break; - case YES_NO: - boxstyle |= SWT.YES | SWT.NO; - } - - this.box = new MessageBox(parent, boxstyle); - this.box.setMessage(message); - this.box.setText(title); - } - - /** - * Open error dialog - * - * @return SWT.OK | SWT.IGNORE | SWT.ABORT | SWT.RETRY | SWT.CANCEL - */ - public int open() { - return this.box.open(); - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java deleted file mode 100644 index f5b5bf9b..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.widgets.Shell; - -import at.asit.pdfover.commons.Messages; - -/** - * An error dialog - */ -public class ErrorDialog extends Dialog { - /** - * @param parent The parent shell - * @param message The error message - * @param button The buttons to be shown - */ - public ErrorDialog(Shell parent, String message, BUTTONS button) { - super(parent, Messages.getString("error.Title"), - message, button, ICON.ERROR); - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java deleted file mode 100644 index bd99b887..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.commons.Constants; - -/** - * - */ -public class ErrorMarker extends Label { - - /** - * SLF4J Logger instance - **/ - @SuppressWarnings("unused") - private static final Logger log = LoggerFactory.getLogger(ErrorMarker.class); - - Image errorImg; - - /** - * Draw an error marker for a faulty entry - * @param parent the parent composite - * @param style the SWT style - * @param message a message describing the error (can be set later through setToolTipText) - */ - public ErrorMarker(Composite parent, int style, - String message) { - super(parent, style); - - InputStream stream = this.getClass().getResourceAsStream(Constants.RES_IMG_ERROR); - - this.errorImg = new Image(getDisplay(), new ImageData(stream)); - - this.addPaintListener(new PaintListener() { - final Rectangle imgSize = ErrorMarker.this.errorImg.getBounds(); - - @Override - public void paintControl(PaintEvent e) { - Rectangle dstSize = ErrorMarker.this.getBounds(); - e.gc.drawImage(ErrorMarker.this.errorImg, - 0, 0, this.imgSize.width, this.imgSize.height, - 0, 0, dstSize.width, dstSize.height); - } - }); - - setToolTipText(message); - } - - @Override - protected void checkSubclass() { - // Allow subclassing - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java deleted file mode 100644 index 4845863f..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import at.asit.pdfover.gui.utils.SWTUtils; - -/** - * - */ -public class InputDialog extends org.eclipse.swt.widgets.Dialog { - /** - * SLF4J Logger instance - **/ -// private static final Logger log = LoggerFactory -// .getLogger(InputDialog.class); - - private String prompt; - String input; - - /** - * SWT flags of the input box - */ - protected static int TEXT_FLAGS = SWT.BORDER; - - /** - * Create a password input dialog - * @param parent parent - * @param title title - * @param prompt prompt message - */ - public InputDialog(Shell parent, String title, String prompt) { - super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); - setText(title); - setMessage(prompt); - } - - /** - * Get the prompt message - * @return the prompt message - */ - public String getPrompt() { - return this.prompt; - } - - /** - * set the prompt message - * @param message the prompt message - */ - public void setMessage(String message) { - this.prompt = message; - } - - /** - * Get the input - * @return the input - */ - public String getInput() { - return this.input; - } - - /** - * Get the input - * @param input the input - */ - public void setInput(String input) { - this.input = input; - } - - /** - * Open the dialog - * @return the input - */ - public String open() { - Shell parent = getParent(); - Shell shell = new Shell(parent, getStyle()); - shell.setText(getText()); - createContents(shell); - shell.pack(); - shell.open(); - Display display = parent.getDisplay(); - Rectangle bounds = parent.getBounds(); - Rectangle main = shell.getBounds(); - shell.setLocation( - bounds.x + (bounds.width - main.width) / 2, - bounds.y + (bounds.height - main.height) / 2); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - return getInput(); - } - - private void createContents(final Shell shell) { - GridLayout layout = new GridLayout(2, false); - layout.verticalSpacing = 10; - layout.marginLeft = 5; - layout.marginRight = 5; - layout.marginTop = 5; - shell.setLayout(layout); - Label label = new Label(shell, SWT.NONE); - label.setText(this.prompt); - GridData data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - final Text text = new Text(shell, TEXT_FLAGS); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - text.setLayoutData(data); - Button ok = new Button(shell, SWT.PUSH); - SWTUtils.setLocalizedText(ok, "common.Ok"); - data = new GridData(GridData.FILL_HORIZONTAL); - ok.setLayoutData(data); - ok.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - InputDialog.this.input = text.getText(); - shell.close(); - } - }); - Button cancel = new Button(shell, SWT.PUSH); - SWTUtils.setLocalizedText(cancel, "common.Cancel"); - data = new GridData(GridData.FILL_HORIZONTAL); - cancel.setLayoutData(data); - cancel.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - InputDialog.this.input = null; - shell.close(); - } - }); - shell.setDefaultButton(ok); - } -} 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 deleted file mode 100644 index 52bdf55c..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * 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.Cursor; -import org.eclipse.swt.graphics.Font; -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 at.asit.pdfover.commons.Constants; - -/** - * 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 = 5; - - /** - * 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; - - /** - * the used text color - */ - protected Color textColor = null; - - /** - * the text size - */ - protected int textsize = Constants.TEXT_SIZE_BUTTON; - - private Color inactiveBackground = null; - private Color activeBackground1 = null; - private Color borderColor = null; - private Color activeBackground = null; - - private Color inactiveText = null; - - private String text = ""; - - private boolean active = true; - - private Image image = null; - - - /** - * @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.paintControl(e); - } - }); - - final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND); - - this.addListener(SWT.Resize, new Listener() { - - @Override - public void handleEvent(Event event) { - MainBarButton.this.setRegion(MainBarButton.this - .getCustomRegion()); - MainBarButton.this.redraw(); - } - }); - - this.setCursor(hand); - - - this.inactiveBackground = Constants.MAINBAR_INACTIVE_BACK; - this.activeBackground1 = Constants.MAINBAR_ACTIVE_BACK_DARK; - this.activeBackground = Constants.MAINBAR_ACTIVE_BACK_LIGHT; - //this.textColor = this.getForeground(); - this.textColor = Constants.MAINBAR_ACTIVE_TEXTCOLOR; - //this.borderColor = new Color(getDisplay(), 0xf9, 0xf9, 0xf9); - this.borderColor = this.getBackground(); - this.inactiveText = Constants.MAINBAR_INACTIVE_TEXTCOLOR; - this.textsize = Constants.TEXT_SIZE_BUTTON; - - } - - /** - * @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; - } - - /** - * @return the textsize - */ - public int getTextsize() { - return this.textsize; - } - - /** - * @param textsize - * the textsize to set - */ - public void setTextsize(int textsize) { - this.textsize = textsize; - } - - /** - * @param textColor - * the textColor to set - */ - public void setTextColor(Color textColor) { - this.textColor = textColor; - } - - /** - * @return the borderColor - */ - public Color getBorderColor() { - return this.borderColor; - } - - /** - * @param borderColor - * the borderColor to set - */ - public void setBorderColor(Color borderColor) { - this.borderColor = borderColor; - } - - - /** - * Gets the image - * - * @return the image - */ - public Image getImage() { - return this.image; - } - - /** - * Sets the Image - * - * @param image - * 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; - } - - /** - * Gets the button text - * - * @return the text - */ - public String getText() { - return this.text; - } - - /** - * Sets the text for the button - * - * @param text - * the text to set - */ - public void setText(String text) { - this.text = text; - } - - /** - * Paint 3D style borders - * - * @param e - */ - protected void paintBackground(PaintEvent e) { - Point size = this.getSize(); - int height = size.y - 4; - - int width = size.x; - - e.gc.setForeground(this.activeBackground1); - e.gc.setBackground(this.activeBackground); - - e.gc.fillGradientRectangle(0, height, width, -1 * height, true); - - //e.gc.setBackground(activeBackground); - - // LEFT - // e.gc.fillGradientRectangle(0, 0, factor, height, false); - - // RIGTH - // e.gc.fillGradientRectangle(width, 0, -1 * (width / factor), height, - // false); - - } - - /** - * Main painting method - * - * @param e - */ - void paintControl(PaintEvent e) { - 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(forecurrent); - e.gc.setBackground(backcurrent); - - this.paintText(e); - } - - /** - * paint the inner button - * - * @param e - */ - protected void paintButton(PaintEvent e) { - // could be overwritten by subclasses - } - - /** - * Paint the text or image on the button - * - * @param e - */ - protected void paintText(PaintEvent e) { - Point size = this.getSize(); - int height = size.y; - - int width = size.x; - - // e.gc.fillGradientRectangle(0, 1, width, height / 4, true); - - if (this.image == null) { - Color current = e.gc.getForeground(); - - 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()); - - String text = this.getText(); - e.gc.setFont(font); - size = e.gc.stringExtent(text); - int texty = (height - size.y) / 2; - int textx = (width - size.x) / 2; - textx = this.changeTextPosition(textx); - e.gc.drawText(this.getText(), textx, texty, true); - font.dispose(); - - e.gc.setForeground(current); - } else { - - //log.debug("Width: " + width + " Height: " + height); - - int w = 0; - Image tmp = null; - if(this.image.getImageData().width < width) { - tmp = new Image(getDisplay(), this.image.getImageData()); - w = (width - this.image.getImageData().width) / 2; - } else if(this.image.getImageData().width > width) { - tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(width, width)); - } else { - tmp = new Image(getDisplay(), this.image.getImageData()); - } - - e.gc.drawImage(tmp, w, w); - } - - } - - /** - * 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 deleted file mode 100644 index 1e80aa36..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 - **/ - @SuppressWarnings("unused") - 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 - 3; - - int split = 10; - int width = size.x - 1; - - 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+split, (height) / 2); - e.gc.drawLine(0+split, (height) / 2, 0, 0); - - } - - /* - * (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 = SplitFactor; - - 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; - } - - /** - * 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 deleted file mode 100644 index 452f0a45..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 - **/ - @SuppressWarnings("unused") - 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 - 3; - - int split = SplitFactor; - 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); - - } - - - /* (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 = SplitFactor; - - 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/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 deleted file mode 100644 index 22a73b15..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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.Image; -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 { - - /** - * SLF4J Logger instance - **/ - @SuppressWarnings("unused") - private static final Logger log = LoggerFactory.getLogger(MainBarRectangleButton.class); - - private Image enabledImg = null; - private Image disabledImg = null; - - /** - * @param parent - * @param style - */ - public MainBarRectangleButton(Composite parent, int style) { - super(parent, style); - this.setActiveBackground(null); - this.setInactiveBackground(null); - } - - /** - * Set the image to display while this control is enabled - * @param enabledImg enabled image - */ - public void setEnabledImage(Image enabledImg) { - this.enabledImg = enabledImg; - if (getEnabled()) - setImage(enabledImg); - } - - /** - * Set the image to display while this control is disabled - * @param disabledImg disabled image - */ - public void setDisabledImage(Image disabledImg) { - this.disabledImg = disabledImg; - if (!getEnabled()) - setImage(disabledImg); - } - - /* - * (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) - * - * @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; - } - - @Override - public void setEnabled(boolean enabled) { - setImage(enabled ? this.enabledImg : this.disabledImg); - super.setEnabled(enabled); - } -} 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 deleted file mode 100644 index ef03fdcb..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 - **/ - @SuppressWarnings("unused") - 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) - */ - @Override - protected void paintButton(PaintEvent e) { - - Point size = this.getSize(); - - int height = size.y - 3; - - int split = SplitFactor; - 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, 0); - - } - - /* (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 = SplitFactor; - - 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; - } - - - /** - * 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/PasswordInputDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java deleted file mode 100644 index 3a15c63a..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.widgets.Shell; - -/** - * - */ -public class PasswordInputDialog extends InputDialog { - - /** - * @param parent - * @param title - * @param prompt - */ - public PasswordInputDialog(Shell parent, String title, String prompt) { - super(parent, title, prompt); - PasswordInputDialog.TEXT_FLAGS = SWT.BORDER | SWT.PASSWORD; - } -} -- cgit v1.2.3