diff options
author | Silenio Quarti <silenio> | 2006-04-26 15:05:25 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2006-04-26 15:05:25 +0000 |
commit | a07aea37cba188968ae92680ce1fd50871a38b9c (patch) | |
tree | 99544ef89009b100b3796f475c2fe2447781e50a /bundles/org.eclipse.swt/Eclipse SWT Theme | |
parent | 6d5ff3f157e8cc8fa7af4fe46b2cb09ee8e2b36b (diff) | |
download | eclipse.platform.swt-a07aea37cba188968ae92680ce1fd50871a38b9c.tar.gz eclipse.platform.swt-a07aea37cba188968ae92680ce1fd50871a38b9c.tar.xz eclipse.platform.swt-a07aea37cba188968ae92680ce1fd50871a38b9c.zip |
37706 - Support native theme drawing API in SWT (internal)
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Theme')
14 files changed, 328 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ButtonDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ButtonDrawData.java new file mode 100644 index 0000000000..6d60094933 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ButtonDrawData.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.internal.theme; + +public class ButtonDrawData extends DrawData { + +public ButtonDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ComboDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ComboDrawData.java new file mode 100644 index 0000000000..3b00dbf2a7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ComboDrawData.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.internal.theme; + +public class ComboDrawData extends DrawData { + +public ComboDrawData() { + state = new int[2]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/DrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/DrawData.java new file mode 100644 index 0000000000..981084895c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/DrawData.java @@ -0,0 +1,86 @@ +package org.eclipse.swt.internal.theme; + +import org.eclipse.swt.graphics.*; + +public class DrawData { + public int style; + public int[] state; + public Rectangle clientArea; + + /** Part states */ + public static final int SELECTED = 1 << 1; + public static final int FOCUSED = 1 << 2; + public static final int PRESSED = 1 << 3; + public static final int ACTIVE = 1 << 4; + public static final int DISABLED = 1 << 5; + public static final int HOT = 1 << 6; + public static final int DEFAULTED = 1 << 7; + public static final int GRAYED = 1 << 8; + + /** Text and Image drawing flags */ + public static final int DRAW_LEFT = 1 << 4; + public static final int DRAW_TOP = 1 << 5; + public static final int DRAW_RIGHT = 1 << 6; + public static final int DRAW_BOTTOM = 1 << 7; + public static final int DRAW_HCENTER = 1 << 8; + public static final int DRAW_VCENTER = 1 << 9; + + /** Widget parts */ + public static final int WIDGET_NOWHERE = -1; + public static final int WIDGET_WHOLE = 0; + + /** Scrollbar parts */ + public static final int SCROLLBAR_UP_ARROW = 1; + public static final int SCROLLBAR_DOWN_ARROW = 2; + public static final int SCROLLBAR_LEFT_ARROW = SCROLLBAR_UP_ARROW; + public static final int SCROLLBAR_RIGHT_ARROW = SCROLLBAR_DOWN_ARROW; + public static final int SCROLLBAR_UP_TRACK = 3; + public static final int SCROLLBAR_DOWN_TRACK = 4; + public static final int SCROLLBAR_LEFT_TRACK = SCROLLBAR_UP_TRACK; + public static final int SCROLLBAR_RIGHT_TRACK = SCROLLBAR_DOWN_TRACK; + public static final int SCROLLBAR_THUMB = 5; + + /** Scale parts */ + public static final int SCALE_UP_TRACK = 1; + public static final int SCALE_LEFT_TRACK = SCALE_UP_TRACK; + public static final int SCALE_DOWN_TRACK = 2; + public static final int SCALE_RIGHT_TRACK = SCALE_DOWN_TRACK; + public static final int SCALE_THUMB = 3; + + /** ToolItem parts */ + public static final int TOOLITEM_ARROW = 1; + + /** Combo parts */ + public static final int COMBO_ARROW = 1; + + +public DrawData() { + state = new int[1]; +} + +Rectangle computeTrim(Theme theme, GC gc) { + return new Rectangle(clientArea.x, clientArea.y, clientArea.width, clientArea.height); +} + +void draw(Theme theme, GC gc, Rectangle bounds) { +} + +void drawImage(Theme theme, Image image, GC gc, Rectangle bounds) { +} + +void drawText(Theme theme, String text, int flags, GC gc, Rectangle bounds) { +} + +Rectangle getBounds(int part, Rectangle bounds) { + return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); +} + +int hit(Theme theme, Point position, Rectangle bounds) { + return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE; +} + +Rectangle measureText(Theme theme, String text, int flags, GC gc, Rectangle bounds) { + return new Rectangle(0, 0, 0, 0); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ExpanderDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ExpanderDrawData.java new file mode 100644 index 0000000000..e9ab8fc8ed --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ExpanderDrawData.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.internal.theme; + +public class ExpanderDrawData extends DrawData { + +public ExpanderDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/GroupDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/GroupDrawData.java new file mode 100644 index 0000000000..8524447a78 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/GroupDrawData.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.theme; + +import org.eclipse.swt.graphics.*; + +public class GroupDrawData extends DrawData { + public int headerWidth; + public int headerHeight; + public Rectangle headerArea; + +public GroupDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ProgressBarDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ProgressBarDrawData.java new file mode 100644 index 0000000000..3b67f7a016 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ProgressBarDrawData.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.internal.theme; + +public class ProgressBarDrawData extends RangeDrawData { + +public ProgressBarDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/RangeDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/RangeDrawData.java new file mode 100644 index 0000000000..991b229a8a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/RangeDrawData.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.theme; + +import org.eclipse.swt.graphics.*; + +public class RangeDrawData extends DrawData { + public int selection; + public int minimum; + public int maximum; + +int getSelection(Point position, Rectangle bounds) { + return 0; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScaleDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScaleDrawData.java new file mode 100644 index 0000000000..5b5ca51a3c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScaleDrawData.java @@ -0,0 +1,11 @@ +package org.eclipse.swt.internal.theme; + +public class ScaleDrawData extends RangeDrawData { + public int increment; + public int pageIncrement; + +public ScaleDrawData() { + state = new int[4]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScrollBarDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScrollBarDrawData.java new file mode 100644 index 0000000000..3cff816810 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ScrollBarDrawData.java @@ -0,0 +1,12 @@ +package org.eclipse.swt.internal.theme; + +public class ScrollBarDrawData extends RangeDrawData { + public int thumb; + public int increment; + public int pageIncrement; + +public ScrollBarDrawData() { + state = new int[6]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabFolderDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabFolderDrawData.java new file mode 100644 index 0000000000..f45b7b28cd --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabFolderDrawData.java @@ -0,0 +1,21 @@ +package org.eclipse.swt.internal.theme; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +public class TabFolderDrawData extends DrawData { + public int tabsWidth; + public int tabsHeight; + public Rectangle tabsArea; + public int selectedX; + public int selectedWidth; + public int spacing; + +public TabFolderDrawData() { + state = new int[1]; + if (SWT.getPlatform().equals("gtk")) { + spacing = -2; + } +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabItemDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabItemDrawData.java new file mode 100644 index 0000000000..94feb285d7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/TabItemDrawData.java @@ -0,0 +1,13 @@ +package org.eclipse.swt.internal.theme; + + +public class TabItemDrawData extends DrawData { + + public TabFolderDrawData parent; + public int position; + +public TabItemDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/Theme.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/Theme.java new file mode 100644 index 0000000000..628f6deb4c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/Theme.java @@ -0,0 +1,101 @@ +package org.eclipse.swt.internal.theme; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +public class Theme { + Device device; + +public Theme(Device device) { + this.device = device; +} + +void checkTheme() { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); +} + +public Rectangle computeTrim(GC gc, DrawData data) { + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + return data.computeTrim(this, gc); +} + +public void dispose () { + device = null; +} + +public void drawBackground(GC gc, Rectangle bounds, DrawData data) { + checkTheme(); + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + data.draw(this, gc, bounds); +} + +public void drawFocus(GC gc, Rectangle bounds, DrawData data) { + checkTheme(); + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height); +} + +public void drawImage(GC gc, Rectangle bounds, DrawData data, Image image, int flags) { + checkTheme(); + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + data.drawImage(this, image, gc, bounds); +} + +public void drawText(GC gc, Rectangle bounds, DrawData data, String text, int flags) { + checkTheme(); + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + data.drawText(this, text, flags, gc, bounds); +} + +public Rectangle getBounds(int part, Rectangle bounds, DrawData data) { + checkTheme(); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return data.getBounds(part, bounds); +} + +public int getSelection(Point offset, Rectangle bounds, RangeDrawData data) { + checkTheme(); + if (offset == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return data.getSelection(offset, bounds); +} + +public int hitBackground(Point position, Rectangle bounds, DrawData data) { + checkTheme(); + if (position == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return data.hit(this, position, bounds); +} + +public boolean isDisposed() { + return device == null; +} + +public Rectangle measureText(GC gc, Rectangle bounds, DrawData data, String text, int flags) { + checkTheme(); + if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + return data.measureText(this, text, flags, gc, bounds); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolBarDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolBarDrawData.java new file mode 100644 index 0000000000..e26b049397 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolBarDrawData.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.internal.theme; + +public class ToolBarDrawData extends DrawData { + +public ToolBarDrawData() { + state = new int[1]; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolItemDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolItemDrawData.java new file mode 100644 index 0000000000..9c94ffb060 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/emulated/org/eclipse/swt/internal/theme/ToolItemDrawData.java @@ -0,0 +1,11 @@ +package org.eclipse.swt.internal.theme; + +public class ToolItemDrawData extends DrawData { + + public ToolBarDrawData parent; + +public ToolItemDrawData() { + state = new int[2]; +} + +} |