5package org.qtproject.qt.android;
7import android.app.Activity;
8import android.graphics.Point;
9import android.util.Log;
10import android.view.View;
11import android.view.ViewGroup;
12import android.view.ViewTreeObserver;
13import android.widget.PopupWindow;
16class EditPopupMenu
implements ViewTreeObserver.OnPreDrawListener, View.OnLayoutChangeListener,
17 EditContextView.OnClickListener
19 private final EditContextView m_view;
20 private final QtEditText m_editText;
22 private PopupWindow m_popup =
null;
23 private final Activity m_activity;
26 private int m_buttons;
28 EditPopupMenu(QtEditText editText)
30 m_activity = (Activity) editText.getContext();
31 m_view =
new EditContextView(m_activity,
this);
32 m_view.addOnLayoutChangeListener(
this);
34 m_editText = editText;
35 m_editText.getViewTreeObserver().addOnPreDrawListener(
this);
38 private void initOverlay()
43 m_popup =
new PopupWindow(m_activity,
null, android.R.attr.textSelectHandleWindowStyle);
44 m_popup.setSplitTouchEnabled(
true);
45 m_popup.setClippingEnabled(
false);
46 m_popup.setContentView(m_view);
47 m_popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
48 m_popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
56 m_view.updateButtons(buttons);
57 Point viewSize = m_view.getCalculatedSize();
59 final int[] layoutLocation =
new int[2];
64 View positioningView = (View) m_editText.getParent();
65 if (positioningView ==
null)
66 positioningView = m_editText;
67 positioningView.getLocationOnScreen(layoutLocation);
70 final int[] activityLocation =
new int[2];
71 final int[] activityLocationInWindow =
new int[2];
72 m_activity.getWindow().getDecorView().getLocationOnScreen(activityLocation);
73 m_activity.getWindow().getDecorView().getLocationInWindow(activityLocationInWindow);
75 int x2 =
x + layoutLocation[0] - activityLocation[0];
76 int y2 =
y + layoutLocation[1] + (activityLocationInWindow[1] - activityLocation[1]);
78 x2 -= viewSize.x / 2 ;
82 y2 = m_editText.getSelectionHandleBottom();
86 QtLayout parentLayout = (QtLayout) m_editText.getParent();
87 parentLayout.requestLayout();
88 }
catch (ClassCastException e) {
89 Log.w(QtNative.QtTAG,
"QtEditText " + m_editText +
" parent is not a QtLayout, " +
90 "requestLayout() skipped");
91 }
catch (NullPointerException e) {
92 Log.w(QtNative.QtTAG,
"QtEditText " + m_editText +
" does not have a parent, " +
93 "requestLayout() skipped");
97 if (positioningView.getWidth() <
x + viewSize.x / 2)
98 x2 = positioningView.getWidth() - viewSize.x;
103 if (m_popup.isShowing())
104 m_popup.update(
x2,
y2, -1, -1);
106 m_popup.showAtLocation(positioningView, 0,
x2,
y2);
114 if (m_popup !=
null) {
121 public boolean onPreDraw() {
125 if (m_popup !=
null && m_popup.isShowing())
133 int oldLeft,
int oldTop,
int oldRight,
int oldBottom)
136 m_popup !=
null && m_popup.isShowing())
141 public void contextButtonClicked(
int buttonId) {
143 case android.R.string.cut:
144 QtNativeInputConnection.cut();
146 case android.R.string.copy:
147 QtNativeInputConnection.copy();
149 case android.R.string.paste:
150 QtNativeInputConnection.paste();
152 case android.R.string.selectAll:
153 QtNativeInputConnection.selectAll();
n void setPosition(void) \n\
GLint GLint GLint GLint GLint x
GLdouble GLdouble GLdouble GLdouble top
GLsizei const GLfloat * v
GLfixed GLfixed GLfixed y2