Mercurial > projects > dwt2
comparison org.eclipse.jface/src/org/eclipse/jface/dialogs/ControlAnimator.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 ******************************************************************************/ | |
13 | |
14 module org.eclipse.jface.dialogs.ControlAnimator; | |
15 | |
16 import java.lang.all; | |
17 | |
18 import org.eclipse.swt.graphics.Point; | |
19 import org.eclipse.swt.graphics.Rectangle; | |
20 import org.eclipse.swt.widgets.Control; | |
21 | |
22 /** | |
23 * ControlAnimator provides a simple implementation to display or hide a control | |
24 * at the bottom of the parent composite. Other animations will be written as | |
25 * subclasses of this class. <p> | |
26 * Instances of this class can be created using an AnimatorFactory. | |
27 * | |
28 * @since 3.2 | |
29 */ | |
30 | |
31 | |
32 public class ControlAnimator { | |
33 /** the control that will be displayed or hidden */ | |
34 protected Control control; | |
35 | |
36 /** | |
37 * Constructs a new ControlAnimator instance and passes along the | |
38 * control that will be displayed or hidden. | |
39 * | |
40 * @param control the control that will be displayed or hidden. | |
41 */ | |
42 public this(Control control) { | |
43 this.control = control; | |
44 } | |
45 | |
46 /** | |
47 * Displays or hides a control at the bottom of the parent composite | |
48 * and makes use of the control's SWT visible flag.<p> | |
49 * Subclasses should override this method.</p> | |
50 * | |
51 * @param visible <code>true</code> if the control should be shown, | |
52 * and <code>false</code> otherwise. | |
53 */ | |
54 public void setVisible(bool visible){ | |
55 // Using the SWT visible flag to determine if the control has | |
56 // already been displayed or hidden. Return if already displayed | |
57 // and visible is true, or if already hidden and visible is false. | |
58 if (!(control.isVisible() ^ visible)) | |
59 return; | |
60 control.setVisible(visible); | |
61 Rectangle parentBounds = control.getParent().getBounds(); | |
62 int bottom = parentBounds.height; | |
63 int endY = visible ? bottom - control.getBounds().height | |
64 : bottom; | |
65 Point loc = control.getLocation(); | |
66 control.setLocation(loc.x,endY); | |
67 } | |
68 | |
69 } |