# HG changeset patch
# User Frank Benoit
+ * The IME composition event is sent to allow
+ * custom text editors to implement in-line
+ * editing of international text.
+ *
+ *
+ * When neither H_SCROLL or V_SCROLL are specified, controls + * are free to create the default scroll bars for the control. + * Using NO_SCROLL overrides the default and forces the control + * to have no scroll bars. + * + * Used By:
Tree
Table
Used By:
+ * Normally, when the user clicks on a control, focus is assigned to that
+ * control, providing the control has no children. Some controls, such as
+ * tool bars and sashes, don't normally take focus when the mouse is clicked
+ * or accept focus when assigned from within the program. This style allows
+ * Composites to implement "no focus" mouse behavior.
+ *
*
Note that this is a HINT.
+ *
Used By:
Composite
Used By:
Composite
Used By:
Composite
+ * By default, before a widget paints, the client area is filled with the current background. + * When this style is specified, the background is not filled and widgets that are obscured + * will draw through. + *
Used By:
Composite
Used By:
Button
with ARROW
styleTracker
Table
Tree
Used By:
TextStyle
Used By:
TextStyle
Used By:
TextStyle
Used By:
TextStyle
Used By:
TextStyle
Used By:
TextStyle
Used By:
TextStyle
Used By:
Used By:
Button
with ARROW
styleTracker
Table
Tree
Used By:
ProgressBar
Used By:
ProgressBar
ProgressBar
+ * to indicate a normal state.
+ * Used By:
ProgressBar
true
if the receiver's list is visible,
+ * and false
otherwise.
+ * + * If one of the receiver's ancestors is not visible or some + * other condition makes the receiver not visible, this method + * may still indicate that it is considered visible even though + * it may not actually be showing. + *
+ * + * @return the receiver's list's visibility state + * + * @exception DWTExceptiontrue
,
+ * and marks it invisible otherwise.
+ * + * If one of the receiver's ancestors is not visible or some + * other condition makes the receiver not visible, marking + * it visible may not actually cause it to be displayed. + *
+ * + * @param visible the new visibility state + * + * @exception DWTExceptiontrue
to indicate that the receiver's close button should be shown.
+ * Otherwise return false
. The initial value is defined by the style (DWT.CLOSE)
+ * that was used to create the receiver.
+ *
+ * @return true
if the close button should be shown
+ *
+ * @exception DWTException true
to indicate that the receiver's close button should be shown.
+ * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has
+ * no effect.
+ *
+ * @param close the new state of the close button
+ *
+ * @exception DWTException true
if the receiver automatically scrolls to a focused child control
+ * to make it visible. Otherwise, returns false
.
+ *
+ * @exception DWTException false
, show a focused control is off.
+ * By default, show a focused control is off.
+ *
+ * @param show true
to show a focused control.
+ *
+ * @exception DWTException + * + * @param lineIndex index of the line to return. + * @return the line text without delimiters + * + * @exception DWTException
DWT.LEFT
,
* DWT.CENTER
or DWT.RIGHT
. The alignment applies for all lines.
+ *
+ * Note that if DWT.MULTI
is set, then DWT.WRAP
must also be set
+ * in order to stabilize the right edge before setting alignment.
+ *
DWT.LEFT
,
* DWT.CENTER
or DWT.RIGHT
.
- * + *
+ * Note that if DWT.MULTI
is set, then DWT.WRAP
must also be set
+ * in order to stabilize the right edge before setting alignment.
+ *
@@ -7489,7 +7604,7 @@
if ((orientation & DWT.LEFT_TO_RIGHT) !is 0 && !isMirrored()) {
return;
}
- if (!BidiUtil.setOrientation(handle, orientation)) {
+ if (!BidiUtil.setOrientation(this, orientation)) {
return;
}
isMirrored_ = (orientation & DWT.RIGHT_TO_LEFT) !is 0;
@@ -7705,6 +7820,7 @@
selectionAnchor = selection.x = start;
caretOffset = selection.y = end;
}
+ caretAlignment = PREVIOUS_OFFSET_TRAILING;
internalRedrawRange(selection.x, selection.y - selection.x);
}
}
@@ -8004,12 +8120,8 @@
checkWidget();
tabLength = tabs;
renderer.setFont(null, tabs);
- if (caretOffset > 0) {
- caretOffset = 0;
- showCaret();
- clearSelection(false);
- }
resetCache(0, content.getLineCount());
+ setCaretLocation();
super.redraw();
}
/**
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/custom/StyledTextDropTargetEffect.d
--- a/dwt/custom/StyledTextDropTargetEffect.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/custom/StyledTextDropTargetEffect.d Sat May 17 17:34:28 2008 +0200
@@ -18,6 +18,8 @@
import dwt.dnd.DropTargetAdapter;
import dwt.dnd.DropTargetEffect;
import dwt.dnd.DropTargetEvent;
+import dwt.graphics.FontMetrics;
+import dwt.graphics.GC;
import dwt.graphics.Point;
import dwt.graphics.Rectangle;
import dwt.widgets.Event;
@@ -31,7 +33,7 @@
/**
* This adapter class provides a default drag under effect (eg. select and scroll)
- * when a drag occurs over a Table
.
+ * when a drag occurs over a StyledText
.
*
*
Classes that wish to provide their own drag under effect for a StyledText
* can extend this class, override the StyledTextDropTargetEffect.dragOver
@@ -172,37 +174,27 @@
pt.y >= scrollY && pt.y <= (scrollY + SCROLL_TOLERANCE))) {
if (System.currentTimeMillis() >= scrollBeginTime) {
Rectangle area = text.getClientArea();
- Rectangle bounds = text.getTextBounds(0, 0);
- int charWidth = bounds.width;
+ GC gc = new GC(text);
+ FontMetrics fm = gc.getFontMetrics();
+ gc.dispose();
+ int charWidth = fm.getAverageCharWidth();
int scrollAmount = 10*charWidth;
if (pt.x < area.x + 3*charWidth) {
int leftPixel = text.getHorizontalPixel();
text.setHorizontalPixel(leftPixel - scrollAmount);
- if (text.getHorizontalPixel() !is leftPixel) {
- text.redraw();
- }
}
if (pt.x > area.width - 3*charWidth) {
int leftPixel = text.getHorizontalPixel();
text.setHorizontalPixel(leftPixel + scrollAmount);
- if (text.getHorizontalPixel() !is leftPixel) {
- text.redraw();
- }
}
- int lineHeight = bounds.height;
+ int lineHeight = text.getLineHeight();
if (pt.y < area.y + lineHeight) {
int topPixel = text.getTopPixel();
text.setTopPixel(topPixel - lineHeight);
- if (text.getTopPixel() !is topPixel) {
- text.redraw();
- }
}
if (pt.y > area.height - lineHeight) {
int topPixel = text.getTopPixel();
text.setTopPixel(topPixel + lineHeight);
- if (text.getTopPixel() !is topPixel) {
- text.redraw();
- }
}
scrollBeginTime = 0;
scrollX = scrollY = -1;
@@ -216,53 +208,10 @@
}
if ((effect & DND.FEEDBACK_SELECT) !is 0) {
- StyledTextContent content = text.getContent();
- int newOffset = -1;
- try {
- newOffset = text.getOffsetAtLocation(pt);
- } catch ( tango.core.Exception.IllegalArgumentException ex1) {
- int maxOffset = content.getCharCount();
- Point maxLocation = text.getLocationAtOffset(maxOffset);
- if (pt.y >= maxLocation.y) {
- try {
- newOffset = text.getOffsetAtLocation(new Point(pt.x, maxLocation.y));
- } catch (tango.core.Exception.IllegalArgumentException ex2) {
- newOffset = maxOffset;
- }
- } else {
- try {
- int startOffset = text.getOffsetAtLocation(new Point(0, pt.y));
- int endOffset = maxOffset;
- int line = content.getLineAtOffset(startOffset);
- int lineCount = content.getLineCount();
- if (line + 1 < lineCount) {
- endOffset = content.getOffsetAtLine(line + 1) - 1;
- }
- int lineHeight = text.getLineHeight(startOffset);
- for (int i = endOffset; i >= startOffset; i--) {
- Point p = text.getLocationAtOffset(i);
- if (p.x < pt.x && p.y < pt.y && p.y + lineHeight > pt.y) {
- newOffset = i;
- break;
- }
- }
- } catch (tango.core.Exception.IllegalArgumentException ex2) {
- newOffset = -1;
- }
- }
- }
- if (newOffset !is -1 && newOffset !is currentOffset) {
- // check if offset is line delimiter
- // see StyledText.isLineDelimiter()
- int line = content.getLineAtOffset(newOffset);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = newOffset - lineOffset;
- // offsetInLine will be greater than line length if the line
- // delimiter is longer than one character and the offset is set
- // in between parts of the line delimiter.
- if (offsetInLine > content.getLine(line).length) {
- newOffset = Math.max(0, newOffset - 1);
- }
+ int[] trailing = new int [1];
+ int newOffset = text.getOffsetAtPoint(pt.x, pt.y, trailing, false);
+ newOffset += trailing [0];
+ if (newOffset !is currentOffset) {
refreshCaret(text, currentOffset, newOffset);
currentOffset = newOffset;
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/custom/StyledTextPrintOptions.d
--- a/dwt/custom/StyledTextPrintOptions.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/custom/StyledTextPrintOptions.d Sat May 17 17:34:28 2008 +0200
@@ -95,5 +95,11 @@
*/
public bool printLineNumbers = false;
+ /**
+ * Labels used for printing line numbers.
+ *
+ * @since 3.4
+ */
+ public String[] lineLabels = null;
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/custom/StyledTextRenderer.d
--- a/dwt/custom/StyledTextRenderer.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/custom/StyledTextRenderer.d Sat May 17 17:34:28 2008 +0200
@@ -27,6 +27,7 @@
import dwt.graphics.TextLayout;
import dwt.graphics.TextStyle;
import dwt.widgets.Display;
+import dwt.widgets.IME;
import dwt.widgets.ScrollBar;
import dwt.custom.StyledText;
import dwt.custom.Bullet;
@@ -391,16 +392,18 @@
int selectionStart = selection.x - lineOffset;
int selectionEnd = selection.y - lineOffset;
Rectangle client = styledText.getClientArea();
- Color lineBackground = getLineBackground(lineIndex, widgetBackground);
+ Color lineBackground = getLineBackground(lineIndex, null);
StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
if (event !is null && event.lineBackground !is null) lineBackground = event.lineBackground;
-
int height = layout.getBounds().height;
- gc.setBackground(lineBackground);
- styledText.drawBackground(gc, client.x, paintY, client.width, height);
-
+ if (lineBackground !is null) {
+ gc.setBackground(lineBackground);
+ gc.fillRectangle(client.x, paintY, client.width, height);
+ } else {
+ gc.setBackground(widgetBackground);
+ styledText.drawBackground(gc, client.x, paintY, client.width, height);
+ }
gc.setForeground(widgetForeground);
- gc.setBackground(lineBackground);
if (selectionStart is selectionEnd || (selectionEnd <= 0 && selectionStart > lineLength - 1)) {
layout.draw(gc, paintX, paintY);
} else {
@@ -663,8 +666,14 @@
}
style = newStyles[newStyles.length - 1];
if (end < style.start + style.length - 1) {
- if (!includeRanges || ranges is null) newStyles[newStyles.length - 1] = style = cast(StyleRange)style.clone();
- style.length = end - style.start + 1;
+ if (end < style.start) {
+ StyleRange[] tmp = new StyleRange[newStyles.length - 1];
+ System.arraycopy(newStyles, 0, tmp, 0, newStyles.length - 1);
+ newStyles = tmp;
+ } else {
+ if (!includeRanges || ranges is null) newStyles[newStyles.length - 1] = style = cast(StyleRange)style.clone();
+ style.length = end - style.start + 1;
+ }
}
return newStyles;
}
@@ -868,6 +877,58 @@
}
}
if (lastOffset < length) layout.setStyle(null, lastOffset, length);
+ if (styledText !is null && styledText.ime !is null) {
+ IME ime = styledText.ime;
+ int compositionOffset = ime.getCompositionOffset();
+ if (compositionOffset !is -1) {
+ int commitCount = ime.getCommitCount();
+ int compositionLength = ime.getText().length;
+ if (compositionLength !is commitCount) {
+ int compositionLine = content.getLineAtOffset(compositionOffset);
+ if (compositionLine is lineIndex) {
+ int[] imeRanges = ime.getRanges();
+ TextStyle[] imeStyles = ime.getStyles();
+ if (imeRanges.length > 0) {
+ for (int i = 0; i < imeStyles.length; i++) {
+ int start = imeRanges[i*2] - lineOffset;
+ int end = imeRanges[i*2+1] - lineOffset;
+ TextStyle imeStyle = imeStyles[i], userStyle;
+ for (int j = start; j <= end; j++) {
+ userStyle = layout.getStyle(j);
+ if (userStyle is null && j > 0) userStyle = layout.getStyle(j - 1);
+ if (userStyle is null && j + 1 < length) userStyle = layout.getStyle(j + 1);
+ if (userStyle is null) {
+ layout.setStyle(imeStyle, j, j);
+ } else {
+ TextStyle newStyle = new TextStyle(imeStyle);
+ if (newStyle.font is null) newStyle.font = userStyle.font;
+ if (newStyle.foreground is null) newStyle.foreground = userStyle.foreground;
+ if (newStyle.background is null) newStyle.background = userStyle.background;
+ layout.setStyle(newStyle, j, j);
+ }
+ }
+ }
+ } else {
+ int start = compositionOffset - lineOffset;
+ int end = start + compositionLength - 1;
+ TextStyle userStyle = layout.getStyle(start);
+ if (userStyle is null) {
+ if (start > 0) userStyle = layout.getStyle(start - 1);
+ if (userStyle is null && end + 1 < length) userStyle = layout.getStyle(end + 1);
+ if (userStyle !is null) {
+ TextStyle newStyle = new TextStyle();
+ newStyle.font = userStyle.font;
+ newStyle.foreground = userStyle.foreground;
+ newStyle.background = userStyle.background;
+ layout.setStyle(newStyle, start, end);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
if (styledText !is null && styledText.isFixedLineHeight()) {
int index = -1;
int lineCount = layout.getLineCount();
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/custom/TableCursor.d
--- a/dwt/custom/TableCursor.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/custom/TableCursor.d Sat May 17 17:34:28 2008 +0200
@@ -160,6 +160,9 @@
TableColumn column = null;
Listener tableListener, resizeListener, disposeItemListener, disposeColumnListener;
+ Color background = null;
+ Color foreground = null;
+
// By default, invert the list selection colors
static final int BACKGROUND = DWT.COLOR_LIST_SELECTION_TEXT;
static final int FOREGROUND = DWT.COLOR_LIST_SELECTION;
@@ -253,6 +256,7 @@
disposeItemListener = new class() Listener {
public void handleEvent(Event event) {
+ unhookRowColumnListeners();
row = null;
column = null;
_resize();
@@ -260,6 +264,7 @@
};
disposeColumnListener = new class() Listener {
public void handleEvent(Event event) {
+ unhookRowColumnListeners();
row = null;
column = null;
_resize();
@@ -319,16 +324,7 @@
void dispose(Event event) {
table.removeListener(DWT.FocusIn, tableListener);
table.removeListener(DWT.MouseDown, tableListener);
- if (column !is null) {
- column.removeListener(DWT.Dispose, disposeColumnListener);
- column.removeListener(DWT.Move, resizeListener);
- column.removeListener(DWT.Resize, resizeListener);
- column = null;
- }
- if (row !is null) {
- row.removeListener(DWT.Dispose, disposeItemListener);
- row = null;
- }
+ unhookRowColumnListeners();
ScrollBar hBar = table.getHorizontalBar();
if (hBar !is null) {
hBar.removeListener(DWT.Selection, resizeListener);
@@ -492,10 +488,11 @@
}
void tableFocusIn(Event event) {
- if (isDisposed())
- return;
- if (isVisible())
+ if (isDisposed()) return;
+ if (isVisible()) {
+ if (row is null && column is null) return;
setFocus();
+ }
}
void tableMouseDown(Event event) {
@@ -522,7 +519,14 @@
}
TableColumn newColumn = null;
int columnCount = table.getColumnCount();
- if (columnCount > 0) {
+ if (columnCount is 0) {
+ if ((table.getStyle() & DWT.FULL_SELECTION) is 0) {
+ Rectangle rect = item.getBounds(0);
+ rect.width += lineWidth;
+ rect.height += lineWidth;
+ if (!rect.contains(pt)) return;
+ }
+ } else {
for (int i = 0; i < columnCount; i++) {
Rectangle rect = item.getBounds(i);
rect.width += lineWidth;
@@ -533,6 +537,7 @@
}
}
if (newColumn is null) {
+ if ((table.getStyle() & DWT.FULL_SELECTION) is 0) return;
newColumn = table.getColumn(0);
}
}
@@ -638,6 +643,30 @@
return column is null ? 0 : table.indexOf(column);
}
/**
+ * Returns the background color that the receiver will use to draw.
+ *
+ * @return the receiver's background color
+ */
+public Color getBackground() {
+ checkWidget();
+ if (background is null) {
+ return getDisplay().getSystemColor(BACKGROUND);
+ }
+ return background;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ */
+public Color getForeground() {
+ checkWidget();
+ if (foreground is null) {
+ return getDisplay().getSystemColor(FOREGROUND);
+ }
+ return foreground;
+}
+/**
* Returns the row over which the TableCursor is positioned.
*
* @return the item for the current position
@@ -651,14 +680,49 @@
checkWidget();
return row;
}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is a hint and may be overridden by the platform. + * For example, on Windows the background of a Button cannot be changed. + *
+ * @param color the new color (or null) + * + * @exception IllegalArgumentException+ * Note: This operation is a hint and may be overridden by the platform. + *
+ * @param color the new color (or null) + * + * @exception IllegalArgumentExceptiongetData(String)
. When a drop target
+ * is created for a control, it is stored as a property in the control
+ * using setData(String, Object)
.
+ *
+ * @since 3.4
+ */
+ public static final String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
+
+ /**
+ * DragSource Key: The string constant for looking up the drag source
+ * for a control using getData(String)
. When a drag source
+ * is created for a control, it is stored as a property in the control
+ * using setData(String, Object)
.
+ *
+ * @since 3.4
+ */
+ public static final String DRAG_SOURCE_KEY = "DragSource"; //$NON-NLS-1$
static const String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
static const String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/DragSource.d
--- a/dwt/dnd/DragSource.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/DragSource.d Sat May 17 17:34:28 2008 +0200
@@ -142,7 +142,6 @@
int dataEffect = DND.DROP_NONE;
static const String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
- static const String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
static const int CFSTR_PERFORMEDDROPEFFECT;
static final TCHAR[] WindowClass = "#32770\0";
static this(){
@@ -180,10 +179,10 @@
public this(Control control, int style) {
super(control, checkStyle(style));
this.control = control;
- if (control.getData(DRAGSOURCEID) !is null) {
+ if (control.getData(DND.DRAG_SOURCE_KEY) !is null) {
DND.error(DND.ERROR_CANNOT_INIT_DRAG);
}
- control.setData(DRAGSOURCEID, this);
+ control.setData(DND.DRAG_SOURCE_KEY, this);
createCOMInterfaces();
this.AddRef();
@@ -251,6 +250,7 @@
* DragSourceListener
interface.
+ *
+ * @exception DWTException DropTarget
to allow data to be dropped on the specified
@@ -151,10 +151,10 @@
public this(Control control, int style) {
super (control, checkStyle(style));
this.control = control;
- if (control.getData(DROPTARGETID) !is null) {
+ if (control.getData(DND.DROP_TARGET_KEY) !is null) {
DND.error(DND.ERROR_CANNOT_INIT_DROP);
}
- control.setData(DROPTARGETID, this);
+ control.setData(DND.DROP_TARGET_KEY, this);
createCOMInterfaces();
this.AddRef();
@@ -222,6 +222,7 @@
* DropTargetListener
interface.
+ *
+ * @exception DWTException ImageTransfer
provides a platform specific mechanism
+ * for converting a Image represented as a java ImageData
to a
+ * platform specific representation of the data and vice versa.
+ * See Transfer
for additional information.
+ *
+ * An example of a java ImageData
is shown
+ * below:
+ * Image image = new Image("C:\temp\img1.gif");
+ * ImageData imgData = image.getImageData();
+ *
+ *
+ * @since 3.4
+ */
+public class ImageTransfer : ByteArrayTransfer {
+
+ private static ImageTransfer _instance;
+ private static const String CF_DIB = "CF_DIB"; //$NON-NLS-1$
+ private static const int CF_DIBID = COM.CF_DIB;
+
+static this(){
+ _instance = new ImageTransfer();
+}
+
+private this() {
+}
+
+/**
+ * Returns the singleton instance of the ImageTransfer class.
+ *
+ * @return the singleton instance of the ImageTransfer class
+ */
+public static ImageTransfer getInstance () {
+ return _instance;
+}
+
+/**
+ * This implementation of javaToNative
converts an ImageData object represented
+ * by java ImageData
to a platform specific representation.
+ * For additional information see Transfer#javaToNative
.
+ *
+ * @param object a java ImageData
containing the ImageData to be
+ * converted
+ * @param transferData an empty TransferData
object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative(Object object, TransferData transferData) {
+ if (!checkImage(object) || !isSupportedType(transferData)) {
+ DND.error(DND.ERROR_INVALID_DATA);
+ }
+ ImageData imgData = cast(ImageData)object;
+ if (imgData is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+
+ int imageSize = imgData.data.length;
+ int imageHeight = imgData.height;
+ int bytesPerLine = imgData.bytesPerLine;
+
+ BITMAPINFOHEADER bmiHeader;
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biSizeImage = imageSize;
+ bmiHeader.biWidth = imgData.width;
+ bmiHeader.biHeight = imageHeight;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = cast(short)imgData.depth;
+ bmiHeader.biCompression = OS.DIB_RGB_COLORS;
+
+ int colorSize = 0;
+ if (bmiHeader.biBitCount <= 8) {
+ colorSize += (1 << bmiHeader.biBitCount) * 4;
+ }
+ byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + colorSize];
+ OS.MoveMemory(bmi.ptr, &bmiHeader, BITMAPINFOHEADER.sizeof);
+
+ RGB[] rgbs = imgData.palette.getRGBs();
+ if (rgbs !is null && colorSize > 0) {
+ int offset = BITMAPINFOHEADER.sizeof;
+ for (int j = 0; j < rgbs.length; j++) {
+ bmi[offset] = cast(byte)rgbs[j].blue;
+ bmi[offset + 1] = cast(byte)rgbs[j].green;
+ bmi[offset + 2] = cast(byte)rgbs[j].red;
+ bmi[offset + 3] = 0;
+ offset += 4;
+ }
+ }
+ auto newPtr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, BITMAPINFOHEADER.sizeof + colorSize + imageSize);
+ OS.MoveMemory(newPtr, bmi.ptr, bmi.length);
+ auto pBitDest = newPtr + BITMAPINFOHEADER.sizeof + colorSize;
+
+ if (imageHeight <= 0) {
+ OS.MoveMemory(pBitDest, imgData.data.ptr, imageSize);
+ } else {
+ int offset = 0;
+ pBitDest += bytesPerLine * (imageHeight - 1);
+ byte[] scanline = new byte[bytesPerLine];
+ for (int i = 0; i < imageHeight; i++) {
+ System.arraycopy(imgData.data, offset, scanline, 0, bytesPerLine);
+ OS.MoveMemory(pBitDest, scanline.ptr, bytesPerLine);
+ offset += bytesPerLine;
+ pBitDest -= bytesPerLine;
+ }
+ }
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.stgmedium.unionField = newPtr;
+ transferData.stgmedium.pUnkForRelease = null;
+ transferData.result = COM.S_OK;
+}
+
+
+/**
+ * This implementation of nativeToJava
converts a platform specific
+ * representation of an image to java ImageData
.
+ * For additional information see Transfer#nativeToJava
.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java ImageData
of the image if
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+ if (!isSupportedType(transferData) || transferData.pIDataObject is null) return null;
+ IDataObject dataObject = cast(IDataObject)(transferData.pIDataObject);
+ dataObject.AddRef();
+ FORMATETC* formatetc = new FORMATETC();
+ formatetc.cfFormat = COM.CF_DIB;
+ formatetc.ptd = null;
+ formatetc.dwAspect = COM.DVASPECT_CONTENT;
+ formatetc.lindex = -1;
+ formatetc.tymed = COM.TYMED_HGLOBAL;
+ STGMEDIUM* stgmedium = new STGMEDIUM();
+ stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.result = dataObject.GetData(formatetc, stgmedium);
+
+ if (transferData.result !is COM.S_OK) return null;
+ HANDLE hMem = stgmedium.unionField;
+ dataObject.Release();
+ try {
+ auto ptr = OS.GlobalLock(hMem);
+ if (ptr is null) return null;
+ try {
+ BITMAPINFOHEADER bmiHeader;
+ OS.MoveMemory(&bmiHeader, ptr, BITMAPINFOHEADER.sizeof);
+ void* pBits;
+ auto memDib = OS.CreateDIBSection(null, cast(BITMAPINFO*)ptr, OS.DIB_RGB_COLORS, &pBits, null, 0);
+ if (memDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
+ void* bits = ptr + bmiHeader.biSize;
+ if (bmiHeader.biBitCount <= 8) {
+ bits += (1 << bmiHeader.biBitCount) * 4;
+ } else if (bmiHeader.biCompression is OS.BI_BITFIELDS) {
+ bits += 12;
+ }
+ if (bmiHeader.biHeight < 0) {
+ OS.MoveMemory(pBits, bits, bmiHeader.biSizeImage);
+ } else {
+ DIBSECTION dib;
+ OS.GetObject(memDib, DIBSECTION.sizeof, &dib);
+ int biHeight = dib.biHeight;
+ int scanline = dib.biSizeImage / biHeight;
+ auto pDestBits = pBits;
+ auto pSourceBits = bits + scanline * (biHeight - 1);
+ for (int i = 0; i < biHeight; i++) {
+ OS.MoveMemory(pDestBits, pSourceBits, scanline);
+ pDestBits += scanline;
+ pSourceBits -= scanline;
+ }
+ }
+ Image image = Image.win32_new(null, DWT.BITMAP, memDib);
+ ImageData data = image.getImageData();
+ OS.DeleteObject(memDib);
+ image.dispose();
+ return data;
+ } finally {
+ OS.GlobalUnlock(hMem);
+ }
+ } finally {
+ OS.GlobalFree(hMem);
+ }
+}
+
+protected int[] getTypeIds(){
+ return [CF_DIBID];
+}
+
+protected String[] getTypeNames(){
+ return [CF_DIB];
+}
+bool checkImage(Object object) {
+ if (object is null || !(null !is cast(ImageData)object )) return false;
+ return true;
+}
+
+protected bool validate(Object object) {
+ return checkImage(object);
+}
+}
+
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/OleEnumFORMATETC.d
--- a/dwt/dnd/OleEnumFORMATETC.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/OleEnumFORMATETC.d Sat May 17 17:34:28 2008 +0200
@@ -15,6 +15,7 @@
import dwt.internal.ole.win32.COM;
import dwt.internal.ole.win32.OBJIDL;
import dwt.internal.ole.win32.extras;
+import dwt.internal.win32.OS;
final class OleEnumFORMATETC {
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/TableDragSourceEffect.d
--- a/dwt/dnd/TableDragSourceEffect.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/TableDragSourceEffect.d Sat May 17 17:34:28 2008 +0200
@@ -14,6 +14,8 @@
import dwt.DWT;
import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.PaletteData;
import dwt.graphics.Rectangle;
import dwt.internal.win32.OS;
import dwt.widgets.Display;
@@ -87,10 +89,78 @@
Image getDragSourceImage(DragSourceEvent event) {
if (dragSourceImage !is null) dragSourceImage.dispose();
dragSourceImage = null;
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
+ SHDRAGIMAGE shdi;
+ int DI_GETDRAGIMAGE = OS.RegisterWindowMessage ( "ShellGetDragImage"w.ptr ); //$NON-NLS-1$
+ if (OS.SendMessage (control.handle, DI_GETDRAGIMAGE, 0, &shdi) !is 0) {
+ event.x += shdi.ptOffset.x;
+ event.y += shdi.ptOffset.y;
+ auto hImage = shdi.hbmpDragImage;
+ if (hImage !is null) {
+ BITMAP bm;
+ OS.GetObject (hImage, BITMAP.sizeof, &bm);
+ int srcWidth = bm.bmWidth;
+ int srcHeight = bm.bmHeight;
+
+ /* Create resources */
+ auto hdc = OS.GetDC (null);
+ auto srcHdc = OS.CreateCompatibleDC (hdc);
+ auto oldSrcBitmap = OS.SelectObject (srcHdc, hImage);
+ auto memHdc = OS.CreateCompatibleDC (hdc);
+ BITMAPINFOHEADER bmiHeader;
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = srcWidth;
+ bmiHeader.biHeight = -srcHeight;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = 32;
+ bmiHeader.biCompression = OS.BI_RGB;
+ void* pBits;
+ auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)&bmiHeader, OS.DIB_RGB_COLORS, &pBits, null, 0);
+ if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES);
+ auto oldMemBitmap = OS.SelectObject (memHdc, memDib);
+
+ BITMAP dibBM;
+ OS.GetObject (memDib, BITMAP.sizeof, &dibBM);
+ int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
+
+ /* Get the foreground pixels */
+ OS.BitBlt (memHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ //byte[] srcData = new byte [sizeInBytes];
+ //OS.MoveMemory (srcData, dibBM.bmBits, sizeInBytes);
+ byte[] srcData = (cast(byte*) dibBM.bmBits)[ 0 .. BITMAPINFOHEADER.sizeof ];
+
+ byte[] alphaData = new byte[srcWidth * srcHeight];
+ int spinc = dibBM.bmWidthBytes - srcWidth * 4;
+ int ap = 0, sp = 3;
+ for (int y = 0; y < srcHeight; ++y) {
+ for (int x = 0; x < srcWidth; ++x) {
+ alphaData [ap++] = srcData [sp];
+ sp += 4;
+ }
+ sp += spinc;
+ }
+ PaletteData palette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ ImageData data = new ImageData(srcWidth, srcHeight, bm.bmBitsPixel, palette, bm.bmWidthBytes, srcData);
+ data.alphaData = alphaData;
+ data.transparentPixel = shdi.crColorKey;
+ dragSourceImage = new Image(control.getDisplay(), data);
+ OS.SelectObject (memHdc, oldMemBitmap);
+ OS.DeleteDC (memHdc);
+ OS.DeleteObject (memDib);
+ OS.SelectObject (srcHdc, oldSrcBitmap);
+ OS.DeleteDC (srcHdc);
+ OS.ReleaseDC (null, hdc);
+ return dragSourceImage;
+ }
+ }
+ return null;
+ }
Table table = cast(Table) control;
+ //TEMPORARY CODE
+ if (table.isListening (DWT.EraseItem) || table.isListening (DWT.PaintItem)) return null;
TableItem[] selection = table.getSelection();
if (selection.length is 0) return null;
- int tableImageList = OS.SendMessage (table.handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ int /*long*/ tableImageList = OS.SendMessage (table.handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
if (tableImageList !is 0) {
int count = Math.min(selection.length, 10);
Rectangle bounds = selection[0].getBounds(0);
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/TreeDragSourceEffect.d
--- a/dwt/dnd/TreeDragSourceEffect.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/TreeDragSourceEffect.d Sat May 17 17:34:28 2008 +0200
@@ -14,6 +14,8 @@
import dwt.DWT;
import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.PaletteData;
import dwt.graphics.Rectangle;
import dwt.internal.win32.OS;
import dwt.widgets.Display;
@@ -86,10 +88,66 @@
Image getDragSourceImage(DragSourceEvent event) {
if (dragSourceImage !is null) dragSourceImage.dispose();
dragSourceImage = null;
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
+ SHDRAGIMAGE shdi;
+ int DI_GETDRAGIMAGE = OS.RegisterWindowMessage ("ShellGetDragImage"w.ptr); //$NON-NLS-1$
+ if (OS.SendMessage (control.handle, DI_GETDRAGIMAGE, 0, &shdi) !is 0) {
+ event.x += shdi.ptOffset.x;
+ event.y += shdi.ptOffset.y;
+ auto hImage = shdi.hbmpDragImage;
+ if (hImage !is null) {
+ BITMAP bm;
+ OS.GetObject (hImage, BITMAP.sizeof, &bm);
+ int srcWidth = bm.bmWidth;
+ int srcHeight = bm.bmHeight;
+
+ /* Create resources */
+ auto hdc = OS.GetDC (null);
+ auto srcHdc = OS.CreateCompatibleDC (hdc);
+ auto oldSrcBitmap = OS.SelectObject (srcHdc, hImage);
+ auto memHdc = OS.CreateCompatibleDC (hdc);
+ BITMAPINFOHEADER bmiHeader;
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = srcWidth;
+ bmiHeader.biHeight = -srcHeight;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = 32;
+ bmiHeader.biCompression = OS.BI_RGB;
+ void* pBits;
+ auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)&bmiHeader, OS.DIB_RGB_COLORS, &pBits, null, 0);
+ if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES);
+ auto oldMemBitmap = OS.SelectObject (memHdc, memDib);
+
+ BITMAP dibBM;
+ OS.GetObject (memDib, BITMAP.sizeof, &dibBM);
+ int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
+
+ /* Get the foreground pixels */
+ OS.BitBlt (memHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ];
+
+ PaletteData palette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ ImageData data = new ImageData(srcWidth, srcHeight, bm.bmBitsPixel, palette, bm.bmWidthBytes, srcData);
+ data.transparentPixel = shdi.crColorKey << 8;
+ dragSourceImage = new Image (control.getDisplay (), data);
+ OS.SelectObject (memHdc, oldMemBitmap);
+ OS.DeleteDC (memHdc);
+ OS.DeleteObject (memDib);
+ OS.SelectObject (srcHdc, oldSrcBitmap);
+ OS.DeleteDC (srcHdc);
+ OS.ReleaseDC (null, hdc);
+ return dragSourceImage;
+ }
+ }
+ return null;
+ }
+
Tree tree = cast(Tree) control;
+ //TEMPORARY CODE
+ if (tree.isListening (DWT.EraseItem) || tree.isListening (DWT.PaintItem)) return null;
TreeItem[] selection = tree.getSelection();
if (selection.length is 0) return null;
- int treeImageList = OS.SendMessage (tree.handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ auto treeImageList = OS.SendMessage (tree.handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
if (treeImageList !is 0) {
int count = Math.min(selection.length, 10);
Rectangle bounds = selection[0].getBounds(0);
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/TreeDropTargetEffect.d
--- a/dwt/dnd/TreeDropTargetEffect.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/TreeDropTargetEffect.d Sat May 17 17:34:28 2008 +0200
@@ -12,8 +12,10 @@
*******************************************************************************/
module dwt.dnd.TreeDropTargetEffect;
+import dwt.DWT;
import dwt.graphics.Point;
import dwt.internal.win32.OS;
+import dwt.widgets.Event;
import dwt.widgets.Tree;
import dwt.widgets.TreeItem;
@@ -59,10 +61,10 @@
static final int SCROLL_HYSTERESIS = 200; // milli seconds
static final int EXPAND_HYSTERESIS = 1000; // milli seconds
- int dropIndex;
+ int /*long*/ dropIndex;
int scrollIndex;
long scrollBeginTime;
- int expandIndex;
+ int /*long*/ expandIndex;
long expandBeginTime;
TreeItem insertItem;
bool insertBefore;
@@ -171,22 +173,21 @@
lpht.pt.x = coordinates.x;
lpht.pt.y = coordinates.y;
OS.SendMessage (handle, OS.TVM_HITTEST, 0, &lpht);
- int hItem = cast(int) lpht.hItem;
+ auto hItem = lpht.hItem;
if ((effect & DND.FEEDBACK_SCROLL) is 0) {
scrollBeginTime = 0;
scrollIndex = -1;
} else {
- if (hItem !is -1 && scrollIndex is hItem && scrollBeginTime !is 0) {
+ if (hItem !is cast(HTREEITEM)-1 && cast(HTREEITEM)scrollIndex is hItem && scrollBeginTime !is 0) {
if (System.currentTimeMillis() >= scrollBeginTime) {
- int topItem = OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
- int nextItem = OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem);
+ auto topItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ auto nextItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem);
bool scroll = true;
if (hItem is topItem) {
- scroll = nextItem !is 0;
+ scroll = nextItem !is null;
} else {
RECT itemRect;
- itemRect.left = nextItem;
- if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, &itemRect) !is 0) {
+ if (OS.TreeView_GetItemRect (handle, nextItem, &itemRect, true)) {
RECT rect;
OS.GetClientRect (handle, &rect);
POINT pt;
@@ -207,23 +208,23 @@
}
} else {
scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollIndex = hItem;
+ scrollIndex = cast(int)hItem;
}
}
if ((effect & DND.FEEDBACK_EXPAND) is 0) {
expandBeginTime = 0;
expandIndex = -1;
} else {
- if (hItem !is -1 && expandIndex is hItem && expandBeginTime !is 0) {
+ if (cast(int)hItem !is -1 && expandIndex is cast(int)hItem && expandBeginTime !is 0) {
if (System.currentTimeMillis() >= expandBeginTime) {
if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem) !is 0) {
- TVITEM tvItem;
- tvItem.hItem = cast(HANDLE) hItem;
- tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, &tvItem);
- if ((tvItem.state & OS.TVIS_EXPANDED) is 0) {
- OS.SendMessage (handle, OS.TVM_EXPAND, OS.TVE_EXPAND, hItem);
+ TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem);
+ if (item !is null && !item.getExpanded()) {
+ item.setExpanded(true);
tree.redraw();
+ Event expandEvent = new Event ();
+ expandEvent.item = item;
+ tree.notifyListeners(DWT.Expand, expandEvent);
}
}
expandBeginTime = 0;
@@ -231,10 +232,10 @@
}
} else {
expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
- expandIndex = hItem;
+ expandIndex = cast(int)hItem;
}
}
- if (dropIndex !is -1 && (dropIndex !is hItem || (effect & DND.FEEDBACK_SELECT) is 0)) {
+ if (dropIndex !is -1 && (dropIndex !is cast(int)hItem || (effect & DND.FEEDBACK_SELECT) is 0)) {
TVITEM tvItem;
tvItem.hItem = cast(HANDLE) dropIndex;
tvItem.mask = OS.TVIF_STATE;
@@ -243,14 +244,14 @@
OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem);
dropIndex = -1;
}
- if (hItem !is -1 && hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) {
+ if (cast(int)hItem !is -1 && cast(int)hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) {
TVITEM tvItem;
tvItem.hItem = cast(HANDLE) hItem;
tvItem.mask = OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_DROPHILITED;
tvItem.state = OS.TVIS_DROPHILITED;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem);
- dropIndex = hItem;
+ dropIndex = cast(int)hItem;
}
if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0 || (effect & DND.FEEDBACK_INSERT_AFTER) !is 0) {
bool before = (effect & DND.FEEDBACK_INSERT_BEFORE) !is 0;
@@ -263,7 +264,7 @@
* Since the insert mark can not be queried from the tree,
* use the Tree API rather than calling the OS directly.
*/
- TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, hItem);
+ TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem);
if (item !is null) {
if (item !is insertItem || before !is insertBefore) {
tree.setInsertMark(item, before);
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/dnd/URLTransfer.d
--- a/dwt/dnd/URLTransfer.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/URLTransfer.d Sat May 17 17:34:28 2008 +0200
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * Copyright (c) 2000, 20007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,8 +12,6 @@
*******************************************************************************/
module dwt.dnd.URLTransfer;
-//import java.net.URL;
-
import dwt.internal.ole.win32.COM;
import dwt.internal.ole.win32.OBJIDL;
import dwt.internal.win32.OS;
@@ -28,21 +26,19 @@
/**
* The class URLTransfer
provides a platform specific mechanism
- * for converting text in URL format represented as a java String[]
+ * for converting text in URL format represented as a java String
* to a platform specific representation of the data and vice versa. See
- * Transfer
for additional information. The first string in the
- * array is mandatory and must contain the fully specified url. The second
- * string in the array is optional and if present contains the title for the
- * page.
+ * Transfer
for additional information. The string
+ * must contain a fully specified url.
*
- * An example of a java String[]
containing a URL is shown
+ *
An example of a java String
containing a URL is shown
* below:
- * String[] urlData = new String[] {"http://www.eclipse.org", "Eclipse.org Main Page"};
+ * String url = "http://www.eclipse.org";
*
*/
-/*public*/ class URLTransfer : ByteArrayTransfer {
+public class URLTransfer : ByteArrayTransfer {
static URLTransfer _instance;
static const String CFSTR_INETURL = "UniformResourceLocator"; //$NON-NLS-1$
@@ -71,11 +67,11 @@
}
/**
- * This implementation of javaToNative
converts a URL and optionally a title
- * represented by a java String[]
to a platform specific representation.
+ * This implementation of javaToNative
converts a URL
+ * represented by a java String
to a platform specific representation.
* For additional information see Transfer#javaToNative
.
*
- * @param object a java String[]
containing a URL and optionally, a title
+ * @param object a java String
containing a URL
* @param transferData an empty TransferData
object; this
* object will be filled in on return with the platform specific format of the data
*/
@@ -85,7 +81,7 @@
}
transferData.result = COM.E_FAIL;
// URL is stored as a null terminated byte array
- String url = (cast(ArrayWrapperString2)object).array[0];
+ String url = (cast(ArrayWrapperString)object).array;
int codePage = OS.GetACP();
wchar[] chars = StrToWCHARs(codePage, url, true );
int cchMultiByte = OS.WideCharToMultiByte(codePage, 0, chars.ptr, -1, null, 0, null, null);
@@ -106,12 +102,12 @@
/**
* This implementation of nativeToJava
converts a platform specific
- * representation of a URL and optionally, a title to a java String[]
.
+ * representation of a URL to a java String
.
* For additional information see Transfer#nativeToJava
.
*
* @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java String[]
containing a URL and optionally a title if the
+ * converted
+ * @return a java String
containing a URL if the
* conversion was successful; otherwise null
*/
public Object nativeToJava(TransferData transferData){
@@ -134,7 +130,7 @@
if (cchWideChar is 0) return null;
wchar[] lpWideCharStr = new wchar [cchWideChar - 1];
OS.MultiByteToWideChar (codePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr.ptr, lpWideCharStr.length);
- return new ArrayWrapperString2( [ WCHARzToStr( lpWideCharStr.ptr) ]);
+ return new ArrayWrapperString( WCHARzToStr( lpWideCharStr.ptr) );
} finally {
OS.GlobalUnlock(hMem);
}
@@ -152,19 +148,8 @@
}
bool checkURL(Object object) {
- if( auto s = cast(ArrayWrapperString2)object ){
- if( s.array.length is 0 ) return false;
- String[] strings = s.array;
- if (strings[0] is null || strings[0].length is 0) return false;
- //PORTING_FIXME: how to validata URL?
- /+try {
- new URL(strings[0]);
- } catch (java.net.MalformedURLException e) {
- return false;
- }+/
- return true;
- }
- return false;
+ return object !is null && (null !is cast(ArrayWrapperString)object) && (cast(ArrayWrapperString)object).array.length > 0;
+
}
protected bool validate(Object object) {
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Color.d
--- a/dwt/graphics/Color.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Color.d Sat May 17 17:34:28 2008 +0200
@@ -40,6 +40,8 @@
public final class Color : Resource {
+ alias Resource.init_ init_;
+
/**
* the handle to the OS color resource
* (Warning: This field is platform dependent)
@@ -55,7 +57,8 @@
/**
* Prevents uninitialized instances from being created outside the package.
*/
-this() {
+this(Device device) {
+ super(device);
}
/**
@@ -83,10 +86,9 @@
* @see #dispose
*/
public this (Device device, int red, int green, int blue) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, red, green, blue);
- if (device.tracking) device.new_Object(this);
+ super(device);
+ init_(red, green, blue);
+ init_();
}
/**
@@ -112,22 +114,13 @@
* @see #dispose
*/
public this (Device device, RGB rgb) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, rgb.red, rgb.green, rgb.blue);
- if (device.tracking) device.new_Object(this);
+ init_(rgb.red, rgb.green, rgb.blue);
+ init_();
}
-/**
- * Disposes of the operating system resources associated with
- * the color. Applications must dispose of all colors which
- * they allocate.
- */
-override public void dispose() {
- if (handle is -1) return;
- if (device.isDisposed()) return;
-
+void destroy() {
/*
* If this is a palette-based device,
* Decrease the reference count for this color.
@@ -143,8 +136,6 @@
}
}
handle = -1;
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
@@ -249,11 +240,10 @@
*
* @see #dispose
*/
-void init_(Device device, int red, int green, int blue) {
+void init_(int red, int green, int blue) {
if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) {
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
- this.device = device;
handle = (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16);
/* If this is not a palette-based device, return */
@@ -338,10 +328,8 @@
* @return a new color object containing the specified device and handle
*/
public static Color win32_new(Device device, int handle) {
- if (device is null) device = Device.getDevice();
- Color color = new Color();
+ Color color = new Color(device);
color.handle = handle;
- color.device = device;
return color;
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Cursor.d
--- a/dwt/graphics/Cursor.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Cursor.d Sat May 17 17:34:28 2008 +0200
@@ -54,6 +54,8 @@
public final class Cursor : Resource {
+ alias Resource.init_ init_;
+
/**
* the handle to the OS cursor resource
* (Warning: This field is platform dependent)
@@ -149,7 +151,8 @@
/**
* Prevents uninitialized instances from being created outside the package.
*/
-this() {
+this(Device device) {
+ super(device);
}
/**
@@ -194,10 +197,8 @@
* @see DWT#CURSOR_HAND
*/
public this(Device device, int style) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
- int lpCursorName = 0;
+ super(device);
+ int /*long*/ lpCursorName = 0;
switch (style) {
case DWT.CURSOR_HAND: lpCursorName = OS.IDC_HAND; break;
case DWT.CURSOR_ARROW: lpCursorName = OS.IDC_ARROW; break;
@@ -240,7 +241,7 @@
}
}
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
+ init_();
}
/**
@@ -275,9 +276,7 @@
*
*/
public this(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ super(device);
if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (mask is null) {
if (source.getTransparencyType() !is DWT.TRANSPARENCY_MASK) {
@@ -307,7 +306,7 @@
static if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED);
handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData.ptr, maskData.ptr);
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
+ init_();
}
/**
@@ -338,9 +337,7 @@
* @since 3.0
*/
public this(Device device, ImageData source, int hotspotX, int hotspotY) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ super(device);
if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
/* Check the hotspots */
if (hotspotX >= source.width || hotspotX < 0 ||
@@ -348,7 +345,7 @@
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
ImageData mask = source.getTransparencyMask();
- int[] result = Image.init_(device, null, source, mask);
+ int[] result = Image.init_(this.device, null, source, mask);
auto hBitmap = cast(HBITMAP)result[0];
auto hMask = cast(HBITMAP)result[1];
/* Create the icon */
@@ -363,18 +360,10 @@
OS.DeleteObject(hBitmap);
OS.DeleteObject(hMask);
isIcon = true;
- if (device.tracking) device.new_Object(this);
+ init_();
}
-/**
- * Disposes of the operating system resources associated with
- * the cursor. Applications must dispose of all cursors which
- * they allocate.
- */
-override public void dispose () {
- if (handle is null) return;
- if (device.isDisposed()) return;
-
+void destroy () {
/*
* It is an error in Windows to destroy the current
* cursor. Check that the cursor that is about to
@@ -402,8 +391,6 @@
static if (!OS.IsWinCE) OS.DestroyCursor(handle);
}
handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
@@ -477,10 +464,8 @@
* @return a new cursor object containing the specified device and handle
*/
public static Cursor win32_new(Device device, HCURSOR handle) {
- if (device is null) device = Device.getDevice();
- Cursor cursor = new Cursor();
+ Cursor cursor = new Cursor(device);
cursor.handle = handle;
- cursor.device = device;
return cursor;
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Device.d
--- a/dwt/graphics/Device.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Device.d Sat May 17 17:34:28 2008 +0200
@@ -17,6 +17,14 @@
import dwt.internal.gdip.Gdip;
import dwt.internal.win32.OS;
+import dwt.graphics.Cursor;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Path;
+import dwt.graphics.Pattern;
+import dwt.graphics.Region;
+import dwt.graphics.TextLayout;
+import dwt.graphics.Transform;
import dwt.graphics.Drawable;
import dwt.graphics.DeviceData;
import dwt.graphics.Rectangle;
@@ -27,8 +35,11 @@
import dwt.dwthelper.Runnable;
import dwt.dwthelper.System;
+
import dwt.dwthelper.utils;
import tango.core.Exception;
+import tango.util.Convert;
+import tango.io.Stdout;
/**
* This class is the abstract superclass of all device objects,
@@ -49,6 +60,7 @@
bool tracking;
Exception [] errors;
Object [] objects;
+ Object trackingLock;
/**
* Palette
@@ -64,7 +76,7 @@
int [] colorRefCount;
/* System Font */
- HFONT systemFont;
+ Font systemFont;
/* Font Enumeration */
int nFonts = 256;
@@ -74,6 +86,7 @@
/* Scripts */
SCRIPT_PROPERTIES*[] scripts;
+ LOGFONT* [] logFontsCache;
/* Advanced Graphics */
ULONG_PTR gdipToken;
@@ -134,22 +147,20 @@
* @see DeviceData
*/
public this(DeviceData data) {
- synchronized (this.classinfo) {
+ synchronized (Device.classinfo) {
debug_ = DEBUG;
tracking = DEBUG;
if (data !is null) {
debug_ = data.debug_;
tracking = data.tracking;
}
- create (data);
- init_ ();
if (tracking) {
errors = new Exception [128];
objects = new Object [128];
+ trackingLock = new Object ();
}
-
- /* Initialize the system font slot */
- systemFont = getSystemFont().handle;
+ create (data);
+ init_ ();
gdipToken = 0;
}
}
@@ -179,8 +190,8 @@
void checkGDIP() {
if (gdipToken) return;
- static if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
- int oldErrorMode = OS.SetErrorMode (OS.SEM_FAILCRITICALERRORS);
+ int oldErrorMode = 0;
+ static if (!OS.IsWinCE) oldErrorMode = OS.SetErrorMode (OS.SEM_FAILCRITICALERRORS);
try {
ULONG_PTR token;
GdiplusStartupInput input;
@@ -191,7 +202,7 @@
} catch (Exception t) {
DWT.error (DWT.ERROR_NO_GRAPHICS_LIBRARY, t, " [GDI+ is required]"); //$NON-NLS-1$
} finally {
- OS.SetErrorMode (oldErrorMode);
+ if (!OS.IsWinCE) OS.SetErrorMode (oldErrorMode);
}
}
@@ -272,23 +283,31 @@
* @see #checkDevice
*/
public void dispose () {
- if (isDisposed()) return;
- checkDevice ();
- release ();
- destroy ();
- disposed = true;
- if (tracking) {
- objects = null;
- errors = null;
+ synchronized (Device.classinfo) {
+ if (isDisposed()) return;
+ checkDevice ();
+ release ();
+ destroy ();
+ disposed = true;
+ if (tracking) {
+ synchronized (trackingLock) {
+ printErrors ();
+ objects = null;
+ errors = null;
+ trackingLock = null;
+ }
+ }
}
}
void dispose_Object (Object object) {
- for (int i=0; ifalse
otherwise
*/
public bool isDisposed () {
- return disposed;
+ synchronized (Device.classinfo) {
+ return disposed;
+ }
}
/**
@@ -802,21 +832,71 @@
}
void new_Object (Object object) {
- for (int i=0; iDWT.BITMAP
, DWT.ICON
)
@@ -156,7 +158,8 @@
/**
* Prevents uninitialized instances from being created outside the package.
*/
-this () {
+this (Device device) {
+ super(device);
}
/**
@@ -190,10 +193,9 @@
*
*/
public this(Device device, int width, int height) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, width, height);
- if (device.tracking) device.new_Object(this);
+ super(device);
+ init_(width, height);
+ init_();
}
/**
@@ -228,15 +230,14 @@
*
*/
public this(Device device, Image srcImage, int flag) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ super(device);
+ device = this.device;
if (srcImage is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (srcImage.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
Rectangle rect = srcImage.getBounds();
+ this.type = srcImage.type;
switch (flag) {
case DWT.IMAGE_COPY: {
- this.type = srcImage.type;
switch (type) {
case DWT.BITMAP:
/* Get the HDC for the device */
@@ -269,7 +270,7 @@
break;
case DWT.ICON:
static if (OS.IsWinCE) {
- init_(device, srcImage.data);
+ init_(srcImage.data);
} else {
handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, rect.width, rect.height, 0);
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
@@ -278,8 +279,7 @@
default:
DWT.error(DWT.ERROR_INVALID_IMAGE);
}
- if (device.tracking) device.new_Object(this);
- return;
+ break;
}
case DWT.IMAGE_DISABLE: {
ImageData data = srcImage.getImageData();
@@ -337,9 +337,8 @@
offset++;
}
}
- init_ (device, newData);
- if (device.tracking) device.new_Object(this);
- return;
+ init_ (newData);
+ break;
}
case DWT.IMAGE_GRAY: {
ImageData data = srcImage.getImageData();
@@ -402,13 +401,13 @@
}
}
}
- init_ (device, newData);
- if (device.tracking) device.new_Object(this);
- return;
+ init_ (newData);
+ break;
}
default:
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
+ init_();
}
/**
@@ -442,11 +441,10 @@
*
*/
public this(Device device, Rectangle bounds) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, bounds.width, bounds.height);
- if (device.tracking) device.new_Object(this);
+ init_(bounds.width, bounds.height);
+ init_();
}
/**
@@ -468,10 +466,9 @@
*
*/
public this(Device device, ImageData data) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, data);
- if (device.tracking) device.new_Object(this);
+ super(device);
+ init_(data);
+ init_();
}
/**
@@ -500,16 +497,15 @@
*
*/
public this(Device device, ImageData source, ImageData mask) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (mask is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (source.width !is mask.width || source.height !is mask.height) {
DWT.error(DWT.ERROR_INVALID_ARGUMENT);
}
mask = ImageData.convertMask(mask);
- init_(device, this, source, mask);
- if (device.tracking) device.new_Object(this);
+ init_(this.device, this, source, mask);
+ init_();
}
/**
@@ -561,10 +557,9 @@
*
*/
public this (Device device, InputStream stream) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- init_(device, new ImageData(stream));
- if (device.tracking) device.new_Object(this);
+ super(device);
+ init_(new ImageData(stream));
+ init_();
}
/**
@@ -595,12 +590,22 @@
*
*/
public this (Device device, String filename) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
+ device = this.device;
if (filename is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ bool gdip = true;
try {
device.checkGDIP();
+ } catch (DWTException e) {
+ gdip = false;
+ }
+ /*
+ * Bug in GDI+. For some reason, Bitmap.LockBits() segment faults
+ * when loading GIF files in 64-bit Windows. The fix is to not use
+ * GDI+ image loading in this case.
+ */
+ if (gdip && (void*).sizeof is 8 && filename.toLowerCase().endsWith(".gif")) gdip = false;
+ if (gdip) {
int length = filename.length;
char[] chars = new char[length+1];
filename.getChars(0, length, chars, 0);
@@ -741,7 +746,7 @@
ImageData img = new ImageData(width, height, depth, paletteData, scanlinePad, data);
img.transparentPixel = transparentPixel;
img.alphaData = alphaData;
- init_(device, img);
+ init_(img);
}
}
}
@@ -753,9 +758,9 @@
return;
}
}
- } catch (DWTException e) {}
- init_(device, new ImageData(filename));
- if(device.tracking) device.new_Object(this);
+ }
+ init_(new ImageData(filename));
+ init_();
}
/**
@@ -853,7 +858,7 @@
offset += 4;
}
}
- int pBits;
+ void* pBits;
HBITMAP hDib = OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0);
if (hDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
@@ -877,7 +882,7 @@
// active, even though it might be unlikely given the short span of time that the
// function has them stored in the int array.
-int[] createGdipImage() {
+int /*long*/ [] createGdipImage() {
switch (type) {
case DWT.BITMAP: {
if (alpha !is -1 || alphaData !is null || transparentPixel !is -1) {
@@ -996,7 +1001,14 @@
int imgHeight = hBitmap is iconInfo.hbmMask ? bm.bmHeight / 2 : bm.bmHeight;
Gdip.Bitmap img;
ubyte* pixels;
- if (imgWidth > imgHeight) {
+ /*
+ * Bug in GDI+. Bitmap_new() segments fault if the image width
+ * is greater than the image height.
+ *
+ * Note that it also fails to generated an appropriate alpha
+ * channel when the icon depth is 32.
+ */
+ if (imgWidth > imgHeight || bm.bmBitsPixel is 32) {
auto hDC = device.internal_new_GC(null);
auto srcHdc = OS.CreateCompatibleDC(hDC);
auto oldSrcBitmap = OS.SelectObject(srcHdc, hBitmap);
@@ -1013,12 +1025,14 @@
OS.MoveMemory(srcData.ptr, dibBM.bmBits, srcData.length);
OS.DeleteObject(memDib);
OS.SelectObject(srcHdc, iconInfo.hbmMask);
- for (int y = 0, dp = 0; y < imgHeight; ++y) {
+ for (int y = 0, dp = 3; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x) {
- if (OS.GetPixel(srcHdc, x, y) !is 0) {
- srcData[dp + 3] = cast(ubyte)0;
- } else {
- srcData[dp + 3] = cast(ubyte)0xFF;
+ if (srcData[dp] is 0) {
+ if (OS.GetPixel(srcHdc, x, y) !is 0) {
+ srcData[dp] = cast(ubyte)0;
+ } else {
+ srcData[dp] = cast(ubyte)0xFF;
+ }
}
dp += 4;
}
@@ -1043,14 +1057,7 @@
return null;
}
-/**
- * Disposes of the operating system resources associated with
- * the image. Applications must dispose of all images which
- * they allocate.
- */
-override public void dispose () {
- if (handle is null) return;
- if (device.isDisposed()) return;
+void destroy () {
if (memGC !is null) memGC.dispose();
if (type is DWT.ICON) {
static if (OS.IsWinCE) data = null;
@@ -1060,8 +1067,6 @@
}
handle = null;
memGC = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
@@ -1579,11 +1584,10 @@
return cast(hash_t)handle;
}
-void init_(Device device, int width, int height) {
+void init_(int width, int height) {
if (width <= 0 || height <= 0) {
DWT.error (DWT.ERROR_INVALID_ARGUMENT);
}
- this.device = device;
type = DWT.BITMAP;
auto hDC = device.internal_new_GC(null);
handle = OS.CreateCompatibleBitmap(hDC, width, height);
@@ -1644,8 +1648,8 @@
bmi[offset + 11] = cast(byte)((blueMask & 0xFF) >> 0);
}
- int[1] pBits;
- return OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0);
+ void* pBits;
+ return OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0);
}
/**
@@ -1666,7 +1670,6 @@
}
static int[] init_(Device device, Image image, ImageData i) {
- if (image !is null) image.device = device;
/*
* BUG in Windows 98:
@@ -1833,7 +1836,7 @@
}
OS.MoveMemory(pBits, data.ptr, data.length);
- int[] result = null;
+ int /*long*/ [] result = null;
if (i.getTransparencyType() is DWT.TRANSPARENCY_MASK) {
/* Get the HDC for the device */
auto hDC = device.internal_new_GC(null);
@@ -1969,7 +1972,7 @@
imageData.maskData = mask.data;
return init_(device, image, imageData);
}
-void init_(Device device, ImageData i) {
+void init_(ImageData i) {
if (i is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
init_(device, this, i);
}
@@ -2013,7 +2016,7 @@
}
data.device = device;
data.image = this;
- data.hFont = device.systemFont;
+ data.font = device.systemFont;
}
return imageDC;
}
@@ -2144,11 +2147,9 @@
* @return a new image object containing the specified device, type and handle
*/
public static Image win32_new(Device device, int type, HGDIOBJ handle) {
- if (device is null) device = Device.getDevice();
- Image image = new Image();
+ Image image = new Image(device);
image.type = type;
image.handle = handle;
- image.device = device;
return image;
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/ImageData.d
--- a/dwt/graphics/ImageData.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/ImageData.d Sat May 17 17:34:28 2008 +0200
@@ -290,7 +290,7 @@
*
* @exception IllegalArgumentException path
. If
+ * flatness
is less than or equal to zero, an unflatten
+ * copy of the path is created. Otherwise, it specifies the maximum
+ * error between the path and its flatten copy. Smaller numbers give
+ * better approximation.
+ * + * This operation requires the operating system's advanced + * graphics subsystem which may not be available on some + * platforms. + *
+ * + * @param device the device on which to allocate the path + * @param path the path to make a copy + * @param flatness the flatness value + * + * @exception IllegalArgumentException+ * This operation requires the operating system's advanced + * graphics subsystem which may not be available on some + * platforms. + *
+ * + * @param device the device on which to allocate the path + * @param data the data for the path + * + * @exception IllegalArgumentExceptiontrue
if the Path has been disposed,
* and false
otherwise.
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Pattern.d
--- a/dwt/graphics/Pattern.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Pattern.d Sat May 17 17:34:28 2008 +0200
@@ -43,7 +43,7 @@
* @since 3.1
*/
public class Pattern : Resource {
-
+ alias Resource.init_ init_;
/**
* the OS resource for the Pattern
* (Warning: This field is platform dependent)
@@ -82,14 +82,12 @@
* @see #dispose()
*/
public this(Device device, Image image) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- this.device = device;
- device.checkGDIP();
- int[] gdipImage = image.createGdipImage();
- auto img = cast(Gdip.Image)gdipImage[0];
+ this.device.checkGDIP();
+ int /*long*/[] gdipImage = image.createGdipImage();
+ auto img = cast(Gdip.Image) gdipImage[0];
int width = Gdip.Image_GetWidth(img);
int height = Gdip.Image_GetHeight(img);
handle = cast(Gdip.Brush)Gdip.TextureBrush_new(img, Gdip.WrapModeTile, 0, 0, width, height);
@@ -99,7 +97,7 @@
OS.HeapFree(hHeap, 0, cast(void*)gdipImage[1]);
}
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
+ init_();
}
/**
@@ -175,14 +173,12 @@
* @since 3.2
*/
public this(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ super(device);
if (color1 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (color1.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
if (color2 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
if (color2.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
- this.device = device;
- device.checkGDIP();
+ this.device.checkGDIP();
auto colorRef1 = color1.handle;
int rgb = ((colorRef1 >> 16) & 0xFF) | (colorRef1 & 0xFF00) | ((colorRef1 & 0xFF) << 16);
auto foreColor = Gdip.Color_new((alpha1 & 0xFF) << 24 | rgb);
@@ -215,23 +211,16 @@
f[0] = 0;
f[1] = 0.5f;
f[2] = 1;
- Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush)handle, c, f, 3);
+ Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush)handle, c.ptr, f.ptr, 3);
Gdip.Color_delete(midColor);
}
Gdip.Color_delete(backColor);
}
Gdip.Color_delete(foreColor);
- if (device.tracking) device.new_Object(this);
+ init_();
}
-/**
- * Disposes of the operating system resources associated with
- * the Pattern. Applications must dispose of all Patterns that
- * they allocate.
- */
-override public void dispose() {
- if (handle is null) return;
- if (device.isDisposed()) return;
+void destroy() {
int type = Gdip.Brush_GetType(handle);
switch (type) {
case Gdip.BrushTypeSolidColor:
@@ -249,8 +238,6 @@
default:
}
handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Region.d
--- a/dwt/graphics/Region.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Region.d Sat May 17 17:34:28 2008 +0200
@@ -38,6 +38,7 @@
*/
public final class Region : Resource {
+ alias Resource.init_ init_;
/**
* the OS resource for the region
@@ -82,12 +83,10 @@
* @since 3.0
*/
public this (Device device) {
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ super(device);
handle = OS.CreateRectRgn (0, 0, 0, 0);
if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
+ init_();
}
/**
@@ -97,7 +96,7 @@
* @param handle the handle for the result
*/
this(Device device, HRGN handle) {
- this.device = device;
+ super(device);
this.handle = handle;
}
@@ -233,18 +232,9 @@
return contains(pt.x, pt.y);
}
-/**
- * Disposes of the operating system resources associated with
- * the region. Applications must dispose of all regions which
- * they allocate.
- */
-override public void dispose () {
- if (handle is null) return;
- if (device.isDisposed()) return;
+void destroy () {
OS.DeleteObject(handle);
handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/Resource.d
--- a/dwt/graphics/Resource.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/Resource.d Sat May 17 17:34:28 2008 +0200
@@ -44,12 +44,30 @@
*/
Device device;
+this() {
+}
+
+this(Device device) {
+ if (device is null) device = Device.getDevice();
+ if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+}
+
+void destroy() {
+}
+
/**
* Disposes of the operating system resources associated with
* this resource. Applications must dispose of all resources
* which they allocate.
*/
-public abstract void dispose();
+public void dispose() {
+ if (device is null) return;
+ if (device.isDisposed()) return;
+ destroy();
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
/**
* Returns the Device
where this resource was
@@ -65,6 +83,10 @@
return device;
}
+void init_() {
+ if (device.tracking) device.new_Object(this);
+}
+
/**
* Returns true
if the resource has been disposed,
* and false
otherwise.
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/graphics/TextLayout.d
--- a/dwt/graphics/TextLayout.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/TextLayout.d Sat May 17 17:34:28 2008 +0200
@@ -16,6 +16,7 @@
import dwt.DWTException;
import dwt.internal.Compatibility;
import dwt.internal.gdip.Gdip;
+
import dwt.internal.win32.OS;
import dwt.graphics.Color;
@@ -51,6 +52,8 @@
* @since 3.0
*/
public final class TextLayout : Resource {
+ alias Resource.init_ init_;
+
Font font;
String text, segmentsText;
int lineSpacing;
@@ -63,6 +66,7 @@
int[] tabs;
int[] segments;
StyleItem[] styles;
+ int stylesCount;
StyleItem[] allRuns;
StyleItem[][] runs;
@@ -89,6 +93,11 @@
}
}
+ /* IME has a copy of these constants */
+ static const int UNDERLINE_IME_DOT = 1 << 16;
+ static const int UNDERLINE_IME_DASH = 2 << 16;
+ static const int UNDERLINE_IME_THICK = 3 << 16;
+
class StyleItem {
TextStyle style;
int start, length;
@@ -112,6 +121,8 @@
int descent;
int leading;
int x;
+ int underlinePos, underlineThickness;
+ int strikeoutPos, strikeoutThickness;
/* Justify info (malloc during computeRuns) */
int* justify;
@@ -191,22 +202,21 @@
*/
public this (Device device) {
static_this();
- if (device is null) device = Device.getDevice();
- if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
- this.device = device;
+ super(device);
wrapWidth = ascent = descent = -1;
lineSpacing = 0;
orientation = DWT.LEFT_TO_RIGHT;
styles = new StyleItem[2];
styles[0] = new StyleItem();
styles[1] = new StyleItem();
+ stylesCount = 2;
text = ""; //$NON-NLS-1$
void* ppv;
OS.OleInitialize(null);
if (OS.CoCreateInstance(CLSID_CMultiLanguage.ptr, null, OS.CLSCTX_INPROC_SERVER, IID_IMLangFontLink2.ptr, cast(void*)&ppv) is OS.S_OK) {
mLangFontLink2 = ppv;
}
- if (device.tracking) device.new_Object(this);
+ init_();
}
void breakRun(StyleItem run) {
@@ -349,9 +359,15 @@
if (start is 0 && i !is lineStart && !run.tab) {
run = allRuns[--i];
} else if (start <= 0 && i is lineStart) {
- i = firstIndice;
- run = allRuns[i];
- start = Math.max(1, firstStart);
+ if (lineWidth is wrapWidth && firstIndice > 0) {
+ i = firstIndice - 1;
+ run = allRuns[i];
+ start = run.length;
+ } else {
+ i = firstIndice;
+ run = allRuns[i];
+ start = Math.max(1, firstStart);
+ }
}
breakRun(run);
while (start < run.length) {
@@ -471,12 +487,7 @@
if (gc is null) device.internal_dispose_GC(hDC, null);
}
-/**
- * Disposes of the operating system resources associated with
- * the text layout. Applications must dispose of all allocated text layouts.
- */
-override public void dispose () {
- if (device is null) return;
+void destroy () {
freeRuns();
font = null;
text = null;
@@ -493,8 +504,6 @@
mLangFontLink2 = null;
}
OS.OleUninitialize();
- if (device.tracking) device.dispose_Object(this);
- device = null;
}
/**
@@ -595,7 +604,7 @@
Gdip.Matrix_delete(identity_);
if (!Gdip.Matrix_IsIdentity(matrix)) {
lpXform = new float[6];
- Gdip.Matrix_GetElements(matrix, lpXform);
+ Gdip.Matrix_GetElements(matrix, lpXform.ptr);
}
Gdip.Matrix_delete(matrix);
if ((data.style & DWT.MIRRORED) !is 0 && lpXform !is null) {
@@ -642,26 +651,26 @@
selectionEnd = translateOffset(selectionEnd);
}
RECT rect;
- void* selBrush;
- void* selPen;
- void* selBrushFg;
+ Gdip.Brush selBrush;
+ Gdip.Pen selPen;
+ Gdip.Brush selBrushFg;
if (hasSelection || (flags & DWT.LAST_LINE_SELECTION) !is 0) {
if (gdip) {
auto bg = selectionBackground.handle;
auto argb = ((alpha & 0xFF) << 24) | ((bg >> 16) & 0xFF) | (bg & 0xFF00) | ((bg & 0xFF) << 16);
auto color = Gdip.Color_new(argb);
- selBrush = Gdip.SolidBrush_new(color);
+ selBrush = cast(Gdip.Brush)Gdip.SolidBrush_new(color);
Gdip.Color_delete(color);
auto fg = selectionForeground.handle;
argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16);
color = Gdip.Color_new(argb);
- selBrushFg = Gdip.SolidBrush_new(color);
- selPen = Gdip.Pen_new( cast(Gdip.Brush)selBrushFg, 1);
+ selBrushFg = cast(Gdip.Brush)Gdip.SolidBrush_new(color);
+ selPen = cast(Gdip.Pen) Gdip.Pen_new( cast(Gdip.Brush)selBrushFg, 1);
Gdip.Color_delete(color);
} else {
- selBrush = OS.CreateSolidBrush(selectionBackground.handle);
- selPen = OS.CreatePen(OS.PS_SOLID, 1, selectionForeground.handle);
+ selBrush = cast(Gdip.Brush)OS.CreateSolidBrush(selectionBackground.handle);
+ selPen = cast(Gdip.Pen)OS.CreatePen(OS.PS_SOLID, 1, selectionForeground.handle);
}
}
int offset = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? -1 : 0;
@@ -670,7 +679,7 @@
int drawX = x + getLineIndent(line);
int drawY = y + lineY[line];
StyleItem[] lineRuns = runs[line];
- int lineHeight = lineY[line+1] - lineY[line];
+ int lineHeight = lineY[line+1] - lineY[line] - lineSpacing;
if (flags !is 0 && (hasSelection || (flags & DWT.LAST_LINE_SELECTION) !is 0)) {
bool extents = false;
if (line is runs.length - 1 && (flags & DWT.LAST_LINE_SELECTION) !is 0) {
@@ -691,21 +700,23 @@
if ((flags & DWT.FULL_SELECTION) !is 0) {
width = OS.IsWin95 ? 0x7FFF : 0x6FFFFFF;
} else {
- width = (lineHeight - lineSpacing) / 3;
+ width = lineHeight / 3;
}
if (gdip) {
- Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing);
+ Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX + lineWidth[line], drawY, width, lineHeight);
} else {
OS.SelectObject(hdc, selBrush);
- OS.PatBlt(hdc, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing, OS.PATCOPY);
+ OS.PatBlt(hdc, drawX + lineWidth[line], drawY, width, lineHeight, OS.PATCOPY);
}
}
}
if (drawX > clip.x + clip.width) continue;
if (drawX + lineWidth[line] < clip.x) continue;
int baseline = Math.max(0, this.ascent);
+ int lineUnderlinePos = 0;
for (int i = 0; i < lineRuns.length; i++) {
baseline = Math.max(baseline, lineRuns[i].ascent);
+ lineUnderlinePos = Math.min(lineUnderlinePos, lineRuns[i].underlinePos);
}
int alignmentX = drawX;
for (int i = 0; i < lineRuns.length; i++) {
@@ -718,26 +729,25 @@
bool fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end;
if (fullSelection) {
if (gdip) {
- Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX, drawY, run.width, lineHeight - lineSpacing);
+ Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX, drawY, run.width, lineHeight);
} else {
OS.SelectObject(hdc, selBrush);
- OS.PatBlt(hdc, drawX, drawY, run.width, lineHeight - lineSpacing, OS.PATCOPY);
+ OS.PatBlt(hdc, drawX, drawY, run.width, lineHeight, OS.PATCOPY);
}
} else {
if (run.style !is null && run.style.background !is null) {
auto bg = run.style.background.handle;
- int drawRunY = drawY + (baseline - run.ascent);
if (gdip) {
int argb = ((alpha & 0xFF) << 24) | ((bg >> 16) & 0xFF) | (bg & 0xFF00) | ((bg & 0xFF) << 16);
auto color = Gdip.Color_new(argb);
auto brush = Gdip.SolidBrush_new(color);
- Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)brush, drawX, drawRunY, run.width, run.ascent + run.descent);
+ Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)brush, drawX, drawY, run.width, lineHeight);
Gdip.Color_delete(color);
Gdip.SolidBrush_delete(brush);
} else {
auto hBrush = OS.CreateSolidBrush (bg);
auto oldBrush = OS.SelectObject(hdc, hBrush);
- OS.PatBlt(hdc, drawX, drawRunY, run.width, run.ascent + run.descent, OS.PATCOPY);
+ OS.PatBlt(hdc, drawX, drawY, run.width, lineHeight, OS.PATCOPY);
OS.SelectObject(hdc, oldBrush);
OS.DeleteObject(hBrush);
}
@@ -757,8 +767,13 @@
OS.ScriptCPtoX(selEnd, true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX;
rect.right = drawX + runX;
- rect.bottom = drawY + lineHeight - lineSpacing;
+ rect.bottom = drawY + lineHeight;
if (gdip) {
+ if (rect.left > rect.right) {
+ int tmp = rect.left;
+ rect.left = rect.right;
+ rect.right = tmp;
+ }
Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
} else {
OS.SelectObject(hdc, selBrush);
@@ -770,6 +785,7 @@
}
drawX += run.width;
}
+ RECT* borderClip = null;
drawX = alignmentX;
for (int i = 0; i < lineRuns.length; i++) {
StyleItem run = lineRuns[i];
@@ -819,7 +835,7 @@
if ((type & OS.PT_CLOSEFIGURE) !is 0) newType |= Gdip.PathPointTypeCloseSubpath;
types[typeIndex] = cast(byte)newType;
}
- auto path = Gdip.GraphicsPath_new(cast(Gdip.Point[])points, types, count, Gdip.FillModeAlternate);
+ auto path = Gdip.GraphicsPath_new(cast(Gdip.Point*)points.ptr, types.ptr, count, Gdip.FillModeAlternate);
if (path is null) DWT.error(DWT.ERROR_NO_HANDLES);
auto brush = foregroundBrush;
if (fullSelection) {
@@ -865,46 +881,31 @@
Gdip.Graphics_Restore(gdipGraphics, gstate2);
}
Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias);
- if (run.style !is null && (run.style.underline || run.style.strikeout)) {
- auto newPen = hasSelection ? cast(Gdip.Pen)selPen : Gdip.Pen_new(brush, 1);
- Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
- if (run.style.underline) {
- int underlineY = drawY + baseline + 1 - run.style.rise;
- Gdip.Graphics_DrawLine(gdipGraphics, newPen, drawX, underlineY, drawX + run.width, underlineY);
- }
- if (run.style.strikeout) {
- int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
- Gdip.Graphics_DrawLine(gdipGraphics, newPen, drawX, strikeoutY, drawX + run.width, strikeoutY);
- }
- if (cast(void*)newPen !is selPen) Gdip.Pen_delete(newPen);
- Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
- }
+ drawLines(gdip, gdipGraphics, x, drawY + baseline, lineUnderlinePos, drawY + lineHeight, lineRuns, i, brush, null, alpha);
if (partialSelection) {
Gdip.Graphics_Restore(gdipGraphics, gstate);
gstate = Gdip.Graphics_Save(gdipGraphics);
Gdip.Graphics_SetClip(gdipGraphics, &gdipRect, Gdip.CombineModeIntersect);
Gdip.Graphics_SetSmoothingMode(gdipGraphics, textAntialias);
- Gdip.Graphics_FillPath(gdipGraphics, cast(Gdip.Brush)selBrushFg, path);
+ if ((data.style & DWT.MIRRORED) !is 0) {
+ gstate2 = Gdip.Graphics_Save(gdipGraphics);
+ Gdip.Graphics_ScaleTransform(gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend);
+ Gdip.Graphics_TranslateTransform(gdipGraphics, -2 * drawX - run.width, 0, Gdip.MatrixOrderPrepend);
+ }
+ Gdip.Graphics_FillPath(gdipGraphics, selBrushFg, path);
+ if ((data.style & DWT.MIRRORED) !is 0) {
+ Gdip.Graphics_Restore(gdipGraphics, gstate2);
+ }
Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias);
- if (run.style !is null && (run.style.underline || run.style.strikeout)) {
- Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
- if (run.style.underline) {
- int underlineY = drawY + baseline + 1 - run.style.rise;
- Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, underlineY, rect.right, underlineY);
- }
- if (run.style.strikeout) {
- int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
- Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, strikeoutY, rect.right, strikeoutY);
- }
- Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
- }
+ drawLines(gdip, gdipGraphics, x, drawY + baseline, lineUnderlinePos, drawY + lineHeight, lineRuns, i, selBrushFg, &rect, alpha);
Gdip.Graphics_Restore(gdipGraphics, gstate);
}
+ borderClip = drawBorder(gdip, gdipGraphics, x, drawY, lineHeight, foregroundBrush, selBrushFg, fullSelection, borderClip, partialSelection ? &rect : null, alpha, lineRuns, i, selectionStart, selectionEnd);
Gdip.GraphicsPath_delete(path);
if ( brush !is cast(Gdip.Brush)selBrushFg && brush !is cast(Gdip.Brush)foregroundBrush)
Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush);
} else {
- int fg = foreground;
+ auto fg = foreground;
if (fullSelection) {
fg = selectionForeground.handle;
} else {
@@ -912,40 +913,14 @@
}
OS.SetTextColor(hdc, fg);
OS.ScriptTextOut(hdc, run.psc, drawX + offset, drawRunY, 0, null, &run.analysis , null, 0, run.glyphs, run.glyphCount, run.advances, run.justify, run.goffsets);
- if (run.style !is null && (run.style.underline || run.style.strikeout)) {
- auto newPen = hasSelection && fg is selectionForeground.handle ? cast(HPEN)selPen : OS.CreatePen(OS.PS_SOLID, 1, fg);
- auto oldPen = OS.SelectObject(hdc, newPen);
- if (run.style.underline) {
- int underlineY = drawY + baseline + 1 - run.style.rise;
- OS.MoveToEx(hdc, drawX, underlineY, null);
- OS.LineTo(hdc, drawX + run.width, underlineY);
- }
- if (run.style.strikeout) {
- int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
- OS.MoveToEx(hdc, drawX, strikeoutY, null);
- OS.LineTo(hdc, drawX + run.width, strikeoutY);
- }
- OS.SelectObject(hdc, oldPen);
- if (!hasSelection || fg !is selectionForeground.handle) OS.DeleteObject(newPen);
- }
+ drawLines(gdip, hdc, x, drawY + baseline, lineUnderlinePos, drawY + lineHeight, lineRuns, i, cast(void*)fg, null, alpha);
if (partialSelection && fg !is selectionForeground.handle) {
OS.SetTextColor(hdc, selectionForeground.handle);
OS.ScriptTextOut(hdc, run.psc, drawX + offset, drawRunY, OS.ETO_CLIPPED, &rect, &run.analysis , null, 0, run.glyphs, run.glyphCount, run.advances, run.justify, run.goffsets);
- if (run.style !is null && (run.style.underline || run.style.strikeout)) {
- auto oldPen = OS.SelectObject(hdc, selPen);
- if (run.style.underline) {
- int underlineY = drawY + baseline + 1 - run.style.rise;
- OS.MoveToEx(hdc, rect.left, underlineY, null);
- OS.LineTo(hdc, rect.right, underlineY);
- }
- if (run.style.strikeout) {
- int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
- OS.MoveToEx(hdc, rect.left, strikeoutY, null);
- OS.LineTo(hdc, rect.right, strikeoutY);
- }
- OS.SelectObject(hdc, oldPen);
- }
+ drawLines(gdip, hdc, x, drawY + baseline, lineUnderlinePos, drawY + lineHeight, lineRuns, i, cast(void*)selectionForeground.handle, &rect, alpha);
}
+ int selForeground = selectionForeground !is null ? selectionForeground.handle : 0;
+ borderClip = drawBorder(gdip, hdc, x, drawY, lineHeight, cast(void*)foreground, cast(void*)selForeground, fullSelection, borderClip, partialSelection ? &rect : null, alpha, lineRuns, i, selectionStart, selectionEnd);
}
}
}
@@ -955,7 +930,7 @@
if (gdip) {
if (selBrush !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrush);
if (selBrushFg !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrushFg);
- if (selPen !is null) Gdip.Pen_delete(cast(Gdip.Pen)selPen);
+ if (selPen !is null) Gdip.Pen_delete(selPen);
} else {
OS.RestoreDC(hdc, state);
if (gdipGraphics !is null) Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc);
@@ -964,6 +939,355 @@
}
}
+void drawLines(bool advance, void* graphics, int x, int lineBaseline, int lineUnderlinePos, int lineBottom, StyleItem[] line, int index, void* color, RECT* clipRect, int alpha) {
+ StyleItem run = line[index];
+ TextStyle style = run.style;
+ if (style is null) return;
+ if (!style.underline && !style.strikeout) return;
+ int runX = x + run.x;
+ int underlineY = lineBaseline - lineUnderlinePos;
+ int strikeoutY = lineBaseline - run.strikeoutPos;
+ if (advance) {
+ Gdip.Graphics_SetPixelOffsetMode(cast(Gdip.Graphics)graphics, Gdip.PixelOffsetModeNone);
+ auto brush = color;
+ if (style.underline) {
+ if (style.underlineColor !is null) {
+ int fg = style.underlineColor.handle;
+ int argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16);
+ auto gdiColor = Gdip.Color_new(argb);
+ brush = Gdip.SolidBrush_new(gdiColor);
+ Gdip.Color_delete(gdiColor);
+ }
+ switch (style.underlineStyle) {
+ case DWT.UNDERLINE_SQUIGGLE:
+ case DWT.UNDERLINE_ERROR: {
+ int squigglyThickness = 1;
+ int squigglyHeight = 2 * squigglyThickness;
+ int squigglyY = Math.min(underlineY - squigglyHeight / 2, lineBottom - squigglyHeight - 1);
+ int squigglyX = runX;
+ for (int i = index; i > 0 && style.isAdherentUnderline(line[i - 1].style); i--) {
+ squigglyX = x + line[i - 1].x;
+ }
+ int gstate = 0;
+ if (clipRect is null) {
+ gstate = Gdip.Graphics_Save(cast(Gdip.Graphics)graphics);
+ Gdip.Rect gdipRect;
+ gdipRect.X = runX;
+ gdipRect.Y = squigglyY;
+ gdipRect.Width = run.width + 1;
+ gdipRect.Height = squigglyY + squigglyHeight + 1;
+ Gdip.Graphics_SetClip(cast(Gdip.Graphics)graphics, &gdipRect, Gdip.CombineModeIntersect);
+ }
+ int[] points = computePolyline(squigglyX, squigglyY, runX + run.width, squigglyY + squigglyHeight);
+ auto pen = Gdip.Pen_new(cast(Gdip.Brush)brush, squigglyThickness);
+ Gdip.Graphics_DrawLines(cast(Gdip.Graphics)graphics, pen, cast(Gdip.Point*)points.ptr, points.length / 2);
+ Gdip.Pen_delete(pen);
+ if (gstate !is 0) Gdip.Graphics_Restore(cast(Gdip.Graphics)graphics, gstate);
+ break;
+ }
+ case DWT.UNDERLINE_SINGLE:
+ Gdip.Graphics_FillRectangle(cast(Gdip.Graphics)graphics, cast(Gdip.Brush)brush, runX, underlineY, run.width, run.underlineThickness);
+ break;
+ case DWT.UNDERLINE_DOUBLE:
+ Gdip.Graphics_FillRectangle(cast(Gdip.Graphics)graphics, cast(Gdip.Brush)brush, runX, underlineY, run.width, run.underlineThickness);
+ Gdip.Graphics_FillRectangle(cast(Gdip.Graphics)graphics, cast(Gdip.Brush)brush, runX, underlineY + run.underlineThickness * 2, run.width, run.underlineThickness);
+ break;
+ case UNDERLINE_IME_THICK:
+ Gdip.Graphics_FillRectangle(cast(Gdip.Graphics)graphics, cast(Gdip.Brush)brush, runX - run.underlineThickness, underlineY, run.width, run.underlineThickness * 2);
+ break;
+ case UNDERLINE_IME_DOT:
+ case UNDERLINE_IME_DASH: {
+ auto pen = Gdip.Pen_new(cast(Gdip.Brush)brush, 1);
+ int dashStyle = style.underlineStyle is UNDERLINE_IME_DOT ? Gdip.DashStyleDot : Gdip.DashStyleDash;
+ Gdip.Pen_SetDashStyle(pen, dashStyle);
+ Gdip.Graphics_DrawLine(cast(Gdip.Graphics)graphics, pen, runX, underlineY, runX + run.width, underlineY);
+ Gdip.Pen_delete(pen);
+ break;
+ }
+ }
+ if (brush !is color) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush);
+ }
+ if (style.strikeout) {
+ if (style.strikeoutColor !is null) {
+ int fg = style.strikeoutColor.handle;
+ int argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16);
+ auto gdiColor = Gdip.Color_new(argb);
+ brush = Gdip.SolidBrush_new(gdiColor);
+ Gdip.Color_delete(gdiColor);
+ }
+ Gdip.Graphics_FillRectangle(cast(Gdip.Graphics)graphics, cast(Gdip.Brush)brush, runX, strikeoutY, run.width, run.strikeoutThickness);
+ if (brush !is color) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush);
+ }
+ Gdip.Graphics_SetPixelOffsetMode(cast(Gdip.Graphics)graphics, Gdip.PixelOffsetModeHalf);
+ } else {
+ uint colorRefUnderline = cast(uint)color;
+ uint colorRefStrikeout = cast(uint)color;
+ int /*long*/ brushUnderline = 0;
+ int /*long*/ brushStrikeout = 0;
+ RECT rect;
+ if (style.underline) {
+ if (style.underlineColor !is null) {
+ colorRefUnderline = style.underlineColor.handle;
+ }
+ switch (style.underlineStyle) {
+ case DWT.UNDERLINE_SQUIGGLE:
+ case DWT.UNDERLINE_ERROR: {
+ int squigglyThickness = 1;
+ int squigglyHeight = 2 * squigglyThickness;
+ int squigglyY = Math.min(underlineY - squigglyHeight / 2, lineBottom - squigglyHeight - 1);
+ int squigglyX = runX;
+ for (int i = index; i > 0 && style.isAdherentUnderline(line[i - 1].style); i--) {
+ squigglyX = x + line[i - 1].x;
+ }
+ int state = OS.SaveDC(graphics);
+ if (clipRect !is null) {
+ OS.IntersectClipRect(graphics, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
+ } else {
+ OS.IntersectClipRect(graphics, runX, squigglyY, runX + run.width + 1, squigglyY + squigglyHeight + 1);
+ }
+ int[] points = computePolyline(squigglyX, squigglyY, runX + run.width, squigglyY + squigglyHeight);
+ auto pen = OS.CreatePen(OS.PS_SOLID, squigglyThickness, colorRefUnderline);
+ auto oldPen = OS.SelectObject(graphics, pen);
+ OS.Polyline(graphics, cast(POINT*)points.ptr, points.length / 2);
+ int length_ = points.length;
+ if (length_ >= 2 && squigglyThickness <= 1) {
+ OS.SetPixel (graphics, points[length_ - 2], points[length_ - 1], colorRefUnderline);
+ }
+ OS.RestoreDC(graphics, state);
+ OS.SelectObject(graphics, oldPen);
+ OS.DeleteObject(pen);
+ break;
+ }
+ case DWT.UNDERLINE_SINGLE:
+ brushUnderline = cast(uint) OS.CreateSolidBrush(colorRefUnderline);
+ OS.SetRect(&rect, runX, underlineY, runX + run.width, underlineY + run.underlineThickness);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.FillRect(graphics, &rect, cast(void*)brushUnderline);
+ break;
+ case DWT.UNDERLINE_DOUBLE:
+ brushUnderline = cast(uint)OS.CreateSolidBrush(colorRefUnderline);
+ OS.SetRect(&rect, runX, underlineY, runX + run.width, underlineY + run.underlineThickness);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.FillRect(graphics, &rect, cast(void*)brushUnderline);
+ OS.SetRect(&rect, runX, underlineY + run.underlineThickness * 2, runX + run.width, underlineY + run.underlineThickness * 3);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.FillRect(graphics, &rect, cast(void*)brushUnderline);
+ break;
+ case UNDERLINE_IME_THICK:
+ brushUnderline = cast(uint)OS.CreateSolidBrush(colorRefUnderline);
+ OS.SetRect(&rect, runX, underlineY - run.underlineThickness, runX + run.width, underlineY + run.underlineThickness);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.FillRect(graphics, &rect, cast(void*)brushUnderline);
+ break;
+ case UNDERLINE_IME_DASH:
+ case UNDERLINE_IME_DOT: {
+ underlineY = lineBaseline + run.descent;
+ int penStyle = style.underlineStyle is UNDERLINE_IME_DASH ? OS.PS_DASH : OS.PS_DOT;
+ auto pen = OS.CreatePen(penStyle, 1, colorRefUnderline);
+ auto oldPen = OS.SelectObject(graphics, pen);
+ OS.SetRect(&rect, runX, underlineY, runX + run.width, underlineY + run.underlineThickness);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.MoveToEx(graphics, rect.left, rect.top, null);
+ OS.LineTo(graphics, rect.right, rect.top);
+ OS.SelectObject(graphics, oldPen);
+ OS.DeleteObject(pen);
+ break;
+ }
+ }
+ }
+ if (style.strikeout) {
+ if (style.strikeoutColor !is null) {
+ colorRefStrikeout = style.strikeoutColor.handle;
+ }
+ if (brushUnderline !is 0 && colorRefStrikeout is colorRefUnderline) {
+ brushStrikeout = brushUnderline;
+ } else {
+ brushStrikeout = cast(int) OS.CreateSolidBrush(colorRefStrikeout);
+ }
+ OS.SetRect(&rect, runX, strikeoutY, runX + run.width, strikeoutY + run.strikeoutThickness);
+ if (clipRect !is null) {
+ rect.left = Math.max(rect.left, clipRect.left);
+ rect.right = Math.min(rect.right, clipRect.right);
+ }
+ OS.FillRect(graphics, &rect, cast(void*)brushStrikeout);
+ }
+ if (brushUnderline !is 0) OS.DeleteObject(cast(void*)brushUnderline);
+ if (brushStrikeout !is 0 && brushStrikeout !is brushUnderline) OS.DeleteObject(cast(void*)brushStrikeout);
+ }
+}
+
+RECT* drawBorder(bool advance, void* graphics, int x, int y, int lineHeight, void* color, void* selectionColor, bool fullSelection, RECT* clipRect, RECT* rect, int alpha, StyleItem[] line, int index, int selectionStart, int selectionEnd) {
+ StyleItem run = line[index];
+ TextStyle style = run.style;
+ if (style is null) return null;
+ if (style.borderStyle is DWT.NONE) return null;
+ if (rect !is null) {
+ if (clipRect is null) {
+ clipRect = new RECT ();
+ OS.SetRect(clipRect, -1, rect.top, -1, rect.bottom);
+ }
+ bool isRTL = (orientation & DWT.RIGHT_TO_LEFT) !is 0;
+ if (run.start <= selectionStart && selectionStart <= run.start + run.length) {
+ if (run.analysis.fRTL ^ isRTL) {
+ clipRect.right = rect.left;
+ } else {
+ clipRect.left = rect.left;
+ }
+ }
+ if (run.start <= selectionEnd && selectionEnd <= run.start + run.length) {
+ if (run.analysis.fRTL ^ isRTL) {
+ clipRect.left = rect.right;
+ } else {
+ clipRect.right = rect.right;
+ }
+ }
+ }
+ if (index + 1 >= line.length || !style.isAdherentBorder(line[index + 1].style)) {
+ int left = run.x;
+ for (int i = index; i > 0 && style.isAdherentBorder(line[i - 1].style); i--) {
+ left = line[i - 1].x;
+ }
+ if (advance) {
+ auto brush = color;
+ int customColor = -1;
+ if (style.borderColor !is null) {
+ customColor = style.borderColor.handle;
+ } else {
+ if (style.foreground !is null) {
+ customColor = style.foreground.handle;
+ }
+ if (fullSelection && clipRect is null) {
+ customColor = -1;
+ brush = selectionColor;
+ }
+ }
+ if (customColor !is -1) {
+ int argb = ((alpha & 0xFF) << 24) | ((customColor >> 16) & 0xFF) | (customColor & 0xFF00) | ((customColor & 0xFF) << 16);
+ auto gdiColor = Gdip.Color_new(argb);
+ brush = Gdip.SolidBrush_new(gdiColor);
+ Gdip.Color_delete(gdiColor);
+ }
+ int lineWidth = 1;
+ int lineStyle = Gdip.DashStyleSolid;
+ switch (style.borderStyle) {
+ case DWT.BORDER_SOLID: break;
+ case DWT.BORDER_DASH: lineStyle = Gdip.DashStyleDash; break;
+ case DWT.BORDER_DOT: lineStyle = Gdip.DashStyleDot; break;
+ }
+ auto pen = Gdip.Pen_new(cast(Gdip.Brush)brush, lineWidth);
+ Gdip.Pen_SetDashStyle(pen, lineStyle);
+ float gdipXOffset = 0.5f, gdipYOffset = 0.5f;
+ Gdip.Graphics_TranslateTransform(cast(Gdip.Graphics)graphics, gdipXOffset, gdipYOffset, Gdip.MatrixOrderPrepend);
+ if (style.borderColor is null && clipRect !is null) {
+ int gstate = Gdip.Graphics_Save(cast(Gdip.Graphics)graphics);
+ if (clipRect.left is -1) clipRect.left = 0;
+ if (clipRect.right is -1) clipRect.right = 0x7ffff;
+ Gdip.Rect gdipRect;
+ gdipRect.X = clipRect.left;
+ gdipRect.Y = clipRect.top;
+ gdipRect.Width = clipRect.right - clipRect.left;
+ gdipRect.Height = clipRect.bottom - clipRect.top;
+ Gdip.Graphics_SetClip(cast(Gdip.Graphics)graphics, &gdipRect, Gdip.CombineModeExclude);
+ Gdip.Graphics_DrawRectangle(cast(Gdip.Graphics)graphics, pen, x + left, y, run.x + run.width - left - 1, lineHeight - 1);
+ Gdip.Graphics_Restore(cast(Gdip.Graphics)graphics, gstate);
+ gstate = Gdip.Graphics_Save(cast(Gdip.Graphics)graphics);
+ Gdip.Graphics_SetClip(cast(Gdip.Graphics)graphics, &gdipRect, Gdip.CombineModeIntersect);
+ auto selPen = Gdip.Pen_new(cast(Gdip.Brush)selectionColor, lineWidth);
+ Gdip.Pen_SetDashStyle(pen, lineStyle);
+ Gdip.Graphics_DrawRectangle(cast(Gdip.Graphics)graphics, selPen, x + left, y, run.x + run.width - left - 1, lineHeight - 1);
+ Gdip.Pen_delete(selPen);
+ Gdip.Graphics_Restore(cast(Gdip.Graphics)graphics, gstate);
+ } else {
+ Gdip.Graphics_DrawRectangle(cast(Gdip.Graphics)graphics, pen, x + left, y, run.x + run.width - left - 1, lineHeight - 1);
+ }
+ Gdip.Graphics_TranslateTransform(cast(Gdip.Graphics)graphics, -gdipXOffset, -gdipYOffset, Gdip.MatrixOrderPrepend);
+ Gdip.Pen_delete(pen);
+ if (customColor !is -1) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush);
+ } else {
+ if (style.borderColor !is null) {
+ color = cast(void*)style.borderColor.handle;
+ } else {
+ if (style.foreground !is null) {
+ color = cast(void*)style.foreground.handle;
+ }
+ if (fullSelection && clipRect is null) {
+ color = selectionColor;
+ }
+ }
+ int lineWidth = 1;
+ int lineStyle = OS.PS_SOLID;
+ switch (style.borderStyle) {
+ case DWT.BORDER_SOLID: break;
+ case DWT.BORDER_DASH: lineStyle = OS.PS_DASH; break;
+ case DWT.BORDER_DOT: lineStyle = OS.PS_DOT; break;
+ }
+ LOGBRUSH logBrush;
+ logBrush.lbStyle = OS.BS_SOLID;
+ logBrush.lbColor = cast(uint)color;
+ auto newPen = OS.ExtCreatePen(lineStyle | OS.PS_GEOMETRIC, Math.max(1, lineWidth), &logBrush, 0, null);
+ auto oldPen = OS.SelectObject(graphics, newPen);
+ auto oldBrush = OS.SelectObject(graphics, OS.GetStockObject(OS.NULL_BRUSH));
+ OS.Rectangle(graphics, x + left, y, x + run.x + run.width, y + lineHeight);
+ if (style.borderColor is null && clipRect !is null && color !is selectionColor) {
+ int state = OS.SaveDC(graphics);
+ if (clipRect.left is -1) clipRect.left = 0;
+ if (clipRect.right is -1) clipRect.right = 0x7ffff;
+ OS.IntersectClipRect(graphics, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
+ logBrush.lbColor = cast(uint)selectionColor;
+ auto selPen = OS.ExtCreatePen (lineStyle | OS.PS_GEOMETRIC, Math.max(1, lineWidth), &logBrush, 0, null);
+ OS.SelectObject(graphics, selPen);
+ OS.Rectangle(graphics, x + left, y, x + run.x + run.width, y + lineHeight);
+ OS.RestoreDC(graphics, state);
+ OS.SelectObject(graphics, newPen);
+ OS.DeleteObject(selPen);
+ }
+ OS.SelectObject(graphics, oldBrush);
+ OS.SelectObject(graphics, oldPen);
+ OS.DeleteObject(newPen);
+ }
+ return null;
+ }
+ return clipRect;
+}
+
+int[] computePolyline(int left, int top, int right, int bottom) {
+ int height = bottom - top; // can be any number
+ int width = 2 * height; // must be even
+ int peaks = Compatibility.ceil(right - left, width);
+ if (peaks is 0 && right - left > 2) {
+ peaks = 1;
+ }
+ int length_ = ((2 * peaks) + 1) * 2;
+ if (length_ < 0) return new int[0];
+
+ int[] coordinates = new int[length_];
+ for (int i = 0; i < peaks; i++) {
+ int index = 4 * i;
+ coordinates[index] = left + (width * i);
+ coordinates[index+1] = bottom;
+ coordinates[index+2] = coordinates[index] + width / 2;
+ coordinates[index+3] = top;
+ }
+ coordinates[length_-2] = left + (width * peaks);
+ coordinates[length_-1] = bottom;
+ return coordinates;
+}
+
void freeRuns () {
if (allRuns is null) return;
for (int i=0; iDWT.UNDERLINE_SINGLE
.
+ *
*
* @since 3.1
*/
public bool underline;
/**
+ * the underline color of the style
+ *
+ * @since 3.4
+ */
+ public Color underlineColor;
+
+ /**
+ * the underline style. This style is ignored when
+ * underline
is false.
+ *
+ * This value should be one of DWT.UNDERLINE_SINGLE
,
+ * DWT.UNDERLINE_DOUBLE
, DWT.UNDERLINE_ERROR
,
+ * or DWT.UNDERLINE_SQUIGGLE
.
+ *
DWT.NONE
.
+ *
+ * This value should be one of DWT.BORDER_SOLID
,
+ * DWT.BORDER_DASH
,DWT.BORDER_DOT
or
+ * DWT.NONE
.
+ *
ALL_PAGES
PrinterData.ALL_PAGES
PAGE_RANGE
PrinterData.PAGE_RANGE
SELECTION
PrinterData.SELECTION
ALL_PAGES
PrinterData.ALL_PAGES
PAGE_RANGE
PrinterData.PAGE_RANGE
SELECTION
PrinterData.SELECTION
* This value can be from 1 to the maximum number of pages for the platform.
- * Note that it is only valid if the scope is PAGE_RANGE
.
+ * Note that it is only valid if the scope is PrinterData.PAGE_RANGE
.
*
* This value can be from 1 to the maximum number of pages for the platform.
- * Note that it is only valid if the scope is PAGE_RANGE
.
+ * Note that it is only valid if the scope is PrinterData.PAGE_RANGE
.
*
* This value can be from 1 to the maximum number of pages for the platform.
- * Note that it is only valid if the scope is PAGE_RANGE
.
+ * Note that it is only valid if the scope is PrinterData.PAGE_RANGE
.
*
* This value can be from 1 to the maximum number of pages for the platform.
- * Note that it is only valid if the scope is PAGE_RANGE
.
+ * Note that it is only valid if the scope is PrinterData.PAGE_RANGE
.
*
PrintDialog
.
+ * On GTK, this contains a copy of the print_settings and page_setup
+ * returned from the PrintDialog
.
+ * On OS X Carbon, this contains a copy of the PrintSettings and PageFormat
+ * returned from the PrintDialog
.
* This field is not currently used on the X/Window System.
*/
byte [] otherData;
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/program/Program.d
--- a/dwt/program/Program.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/program/Program.d Sat May 17 17:34:28 2008 +0200
@@ -42,10 +42,11 @@
TCHAR[] pszOut = NewTCHARs(0, 1024);
uint[1] pcchOut;
pcchOut[0] = pszOut.length;
- int result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr);
+ int flags = OS.ASSOCF_NOTRUNCATE | OS.ASSOCF_INIT_IGNOREUNKNOWN;
+ int result = OS.AssocQueryString (flags, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr);
if (result is OS.E_POINTER) {
pszOut = NewTCHARs(0, pcchOut [0]);
- result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr);
+ result = OS.AssocQueryString (flags, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr);
}
if (result is 0) {
if (!OS.IsWinCE && expand) {
@@ -252,13 +253,12 @@
}
/**
- * Launches the executable associated with the file in
- * the operating system. If the file is an executable,
- * then the executable is launched. Note that a Display
- * must already exist to guarantee that this method returns
- * an appropriate result.
+ * Launches the operating system executable associated with the file or
+ * URL (http:// or https://). If the file is an executable then the
+ * executable is launched. Note that a Display
must already
+ * exist to guarantee that this method returns an appropriate result.
*
- * @param fileName the file or program name
+ * @param fileName the file or program name or URL (http:// or https://)
* @return true
if the file is launched, otherwise false
*
* @exception IllegalArgumentException true
if the receiver is grayed,
+ * and false otherwise. When the widget does not have
+ * the CHECK
style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception DWTException DWT.COMMAND
, the message text
* is displayed to provide further information for the user.
@@ -980,16 +1080,10 @@
checkWidget ();
if ((style & (DWT.CHECK | DWT.RADIO | DWT.TOGGLE)) is 0) return;
int flags = selected ? OS.BST_CHECKED : OS.BST_UNCHECKED;
- /*
- * Feature in Windows. When BM_SETCHECK is used
- * to set the checked state of a radio or check
- * button, it sets the WM_TABSTOP style. This
- * is undocumented and unwanted. The fix is
- * to save and restore the window style bits.
- */
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- OS.SendMessage (handle, OS.BM_SETCHECK, flags, 0);
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ if ((style & DWT.CHECK) !is 0) {
+ if (selected && grayed) flags = OS.BST_INDETERMINATE;
+ }
+ updateSelection (flags);
}
/**
@@ -1038,6 +1132,35 @@
_setText (string);
}
+void updateSelection (int flags) {
+ if (flags !is OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0)) {
+ /*
+ * Feature in Windows. When BM_SETCHECK is used
+ * to set the checked state of a radio or check
+ * button, it sets the WM_TABSTOP style. This
+ * is undocumented and unwanted. The fix is
+ * to save and restore the window style bits.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((style & DWT.CHECK) !is 0) {
+ if (flags is OS.BST_INDETERMINATE) {
+ bits &= ~OS.BS_CHECKBOX;
+ bits |= OS.BS_3STATE;
+ } else {
+ bits |= OS.BS_CHECKBOX;
+ bits &= ~OS.BS_3STATE;
+ }
+ if (bits !is OS.GetWindowLong (handle, OS.GWL_STYLE)) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ }
+ OS.SendMessage (handle, OS.BM_SETCHECK, flags, 0);
+ if (bits !is OS.GetWindowLong (handle, OS.GWL_STYLE)) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ }
+}
+
override int widgetStyle () {
int bits = super.widgetStyle ();
if ((style & DWT.FLAT) !is 0) bits |= OS.BS_FLAT;
@@ -1184,7 +1307,7 @@
}
if (redraw) {
OS.InvalidateRect (handle, null, false);
- int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
+ int /*long*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
return new LRESULT (code);
}
}
@@ -1193,7 +1316,7 @@
}
override LRESULT wmCommandChild (int wParam, int lParam) {
- int code = wParam >> 16;
+ int code = OS.HIWORD (wParam);
switch (code) {
case OS.BN_CLICKED:
case OS.BN_DOUBLECLICKED:
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Canvas.d
--- a/dwt/widgets/Canvas.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Canvas.d Sat May 17 17:34:28 2008 +0200
@@ -24,6 +24,7 @@
import dwt.widgets.Caret;
import dwt.widgets.Control;
import dwt.widgets.Display;
+import dwt.widgets.IME;
import dwt.dwthelper.utils;
@@ -53,6 +54,7 @@
alias Composite.windowProc windowProc;
Caret caret;
+ IME ime;
/**
* Prevents uninitialized instances from being created outside the package.
@@ -103,37 +105,6 @@
}
/**
- * Returns the caret.
- * - * The caret for the control is automatically hidden - * and shown when the control is painted or resized, - * when focus is gained or lost and when an the control - * is scrolled. To avoid drawing on top of the caret, - * the programmer must hide and show the caret when - * drawing in the window any other time. - *
- * - * @return the caret - * - * @exception DWTException+ * The caret for the control is automatically hidden + * and shown when the control is painted or resized, + * when focus is gained or lost and when an the control + * is scrolled. To avoid drawing on top of the caret, + * the programmer must hide and show the caret when + * drawing in the window any other time. + *
+ * + * @return the caret + * + * @exception DWTExceptiontrue
,
+ * and marks it invisible otherwise.
+ * + * If one of the receiver's ancestors is not visible or some + * other condition makes the receiver not visible, marking + * it visible may not actually cause it to be displayed. + *
+ * + * @param visible the new visibility state + * + * @exception DWTExceptiontrue
,
- * and marks it invisible otherwise.
- * - * If one of the receiver's ancestors is not visible or some - * other condition makes the receiver not visible, marking - * it visible may not actually cause it to be displayed. - *
- * - * @param visible the new visibility state - * - * @exception DWTExceptionDWT.LEFT_TO_RIGHT
or DWT.RIGHT_TO_LEFT
.
* @@ -1778,7 +1786,7 @@ start = wcsToMbcsPos (start); end = wcsToMbcsPos (end); } - int bits = (start & 0xFFFF) | ((end << 16) & 0xFFFF0000); + int /*long*/ bits = OS.MAKELPARAM (start, end); OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits); } @@ -1814,7 +1822,7 @@ int limit = LIMIT; auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); if (hwndText !is null) { - limit = OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0); + limit = OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF; } if (string.length > limit) string = string.substring (0, limit); TCHAR* buffer = StrToTCHARz( string ); @@ -1893,11 +1901,11 @@ auto newProc = display.windowProc; auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); if (hwndText !is null) { - OS.SetWindowLong (hwndText, OS.GWL_WNDPROC, newProc); + OS.SetWindowLongPtr (hwndText, OS.GWLP_WNDPROC, newProc); } auto hwndList = OS.GetDlgItem (handle, CBID_LIST); if (hwndList !is null) { - OS.SetWindowLong (hwndList, OS.GWL_WNDPROC, newProc); + OS.SetWindowLongPtr (hwndList, OS.GWLP_WNDPROC, newProc); } } @@ -1907,7 +1915,7 @@ * to select an item in the list and escape to close * the combo box. */ - switch (msg.wParam) { + switch ((msg.wParam)) { case OS.VK_RETURN: case OS.VK_ESCAPE: if ((style & DWT.DROP_DOWN) !is 0) { @@ -1944,11 +1952,11 @@ super.unsubclass (); auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); if (hwndText !is null && EditProc !is null) { - OS.SetWindowLong (hwndText, OS.GWL_WNDPROC, cast(int) EditProc); + OS.SetWindowLongPtr (hwndText, OS.GWLP_WNDPROC, cast(LONG_PTR)EditProc); } auto hwndList = OS.GetDlgItem (handle, CBID_LIST); if (hwndList !is null && ListProc !is null) { - OS.SetWindowLong (hwndList, OS.GWL_WNDPROC, cast(int) ListProc); + OS.SetWindowLongPtr (hwndList, OS.GWLP_WNDPROC, cast(LONG_PTR)ListProc); } } @@ -2107,7 +2115,7 @@ } override LRESULT WM_GETDLGCODE (int wParam, int lParam) { - int code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam); + int /*long*/ code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam); return new LRESULT (code | OS.DLGC_WANTARROWS); } @@ -2164,6 +2172,16 @@ override LRESULT WM_SIZE (int wParam, int lParam) { /* + * Feature in Windows. When a combo box is resized, + * the size of the drop down rectangle is specified + * using the height and then the combo box resizes + * to be the height of the text field. This causes + * two WM_SIZE messages to be sent and two DWT.Resize + * events to be issued. The fix is to ignore the + * second resize. + */ + if (ignoreResize) return null; + /* * Bug in Windows. If the combo box has the CBS_SIMPLE style, * the list portion of the combo box is not redrawn when the * combo box is resized. The fix is to force a redraw when @@ -2221,7 +2239,7 @@ if (isDisposed ()) return result; if (buffer !is null) { OS.SetWindowText (handle, buffer.ptr); - int bits = (start & 0xFFFF) | ((end << 16) & 0xFFFF0000); + int /*long*/ bits = OS.MAKELPARAM (start, end); OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits); if (redraw) setRedraw (true); } @@ -2236,6 +2254,56 @@ return result; } +override LRESULT WM_WINDOWPOSCHANGING (int /*long*/ wParam, int /*long*/ lParam) { + LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam); + if (result !is null) return result; + /* + * Feature in Windows. When a combo box is resized, + * the size of the drop down rectangle is specified + * using the height and then the combo box resizes + * to be the height of the text field. This causes + * sibling windows that intersect with the original + * bounds to redrawn. The fix is to stop the redraw + * using SWP_NOREDRAW and then damage the combo box + * text field and the area in the parent where the + * combo box used to be. + */ + if (OS.IsWinCE) return result; + if (drawCount !is 0) return result; + if (!OS.IsWindowVisible (handle)) return result; + if (ignoreResize) { + WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam; + if ((lpwp.flags & OS.SWP_NOSIZE) is 0) { + lpwp.flags |= OS.SWP_NOREDRAW; + OS.InvalidateRect (handle, null, true); + RECT rect; + OS.GetWindowRect (handle, &rect); + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + if (width !is 0 && height !is 0) { + auto hwndParent = parent.handle; + auto hwndChild = OS.GetWindow (hwndParent, OS.GW_CHILD); + OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); + auto rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom); + while (hwndChild !is null) { + if (hwndChild !is handle) { + OS.GetWindowRect (hwndChild, &rect); + OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); + auto rgn2 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom); + OS.CombineRgn (rgn1, rgn1, rgn2, OS.RGN_DIFF); + OS.DeleteObject (rgn2); + } + hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT); + } + int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; + OS.RedrawWindow (hwndParent, null, rgn1, flags); + OS.DeleteObject (rgn1); + } + } + } + return result; +} + override LRESULT wmChar (HWND hwnd, int wParam, int lParam) { if (ignoreCharacter) return null; LRESULT result = super.wmChar (hwnd, wParam, lParam); @@ -2345,7 +2413,7 @@ } override LRESULT wmCommandChild (int wParam, int lParam) { - int code = wParam >> 16; + int code = OS.HIWORD (wParam); switch (code) { case OS.CBN_EDITCHANGE: if (ignoreModify) break; @@ -2429,7 +2497,7 @@ * them to the application. */ ignoreCharacter = true; - int result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam); + int /*long*/ result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam); MSG msg; int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE; while (OS.PeekMessage (&msg, hwnd, OS.WM_CHAR, OS.WM_CHAR, flags)) { @@ -2472,7 +2540,7 @@ if (result !is null) return result; if ((style & DWT.READ_ONLY) is 0) { if (wParam is OS.VK_DOWN) { - int code = callWindowProc (hwnd, OS.WM_SYSKEYDOWN, wParam, lParam); + int /*long*/ code = callWindowProc (hwnd, OS.WM_SYSKEYDOWN, wParam, lParam); int newSelection = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0); if (oldSelection !is newSelection) { sendEvent (DWT.Modify); diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Composite.d Sat May 17 17:34:28 2008 +0200 @@ -31,6 +31,7 @@ import dwt.widgets.Event; import dwt.widgets.ToolTip; import dwt.widgets.Display; +import dwt.widgets.Widget; import dwt.dwthelper.System; import dwt.dwthelper.utils; @@ -67,11 +68,11 @@ public class Composite : Scrollable { + alias Scrollable.setBounds setBounds; alias Scrollable.computeSize computeSize; alias Scrollable.translateMnemonic translateMnemonic; Layout layout_; - HFONT font; WINDOWPOS* [] lpwp; Control [] tabList; int layoutCount, backgroundMode; @@ -211,6 +212,17 @@ } } +void checkComposited () { + if ((state & CANVAS) !is 0) { + if ((style & DWT.TRANSPARENT) !is 0) { + auto hwndParent = parent.handle; + int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE); + bits |= OS.WS_EX_COMPOSITED; + OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits); + } + } +} + override protected void checkSubclass () { /* Do nothing - Subclassing is allowed */ } @@ -254,12 +266,75 @@ return new Point (trim.width, trim.height); } +/** + * Copies a rectangular area of the receiver at the specified + * position using the gc. + * + * @param gc the gc where the rectangle is to be filled + * @param x the x coordinate of the rectangle to be filled + * @param y the y coordinate of the rectangle to be filled + * @param width the width of the rectangle to be filled + * @param height the height of the rectangle to be filled + * + * @exception IllegalArgumentException
true
, causes the receiver to have
* all mouse events delivered to it until the method is called with
- * false
as the argument.
+ * false
as the argument. Note that on some platforms,
+ * a mouse button must currently be down for capture to be assigned.
*
* @param capture true
to capture the mouse, and false
to release it
*
@@ -2640,7 +2720,7 @@
}
void setCursor () {
- int lParam = OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16);
+ int /*long*/ lParam = OS.MAKELPARAM (OS.HTCLIENT, OS.WM_MOUSEMOVE);
OS.SendMessage (handle, OS.WM_SETCURSOR, handle, lParam);
}
@@ -2668,7 +2748,7 @@
if (cursor !is null && cursor.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
this.cursor = cursor;
static if (OS.IsWinCE) {
- int hCursor = cursor !is null ? cursor.handle : 0;
+ int /*long*/ hCursor = cursor !is null ? cursor.handle : 0;
OS.SetCursor (hCursor);
return;
}
@@ -2797,6 +2877,7 @@
if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
hFont = font.handle;
}
+ this.font = font;
if (hFont is null) hFont = defaultFont ();
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);
}
@@ -3010,6 +3091,36 @@
}
}
+/**
+ * Sets the shape of the control to the region specified
+ * by the argument. When the argument is null, the
+ * default shape of the control is restored.
+ *
+ * @param region the region that defines the shape of the control (or null)
+ *
+ * @exception IllegalArgumentException + * This is the recommended way to set the date, because setting the year, + * month, and day separately may result in invalid intermediate dates. + *
+ * + * @param year an integer between 1752 and 9999 + * @param month an integer between 0 and 11 + * @param day a positive integer beginning with 1 + * + * @exception DWTException* The first day of the month is 1, and the last day depends on the month and year. @@ -658,6 +707,7 @@ msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; systime.wDay = cast(short)day; OS.SendMessage (handle, msg, 0, &systime); + lastSystemTime = null; } /** @@ -681,6 +731,7 @@ msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; systime.wHour = cast(short)hours; OS.SendMessage (handle, msg, 0, &systime); + if ((style & DWT.CALENDAR) !is 0 && hours >= 0 && hours <= 23) time.wHour = cast(short)hours; } /** @@ -704,6 +755,7 @@ msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; systime.wMinute = cast(short)minutes; OS.SendMessage (handle, msg, 0, &systime); + if ((style & DWT.CALENDAR) !is 0 && minutes >= 0 && minutes <= 59) time.wMinute = cast(short)minutes; } /** @@ -727,6 +779,7 @@ msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; systime.wMonth = cast(short)(month + 1); OS.SendMessage (handle, msg, 0, &systime); + lastSystemTime = null; } /** @@ -750,6 +803,41 @@ msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; systime.wSecond = cast(short)seconds; OS.SendMessage (handle, msg, 0, &systime); + if ((style & DWT.CALENDAR) !is 0 && seconds >= 0 && seconds <= 59) time.wSecond = cast(short)seconds; +} + +/** + * Sets the receiver's hours, minutes, and seconds in a single operation. + * + * @param hours an integer between 0 and 23 + * @param minutes an integer between 0 and 59 + * @param seconds an integer between 0 and 59 + * + * @exception DWTException
DWTError.error
to handle the error.
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/DirectoryDialog.d
--- a/dwt/widgets/DirectoryDialog.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/DirectoryDialog.d Sat May 17 17:34:28 2008 +0200
@@ -58,7 +58,7 @@
* syncExec
* or null if no such runnable is currently being invoked by
* the user-interface thread.
@@ -2182,8 +2230,10 @@
*
*/
public Thread getSyncThread () {
- if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
- return synchronizer.syncThread;
+ synchronized (Device.classinfo) {
+ if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+ }
}
/**
@@ -2414,8 +2464,10 @@
*
*/
public Thread getThread () {
- if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
- return thread;
+ synchronized (Device.classinfo) {
+ if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+ }
}
HTHEME hButtonTheme () {
@@ -2475,7 +2527,7 @@
data.style |= DWT.LEFT_TO_RIGHT;
}
data.device = this;
- data.hFont = getSystemFont ().handle;
+ data.font = getSystemFont ();
}
return hDC;
}
@@ -2513,6 +2565,29 @@
lpWndClass.lpfnWndProc = &windowProcFunc;
lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW);
+
+
+ //DWT_TODO: Check if this can be disabled for DWT
+ /+
+ /*
+ * Set the default icon for the window class to IDI_APPLICATION.
+ * This is not necessary for native Windows applications but
+ * versions of Java starting at JDK 1.6 set the icon in the
+ * executable instead of leaving the default.
+ */
+ if (!OS.IsWinCE && Library.JAVA_VERSION >= Library.JAVA_VERSION (1, 6, 0)) {
+ TCHAR[] lpszFile = NewTCHARs (0, OS.MAX_PATH);
+ while (OS.GetModuleFileName (0, lpszFile.ptr, lpszFile.length) is lpszFile.length) {
+ lpszFile = NewTCHARs (0, lpszFile.length + OS.MAX_PATH);
+ }
+ if (OS.ExtractIconEx (lpszFile.ptr, -1, null, null, 1) !is 0) {
+ String fileName = TCHARzToStr( lpszFile.ptr );
+ if (fileName.endsWith ("java.exe") || fileName.endsWith ("javaw.exe")) { //$NON-NLS-1$ //$NON-NLS-2$
+ lpWndClass.hIcon = OS.LoadIcon (0, OS.IDI_APPLICATION);
+ }
+ }
+ }
+ +/
int byteCount = windowClass_.length * TCHAR.sizeof;
lpWndClass.lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (lpWndClass.lpszClassName, windowClass_.ptr, byteCount);
@@ -2520,7 +2595,9 @@
OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
/* Register the DWT drop shadow window class */
- if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) lpWndClass.style |= OS.CS_DROPSHADOW;
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
+ lpWndClass.style |= OS.CS_DROPSHADOW;
+ }
byteCount = windowShadowClass.length * TCHAR.sizeof;
lpWndClass.lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (lpWndClass.lpszClassName, windowShadowClass.ptr, byteCount);
@@ -2540,7 +2617,7 @@
//messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$
//messageProc_ = messageCallback.getAddress ();
//if (messageProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
- OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, cast(int) &messageProcFunc);
+ OS.SetWindowLongPtr (hwndMessage, OS.GWLP_WNDPROC, cast(LONG_PTR) &messageProcFunc);
/* Create the filter hook */
static if (!OS.IsWinCE) {
@@ -2561,6 +2638,7 @@
/* Register custom messages message */
SWT_TASKBARCREATED = OS.RegisterWindowMessage (StrToTCHARz ( "TaskbarCreated" ));
SWT_RESTORECARET = OS.RegisterWindowMessage (StrToTCHARz ( "SWT_RESTORECARET"));
+ DI_GETDRAGIMAGE = OS.RegisterWindowMessage (StrToTCHARz ( "ShellGetDragImage")); //$NON-NLS-1$
/* Initialize OLE */
static if (!OS.IsWinCE) OS.OleInitialize (null);
@@ -2988,9 +3066,10 @@
*/
if (wParam !is 0) {
if (!isXMouseActive ()) {
- if (modalDialogShell !is null && modalDialogShell.isDisposed ()) modalDialogShell = null;
- Shell modal = modalDialogShell !is null ? modalDialogShell : getModalShell ();
- if (modal !is null) {
+ auto hwndActive = OS.GetActiveWindow ();
+ if (hwndActive !is null && OS.IsWindowEnabled (hwndActive)) break;
+ Shell modal = modalDialog !is null ? modalDialog.parent : getModalShell ();
+ if (modal !is null && !modal.isDisposed ()) {
auto hwndModal = modal.handle;
if (OS.IsWindowEnabled (hwndModal)) {
modal.bringToTop ();
@@ -3017,7 +3096,8 @@
* to run. In order to avoid running code after the display
* has been disposed, exit from Java.
*/
- System.exit (0);
+ /* This code is intentionally commented */
+// System.exit (0);
}
break;
}
@@ -3027,7 +3107,15 @@
if (!event.doit) return 0;
break;
}
+ case OS.WM_DWMCOLORIZATIONCOLORCHANGED: {
+ OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null);
+ break;
+ }
case OS.WM_SETTINGCHANGE: {
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
+ OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null);
+ break;
+ }
switch (wParam) {
case 0:
case 1:
@@ -3107,9 +3195,10 @@
int msgFilterProc (int code, int wParam, int lParam) {
switch (code) {
case OS.MSGF_COMMCTRL_BEGINDRAG: {
- if (!runDragDrop) {
- hookMsg = *cast(MSG*)lParam;
+ if (!runDragDrop && !dragCancelled) {
+ *hookMsg = *cast(MSG*)lParam;
if (hookMsg.message is OS.WM_MOUSEMOVE) {
+ dragCancelled = true;
OS.SendMessage (hookMsg.hwnd, OS.WM_CANCELMODE, 0, 0);
}
}
@@ -3131,7 +3220,7 @@
case OS.MSGF_SCROLLBAR:
case OS.MSGF_SIZE: {
if (runMessages) {
- hookMsg = *cast(MSG*)lParam;
+ *hookMsg = *cast(MSG*)lParam;
if (hookMsg.message is OS.WM_NULL) {
MSG msg;
int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
@@ -3224,118 +3313,120 @@
*
*/
public bool post (Event event) {
- if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
- if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
- int type = event.type;
- switch (type){
- case DWT.KeyDown:
- case DWT.KeyUp: {
+ synchronized (Device.classinfo) {
+ if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+ if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
+ int type = event.type;
+ switch (type){
+ case DWT.KeyDown:
+ case DWT.KeyUp: {
KEYBDINPUT inputs;
inputs.wVk = cast(short) untranslateKey (event.keyCode);
- if (inputs.wVk is 0) {
- char key = event.character;
- switch (key) {
- case DWT.BS: inputs.wVk = cast(short) OS.VK_BACK; break;
- case DWT.CR: inputs.wVk = cast(short) OS.VK_RETURN; break;
- case DWT.DEL: inputs.wVk = cast(short) OS.VK_DELETE; break;
- case DWT.ESC: inputs.wVk = cast(short) OS.VK_ESCAPE; break;
- case DWT.TAB: inputs.wVk = cast(short) OS.VK_TAB; break;
- /*
- * Since there is no LF key on the keyboard, do not attempt
- * to map LF to CR or attempt to post an LF key.
- */
-// case DWT.LF: inputs.wVk = cast(short) OS.VK_RETURN; break;
- case DWT.LF: return false;
- default: {
- static if (OS.IsWinCE) {
- inputs.wVk = cast(int)OS.CharUpper (cast(wchar*) key);
- } else {
- inputs.wVk = OS.VkKeyScan (cast(short) wcsToMbcs (key, 0));
- if (inputs.wVk is -1) return false;
- inputs.wVk &= 0xFF;
+ if (inputs.wVk is 0) {
+ char key = event.character;
+ switch (key) {
+ case DWT.BS: inputs.wVk = cast(short) OS.VK_BACK; break;
+ case DWT.CR: inputs.wVk = cast(short) OS.VK_RETURN; break;
+ case DWT.DEL: inputs.wVk = cast(short) OS.VK_DELETE; break;
+ case DWT.ESC: inputs.wVk = cast(short) OS.VK_ESCAPE; break;
+ case DWT.TAB: inputs.wVk = cast(short) OS.VK_TAB; break;
+ /*
+ * Since there is no LF key on the keyboard, do not attempt
+ * to map LF to CR or attempt to post an LF key.
+ */
+// case DWT.LF: inputs.wVk = cast(short) OS.VK_RETURN; break;
+ case DWT.LF: return false;
+ default: {
+ static if (OS.IsWinCE) {
+ inputs.wVk = cast(int)OS.CharUpper (cast(wchar*) key);
+ } else {
+ inputs.wVk = OS.VkKeyScan (cast(short) wcsToMbcs (key, 0));
+ if (inputs.wVk is -1) return false;
+ inputs.wVk &= 0xFF;
+ }
}
}
}
- }
- inputs.dwFlags = type is DWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0;
+ inputs.dwFlags = type is DWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0;
auto hHeap = OS.GetProcessHeap ();
auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
pInputs.type = OS.INPUT_KEYBOARD;
- pInputs.ki = inputs;
- //OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof);
- bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
- OS.HeapFree (hHeap, 0, pInputs);
- return result;
- }
- case DWT.MouseDown:
- case DWT.MouseMove:
- case DWT.MouseUp:
- case DWT.MouseWheel: {
- MOUSEINPUT inputs;
- if (type is DWT.MouseMove){
- inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE;
- int x= 0, y = 0, width = 0, height = 0;
- if (OS.WIN32_VERSION >= OS.VERSION (5, 0)) {
- inputs.dwFlags |= OS.MOUSEEVENTF_VIRTUALDESK;
- x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
- y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
- width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
- height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
+ //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit
+ pInputs.ki = inputs;
+ //OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof);
+ bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
+ OS.HeapFree (hHeap, 0, pInputs);
+ return result;
+ }
+ case DWT.MouseDown:
+ case DWT.MouseMove:
+ case DWT.MouseUp:
+ case DWT.MouseWheel: {
+ MOUSEINPUT inputs;
+ if (type is DWT.MouseMove){
+ inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE;
+ int x= 0, y = 0, width = 0, height = 0;
+ if (OS.WIN32_VERSION >= OS.VERSION (5, 0)) {
+ inputs.dwFlags |= OS.MOUSEEVENTF_VIRTUALDESK;
+ x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
+ y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
+ width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
+ height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
+ } else {
+ width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
+ height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
+ }
+ inputs.dx = ((event.x - x) * 65535 + width - 2) / (width - 1);
+ inputs.dy = ((event.y - y) * 65535 + height - 2) / (height - 1);
} else {
- width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
- height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
- }
- inputs.dx = ((event.x - x) * 65535 + width - 2) / (width - 1);
- inputs.dy = ((event.y - y) * 65535 + height - 2) / (height - 1);
- } else {
- if (type is DWT.MouseWheel) {
- if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
- inputs.dwFlags = OS.MOUSEEVENTF_WHEEL;
- switch (event.detail) {
- case DWT.SCROLL_PAGE:
- inputs.mouseData = event.count * OS.WHEEL_DELTA;
- break;
- case DWT.SCROLL_LINE:
- int value;
- OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0);
- inputs.mouseData = event.count * OS.WHEEL_DELTA / value;
- break;
- default: return false;
- }
- } else {
- switch (event.button) {
- case 1: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_LEFTDOWN : OS.MOUSEEVENTF_LEFTUP; break;
- case 2: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_MIDDLEDOWN : OS.MOUSEEVENTF_MIDDLEUP; break;
- case 3: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_RIGHTDOWN : OS.MOUSEEVENTF_RIGHTUP; break;
- case 4: {
- if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
- inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP;
- inputs.mouseData = OS.XBUTTON1;
- break;
+ if (type is DWT.MouseWheel) {
+ if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
+ inputs.dwFlags = OS.MOUSEEVENTF_WHEEL;
+ switch (event.detail) {
+ case DWT.SCROLL_PAGE:
+ inputs.mouseData = event.count * OS.WHEEL_DELTA;
+ break;
+ case DWT.SCROLL_LINE:
+ int value;
+ OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0);
+ inputs.mouseData = event.count * OS.WHEEL_DELTA / value;
+ break;
+ default: return false;
}
- case 5: {
- if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
- inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP;
- inputs.mouseData = OS.XBUTTON2;
- break;
+ } else {
+ switch (event.button) {
+ case 1: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_LEFTDOWN : OS.MOUSEEVENTF_LEFTUP; break;
+ case 2: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_MIDDLEDOWN : OS.MOUSEEVENTF_MIDDLEUP; break;
+ case 3: inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_RIGHTDOWN : OS.MOUSEEVENTF_RIGHTUP; break;
+ case 4: {
+ if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
+ inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP;
+ inputs.mouseData = OS.XBUTTON1;
+ break;
+ }
+ case 5: {
+ if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
+ inputs.dwFlags = type is DWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP;
+ inputs.mouseData = OS.XBUTTON2;
+ break;
+ }
+ default: return false;
}
- default: return false;
}
}
+ auto hHeap = OS.GetProcessHeap ();
+ auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
+ pInputs.type = OS.INPUT_MOUSE;
+ //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit
+ pInputs.mi = inputs;
+ bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
+ OS.HeapFree (hHeap, 0, pInputs);
+ return result;
}
- auto hHeap = OS.GetProcessHeap ();
- auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
- pInputs.type = OS.INPUT_MOUSE;
- //OS.MoveMemory(pInputs, [OS.INPUT_MOUSE], 4);
- pInputs.mi = inputs;
- //OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof);
- bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
- OS.HeapFree (hHeap, 0, pInputs);
- return result;
+ default:
}
- default:
+ return false;
}
- return false;
}
void postEvent (Event event) {
@@ -3389,10 +3480,10 @@
lpStartupInfo = null;
drawMenuBars ();
runPopups ();
- if (OS.PeekMessage (&msg, null, 0, 0, OS.PM_REMOVE)) {
- if (!filterMessage (&msg)) {
- OS.TranslateMessage (&msg);
- OS.DispatchMessage (&msg);
+ if (OS.PeekMessage (msg, null, 0, 0, OS.PM_REMOVE)) {
+ if (!filterMessage (msg)) {
+ OS.TranslateMessage (msg);
+ OS.DispatchMessage (msg);
}
runDeferredEvents ();
return true;
@@ -3400,18 +3491,20 @@
return runMessages && runAsyncMessages (false);
}
-static synchronized void register (Display display) {
+static void register (Display display) {
static_this();
- for (int i=0; i+ * This is an index into the FilterExtensions array and + * the FilterNames array. + *
+ * + * @return index the file extension filter index + * + * @see #getFilterExtensions + * @see #getFilterNames + * + * @since 3.4 + */ +public int getFilterIndex () { + return filterIndex; +} + +/** * Returns the names that describe the filter extensions * which the dialog will use to filter the files it shows. * @@ -147,6 +182,19 @@ return filterPath; } +/** + * Returns the flag that the dialog will use to + * determine whether to prompt the user for file + * overwrite if the selected file already exists. + * + * @return true if the dialog will prompt for file overwrite, false otherwise + * + * @since 3.4 + */ +public bool getOverwrite () { + return overwrite; +} + private static extern(Windows) uint OFNHookProc (HWND hdlg, uint uiMsg, uint wParam, int lParam) { switch (uiMsg) { case OS.WM_NOTIFY: @@ -193,7 +241,35 @@ /* Get the owner HWND for the dialog */ HWND hwndOwner; - if (parent !is null) hwndOwner = parent.handle; + auto hwndParent = parent.handle; + + /* + * Feature in Windows. There is no API to set the orientation of a + * file dialog. It is always inherited from the parent. The fix is + * to create a hidden parent and set the orientation in the hidden + * parent for the dialog to inherit. + */ + bool enabled = false; + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { + int dialogOrientation = style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); + int parentOrientation = parent.style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); + if (dialogOrientation !is parentOrientation) { + int exStyle = OS.WS_EX_NOINHERITLAYOUT; + if (dialogOrientation is DWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL; + hwndOwner = OS.CreateWindowEx ( + exStyle, + Shell.DialogClass.ptr, + null, + 0, + OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, + hwndParent, + null, + OS.GetModuleHandle (null), + null); + enabled = OS.IsWindowEnabled (hwndParent) !is 0; + if (enabled) OS.EnableWindow (hwndParent, false); + } + } /* Convert the title and copy it into lpstrTitle */ if (title is null) title = ""; @@ -253,7 +329,8 @@ OPENFILENAME struct_; struct_.lStructSize = OPENFILENAME.sizeof; struct_.Flags = OS.OFN_HIDEREADONLY | OS.OFN_NOCHANGEDIR; - //Callback callback = null; + bool save = (style & DWT.SAVE) !is 0; + if (save && overwrite) struct_.Flags |= OS.OFN_OVERWRITEPROMPT; if ((style & DWT.MULTI) !is 0) { struct_.Flags |= OS.OFN_ALLOWMULTISELECT | OS.OFN_EXPLORER; if (!OS.IsWinCE && USE_HOOK) { @@ -271,7 +348,7 @@ struct_.nMaxFile = nMaxFile; struct_.lpstrInitialDir = lpstrInitialDir; struct_.lpstrFilter = lpstrFilter; - struct_.nFilterIndex = 0; + struct_.nFilterIndex = filterIndex is 0 ? filterIndex : filterIndex + 1; /* * Set the default extension to an empty string. If the @@ -280,18 +357,17 @@ * extension at the time that the dialog is closed. */ TCHAR* lpstrDefExt; - bool save = (style & DWT.SAVE) !is 0; if (save) { lpstrDefExt = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); struct_.lpstrDefExt = lpstrDefExt; } /* Make the parent shell be temporary modal */ - Shell oldModal = null; + Dialog oldModal = null; Display display = parent.getDisplay (); if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { - oldModal = display.getModalDialogShell (); - display.setModalDialogShell (parent); + oldModal = display.getModalDialog (); + display.setModalDialog (this); } /* @@ -327,7 +403,7 @@ /* Clear the temporary dialog modal parent */ if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { - display.setModalDialogShell (oldModal); + display.setModalDialog (oldModal); } /* Dispose the callback and reassign the buffer */ @@ -335,7 +411,7 @@ lpstrFile = struct_.lpstrFile; /* Set the new path, file name and filter */ - fileNames = new String [0]; + fileNames = null; String fullPath = null; if (success) { @@ -408,6 +484,7 @@ fileNames = newFileNames; } } + filterIndex = struct_.nFilterIndex - 1; } /* Free the memory that was allocated. */ @@ -417,6 +494,13 @@ OS.HeapFree (hHeap, 0, lpstrTitle); if (lpstrDefExt !is null) OS.HeapFree (hHeap, 0, lpstrDefExt); + /* Destroy the BIDI orientation window */ + if (hwndParent !is hwndOwner) { + if (enabled) OS.EnableWindow (hwndParent, true); + OS.SetActiveWindow (hwndParent); + OS.DestroyWindow (hwndOwner); + } + /* * This code is intentionally commented. On some * platforms, the owner window is repainted right @@ -461,7 +545,27 @@ } /** - * Sets the the names that describe the filter extensions + * Set the 0-based index of the file extension filter + * which the dialog will use initially to filter the files + * it shows to the argument. + *+ * This is an index into the FilterExtensions array and + * the FilterNames array. + *
+ * + * @param index the file extension filter index + * + * @see #setFilterExtensions + * @see #setFilterNames + * + * @since 3.4 + */ +public void setFilterIndex (int index) { + filterIndex = index; +} + +/** + * Sets the names that describe the filter extensions * which the dialog will use to filter the files it shows * to the argument, which may be null. *@@ -499,5 +603,17 @@ filterPath = string; } +/** + * Sets the flag that the dialog will use to + * determine whether to prompt the user for file + * overwrite if the selected file already exists. + * + * @param overwrite true if the dialog will prompt for file overwrite, false otherwise + * + * @since 3.4 + */ +public void setOverwrite (bool overwrite) { + this.overwrite = overwrite; +} } diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/FontDialog.d --- a/dwt/widgets/FontDialog.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/FontDialog.d Sat May 17 17:34:28 2008 +0200 @@ -58,7 +58,7 @@ * */ public this (Shell parent) { - this (parent, DWT.PRIMARY_MODAL); + this (parent, DWT.APPLICATION_MODAL); } /** @@ -86,7 +86,7 @@ * */ public this (Shell parent, int style) { - super (parent, style); + super (parent, checkStyle (parent, style)); checkSubclass (); } @@ -145,8 +145,36 @@ static if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED); /* Get the owner HWND for the dialog */ - HWND hwndOwner; - if (parent !is null) hwndOwner = parent.handle; + HWND hwndOwner = parent.handle; + auto hwndParent = parent.handle; + + /* + * Feature in Windows. There is no API to set the orientation of a + * font dialog. It is always inherited from the parent. The fix is + * to create a hidden parent and set the orientation in the hidden + * parent for the dialog to inherit. + */ + bool enabled = false; + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { + int dialogOrientation = style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); + int parentOrientation = parent.style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); + if (dialogOrientation !is parentOrientation) { + int exStyle = OS.WS_EX_NOINHERITLAYOUT; + if (dialogOrientation is DWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL; + hwndOwner = OS.CreateWindowEx ( + exStyle, + Shell.DialogClass.ptr, + null, + 0, + OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, + hwndParent, + null, + OS.GetModuleHandle (null), + null); + enabled = OS.IsWindowEnabled (hwndParent) !is 0; + if (enabled) OS.EnableWindow (hwndParent, false); + } + } /* Open the dialog */ auto hHeap = OS.GetProcessHeap (); @@ -175,12 +203,12 @@ } /* Make the parent shell be temporary modal */ - Shell oldModal = null; + Dialog oldModal = null; Display display = null; if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { display = parent.getDisplay (); - oldModal = display.getModalDialogShell (); - display.setModalDialogShell (parent); + oldModal = display.getModalDialog (); + display.setModalDialog (this); } /* Open the dialog */ @@ -188,7 +216,7 @@ /* Clear the temporary dialog modal parent */ if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { - display.setModalDialogShell (oldModal); + display.setModalDialog (oldModal); } /* Compute the result */ @@ -235,6 +263,13 @@ /* Free the OS memory */ if (lpLogFont !is null) OS.HeapFree (hHeap, 0, lpLogFont); + /* Destroy the BIDI orientation window */ + if (hwndParent !is hwndOwner) { + if (enabled) OS.EnableWindow (hwndParent, true); + OS.SetActiveWindow (hwndParent); + OS.DestroyWindow (hwndOwner); + } + /* * This code is intentionally commented. On some * platforms, the owner window is repainted right diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Group.d --- a/dwt/widgets/Group.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Group.d Sat May 17 17:34:28 2008 +0200 @@ -207,7 +207,8 @@ OS.DrawText (hDC, buffer, -1, &rect, flags); if (newFont !is null) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); - size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6); + int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; + size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6 + offsetY); } return size; } @@ -223,15 +224,27 @@ OS.GetTextMetrics (hDC, &tm); if (newFont !is null) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); + int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; trim.x -= CLIENT_INSET; - trim.y -= tm.tmHeight; + trim.y -= tm.tmHeight + offsetY; trim.width += CLIENT_INSET * 2; trim.height += tm.tmHeight + CLIENT_INSET; return trim; } override void createHandle () { + /* + * Feature in Windows. When a button is created, + * it clears the UI state for all controls in the + * shell by sending WM_CHANGEUISTATE with UIS_SET, + * UISF_HIDEACCEL and UISF_HIDEFOCUS to the parent. + * This is undocumented and unexpected. The fix + * is to ignore the WM_CHANGEUISTATE, when sent + * from CreateWindowEx(). + */ + parent.state |= IGNORE_WM_CHANGEUISTATE; super.createHandle (); + parent.state &= ~IGNORE_WM_CHANGEUISTATE; state |= DRAW_BACKGROUND; state &= ~CANVAS; } @@ -265,7 +278,8 @@ OS.GetTextMetrics (hDC, &tm); if (newFont !is null) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); - int x = CLIENT_INSET, y = tm.tmHeight; + int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; + int x = CLIENT_INSET, y = tm.tmHeight + offsetY; int width = Math.max (0, rect.right - CLIENT_INSET * 2); int height = Math.max (0, rect.bottom - y - CLIENT_INSET); return new Rectangle (x, y, width, height); @@ -406,7 +420,7 @@ * allow children, answer HTCLIENT to allow mouse messages * to be delivered to the children. */ - int code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); + int /*long*/ code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); if (code is OS.HTTRANSPARENT) code = OS.HTCLIENT; return new LRESULT (code); } @@ -438,7 +452,7 @@ */ if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { auto nSavedDC = OS.SaveDC (cast(HDC)wParam); - int code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); + int /*long*/ code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); OS.RestoreDC (cast(HDC)wParam, nSavedDC); return new LRESULT (code); } @@ -467,7 +481,7 @@ } if (redraw) { OS.InvalidateRect (handle, null, false); - int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); + int /*long*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); return new LRESULT (code); } return result; diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/IME.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/widgets/IME.d Sat May 17 17:34:28 2008 +0200 @@ -0,0 +1,429 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.widgets.IME; + + +import dwt.DWT; +import dwt.graphics.Color; +import dwt.graphics.TextStyle; +import dwt.internal.win32.OS; +import dwt.internal.win32.WINTYPES; + +import dwt.widgets.Widget; +import dwt.widgets.Canvas; +import dwt.widgets.Event; +import dwt.widgets.Display; + +import dwt.dwthelper.utils; + +/** + * TODO - JAVA DOC + * + *
+ * . + *
+ * + * @since 3.4 + */ + +public class IME : Widget { + Canvas parent; + int caretOffset; + int startOffset; + int commitCount; + String text; + int [] ranges; + TextStyle [] styles; + + static const int WM_MSIME_MOUSE; + + static byte [16] IID_ITfInputProcessorProfiles; + static byte [16] IID_ITfDisplayAttributeProvider; + static byte [16] CLSID_TF_InputProcessorProfiles; + static byte [16] GUID_TFCAT_TIP_KEYBOARD; + static this() { + WM_MSIME_MOUSE = OS.RegisterWindowMessage (StrToTCHARz ("MSIMEMouseOperation")); + + OS.IIDFromString ("{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}\0"w.ptr, IID_ITfInputProcessorProfiles.ptr); + OS.IIDFromString ("{fee47777-163c-4769-996a-6e9c50ad8f54}\0"w.ptr, IID_ITfDisplayAttributeProvider.ptr); + OS.IIDFromString ("{33C53A50-F456-4884-B049-85FD643ECFED}\0"w.ptr, CLSID_TF_InputProcessorProfiles.ptr); + OS.IIDFromString ("{34745C63-B2F0-4784-8B67-5E12C8701A31}\0"w.ptr, GUID_TFCAT_TIP_KEYBOARD.ptr); + } + + /* TextLayout has a copy of these constants */ + static const int UNDERLINE_IME_DOT = 1 << 16; + static const int UNDERLINE_IME_DASH = 2 << 16; + static const int UNDERLINE_IME_THICK = 3 << 16; + +/** + * Prevents uninitialized instances from being created outside the package. + */ +this () { +} + +/** + * + * @see DWT + */ +public this (Canvas parent, int style) { + super (parent, style); + this.parent = parent; + createWidget (); +} + +void createWidget () { + text = ""; + startOffset = -1; + if (parent.getIME () is null) { + parent.setIME (this); + } +} + +public int getCaretOffset () { + checkWidget (); + return startOffset + caretOffset; +} + +public int getCommitCount () { + checkWidget (); + return commitCount; +} + +public int getCompositionOffset () { + checkWidget (); + return startOffset; +} + +TF_DISPLAYATTRIBUTE* getDisplayAttribute (short langid, int attInfo) { + void* pProfiles; + int hr = OS.CoCreateInstance (CLSID_TF_InputProcessorProfiles.ptr, null, OS.CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles.ptr, &pProfiles); + TF_DISPLAYATTRIBUTE* pda; + if (hr is OS.S_OK) { + byte [16] pclsid; + byte [16] pguidProfile; + /* pProfiles.GetDefaultLanguageProfile () */ + hr = OS.VtblCall (8, pProfiles, cast(int)langid, cast(int)GUID_TFCAT_TIP_KEYBOARD.ptr, cast(int)pclsid.ptr, cast(int)pguidProfile.ptr); + if (hr is OS.S_OK) { + void* pProvider; + hr = OS.CoCreateInstance (pclsid.ptr, null, OS.CLSCTX_INPROC_SERVER, IID_ITfDisplayAttributeProvider.ptr, &pProvider); + if (hr is OS.S_OK) { + void* pEnum; + /* pProvider.EnumDisplayAttributeInfo () */ + hr = OS.VtblCall (3, pProvider, cast(int)&pEnum); + if (hr is OS.S_OK) { + void* pDispInfo; + TF_DISPLAYATTRIBUTE* tempPda; + /* pEnum.Next () */ + while ((hr = OS.VtblCall (4, pEnum, 1, cast(int) &pDispInfo, 0 )) is OS.S_OK) { + /* pDispInfo.GetAttributeInfo(); */ + OS.VtblCall (5, pDispInfo, cast(int)&tempPda); + /* pDispInfo.Release () */ + OS.VtblCall (2, pDispInfo); + if (tempPda.bAttr is attInfo) { + pda = tempPda; + break; + } + } + /* pEnum.Release () */ + hr = OS.VtblCall (2, pEnum); + } + /* pProvider.Release () */ + hr = OS.VtblCall (2, pProvider); + } + } + /* pProfiles.Release () */ + hr = OS.VtblCall (2, pProfiles); + } + if (pda is null) { + pda = new TF_DISPLAYATTRIBUTE (); + switch (attInfo) { + case OS.TF_ATTR_INPUT: + pda.lsStyle = OS.TF_LS_SQUIGGLE; + break; + case OS.TF_ATTR_CONVERTED: + case OS.TF_ATTR_TARGET_CONVERTED: + pda.lsStyle = OS.TF_LS_SOLID; + pda.fBoldLine = attInfo is OS.TF_ATTR_TARGET_CONVERTED; + break; + } + } + return pda; +} + +public int [] getRanges () { + checkWidget (); + if (ranges is null) return new int [0]; + int [] result = new int [ranges.length]; + for (int i = 0; i < result.length; i++) { + result [i] = ranges [i] + startOffset; + } + return result; +} + +public TextStyle [] getStyles () { + checkWidget (); + if (styles is null) return new TextStyle [0]; + TextStyle [] result = new TextStyle [styles.length]; + System.arraycopy (styles, 0, result, 0, styles.length); + return result; +} + +public String getText () { + checkWidget (); + return text; +} + +public bool getWideCaret() { + checkWidget (); + auto layout = OS.GetKeyboardLayout (0); + short langID = cast(short)OS.LOWORD ( cast(int) layout); + return OS.PRIMARYLANGID (langID) is OS.LANG_KOREAN; +} + +bool isInlineEnabled () { + if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (5, 1)) return false; + return OS.IsDBLocale && hooks (DWT.ImeComposition); +} + +void releaseParent () { + super.releaseParent (); + if (this is parent.getIME ()) parent.setIME (null); +} + +void releaseWidget () { + super.releaseWidget (); + parent = null; + text = null; + styles = null; + ranges = null; +} + +public void setCompositionOffset (int offset) { + checkWidget (); + if (offset < 0) return; + if (startOffset !is -1) { + startOffset = offset; + } +} + +LRESULT WM_IME_COMPOSITION (int /*long*/ wParam, int /*long*/ lParam) { + if (!isInlineEnabled ()) return null; + ranges = null; + styles = null; + caretOffset = commitCount = 0; + auto hwnd = parent.handle; + auto hIMC = OS.ImmGetContext (hwnd); + int codePage = parent.getCodePage (); + if (hIMC !is null) { + TCHAR[] buffer = null; + if ((lParam & OS.GCS_RESULTSTR) !is 0) { + int length_ = OS.ImmGetCompositionString (hIMC, OS.GCS_RESULTSTR, null, 0); + if (length_ > 0) { + buffer = NewTCHARs (codePage, length_ / TCHAR.sizeof); + OS.ImmGetCompositionString (hIMC, OS.GCS_RESULTSTR, buffer.ptr, length_); + if (startOffset is -1) { + Event event = new Event (); + event.detail = DWT.COMPOSITION_SELECTION; + sendEvent (DWT.ImeComposition, event); + startOffset = event.start; + } + Event event = new Event (); + event.detail = DWT.COMPOSITION_CHANGED; + event.start = startOffset; + event.end = startOffset + text.length; + event.text = text = buffer !is null ? TCHARsToStr(buffer) : ""; + commitCount = text.length ; + sendEvent (DWT.ImeComposition, event); + String chars = text; + text = ""; + startOffset = -1; + commitCount = 0; + if (event.doit) { + Display display = this.display; + display.lastKey = 0; + display.lastVirtual = display.lastNull = display.lastDead = false; + length_ = chars.length; + for (int i = 0; i < length_; i++) { + char c = chars.charAt (i); + display.lastAscii = c; + event = new Event (); + event.character = c; + parent.sendEvent (DWT.KeyDown, event); + } + } + } + if ((lParam & OS.GCS_COMPSTR) is 0) return LRESULT.ONE; + } + buffer = null; + if ((lParam & OS.GCS_COMPSTR) !is 0) { + int length_ = OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, null, 0); + if (length_ > 0) { + buffer = NewTCHARs (codePage, length_ / TCHAR.sizeof); + OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, buffer.ptr, length_); + if ((lParam & OS.GCS_CURSORPOS) !is 0) { + caretOffset = OS.ImmGetCompositionString (hIMC, OS.GCS_CURSORPOS, null, 0); + } + int [] clauses = null; + if ((lParam & OS.GCS_COMPCLAUSE) !is 0) { + length_ = OS.ImmGetCompositionStringW (hIMC, OS.GCS_COMPCLAUSE, /+cast(int [])+/null, 0); + if (length_ > 0) { + clauses = new int [length_ / 4]; + OS.ImmGetCompositionStringW (hIMC, OS.GCS_COMPCLAUSE, clauses.ptr, length_); + } + } + if ((lParam & OS.GCS_COMPATTR) !is 0 && clauses !is null) { + length_ = OS.ImmGetCompositionStringA (hIMC, OS.GCS_COMPATTR, /+cast(byte [])+/null, 0); + if (length_ > 0) { + byte [] attrs = new byte [length_]; + OS.ImmGetCompositionStringA (hIMC, OS.GCS_COMPATTR, attrs.ptr, length_); + length_ = clauses.length - 1; + ranges = new int [length_ * 2]; + styles = new TextStyle [length_]; + auto layout = OS.GetKeyboardLayout (0); + short langID = cast(short)OS.LOWORD ( cast(int) layout); + TF_DISPLAYATTRIBUTE* attr = null; + TextStyle style = null; + for (int i = 0; i < length_; i++) { + ranges [i * 2] = clauses [i]; + ranges [i * 2 + 1] = clauses [i + 1] - 1; + styles [i] = style = new TextStyle (); + attr = getDisplayAttribute (langID, attrs [clauses [i]]); + if (attr !is null) { + switch (attr.crText.type) { + case OS.TF_CT_COLORREF: + style.foreground = Color.win32_new (display, attr.crText.cr); + break; + case OS.TF_CT_SYSCOLOR: + int colorRef = OS.GetSysColor (attr.crText.cr); + style.foreground = Color.win32_new (display, colorRef); + break; + } + switch (attr.crBk.type) { + case OS.TF_CT_COLORREF: + style.background = Color.win32_new (display, attr.crBk.cr); + break; + case OS.TF_CT_SYSCOLOR: + int colorRef = OS.GetSysColor (attr.crBk.cr); + style.background = Color.win32_new (display, colorRef); + break; + } + switch (attr.crLine.type) { + case OS.TF_CT_COLORREF: + style.underlineColor = Color.win32_new (display, attr.crLine.cr); + break; + case OS.TF_CT_SYSCOLOR: + int colorRef = OS.GetSysColor (attr.crLine.cr); + style.underlineColor = Color.win32_new (display, colorRef); + break; + } + style.underline = attr.lsStyle !is OS.TF_LS_NONE; + switch (attr.lsStyle) { + case OS.TF_LS_SQUIGGLE: + style.underlineStyle = DWT.UNDERLINE_SQUIGGLE; + break; + case OS.TF_LS_DASH: + style.underlineStyle = UNDERLINE_IME_DASH; + break; + case OS.TF_LS_DOT: + style.underlineStyle = UNDERLINE_IME_DOT; + break; + case OS.TF_LS_SOLID: + style.underlineStyle = attr.fBoldLine ? UNDERLINE_IME_THICK : DWT.UNDERLINE_SINGLE; + break; + } + } + } + } + } + } + OS.ImmReleaseContext (hwnd, hIMC); + } + int end = startOffset + text.length; + if (startOffset is -1) { + Event event = new Event (); + event.detail = DWT.COMPOSITION_SELECTION; + sendEvent (DWT.ImeComposition, event); + startOffset = event.start; + end = event.end; + } + Event event = new Event (); + event.detail = DWT.COMPOSITION_CHANGED; + event.start = startOffset; + event.end = end; + event.text = text = buffer !is null ? TCHARsToStr(buffer) : ""; + sendEvent (DWT.ImeComposition, event); + if (text.length is 0) { + startOffset = -1; + ranges = null; + styles = null; + } + } + return LRESULT.ONE; +} + +LRESULT WM_IME_COMPOSITION_START (int /*long*/ wParam, int /*long*/ lParam) { + return isInlineEnabled () ? LRESULT.ONE : null; +} + +LRESULT WM_IME_ENDCOMPOSITION (int /*long*/ wParam, int /*long*/ lParam) { + return isInlineEnabled () ? LRESULT.ONE : null; +} + +LRESULT WM_KILLFOCUS (int /*long*/ wParam, int /*long*/ lParam) { + if (!isInlineEnabled ()) return null; + auto hwnd = parent.handle; + auto hIMC = OS.ImmGetContext (hwnd); + if (hIMC !is null) { + if (OS.ImmGetOpenStatus (hIMC)) { + OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0); + } + OS.ImmReleaseContext (hwnd, hIMC); + } + return null; +} + +LRESULT WM_LBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) { + if (!isInlineEnabled ()) return null; + auto hwnd = parent.handle; + auto hIMC = OS.ImmGetContext (hwnd); + if (hIMC !is null) { + if (OS.ImmGetOpenStatus (hIMC)) { + if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, null, 0) > 0) { + Event event = new Event (); + event.detail = DWT.COMPOSITION_OFFSET; + event.x = OS.GET_X_LPARAM (lParam); + event.y = OS.GET_Y_LPARAM (lParam); + sendEvent (DWT.ImeComposition, event); + int offset = event.index; + int length_ = text.length; + if (offset !is -1 && startOffset !is -1 && startOffset <= offset && offset < startOffset + length_) { + auto imeWnd = OS.ImmGetDefaultIMEWnd (hwnd); + offset = event.index + event.count - startOffset; + int trailing = event.count > 0 ? 1 : 2; + int /*long*/ param = OS.MAKEWPARAM (OS.MAKEWORD (OS.IMEMOUSE_LDOWN, trailing), offset); + OS.SendMessage (imeWnd, WM_MSIME_MOUSE, param, hIMC); + } else { + OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0); + } + } + } + OS.ImmReleaseContext (hwnd, hIMC); + } + return null; +} + +} diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Label.d --- a/dwt/widgets/Label.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Label.d Sat May 17 17:34:28 2008 +0200 @@ -34,6 +34,13 @@ * user interface object that displays a string or image. * When SEPARATOR is specified, displays a single * vertical or horizontal line. + *+ * Shadow styles are hints and may not be honoured + * by the platform. To create a separator label + * with the default shadow style for the platform, + * do not specify a shadow style. + *
+ *
+ * After constructing a menu, it can be set into its parent
+ * using parent.setMenu(menu)
. In this case, the parent may
+ * be any control in the same widget tree as the parent.
+ *
DWT
style constants. The class description
* lists the style constants that are applicable to the class.
* Style bits are also inherited from superclasses.
+ *
+ * After constructing a menu or menuBar, it can be set into its parent
+ * using parent.setMenu(menu)
or parent.setMenuBar(menuBar)
.
*
Menu
) and sets the style
* for the instance so that the instance will be a drop-down
* menu on the given parent's parent.
+ *
+ * After constructing a drop-down menu, it can be set into its parentMenu
+ * using parentMenu.setMenu(menu)
.
+ *
MenuItem
) and sets the style
* for the instance so that the instance will be a drop-down
* menu on the given parent's parent menu.
+ *
+ * After constructing a drop-down menu, it can be set into its parentItem
+ * using parentItem.setMenu(menu)
.
+ *
NORMAL
, ERROR
or PAUSED
.
+ *
+ * @return the state
+ *
+ * @exception DWTException NORMAL
, ERROR
or PAUSED
.
+ *
+ * @param state the new state
+ *
+ * @exception DWTException
* IMPORTANT: This method is not part of the public
* API for Shell
. It is marked public only so that it
@@ -430,12 +432,30 @@
return new Shell (display, null, DWT.NO_TRIM, handle, true);
}
+/**
+ * Invokes platform specific functionality to allocate a new shell
+ * that is not embedded.
+ *
+ * IMPORTANT: This method is not part of the public
+ * API for Shell
. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
true
if the receiver is currently
+ * in fullscreen state, and false otherwise.
+ * + * + * @return the fullscreen state + * + * @exception DWTException
+ * This operation requires the operating system's advanced + * widgets subsystem which may not be available on some + * platforms. + *
+ * @param alpha the alpha value + * + * @exception DWTExceptiontrue
causes the receiver
+ * to switch to the full screen state, and if the argument is
+ * false
and the receiver was previously switched
+ * into full screen state, causes the receiver to switch back
+ * to either the maximmized or normal states.
+ *
+ * Note: The result of intermixing calls to setFullScreen(true)
,
+ * setMaximized(true)
and setMinimized(true)
will
+ * vary by platform. Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ *
DWT
:
@@ -1359,7 +1530,7 @@
public void setImeInputMode (int mode) {
checkWidget ();
if (!OS.IsDBLocale) return;
- bool imeOn = mode !is DWT.NONE && mode !is DWT.ROMAN;
+ bool imeOn = mode !is DWT.NONE;
auto hIMC = OS.ImmGetContext (handle);
OS.ImmSetOpenStatus (hIMC, imeOn);
if (imeOn) {
@@ -1376,7 +1547,7 @@
oldBits = OS.IME_CMODE_KATAKANA;
}
}
- if ((mode & DWT.DBCS) !is 0) {
+ if ((mode & (DWT.DBCS | DWT.NATIVE)) !is 0) {
newBits |= OS.IME_CMODE_FULLSHAPE;
} else {
oldBits |= OS.IME_CMODE_FULLSHAPE;
@@ -1386,7 +1557,8 @@
} else {
oldBits |= OS.IME_CMODE_ROMAN;
}
- lpfdwConversion |= newBits; lpfdwConversion &= ~oldBits;
+ lpfdwConversion |= newBits;
+ lpfdwConversion &= ~oldBits;
OS.ImmSetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);
}
}
@@ -1492,14 +1664,7 @@
public void setRegion (Region region) {
checkWidget ();
if ((style & DWT.NO_TRIM) is 0) return;
- if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
- HRGN hRegion;
- if (region !is null) {
- hRegion = OS.CreateRectRgn (0, 0, 0, 0);
- OS.CombineRgn (hRegion, region.handle, hRegion, OS.RGN_OR);
- }
- OS.SetWindowRgn (handle, hRegion, true);
- this.region = region;
+ super.setRegion (region);
}
void setToolTipText (HWND hwnd, String text) {
@@ -1522,7 +1687,7 @@
}
}
-void setToolTipText (NMTTDISPINFO* lpnmtdi, byte [] buffer) {
+void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) {
/*
* Ensure that the current position of the mouse
* is inside the client area of the shell. This
@@ -1538,7 +1703,7 @@
lpnmtdi.lpszText = lpstrTip;
}
-void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) {
+void setToolTipText (NMTTDISPINFO* lpnmtdi, wchar [] buffer) {
/*
* Ensure that the current position of the mouse
* is inside the client area of the shell. This
@@ -1548,7 +1713,7 @@
if (!hasCursor ()) return;
auto hHeap = OS.GetProcessHeap ();
if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip);
- TCHAR[] charz = StrToTCHARs( 0, buffer );
+ TCHAR[] charz = buffer;//StrToTCHARs( 0, buffer );
int byteCount = charz.length * TCHAR.sizeof;
lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (lpstrTip, charz.ptr, byteCount);
@@ -1605,12 +1770,6 @@
override public void setVisible (bool visible) {
checkWidget ();
- if (drawCount !is 0) {
- if (((state & HIDDEN) is 0) is visible) return;
- } else {
- if (visible is OS.IsWindowVisible (handle)) return;
- }
-
/*
* Feature in Windows. When ShowWindow() is called used to hide
* a window, Windows attempts to give focus to the parent. If the
@@ -1624,6 +1783,9 @@
if ((style & mask) !is 0) {
if (visible) {
display.setModalShell (this);
+ if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) {
+ display.setModalDialog (null);
+ }
Control control = display._getFocusControl ();
if (control !is null && !control.isActive ()) {
bringToTop ();
@@ -1656,22 +1818,41 @@
if (!visible) fixActiveShell ();
super.setVisible (visible);
if (isDisposed ()) return;
- if (showWithParent is visible) return;
- showWithParent = visible;
+ if (showWithParent !is visible) {
+ showWithParent = visible;
+ if (visible) {
+ static if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, true);
+ }
+ }
+
+ /* Make the splash screen appear in the task bar */
if (visible) {
- static if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, true);
+ if (parent !is null && (parent.state & FOREIGN_HANDLE) !is 0) {
+ auto hwndParent = parent.handle;
+ int style = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
+ if ((style & OS.WS_EX_TOOLWINDOW) !is 0) {
+ OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, style & ~OS.WS_EX_TOOLWINDOW);
+ /*
+ * Bug in Windows. The window does not show in the task bar when
+ * WS_EX_TOOLWINDOW is removed after the window has already been shown.
+ * The fix is to hide and shown the shell.
+ */
+ OS.ShowWindow (hwndParent, OS.SW_HIDE);
+ OS.ShowWindow (hwndParent, OS.SW_RESTORE);
+ }
+ }
}
}
override void subclass () {
super.subclass ();
if (ToolTipProc !is null) {
- int newProc = display.windowProc;
+ int /*long*/ newProc = display.windowProc;
if (toolTipHandle_ !is null) {
- OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, newProc);
+ OS.SetWindowLongPtr (toolTipHandle_, OS.GWLP_WNDPROC, newProc);
}
if (balloonTipHandle_ !is null) {
- OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, newProc);
+ OS.SetWindowLongPtr (balloonTipHandle_, OS.GWLP_WNDPROC, newProc);
}
}
}
@@ -1698,10 +1879,10 @@
super.unsubclass ();
if (ToolTipProc !is null) {
if (toolTipHandle_ !is null) {
- OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, cast(int)ToolTipProc);
+ OS.SetWindowLongPtr (toolTipHandle_, OS.GWLP_WNDPROC, cast(int)ToolTipProc);
}
if (toolTipHandle_ !is null) {
- OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, cast(int)ToolTipProc);
+ OS.SetWindowLongPtr (toolTipHandle_, OS.GWLP_WNDPROC, cast(int)ToolTipProc);
}
}
}
@@ -1780,7 +1961,7 @@
static if (OS.IsSP) return cast(int) DialogProc;
if ((style & DWT.TOOL) !is 0) {
int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE;
- if ((style & trim) is 0) super.windowProc ();
+ if ((style & trim) is 0) return super.windowProc ();
}
return parent !is null ? cast(int) DialogProc : super.windowProc ();
}
@@ -1858,14 +2039,14 @@
* to adding a listener.
*/
if (hooks (DWT.HardKeyDown) || hooks (DWT.HardKeyUp)) {
- int fActive = wParam & 0xFFFF;
- int hwnd = fActive !is 0 ? handle : 0;
+ int fActive = OS.LOWORD (wParam);
+ int /*long*/ hwnd = fActive !is 0 ? handle : 0;
for (int bVk=OS.VK_APP1; bVk<=OS.VK_APP6; bVk++) {
OS.SHSetAppKeyWndAssoc (cast(byte) bVk, hwnd);
}
}
/* Restore SIP state when window is activated */
- if ((wParam & 0xFFFF) !is 0) {
+ if (OS.LOWORD (wParam) !is 0) {
OS.SHSipPreference (handle, psai.fSipUp is 0 ? OS.SIP_DOWN : OS.SIP_UP);
}
}
@@ -1873,24 +2054,20 @@
/*
* Bug in Windows XP. When a Shell is deactivated, the
* IME composition window does not go away. This causes
- * repaint issues. The fix is to close the IME to cause
- * the composition string to be committed.
- *
- * Note. The IME needs to be reopened in order to preserve
- * the input method status.
+ * repaint issues. The fix is to commit the composition
+ * string.
*/
if (OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
- if ((wParam & 0xFFFF) is 0 && OS.IsDBLocale && hIMC !is null) {
- if (OS.ImmGetOpenStatus(hIMC)) {
- OS.ImmSetOpenStatus (hIMC, false);
- OS.ImmSetOpenStatus (hIMC, true);
+ if (OS.LOWORD (wParam) is 0 && OS.IsDBLocale && hIMC !is null) {
+ if (OS.ImmGetOpenStatus (hIMC)) {
+ OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0);
}
}
}
/* Process WM_ACTIVATE */
LRESULT result = super.WM_ACTIVATE (wParam, lParam);
- if ((wParam & 0xFFFF) is 0) {
+ if (OS.LOWORD (wParam) is 0) {
if (lParam is 0 || (cast(HANDLE)lParam !is toolTipHandle_ && cast(HANDLE)lParam !is balloonTipHandle_)) {
ToolTip tip = getCurrentToolTip ();
if (tip !is null) tip.setVisible (false);
@@ -1906,7 +2083,7 @@
* been pressed. lParam is either 0 (PocketPC 2002) or the handle
* to the Shell (PocketPC).
*/
- int loWord = wParam & 0xFFFF;
+ int loWord = OS.LOWORD (wParam);
if (loWord is OS.IDOK && (lParam is 0 || lParam is handle)) {
OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
return LRESULT.ZERO;
@@ -1929,7 +2106,7 @@
if (lParam is hwndCB) {
return super.WM_COMMAND (wParam, 0);
} else {
- int hwndChild = OS.GetWindow (hwndCB, OS.GW_CHILD);
+ int /*long*/ hwndChild = OS.GetWindow (hwndCB, OS.GW_CHILD);
if (lParam is hwndChild) return super.WM_COMMAND (wParam, 0);
}
}
@@ -1975,10 +2152,8 @@
override LRESULT WM_ENTERIDLE (int wParam, int lParam) {
LRESULT result = super.WM_ENTERIDLE (wParam, lParam);
if (result !is null) return result;
- static if (OS.IsWinCE) {
- if (display.runMessages) {
- if (display.runAsyncMessages (true)) display.wakeThread ();
- }
+ if (display.runMessages) {
+ if (display.runAsyncMessages (false)) display.wakeThread ();
}
return result;
}
@@ -2006,7 +2181,7 @@
* and stop the normal shell activation but allow the mouse
* down to be delivered.
*/
- int hittest = cast(short) (lParam & 0xFFFF);
+ int hittest = cast(short) OS.LOWORD (lParam);
switch (hittest) {
case OS.HTERROR:
case OS.HTTRANSPARENT:
@@ -2049,8 +2224,7 @@
POINT pt;
if (!OS.GetCursorPos (&pt)) {
int pos = OS.GetMessagePos ();
- pt.x = cast(short) (pos & 0xFFFF);
- pt.y = cast(short) (pos >> 16);
+ OS.POINTSTOPOINT (pt, pos);
}
auto hwnd = OS.WindowFromPoint (pt);
if (hwnd is null) return null;
@@ -2073,8 +2247,9 @@
}
}
+ int /*long*/ code = callWindowProc (handle, OS.WM_MOUSEACTIVATE, wParam, lParam);
setActiveControl (control);
- return null;
+ return new LRESULT (code);
}
override LRESULT WM_MOVE (int wParam, int lParam) {
@@ -2085,32 +2260,16 @@
return result;
}
-override LRESULT WM_NCACTIVATE (int wParam, int lParam) {
- Display display = this.display;
- LRESULT result = super.WM_NCACTIVATE (wParam, lParam);
- if (display.isXMouseActive ()) {
- if (lockToolTipControl !is null) {
- if (OS.GetAsyncKeyState (OS.VK_LBUTTON) < 0) return result;
- if (OS.GetAsyncKeyState (OS.VK_MBUTTON) < 0) return result;
- if (OS.GetAsyncKeyState (OS.VK_RBUTTON) < 0) return result;
- if (OS.GetAsyncKeyState (OS.VK_XBUTTON1) < 0) return result;
- if (OS.GetAsyncKeyState (OS.VK_XBUTTON2) < 0) return result;
- return LRESULT.ZERO;
- }
- }
- return result;
-}
-
override LRESULT WM_NCHITTEST (int wParam, int lParam) {
if (!OS.IsWindowEnabled (handle)) return null;
if (!isEnabled () || !isActive ()) {
if (!Display.TrimEnabled) return new LRESULT (OS.HTNOWHERE);
- int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ int /*long*/ hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (hittest is OS.HTCLIENT || hittest is OS.HTMENU) hittest = OS.HTBORDER;
return new LRESULT (hittest);
}
if (menuBar !is null && !menuBar.getEnabled ()) {
- int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ int /*long*/ hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (hittest is OS.HTMENU) hittest = OS.HTBORDER;
return new LRESULT (hittest);
}
@@ -2133,7 +2292,7 @@
bool fixActive = OS.IsWin95 && display.lastHittest is OS.HTCAPTION;
if (fixActive) hwndActive = OS.SetActiveWindow (handle);
display.lockActiveWindow = true;
- int code = callWindowProc (handle, OS.WM_NCLBUTTONDOWN, wParam, lParam);
+ int /*long*/ code = callWindowProc (handle, OS.WM_NCLBUTTONDOWN, wParam, lParam);
display.lockActiveWindow = false;
if (fixActive) OS.SetActiveWindow (hwndActive);
Control focusControl = display.lastHittestControl;
@@ -2168,7 +2327,7 @@
* fix is to detect this case and bring the shell
* forward.
*/
- int msg = cast(short) (lParam >> 16);
+ int msg = OS.HIWORD (lParam);
if (msg is OS.WM_LBUTTONDOWN) {
if (!Display.TrimEnabled) {
Shell modalShell = display.getModalShell ();
@@ -2203,15 +2362,14 @@
* with HTERROR to set the cursor but only when the
* mouse is in the client area of the shell.
*/
- int hitTest = cast(short) (lParam & 0xFFFF);
+ int hitTest = cast(short) OS.LOWORD (lParam);
if (hitTest is OS.HTERROR) {
if (!getEnabled ()) {
Control control = display.getControl (cast(HANDLE)wParam);
if (control is this && cursor !is null) {
POINT pt;
int pos = OS.GetMessagePos ();
- pt.x = cast(short) (pos & 0xFFFF);
- pt.y = cast(short) (pos >> 16);
+ OS.POINTSTOPOINT (pt, pos);
OS.ScreenToClient (handle, &pt);
RECT rect;
OS.GetClientRect (handle, &rect);
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Slider.d
--- a/dwt/widgets/Slider.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Slider.d Sat May 17 17:34:28 2008 +0200
@@ -669,7 +669,7 @@
case OS.VK_LEFT:
case OS.VK_RIGHT: {
int key = wParam is OS.VK_LEFT ? OS.VK_RIGHT : OS.VK_LEFT;
- int code = callWindowProc (handle, OS.WM_KEYDOWN, key, lParam);
+ int /*long*/ code = callWindowProc (handle, OS.WM_KEYDOWN, key, lParam);
return new LRESULT (code);
}
default:
@@ -752,7 +752,7 @@
override LRESULT wmScrollChild (int wParam, int lParam) {
/* Do nothing when scrolling is ending */
- int code = wParam & 0xFFFF;
+ int code = OS.LOWORD (wParam);
if (code is OS.SB_ENDSCROLL) return null;
/* Move the thumb */
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Spinner.d
--- a/dwt/widgets/Spinner.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Spinner.d Sat May 17 17:34:28 2008 +0200
@@ -32,6 +32,7 @@
import tango.text.convert.Integer : toString;
static import tango.text.Text;
alias tango.text.Text.Text!(char) StringBuffer;
+import tango.util.Convert;
/**
* Instances of this class are selectable user interface
@@ -86,7 +87,22 @@
static_this_completed = true;
}
}
+ /**
+ * the operating system limit for the number of characters
+ * that the text field in an instance of this class can hold
+ *
+ * @since 3.4
+ */
+ public static int LIMIT;
+ /*
+ * These values can be different on different platforms.
+ * Therefore they are not initialized in the declaration
+ * to stop the compiler from inlining.
+ */
+ static this() {
+ LIMIT = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF;
+ }
/**
* Constructs a new instance of this class given its parent
@@ -173,7 +189,7 @@
hInstance,
null);
if (hwndText is null) error (DWT.ERROR_NO_HANDLES);
- OS.SetWindowLong (hwndText, OS.GWL_ID, cast(int) hwndText);
+ OS.SetWindowLongPtr (hwndText, OS.GWLP_ID, cast(LONG_PTR)hwndText);
int upDownStyle = OS.WS_CHILD | OS.WS_VISIBLE | OS.UDS_AUTOBUDDY;
if ((style & DWT.WRAP) !is 0) upDownStyle |= OS.UDS_WRAP;
if ((style & DWT.BORDER) !is 0) {
@@ -196,7 +212,7 @@
if (hwndUpDown is null) error (DWT.ERROR_NO_HANDLES);
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
SetWindowPos (hwndText, hwndUpDown, 0, 0, 0, 0, flags);
- OS.SetWindowLong (hwndUpDown, OS.GWL_ID, cast(int) hwndUpDown);
+ OS.SetWindowLongPtr (hwndUpDown, OS.GWLP_ID, cast(LONG_PTR)hwndUpDown);
if (OS.IsDBLocale) {
auto hIMC = OS.ImmGetContext (handle);
OS.ImmAssociateContext (hwndText, hIMC);
@@ -365,9 +381,9 @@
* the single-line text widget in an editable combo
* box.
*/
- int margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
- x -= margins & 0xFFFF;
- width += (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF);
+ int /*long*/ margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
+ x -= OS.LOWORD (margins);
+ width += OS.LOWORD (margins) + OS.HIWORD (margins);
if ((style & DWT.BORDER) !is 0) {
x -= 1;
y -= 1;
@@ -538,13 +554,13 @@
public int getSelection () {
checkWidget ();
static if (OS.IsWinCE) {
- return OS.SendMessage (hwndUpDown, OS.UDM_GETPOS, 0, 0) & 0xFFFF;
+ return OS.LOWORD (OS.SendMessage (hwndUpDown, OS.UDM_GETPOS, 0, 0));
} else {
return OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
}
}
-int getSelectionText () {
+int getSelectionText (bool [] parseFail) {
int length_ = OS.GetWindowTextLength (hwndText);
TCHAR[] buffer = NewTCHARs (getCodePage (), length_ + 1);
OS.GetWindowText (hwndText, buffer.ptr, length_ + 1);
@@ -555,7 +571,8 @@
String decimalSeparator = getDecimalSeparator ();
int index = string.indexOf (decimalSeparator);
if (index !is -1) {
- String wholePart = string.substring (0, index);
+ int startIndex = string.startsWith ("+") || string.startsWith ("-") ? 1 : 0;
+ String wholePart = startIndex !is index ? string.substring (startIndex, index) : "0";
String decimalPart = string.substring (index + 1);
if (decimalPart.length > digits) {
decimalPart = decimalPart.substring (0, digits);
@@ -569,8 +586,10 @@
int decimalValue = Integer.parseInt (decimalPart);
for (int i = 0; i < digits; i++) wholeValue *= 10;
value = wholeValue + decimalValue;
+ if (string.startsWith ("-")) value = -value;
} else {
value = Integer.parseInt (string);
+ for (int i = 0; i < digits; i++) value *= 10;
}
} else {
value = Integer.parseInt (string);
@@ -580,9 +599,55 @@
if (min <= value && value <= max) return value;
} catch (NumberFormatException e) {
}
+ parseFail [0] = true;
return -1;
}
+/**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field, or an empty string if there are no
+ * contents.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException setTextLimit()
, it will be the constant
+ * Spinner.LIMIT
.
+ *
+ * @return the text limit
+ *
+ * @exception DWTException
+ * To reset this value to the default, use setTextLimit(Spinner.LIMIT)
.
+ * Specifying a limit value larger than Spinner.LIMIT
sets the
+ * receiver's limit to Spinner.LIMIT
.
+ *
TabFolder
.
*
* @return the receiver's parent
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Table.d
--- a/dwt/widgets/Table.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Table.d Sat May 17 17:34:28 2008 +0200
@@ -33,6 +33,7 @@
import dwt.widgets.Event;
import dwt.widgets.Control;
import dwt.widgets.Display;
+import dwt.widgets.Shell;
import dwt.dwthelper.utils;
@@ -66,12 +67,13 @@
*
*
* Note that although this class is a subclass of Composite
,
- * it does not make sense to add Control
children to it,
- * or set a layout on it.
+ * it does not normally make sense to add Control
children to
+ * it, or set a layout on it, unless implementing something like a cell
+ * editor.
*
*
true
if the item is selected,
* and false
otherwise. Indices out of
@@ -2744,7 +2939,7 @@
TableItem item = items [index];
if (item !is null && !item.isDisposed ()) item.release (false);
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) error (DWT.ERROR_ITEM_NOT_REMOVED);
System.arraycopy (items, index + 1, items, index, --count - index);
@@ -2778,7 +2973,7 @@
if (item !is null && !item.isDisposed ()) item.release (false);
setDeferResize (true);
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) error (DWT.ERROR_ITEM_NOT_REMOVED);
System.arraycopy (items, index + 1, items, index, --count - index);
@@ -2819,7 +3014,7 @@
TableItem item = items [index];
if (item !is null && !item.isDisposed ()) item.release (false);
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) break;
index++;
@@ -2873,7 +3068,7 @@
int index = itemCount - 1;
while (index >= 0) {
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) break;
--index;
@@ -2892,7 +3087,7 @@
if (index !is -1) error (DWT.ERROR_ITEM_NOT_REMOVED);
} else {
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEALLITEMS, 0, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEALLITEMS, 0, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) error (DWT.ERROR_ITEM_NOT_REMOVED);
}
@@ -3067,10 +3262,8 @@
ignoreSelect = false;
}
-void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW* nmcd, int lParam) {
+void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW* nmcd, int lParam, Event measureEvent) {
auto hDC = nmcd.nmcd.hdc;
- auto hFont = item.cellFont !is null ? item.cellFont [nmcd.iSubItem] : cast(HFONT)-1;
- if (hFont is cast(HFONT)-1) hFont = item.font;
int clrText = item.cellForeground !is null ? item.cellForeground [nmcd.iSubItem] : -1;
if (clrText is -1) clrText = item.foreground;
int clrTextBk = -1;
@@ -3105,7 +3298,7 @@
}
if (OS.IsWindowEnabled (handle)) {
if (selected && (nmcd.iSubItem is 0 || (style & DWT.FULL_SELECTION) !is 0)) {
- if (OS.GetFocus () is handle) {
+ if (OS.GetFocus () is handle || display.getHighContrast ()) {
drawSelected = true;
data.foreground = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);
data.background = clrSelectionBk = OS.GetSysColor (OS.COLOR_HIGHLIGHT);
@@ -3120,16 +3313,17 @@
} else {
drawBackground = clrTextBk !is -1;
/*
- * Bug in Windows. When LVM_SETTEXTBKCOLOR or LVM_SETBKCOLOR
- * is used to set the background color of the the text or the
- * control, the color is not set in the HDC that is provided
- * in Custom Draw. The fix is to explicitly set the background
- * color.
+ * Bug in Windows. When LVM_SETTEXTBKCOLOR, LVM_SETBKCOLOR
+ * or LVM_SETTEXTCOLOR is used to set the background color of
+ * the the text or the control, the color is not set in the HDC
+ * that is provided in Custom Draw. The fix is to explicitly
+ * set the color.
*/
- if (clrTextBk is -1) {
+ if (clrText is -1 || clrTextBk is -1) {
Control control = findBackgroundControl ();
if (control is null) control = this;
- clrTextBk = control.getBackgroundPixel ();
+ if (clrText is -1) clrText = control.getForegroundPixel ();
+ if (clrTextBk is -1) clrTextBk = control.getBackgroundPixel ();
}
data.foreground = clrText !is -1 ? clrText : OS.GetTextColor (hDC);
data.background = clrTextBk !is -1 ? clrTextBk : OS.GetBkColor (hDC);
@@ -3139,7 +3333,7 @@
data.background = OS.GetSysColor (OS.COLOR_3DFACE);
if (selected) clrSelectionBk = data.background;
}
- data.hFont = hFont;
+ data.font = item.getFont (nmcd.iSubItem);
data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
auto nSavedDC = OS.SaveDC (hDC);
GC gc = GC.win32_new (hDC, data);
@@ -3158,6 +3352,7 @@
}
}
}
+ bool focused = (event.detail & DWT.FOCUSED) !is 0;
if (drawHot) event.detail |= DWT.HOT;
if (drawSelected) event.detail |= DWT.SELECTED;
if (drawBackground) event.detail |= DWT.BACKGROUND;
@@ -3196,10 +3391,7 @@
OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
}
}
- if (ignoreDrawFocus) {
- nmcd.nmcd.uItemState &= ~OS.CDIS_FOCUS;
- OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
- }
+
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
bool firstColumn = nmcd.iSubItem is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
if (ignoreDrawForeground && ignoreDrawHot) {
@@ -3208,37 +3400,55 @@
fillBackground (hDC, clrTextBk, &backgroundRect);
}
}
- if (!ignoreDrawHot || (!ignoreDrawSelection && clrSelectionBk !is -1)) {
+ focusRect = null;
+ if (!ignoreDrawHot || !ignoreDrawSelection || !ignoreDrawFocus) {
+ bool fullText = (style & DWT.FULL_SELECTION) !is 0 || !firstColumn;
+ RECT textRect = item.getBounds (nmcd.nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC);
+ if ((style & DWT.FULL_SELECTION) is 0) {
+ if (measureEvent !is null) {
+ textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width);
+ }
+ if (!ignoreDrawFocus) {
+ nmcd.nmcd.uItemState &= ~OS.CDIS_FOCUS;
+ OS.MoveMemory (cast(void*)lParam, &nmcd, NMLVCUSTOMDRAW.sizeof);
+ focusRect = new RECT;
+ *focusRect = textRect;
+ }
+ }
if (explorerTheme) {
- bool hot = drawHot;
- RECT pClipRect;
- OS.SetRect (&pClipRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom);
- RECT rect;
- OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom);
- if ((style & DWT.FULL_SELECTION) !is 0) {
- int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
- int index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
- RECT headerRect;
- OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, &headerRect);
- OS.MapWindowPoints (hwndHeader, handle, cast(POINT*) &headerRect, 2);
- rect.left = 0;
- rect.right = headerRect.right;
- pClipRect.left = cellRect.left;
- pClipRect.right += EXPLORER_EXTRA;
- } else {
- rect.right += EXPLORER_EXTRA;
- pClipRect.right += EXPLORER_EXTRA;
+ if (!ignoreDrawHot || (!ignoreDrawSelection && clrSelectionBk !is -1)) {
+ bool hot = drawHot;
+ RECT pClipRect;
+ OS.SetRect (&pClipRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom);
+ RECT rect;
+ OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom);
+ if ((style & DWT.FULL_SELECTION) !is 0) {
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ int index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
+ RECT headerRect;
+ OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, &headerRect);
+ OS.MapWindowPoints (hwndHeader, handle, cast(POINT*) &headerRect, 2);
+ rect.left = 0;
+ rect.right = headerRect.right;
+ pClipRect.left = cellRect.left;
+ pClipRect.right += EXPLORER_EXTRA;
+ } else {
+ rect.right += EXPLORER_EXTRA;
+ pClipRect.right += EXPLORER_EXTRA;
+ }
+ auto hTheme = OS.OpenThemeData (handle, Display.LISTVIEW.ptr);
+ int iStateId = selected ? OS.LISS_SELECTED : OS.LISS_HOT;
+ if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.LISS_SELECTEDNOTFOCUS;
+ OS.DrawThemeBackground (hTheme, hDC, OS.LVP_LISTITEM, iStateId, &rect, &pClipRect);
+ OS.CloseThemeData (hTheme);
}
- auto hTheme = OS.OpenThemeData (handle, Display.LISTVIEW.ptr);
- int iStateId = selected ? OS.LISS_SELECTED : OS.LISS_HOT;
- if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.LISS_SELECTEDNOTFOCUS;
- OS.DrawThemeBackground (hTheme, hDC, OS.LVP_LISTITEM, iStateId, &rect, &pClipRect);
- OS.CloseThemeData (hTheme);
} else {
- bool fullText = ((style & DWT.FULL_SELECTION) !is 0 || !firstColumn);
- RECT textRect = item.getBounds (nmcd.nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC);
- fillBackground (hDC, clrSelectionBk, &textRect);
- }
+ if (!ignoreDrawSelection && clrSelectionBk !is -1) fillBackground (hDC, clrSelectionBk, &textRect);
+ }
+ }
+ if (focused && ignoreDrawFocus) {
+ nmcd.nmcd.uItemState &= ~OS.CDIS_FOCUS;
+ OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
}
if (ignoreDrawForeground) {
RECT clipRect = item.getBounds (nmcd.nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, false, hDC);
@@ -3248,13 +3458,40 @@
}
}
-Event sendMeasureItemEvent (TableItem item, int row, int column, HDC hDC) {
- auto hFont = item.cellFont !is null ? item.cellFont [column] : cast(HFONT)-1;
- if (hFont is cast(HFONT)-1) hFont = item.font;
+Event sendEraseItemEvent (TableItem item, NMTTCUSTOMDRAW* nmcd, int column, RECT* cellRect) {
+ int nSavedDC = OS.SaveDC (nmcd.nmcd.hdc);
+ RECT* insetRect = toolTipInset (cellRect);
+ OS.SetWindowOrgEx (nmcd.nmcd.hdc, insetRect.left, insetRect.top, null);
GCData data = new GCData ();
data.device = display;
- data.hFont = hFont;
- auto nSavedDC = OS.SaveDC (hDC);
+ data.foreground = OS.GetTextColor (nmcd.nmcd.hdc);
+ data.background = OS.GetBkColor (nmcd.nmcd.hdc);
+ data.font = item.getFont (column);
+ data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ GC gc = GC.win32_new (nmcd.nmcd.hdc, data);
+ Event event = new Event ();
+ event.item = item;
+ event.index = column;
+ event.gc = gc;
+ event.detail |= DWT.FOREGROUND;
+ event.x = cellRect.left;
+ event.y = cellRect.top;
+ event.width = cellRect.right - cellRect.left;
+ event.height = cellRect.bottom - cellRect.top;
+ //gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (DWT.EraseItem, event);
+ event.gc = null;
+ //int newTextClr = data.foreground;
+ gc.dispose ();
+ OS.RestoreDC (nmcd.nmcd.hdc, nSavedDC);
+ return event;
+}
+
+Event sendMeasureItemEvent (TableItem item, int row, int column, HDC hDC) {
+ GCData data = new GCData ();
+ data.device = display;
+ data.font = item.getFont (column);
+ int nSavedDC = OS.SaveDC (hDC);
GC gc = GC.win32_new (hDC, data);
RECT itemRect = item.getBounds (row, column, true, true, false, false, hDC);
Event event = new Event ();
@@ -3281,7 +3518,16 @@
return event;
}
-LRESULT sendMouseDownEvent (int type, int button, int msg, int wParam, int lParam) {
+LRESULT sendMouseDownEvent (int type, int button, int msg, int /*long*/ wParam, int /*long*/ lParam) {
+ Display display = this.display;
+ display.captureChanged = false;
+ if (!sendMouseEvent (type, button, handle, msg, wParam, lParam)) {
+ if (!display.captureChanged && !isDisposed ()) {
+ if (OS.GetCapture () !is handle) OS.SetCapture (handle);
+ }
+ return LRESULT.ZERO;
+ }
+
/*
* Feature in Windows. Inside WM_LBUTTONDOWN and WM_RBUTTONDOWN,
* the widget starts a modal loop to determine if the user wants
@@ -3295,16 +3541,30 @@
* the widget does not eat the mouse up.
*/
LVHITTESTINFO pinfo;
- pinfo.pt.x = cast(short) (lParam & 0xFFFF);
- pinfo.pt.y = cast(short) (lParam >> 16);
+ pinfo.pt.x = OS.GET_X_LPARAM (lParam);
+ pinfo.pt.y = OS.GET_Y_LPARAM (lParam);
OS.SendMessage (handle, OS.LVM_HITTEST, 0, &pinfo);
- Display display = this.display;
- display.captureChanged = false;
- if (!sendMouseEvent (type, button, handle, msg, wParam, lParam)) {
- if (!display.captureChanged && !isDisposed ()) {
- if (OS.GetCapture () !is handle) OS.SetCapture (handle);
- }
- return LRESULT.ZERO;
+ if ((style & DWT.FULL_SELECTION) is 0) {
+ if (hooks (DWT.MeasureItem)) {
+ OS.SendMessage (handle, OS.LVM_SUBITEMHITTEST, 0, &pinfo);
+ if (pinfo.iItem is -1) {
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ if (count !is 0) {
+ RECT rect;
+ rect.left = OS.LVIR_ICON;
+ ignoreCustomDraw = true;
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, &rect);
+ ignoreCustomDraw = false;
+ if (code !is 0) {
+ pinfo.pt.x = rect.left;
+ OS.SendMessage (handle, OS.LVM_SUBITEMHITTEST, 0, &pinfo);
+ pinfo.flags &= ~(OS.LVHT_ONITEMICON | OS.LVHT_ONITEMLABEL);
+ }
+ }
+ } else {
+ if (pinfo.iSubItem !is 0) pinfo.iItem = -1;
+ }
+ }
}
/*
@@ -3354,6 +3614,21 @@
forceSelect = true;
}
}
+
+ /* Determine whether the user has selected an item based on DWT.MeasureItem */
+ fullRowSelect = false;
+ if (pinfo.iItem !is -1) {
+ if ((style & DWT.FULL_SELECTION) is 0) {
+ if (hooks (DWT.MeasureItem)) {
+ fullRowSelect = hitTestSelection (pinfo.iItem, pinfo.pt.x, pinfo.pt.y);
+ if (fullRowSelect) {
+ int flags = OS.LVHT_ONITEMICON | OS.LVHT_ONITEMLABEL;
+ if ((pinfo.flags & flags) !is 0) fullRowSelect = false;
+ }
+ }
+ }
+ }
+
/*
* Feature in Windows. Inside WM_LBUTTONDOWN and WM_RBUTTONDOWN,
* the widget starts a modal loop to determine if the user wants
@@ -3366,11 +3641,31 @@
if (!dragDetect) {
int flags = OS.LVHT_ONITEMICON | OS.LVHT_ONITEMLABEL;
dragDetect = pinfo.iItem is -1 || (pinfo.flags & flags) is 0;
- }
+ if (fullRowSelect) dragDetect = true;
+ }
+
+ /*
+ * Temporarily set LVS_EX_FULLROWSELECT to allow drag and drop
+ * and the mouse to manipulate items based on the results of
+ * the DWT.MeasureItem event.
+ */
+ if (fullRowSelect) {
+ OS.UpdateWindow (handle);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, OS.LVS_EX_FULLROWSELECT, OS.LVS_EX_FULLROWSELECT);
+ }
+ dragStarted = false;
+ display.dragCancelled = false;
if (!dragDetect) display.runDragDrop = false;
- int code = callWindowProc (handle, msg, wParam, lParam, forceSelect);
+ int /*long*/ code = callWindowProc (handle, msg, wParam, lParam, forceSelect);
if (!dragDetect) display.runDragDrop = true;
- if (dragStarted || !dragDetect) {
+ if (fullRowSelect) {
+ fullRowSelect = false;
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, OS.LVS_EX_FULLROWSELECT, 0);
+ }
+
+ if (dragStarted || display.dragCancelled) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () !is handle) OS.SetCapture (handle);
}
@@ -3384,7 +3679,6 @@
sendMouseEvent (DWT.MouseUp, button, handle, msg, wParam, lParam);
}
}
- dragStarted = false;
return new LRESULT (code);
}
@@ -3392,9 +3686,7 @@
auto hDC = nmcd.nmcd.hdc;
GCData data = new GCData ();
data.device = display;
- auto hFont = item.cellFont !is null ? item.cellFont [nmcd.iSubItem] : cast(HFONT)-1;
- if (hFont is cast(HFONT)-1) hFont = item.font;
- data.hFont = hFont;
+ data.font = item.getFont (nmcd.iSubItem);
/*
* Bug in Windows. For some reason, CDIS_SELECTED always set,
* even for items that are not selected. The fix is to get
@@ -3412,7 +3704,7 @@
}
if (OS.IsWindowEnabled (handle)) {
if (selected && (nmcd.iSubItem is 0 || (style & DWT.FULL_SELECTION) !is 0)) {
- if (OS.GetFocus () is handle) {
+ if (OS.GetFocus () is handle || display.getHighContrast ()) {
drawSelected = true;
if (selectionForeground !is -1) {
data.foreground = selectionForeground;
@@ -3437,16 +3729,17 @@
if (clrTextBk is -1) clrTextBk = item.background;
drawBackground = clrTextBk !is -1;
/*
- * Bug in Windows. When LVM_SETTEXTBKCOLOR or LVM_SETBKCOLOR
- * is used to set the background color of the the text or the
- * control, the color is not set in the HDC that is provided
- * in Custom Draw. The fix is to explicitly set the background
- * color.
+ * Bug in Windows. When LVM_SETTEXTBKCOLOR, LVM_SETBKCOLOR
+ * or LVM_SETTEXTCOLOR is used to set the background color of
+ * the the text or the control, the color is not set in the HDC
+ * that is provided in Custom Draw. The fix is to explicitly
+ * set the color.
*/
- if (clrTextBk is -1) {
+ if (clrText is -1 || clrTextBk is -1) {
Control control = findBackgroundControl ();
if (control is null) control = this;
- clrTextBk = control.getBackgroundPixel ();
+ if (clrText is -1) clrText = control.getForegroundPixel ();
+ if (clrTextBk is -1) clrTextBk = control.getBackgroundPixel ();
}
data.foreground = clrText !is -1 ? clrText : OS.GetTextColor (hDC);
data.background = clrTextBk !is -1 ? clrTextBk : OS.GetBkColor (hDC);
@@ -3485,21 +3778,56 @@
int cellHeight = cellRect.bottom - cellRect.top;
gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
sendEvent (DWT.PaintItem, event);
+ if (data.focusDrawn) focusRect = null;
event.gc = null;
gc.dispose ();
OS.RestoreDC (hDC, nSavedDC);
}
-override void setBackgroundImage (HBITMAP hBitmap) {
+Event sendPaintItemEvent (TableItem item, NMTTCUSTOMDRAW* nmcd, int column, RECT* itemRect) {
+ int nSavedDC = OS.SaveDC (nmcd.nmcd.hdc);
+ RECT* insetRect = toolTipInset (itemRect);
+ OS.SetWindowOrgEx (nmcd.nmcd.hdc, insetRect.left, insetRect.top, null);
+ GCData data = new GCData ();
+ data.device = display;
+ data.font = item.getFont (column);
+ data.foreground = OS.GetTextColor (nmcd.nmcd.hdc);
+ data.background = OS.GetBkColor (nmcd.nmcd.hdc);
+ data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ GC gc = GC.win32_new (nmcd.nmcd.hdc, data);
+ Event event = new Event ();
+ event.item = item;
+ event.index = column;
+ event.gc = gc;
+ event.detail |= DWT.FOREGROUND;
+ event.x = itemRect.left;
+ event.y = itemRect.top;
+ event.width = itemRect.right - itemRect.left;
+ event.height = itemRect.bottom - itemRect.top;
+ //gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
+ sendEvent (DWT.PaintItem, event);
+ event.gc = null;
+ gc.dispose ();
+ OS.RestoreDC (nmcd.nmcd.hdc, nSavedDC);
+ return event;
+}
+
+void setBackgroundImage (HBITMAP hBitmap) {
super.setBackgroundImage (hBitmap);
- if (!customDraw) setBackgroundTransparent (hBitmap !is null);
+ if (hBitmap !is null) {
+ setBackgroundTransparent (true);
+ } else {
+ if (!hooks (DWT.MeasureItem) && !hooks (DWT.EraseItem) && !hooks (DWT.PaintItem)) {
+ setBackgroundTransparent (false);
+ }
+ }
}
override void setBackgroundPixel (int newPixel) {
- if (!customDraw) {
+ int oldPixel = OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+ if (oldPixel !is OS.CLR_NONE) {
if (findImageControl () !is null) return;
if (newPixel is -1) newPixel = defaultBackground ();
- int oldPixel = OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
if (oldPixel !is newPixel) {
OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, newPixel);
OS.SendMessage (handle, OS.LVM_SETTEXTBKCOLOR, 0, newPixel);
@@ -3565,7 +3893,11 @@
Control control = findBackgroundControl ();
if (control is null) control = this;
if (control.backgroundImage is null) {
- setBackgroundPixel (control.getBackgroundPixel ());
+ int newPixel = control.getBackgroundPixel ();
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, newPixel);
+ OS.SendMessage (handle, OS.LVM_SETTEXTBKCOLOR, 0, newPixel);
+ if ((style & DWT.CHECK) !is 0) fixCheckboxImageListColor (true);
+ OS.InvalidateRect (handle, null, true);
}
/* Set LVS_EX_FULLROWSELECT */
@@ -3701,9 +4033,16 @@
if (defer) {
if (resizeCount++ is 0) {
wasResized = false;
+ /*
+ * Feature in Windows. When LVM_SETBKCOLOR is used with CLR_NONE
+ * to make the background of the table transparent, drawing becomes
+ * slow. The fix is to temporarily clear CLR_NONE when redraw is
+ * turned off.
+ */
if (hooks (DWT.MeasureItem) || hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) {
if (drawCount++ is 0 && OS.IsWindowVisible (handle)) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, 0xFFFFFF);
}
}
}
@@ -3711,6 +4050,7 @@
if (--resizeCount is 0) {
if (hooks (DWT.MeasureItem) || hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) {
if (--drawCount is 0 /*&& OS.IsWindowVisible (handle)*/) {
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, OS.CLR_NONE);
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
static if (OS.IsWinCE) {
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
@@ -4004,7 +4344,7 @@
if (item !is null && !item.isDisposed ()) item.release (false);
if (!isVirtual) {
ignoreSelect = ignoreShrink = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, count, 0);
+ int /*long*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, count, 0);
ignoreSelect = ignoreShrink = false;
if (code is 0) break;
}
@@ -4241,25 +4581,23 @@
int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
while (index < itemCount) {
String string = null;
- HFONT font = cast(HFONT)-1;
+ HFONT hFont = cast(HFONT)-1;
if (item !is null) {
string = item.text;
imageIndent = Math.max (imageIndent, item.imageIndent);
- if (item.cellFont !is null) font = item.cellFont [0];
- if (font is cast(HFONT)-1) font = item.font;
+ hFont = item.fontHandle (0);
} else {
if (items [index] !is null) {
TableItem tableItem = items [index];
string = tableItem.text;
imageIndent = Math.max (imageIndent, tableItem.imageIndent);
- if (tableItem.cellFont !is null) font = tableItem.cellFont [0];
- if (font is cast(HFONT)-1) font = tableItem.font;
+ hFont = tableItem.fontHandle (0);
}
}
if (string !is null && string.length !is 0) {
- if (font !is cast(HFONT)-1) {
+ if (hFont !is cast(HFONT)-1) {
auto hDC = OS.GetDC (handle);
- auto oldFont = OS.SelectObject (hDC, font);
+ auto oldFont = OS.SelectObject (hDC, hFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
TCHAR[] buffer = StrToTCHARs (getCodePage (), string, false);
RECT rect;
@@ -4865,8 +5203,31 @@
super.subclass ();
if (HeaderProc !is null) {
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, display.windowProc);
- }
+ OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, display.windowProc);
+ }
+}
+
+RECT* toolTipInset (RECT* rect) {
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
+ RECT* insetRect = new RECT;
+ OS.SetRect (insetRect, rect.left - 1, rect.top - 1, rect.right + 1, rect.bottom + 1);
+ return insetRect;
+ }
+ return rect;
+}
+
+RECT* toolTipRect (RECT* rect) {
+ RECT* toolRect = new RECT;
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
+ OS.SetRect (toolRect, rect.left - 1, rect.top - 1, rect.right + 1, rect.bottom + 1);
+ } else {
+ HWND hwndToolTip = cast(HWND)OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
+ OS.SetRect (toolRect, rect.left, rect.top, rect.right, rect.bottom);
+ int dwStyle = OS.GetWindowLong (hwndToolTip, OS.GWL_STYLE);
+ int dwExStyle = OS.GetWindowLong (hwndToolTip, OS.GWL_EXSTYLE);
+ OS.AdjustWindowRectEx (toolRect, dwStyle, false, dwExStyle);
+ }
+ return toolRect;
}
override String toolTipText (NMTTDISPINFO* hdr) {
@@ -4885,7 +5246,7 @@
super.unsubclass ();
if (HeaderProc !is null) {
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, cast(int) HeaderProc);
+ OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, cast(LONG_PTR)HeaderProc);
}
}
@@ -4904,15 +5265,15 @@
*/
WNDPROC oldHeaderProc, oldTableProc;
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- bool fixSubclass = !hasChildren () && !hooks (DWT.Paint) && !filters (DWT.Paint);
+ bool fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
- oldTableProc = cast(WNDPROC) OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int) TableProc);
- oldHeaderProc = cast(WNDPROC) OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, cast(int) HeaderProc);
+ oldTableProc = cast(WNDPROC)OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR)TableProc);
+ oldHeaderProc = cast(WNDPROC)OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, cast(LONG_PTR)HeaderProc);
}
super.update (all);
if (fixSubclass) {
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int) oldTableProc);
- OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, cast(int) oldHeaderProc);
+ OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR)oldTableProc);
+ OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, cast(LONG_PTR)oldHeaderProc);
}
}
@@ -5044,13 +5405,12 @@
}
case OS.WM_SETCURSOR: {
if (wParam is cast(int)hwnd) {
- int hitTest = cast(short) (lParam & 0xFFFF);
+ int hitTest = cast(short) OS.LOWORD (lParam);
if (hitTest is OS.HTCLIENT) {
HDHITTESTINFO pinfo;
int pos = OS.GetMessagePos ();
POINT pt;
- pt.x = cast(short) (pos & 0xFFFF);
- pt.y = cast(short) (pos >> 16);
+ OS.POINTSTOPOINT (pt, pos);
OS.ScreenToClient (hwnd, &pt);
pinfo.pt.x = pt.x;
pinfo.pt.y = pt.y;
@@ -5070,6 +5430,19 @@
}
return callWindowProc (hwnd, msg, wParam, lParam);
}
+ if (msg is Display.DI_GETDRAGIMAGE) {
+ /*
+ * Bug in Windows. For some reason, DI_GETDRAGIMAGE
+ * returns an image that does not contain strings.
+ * The fix is to disable the table window proc.
+ *
+ * NOTE: This only happens on Vista.
+ */
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) return 0;
+ //TEMPORARY CODE
+ if (hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) return 0;
+// if (getSelectionCount () !is 1) return 0;
+ }
return super.windowProc (hwnd, msg, wParam, lParam);
}
@@ -5094,7 +5467,7 @@
* This allows the application to cancel an operation that is normally
* performed in WM_KEYDOWN from WM_CHAR.
*/
- int code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ int /*long*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
return new LRESULT (code);
case DWT.CR:
/*
@@ -5203,18 +5576,18 @@
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- int oldHeaderProc = 0, oldTableProc = 0;
+ int /*long*/ oldHeaderProc = 0, oldTableProc = 0;
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- bool fixSubclass = !hasChildren () && !hooks (DWT.Paint) && !filters (DWT.Paint);
+ bool fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
- oldTableProc = OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int) TableProc);
- oldHeaderProc = OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, cast(int) HeaderProc);
+ oldTableProc = OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR)TableProc);
+ oldHeaderProc = OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, cast(LONG_PTR)HeaderProc);
}
- int code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ int /*long*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
result = code is 0 ? LRESULT.ZERO : new LRESULT (code);
if (fixSubclass) {
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldTableProc);
- OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, oldHeaderProc);
+ OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, oldTableProc);
+ OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, oldHeaderProc);
}
//FALL THROUGH
case OS.VK_UP:
@@ -5250,8 +5623,8 @@
* case and avoid calling the window proc.
*/
LVHITTESTINFO pinfo;
- pinfo.pt.x = cast(short) (lParam & 0xFFFF);
- pinfo.pt.y = cast(short) (lParam >> 16);
+ pinfo.pt.x = OS.GET_X_LPARAM (lParam);
+ pinfo.pt.y = OS.GET_Y_LPARAM (lParam);
int index = OS.SendMessage (handle, OS.LVM_HITTEST, 0, &pinfo);
Display display = this.display;
display.captureChanged = false;
@@ -5302,8 +5675,8 @@
/* Look for check/uncheck */
if ((style & DWT.CHECK) !is 0) {
LVHITTESTINFO pinfo;
- pinfo.pt.x = cast(short) (lParam & 0xFFFF);
- pinfo.pt.y = cast(short) (lParam >> 16);
+ pinfo.pt.x = OS.GET_X_LPARAM (lParam);
+ pinfo.pt.y = OS.GET_Y_LPARAM (lParam);
/*
* Note that when the table has LVS_EX_FULLROWSELECT and the
* user clicks anywhere on a row except on the check box, all
@@ -5422,8 +5795,8 @@
* case and avoid calling the window proc.
*/
LVHITTESTINFO pinfo;
- pinfo.pt.x = cast(short) (lParam & 0xFFFF);
- pinfo.pt.y = cast(short) (lParam >> 16);
+ pinfo.pt.x = OS.GET_X_LPARAM (lParam);
+ pinfo.pt.y = OS.GET_Y_LPARAM (lParam);
OS.SendMessage (handle, OS.LVM_HITTEST, 0, &pinfo);
Display display = this.display;
display.captureChanged = false;
@@ -5507,7 +5880,32 @@
return result;
}
-override LRESULT WM_SIZE (int wParam, int lParam) {
+override LRESULT WM_SETREDRAW (int wParam, int lParam) {
+ LRESULT result = super.WM_SETREDRAW (wParam, lParam);
+ if (result !is null) return result;
+ /*
+ * Feature in Windows. When LVM_SETBKCOLOR is used with CLR_NONE
+ * to make the background of the table transparent, drawing becomes
+ * slow. The fix is to temporarily clear CLR_NONE when redraw is
+ * turned off.
+ */
+ if (wParam is 1) {
+ if (OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) !is OS.CLR_NONE) {
+ if (hooks (DWT.MeasureItem) || hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) {
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, OS.CLR_NONE);
+ }
+ }
+ }
+ int /*long*/ code = callWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
+ if (wParam is 0) {
+ if (OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) is OS.CLR_NONE) {
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, 0xFFFFFF);
+ }
+ }
+ return code is 0 ? LRESULT.ZERO : new LRESULT (code);
+}
+
+override LRESULT WM_SIZE (int /*long*/ wParam, int /*long*/ lParam) {
if (ignoreResize) return null;
if (hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) {
OS.InvalidateRect (handle, null, true);
@@ -5525,8 +5923,11 @@
if (findBackgroundControl () is null) {
setBackgroundPixel (defaultBackground ());
} else {
- if ((style & DWT.CHECK) !is 0) {
- fixCheckboxImageListColor (true);
+ int oldPixel = OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+ if (oldPixel !is OS.CLR_NONE) {
+ if (findImageControl () is null) {
+ if ((style & DWT.CHECK) !is 0) fixCheckboxImageListColor (true);
+ }
}
}
return result;
@@ -5551,27 +5952,78 @@
}
/*
- * When there are many columns in a table, scrolling performance
- * can be improved by temporarily unsubclassing the window proc
- * so that internal messages are dispatched directly to the table.
- * If the application expects to see a paint event or has a child
- * whose font, foreground or background color might be needed,
- * the window proc cannot be unsubclassed
+ * Feature in Windows. When there are many columns in a table,
+ * scrolling performance can be improved by unsubclassing the
+ * window proc so that internal messages are dispatched directly
+ * to the table. If the application expects to see a paint event
+ * or has a child whose font, foreground or background color might
+ * be needed, the window proc cannot be unsubclassed
*
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- int oldHeaderProc = 0, oldTableProc = 0;
+ WNDPROC oldHeaderProc, oldTableProc;
auto hwndHeader = cast(HWND) OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- bool fixSubclass = !hasChildren () && !hooks (DWT.Paint) && !filters (DWT.Paint);
+ bool fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
- oldTableProc = OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int)TableProc);
- oldHeaderProc = OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, cast(int)HeaderProc);
- }
+ oldTableProc = cast(WNDPROC)OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR)TableProc);
+ oldHeaderProc = cast(WNDPROC)OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, cast(LONG_PTR)HeaderProc);
+ }
+
+ /*
+ * Feature in Windows. For some reason, when the table window
+ * proc processes WM_HSCROLL or WM_VSCROLL when there are many
+ * columns in the table, scrolling is slow and the table does
+ * not keep up with the position of the scroll bar. The fix
+ * is to turn off redraw, scroll, turn redraw back on and redraw
+ * the entire table. Strangly, redrawing the entire table is
+ * faster.
+ */
+ bool fixScroll = false;
+ if (OS.LOWORD (wParam) !is OS.SB_ENDSCROLL) {
+ if (OS.COMCTL32_MAJOR >= 6) {
+ if (columnCount > H_SCROLL_LIMIT) {
+ int rowCount = OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
+ if (rowCount > V_SCROLL_LIMIT) fixScroll = drawCount is 0 && OS.IsWindowVisible (handle);
+ }
+ }
+ }
+ if (fixScroll) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
LRESULT result = super.WM_HSCROLL (wParam, lParam);
+ if (fixScroll) {
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, null, flags);
+ /*
+ * Feature in Windows. On Vista only, it is faster to
+ * compute and answer the data for the visible columns
+ * of a table when scrolling, rather than just return
+ * the data for each column when asked.
+ */
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
+ RECT headerRect, rect;
+ OS.GetClientRect (handle, &rect);
+ bool [] visible = new bool [columnCount];
+ for (int i=0; i+ * Note that due to a restriction on some platforms, the first column + * is always left aligned. + *
* @param parent a composite control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * @param index the zero-relative index to store the receiver in its parent @@ -387,8 +390,7 @@ for (int i=0; iRIGHT
* or CENTER
.
- *
+ * + * Note that due to a restriction on some platforms, the first column + * is always left aligned. + *
* @param alignment the new alignment * * @exception DWTException*
* Note that although this class is a subclass of Composite
,
- * it does not make sense to add Control
children to it,
- * or set a layout on it.
+ * it does not normally make sense to add Control
children to
+ * it, or set a layout on it, unless implementing something like a cell
+ * editor.
*
*
* If the receiver is single-select, do nothing.
@@ -4085,8 +4329,8 @@
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.state = OS.TVIS_SELECTED;
tvItem.stateMask = OS.TVIS_SELECTED;
- int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int) TreeProc);
+ int /*long*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR)TreeProc);
if ((style & DWT.VIRTUAL) !is 0) {
HANDLE hItem = cast(HANDLE) OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
select (hItem, &tvItem);
@@ -4099,7 +4343,95 @@
}
}
}
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, oldProc);
+}
+
+Event sendEraseItemEvent (TreeItem item, NMTTCUSTOMDRAW* nmcd, int column, RECT* cellRect) {
+ int nSavedDC = OS.SaveDC (nmcd.nmcd.hdc);
+ RECT* insetRect = toolTipInset (cellRect);
+ OS.SetWindowOrgEx (nmcd.nmcd.hdc, insetRect.left, insetRect.top, null);
+ GCData data = new GCData ();
+ data.device = display;
+ data.foreground = OS.GetTextColor (nmcd.nmcd.hdc);
+ data.background = OS.GetBkColor (nmcd.nmcd.hdc);
+ data.font = item.getFont (column);
+ data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ GC gc = GC.win32_new (nmcd.nmcd.hdc, data);
+ Event event = new Event ();
+ event.item = item;
+ event.index = column;
+ event.gc = gc;
+ event.detail |= DWT.FOREGROUND;
+ event.x = cellRect.left;
+ event.y = cellRect.top;
+ event.width = cellRect.right - cellRect.left;
+ event.height = cellRect.bottom - cellRect.top;
+ //gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (DWT.EraseItem, event);
+ event.gc = null;
+ //int newTextClr = data.foreground;
+ gc.dispose ();
+ OS.RestoreDC (nmcd.nmcd.hdc, nSavedDC);
+ return event;
+}
+
+Event sendMeasureItemEvent (TreeItem item, int index, HDC hDC) {
+ RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC);
+ int nSavedDC = OS.SaveDC (hDC);
+ GCData data = new GCData ();
+ data.device = display;
+ data.font = item.getFont (index);
+ GC gc = GC.win32_new (hDC, data);
+ Event event = new Event ();
+ event.item = item;
+ event.gc = gc;
+ event.index = index;
+ event.x = itemRect.left;
+ event.y = itemRect.top;
+ event.width = itemRect.right - itemRect.left;
+ event.height = itemRect.bottom - itemRect.top;
+ sendEvent (DWT.MeasureItem, event);
+ event.gc = null;
+ gc.dispose ();
+ OS.RestoreDC (hDC, nSavedDC);
+ if (isDisposed () || item.isDisposed ()) return null;
+ if (hwndHeader !is null) {
+ if (columnCount is 0) {
+ if (event.x + event.width > scrollWidth) {
+ setScrollWidth (scrollWidth = event.x + event.width);
+ }
+ }
+ }
+ if (event.height > getItemHeight ()) setItemHeight (event.height);
+ return event;
+}
+
+Event sendPaintItemEvent (TreeItem item, NMTTCUSTOMDRAW* nmcd, int column, RECT* itemRect) {
+ int nSavedDC = OS.SaveDC (nmcd.nmcd.hdc);
+ RECT* insetRect = toolTipInset (itemRect);
+ OS.SetWindowOrgEx (nmcd.nmcd.hdc, insetRect.left, insetRect.top, null);
+ GCData data = new GCData ();
+ data.device = display;
+ data.font = item.getFont (column);
+ data.foreground = OS.GetTextColor (nmcd.nmcd.hdc);
+ data.background = OS.GetBkColor (nmcd.nmcd.hdc);
+ data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ GC gc = GC.win32_new (nmcd.nmcd.hdc, data);
+ Event event = new Event ();
+ event.item = item;
+ event.index = column;
+ event.gc = gc;
+ event.detail |= DWT.FOREGROUND;
+ event.x = itemRect.left;
+ event.y = itemRect.top;
+ event.width = itemRect.right - itemRect.left;
+ event.height = itemRect.bottom - itemRect.top;
+ //gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
+ sendEvent (DWT.PaintItem, event);
+ event.gc = null;
+ gc.dispose ();
+ OS.RestoreDC (nmcd.nmcd.hdc, nSavedDC);
+ return event;
}
override void setBackgroundImage (HBITMAP hBitmap) {
@@ -4164,24 +4496,6 @@
updateFullSelection ();
}
-override void setBounds (int x, int y, int width, int height, int flags) {
- /*
- * Ensure that the selection is visible when the tree is resized
- * from a zero size to a size that can show the selection.
- */
- bool fixSelection = false;
- if ((flags & OS.SWP_NOSIZE) is 0 && (width !is 0 || height !is 0)) {
- if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) is 0) {
- fixSelection = true;
- }
- }
- super.setBounds (x, y, width, height, flags);
- if (fixSelection) {
- HANDLE hItem = cast(HANDLE) OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem !is null) showItem (hItem);
- }
-}
-
override void setCursor () {
/*
* Bug in Windows. Under certain circumstances, when WM_SETCURSOR
@@ -4224,39 +4538,35 @@
public void setColumnOrder (int [] order) {
checkWidget ();
if (order is null) error (DWT.ERROR_NULL_ARGUMENT);
- int count = 0;
- if (hwndHeader !is null) {
- count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
- }
- if (count is 0) {
+ if (columnCount is 0) {
if (order.length !is 0) error (DWT.ERROR_INVALID_ARGUMENT);
return;
}
- if (order.length !is count) error (DWT.ERROR_INVALID_ARGUMENT);
- int [] oldOrder = new int [count];
- OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, oldOrder.ptr);
+ if (order.length !is columnCount) error (DWT.ERROR_INVALID_ARGUMENT);
+ int [] oldOrder = new int [columnCount];
+ OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, columnCount, oldOrder.ptr);
bool reorder = false;
- bool [] seen = new bool [count];
+ bool [] seen = new bool [columnCount];
for (int i=0; i
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ *
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ * LEFT
, RIGHT
* or CENTER
.
- *
+ *
@@ -508,7 +496,7 @@
auto hwndHeader = parent.hwndHeader;
if (hwndHeader is null) return;
HDITEM hdItem;
- hdItem.mask = OS.HDI_FORMAT | OS.HDI_IMAGE;
+ hdItem.mask = OS.HDI_FORMAT;
OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, &hdItem);
hdItem.fmt &= ~OS.HDF_JUSTIFYMASK;
if ((style & DWT.LEFT) is DWT.LEFT) hdItem.fmt |= OS.HDF_LEFT;
@@ -623,10 +611,12 @@
case DWT.UP:
hdItem.fmt &= ~(OS.HDF_IMAGE | OS.HDF_SORTDOWN);
hdItem.fmt |= OS.HDF_SORTUP;
+ if (image is null) hdItem.mask &= ~OS.HDI_IMAGE;
break;
case DWT.DOWN:
hdItem.fmt &= ~(OS.HDF_IMAGE | OS.HDF_SORTUP);
hdItem.fmt |= OS.HDF_SORTDOWN;
+ if (image is null) hdItem.mask &= ~OS.HDI_IMAGE;
break;
case DWT.NONE:
hdItem.fmt &= ~(OS.HDF_SORTUP | OS.HDF_SORTDOWN);
@@ -635,6 +625,7 @@
hdItem.iImage = parent.imageIndexHeader (image);
} else {
hdItem.fmt &= ~OS.HDF_IMAGE;
+ hdItem.mask &= ~OS.HDI_IMAGE;
}
break;
default:
@@ -681,7 +672,7 @@
* with spaces.
*/
auto hHeap = OS.GetProcessHeap ();
- TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), fixMnemonic (string), true);
+ TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), fixMnemonic (string, true), true);
int byteCount = buffer.length * TCHAR.sizeof;
auto pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer.ptr, byteCount);
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/TreeItem.d
--- a/dwt/widgets/TreeItem.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/TreeItem.d Sat May 17 17:34:28 2008 +0200
@@ -58,11 +58,11 @@
Tree parent;
String [] strings;
Image [] images;
+ Font font;
+ Font [] cellFont;
bool cached;
int background = -1, foreground = -1;
- HFONT font = cast(HFONT)-1;
int [] cellBackground, cellForeground;
- HFONT[] cellFont;
/**
* Constructs a new instance of this class given its parent
@@ -258,7 +258,7 @@
OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
}
background = foreground = -1;
- HFONT font = cast(HFONT)-1;
+ font = null;
cellBackground = cellForeground = null;
cellFont = null;
if ((parent.style & DWT.VIRTUAL) !is 0) cached = false;
@@ -340,6 +340,12 @@
releaseHandle ();
}
+HFONT fontHandle (int index) {
+ if (cellFont !is null && cellFont [index] !is null) return cellFont [index].handle;
+ if (font !is null) return font.handle;
+ return cast(HFONT)-1;
+}
+
/**
* Returns the receiver's background color.
*
@@ -444,14 +450,13 @@
int columnCount = 0;
auto hwndHeader = parent.hwndHeader;
if (hwndHeader !is null) {
- columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ columnCount = parent.columnCount;
firstColumn = index is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
}
RECT rect;
if (firstColumn) {
- rect.left = cast(int) handle;
bool full = columnCount is 0 && getText && getImage && fullText && fullImage;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, cast(int)&rect) is 0) {
+ if (!OS.TreeView_GetItemRect (hwnd, handle, &rect, !full)) {
return RECT.init;
}
if (getImage && !fullImage) {
@@ -474,7 +479,7 @@
headerRect.right = parent.scrollWidth;
if (headerRect.right is 0) headerRect = rect;
}
- if (fullText) rect.right = headerRect.right;
+ if (fullText && clip) rect.right = headerRect.right;
if (fullImage) rect.left = headerRect.left;
if (clip && headerRect.right < rect.right) {
rect.right = headerRect.right;
@@ -487,12 +492,11 @@
if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) &headerRect) is 0) {
return RECT.init;
}
- rect.left = cast(int)handle;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) is 0) {
+ if (!OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) {
return RECT.init;
}
rect.left = headerRect.left;
- if (fullText && getImage) {
+ if (fullText && getImage && clip) {
rect.right = headerRect.right;
} else {
rect.right = headerRect.left;
@@ -507,7 +511,7 @@
rect.right += size.x;
}
if (getText) {
- if (fullText) {
+ if (fullText && clip) {
rect.left = rect.right + Tree.INSET;
rect.right = headerRect.right;
} else {
@@ -520,8 +524,7 @@
HFONT hFont;
if (hDC is null) {
hNewDC = OS.GetDC (hwnd);
- hFont = cellFont !is null ? cellFont [index] : cast(HFONT)-1;
- if (hFont is cast(HFONT)-1) hFont = font;
+ hFont = fontHandle (index);
if (hFont is cast(HFONT)-1) hFont = cast(HFONT) OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
hFont = OS.SelectObject (hNewDC, hFont);
}
@@ -627,7 +630,7 @@
public Font getFont () {
checkWidget ();
if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
- return font is cast(HFONT)-1 ? parent.getFont () : Font.win32_new (display, font);
+ return font !is null ? font : parent.getFont ();
}
/**
@@ -649,8 +652,8 @@
if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count -1) return getFont ();
- auto hFont = (cellFont !is null) ? cellFont [index] : font;
- return hFont is cast(HFONT)-1 ? getFont () : Font.win32_new (display, hFont);
+ if (cellFont is null || cellFont [index] is null) return getFont ();
+ return cellFont [index];
}
/**
@@ -976,8 +979,6 @@
if (parent.currentItem is this || parent.drawCount !is 0) return;
auto hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
- RECT rect;
- rect.left = cast(int)handle;
/*
* When there are no columns and the tree is not
* full selection, redraw only the text. This is
@@ -985,17 +986,15 @@
*/
bool full = (parent.style & (DWT.FULL_SELECTION | DWT.VIRTUAL)) !is 0;
if (!full) {
- auto hwndHeader = parent.hwndHeader;
- if (hwndHeader !is null) {
- full = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0) !is 0;
- }
+ full = parent.columnCount !is 0;
if (!full) {
if (parent.hooks (DWT.EraseItem) || parent.hooks (DWT.PaintItem)) {
full = true;
}
}
}
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, cast(int) &rect) !is 0) {
+ RECT rect;
+ if (OS.TreeView_GetItemRect (hwnd, handle, &rect, !full)) {
OS.InvalidateRect (hwnd, &rect, true);
}
}
@@ -1178,8 +1177,7 @@
if ((parent.style & DWT.VIRTUAL) !is 0) {
if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
RECT rect;
- rect.left = cast(int) handle;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) !is 0) {
+ if (OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) {
OS.InvalidateRect (hwnd, &rect, true);
}
}
@@ -1238,20 +1236,17 @@
*/
RECT oldRect;
RECT [] rects = null;
- SCROLLINFO oldInfo;
- bool oldInfoNull = true;
+ SCROLLINFO* oldInfo;
int count = 0;
HANDLE hBottomItem;
bool redraw = false, noScroll = true;
HANDLE hTopItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (noScroll && hTopItem !is null) {
- //oldInfo = new SCROLLINFO ();
- oldInfoNull = false;
+ oldInfo = new SCROLLINFO ();
oldInfo.cbSize = SCROLLINFO.sizeof;
oldInfo.fMask = OS.SIF_ALL;
- if (!OS.GetScrollInfo (hwnd, OS.SB_HORZ, &oldInfo)) {
- //oldInfo = null;
- oldInfoNull = true;
+ if (!OS.GetScrollInfo (hwnd, OS.SB_HORZ, oldInfo)) {
+ oldInfo = null;
}
if (parent.drawCount is 0 && OS.IsWindowVisible (hwnd)) {
bool noAnimate = true;
@@ -1261,8 +1256,7 @@
int index = 0;
while (hItem !is null && (noAnimate || hItem !is handle) && index < count) {
RECT rect;
- rect.left = cast(int) hItem;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, cast(int) &rect) !is 0) {
+ if (OS.TreeView_GetItemRect (hwnd, hItem, &rect, true)) {
rects [index++] = rect;
}
hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, cast(int) &hItem);
@@ -1312,10 +1306,8 @@
bool collapsed = false;
if (!expanded) {
RECT rect;
- rect.left = cast(int)hTopItem;
- while (hTopItem !is null && OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) is 0) {
- rect.left = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem);
- hTopItem = cast(HANDLE) rect.left;
+ while (hTopItem !is null && !OS.TreeView_GetItemRect (hwnd, hTopItem, &rect, false)) {
+ hTopItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem);
collapsed = true;
}
}
@@ -1324,13 +1316,13 @@
OS.SendMessage (hwnd, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hTopItem);
scrolled = hTopItem !is cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
}
- if (!collapsed && !scrolled && !oldInfoNull ) {
+ if (!collapsed && !scrolled && oldInfo !is null ) {
SCROLLINFO newInfo;
newInfo.cbSize = SCROLLINFO.sizeof;
newInfo.fMask = OS.SIF_ALL;
if (OS.GetScrollInfo (hwnd, OS.SB_HORZ, &newInfo)) {
if (oldInfo.nPos !is newInfo.nPos) {
- int lParam = OS.SB_THUMBPOSITION | ((oldInfo.nPos << 16) & 0xFFFF0000);
+ int /*long*/ lParam = OS.MAKELPARAM (OS.SB_THUMBPOSITION, oldInfo.nPos);
OS.SendMessage (hwnd, OS.WM_HSCROLL, lParam, 0);
}
}
@@ -1345,8 +1337,7 @@
int index = 0;
while (hItem !is null && index < count) {
RECT rect;
- rect.left = cast(int) hItem;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, cast(int) &rect) !is 0) {
+ if (OS.TreeView_GetItemRect (hwnd, hItem, &rect, true)) {
if (!OS.EqualRect (&rect, & rects [index])) {
break;
}
@@ -1376,8 +1367,7 @@
}
if (handle is hBottomItem) {
RECT rect;
- rect.left = cast(int) hBottomItem;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int)&rect) !is 0) {
+ if (OS.TreeView_GetItemRect (hwnd, hBottomItem, &rect, false)) {
OS.InvalidateRect (hwnd, &rect, true);
}
}
@@ -1427,13 +1417,11 @@
if (font !is null && font.isDisposed ()) {
DWT.error (DWT.ERROR_INVALID_ARGUMENT);
}
- HFONT hFont = cast(HFONT)-1;
- if (font !is null) {
- parent.customDraw = true;
- hFont = font.handle;
- }
- if (this.font is hFont) return;
- this.font = hFont;
+ Font oldFont = this.font;
+ if (oldFont is font) return;
+ this.font = font;
+ if (oldFont !is null && oldFont.opEquals (font)) return;
+ if (font !is null) parent.customDraw = true;
if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
/*
* Bug in Windows. When the font is changed for an item,
@@ -1479,19 +1467,15 @@
}
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return;
- HFONT hFont = cast(HFONT)-1;
- if (font !is null) {
- parent.customDraw = true;
- hFont = font.handle;
+ if (cellFont is null) {
+ if (font is null) return;
+ cellFont = new Font [count];
}
- if (cellFont is null) {
- cellFont = new HFONT [count];
- for (int i = 0; i < count; i++) {
- cellFont [i] = cast(HFONT) -1;
- }
- }
- if (cellFont [index] is hFont) return;
- cellFont [index] = hFont;
+ Font oldFont = cellFont [index];
+ if (oldFont is font) return;
+ cellFont [index] = font;
+ if (oldFont !is null && oldFont.opEquals (font)) return;
+ if (font !is null) parent.customDraw = true;
if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
/*
* Bug in Windows. When the font is changed for an item,
@@ -1633,8 +1617,7 @@
if ((parent.style & DWT.VIRTUAL) !is 0) {
if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
RECT rect;
- rect.left = cast(int)handle;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int)&rect) !is 0) {
+ if (OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) {
OS.InvalidateRect (hwnd, &rect, true);
}
}
diff -r ab60f3309436 -r 36f5cb12e1a2 dwt/widgets/Widget.d
--- a/dwt/widgets/Widget.d Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Widget.d Sat May 17 17:34:28 2008 +0200
@@ -101,6 +101,15 @@
static const int FOREIGN_HANDLE = 1<<14;
static const int DRAG_DETECT = 1<<15;
+ /* Move and resize state flags */
+ static final int MOVE_OCCURRED = 1<<16;
+ static final int MOVE_DEFERRED = 1<<17;
+ static final int RESIZE_OCCURRED = 1<<18;
+ static final int RESIZE_DEFERRED = 1<<19;
+
+ /* Ignore WM_CHANGEUISTATE */
+ static final int IGNORE_WM_CHANGEUISTATE = 1<<20;
+
/* Default size for widgets */
static const int DEFAULT_WIDTH = 64;
static const int DEFAULT_HEIGHT = 64;
@@ -197,6 +206,7 @@
*
* @see Listener
* @see DWT
+ * @see #getListeners(int)
* @see #removeListener(int, Listener)
* @see #notifyListeners
*/
@@ -357,7 +367,27 @@
void checkWidget () {
Display display = this.display;
if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
- if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+ if (display.thread !is Thread.getThis ()) {
+ /*
+ * Bug in IBM JVM 1.6. For some reason, under
+ * conditions that are yet to be full understood,
+ * Thread.currentThread() is either returning null
+ * or a different instance from the one that was
+ * saved when the Display was created. This is
+ * possibly a JIT problem because modifying this
+ * method to print logging information when the
+ * error happens seems to fix the problem. The
+ * fix is to use operating system calls to verify
+ * that the current thread is not the Display thread.
+ *
+ * NOTE: Despite the fact that Thread.currentThread()
+ * is used in other places, the failure has only been
+ * observed here.
+ */
+ if (display.threadId !is OS.GetCurrentThreadId ()) {
+ error (DWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
if ((state & DISPOSED) !is 0) error (DWT.ERROR_WIDGET_DISPOSED);
}
@@ -475,12 +505,17 @@
}
char [] fixMnemonic (String string) {
- char [] buffer = string.dup;
+ return fixMnemonic (string, false);
+}
+
+char [] fixMnemonic (String string, bool spaces) {
+ char [] buffer = string ~ '\0';
int i = 0, j = 0;
while (i < buffer.length) {
if (buffer [i] is '&') {
if (i + 1 < buffer.length && buffer [i + 1] is '&') {
- buffer [j++] = ' ';
+ if (spaces) buffer [j] = ' ';
+ j++;
i++;
}
i++;
@@ -577,6 +612,33 @@
return display;
}
+/**
+ * Returns an array of listeners who will be notified when an event
+ * of the given type occurs. The event type is one of the event constants
+ * defined in class
DWT
.
+ *
+ * @param eventType the type of event to listen for
+ * @return an array of listeners that will be notified when the event occurs
+ *
+ * @exception DWTException
+ *
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addListener(int, Listener)
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ *
+ * @since 3.4
+ */
+public Listener[] getListeners (int eventType) {
+ checkWidget();
+ if (eventTable is null) return new Listener[0];
+ return eventTable.getListeners(eventType);
+}
+
Menu getMenu () {
return null;
}
@@ -732,6 +794,7 @@
*
* @see DWT
* @see #addListener
+ * @see #getListeners(int)
* @see #removeListener(int, Listener)
*/
public void notifyListeners (int eventType, Event event) {
@@ -880,6 +943,7 @@
* @see Listener
* @see DWT
* @see #addListener
+ * @see #getListeners(int)
* @see #notifyListeners
*/
public void removeListener (int eventType, Listener listener) {
@@ -999,13 +1063,13 @@
}
}
-bool sendKeyEvent (int type, int msg, int wParam, int lParam) {
+bool sendKeyEvent (int type, int msg, int /*long*/ wParam, int /*long*/ lParam) {
Event event = new Event ();
if (!setKeyState (event, type, wParam, lParam)) return true;
return sendKeyEvent (type, msg, wParam, lParam, event);
}
-bool sendKeyEvent (int type, int msg, int wParam, int lParam, Event event) {
+bool sendKeyEvent (int type, int msg, int /*long*/ wParam, int /*long*/ lParam, Event event) {
sendEvent (type, event);
if (isDisposed ()) return false;
return event.doit;
@@ -1021,8 +1085,8 @@
event.button = button;
event.detail = detail;
event.count = count;
- event.x = cast(short) (lParam & 0xFFFF);
- event.y = cast(short) (lParam >> 16);
+ event.x = OS.GET_X_LPARAM (lParam);
+ event.y = OS.GET_Y_LPARAM (lParam);
setInputState (event, type);
mapEvent (hwnd, event);
if (send) {
@@ -1149,8 +1213,10 @@
if (OS.GetKeyState (OS.VK_LBUTTON) < 0) event.stateMask |= DWT.BUTTON1;
if (OS.GetKeyState (OS.VK_MBUTTON) < 0) event.stateMask |= DWT.BUTTON2;
if (OS.GetKeyState (OS.VK_RBUTTON) < 0) event.stateMask |= DWT.BUTTON3;
- if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= DWT.BUTTON4;
- if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= DWT.BUTTON5;
+ if (display.xMouse) {
+ if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= DWT.BUTTON4;
+ if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= DWT.BUTTON5;
+ }
switch (type) {
case DWT.MouseDown:
case DWT.MouseDoubleClick:
@@ -1183,7 +1249,7 @@
return true;
}
-bool setKeyState (Event event, int type, int wParam, int lParam) {
+bool setKeyState (Event event, int type, int /*long*/ wParam, int /*long*/ lParam) {
/*
* Feature in Windows. When the user presses Ctrl+Backspace
@@ -1357,16 +1423,16 @@
int x = 0, y = 0;
if (lParam !is -1) {
POINT pt;
- x = pt.x = cast(short) (lParam & 0xFFFF);
- y = pt.y = cast(short) (lParam >> 16);
- OS.ScreenToClient (hwnd, &pt);
+ OS.POINTSTOPOINT (pt, lParam);
+ x = pt.x;
+ y = pt.y;
RECT rect;
OS.GetClientRect (hwnd, &rect);
if (!OS.PtInRect (&rect, pt)) return null;
} else {
int pos = OS.GetMessagePos ();
- x = cast(short) (pos & 0xFFFF);
- y = cast(short) (pos >> 16);
+ x = OS.GET_X_LPARAM (pos);
+ y = OS.GET_Y_LPARAM (pos);
}
/* Show the menu */
@@ -1434,7 +1500,22 @@
default:
}
} else {
- mapKey = OS.MapVirtualKey (wParam, 2);
+ /*
+ * Feature in Windows. For numbers in Marathi and Bengali,
+ * MapVirtualKey() returns the localized number instead of
+ * the ASCII equivalent. For example, MapVirtualKey()
+ * maps VK_1 on the Marathi keyboard to \u2407, which is
+ * a valid Unicode Marathi '1' character, but not ASCII.
+ * The fix is to test for VK_0 to VK_9 and map these
+ * explicitly.
+ *
+ * NOTE: VK_0 to VK_9 are the same as ASCII.
+ */
+ if ('0' <= wParam && wParam <= '9') {
+ mapKey = wParam;
+ } else {
+ mapKey = OS.MapVirtualKey (wParam, 2);
+ }
}
/*
@@ -1718,6 +1799,7 @@
}
LRESULT wmKillFocus (HWND hwnd, int wParam, int lParam) {
+ display.scrollRemainder = 0;
int code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam);
sendFocusEvent (DWT.FocusOut);
// widget could be disposed at this point
@@ -1766,8 +1848,8 @@
LRESULT wmLButtonDown (HWND hwnd, int wParam, int lParam) {
Display display = this.display;
LRESULT result = null;
- int x = cast(short) (lParam & 0xFFFF);
- int y = cast(short) (lParam >> 16);
+ int x = OS.GET_X_LPARAM (lParam);
+ int y = OS.GET_Y_LPARAM (lParam);
bool [] consume = null, detect = null;
bool dragging = false, mouseDown = true;
int count = display.getClickCount (DWT.MouseDown, 1, hwnd, lParam);
@@ -1871,7 +1953,7 @@
*/
int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
- if (((wParam & 0xFFFF) & mask) is 0) {
+ if ((wParam & mask) is 0) {
if (OS.GetCapture () is hwnd) OS.ReleaseCapture ();
}
return result;
@@ -1937,7 +2019,7 @@
*/
int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
- if (((wParam & 0xFFFF) & mask) is 0) {
+ if ((wParam & mask) is 0) {
if (OS.GetCapture () is hwnd) OS.ReleaseCapture ();
}
return result;
@@ -1954,10 +2036,9 @@
if (!hooks (DWT.MouseExit) && !filters (DWT.MouseExit)) return null;
int pos = OS.GetMessagePos ();
POINT pt;
- pt.x = cast(short) (pos & 0xFFFF);
- pt.y = cast(short) (pos >> 16);
+ OS.POINTSTOPOINT (pt, pos);
OS.ScreenToClient (hwnd, &pt);
- lParam = (pt.x & 0xFFFF) | ((pt.y << 16) & 0xFFFF0000);
+ lParam = OS.MAKELPARAM (pt.x, pt.y);
if (!sendMouseEvent (DWT.MouseExit, 0, hwnd, OS.WM_MOUSELEAVE, wParam, lParam)) {
return LRESULT.ZERO;
}
@@ -2017,30 +2098,37 @@
}
LRESULT wmMouseWheel (HWND hwnd, int wParam, int lParam) {
- if (!hooks (DWT.MouseWheel) && !filters (DWT.MouseWheel)) return null;
- int delta = wParam >> 16;
- int value;
- int count, detail;
- OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0);
- if (value is OS.WHEEL_PAGESCROLL) {
+ int delta = OS.GET_WHEEL_DELTA_WPARAM (wParam);
+ int linesToScroll;
+ int detail;
+ OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &linesToScroll, 0);
+ if (linesToScroll is OS.WHEEL_PAGESCROLL) {
detail = DWT.SCROLL_PAGE;
- count = delta / OS.WHEEL_DELTA;
} else {
detail = DWT.SCROLL_LINE;
- count = value * delta / OS.WHEEL_DELTA;
+ delta *= linesToScroll;
}
+ /* Check if the delta and the remainder have the same direction (sign) */
+ if ((delta ^ display.scrollRemainder) >= 0) delta += display.scrollRemainder;
+ display.scrollRemainder = delta % OS.WHEEL_DELTA;
+
+ if (!hooks (DWT.MouseWheel) && !filters (DWT.MouseWheel)) return null;
+ int count = delta / OS.WHEEL_DELTA;
POINT pt;
- pt.x = cast(short) (lParam & 0xFFFF);
- pt.y = cast(short) (lParam >> 16);
+ OS.POINTSTOPOINT (pt, lParam);
OS.ScreenToClient (hwnd, &pt);
- lParam = (pt.x & 0xFFFF) | ((pt.y << 16) & 0xFFFF0000);
+ lParam = OS.MAKELPARAM (pt.x, pt.y);
if (!sendMouseEvent (DWT.MouseWheel, 0, count, detail, true, hwnd, OS.WM_MOUSEWHEEL, wParam, lParam)) {
return LRESULT.ZERO;
}
return null;
}
-LRESULT wmPaint (HWND hwnd, int wParam, int lParam) {
+LRESULT wmNCPaint (HWND hwnd, int /*long*/ wParam, int /*long*/ lParam) {
+ return null;
+}
+
+LRESULT wmPaint (HWND hwnd, int /*long*/ wParam, int /*long*/ lParam) {
/* Exit early - don't draw the background */
if (!hooks (DWT.Paint) && !filters (DWT.Paint)) {
@@ -2048,7 +2136,7 @@
}
/* Issue a paint event */
- int result = 0;
+ int /*long*/ result = 0;
static if (OS.IsWinCE) {
RECT rect;
OS.GetUpdateRect (hwnd, &rect, false);
@@ -2132,7 +2220,7 @@
if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
if ((bits & OS.WS_EX_CLIENTEDGE) !is 0) {
- int code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
+ int /*long*/ code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
RECT rect;
OS.GetWindowRect (hwnd, &rect);
rect.right -= rect.left;
@@ -2210,14 +2298,14 @@
*/
int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
- if (((wParam & 0xFFFF) & mask) is 0) {
+ if ((wParam & mask) is 0) {
if (OS.GetCapture () is hwnd) OS.ReleaseCapture ();
}
return result;
}
LRESULT wmSetFocus (HWND hwnd, int wParam, int lParam) {
- int code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
+ int /*long*/ code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
sendFocusEvent (DWT.FocusIn);
// widget could be disposed at this point
@@ -2246,7 +2334,7 @@
/* Call the window proc to determine whether it is a system key or mnemonic */
bool oldKeyHit = display.mnemonicKeyHit;
display.mnemonicKeyHit = true;
- int result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
+ int /*long*/ result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
bool consumed = false;
if (!display.mnemonicKeyHit) {
consumed = !sendKeyEvent (DWT.KeyDown, OS.WM_SYSCHAR, wParam, lParam);
@@ -2405,7 +2493,7 @@
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
+ int button = OS.HIWORD (wParam) is OS.XBUTTON1 ? 4 : 5;
sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam);
if (sendMouseEvent (DWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam));
@@ -2423,7 +2511,7 @@
Display display = this.display;
display.captureChanged = false;
display.xMouse = true;
- int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
+ int button = OS.HIWORD (wParam) is OS.XBUTTON1 ? 4 : 5;
if (sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam));
} else {
@@ -2438,7 +2526,7 @@
LRESULT wmXButtonUp (HWND hwnd, int wParam, int lParam) {
Display display = this.display;
LRESULT result = null;
- int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
+ int button = OS.HIWORD (wParam) is OS.XBUTTON1 ? 4 : 5;
if (sendMouseEvent (DWT.MouseUp, button, hwnd, OS.WM_XBUTTONUP, wParam, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam));
} else {
@@ -2452,7 +2540,7 @@
*/
int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
- if (((wParam & 0xFFFF) & mask) is 0) {
+ if ((wParam & mask) is 0) {
if (OS.GetCapture () is hwnd) OS.ReleaseCapture ();
}
return result;