1 /*
2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package apple.laf;
27 
28 import java.nio.ByteBuffer;
29 
30 import java.lang.annotation.Native;
31 
32 public final class JRSUIConstants {
33 
34     /**
35      * There is no way to get width of focus border, so it is hardcoded here.
36      * All components, which can be focused should take care about it.
37      */
38     public static final int FOCUS_SIZE = 4;
39 
getPtrForConstant(final int constant)40     private static native long getPtrForConstant(final int constant);
41 
42     static class Key {
43         @Native protected static final int _value = 20;
44         public static final Key VALUE = new Key(_value);
45 
46         @Native protected static final int _thumbProportion = 24;
47         public static final Key THUMB_PROPORTION = new Key(_thumbProportion);
48 
49         @Native protected static final int _thumbStart = 25;
50         public static final Key THUMB_START = new Key(_thumbStart);
51 
52         @Native protected static final int _windowTitleBarHeight = 28;
53         public static final Key WINDOW_TITLE_BAR_HEIGHT = new Key(_windowTitleBarHeight);
54 
55         @Native protected static final int _animationFrame = 23;
56         public static final Key ANIMATION_FRAME = new Key(_animationFrame);
57 
58         final int constant;
59         private long ptr;
60 
Key(final int constant)61         private Key(final int constant) {
62             this.constant = constant;
63         }
64 
getConstantPtr()65         long getConstantPtr() {
66             if (ptr != 0) return ptr;
67             ptr = getPtrForConstant(constant);
68             if (ptr != 0) return ptr;
69             throw new RuntimeException("Constant not implemented in native: " + this);
70         }
71 
getConstantName(Key hit)72         private String getConstantName(Key hit) {
73             if (hit == VALUE) {
74                 return "VALUE";
75             } else if (hit == THUMB_PROPORTION) {
76                 return "THUMB_PROPORTION";
77             } else if (hit == THUMB_START) {
78                 return "THUMB_START";
79             } else if (hit == WINDOW_TITLE_BAR_HEIGHT) {
80                 return "WINDOW_TITLE_BAR_HEIGHT";
81             } else if (hit == ANIMATION_FRAME) {
82                 return "ANIMATION_FRAME";
83             }
84             return getClass().getSimpleName();
85         }
86 
toString()87         public String toString() {
88             return getConstantName(this) + (ptr == 0 ? "(unlinked)" : "");
89         }
90     }
91 
92     static class DoubleValue {
93         @Native protected static final byte TYPE_CODE = 1;
94 
95         final double doubleValue;
96 
DoubleValue(final double doubleValue)97         DoubleValue(final double doubleValue) {
98             this.doubleValue = doubleValue;
99         }
100 
getTypeCode()101         public byte getTypeCode() {
102             return TYPE_CODE;
103         }
104 
putValueInBuffer(final ByteBuffer buffer)105         public void putValueInBuffer(final ByteBuffer buffer) {
106             buffer.putDouble(doubleValue);
107         }
108 
equals(final Object obj)109         public boolean equals(final Object obj) {
110             return (obj instanceof DoubleValue) && (((DoubleValue)obj).doubleValue == doubleValue);
111         }
112 
hashCode()113         public int hashCode() {
114             final long bits = Double.doubleToLongBits(doubleValue);
115             return (int)(bits ^ (bits >>> 32));
116         }
117 
toString()118         public String toString() {
119             return Double.toString(doubleValue);
120         }
121     }
122 
123 
124     static class PropertyEncoding {
125         final long mask;
126         final byte shift;
127 
PropertyEncoding(final long mask, final byte shift)128         PropertyEncoding(final long mask, final byte shift) {
129             this.mask = mask;
130             this.shift = shift;
131         }
132     }
133 
134     static class Property {
135         final PropertyEncoding encoding;
136         final long value;
137         final byte ordinal;
138 
Property(final PropertyEncoding encoding, final byte ordinal)139         Property(final PropertyEncoding encoding, final byte ordinal) {
140             this.encoding = encoding;
141             this.value = ((long)ordinal) << encoding.shift;
142             this.ordinal = ordinal;
143         }
144 
145         /**
146          * Applies this property value to the provided state
147          * @param encodedState the incoming JRSUI encoded state
148          * @return the composite of the provided JRSUI encoded state and this value
149          */
apply(final long encodedState)150         public long apply(final long encodedState) {
151             return (encodedState & ~encoding.mask) | value;
152         }
153 
toString()154         public String toString() {
155             return getClass().getSimpleName();
156         }
157     }
158 
159     public static class Size extends Property {
160         @Native private static final byte SHIFT = 0;
161         @Native private static final byte SIZE = 3;
162         @Native private static final long MASK = (long)0x7 << SHIFT;
163         private static final PropertyEncoding size = new PropertyEncoding(MASK, SHIFT);
164 
Size(final byte value)165         Size(final byte value) {
166             super(size, value);
167         }
168 
169         @Native private static final byte _mini = 1;
170         public static final Size MINI = new Size(_mini);
171         @Native private static final byte _small = 2;
172         public static final Size SMALL = new Size(_small);
173         @Native private static final byte _regular = 3;
174         public static final Size REGULAR = new Size(_regular);
175         @Native private static final byte _large = 4;
176         public static final Size LARGE = new Size(_large);
177     }
178 
179     public static class State extends Property {
180         @Native private static final byte SHIFT = Size.SHIFT + Size.SIZE;
181         @Native private static final byte SIZE = 4;
182         @Native private static final long MASK = (long)0xF << SHIFT;
183         private static final PropertyEncoding state = new PropertyEncoding(MASK, SHIFT);
184 
State(final byte value)185         State(final byte value) {
186             super(state, value);
187         }
188 
189         @Native private static final byte _active = 1;
190         public static final State ACTIVE = new State(_active);
191         @Native private static final byte _inactive = 2;
192         public static final State INACTIVE = new State(_inactive);
193         @Native private static final byte _disabled = 3;
194         public static final State DISABLED = new State(_disabled);
195         @Native private static final byte _pressed = 4;
196         public static final State PRESSED = new State(_pressed);
197         @Native private static final byte _pulsed = 5;
198         public static final State PULSED = new State(_pulsed);
199         @Native private static final byte _rollover = 6;
200         public static final State ROLLOVER = new State(_rollover);
201         @Native private static final byte _drag = 7;
202         public static final State DRAG = new State(_drag);
203     }
204 
205     public static class Direction extends Property {
206         @Native private static final byte SHIFT = State.SHIFT + State.SIZE;
207         @Native private static final byte SIZE = 4;
208         @Native private static final long MASK = (long)0xF << SHIFT;
209         private static final PropertyEncoding direction = new PropertyEncoding(MASK, SHIFT);
210 
Direction(final byte value)211         Direction(final byte value) {
212             super(direction, value);
213         }
214 
215         @Native private static final byte _none = 1;
216         public static final Direction NONE = new Direction(_none);
217         @Native private static final byte _up = 2;
218         public static final Direction UP = new Direction(_up);
219         @Native private static final byte _down = 3;
220         public static final Direction DOWN = new Direction(_down);
221         @Native private static final byte _left = 4;
222         public static final Direction LEFT = new Direction(_left);
223         @Native private static final byte _right = 5;
224         public static final Direction RIGHT = new Direction(_right);
225         @Native private static final byte _north = 6;
226         public static final Direction NORTH = new Direction(_north);
227         @Native private static final byte _south = 7;
228         public static final Direction SOUTH = new Direction(_south);
229         @Native private static final byte _east = 8;
230         public static final Direction EAST = new Direction(_east);
231         @Native private static final byte _west = 9;
232         public static final Direction WEST = new Direction(_west);
233     }
234 
235     public static class Orientation extends Property {
236         @Native private static final byte SHIFT = Direction.SHIFT + Direction.SIZE;
237         @Native private static final byte SIZE = 2;
238         @Native private static final long MASK = (long)0x3 << SHIFT;
239         private static final PropertyEncoding orientation = new PropertyEncoding(MASK, SHIFT);
240 
Orientation(final byte value)241         Orientation(final byte value) {
242             super(orientation, value);
243         }
244 
245         @Native private static final byte _horizontal = 1;
246         public static final Orientation HORIZONTAL = new Orientation(_horizontal);
247         @Native private static final byte _vertical = 2;
248         public static final Orientation VERTICAL = new Orientation(_vertical);
249     }
250 
251     public static class AlignmentVertical extends Property {
252         @Native private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE;
253         @Native private static final byte SIZE = 2;
254         @Native private static final long MASK = (long)0x3 << SHIFT;
255         private static final PropertyEncoding alignmentVertical = new PropertyEncoding(MASK, SHIFT);
256 
AlignmentVertical(final byte value)257         AlignmentVertical(final byte value){
258             super(alignmentVertical, value);
259         }
260 
261         @Native private static final byte _top = 1;
262         public static final AlignmentVertical TOP = new AlignmentVertical(_top);
263         @Native private static final byte _center = 2;
264         public static final AlignmentVertical CENTER = new AlignmentVertical(_center);
265         @Native private static final byte _bottom = 3;
266         public static final AlignmentVertical BOTTOM = new AlignmentVertical(_bottom);
267     }
268 
269     public static class AlignmentHorizontal extends Property {
270         @Native private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE;
271         @Native private static final byte SIZE = 2;
272         @Native private static final long MASK = (long)0x3 << SHIFT;
273         private static final PropertyEncoding alignmentHorizontal = new PropertyEncoding(MASK, SHIFT);
274 
AlignmentHorizontal(final byte value)275         AlignmentHorizontal(final byte value){
276             super(alignmentHorizontal, value);
277         }
278 
279         @Native private static final byte _left = 1;
280         public static final AlignmentHorizontal LEFT = new AlignmentHorizontal(_left);
281         @Native private static final byte _center =  2;
282         public static final AlignmentHorizontal CENTER = new AlignmentHorizontal(_center);
283         @Native private static final byte _right = 3;
284         public static final AlignmentHorizontal RIGHT = new AlignmentHorizontal(_right);
285     }
286 
287     public static class SegmentPosition extends Property {
288         @Native private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE;
289         @Native private static final byte SIZE = 3;
290         @Native private static final long MASK = (long)0x7 << SHIFT;
291         private static final PropertyEncoding segmentPosition = new PropertyEncoding(MASK, SHIFT);
292 
SegmentPosition(final byte value)293         SegmentPosition(final byte value) {
294             super(segmentPosition, value);
295         }
296 
297         @Native private static final byte _first = 1;
298         public static final SegmentPosition FIRST = new SegmentPosition(_first);
299         @Native private static final byte _middle = 2;
300         public static final SegmentPosition MIDDLE = new SegmentPosition(_middle);
301         @Native private static final byte _last = 3;
302         public static final SegmentPosition LAST = new SegmentPosition(_last);
303         @Native private static final byte _only = 4;
304         public static final SegmentPosition ONLY = new SegmentPosition(_only);
305     }
306 
307     public static class ScrollBarPart extends Property {
308         @Native private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE;
309         @Native private static final byte SIZE = 4;
310         @Native private static final long MASK = (long)0xF << SHIFT;
311         private static final PropertyEncoding scrollBarPart = new PropertyEncoding(MASK, SHIFT);
312 
ScrollBarPart(final byte value)313         ScrollBarPart(final byte value) {
314             super(scrollBarPart, value);
315         }
316 
317         @Native private static final byte _none = 1;
318         public static final ScrollBarPart NONE = new ScrollBarPart(_none);
319         @Native private static final byte _thumb = 2;
320         public static final ScrollBarPart THUMB = new ScrollBarPart(_thumb);
321         @Native private static final byte _arrowMin = 3;
322         public static final ScrollBarPart ARROW_MIN = new ScrollBarPart(_arrowMin);
323         @Native private static final byte _arrowMax = 4;
324         public static final ScrollBarPart ARROW_MAX = new ScrollBarPart(_arrowMax);
325         @Native private static final byte _arrowMaxInside = 5;
326         public static final ScrollBarPart ARROW_MAX_INSIDE = new ScrollBarPart(_arrowMaxInside);
327         @Native private static final byte _arrowMinInside = 6;
328         public static final ScrollBarPart ARROW_MIN_INSIDE = new ScrollBarPart(_arrowMinInside);
329         @Native private static final byte _trackMin = 7;
330         public static final ScrollBarPart TRACK_MIN = new ScrollBarPart(_trackMin);
331         @Native private static final byte _trackMax = 8;
332         public static final ScrollBarPart TRACK_MAX = new ScrollBarPart(_trackMax);
333     }
334 
335     public static class Variant extends Property {
336         @Native private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE;
337         @Native private static final byte SIZE = 4;
338         @Native private static final long MASK = (long)0xF << SHIFT;
339         private static final PropertyEncoding variant = new PropertyEncoding(MASK, SHIFT);
340 
Variant(final byte value)341         Variant(final byte value) {
342             super(variant, value);
343         }
344 
345         @Native private static final byte _menuGlyph = 1;
346         public static final Variant MENU_GLYPH = new Variant(_menuGlyph);
347         @Native private static final byte _menuPopup = Variant._menuGlyph + 1;
348         public static final Variant MENU_POPUP = new Variant(_menuPopup);
349         @Native private static final byte _menuPulldown = Variant._menuPopup + 1;
350         public static final Variant MENU_PULLDOWN = new Variant(_menuPulldown);
351         @Native private static final byte _menuHierarchical = Variant._menuPulldown + 1;
352         public static final Variant MENU_HIERARCHICAL = new Variant(_menuHierarchical);
353 
354         @Native private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1;
355         public static final Variant GRADIENT_LIST_BACKGROUND_EVEN = new Variant(_gradientListBackgroundEven);
356         @Native private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1;
357         public static final Variant GRADIENT_LIST_BACKGROUND_ODD = new Variant(_gradientListBackgroundOdd);
358         @Native private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1;
359         public static final Variant GRADIENT_SIDE_BAR = new Variant(_gradientSideBar);
360         @Native private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1;
361         public static final Variant GRADIENT_SIDE_BAR_SELECTION = new Variant(_gradientSideBarSelection);
362         @Native private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1;
363         public static final Variant GRADIENT_SIDE_BAR_FOCUSED_SELECTION = new Variant(_gradientSideBarFocusedSelection);
364     }
365 
366     public static class WindowType extends Property {
367         @Native private static final byte SHIFT = Variant.SHIFT + Variant.SIZE;
368         @Native private static final byte SIZE = 2;
369         @Native private static final long MASK = (long)0x3 << SHIFT;
370         private static final PropertyEncoding windowType = new PropertyEncoding(MASK, SHIFT);
371 
WindowType(final byte value)372         WindowType(final byte value){
373             super(windowType, value);
374         }
375 
376         @Native private static final byte _document = 1;
377         public static final WindowType DOCUMENT = new WindowType(_document);
378         @Native private static final byte _utility = 2;
379         public static final WindowType UTILITY = new WindowType(_utility);
380         @Native private static final byte _titlelessUtility = 3;
381         public static final WindowType TITLELESS_UTILITY = new WindowType(_titlelessUtility);
382     }
383 
384     public static class Focused extends Property {
385         @Native private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE;
386         @Native private static final byte SIZE = 1;
387         @Native private static final long MASK = (long)0x1 << SHIFT;
388         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
389 
Focused(final byte value)390         Focused(final byte value) {
391             super(focused, value);
392         }
393 
394         @Native private static final byte _no = 0;
395         public static final Focused NO = new Focused(_no);
396         @Native private static final byte _yes = 1;
397         public static final Focused YES = new Focused(_yes);
398     }
399 
400     public static class IndicatorOnly extends Property {
401         @Native private static final byte SHIFT = Focused.SHIFT + Focused.SIZE;
402         @Native private static final byte SIZE = 1;
403         @Native private static final long MASK = (long)0x1 << SHIFT;
404         private static final PropertyEncoding indicatorOnly = new PropertyEncoding(MASK, SHIFT);
405 
IndicatorOnly(final byte value)406         IndicatorOnly(final byte value) {
407             super(indicatorOnly, value);
408         }
409 
410         @Native private static final byte _no = 0;
411         public static final IndicatorOnly NO = new IndicatorOnly(_no);
412         @Native private static final byte _yes = 1;
413         public static final IndicatorOnly YES = new IndicatorOnly(_yes);
414     }
415 
416     public static class NoIndicator extends Property {
417         @Native private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE;
418         @Native private static final byte SIZE = 1;
419         @Native private static final long MASK = (long)0x1 << SHIFT;
420         private static final PropertyEncoding noIndicator = new PropertyEncoding(MASK, SHIFT);
421 
NoIndicator(final byte value)422         NoIndicator(final byte value) {
423             super(noIndicator, value);
424         }
425 
426         @Native private static final byte _no = 0;
427         public static final NoIndicator NO = new NoIndicator(_no);
428         @Native private static final byte _yes = 1;
429         public static final NoIndicator YES = new NoIndicator(_yes);
430     }
431 
432     public static class ArrowsOnly extends Property {
433         @Native private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE;
434         @Native private static final byte SIZE = 1;
435         @Native private static final long MASK = (long)0x1 << SHIFT;
436         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
437 
ArrowsOnly(final byte value)438         ArrowsOnly(final byte value) {
439             super(focused, value);
440         }
441 
442         @Native private static final byte _no = 0;
443         public static final ArrowsOnly NO = new ArrowsOnly(_no);
444         @Native private static final byte _yes = 1;
445         public static final ArrowsOnly YES = new ArrowsOnly(_yes);
446     }
447 
448     public static class FrameOnly extends Property {
449         @Native private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE;
450         @Native private static final byte SIZE = 1;
451         @Native private static final long MASK = (long)0x1 << SHIFT;
452         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
453 
FrameOnly(final byte value)454         FrameOnly(final byte value) {
455             super(focused, value);
456         }
457 
458         @Native private static final byte _no = 0;
459         public static final FrameOnly NO = new FrameOnly(_no);
460         @Native private static final byte _yes = 1;
461         public static final FrameOnly YES = new FrameOnly(_yes);
462     }
463 
464     public static class SegmentTrailingSeparator extends Property {
465         @Native private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE;
466         @Native private static final byte SIZE = 1;
467         @Native private static final long MASK = (long)0x1 << SHIFT;
468         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
469 
SegmentTrailingSeparator(final byte value)470         SegmentTrailingSeparator(final byte value) {
471             super(focused, value);
472         }
473 
474         @Native private static final byte _no = 0;
475         public static final SegmentTrailingSeparator NO = new SegmentTrailingSeparator(_no);
476         @Native private static final byte _yes = 1;
477         public static final SegmentTrailingSeparator YES = new SegmentTrailingSeparator(_yes);
478     }
479 
480     public static class SegmentLeadingSeparator extends Property {
481         @Native private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE;
482         @Native private static final byte SIZE = 1;
483         @Native private static final long MASK = (long)0x1 << SHIFT;
484         private static final PropertyEncoding leadingSeparator = new PropertyEncoding(MASK, SHIFT);
485 
SegmentLeadingSeparator(final byte value)486         SegmentLeadingSeparator(final byte value) {
487             super(leadingSeparator, value);
488         }
489 
490         @Native private static final byte _no = 0;
491         public static final SegmentLeadingSeparator NO = new SegmentLeadingSeparator(_no);
492         @Native private static final byte _yes = 1;
493         public static final SegmentLeadingSeparator YES = new SegmentLeadingSeparator(_yes);
494     }
495 
496     public static class NothingToScroll extends Property {
497         @Native private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE;
498         @Native private static final byte SIZE = 1;
499         @Native private static final long MASK = (long)0x1 << SHIFT;
500         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
501 
NothingToScroll(final byte value)502         NothingToScroll(final byte value) {
503             super(focused, value);
504         }
505 
506         @Native private static final byte _no = 0;
507         public static final NothingToScroll NO = new NothingToScroll(_no);
508         @Native private static final byte _yes = 1;
509         public static final NothingToScroll YES = new NothingToScroll(_yes);
510     }
511 
512     public static class WindowTitleBarSeparator extends Property {
513         @Native private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE;
514         @Native private static final byte SIZE = 1;
515         @Native private static final long MASK = (long)0x1 << SHIFT;
516         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
517 
WindowTitleBarSeparator(final byte value)518         WindowTitleBarSeparator(final byte value) {
519             super(focused, value);
520         }
521 
522         @Native private static final byte _no = 0;
523         public static final WindowTitleBarSeparator NO = new WindowTitleBarSeparator(_no);
524         @Native private static final byte _yes = 1;
525         public static final WindowTitleBarSeparator YES = new WindowTitleBarSeparator(_yes);
526     }
527 
528     public static class WindowClipCorners extends Property {
529         @Native private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE;
530         @Native private static final byte SIZE = 1;
531         @Native private static final long MASK = (long)0x1 << SHIFT;
532         private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
533 
WindowClipCorners(final byte value)534         WindowClipCorners(final byte value) {
535             super(focused, value);
536         }
537 
538         @Native private static final byte _no = 0;
539         public static final WindowClipCorners NO = new WindowClipCorners(_no);
540         @Native private static final byte _yes = 1;
541         public static final WindowClipCorners YES = new WindowClipCorners(_yes);
542     }
543 
544     public static class ShowArrows extends Property {
545         @Native private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE;
546         @Native private static final byte SIZE = 1;
547         @Native private static final long MASK = (long)0x1 << SHIFT;
548         private static final PropertyEncoding showArrows = new PropertyEncoding(MASK, SHIFT);
549 
ShowArrows(final byte value)550         ShowArrows(final byte value) {
551             super(showArrows, value);
552         }
553 
554         @Native private static final byte _no = 0;
555         public static final ShowArrows NO = new ShowArrows(_no);
556         @Native private static final byte _yes = 1;
557         public static final ShowArrows YES = new ShowArrows(_yes);
558     }
559 
560     public static class BooleanValue extends Property {
561         @Native private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE;
562         @Native private static final byte SIZE = 1;
563         @Native private static final long MASK = (long)0x1 << SHIFT;
564         private static final PropertyEncoding booleanValue = new PropertyEncoding(MASK, SHIFT);
565 
BooleanValue(final byte value)566         BooleanValue(final byte value) {
567             super(booleanValue, value);
568         }
569 
570         @Native private static final byte _no = 0;
571         public static final BooleanValue NO = new BooleanValue(_no);
572         @Native private static final byte _yes = 1;
573         public static final BooleanValue YES = new BooleanValue(_yes);
574     }
575 
576     public static class Animating extends Property {
577         @Native private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE;
578         @Native private static final byte SIZE = 1;
579         @Native private static final long MASK = (long)0x1 << SHIFT;
580         private static final PropertyEncoding animating = new PropertyEncoding(MASK, SHIFT);
581 
Animating(final byte value)582         Animating(final byte value) {
583             super(animating, value);
584         }
585 
586         @Native private static final byte _no = 0;
587         public static final Animating NO = new Animating(_no);
588         @Native private static final byte _yes = 1;
589         public static final Animating YES = new Animating(_yes);
590     }
591 
592     public static class Widget extends Property {
593         @Native private static final byte SHIFT = Animating.SHIFT + Animating.SIZE;
594         @Native private static final byte SIZE = 7;
595         @Native private static final long MASK = (long)0x7F << SHIFT;
596         private static final PropertyEncoding widget = new PropertyEncoding(MASK, SHIFT);
597 
Widget(final byte constant)598         Widget(final byte constant) {
599             super(widget, constant);
600         }
601 
602         @Native private static final byte _background = 1;
603         public static final Widget BACKGROUND = new Widget(_background);
604 
605         @Native private static final byte _buttonBevel = _background + 1;
606         public static final Widget BUTTON_BEVEL = new Widget(_buttonBevel);
607         @Native private static final byte _buttonBevelInset = _buttonBevel + 1;
608         public static final Widget BUTTON_BEVEL_INSET = new Widget(_buttonBevelInset);
609         @Native private static final byte _buttonBevelRound = _buttonBevelInset + 1;
610         public static final Widget BUTTON_BEVEL_ROUND = new Widget(_buttonBevelRound);
611 
612         @Native private static final byte _buttonCheckBox = _buttonBevelRound + 1;
613         public static final Widget BUTTON_CHECK_BOX = new Widget(_buttonCheckBox);
614 
615         @Native private static final byte _buttonComboBox = _buttonCheckBox + 1;
616         public static final Widget BUTTON_COMBO_BOX = new Widget(_buttonComboBox);
617         @Native private static final byte _buttonComboBoxInset = _buttonComboBox + 1;
618         public static final Widget BUTTON_COMBO_BOX_INSET = new Widget(_buttonComboBoxInset); // not hooked up in JRSUIConstants.m
619 
620         @Native private static final byte _buttonDisclosure = _buttonComboBoxInset + 1;
621         public static final Widget BUTTON_DISCLOSURE = new Widget(_buttonDisclosure);
622 
623         @Native private static final byte _buttonListHeader = _buttonDisclosure + 1;
624         public static final Widget BUTTON_LIST_HEADER = new Widget(_buttonListHeader);
625 
626         @Native private static final byte _buttonLittleArrows = _buttonListHeader + 1;
627         public static final Widget BUTTON_LITTLE_ARROWS = new Widget(_buttonLittleArrows);
628 
629         @Native private static final byte _buttonPopDown = _buttonLittleArrows + 1;
630         public static final Widget BUTTON_POP_DOWN = new Widget(_buttonPopDown);
631         @Native private static final byte _buttonPopDownInset = _buttonPopDown + 1;
632         public static final Widget BUTTON_POP_DOWN_INSET = new Widget(_buttonPopDownInset);
633         @Native private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1;
634         public static final Widget BUTTON_POP_DOWN_SQUARE = new Widget(_buttonPopDownSquare);
635 
636         @Native private static final byte _buttonPopUp = _buttonPopDownSquare + 1;
637         public static final Widget BUTTON_POP_UP = new Widget(_buttonPopUp);
638         @Native private static final byte _buttonPopUpInset = _buttonPopUp + 1;
639         public static final Widget BUTTON_POP_UP_INSET = new Widget(_buttonPopUpInset);
640         @Native private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1;
641         public static final Widget BUTTON_POP_UP_SQUARE = new Widget(_buttonPopUpSquare);
642 
643         @Native private static final byte _buttonPush = _buttonPopUpSquare + 1;
644         public static final Widget BUTTON_PUSH = new Widget(_buttonPush);
645         @Native private static final byte _buttonPushScope = _buttonPush + 1;
646         public static final Widget BUTTON_PUSH_SCOPE = new Widget(_buttonPushScope);
647         @Native private static final byte _buttonPushScope2 = _buttonPushScope + 1;
648         public static final Widget BUTTON_PUSH_SCOPE2 = new Widget(_buttonPushScope2);
649         @Native private static final byte _buttonPushTextured = _buttonPushScope2 + 1;
650         public static final Widget BUTTON_PUSH_TEXTURED = new Widget(_buttonPushTextured);
651         @Native private static final byte _buttonPushInset = _buttonPushTextured + 1;
652         public static final Widget BUTTON_PUSH_INSET = new Widget(_buttonPushInset);
653         @Native private static final byte _buttonPushInset2 = _buttonPushInset + 1;
654         public static final Widget BUTTON_PUSH_INSET2 = new Widget(_buttonPushInset2);
655 
656         @Native private static final byte _buttonRadio = _buttonPushInset2 + 1;
657         public static final Widget BUTTON_RADIO = new Widget(_buttonRadio);
658 
659         @Native private static final byte _buttonRound = _buttonRadio + 1;
660         public static final Widget BUTTON_ROUND = new Widget(_buttonRound);
661         @Native private static final byte _buttonRoundHelp = _buttonRound + 1;
662         public static final Widget BUTTON_ROUND_HELP = new Widget(_buttonRoundHelp);
663         @Native private static final byte _buttonRoundInset = _buttonRoundHelp + 1;
664         public static final Widget BUTTON_ROUND_INSET = new Widget(_buttonRoundInset);
665         @Native private static final byte _buttonRoundInset2 =_buttonRoundInset + 1;
666         public static final Widget BUTTON_ROUND_INSET2 = new Widget(_buttonRoundInset2);
667 
668         @Native private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1;
669         public static final Widget BUTTON_SEARCH_FIELD_CANCEL = new Widget(_buttonSearchFieldCancel);
670         @Native private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1;
671         public static final Widget BUTTON_SEARCH_FIELD_FIND = new Widget(_buttonSearchFieldFind);
672 
673         @Native private static final byte _buttonSegmented = _buttonSearchFieldFind + 1;
674         public static final Widget BUTTON_SEGMENTED = new Widget(_buttonSegmented);
675         @Native private static final byte _buttonSegmentedInset = _buttonSegmented + 1;
676         public static final Widget BUTTON_SEGMENTED_INSET = new Widget(_buttonSegmentedInset);
677         @Native private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1;
678         public static final Widget BUTTON_SEGMENTED_INSET2 = new Widget(_buttonSegmentedInset2);
679         @Native private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1;
680         public static final Widget BUTTON_SEGMENTED_SCURVE = new Widget(_buttonSegmentedSCurve);
681         @Native private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1;
682         public static final Widget BUTTON_SEGMENTED_TEXTURED = new Widget(_buttonSegmentedTextured);
683         @Native private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1;
684         public static final Widget BUTTON_SEGMENTED_TOOLBAR = new Widget(_buttonSegmentedToolbar);
685 
686         @Native private static final byte _dial = _buttonSegmentedToolbar + 1;
687         public static final Widget DIAL = new Widget(_dial);
688 
689         @Native private static final byte _disclosureTriangle = _dial + 1;
690         public static final Widget DISCLOSURE_TRIANGLE = new Widget(_disclosureTriangle);
691 
692         @Native private static final byte _dividerGrabber = _disclosureTriangle + 1;
693         public static final Widget DIVIDER_GRABBER = new Widget(_dividerGrabber);
694         @Native private static final byte _dividerSeparatorBar = _dividerGrabber + 1;
695         public static final Widget DIVIDER_SEPARATOR_BAR = new Widget(_dividerSeparatorBar);
696         @Native private static final byte _dividerSplitter = _dividerSeparatorBar + 1;
697         public static final Widget DIVIDER_SPLITTER = new Widget(_dividerSplitter);
698 
699         @Native private static final byte _focus = _dividerSplitter + 1;
700         public static final Widget FOCUS = new Widget(_focus);
701 
702         @Native private static final byte _frameGroupBox = _focus + 1;
703         public static final Widget FRAME_GROUP_BOX = new Widget(_frameGroupBox);
704         @Native private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1;
705         public static final Widget FRAME_GROUP_BOX_SECONDARY = new Widget(_frameGroupBoxSecondary);
706 
707         @Native private static final byte _frameListBox = _frameGroupBoxSecondary + 1;
708         public static final Widget FRAME_LIST_BOX = new Widget(_frameListBox);
709 
710         @Native private static final byte _framePlacard = _frameListBox + 1;
711         public static final Widget FRAME_PLACARD = new Widget(_framePlacard);
712 
713         @Native private static final byte _frameTextField = _framePlacard + 1;
714         public static final Widget FRAME_TEXT_FIELD = new Widget(_frameTextField);
715         @Native private static final byte _frameTextFieldRound = _frameTextField + 1;
716         public static final Widget FRAME_TEXT_FIELD_ROUND = new Widget(_frameTextFieldRound);
717 
718         @Native private static final byte _frameWell = _frameTextFieldRound + 1;
719         public static final Widget FRAME_WELL = new Widget(_frameWell);
720 
721         @Native private static final byte _growBox = _frameWell + 1;
722         public static final Widget GROW_BOX = new Widget(_growBox);
723         @Native private static final byte _growBoxTextured = _growBox + 1;
724         public static final Widget GROW_BOX_TEXTURED = new Widget(_growBoxTextured);
725 
726         @Native private static final byte _gradient = _growBoxTextured + 1;
727         public static final Widget GRADIENT = new Widget(_gradient);
728 
729         @Native private static final byte _menu = _gradient + 1;
730         public static final Widget MENU = new Widget(_menu);
731         @Native private static final byte _menuItem = _menu + 1;
732         public static final Widget MENU_ITEM = new Widget(_menuItem);
733         @Native private static final byte _menuBar = _menuItem + 1;
734         public static final Widget MENU_BAR = new Widget(_menuBar);
735         @Native private static final byte _menuTitle = _menuBar + 1;
736         public static final Widget MENU_TITLE = new Widget(_menuTitle);
737 
738         @Native private static final byte _progressBar = _menuTitle + 1;
739         public static final Widget PROGRESS_BAR = new Widget(_progressBar);
740         @Native private static final byte _progressIndeterminateBar = _progressBar + 1;
741         public static final Widget PROGRESS_INDETERMINATE_BAR = new Widget(_progressIndeterminateBar);
742         @Native private static final byte _progressRelevance = _progressIndeterminateBar + 1;
743         public static final Widget PROGRESS_RELEVANCE = new Widget(_progressRelevance);
744         @Native private static final byte _progressSpinner = _progressRelevance + 1;
745         public static final Widget PROGRESS_SPINNER = new Widget(_progressSpinner);
746 
747         @Native private static final byte _scrollBar = _progressSpinner + 1;
748         public static final Widget SCROLL_BAR = new Widget(_scrollBar);
749 
750         @Native private static final byte _scrollColumnSizer = _scrollBar + 1;
751         public static final Widget SCROLL_COLUMN_SIZER = new Widget(_scrollColumnSizer);
752 
753         @Native private static final byte _slider = _scrollColumnSizer + 1;
754         public static final Widget SLIDER = new Widget(_slider);
755         @Native private static final byte _sliderThumb = _slider + 1;
756         public static final Widget SLIDER_THUMB = new Widget(_sliderThumb);
757 
758         @Native private static final byte _synchronization = _sliderThumb + 1;
759         public static final Widget SYNCHRONIZATION = new Widget(_synchronization);
760 
761         @Native private static final byte _tab = _synchronization + 1;
762         public static final Widget TAB = new Widget(_tab);
763 
764         @Native private static final byte _titleBarCloseBox = _tab + 1;
765         public static final Widget TITLE_BAR_CLOSE_BOX = new Widget(_titleBarCloseBox);
766         @Native private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1;
767         public static final Widget TITLE_BAR_COLLAPSE_BOX = new Widget(_titleBarCollapseBox);
768         @Native private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1;
769         public static final Widget TITLE_BAR_ZOOM_BOX = new Widget(_titleBarZoomBox);
770 
771         @Native private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1;
772         public static final Widget TITLE_BAR_TOOLBAR_BUTTON = new Widget(_titleBarToolbarButton);
773 
774         @Native private static final byte _toolbarItemWell = _titleBarToolbarButton + 1;
775         public static final Widget TOOLBAR_ITEM_WELL = new Widget(_toolbarItemWell);
776 
777         @Native private static final byte _windowFrame = _toolbarItemWell + 1;
778         public static final Widget WINDOW_FRAME = new Widget(_windowFrame);
779     }
780 
781     public static class Hit {
782         @Native private static final int _unknown = -1;
783         public static final Hit UNKNOWN = new Hit(_unknown);
784         @Native private static final int _none = 0;
785         public static final Hit NONE = new Hit(_none);
786         @Native private static final int _hit = 1;
787         public static final Hit HIT = new Hit(_hit);
788 
789         final int hit;
Hit(final int hit)790         Hit(final int hit) { this.hit = hit; }
791 
isHit()792         public boolean isHit() {
793             return hit > 0;
794         }
795 
getConstantName(Hit hit)796         private String getConstantName(Hit hit) {
797             if (hit == UNKNOWN) {
798                 return "UNKNOWN";
799             } else if (hit == NONE) {
800                 return "NONE";
801             } else if (hit == HIT) {
802                 return "HIT";
803             }
804             return getClass().getSimpleName();
805         }
806 
toString()807         public String toString() {
808             return getConstantName(this);
809         }
810     }
811 
812     public static class ScrollBarHit extends Hit {
813         @Native private static final int _thumb = 2;
814         public static final ScrollBarHit THUMB = new ScrollBarHit(_thumb);
815 
816         @Native private static final int _trackMin = 3;
817         public static final ScrollBarHit TRACK_MIN = new ScrollBarHit(_trackMin);
818         @Native private static final int _trackMax = 4;
819         public static final ScrollBarHit TRACK_MAX = new ScrollBarHit(_trackMax);
820 
821         @Native private static final int _arrowMin = 5;
822         public static final ScrollBarHit ARROW_MIN = new ScrollBarHit(_arrowMin);
823         @Native private static final int _arrowMax = 6;
824         public static final ScrollBarHit ARROW_MAX = new ScrollBarHit(_arrowMax);
825         @Native private static final int _arrowMaxInside = 7;
826         public static final ScrollBarHit ARROW_MAX_INSIDE = new ScrollBarHit(_arrowMaxInside);
827         @Native private static final int _arrowMinInside = 8;
828         public static final ScrollBarHit ARROW_MIN_INSIDE = new ScrollBarHit(_arrowMinInside);
829 
ScrollBarHit(final int hit)830         ScrollBarHit(final int hit) { super(hit); }
831     }
832 
getHit(final int hit)833     static Hit getHit(final int hit) {
834         switch (hit) {
835             case Hit._none:
836                 return Hit.NONE;
837             case Hit._hit:
838                 return Hit.HIT;
839 
840             case ScrollBarHit._thumb:
841                 return ScrollBarHit.THUMB;
842             case ScrollBarHit._trackMin:
843                 return ScrollBarHit.TRACK_MIN;
844             case ScrollBarHit._trackMax:
845                 return ScrollBarHit.TRACK_MAX;
846             case ScrollBarHit._arrowMin:
847                 return ScrollBarHit.ARROW_MIN;
848             case ScrollBarHit._arrowMax:
849                 return ScrollBarHit.ARROW_MAX;
850             case ScrollBarHit._arrowMaxInside:
851                 return ScrollBarHit.ARROW_MAX_INSIDE;
852             case ScrollBarHit._arrowMinInside:
853                 return ScrollBarHit.ARROW_MIN_INSIDE;
854         }
855         return Hit.UNKNOWN;
856     }
857 }
858