Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.GWT.client.widgets;

import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.widgets.nonpublic.*;
import org.litesoft.ui.*;

import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;

public class SizeableQBEboxedPanel extends AbstractSizeableSimplePanel {
    private static final String STYLE = "NineCeller";

    public static final int STANDARD_SIZE = 11;
    public static final int LEFT_WIDTH = 36;

    private static final String QBEPOPUP_POINTER = "common/images/QBEpopup/pointer.gif";
    private static final int POINTER_HEIGHT = 32;
    private static final int POINTER_WIDTH = 27;

    private Element mPointer;
    private int mAt = 0;
    private boolean mShowingPointer = true;

    public SizeableQBEboxedPanel() {
        mPointer = createPointer();
        Element zGraphRoot = CommonElementHelper.createTable();
        Element zTBody = CommonElementHelper.appendToParent( DOM.createTBody(), zGraphRoot );
        addRow( zTBody, CompassPoint.NW, CompassPoint.N, CompassPoint.NE );
        Element zInnerElement = addRow( zTBody, CompassPoint.W, mPointer, CompassPoint.center, null, CompassPoint.E, createTransparentImg( STANDARD_SIZE ) );
        addRow( zTBody, CompassPoint.SW, CompassPoint.S, CompassPoint.SE );
        initializeElements( getHelper().create_OeTable_SeDiv_IeGraph( true, zGraphRoot, zInnerElement ), "LayoutSizeableQBEpopupPanel" );
        addStyleName( STYLE );
        show( false );
    }

    public SizeableQBEboxedPanel( Widget pWidget ) {
        this();
        setWidget( pWidget );
    }

    public SizeableQBEboxedPanel style( String pStyleName ) {
        addStyleName( pStyleName );
        return this;
    }

    public SizeableQBEboxedPanel stretchable() {
        LLstretchable();
        return this;
    }

    public SizeableQBEboxedPanel stretchableVertically() {
        LLstretchableVertically();
        return this;
    }

    public SizeableQBEboxedPanel stretchableHorizontally() {
        LLstretchableHorizontally();
        return this;
    }

    @Override
    public void setWidget( Widget pWidget ) {
        Widget zWidget = getWidget();
        if ( zWidget == null ) {
            super.setWidget( pWidget );
        } else {
            int zWidth = zWidget.getOffsetWidth();
            int zHeight = zWidget.getOffsetHeight();
            super.setWidget( pWidget );
            pWidget.setWidth( "" + zWidth );
            pWidget.setHeight( "" + zHeight );
        }
    }

    public void show( boolean pShow ) {
        UtilsGwt.setHidden( this, !pShow );
        CommonElementHelper.setHidden( mPointer, !pShow );
    }

    public boolean isPointerShowing() {
        return mShowingPointer;
    }

    public int getPointsAt() {
        return mAt + (POINTER_HEIGHT / 2);
    }

    public void pointTo( Widget pWidget ) {
        pointTo( pWidget, HasVerticalAlignment.ALIGN_MIDDLE );
    }

    public void pointTo( Widget pWidget, HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
        pointTo( pWidget.getElement(), pValign );
    }

    public void pointTo( Element pElement ) {
        pointTo( pElement, HasVerticalAlignment.ALIGN_MIDDLE );
    }

    public void pointTo( Element pElement, HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
        int zAt = pElement.getAbsoluteTop();
        if ( pValign != HasVerticalAlignment.ALIGN_TOP ) {
            int zHeight = pElement.getOffsetHeight();
            if ( pValign == HasVerticalAlignment.ALIGN_BOTTOM ) {
                zAt += zHeight - 1;
            } else // Assume Middle
            {
                zAt += zHeight / 2;
            }
        }
        pointTo( zAt );
    }

    public void pointTo( int pTopOfPageOffset ) {
        int zPointerTDAt = mPointer.getParentElement().getAbsoluteTop();
        int zAt = pTopOfPageOffset - zPointerTDAt; // Make Relative to my TD
        zAt -= POINTER_HEIGHT / 2;
        setAt( constrainAt( zAt ), zAt );
        show( true );
    }

    private void setAt( int zAt, int zDesiredAt ) // PreConstrained
    {
        mPointer.getStyle().setPropertyPx( "top", mAt = zAt );
        mShowingPointer = (zAt == zDesiredAt);
        CommonElementHelper.setHidden( mPointer, !mShowingPointer );
    }

    private int constrainAt( int zAt ) {
        int zMaxAt = mPointer.getParentElement().getOffsetHeight() - POINTER_HEIGHT;
        zAt = Math.min( zAt, zMaxAt );
        zAt = Math.max( 0, zAt );
        return zAt;
    }

    private Element createPointer() {
        Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), QBEPOPUP_POINTER );
        zElement.getStyle().setProperty( "position", "relative" );
        zElement.getStyle().setPropertyPx( "width", POINTER_WIDTH );
        zElement.getStyle().setPropertyPx( "height", POINTER_HEIGHT );
        return zElement;
    }

    private Element createTransparentImg( int pWidth ) {
        Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), TransparentImage.URL );
        zElement.getStyle().setPropertyPx( "width", pWidth );
        zElement.getStyle().setPropertyPx( "height", STANDARD_SIZE );
        return zElement;
    }

    /**
     * @return Center TD
     */
    private Element addRow( Element pTBody, CompassPoint pLeftCP, Element pLeftElement, CompassPoint pCenterCP, Element pCenterElement, CompassPoint pRightCP,
                            Element pRightElement ) {
        Element zTR = CommonElementHelper.appendToParent( DOM.createTR(), pTBody );
        CommonElementHelper.setTDvAlign( addTD( zTR, pLeftCP, pLeftElement ), HasVerticalAlignment.ALIGN_TOP );
        Element zCenterTD = addTD( zTR, pCenterCP, pCenterElement );
        addTD( zTR, pRightCP, pRightElement );
        return zCenterTD;
    }

    private Element addTD( Element pTR, CompassPoint pCP, Element pElement ) {
        Element zTD = CommonElementHelper.appendToParent( DOM.createTD(), pTR );
        if ( pElement != null ) {
            zTD.appendChild( pElement );
        }
        zTD.setClassName( "CP_" + pCP );
        return zTD;
    }

    private void addRow( Element pTBody, CompassPoint pLeft, CompassPoint pCenter, CompassPoint pRight ) {
        addRow( pTBody, pLeft, createTransparentImg( LEFT_WIDTH ), pCenter, createTransparentImg( STANDARD_SIZE ), pRight,
                createTransparentImg( STANDARD_SIZE ) );
    }

    @Override
    public void setWidth( String width ) {
        super.setWidth( width );
    }

    @Override
    public void setHeight( String height ) {
        super.setHeight( height );
        int zAt = constrainAt( mAt );
        if ( zAt != mAt ) {
            setAt( zAt, mAt );
        }
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/SizeableQBEboxedPanel.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

390 Diff Diff GeorgeS picture GeorgeS Sun 14 Aug, 2011 19:33:48 +0000
151 Diff Diff GeorgeS picture GeorgeS Thu 17 Mar, 2011 04:16:22 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000