This source file includes following definitions.
- onMeasure
- onLayout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.gnu.emacs;
21
22
23
24 import android.content.Context;
25
26 import android.view.View;
27 import android.view.View.MeasureSpec;
28 import android.view.ViewGroup;
29
30
31
32
33
34
35
36
37
38
39
40 public final class EmacsDialogButtonLayout extends ViewGroup
41 {
42 public
43 EmacsDialogButtonLayout (Context context)
44 {
45 super (context);
46 }
47
48 @Override
49 protected void
50 onMeasure (int widthMeasureSpec, int heightMeasureSpec)
51 {
52 int width, count, i, x, y, height, spec, tempSpec;
53 View view;
54
55
56
57
58 width = MeasureSpec.getSize (widthMeasureSpec);
59 spec = MeasureSpec.makeMeasureSpec (0, MeasureSpec.UNSPECIFIED);
60 tempSpec
61 = MeasureSpec.makeMeasureSpec (width, MeasureSpec.AT_MOST);
62 x = y = height = 0;
63
64
65
66 count = getChildCount ();
67
68 for (i = 0; i < count; ++i)
69 {
70 view = getChildAt (i);
71
72
73 view.measure (spec, spec);
74
75 if (width - x < view.getMeasuredWidth ())
76 {
77
78
79 if (x != 0)
80 {
81 y += height;
82 height = x = 0;
83 }
84
85 if (view.getMeasuredWidth () > width)
86
87
88 view.measure (tempSpec, spec);
89 }
90
91 height = Math.max (height, view.getMeasuredHeight ());
92 x += view.getMeasuredWidth ();
93 }
94
95
96 setMeasuredDimension (width, y + height);
97 }
98
99 @Override
100 protected void
101 onLayout (boolean changed, int left, int top, int right,
102 int bottom)
103 {
104 int width, count, i, x, y, height, spec, tempSpec;
105 View view;
106
107
108
109
110 width = getMeasuredWidth ();
111 spec = MeasureSpec.makeMeasureSpec (0, MeasureSpec.UNSPECIFIED);
112 tempSpec
113 = MeasureSpec.makeMeasureSpec (width, MeasureSpec.AT_MOST);
114 x = y = height = 0;
115
116
117
118 count = getChildCount ();
119
120 for (i = 0; i < count; ++i)
121 {
122 view = getChildAt (i);
123
124
125 view.measure (spec, spec);
126
127 if (width - x < view.getMeasuredWidth ())
128 {
129
130
131 if (x != 0)
132 {
133 y += height;
134 height = x = 0;
135 }
136
137 if (view.getMeasuredWidth () > width)
138
139
140 view.measure (tempSpec, spec);
141 }
142
143
144 view.layout (x, y, x + view.getMeasuredWidth (),
145 y + view.getMeasuredHeight ());
146
147
148 height = Math.max (height, view.getMeasuredHeight ());
149 x += view.getMeasuredWidth ();
150 }
151 }
152 };