# HG changeset patch # User Jacob Carlborg # Date 1232104748 -3600 # Node ID 540fa4e9974a428ba1555579ecf99f491499948b # Parent 63a09873578e24a8c5e5f2cdddc3736eed063f53 Ported dwt.internal.theme diff -r 63a09873578e -r 540fa4e9974a dwt/browser/MozillaDelegate.d --- a/dwt/browser/MozillaDelegate.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/browser/MozillaDelegate.d Fri Jan 16 12:19:08 2009 +0100 @@ -13,135 +13,130 @@ *******************************************************************************/ module dwt.browser.MozillaDelegate; +import dwt.dwthelper.utils; + import dwt.DWT; -import dwt.browser.Browser; -import dwt.dwthelper.string; -import dwt.dwthelper.utils; import dwt.widgets.Display; import dwt.widgets.Event; import dwt.widgets.Listener; +import dwt.browser.Browser; +import objc = dwt.internal.objc.runtime; + class MozillaDelegate { Browser browser; Listener listener; - bool hasFocus; + boolean hasFocus; + +this (Browser browser) { + super (); + this.browser = browser; +} - this (Browser browser) { - super(); - this.browser = browser; - } - -static Browser findBrowser (int /*long*/ handle) { - Display display = Display.getCurrent(); - return cast(Browser) display.findWidget(handle); - } +static Browser findBrowser (objc.id handle) { + Display display = Display.getCurrent (); + return cast(Browser)display.findWidget (handle); +} - static char[] mbcsToWcs (String codePage, byte[] buffer) { - // int encoding = OS.CFStringGetSystemEncoding (); - // int cfString = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, buffer, buffer.length, encoding, false); - // char[] chars = null; - // if (cfString !is 0) { - // int length = OS.CFStringGetLength (cfString); - // chars = new char [length]; - // if (length !is 0) { - // CFRange range = new CFRange (); - // range.length = length; - // OS.CFStringGetCharacters (cfString, range, chars); - // } - // OS.CFRelease (cfString); - // } - // return chars; +static char[] mbcsToWcs (String codePage, byte [] buffer) { +// int encoding = OS.CFStringGetSystemEncoding (); +// int cfstring = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, buffer, buffer.length, encoding, false); +// char[] chars = null; +// if (cfstring != 0) { +// int length = OS.CFStringGetLength (cfstring); +// chars = new char [length]; +// if (length != 0) { +// CFRange range = new CFRange (); +// range.length = length; +// OS.CFStringGetCharacters (cfstring, range, chars); +// } +// OS.CFRelease (cfstring); +// } +// return chars; // TODO implement mbcsToWcs - //return new String(buffer).toCharArray(); commented by Jacob Carlborg - return cast(char[]) buffer.dup; // FIXME - } + return new String(buffer).toCharArray(); +} - static byte[] wcsToMbcs (String codePage, String str, bool terminate) { - // char[] chars = new char [String.length()]; - // String.getChars (0, chars.length, chars, 0); - // int cfString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length); - // byte[] buffer = null; - // if (cfString !is 0) { - // CFRange range = new CFRange (); - // range.length = chars.length; - // int encoding = OS.CFStringGetSystemEncoding (); - // int[] size = new int[1]; - // int numChars = OS.CFStringGetBytes (cfString, range, encoding, cast(byte)'?', true, null, 0, size); - // buffer = new byte [size[0] + (terminate ? 1 : 0)]; - // if (numChars !is 0) { - // numChars = OS.CFStringGetBytes (cfString, range, encoding, cast(byte)'?', true, buffer, size[0], size); - // } - // OS.CFRelease (cfString); - // } - // return buffer; +static byte[] wcsToMbcs (String codePage, String string, boolean terminate) { +// char[] chars = new char [string.length()]; +// string.getChars (0, chars.length, chars, 0); +// int cfstring = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length); +// byte[] buffer = null; +// if (cfstring != 0) { +// CFRange range = new CFRange (); +// range.length = chars.length; +// int encoding = OS.CFStringGetSystemEncoding (); +// int[] size = new int[1]; +// int numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte)'?', true, null, 0, size); +// buffer = new byte [size[0] + (terminate ? 1 : 0)]; +// if (numChars != 0) { +// numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte)'?', true, buffer, size[0], size); +// } +// OS.CFRelease (cfstring); +// } +// return buffer; // TODO implement wcsToMbcs - if (terminate) - str ~= "\0"; - - //return str.getBytes(); commented by Jacob Carlborg - return cast(byte[]) str.dup; // FIXME - } + if (terminate) string += "\0"; + return string.getBytes(); +} int /*long*/ getHandle () { - return browser.view.id; - } - - String getLibraryName () { - return "libxpcom.dylib"; //$NON-NLS-1$ - } - - String getDWTInitLibraryName () { - return "swt-xulrunner"; //$NON-NLS-1$ - } + return browser.view.id; +} - void handleFocus () { - if (hasFocus) - return; - hasFocus = true; - (cast(Mozilla) browser.webBrowser).Activate(); - browser.setFocus(); - listener = new class Listener { - public void handleEvent (Event event) { - if (event.widget == browser) - return; +String getLibraryName () { + return "libxpcom.dylib"; //$NON-NLS-1$ +} + +String getSWTInitLibraryName () { + return "swt-xulrunner"; //$NON-NLS-1$ +} - (cast(Mozilla) browser.webBrowser).Deactivate(); - hasFocus = false; - browser.getDisplay().removeFilter(DWT.FocusIn, this); - browser.getShell().removeListener(DWT.Deactivate, this); - listener = null; - } - - }; - browser.getDisplay().addFilter(DWT.FocusIn, listener); - browser.getShell().addListener(DWT.Deactivate, listener); - } +void handleFocus () { + if (hasFocus) return; + hasFocus = true; + ((Mozilla)browser.webBrowser).Activate (); + browser.setFocus (); + listener = new Listener () { + public void handleEvent (Event event) { + if (event.widget == browser) return; + ((Mozilla)browser.webBrowser).Deactivate (); + hasFocus = false; + browser.getDisplay ().removeFilter (SWT.FocusIn, this); + browser.getShell ().removeListener (SWT.Deactivate, this); + listener = null; + } + + }; + browser.getDisplay ().addFilter (SWT.FocusIn, listener); + browser.getShell ().addListener (SWT.Deactivate, listener); +} - void handleMouseDown () { - } +void handleMouseDown () { +} - bool hookEnterExit () { - return true; - } +boolean hookEnterExit () { + return true; +} - void init_ () { - } +void init () { +} - bool needsSpinup () { - return false; - } +boolean needsSpinup () { + return false; +} void onDispose (int /*long*/ embedHandle) { - if (listener !is null) { - browser.getDisplay().removeFilter(DWT.FocusIn, listener); - browser.getShell().removeListener(DWT.Deactivate, listener); - listener = null; - } - browser = null; + if (listener != null) { + browser.getDisplay ().removeFilter (SWT.FocusIn, listener); + browser.getShell ().removeListener (SWT.Deactivate, listener); + listener = null; } + browser = null; +} void setSize (int /*long*/ embedHandle, int width, int height) { - // TODO - } + // TODO +} } diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ButtonDrawData.d --- a/dwt/internal/theme/ButtonDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ButtonDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ButtonDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; public class ButtonDrawData : DrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ComboDrawData.d --- a/dwt/internal/theme/ComboDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ComboDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ComboDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; public class ComboDrawData : DrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/DrawData.d --- a/dwt/internal/theme/DrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/DrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,10 +7,20 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.DrawData; + +import dwt.dwthelper.utils; -import dwt.graphics.*; +import dwt.graphics.GC; +import dwt.graphics.Image; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; + +import dwt.internal.theme.Theme; public class DrawData { public int style; @@ -18,50 +28,50 @@ 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; - + public static const int SELECTED = 1 << 1; + public static const int FOCUSED = 1 << 2; + public static const int PRESSED = 1 << 3; + public static const int ACTIVE = 1 << 4; + public static const int DISABLED = 1 << 5; + public static const int HOT = 1 << 6; + public static const int DEFAULTED = 1 << 7; + public static const 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; + public static const int DRAW_LEFT = 1 << 4; + public static const int DRAW_TOP = 1 << 5; + public static const int DRAW_RIGHT = 1 << 6; + public static const int DRAW_BOTTOM = 1 << 7; + public static const int DRAW_HCENTER = 1 << 8; + public static const int DRAW_VCENTER = 1 << 9; /** Widget parts */ - public static final int WIDGET_NOWHERE = -1; - public static final int WIDGET_WHOLE = 0; + public static const int WIDGET_NOWHERE = -1; + public static const 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; - + public static const int SCROLLBAR_UP_ARROW = 1; + public static const int SCROLLBAR_DOWN_ARROW = 2; + public static const int SCROLLBAR_LEFT_ARROW = SCROLLBAR_UP_ARROW; + public static const int SCROLLBAR_RIGHT_ARROW = SCROLLBAR_DOWN_ARROW; + public static const int SCROLLBAR_UP_TRACK = 3; + public static const int SCROLLBAR_DOWN_TRACK = 4; + public static const int SCROLLBAR_LEFT_TRACK = SCROLLBAR_UP_TRACK; + public static const int SCROLLBAR_RIGHT_TRACK = SCROLLBAR_DOWN_TRACK; + public static const 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; - + public static const int SCALE_UP_TRACK = 1; + public static const int SCALE_LEFT_TRACK = SCALE_UP_TRACK; + public static const int SCALE_DOWN_TRACK = 2; + public static const int SCALE_RIGHT_TRACK = SCALE_DOWN_TRACK; + public static const int SCALE_THUMB = 3; + /** ToolItem parts */ - public static final int TOOLITEM_ARROW = 1; - + public static const int TOOLITEM_ARROW = 1; + /** Combo parts */ - public static final int COMBO_ARROW = 1; + public static const int COMBO_ARROW = 1; public this() { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ExpanderDrawData.d --- a/dwt/internal/theme/ExpanderDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ExpanderDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ExpanderDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; public class ExpanderDrawData : DrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/GroupDrawData.d --- a/dwt/internal/theme/GroupDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/GroupDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,10 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.GroupDrawData; + +import dwt.dwthelper.utils; -import dwt.graphics.*; +import dwt.graphics.Rectangle; + +import dwt.internal.theme.DrawData; public class GroupDrawData : DrawData { public int headerWidth; diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ProgressBarDrawData.d --- a/dwt/internal/theme/ProgressBarDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ProgressBarDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ProgressBarDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.RangeDrawData; public class ProgressBarDrawData : RangeDrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/RangeDrawData.d --- a/dwt/internal/theme/RangeDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/RangeDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,10 +7,18 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.RangeDrawData; + +import dwt.dwthelper.utils; -import dwt.graphics.*; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; + +import dwt.internal.theme.DrawData; public class RangeDrawData : DrawData { public int selection; diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ScaleDrawData.d --- a/dwt/internal/theme/ScaleDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ScaleDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ScaleDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.RangeDrawData; public class ScaleDrawData : RangeDrawData { public int increment; diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ScrollBarDrawData.d --- a/dwt/internal/theme/ScrollBarDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ScrollBarDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ScrollBarDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.RangeDrawData; public class ScrollBarDrawData : RangeDrawData { public int thumb; diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/TabFolderDrawData.d --- a/dwt/internal/theme/TabFolderDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/TabFolderDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,11 +7,18 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.TabFolderDrawData; -import dwt.*; -import dwt.graphics.*; +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.graphics.Rectangle; + +import dwt.internal.theme.DrawData; public class TabFolderDrawData : DrawData { public int tabsWidth; @@ -23,7 +30,7 @@ public this() { state = new int[1]; - if (DWT.getPlatform().opEquals("gtk")) { + if (DWT.getPlatform().equals("gtk")) { spacing = -2; } } diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/TabItemDrawData.d --- a/dwt/internal/theme/TabItemDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/TabItemDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,9 +7,16 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.TabItemDrawData; +import minid.compiler; +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; +import dwt.internal.theme.TabFolderDrawData; public class TabItemDrawData : DrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/Theme.d --- a/dwt/internal/theme/Theme.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/Theme.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,11 +7,23 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.Theme; + +import dwt.dwthelper.utils; -import dwt.*; -import dwt.graphics.*; +import dwt.DWT; +import dwt.graphics.Device; +import dwt.graphics.GC; +import dwt.graphics.Image; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; + +import dwt.internal.theme.DrawData; +import dwt.internal.theme.RangeDrawData; public class Theme { Device device; diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ToolBarDrawData.d --- a/dwt/internal/theme/ToolBarDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ToolBarDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ToolBarDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; public class ToolBarDrawData : DrawData { diff -r 63a09873578e -r 540fa4e9974a dwt/internal/theme/ToolItemDrawData.d --- a/dwt/internal/theme/ToolItemDrawData.d Thu Jan 15 23:08:54 2009 +0100 +++ b/dwt/internal/theme/ToolItemDrawData.d Fri Jan 16 12:19:08 2009 +0100 @@ -7,8 +7,15 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.internal.theme; +module dwt.internal.theme.ToolItemDrawData; + +import dwt.dwthelper.utils; +import dwt.internal.theme.DrawData; +import dwt.internal.theme.ToolBarDrawData; public class ToolItemDrawData : DrawData {