1 /*
2 $Id: UnderLayout.java 726 2005-04-05 12:09:09Z guest $
3 */
4
5
6 /*
7 Copyright (C) 2001-2002 Mainline Project (I3S - ESSI - CNRS -UNSA)
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 For further information on the GNU Lesser General Public License,
24 see: http://www.gnu.org/copyleft/lesser.html
25 For further information on this library, contact: mainline@essi.fr
26 */
27
28
29 package fr.ove.openmath.jome.ctrlview.bidim;
30
31 import java.awt.*;
32
33 import fr.ove.openmath.jome.ctrlview.bidim.Display;
34 import fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout;
35 import fr.ove.openmath.jome.ctrlview.bidim.HorizontalLayout;
36 import fr.ove.openmath.jome.ctrlview.bidim.selection.events.SelectionEvent;
37 import fr.ove.openmath.jome.model.*;
38
39 /***
40 * A layout manager that lays components horyzontally, but the last one in the
41 * list, is treated as a underscript (there is an downward shitf).
42 *
43 * @author © 1999 DIRAT Laurent
44 * @version 2.0 13/12/1999
45 */
46 //public class UnderLayout extends ScriptLayout {
47 public class UnderLayout extends VerticalCenteredLayout {
48 /***
49 * Computes the size of the display according to its children size (if any),
50 * and its different attributes.
51 * @return the size of the display.
52 */
53 public Dimension computeAttributes() {
54 /* int ascent = 0;
55 int descent = 0;
56 int width = 0;
57 int height = 0;
58
59 Display base, indice;
60 int decalage = 0;
61
62 base = (Display) displayToLay.getComponent(0);
63 base.setSize(base.getPreferredSize());
64 width += base.getWidth() + base.getShiftX();
65
66 indice = (Display) displayToLay.getComponent(1);
67
68 if (base.getLayout() instanceof UnderLayout)
69 ((DisplayLayout) indice.getLayout()).updateLevel(((Display) base.getComponent(1)).getLevel()+ 1);
70 else
71 ((DisplayLayout) indice.getLayout()).updateLevel(base.getLevel()+ 1);
72
73 indice.setSize(indice.getPreferredSize());
74
75 if (base.getLayout() instanceof UnderLayout) {
76 Display ind_base = (Display) base.getComponent(1);
77 decalage = ind_base.getDescent() + ind_base.getShiftY();
78 }
79 else
80 decalage = base.getDescent() + indice.getAscent();
81
82 base.setShiftY(0); // ATTENTION : rajout !!!!!!
83
84 indice.setShiftY(decalage);
85 indice.setShiftX(-(width/2+indice.getWidth()/2));
86 //width += indice.getWidth() + indice.getShiftX();
87
88 displayToLay.setAscent(base.getAscent());
89 displayToLay.setDescent(decalage + indice.getDescent());
90
91 height += displayToLay.getAscent() + displayToLay.getDescent();
92 displayToLay.setSize(width , height);
93
94 displayToLay.setComputeAttributes(false);
95 return new Dimension(width, height);
96 */
97
98 Dimension dim = super.computeAttributes();
99
100 displayToLay.setAscent(((Display) displayToLay.getComponent(0)).getAscent());
101 displayToLay.setDescent(displayToLay.getHeight() - displayToLay.getAscent());
102
103 return dim;
104 }
105
106 public void validateSelection() {
107 // To Do !!!!
108 }
109 /***
110 * Checks the validity of the deselection.
111 * @param display the display to deselect.
112 */
113 public void validateDeselection(Display display) {
114 // To Do !!!!
115 }
116
117 /***
118 * The display needs to be rebuilt. We do this.
119 */
120 public void rebuildDisplay() {
121 // La taille des displays est probablement diffÈrente de ceux qui Ètaient
122 // prÈcÈdemment. On demande alors le recalcul des display ancÍtres.
123 displayToLay.computeAncestorsAttributes();
124 }
125
126
127 }