# HG changeset patch
# User Frank Benoit
# Date 1199933508 -3600
# Node ID 3a3e3aa76b66422d0bad53dd99c6bfcbb8d9e015
# Parent 27324bbbac70a758cd7e7d03c0cb36f483186236
Composite
diff -r 27324bbbac70 -r 3a3e3aa76b66 dwt/internal/gtk/OS.d
--- a/dwt/internal/gtk/OS.d Thu Jan 10 02:18:07 2008 +0100
+++ b/dwt/internal/gtk/OS.d Thu Jan 10 03:51:48 2008 +0100
@@ -113,6 +113,7 @@
public alias dwt.internal.c.gtk.GtkWidgetClass GtkWidgetClass;
public alias dwt.internal.c.gtk.GtkCellRendererClass GtkCellRendererClass;
public alias dwt.internal.c.gtk.GtkAllocation GtkAllocation;
+public alias dwt.internal.c.gtk.GtkSocket GtkSocket;
public alias dwt.internal.c.Xlib.XErrorEvent XErrorEvent;
public alias dwt.internal.c.Xlib.XExposeEvent XExposeEvent;
@@ -1163,7 +1164,7 @@
mixin ForwardGtkOsCFunc!(.g_list_nth_data);
mixin ForwardGtkOsCFunc!(.g_list_prepend);
// mixin ForwardGtkOsCFunc!(.g_list_set_previous);
-// mixin ForwardGtkOsCFunc!(.g_list_previous);
+ //mixin ForwardGtkOsCFunc!(.g_list_previous);
mixin ForwardGtkOsCFunc!(.g_list_remove_link);
mixin ForwardGtkOsCFunc!(.g_list_reverse);
mixin ForwardGtkOsCFunc!(.g_locale_from_utf8);
diff -r 27324bbbac70 -r 3a3e3aa76b66 dwt/widgets/Composite.d
--- a/dwt/widgets/Composite.d Thu Jan 10 02:18:07 2008 +0100
+++ b/dwt/widgets/Composite.d Thu Jan 10 03:51:48 2008 +0100
@@ -9,25 +9,25 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
module dwt.widgets.Composite;
-import dwt.widgets.Control;
-import dwt.internal.c.gtk;
-class Composite : Control {
- Control [] _getTabList ();
- int backgroundMode;
- GtkWidget* parentingHandle ();
- Control [] _getChildren () ;
- void removeControl (Control control);
- void moveAbove (GtkWidget* child, GtkWidget* sibling);
- void moveBelow (GtkWidget* child, GtkWidget* sibling);
- void fixZOrder () ;
-}
+import dwt.widgets.Control;
+import dwt.widgets.Scrollable;
+import dwt.widgets.Layout;
+import dwt.widgets.Decorations;
+import dwt.widgets.ScrollBar;
+import dwt.widgets.Shell;
+import dwt.widgets.Menu;
+import dwt.widgets.Event;
+import dwt.widgets.Widget;
+import dwt.widgets.Display;
+import dwt.graphics.GCData;
-/+
-import dwt.*;
-import dwt.internal.cairo.*;
-import dwt.internal.gtk.*;
-import dwt.graphics.*;
+import dwt.internal.gtk.OS;
+import dwt.graphics.GC;
+import dwt.SWT;
+import dwt.internal.cairo.Cairo;
+import dwt.internal.gtk.OS;
+import dwt.graphics.Rectangle;
/**
* Instances of this class are controls which are capable
@@ -58,16 +58,17 @@
*
* @see Canvas
*/
-public class Composite extends Scrollable {
- public int /*long*/ embeddedHandle;
- int /*long*/ imHandle, socketHandle;
- Layout layout;
+public class Composite : Scrollable {
+ public int embeddedHandle;
+ GtkIMContext* imHandle_;
+ GtkWidget* socketHandle;
+ Layout layout_;
Control[] tabList;
int layoutCount, backgroundMode;
- static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$
+ static const char[] NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$
-Composite () {
+this () {
/* Do nothing */
}
@@ -101,44 +102,44 @@
* @see SWT#NO_RADIO_GROUP
* @see Widget#getStyle
*/
-public Composite (Composite parent, int style) {
+public this (Composite parent, int style) {
super (parent, style);
}
Control [] _getChildren () {
- int /*long*/ parentHandle = parentingHandle ();
- int /*long*/ list = OS.gtk_container_get_children (parentHandle);
- if (list == 0) return new Control [0];
+ auto parentHandle = parentingHandle ();
+ auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle);
+ if (list is null) return new Control [0];
int count = OS.g_list_length (list);
Control [] children = new Control [count];
int i = 0;
- int /*long*/ temp = list;
- while (temp != 0) {
- int /*long*/ handle = OS.g_list_data (temp);
- if (handle != 0) {
+ auto temp = list;
+ while (temp !is null) {
+ auto handle = cast(GtkWidget*)OS.g_list_data (temp);
+ if (handle !is null) {
Widget widget = display.getWidget (handle);
- if (widget != null && widget != this) {
- if (widget instanceof Control) {
- children [i++] = (Control) widget;
+ if (widget !is null && widget !is this) {
+ if (auto c = cast(Control)widget) {
+ children [i++] = c;
}
}
}
- temp = OS.g_list_next (temp);
+ temp = cast(GList*)OS.g_list_next (temp);
}
OS.g_list_free (list);
- if (i == count) return children;
+ if (i is count) return children;
Control [] newChildren = new Control [i];
System.arraycopy (children, 0, newChildren, 0, i);
return newChildren;
}
Control [] _getTabList () {
- if (tabList == null) return tabList;
+ if (tabList is null) return tabList;
int count = 0;
for (int i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
- * @see #setLayoutDeferred(boolean)
+ * @see #setLayoutDeferred(bool)
* @see #isLayoutDeferred()
*
* @since 3.1
*/
-public boolean getLayoutDeferred () {
+public bool getLayoutDeferred () {
checkWidget ();
return layoutCount > 0 ;
}
@@ -619,7 +621,7 @@
public Control [] getTabList () {
checkWidget ();
Control [] tabList = _getTabList ();
- if (tabList == null) {
+ if (tabList is null) {
int count = 0;
Control [] list =_getChildren ();
for (int i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
- * @see #setLayoutDeferred(boolean)
+ * @see #setLayoutDeferred(bool)
* @see #getLayoutDeferred()
*
* @since 3.1
*/
-public boolean isLayoutDeferred () {
+public bool isLayoutDeferred () {
checkWidget ();
- return findDeferredControl () != null;
+ return findDeferredControl () !is null;
}
-boolean isTabGroup() {
- if ((state & CANVAS) != 0) return true;
+bool isTabGroup() {
+ if ((state & CANVAS) !is 0) return true;
return super.isTabGroup();
}
@@ -861,9 +857,9 @@
* ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*/
-public void layout (boolean changed) {
+public void layout (bool changed) {
checkWidget ();
- if (layout == null) return;
+ if (layout_ is null) return;
layout (changed, false);
}
@@ -902,9 +898,9 @@
*
* @since 3.1
*/
-public void layout (boolean changed, boolean all) {
+public void layout (bool changed, bool all) {
checkWidget ();
- if (layout == null && !all) return;
+ if (layout_ is null && !all) return;
markLayout (changed, all);
updateLayout (all);
}
@@ -939,15 +935,15 @@
*/
public void layout (Control [] changed) {
checkWidget ();
- if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT);
for (int i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
- * @see #layout(boolean)
+ * @see #layout(bool)
* @see #layout(Control[])
*
* @since 3.1
*/
-public void setLayoutDeferred (boolean defer) {
+public void setLayoutDeferred (bool defer) {
if (!defer) {
- if (--layoutCount == 0) {
- if ((state & LAYOUT_CHILD) != 0 || (state & LAYOUT_NEEDED) != 0) {
+ if (--layoutCount is 0) {
+ if ((state & LAYOUT_CHILD) !is 0 || (state & LAYOUT_NEEDED) !is 0) {
updateLayout (true);
}
}
@@ -1231,20 +1227,20 @@
}
}
-boolean setScrollBarVisible (ScrollBar bar, boolean visible) {
- boolean changed = super.setScrollBarVisible (bar, visible);
- if (changed && layout != null) {
+bool setScrollBarVisible (ScrollBar bar, bool visible) {
+ bool changed = super.setScrollBarVisible (bar, visible);
+ if (changed && layout_ !is null) {
markLayout (false, false);
updateLayout (false);
}
return changed;
}
-boolean setTabGroupFocus (boolean next) {
+bool setTabGroupFocus (bool next) {
if (isTabItem ()) return setTabItemFocus (next);
- boolean takeFocus = (style & SWT.NO_FOCUS) == 0;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (socketHandle != 0) takeFocus = true;
+ bool takeFocus = (style & SWT.NO_FOCUS) is 0;
+ if ((state & CANVAS) !is 0) takeFocus = hooksKeys ();
+ if (socketHandle !is null) takeFocus = true;
if (takeFocus && setTabItemFocus (next)) return true;
Control [] children = _getChildren ();
for (int i=0; i
+ * This method computes the size that the client area
+ * of the composite must be in order to position all
+ * children at their preferred size inside the
+ * composite according to the layout algorithm
+ * encoded by this layout.
+ *
+ *
+ * When a width or height hint is supplied, it is
+ * used to constrain the result. For example, if a
+ * width hint is provided that is less than the
+ * width of the client area, the layout may choose
+ * to wrap and increase height, clip, overlap, or
+ * otherwise constrain the children.
+ *
+ *
+ * @param composite a composite widget using this layout
+ * @param wHint width (SWT.DEFAULT
for preferred size)
+ * @param hHint height (SWT.DEFAULT
for preferred size)
+ * @param flushCache true
means flush cached layout values
+ * @return a point containing the computed size (width, height)
+ *
+ * @see #layout
+ * @see Control#getBorderWidth
+ * @see Control#getBounds
+ * @see Control#getSize
+ * @see Control#pack(boolean)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache);
+
+/**
+ * Instruct the layout to flush any cached values
+ * associated with the control specified in the argument
+ * control
.
+ *
+ * @param control a control managed by this layout
+ * @return true if the Layout has flushed all cached information associated with control
+ *
+ * @since 3.1
+ */
+bool flushCache (Control control) {
+ return false;
+}
+
+/**
+ * Lays out the children of the specified composite
+ * according to this layout.
+ *
+ * This method positions and sizes the children of a
+ * composite using the layout algorithm encoded by this
+ * layout. Children of the composite are positioned in
+ * the client area of the composite. The position of
+ * the composite is not altered by this method.
+ *
+ *
+ * When the flush cache hint is true, the layout is
+ * instructed to flush any cached values associated
+ * with the children. Typically, a layout will cache
+ * the preferred sizes of the children to avoid the
+ * expense of computing these values each time the
+ * widget is laid out.
+ *
+ *
+ * When layout is triggered explicitly by the programmer
+ * the flush cache hint is true. When layout is triggered
+ * by a resize, either caused by the programmer or by the
+ * user, the hint is false.
+ *
+ *
+ * @param composite a composite widget using this layout
+ * @param flushCache true
means flush cached layout values
+ */
+abstract void layout (Composite composite, bool flushCache);
+}
diff -r 27324bbbac70 -r 3a3e3aa76b66 dwt/widgets/Scrollable.d
--- a/dwt/widgets/Scrollable.d Thu Jan 10 02:18:07 2008 +0100
+++ b/dwt/widgets/Scrollable.d Thu Jan 10 03:51:48 2008 +0100
@@ -38,7 +38,7 @@
*
*/
public abstract class Scrollable : Control {
- GtkScrolledWindow* scrolledHandle;
+ GtkWidget* scrolledHandle;
ScrollBar horizontalBar, verticalBar;
/**
@@ -141,10 +141,10 @@
bar.display = display;
bar.state |= HANDLE;
if ((style & SWT.H_SCROLL) !is 0) {
- bar.handle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR (scrolledHandle);
- bar.adjustmentHandle = OS.gtk_scrolled_window_get_hadjustment (scrolledHandle);
+ bar.handle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR (cast(GtkScrolledWindow*)scrolledHandle);
+ bar.adjustmentHandle = OS.gtk_scrolled_window_get_hadjustment (cast(GtkScrolledWindow*)scrolledHandle);
} else {
- bar.handle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (scrolledHandle);
+ bar.handle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (cast(GtkScrolledWindow*)scrolledHandle);
bar.adjustmentHandle = OS.gtk_scrolled_window_get_vadjustment (cast(GtkScrolledWindow*)scrolledHandle);
}
bar.hookEvents ();
@@ -266,11 +266,11 @@
int hScrollBarWidth() {
if (horizontalBar is null) return 0;
- auto hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(scrolledHandle);
+ auto hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle);
if (hBarHandle is null) return 0;
GtkRequisition* requisition = new GtkRequisition();
OS.gtk_widget_size_request(cast(GtkWidget*)hBarHandle, requisition);
- int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle);
+ int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle);
return requisition.height + spacing;
}
@@ -290,7 +290,7 @@
bool setScrollBarVisible (ScrollBar bar, bool visible) {
if (scrolledHandle is null) return false;
int hsp, vsp;
- OS.gtk_scrolled_window_get_policy (scrolledHandle, &hsp, &vsp);
+ OS.gtk_scrolled_window_get_policy (cast(GtkScrolledWindow*)scrolledHandle, &hsp, &vsp);
int policy = visible ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
if ((bar.style & SWT.HORIZONTAL) !is 0) {
if (hsp is policy) return false;
@@ -299,7 +299,7 @@
if (vsp is policy) return false;
vsp = policy;
}
- OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+ OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp);
bar.sendEvent (visible ? SWT.Show : SWT.Hide);
sendEvent (SWT.Resize);
return true;
@@ -364,7 +364,7 @@
GtkWidget* topHandle () {
if (fixedHandle !is null) return fixedHandle;
- if (scrolledHandle !is null) return cast(GtkWidget*)scrolledHandle;
+ if (scrolledHandle !is null) return scrolledHandle;
return super.topHandle ();
}
@@ -374,11 +374,11 @@
int vScrollBarWidth() {
if (verticalBar is null) return 0;
- auto vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(scrolledHandle);
+ auto vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle);
if (vBarHandle is null) return 0;
GtkRequisition* requisition = new GtkRequisition();
OS.gtk_widget_size_request (cast(GtkWidget*)vBarHandle, requisition);
- int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle);
+ int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle);
return requisition.width + spacing;
}
}
diff -r 27324bbbac70 -r 3a3e3aa76b66 todo.txt
--- a/todo.txt Thu Jan 10 02:18:07 2008 +0100
+++ b/todo.txt Thu Jan 10 03:51:48 2008 +0100
@@ -5,7 +5,7 @@
Questions:
Whats needed at minimum to make a test with empty window?
How about memory management?
-
+ Check to remove "package", it non-virtual.
SWT // left: getMessage -> Compatibility:ResourceBundle
SWTError // OK