annotate dwt/layout/FormAttachment.d @ 156:969e7de37c3d default tip

Fixes to get dwt to work with dmd and ldc
author Jacob Carlborg <doob@me.com>
date Wed, 08 Jul 2009 21:56:44 +0200
parents d8635bb48c7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
d8635bb48c7c Merge with SWT 3.5
Jacob Carlborg <doob@me.com>
parents: 40
diff changeset
1 /*******************************************************************************
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
7 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
8 * Contributors:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
10 * Port to the D programming language:
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
11 * Frank Benoit <benoit@tionex.de>
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
13 module dwt.layout.FormAttachment;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
14
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
15 import dwt.DWT;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
16 import dwt.widgets.Control;
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
17 import dwt.layout.FormLayout;
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
18 import dwt.layout.FormData;
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
19
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
20 import tango.text.convert.Format;
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
21 import dwt.dwthelper.utils;
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
22
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
23 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
24 * Instances of this class are used to define the edges of a control
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
25 * within a <code>FormLayout</code>.
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
26 * <p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
27 * <code>FormAttachments</code> are set into the top, bottom, left,
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
28 * and right fields of the <code>FormData</code> for a control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
29 * For example:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
30 * <pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
31 * FormData data = new FormData();
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
32 * data.top = new FormAttachment(0,5);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
33 * data.bottom = new FormAttachment(100,-5);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
34 * data.left = new FormAttachment(0,5);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
35 * data.right = new FormAttachment(100,-5);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
36 * button.setLayoutData(data);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
37 * </pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
38 * </p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
39 * <p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
40 * A <code>FormAttachment</code> defines where to attach the side of
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
41 * a control by using the equation, y = ax + b. The "a" term represents
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
42 * a fraction of the parent composite's width (from the left) or height
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
43 * (from the top). It can be defined using a numerator and denominator,
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
44 * or just a percentage value. If a percentage is used, the denominator
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
45 * is set to 100. The "b" term in the equation represents an offset, in
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
46 * pixels, from the attachment position. For example:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
47 * <pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
48 * FormAttachment attach = new FormAttachment (20, -5);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
49 * </pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
50 * specifies that the side to which the <code>FormAttachment</code>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
51 * object belongs will lie at 20% of the parent composite, minus 5 pixels.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
52 * </p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
53 * <p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
54 * Control sides can also be attached to another control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
55 * For example:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
56 * <pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
57 * FormAttachment attach = new FormAttachment (button, 10);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
58 * </pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
59 * specifies that the side to which the <code>FormAttachment</code>
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
60 * object belongs will lie in the same position as the adjacent side of
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
61 * the <code>button</code> control, plus 10 pixels. The control side can
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
62 * also be attached to the opposite side of the specified control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
63 * For example:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
64 * <pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
65 * FormData data = new FormData ();
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
66 * data.left = new FormAttachment (button, 0, DWT.LEFT);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
67 * </pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
68 * specifies that the left side of the control will lie in the same position
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
69 * as the left side of the <code>button</code> control. The control can also
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
70 * be attached in a position that will center the control on the specified
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
71 * control. For example:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
72 * <pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
73 * data.left = new FormAttachment (button, 0, DWT.CENTER);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
74 * </pre>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
75 * specifies that the left side of the control will be positioned so that it is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
76 * centered between the left and right sides of the <code>button</code> control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
77 * If the alignment is not specified, the default is to attach to the adjacent side.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
78 * </p>
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
79 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
80 * @see FormLayout
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
81 * @see FormData
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
82 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
83 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
84 * @since 2.0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
85 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
86 public final class FormAttachment {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
87 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
88 * numerator specifies the numerator of the "a" term in the
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
89 * equation, y = ax + b, which defines the attachment.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
90 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
91 public int numerator;
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
92
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
93 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
94 * denominator specifies the denominator of the "a" term in the
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
95 * equation, y = ax + b, which defines the attachment.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
96 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
97 * The default value is 100.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
98 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
99 public int denominator = 100;
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
100
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
101 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
102 * offset specifies the offset, in pixels, of the control side
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
103 * from the attachment position.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
104 * If the offset is positive, then the control side is offset
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
105 * to the right of or below the attachment position. If it is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
106 * negative, then the control side is offset to the left of or
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
107 * above the attachment position.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
108 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
109 * This is equivalent to the "b" term in the equation y = ax + b.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
110 * The default value is 0.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
111 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
112 public int offset;
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
113
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
114 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
115 * control specifies the control to which the control side is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
116 * attached.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
117 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
118 public Control control;
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
119
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
120 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
121 * alignment specifies the alignment of the control side that is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
122 * attached to a control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
123 * <p>
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
124 * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
125 * and right attachments, LEFT, RIGHT and CENTER are used. If any other case
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
126 * occurs, the default will be used instead.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
127 * </p>
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
128 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
129 * <br>Possible values are: <ul>
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
130 * <li>{@link DWT#TOP}: Attach the side to the top side of the specified control.</li>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
131 * <li>{@link DWT#BOTTOM}: Attach the side to the bottom side of the specified control.</li>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
132 * <li>{@link DWT#LEFT}: Attach the side to the left side of the specified control.</li>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
133 * <li>{@link DWT#RIGHT}: Attach the side to the right side of the specified control.</li>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
134 * <li>{@link DWT#CENTER}: Attach the side at a position which will center the control on the specified control.</li>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
135 * <li>{@link DWT#DEFAULT}: Attach the side to the adjacent side of the specified control.</li>
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
136 * </ul>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
137 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
138 public int alignment;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
139
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
140 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
141 * Constructs a new instance of this class.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
142 * Since no numerator, denominator or offset is specified,
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
143 * the attachment is treated as a percentage of the form.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
144 * The numerator is zero, the denominator is 100 and the
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
145 * offset is zero.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
146 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
147 * @since 3.2
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
148 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
149 public this () {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
150 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
151
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
152 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
153 * Constructs a new instance of this class given a numerator
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
154 * Since no denominator or offset is specified, the default
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
155 * is to treat the numerator as a percentage of the form, with a
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
156 * denominator of 100. The offset is zero.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
157 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
158 * @param numerator the percentage of the position
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
159 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
160 * @since 3.0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
161 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
162 public this (int numerator) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
163 this (numerator, 100, 0);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
164 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
165
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
166 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
167 * Constructs a new instance of this class given a numerator
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
168 * and an offset. Since no denominator is specified, the default
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
169 * is to treat the numerator as a percentage of the form, with a
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
170 * denominator of 100.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
171 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
172 * @param numerator the percentage of the position
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
173 * @param offset the offset of the side from the position
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
174 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
175 public this (int numerator, int offset) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
176 this (numerator, 100, offset);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
177 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
178
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
179 /**
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
180 * Constructs a new instance of this class given a numerator
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
181 * and denominator and an offset. The position of the side is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
182 * given by the fraction of the form defined by the numerator
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
183 * and denominator.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
184 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
185 * @param numerator the numerator of the position
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
186 * @param denominator the denominator of the position
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
187 * @param offset the offset of the side from the position
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
188 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
189 public this (int numerator, int denominator, int offset) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
190 if (denominator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
191 this.numerator = numerator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
192 this.denominator = denominator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
193 this.offset = offset;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
194 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
195
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
196 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
197 * Constructs a new instance of this class given a control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
198 * Since no alignment is specified, the default alignment is
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
199 * to attach the side to the adjacent side of the specified
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
200 * control. Since no offset is specified, an offset of 0 is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
201 * used.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
202 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
203 * @param control the control the side is attached to
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
204 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
205 public this (Control control) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
206 this (control, 0, DWT.DEFAULT);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
207 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
208
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
209 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
210 * Constructs a new instance of this class given a control
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
211 * and an offset. Since no alignment is specified, the default
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
212 * alignment is to attach the side to the adjacent side of the
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
213 * specified control.
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
214 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
215 * @param control the control the side is attached to
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
216 * @param offset the offset of the side from the control
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
217 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
218 public this (Control control, int offset) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
219 this (control, offset, DWT.DEFAULT);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
220 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
221
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
222 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
223 * Constructs a new instance of this class given a control,
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
224 * an offset and an alignment. The possible alignment values are:
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
225 * <dl>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
226 * <dt><b>{@link DWT#TOP}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
227 * <dd>the side will be attached to the top side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
228 * <dt><b>{@link DWT#BOTTOM}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
229 * <dd>the side will be attached to the bottom side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
230 * <dt><b>{@link DWT#LEFT}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
231 * <dd>the side will be attached to the left side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
232 * <dt><b>{@link DWT#RIGHT}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
233 * <dd>the side will be attached to the right side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
234 * <dt><b>{@link DWT#CENTER}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
235 * <dd>the side will be centered on the same side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
236 * <dt><b>{@link DWT#DEFAULT}</b></dt>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
237 * <dd>the side will be attached to the adjacent side of the specified control</dd>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
238 * </dl>
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
239 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
240 * @param control the control the side is attached to
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
241 * @param offset the offset of the side from the control
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
242 * @param alignment the alignment of the side to the control it is attached to,
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
243 * one of TOP, BOTTOM, LEFT, RIGHT, CENTER, or DEFAULT
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
244 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
245 public this (Control control, int offset, int alignment) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
246 this.control = control;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
247 this.offset = offset;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
248 this.alignment = alignment;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
249 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
250
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
251 FormAttachment divide (int value) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
252 return new FormAttachment (numerator, denominator * value, offset / value);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
253 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
254
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
255 int gcd (int m, int n) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
256 int temp;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
257 m = Math.abs (m);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
258 n = Math.abs (n);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
259 if (m < n) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
260 temp = m;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
261 m = n;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
262 n = temp;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
263 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
264 while (n !is 0){
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
265 temp = m;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
266 m = n;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
267 n = temp % n;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
268 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
269 return m;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
270 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
271
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
272 FormAttachment minus (FormAttachment attachment) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
273 FormAttachment solution = new FormAttachment ();
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
274 solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
275 solution.denominator = denominator * attachment.denominator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
276 int gcd = gcd (solution.denominator, solution.numerator);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
277 solution.numerator = solution.numerator / gcd;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
278 solution.denominator = solution.denominator / gcd;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
279 solution.offset = offset - attachment.offset;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
280 return solution;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
281 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
282
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
283 FormAttachment minus (int value) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
284 return new FormAttachment (numerator, denominator, offset - value);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
285 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
286
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
287 FormAttachment plus (FormAttachment attachment) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
288 FormAttachment solution = new FormAttachment ();
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
289 solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
290 solution.denominator = denominator * attachment.denominator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
291 int gcd = gcd (solution.denominator, solution.numerator);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
292 solution.numerator = solution.numerator / gcd;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
293 solution.denominator = solution.denominator / gcd;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
294 solution.offset = offset + attachment.offset;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
295 return solution;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
296 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
297
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
298 FormAttachment plus (int value) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
299 return new FormAttachment (numerator, denominator, offset + value);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
300 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
301
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
302 int solveX (int value) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
303 if (denominator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
304 return ((numerator * value) / denominator) + offset;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
305 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
306
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
307 int solveY (int value) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
308 if (numerator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
309 return (value - offset) * denominator / numerator;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
310 }
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
311
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
312 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
313 * Returns a string containing a concise, human-readable
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
314 * description of the receiver.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
315 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
316 * @return a string representation of the FormAttachment
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
317 */
40
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
318 public override String toString () {
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
319 String string = control !is null ? control.toString () : Format( "{}/{}", numerator, denominator );
fbe68c33eeee Sync layout with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 5
diff changeset
320 return Format("{{y = ({})x + {}}", string, ( offset >= 0 ? Format(")x + {}", offset ) : Format( ")x - {}", -offset)));
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
321 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
322
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
323 }