Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java145
1 files changed, 112 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
index 40fc195c5a..b120e52b4e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -72,6 +72,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE | CANVAS;
int parentHandle = parent.handle;
createScrolledHandle (parentHandle);
}
@@ -89,27 +90,36 @@ void createScrollBars () {
void createScrolledHandle (int parentHandle) {
int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
int [] args = new int [] {
- /*
- * Bug in Photon. We must set Pt_GETS_FOCUS or Photon will
- * segment fault when no widget has focus and a key is pressed.
- */
- OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if ((style & SWT.NO_BACKGROUND) != 0) {
+ args = new int [] {OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0};
+ OS.PtSetResources(scrolledHandle, args.length / 3, args);
+ }
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
Display display = getDisplay ();
int clazz = display.PtContainer;
args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (clazz, scrolledHandle, args.length / 3, args);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
createScrollBars ();
}
+
+public Rectangle getClientArea () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (scrolledHandle == 0) return super.getClientArea ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
public Control [] getChildren () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
@@ -137,6 +147,10 @@ boolean hasBorder () {
return (style & SWT.BORDER) != 0;
}
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
void hookEvents () {
super.hookEvents ();
int windowProc = getDisplay ().windowProc;
@@ -169,8 +183,39 @@ public void layout (boolean changed) {
layout.layout (this, changed);
}
+int processMouse (int info) {
+
+ /* Set focus for a canvas with no children */
+ if (OS.PtWidgetChildFront (handle) == 0) {
+ if ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS: {
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons == OS.Ph_BUTTON_SELECT) {
+ setFocus ();
+ }
+ }
+ }
+ }
+ }
+ return super.processMouse (info);
+}
+
int processPaint (int damage) {
- OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ }
+ }
return super.processPaint (damage);
}
@@ -179,12 +224,17 @@ int processResize (int info) {
PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PtContainerCallback_t cbdata = new PtContainerCallback_t ();
+ OS.memmove(cbdata, cbinfo.cbdata, PtContainerCallback_t.sizeof);
+ if (cbdata.new_dim_w == cbdata.old_dim_w && cbdata.new_dim_h == cbdata.old_dim_h) {
+ return OS.Pt_CONTINUE;
+ }
sendEvent (SWT.Resize);
if (layout != null) layout (false);
return OS.Pt_CONTINUE;
}
-void releaseWidget () {
+void releaseChildren () {
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
@@ -193,6 +243,10 @@ void releaseWidget () {
child.releaseHandle ();
}
}
+}
+
+void releaseWidget () {
+ releaseChildren ();
super.releaseWidget ();
}
@@ -207,46 +261,66 @@ boolean sendResize () {
}
void resizeClientArea (int width, int height) {
+ if (scrolledHandle == 0) return;
+
+ /* Calculate the insets */
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ int flags = args [1];
+ int bevel = args [4];
+ int top = 0, left = 0, right = 0, bottom = 0;
+ if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
+ if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
+ if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
+ if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
+ if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
+ if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
+
+ int clientWidth = width - (left + right);
+ int clientHeight = height - (top + bottom);
+
int vBarWidth = 0, hBarHeight = 0;
boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
if (isVisibleHBar) {
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
- height = height - (hBarHeight = args [1]);
+ clientHeight -= (hBarHeight = args [1]);
}
if (isVisibleVBar) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
OS.PtGetResources (verticalBar.handle, args.length / 3, args);
- width = width - (vBarWidth = args [1]);
- }
-
- //NOT DONE - used widget canvas to compute insets
- int left = 0, right = 0;
- if (hasBorder ()) {
- left = 2;
- if (isVisibleHBar && isVisibleVBar) right = 3;
+ clientWidth -= (vBarWidth = args [1]);
}
if (isVisibleHBar) {
- horizontalBar.setBounds (-left, height - left, width + right, hBarHeight);
+ horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
}
if (isVisibleVBar) {
- verticalBar.setBounds (width - left, -left, vBarWidth, height + right);
+ verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
}
-
- PhArea_t area = new PhArea_t ();
- area.size_w = (short) (Math.max (width - (left * 2), 0));
- area.size_h = (short) (Math.max (height - (left * 2), 0));
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- int [] args = {OS.Pt_ARG_AREA, ptr, 0};
+ args = new int [] {
+ OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
+ };
OS.PtSetResources (handle, args.length / 3, args);
- OS.free (ptr);
}
void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- if (resize) resizeClientArea (width, height);
super.setBounds (x, y, width, height, move, resize);
+ if (resize) resizeClientArea (width, height);
}
public void setLayout (Layout layout) {
@@ -255,4 +329,9 @@ public void setLayout (Layout layout) {
this.layout = layout;
}
-} \ No newline at end of file
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ if ((state & CANVAS) != 0 && hooks (SWT.KeyDown)) return 0;
+ return super.traversalCode (key_sym, ke);
+}
+
+}

Back to the top