5package org.qtproject.qt.android;
7import android.app.Activity;
8import android.content.Context;
9import android.os.Build;
10import android.util.AttributeSet;
11import android.util.DisplayMetrics;
12import android.view.Display;
13import android.view.MotionEvent;
14import android.view.View;
15import android.view.ViewGroup;
17class QtLayout
extends ViewGroup {
19 public QtLayout(Context
context)
29 public QtLayout(Context
context, AttributeSet
attrs,
int defStyle)
35 protected void onMeasure(
int widthMeasureSpec,
int heightMeasureSpec)
37 int count = getChildCount();
43 measureChildren(widthMeasureSpec, heightMeasureSpec);
48 if (
child.getVisibility() != GONE) {
52 if (
child.getLayoutParams() instanceof QtLayout.LayoutParams) {
53 QtLayout.LayoutParams lp
54 = (QtLayout.LayoutParams)
child.getLayoutParams();
55 childRight = lp.x +
child.getMeasuredWidth();
56 childBottom = lp.y +
child.getMeasuredHeight();
58 childRight =
child.getMeasuredWidth();
59 childBottom =
child.getMeasuredHeight();
62 maxWidth = Math.max(maxWidth, childRight);
63 maxHeight = Math.max(maxHeight, childBottom);
68 maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
69 maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
71 setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec),
72 resolveSize(maxHeight, heightMeasureSpec));
82 protected ViewGroup.LayoutParams generateDefaultLayoutParams()
84 return new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
85 android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
91 protected void onLayout(
boolean changed,
int l,
int t,
int r,
int b)
93 int count = getChildCount();
96 if (
child.getVisibility() != GONE) {
97 QtLayout.LayoutParams lp =
98 (QtLayout.LayoutParams)
child.getLayoutParams();
100 int childLeft = lp.x;
102 int childRight = (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) ?
103 r - l : childLeft +
child.getMeasuredWidth();
104 int childBottom = (lp.height == ViewGroup.LayoutParams.MATCH_PARENT) ?
105 b -
t : childTop +
child.getMeasuredHeight();
106 child.
layout(childLeft, childTop, childRight, childBottom);
113 protected boolean checkLayoutParams(ViewGroup.LayoutParams
p)
115 return p instanceof QtLayout.LayoutParams;
119 protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams
p)
121 return new LayoutParams(
p);
172 public void moveChild(View
view,
int index)
177 if (indexOfChild(
view) == -1)
180 detachViewFromParent(
view);
192 public void setLayoutParams(
final View childView,
193 final ViewGroup.LayoutParams
params,
194 final boolean forceRedraw)
197 if (childView ==
null)
201 if (!checkLayoutParams(
params))
205 final boolean canUpdate = (
this == childView.getParent());
208 childView.setLayoutParams(
params);
212 addView(childView,
params);
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
LayoutParams(int width, int height, int x, int y)
LayoutParams(ViewGroup.LayoutParams source)
LayoutParams(int width, int height)
static struct AttrInfo attrs[]
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLsizei GLsizei GLchar * source