summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe <gheorghe>2009-11-12 19:24:24 +0000
committerBogdan Gheorghe <gheorghe>2009-11-12 19:24:24 +0000
commitf15ff0bb3cff4bd3ecbcf7fe360d6cd226272c84 (patch)
tree9569ad8a2570edbb7a0506fe0a345a983f0d6418
parent4c0e6ba4b69579a10f5aa2002e774ab773eb3f0c (diff)
downloadeclipse.platform.swt-f15ff0bb3cff4bd3ecbcf7fe360d6cd226272c84.tar.gz
eclipse.platform.swt-f15ff0bb3cff4bd3ecbcf7fe360d6cd226272c84.tar.xz
eclipse.platform.swt-f15ff0bb3cff4bd3ecbcf7fe360d6cd226272c84.zip
260406 - e4 CSS: widgets need to notify CSS to apply style information
260407 - e4 CSS: css attribute storage and notification
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Decorations.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java67
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Tray.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/expand/org/eclipse/swt/widgets/ExpandBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java8
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java8
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolBar.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Decorations.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ExpandBar.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Menu.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/MenuItem.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolBar.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tracker.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tree.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java26
113 files changed, 1422 insertions, 16 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index c2104bb637..10159023da 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -2486,6 +2486,14 @@ public void removeSelectionListener(SelectionListener listener) {
removeListener(SWT.Selection, listener);
removeListener(SWT.DefaultSelection, listener);
}
+
+public void reskin(int flags) {
+ super.reskin(flags);
+ for (int i = 0; i < items.length; i++) {
+ items[i].reskin(flags);
+ }
+}
+
public void setBackground (Color color) {
super.setBackground(color);
redraw();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java
index f233332c5d..4a87c66bd5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java
@@ -280,6 +280,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
index 61c63b39fa..7b311304e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
@@ -189,6 +189,7 @@ public void changed (Control[] changed) {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
+ display.runSkin ();
Point size;
if (layout != null) {
if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {
@@ -903,6 +904,15 @@ void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resetVisibleRegion (int control) {
if (scrolledVisibleRgn != 0) {
OS.DisposeRgn (scrolledVisibleRgn);
@@ -1087,6 +1097,7 @@ void updateLayout (boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
index 8d9454d554..2756d5ea3b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
@@ -3672,6 +3672,7 @@ public boolean setParent (Composite parent) {
OS.HIViewSetVisible (topHandle, (state & HIDDEN) == 0);
OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
this.parent = parent;
+ reskin (SWT.ALL);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
index 185f0dc80b..809037a78b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
@@ -408,6 +408,18 @@ void releaseWidget () {
defaultButton = null;
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ Menu [] menus = display.getMenus (this);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
boolean restoreFocus () {
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
if (savedFocus == null) return false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
index 06c6eb4e26..e83439feab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
@@ -312,6 +312,10 @@ public class Display extends Device {
static Display Default;
static Display [] Displays = new Display [4];
+ /* Skinning support */
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
static final String SET_MODAL_DIALOG = "org.eclipse.swt.internal.modalDialog"; //$NON-NLS-1$
@@ -535,6 +539,15 @@ void addPopup (Menu menu) {
popups [index] = menu;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
void addToDisposeWindow (int control) {
int [] root = new int [1];
if (disposeWindow == 0) {
@@ -3087,6 +3100,7 @@ int readImageRef(int path) {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runSkin ();
runDeferredLayouts ();
boolean events = false;
events |= runSettings ();
@@ -3614,6 +3628,29 @@ boolean runSettings () {
return true;
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
boolean runTimers () {
if (timerList == null) return false;
boolean result = false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java
index 13a2f739e1..e98b77674e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java
@@ -1042,6 +1042,15 @@ public void removeMenuListener (MenuListener listener) {
eventTable.unhook (SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java
index 8910067ba9..427638f987 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java
@@ -543,6 +543,13 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/*public*/ void select () {
checkWidget ();
Menu menu = parent, menuParent;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
index 6bb089c7d1..d1b6d9c51c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
@@ -380,6 +380,12 @@ void resizeClientArea () {
}
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
boolean sendMouseWheel (short wheelAxis, int wheelDelta) {
if ((state & CANVAS) != 0) {
ScrollBar bar = wheelAxis == OS.kEventMouseWheelAxisX ? horizontalBar : verticalBar;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
index 2c9601c839..106718bcb4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
@@ -284,6 +284,7 @@ Shell (Display display, Shell parent, int style, int handle, boolean embedded) {
state |= FOREIGN_HANDLE;
}
}
+ reskinWidget ();
createWidget ();
}
@@ -1353,6 +1354,21 @@ void resizeBounds () {
resizeClientArea ();
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ if (toolTips != null) {
+ for (int i=0; i<toolTips.length; i++) {
+ ToolTip toolTip = toolTips [i];
+ if (toolTip != null) toolTip.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Moves the receiver to the top of the drawing order for
* the display on which it was created (so that all other
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java
index dc60a2cdcd..ecdc2944dd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java
@@ -563,6 +563,18 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ int count = OS.GetControl32BitMaximum (handle);
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
int result = super.setBounds(x, y, width, height, move, resize, events);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java
index 8717f471c2..f000b1f3b9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java
@@ -2635,6 +2635,23 @@ void resetVisibleRegion (int control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java
index 8e0fc07595..d498ab90fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java
@@ -487,6 +487,16 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setBackground (float [] color) {
super.setBackground (color);
if (items == null) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java
index 91d93f3b18..850e7294f3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java
@@ -138,6 +138,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java
index f9d739c316..4ea541eaaf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java
@@ -2840,6 +2840,22 @@ void resetVisibleRegion (int control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) item.reskinChildren (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Display a mark indicating the point at which an item will be inserted.
* The drop insert item has a visual hint to show where a dragged item
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
index 08ad2c68e8..3af8825297 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
@@ -92,6 +92,9 @@ public abstract class Widget {
static final String IS_ACTIVE = "org.eclipse.swt.internal.isActive"; //$NON-NLS-1$
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -137,6 +140,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
int actionProc (int theControl, int partCode) {
@@ -1571,6 +1575,27 @@ protected void removeListener (int eventType, SWTEventListener handler) {
}
/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
+/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is disposed.
*
@@ -1861,6 +1886,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
boolean setInputState (Event event, int type, int chord, int modifiers) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
index 673572bc6b..a999c981bd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
@@ -291,6 +291,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
index 95ebf52e42..5b8b79752a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
@@ -212,6 +212,7 @@ public void changed (Control[] changed) {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
+ display.runSkin ();
Point size;
if (layout != null) {
if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {
@@ -785,6 +786,15 @@ void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resized () {
super.resized ();
if (layout != null) {
@@ -1046,6 +1056,7 @@ void updateLayout (boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin ();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 8faf8ab53b..db707dd7c5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -3482,6 +3482,7 @@ public boolean setParent (Composite parent) {
parent.contentView().addSubview(topView, OS.NSWindowBelow, null);
topView.release();
this.parent = parent;
+ reskin (SWT.ALL);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Decorations.java
index e0c6c74c29..b172a134d1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Decorations.java
@@ -407,6 +407,18 @@ void releaseWidget () {
defaultButton = null;
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ Menu [] menus = display.getMenus (this);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
boolean restoreFocus () {
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
if (savedFocus == null) return false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 4b3db1300a..590bc80a86 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -284,7 +284,12 @@ public class Display extends Device {
/* Multiple Displays. */
static Display Default;
static Display [] Displays = new Display [4];
-
+
+ /* Skinning support */
+ static final int GROW_SIZE = 1024;
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets.";
@@ -503,6 +508,15 @@ void addPopup (Menu menu) {
popups [index] = menu;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
void addWidget (NSObject view, Widget widget) {
if (view == null) return;
OS.object_setInstanceVariable (view.id, SWT_OBJECT, widget.jniRef);
@@ -3181,6 +3195,7 @@ public boolean readAndDispatch () {
checkDevice ();
if (sendEventCount == 0 && loopCount == poolCount - 1 && Callback.getEntryCount () == 0) removePool ();
addPool ();
+ runSkin ();
runDeferredLayouts ();
loopCount++;
boolean events = false;
@@ -3623,6 +3638,29 @@ boolean runSettings () {
return true;
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
boolean runTimers () {
if (timerList == null) return false;
boolean result = false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
index 1a6551a8cf..ffacf9fef5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
@@ -788,6 +788,15 @@ public void removeMenuListener (MenuListener listener) {
eventTable.unhook (SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java
index c841250a22..11fb767d51 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java
@@ -499,6 +499,13 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
void selectRadio () {
int index = 0;
MenuItem [] items = parent.getItems ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java
index c5bb1ae72a..ba1e6e94c2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java
@@ -290,6 +290,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
void scrollClipViewToPoint (int /*long*/ id, int /*long*/ sel, int /*long*/ clipView, NSPoint point) {
if ((state & CANVAS) == 0 && scrollView != null) {
NSClipView clip = new NSClipView (clipView);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
index 4781a387d8..6f7ddb7546 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
@@ -281,6 +281,7 @@ Shell (Display display, Shell parent, int style, int /*long*/handle, boolean emb
state |= FOREIGN_HANDLE;
}
}
+ reskinWidget();
createWidget ();
}
@@ -1236,6 +1237,15 @@ public void removeShellListener(ShellListener listener) {
eventTable.unhook(SWT.Deiconify,listener);
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
void sendToolTipEvent (boolean enter) {
if (!isVisible()) return;
if (tooltipTag == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
index 45700362ef..3a91d4e6e3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
@@ -489,6 +489,17 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ super.reskinChildren (flags);
+}
+
void setFont (NSFont font) {
((NSTabView)view).setFont(font);
for (int i = 0; i < itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
index 6f395abf51..1c6ad92785 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
@@ -2169,6 +2169,23 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
index b17033e132..27d453ca28 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
@@ -546,6 +546,16 @@ void resized () {
relayout ();
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setFont(NSFont font) {
for (int i = 0; i < itemCount; i++) {
ToolItem item = items[i];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
index c7a9e95ef4..d40c7c44e6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
@@ -136,6 +136,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index 695e7f354d..ae3acb54f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -2261,6 +2261,22 @@ public void removeTreeListener (TreeListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) item.reskinChildren (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setImage (int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
OS.object_setInstanceVariable(id, Display.SWT_IMAGE, arg0);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
index f57f16769e..53678a1df5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
@@ -87,6 +87,9 @@ public abstract class Widget {
static final String IS_ACTIVE = "org.eclipse.swt.internal.isActive"; //$NON-NLS-1$
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -129,6 +132,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
int /*long*/ accessibilityActionDescription(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
@@ -302,6 +306,27 @@ void becomeKeyWindow (int /*long*/ id, int /*long*/ sel) {
callSuper(id, sel);
}
+/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
boolean resignFirstResponder (int /*long*/ id, int /*long*/ sel) {
return callSuperBoolean(id, sel);
}
@@ -1464,6 +1489,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
void setOpenGLContext(Object value) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index 6f7fe02158..f7f3635746 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -574,7 +574,7 @@ public class SWT {
* @since 3.6
*/
public static final int MouseHorizontalWheel = 38;
-
+
/**
* The mouse wheel event type (value is 37).
* This is a synonym for {@link #MouseVerticalWheel} (value is 37).
@@ -683,6 +683,23 @@ public class SWT {
*/
public static final int OrientationChange = 44;
+ /**
+ * The skin event type (value is 45).
+ *
+ * <p>
+ * The skin event is sent by the display when a widget needs to
+ * be skinned.
+ * </p>
+ *
+ * @see org.eclipse.swt.widgets.Widget#addListener
+ * @see org.eclipse.swt.widgets.Display#addFilter
+ * @see org.eclipse.swt.widgets.Event
+ * @see org.eclipse.swt.widgets.Widget#reskin(int)
+ *
+ * @since 3.6
+ */
+ public static final int Skin = 45;
+
/* Event Details */
/**
@@ -867,20 +884,6 @@ public class SWT {
public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
/**
- * A constant indicating that a given operation should be performed on
- * all widgets (value is 1&lt;&lt;0).
- *
- * <p><b>Used By:</b><ul>
- * <li><code>Composite</code> layout</li>
- * </ul></p>
- *
- * @see org.eclipse.swt.widgets.Composite#layout(org.eclipse.swt.widgets.Control[], int)
- *
- * @since 3.6
- */
- public static final int ALL = 1 << 0;
-
- /**
* A constant indicating that widgets have changed.
* (value is 1&lt;&lt;1).
*
@@ -3817,6 +3820,40 @@ public class SWT {
*/
public static final int MOVEMENT_WORD_START = 1 << 4;
+ /**
+ * A constant indicating that a given operation should be performed on
+ * all widgets (value is 1&lt;&lt;0).
+ *
+ * <p><b>Used By:</b><ul>
+ * <li><code>Composite</code> layout</li>
+ * </ul></p>
+ *
+ * @see org.eclipse.swt.widgets.Composite#layout(org.eclipse.swt.widgets.Control[], int)
+ *
+ * @since 3.6
+ */
+ public static final int ALL = 1 << 0;
+
+ /**
+ * Key value for setting and getting the skin class of a widget.
+ *
+ * @see org.eclipse.swt.widgets.Widget#getData(String)
+ * @see org.eclipse.swt.widgets.Widget#setData(String, Object)
+ *
+ * @since 3.6
+ */
+ public static final String SKIN_CLASS = "org.eclipse.swt.skin.class";
+
+ /**
+ * Key value for setting and getting the skin id of a widget.
+ *
+ * @see org.eclipse.swt.widgets.Widget#getData(String)
+ * @see org.eclipse.swt.widgets.Widget#setData(String, Object)
+ *
+ * @since 3.6
+ */
+ public static final String SKIN_ID = "org.eclipse.swt.skin.id";
+
/**
* Answers a concise, human readable description of the error code.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Tray.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Tray.java
index 53fadefae4..e7c4ecfe20 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Tray.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Tray.java
@@ -45,6 +45,7 @@ Tray (Display display, int style) {
error (SWT.ERROR_THREAD_INVALID_ACCESS);
}
this.display = display;
+ reskinWidget ();
}
void createItem (TrayItem item, int index) {
@@ -146,4 +147,14 @@ void releaseParent () {
if (display.tray == this) display.tray = null;
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TrayItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
index 8abac1a4e0..9d3e6a7540 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
@@ -13,6 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
/**
* Instances of this class provide an area for dynamically
@@ -1099,6 +1100,19 @@ public void setWrapIndices (int[] indices) {
}
relayout();
}
+
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int row = 0; row < items.length; row++) {
+ for (int i = 0; i < items[row].length; i++) {
+ CoolItem item = items[row][i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ }
+ super.reskinChildren (flags);
+}
+
public void setCursor (Cursor cursor) {
checkWidget ();
super.setCursor (this.cursor = cursor);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/expand/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/expand/org/eclipse/swt/widgets/ExpandBar.java
index 86e4a47bb7..fc2e9dc3fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/expand/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/expand/org/eclipse/swt/widgets/ExpandBar.java
@@ -379,6 +379,16 @@ public void removeExpandListener (ExpandListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ExpandItem item = items [i];
+ if (item != null ) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
public void setFont(Font font) {
super.setFont (font);
this.font = font;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
index 9c1384f2c2..ea9d245137 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
@@ -1057,6 +1057,17 @@ void resize() {
ensureRightFreeSpaceUsed();
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Scroll the tab items to the left.
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
index af445fdd61..46ed89501e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
@@ -3135,6 +3135,22 @@ public void removeSelectionListener (SelectionListener listener) {
removeListener (SWT.Selection, listener);
removeListener (SWT.DefaultSelection, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemsCount; i++) {
+ TableItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
index 1e65f8c530..40e0e2cac4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
@@ -3387,6 +3387,21 @@ public void removeTreeListener (TreeListener listener) {
removeListener (SWT.Expand, listener);
removeListener (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) item.reskinChildren (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
/**
* Selects an item in the receiver. If the item was already
* selected, it remains selected.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index ea6a1495d8..6c480d3ff6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -211,6 +211,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 5dc2d87427..55354e2285 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -210,6 +210,7 @@ int /*long*/ childStyle () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ display.runSkin();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
Point size;
@@ -1224,6 +1225,15 @@ void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resizeHandle (int width, int height) {
super.resizeHandle (width, height);
if (socketHandle != 0) OS.gtk_widget_set_size_request (socketHandle, width, height);
@@ -1444,6 +1454,7 @@ void updateLayout (boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index e4bacbceb3..80a2ebf139 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -3913,6 +3913,7 @@ public boolean setParent (Composite parent) {
OS.gtk_fixed_move (newParent, topHandle, x, y);
this.parent = parent;
setZOrder (null, false, true);
+ reskin (SWT.ALL);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
index 38ed5a2f6a..0ee4ad11fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
@@ -489,6 +489,17 @@ void releaseWidget () {
defaultButton = saveDefault = null;
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
boolean restoreFocus () {
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
boolean restored = savedFocus != null && savedFocus.setFocus ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 33fbc9eeea..caf4397df9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -400,6 +400,10 @@ public class Display extends Device {
static Display Default;
static Display [] Displays = new Display [4];
+ /* Skinning support */
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
/* This code is intentionally commented.
@@ -642,6 +646,15 @@ void addPopup (Menu menu) {
popups [index] = menu;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
void addWidget (int /*long*/ handle, Widget widget) {
if (handle == 0) return;
if (freeSlot == -1) {
@@ -3103,6 +3116,7 @@ void putGdkEvents () {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runSkin ();
runDeferredLayouts ();
boolean events = false;
events |= runSettings ();
@@ -3556,6 +3570,29 @@ boolean runSettings () {
return true;
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
/**
* On platforms which support it, sets the application name
* to be the argument. On Motif, for example, this can be used
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index b3584f8586..55354051b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -601,6 +601,16 @@ public void removeExpandListener (ExpandListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ExpandItem item = items [i];
+ if (item != null ) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 5e042a67b5..e585ee1d96 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -834,6 +834,15 @@ public void removeHelpListener (HelpListener listener) {
eventTable.unhook (SWT.Help, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
boolean sendHelpEvent (int /*long*/ helpType) {
if (selectedItem != null && !selectedItem.isDisposed()) {
if (selectedItem.hooks (SWT.Help)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index e88eefdf89..38e6ac81c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -574,6 +574,12 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.Selection, listener);
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
void selectRadio () {
int index = 0;
MenuItem [] items = parent.getItems ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index ab3304558a..e349be0d88 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -276,6 +276,12 @@ int hScrollBarWidth() {
return requisition.height + spacing;
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
boolean sendLeaveNotify () {
return scrolledHandle != 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 1eb04fed20..b3f1973a58 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -277,6 +277,7 @@ Shell (Display display, Shell parent, int style, int /*long*/ handle, boolean em
state |= FOREIGN_HANDLE;
}
}
+ reskinWidget();
createWidget (0);
}
@@ -1471,6 +1472,21 @@ void removeTooTip (ToolTip toolTip) {
}
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ if (toolTips != null) {
+ for (int i=0; i<toolTips.length; i++) {
+ ToolTip toolTip = toolTips [i];
+ if (toolTip != null) toolTip.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index 4c284130fb..8c29dc4c52 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -587,6 +587,22 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ int /*long*/ list = OS.gtk_container_get_children (handle);
+ if (list != 0){
+ int count = OS.g_list_length (list);
+ OS.g_list_free (list);
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 5a3379865e..f44b533bca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -2721,6 +2721,23 @@ void resetCustomDraw () {
firstCustomDraw = false;
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 7e10532e9a..a87565f926 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -498,6 +498,17 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ ToolItem[] items = _getItems();
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0) relayout ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index e5729d3980..9bb9bc74e2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -132,6 +132,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 310d6bb39b..d3267d82ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -2717,6 +2717,22 @@ void resetCustomDraw () {
firstCustomDraw = false;
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) item.reskinChildren (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Display a mark indicating the point at which an item will be inserted.
* The drop insert item has a visual hint to show where a dragged item
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index ae822517fb..3b7cf9d134 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -94,6 +94,9 @@ public abstract class Widget {
static final int FOREIGN_HANDLE = 1<<22;
static final int DRAG_DETECT = 1<<23;
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -210,6 +213,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
void _addListener (int eventType, Listener listener) {
@@ -1164,6 +1168,27 @@ int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*l
}
/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
+/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is disposed.
*
@@ -1429,6 +1454,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
void setForegroundColor (int /*long*/ handle, GdkColor color) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
index 439c284228..82827bf4a7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
@@ -161,6 +161,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
index 35e769a8d1..e9bfa62e87 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
@@ -145,6 +145,7 @@ Control [] _getTabList () {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
+ display.runSkin();
Point size;
if (layout != null) {
if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {
@@ -1014,6 +1015,14 @@ void releaseWidget () {
void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
void resizeClientWindow () {
if (clientWindow == 0) return;
boolean warnings = display.getWarnings ();
@@ -1317,6 +1326,7 @@ void updateLayout (boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
index 6aea3bb376..4b5a5dd43e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
@@ -2782,6 +2782,7 @@ public void setMenu (Menu menu) {
public boolean setParent (Composite parent) {
checkWidget();
if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ reskin (SWT.ALL);
return false;
}
void setParentBackground () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
index 5c0b2ba927..199a3448c4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
@@ -445,6 +445,16 @@ void releaseWidget () {
defaultButton = saveDefault = null;
label = null;
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
boolean restoreFocus () {
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
boolean restored = savedFocus != null && savedFocus.setFocus ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
index 93d5eb6300..681ee2848f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
@@ -300,6 +300,10 @@ public class Display extends Device {
/* Workaround for GP when disposing a display */
static boolean DisplayDisposed;
+ /* Skinning support */
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
/*
@@ -558,6 +562,14 @@ void addPopup (Menu menu) {
}
popups [index] = menu;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -2829,6 +2841,7 @@ void postEvent (Event event) {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runSkin ();
runDeferredLayouts ();
boolean events = runPopups ();
int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
@@ -3251,6 +3264,28 @@ boolean runPopups () {
popups = null;
return result;
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
void sendEvent (int eventType, Event event) {
if (eventTable == null && filterTable == null) {
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
index a9c5f18866..f9dcf0113c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
@@ -762,6 +762,14 @@ public void removeMenuListener(MenuListener listener) {
eventTable.unhook(SWT.Hide, listener);
eventTable.unhook(SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
void sendHelpEvent (int callData) {
if (hooks (SWT.Help)) {
postEvent (SWT.Help);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
index 592f9042de..9731e46e12 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
@@ -612,6 +612,12 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook(SWT.Selection, listener);
eventTable.unhook(SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
void selectRadio () {
int index = 0;
MenuItem [] items = parent.getItems ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
index bd8cc53cbc..3cf87dcb20 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
@@ -260,6 +260,11 @@ void releaseHandle () {
super.releaseHandle ();
scrolledHandle = formHandle = 0;
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
index 942cee0886..2b68867071 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
@@ -275,6 +275,7 @@ Shell (Display display, Shell parent, int style, int handle, boolean embedded) {
state |= FOREIGN_HANDLE;
}
}
+ reskinWidget();
createWidget (0);
}
/**
@@ -1342,6 +1343,15 @@ public void removeShellListener(ShellListener listener) {
eventTable.unhook(SWT.Deiconify,listener);
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
index a9d66b0d96..a5afb5901e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
@@ -457,6 +457,15 @@ void removeControl (Control control) {
if (item.control == control) item.setControl (null);
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
for (int i=0; i<itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
index b7d096f337..77ace947a2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
@@ -131,6 +131,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
index 53c8c49db6..5f37d90bdd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
@@ -85,6 +85,9 @@ public abstract class Widget {
static final int FOREIGN_HANDLE = 1<<13;
static final int DRAG_DETECT = 1<<14;
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -161,6 +164,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
/**
* Adds the listener to the collection of listeners who will
@@ -761,6 +765,24 @@ protected void removeListener (int eventType, SWTEventListener handler) {
eventTable.unhook (eventType, handler);
}
/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+void reskinChildren (int flags) {
+}
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is disposed.
*
@@ -1111,6 +1133,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
index acd420000a..44d3d8a528 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -191,6 +191,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
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 bed42877ec..e1e576c1b5 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
@@ -211,6 +211,7 @@ Control [] computeTabList () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
+ display.runSkin ();
Point size;
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -933,6 +934,15 @@ void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resizeClientArea () {
int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
OS.PtGetResources (scrolledHandle, args.length / 3, args);
@@ -1165,6 +1175,7 @@ void updateLayout (boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin ();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
index 2a58676f3f..b310dfbfa1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
@@ -2776,6 +2776,7 @@ public void setMenu (Menu menu) {
public boolean setParent (Composite parent) {
checkWidget();
if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ reskin (SWT.ALL);
return false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
index cab73999ad..f327f05505 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -394,6 +394,17 @@ void remove (Menu menu) {
}
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void resizeBounds (int width, int height) {
int menuHeight = 0;
if (menuBar != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
index 6cb808cdb6..de7dc27068 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -270,6 +270,11 @@ public class Display extends Device {
int SCROLLBAR_VERTICAL_BASIC_FLAGS;
int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+ /* Skinning support */
+ static final int GROW_SIZE = 1024;
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package name */
static final String PACKAGE_NAME;
static {
@@ -426,6 +431,15 @@ public void addListener (int eventType, Listener listener) {
eventTable.hook (eventType, listener);
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -2051,6 +2065,7 @@ void postEvent (Event event) {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runSkin ();
runDeferredLayouts ();
idle = false;
OS.PtRelease ();
@@ -2309,6 +2324,29 @@ boolean runDeferredLayouts () {
return false;
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
void sendEvent (int eventType, Event event) {
if (eventTable == null && filterTable == null) {
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
index 6234527894..c54ba7b0b3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -697,6 +697,15 @@ public void removeMenuListener (MenuListener listener) {
eventTable.unhook (SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
index e2f942200c..4553d5e9bf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -572,6 +572,13 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
void selectRadio () {
int index = 0;
MenuItem [] items = parent.getItems ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
index 22cc818e63..3d7b2916f2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
@@ -220,6 +220,12 @@ void resizeClientArea () {
/* Do nothing */
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
void releaseChildren (boolean destroy) {
if (horizontalBar != null) {
horizontalBar.release (false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
index e66164f526..dbd6597d8c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -265,6 +265,7 @@ Shell (Display display, Shell parent, int style, int handle) {
this.parent = parent;
this.display = display;
this.handle = handle;
+ reskinWidget();
createWidget (0);
}
@@ -965,6 +966,15 @@ public void removeShellListener (ShellListener listener) {
eventTable.unhook (SWT.Deactivate, listener);
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
index 35c64ff915..06b11f4982 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
@@ -604,6 +604,17 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
int result = super.setBounds (x, y, width, height, move, resize, events);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
index 823bff5614..078e1896dd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -414,6 +414,16 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
for (int i = 0; i < itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
index 0ea5d78fdc..1e6e5dbce8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
@@ -97,6 +97,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
index 223294eeac..949b80a505 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -83,6 +83,9 @@ public abstract class Widget {
static final int RELEASED = 1<<11;
static final int DISPOSE_SENT = 1<<12;
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -125,6 +128,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
@@ -908,6 +912,27 @@ protected void removeListener (int eventType, SWTEventListener handler) {
}
/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
+/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is disposed.
*
@@ -1107,6 +1132,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
boolean setInputState (Event event, int type, int key_mods, int button_state) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index 755133c792..5ca958ded8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -174,6 +174,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index 8e7b16bdb1..37352bfa79 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -224,6 +224,7 @@ Widget [] computeTabList () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ display.runSkin ();
Point size;
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -858,6 +859,15 @@ void removeControl (Control control) {
resizeChildren ();
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resizeChildren () {
if (lpwp == null) return;
do {
@@ -1222,6 +1232,7 @@ void updateLayout (boolean resize, boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin();
if (resize) setResizeChildren (false);
layout.layout (this, changed);
if (resize) setResizeChildren (true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 261d8cc198..1e47ec752f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -3935,6 +3935,7 @@ public boolean setParent (Composite parent) {
this.parent = parent;
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);
+ reskin (SWT.ALL);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
index ea6585e563..94bc063e8f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -727,6 +727,16 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ CoolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setBackgroundPixel (int pixel) {
if (pixel == -1) pixel = defaultBackground ();
OS.SendMessage (handle, OS.RB_SETBKCOLOR, 0, pixel);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index ca06ad3400..15ab45fe60 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -803,6 +803,17 @@ void removeMenu (Menu menu) {
}
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
boolean restoreFocus () {
if (display.ignoreRestoreFocus) return true;
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 59ff1ecfb2..5d2c2d9fc8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -393,6 +393,10 @@ public class Display extends Device {
/* Workaround for Adobe Reader 7.0 */
int hitCount;
+ /* Skinning support */
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
/*
@@ -510,6 +514,15 @@ void addControl (int /*long*/ handle, Control control) {
controlTable [oldSlot] = control;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when an event of the given type occurs anywhere
@@ -3500,6 +3513,7 @@ public boolean readAndDispatch () {
checkDevice ();
lpStartupInfo = null;
drawMenuBars ();
+ runSkin ();
runDeferredLayouts ();
runPopups ();
if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {
@@ -3983,6 +3997,29 @@ void runSettings () {
}
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
boolean runTimer (int /*long*/ id) {
if (timerList != null && timerIds != null) {
int index = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
index ca9c0bb0be..6ee27b8509 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
@@ -480,6 +480,16 @@ public void removeExpandListener (ExpandListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ExpandItem item = items [i];
+ if (item != null ) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
if (!OS.IsWinCE) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
index 183a593045..afb4bec41e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -1224,6 +1224,15 @@ public void removeMenuListener (MenuListener listener) {
eventTable.unhook (SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the control
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
index 2fcc9e9607..63a1892639 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
@@ -600,6 +600,14 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
void selectRadio () {
int index = 0;
MenuItem [] items = parent.getItems ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
index 26360c1fa3..73bfc18af0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -226,6 +226,12 @@ void releaseChildren (boolean destroy) {
super.releaseChildren (destroy);
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
int /*long*/ scrolledHandle () {
return handle;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index abf8aad68b..62d6bd6e1c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -292,6 +292,7 @@ Shell (Display display, Shell parent, int style, int /*long*/ handle, boolean em
if (handle != 0 && !embedded) {
state |= FOREIGN_HANDLE;
}
+ reskinWidget();
createWidget ();
}
@@ -1322,6 +1323,21 @@ public void removeShellListener (ShellListener listener) {
eventTable.unhook (SWT.Deactivate, listener);
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ if (toolTips != null) {
+ for (int i=0; i<toolTips.length; i++) {
+ ToolTip toolTip = toolTips [i];
+ if (toolTip != null) toolTip.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
LRESULT selectPalette (int /*long*/ hPalette) {
int /*long*/ hDC = OS.GetDC (handle);
int /*long*/ hOld = OS.SelectPalette (hDC, hPalette, false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index e3aa38aeee..de71d4c942 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -614,6 +614,19 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+
+void reskinChildren (int flags) {
+ if (items != null) {
+ int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ items = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the receiver's selection to the given item.
* The current selected is first cleared, then the new item is
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 50f9a02bdb..5b769519ba 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -3157,6 +3157,24 @@ public void select (int [] indices) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index 77ac924055..face397f14 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -839,6 +839,16 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
void setBackgroundImage (int /*long*/ hBitmap) {
super.setBackgroundImage (hBitmap);
setBackgroundTransparent (hBitmap != 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
index 3257ade1fc..6caa2e12b9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
@@ -140,6 +140,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index b55c414c4d..073fb349f7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -4014,6 +4014,23 @@ public void removeTreeListener(TreeListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) item.reskinChildren (flags);
+ }
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
+
/**
* Display a mark indicating the point at which an item will be inserted.
* The drop insert item has a visual hint to show where a dragged item
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 2cbe077bbe..05b1a25022 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -90,6 +90,9 @@ public abstract class Widget {
/* Ignore WM_CHANGEUISTATE */
static final int IGNORE_WM_CHANGEUISTATE = 1<<20;
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -146,6 +149,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
void _addListener (int eventType, Listener listener) {
@@ -974,6 +978,50 @@ public void removeDisposeListener (DisposeListener listener) {
eventTable.unhook (SWT.Dispose, listener);
}
+/**
+ * Marks the widget to be skinned.
+ * <p>
+ * The skin event is sent to the receiver's display when appropriate (usually before the next event
+ * is handled). Widgets are automatically marked for skinning upon creation as well as when its skin
+ * id or class changes. The skin id and/or class can be changed by calling <code>Display.setData(String, Object)</code>
+ * with the keys SWT.SKIN_ID and/or SWT.SKIN_CLASS. Once the skin event is sent to a widget, it
+ * will not be sent again unless <code>reskin(int)</code> is called on the widget or on an ancestor
+ * while specifying the <code>SWT.ALL</code> flag.
+ * </p>
+ * <p>
+ * The parameter <code>flags</code> may be either:
+ * <dl>
+ * <dt><b>SWT.ALL</b></dt>
+ * <dd>all children in the receiver's widget tree should be skinned</dd>
+ * <dt><b>SWT.NONE</b></dt>
+ * <dd>only the receiver should be skinned</dd>
+ * </dl>
+ * </p>
+ * @param flags the flags specifying how to reskin
+ *
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
boolean sendDragEvent (int button, int x, int y) {
Event event = new Event ();
event.button = button;
@@ -1207,6 +1255,7 @@ public void setData (String key, Object value) {
}
}
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
boolean sendFocusEvent (int type) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java
index d662b69410..43a26983bc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java
@@ -149,6 +149,12 @@ void releaseChildren (boolean destroy) {
}
}
+void reskinChildren (int flags) {
+ if (caret != null) caret.reskin (flags);
+ if (ime != null) ime.reskin (flags);
+ super.reskinChildren (flags);
+}
+
/**
* Fills the interior of the rectangle specified by the arguments,
* with the receiver's background.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
index aadca4d793..5f3999e80b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
@@ -243,6 +243,7 @@ Control [] computeTabList () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ display.runSkin ();
Point size;
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -898,6 +899,15 @@ void removeControl (Control control) {
fixTabList (control);
}
+void reskinChildren (int flags) {
+ super.reskinChildren (flags);
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child != null) child.reskin (flags);
+ }
+}
+
void resized () {
super.resized();
if (isDisposed ()) return;
@@ -1166,6 +1176,7 @@ void updateLayout (boolean resize, boolean all) {
if ((state & LAYOUT_NEEDED) != 0) {
boolean changed = (state & LAYOUT_CHANGED) != 0;
state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+ display.runSkin ();
layout.layout (this, changed);
}
if (all) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java
index 1cbda102e8..c6ad6eb65e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java
@@ -3612,6 +3612,7 @@ public boolean setParent (Composite parent) {
checkWidget ();
if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ reskin (SWT.ALL);
if (this.parent == parent) return true;
if (!isReparentable ()) return false;
return false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolBar.java
index 2b35cecfe6..d7b4f3385c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolBar.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.internal.wpf.*;
+import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
@@ -525,6 +526,16 @@ void removeControl (Control control) {
}
}
+void reskinChildren (int flags) {
+ if (items != null) {
+ for (int i=0; i<items.length; i++) {
+ CoolItem item = items [i];
+ if (item != null) item.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, int flags) {
int result = super.setBounds (x, y, width, height, flags);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Decorations.java
index 95b68840ee..beea4160c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Decorations.java
@@ -530,6 +530,17 @@ void removeMenu (Menu menu) {
}
}
+void reskinChildren (int flags) {
+ if (menuBar != null) menuBar.reskin (flags);
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null) menu.reskin (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
boolean restoreFocus () {
// if (display.ignoreRestoreFocus) return true;
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
index a7d778f657..7542a3bf39 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
@@ -314,6 +314,11 @@ public class Display extends Device {
Shell [] modalShells;
// Shell modalDialogShell;
+ /* Skinning support */
+ static final int GROW_SIZE = 1024;
+ Widget [] skinList = new Widget [GROW_SIZE];
+ int skinCount;
+
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
/*
@@ -556,6 +561,15 @@ void addShell (Shell shell) {
shells [index] = shell;
}
+void addSkinnableWidget (Widget widget) {
+ if (skinCount >= skinList.length) {
+ Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
+ skinList = newSkinWidgets;
+ }
+ skinList [skinCount++] = widget;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -2224,6 +2238,7 @@ void removeShell (Shell shell) {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runSkin ();
runDeferredLayouts ();
runPopups ();
idle = false;
@@ -2554,6 +2569,29 @@ void runSettings () {
}
}
+boolean runSkin () {
+ if (skinCount > 0) {
+ Widget [] oldSkinWidgets = skinList;
+ int count = skinCount;
+ skinList = new Widget[GROW_SIZE];
+ skinCount = 0;
+ if (eventTable != null && eventTable.hooks(SWT.Skin)) {
+ for (int i = 0; i < count; i++) {
+ Widget widget = oldSkinWidgets[i];
+ if (widget != null && !widget.isDisposed()) {
+ widget.state &= ~Widget.SKIN_NEEDED;
+ oldSkinWidgets[i] = null;
+ Event event = new Event ();
+ event.widget = widget;
+ sendEvent (SWT.Skin, event);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
void saveResources () {
// int resourceCount = 0;
// if (resources == null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ExpandBar.java
index b6cfac15bc..dc37db1357 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ExpandBar.java
@@ -418,6 +418,20 @@ public void removeExpandListener (ExpandListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (itemCount > 0) {
+ int items = OS.Panel_Children (handle);
+ for (int i=0; i<itemCount; i++) {
+ ExpandItem item = getItem (items, i);
+ if (item != null) {
+ item.reskin(flags);
+ }
+ }
+ OS.GCHandle_Free (items);
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, int flags) {
int result = super.setBounds (x, y, width, height, flags);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Menu.java
index b6462e7c77..5130e87dec 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Menu.java
@@ -786,6 +786,15 @@ public void removeMenuListener (MenuListener listener) {
eventTable.unhook (SWT.Show, listener);
}
+void reskinChildren (int flags) {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ item.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/MenuItem.java
index cc5a802a22..bd7a4e0320 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/MenuItem.java
@@ -534,6 +534,13 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (menu != null) {
+ menu.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Sets the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
index 2176dd0efb..15bfdbfce3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
@@ -306,6 +306,12 @@ void releaseHandle () {
scrolledHandle = 0;
}
+void reskinChildren (int flags) {
+ if (horizontalBar != null) horizontalBar.reskin (flags);
+ if (verticalBar != null) verticalBar.reskin (flags);
+ super.reskinChildren (flags);
+}
+
int topHandle () {
return scrolledHandle != 0 ? scrolledHandle : super.topHandle ();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
index 6ec9c27532..c915f23bb4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
@@ -272,6 +272,7 @@ Shell (Display display, Shell parent, int style, int handle, boolean embedded) {
shellHandle = handle;
}
}
+ reskinWidget();
createWidget ();
}
@@ -1109,6 +1110,15 @@ public void removeShellListener (ShellListener listener) {
eventTable.unhook (SWT.Deactivate, listener);
}
+void reskinChildren (int flags) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != null) shell.reskin (flags);
+ }
+ super.reskinChildren (flags);
+}
+
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
index 9100ff47f0..104a39ab36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
@@ -576,6 +576,18 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+void reskinChildren (int flags) {
+ if (itemCount > 0) {
+ int items = OS.ItemsControl_Items (handle);
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = getItem (items, i);
+ if (item != null) item.reskin(flags);
+ }
+ OS.GCHandle_Free (items);
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, int flags) {
int result = super.setBounds (x, y, width, height, flags);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java
index 068104d290..808c47e9a6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java
@@ -1763,6 +1763,25 @@ public void select (int [] indices) {
ignoreSelection = false;
}
+void reskinChildren (int flags) {
+ if (itemCount > 0) {
+ int items = OS.ItemsControl_Items (handle);
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = getItem (items, i, true);
+ if (item != null) item.reskin (flags);
+ }
+ OS.GCHandle_Free (items);
+ }
+ if (columns != null) {
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.reskin (flags);
+ }
+ columns = null;
+ }
+ super.reskinChildren (flags);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolBar.java
index ddc1d15a8e..c537cd03ff 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolBar.java
@@ -421,6 +421,18 @@ void removeControl (Control control) {
OS.GCHandle_Free (items);
}
+void reskinChildren (int flags) {
+ if (itemCount > 0) {
+ int items = OS.ItemsControl_Items (handle);
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = getItem (items, i);
+ if (item != null) item.reskin (flags);
+ }
+ OS.GCHandle_Free (items);
+ }
+ super.reskinChildren (flags);
+}
+
void setButtonVisibility (byte visibility) {
int template = OS.Control_Template (handle);
int overFlowName = createDotNetString ("OverflowGrid", false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tracker.java
index 884c71b1cf..1528845344 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tracker.java
@@ -136,6 +136,7 @@ public Tracker (Display display, int style) {
}
this.style = checkStyle (style);
this.display = display;
+ reskinWidget ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tree.java
index 72d06c0c46..45d42dae34 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Tree.java
@@ -1821,6 +1821,24 @@ public void removeTreeListener(TreeListener listener) {
eventTable.unhook (SWT.Collapse, listener);
}
+void reskinChildren (int flags) {
+ if (itemCount > 0) {
+ int items = OS.ItemsControl_Items (handle);
+ for (int i = 0; i < itemCount; i++) {
+ TreeItem item = getItem (items, i, true);
+ if (item != null) item.reskinChildren (flags);
+ }
+ OS.GCHandle_Free (items);
+ }
+ if (columns != null) {
+ for (int i=0; i<columns.length; i++) {
+ TreeColumn column = columns [i];
+ if (column != null) column.reskinChildren (flags);
+ }
+ }
+ super.reskinChildren (flags);
+}
+
int setBounds (int x, int y, int width, int height, int flags) {
int result = super.setBounds (x, y, width, height, flags);
if ((result & RESIZED) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
index a99a6c0933..75698d83ec 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
@@ -94,6 +94,9 @@ public abstract class Widget {
/* DragDetect */
static final int DRAG_DETECT = 1<<15;
+ /* Notify of the opportunity to skin this widget */
+ static final int SKIN_NEEDED = 1<<21;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -141,6 +144,7 @@ public Widget (Widget parent, int style) {
checkParent (parent);
this.style = style;
display = parent.display;
+ reskinWidget ();
}
void _addListener (int eventType, Listener listener) {
@@ -1000,6 +1004,27 @@ protected void removeListener (int eventType, SWTEventListener listener) {
}
/**
+ *
+ * @param flags
+ * @since 3.6
+ */
+public void reskin (int flags) {
+ checkWidget ();
+ reskinWidget ();
+ if ((flags & SWT.ALL) != 0) reskinChildren (flags);
+}
+
+void reskinChildren (int flags) {
+}
+
+void reskinWidget() {
+ if ((state & SKIN_NEEDED) != SKIN_NEEDED) {
+ this.state |= SKIN_NEEDED;
+ display.addSkinnableWidget(this);
+ }
+}
+
+/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is disposed.
*
@@ -1321,6 +1346,7 @@ public void setData (String key, Object value) {
OS.GCHandle_Free(uri);
OS.GCHandle_Free(ptr);
}
+ if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
boolean sendFocusEvent (int type) {