5package org.qtproject.qt.android;
7import android.content.Context;
8import android.util.AttributeSet;
9import android.view.View;
10import android.view.ViewGroup;
11import android.view.ViewParent;
13class QtLayout
extends ViewGroup {
31 protected void onMeasure(
int widthMeasureSpec,
int heightMeasureSpec)
33 int count = getChildCount();
39 measureChildren(widthMeasureSpec, heightMeasureSpec);
42 for (
int i = 0;
i <
count;
i++) {
43 View
child = getChildAt(i);
44 if (
child.getVisibility() != GONE) {
48 if (
child.getLayoutParams() instanceof QtLayout.LayoutParams) {
49 QtLayout.LayoutParams lp
50 = (QtLayout.LayoutParams)
child.getLayoutParams();
51 childRight = lp.x +
child.getMeasuredWidth();
52 childBottom = lp.y +
child.getMeasuredHeight();
54 childRight =
child.getMeasuredWidth();
55 childBottom =
child.getMeasuredHeight();
58 maxWidth = Math.max(maxWidth, childRight);
59 maxHeight = Math.max(maxHeight, childBottom);
64 maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
65 maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
67 setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec),
68 resolveSize(maxHeight, heightMeasureSpec));
78 protected ViewGroup.LayoutParams generateDefaultLayoutParams()
80 return new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
81 android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
87 protected void onLayout(
boolean changed,
int l,
int t,
int r,
int b)
89 int count = getChildCount();
90 for (
int i = 0;
i <
count;
i++) {
91 View
child = getChildAt(i);
92 if (
child.getVisibility() != GONE) {
93 QtLayout.LayoutParams lp =
94 (QtLayout.LayoutParams)
child.getLayoutParams();
98 int childRight = (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) ?
99 r - l : childLeft +
child.getMeasuredWidth();
100 int childBottom = (lp.height == ViewGroup.LayoutParams.MATCH_PARENT) ?
101 b -
t : childTop +
child.getMeasuredHeight();
102 child.
layout(childLeft, childTop, childRight, childBottom);
109 protected boolean checkLayoutParams(ViewGroup.LayoutParams
p)
111 return p instanceof QtLayout.LayoutParams;
115 protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams
p)
117 return new LayoutParams(
p);
125 static class LayoutParams
extends ViewGroup.LayoutParams
162 LayoutParams(ViewGroup.LayoutParams
source)
173 if (indexOfChild(
view) == -1)
176 detachViewFromParent(
view);
188 void setLayoutParams(
final View childView,
189 final ViewGroup.LayoutParams
params,
190 final boolean forceRedraw)
193 if (childView ==
null)
197 if (!checkLayoutParams(
params))
200 final ViewParent parent = childView.getParent();
203 final boolean canUpdate = (
this == parent);
206 childView.setLayoutParams(
params);
211 if (parent instanceof ViewGroup)
212 ((ViewGroup)parent).removeView(childView);
213 addView(childView,
params);
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
static const QString context()
static struct AttrInfo attrs[]
GLboolean GLboolean GLboolean b
GLenum GLenum GLsizei count
GLsizei GLsizei GLchar * source