*** empty log message ***
diff --git a/bundles/org.eclipse.swt/.vcm_meta b/bundles/org.eclipse.swt/.vcm_meta
deleted file mode 100755
index 67f905f..0000000
--- a/bundles/org.eclipse.swt/.vcm_meta
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-description>
- <comment></comment>
- <nature id="org.eclipse.jdt.core.javanature"/>
- <nature id="org.eclipse.pde.PluginNature"/>
- <builder name="org.eclipse.jdt.core.javabuilder">
- </builder>
- <builder name="org.eclipse.pde.ManifestBuilder">
- </builder>
- <builder name="org.eclipse.pde.SchemaBuilder">
- </builder>
-</project-description>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
index 14ccb40..9e48df2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
@@ -8,8 +9,9 @@
SWT experimental AWT embedding support
<h2>
Package Specification</h2>
-This package contains an experimental <code>SWT_AWT</code> class which provides support for
-embedding AWT widgets within SWT layouts. Currently, this support only works on win32 platforms,
-and has several lightweight widget focus issues.
+This package contains an experimental <code>SWT_AWT</code> class which
+provides support for embedding AWT widgets within SWT layouts. Currently,
+this support only works on win32 platforms, and has several lightweight
+widget focus issues.
</body>
</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/package.html b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/package.html
index bbae43c..d83065a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
index f8c4a95..4a71dca 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
@@ -1029,7 +1029,7 @@
if (event.character == SWT.ESC) { // escape key cancels popup list
dropDown (false);
}
- if (event.character == SWT.CR || event.character == '\t') {
+ if (event.character == SWT.CR) {
dropDown (false);
Event e = new Event();
e.time = event.time;
@@ -1103,10 +1103,10 @@
}
case SWT.Traverse: {
switch (event.detail) {
- case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_RETURN:
case SWT.TRAVERSE_ARROW_PREVIOUS:
case SWT.TRAVERSE_ARROW_NEXT:
- // The tab key causes default selection and
+ // The enter causes default selection and
// the arrow keys are used to manipulate the list contents so
// do not use them for traversal.
event.doit = false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index dbe7cf0..9c295a6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -33,6 +33,9 @@
* <dd>"CTabFolder"</dd>
* </dl>
* <p>
+ * Note: Only one of the styles TOP and BOTTOM
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -203,14 +206,14 @@
};
int[] folderEvents = new int[]{
- SWT.Dispose,
- SWT.MouseDown,
+ SWT.Dispose,
+ SWT.Paint,
+ SWT.Resize,
SWT.MouseDoubleClick,
- SWT.MouseMove,
- SWT.MouseExit,
+ SWT.MouseDown,
+ SWT.MouseExit,
SWT.MouseHover,
- SWT.Paint,
- SWT.Resize,
+ SWT.MouseMove,
SWT.FocusIn,
SWT.FocusOut,
SWT.KeyDown,
@@ -284,7 +287,7 @@
tabListeners = newTabListeners;
tabListeners[tabListeners.length - 1] = listener;
showClose = true;
- layoutItems();
+ layoutButtons();
}
void onClientAreaChange() {
oldArea = null;
@@ -312,13 +315,14 @@
int minWidth = 0;
int minHeight = 0;
- // tab width
- if (items.length > 0) {
- CTabItem lastItem = items[items.length-1];
- minWidth = lastItem.x + lastItem.width;
+ // preferred width of tab area to show all tabs
+ GC gc = new GC(this);
+ for (int i = 0; i < items.length; i++) {
+ minWidth += items[i].preferredWidth(gc);
}
+ gc.dispose();
- // get max preferred size of items
+ // preferred size of controls in tab items
for (int i = 0; i < items.length; i++) {
Control control = items[i].getControl();
if (control != null && !control.isDisposed()){
@@ -334,19 +338,29 @@
if (hHint != SWT.DEFAULT) minHeight = hHint;
Rectangle trim = computeTrim(0, 0, minWidth, minHeight);
- return new Point (trim.width, trim.height);
+ return new Point (trim.width - trim.x, trim.height - trim.y);
}
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
- int tabHeight = getTabHeight();
- int trimX = x - marginWidth - borderLeft;
- int trimY = y - marginHeight - tabHeight - borderTop;
- if (onBottom) {
- trimY = y - marginHeight - borderTop;
+ if (items.length == 0) {
+ if (!showBorders) return new Rectangle(x, y, width, height);
+ int trimX = x - borderRight - 1;
+ int trimY = y - borderBottom - 1;
+ int trimWidth = width + borderRight + 2;
+ int trimHeight = height + borderBottom + 2;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+ } else {
+ int tabHeight = getTabHeight();
+ int trimX = x - marginWidth - borderLeft;
+ int trimY = y - marginHeight - tabHeight - borderTop - 1;
+ // -1 is for the line at the bottom of the tabs
+ if (onBottom) {
+ trimY = y - marginHeight - borderTop;
+ }
+ int trimWidth = width + borderLeft + borderRight + 2*marginWidth;
+ int trimHeight = height + borderTop + borderBottom + 2*marginHeight + tabHeight + 1;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
}
- int trimWidth = width + borderLeft + borderRight + 2*marginWidth;
- int trimHeight = height + borderTop + borderBottom + 2*marginHeight + tabHeight;
- return new Rectangle (trimX, trimY, trimWidth, trimHeight);
}
/**
* Create the specified item at 'index'.
@@ -370,9 +384,8 @@
if (items.length == 1) {
topTabIndex = 0;
}
-
layoutItems();
- ensureVisible();
+ showItem(item);
if (items.length == 1) {
redraw();
@@ -491,7 +504,6 @@
}
layoutItems();
- ensureVisible();
redrawTabArea(-1);
}
private void onKeyDown(Event e) {
@@ -606,12 +618,17 @@
}
public Rectangle getClientArea() {
checkWidget();
- Rectangle clientArea = super.getClientArea();
- clientArea.x = xClient;
- clientArea.y = yClient;
- clientArea.width -= 2*marginWidth + borderLeft + borderRight;
- clientArea.height -= 2*marginHeight + borderTop + borderBottom + getTabHeight() + 1;
- return clientArea;
+ Point size = getSize();
+ if (items.length == 0) {
+ if (!showBorders) return super.getClientArea();
+ int width = size.x - borderRight - 2;
+ int height = size.y - borderBottom - 2;
+ return new Rectangle(borderRight + 1, borderBottom + 1, width, height);
+ } else {
+ int width = size.x - 2*marginWidth - borderLeft - borderRight;
+ int height = size.y - 2*marginHeight - borderTop - borderBottom - getTabHeight() - 1;
+ return new Rectangle(xClient, yClient, width, height);
+ }
}
/**
* Returns the height of the tab
@@ -890,6 +907,7 @@
// When the close button is right at the edge of the Tab folder, hide it because
// otherwise it may block off a part of the border on the right
if (showClose) {
+ inactiveCloseBar.setVisible(false);
CTabItem item = getSelection();
if (item == null) {
closeBar.setVisible(false);
@@ -908,83 +926,45 @@
}
}
}
+boolean setItemsLocation() {
+ if (items.length == 0) return false;
+ Rectangle area = super.getClientArea();
+ int x = area.x;
+ int y = area.y + borderTop;
+ if (onBottom) {
+ int tabHeight = getTabHeight();
+ y = Math.max(0, area.y + area.height - borderBottom - tabHeight);
+ }
+ boolean changed = false;
+ for (int i = topTabIndex - 1; i>=0; i--) {
+ // if the first visible tab is not the first tab
+ CTabItem tab = items[i];
+ x -= tab.width;
+ if (!changed && (tab.x != x || tab.y != y) ) changed = true;
+ // layout tab items from right to left thus making them invisible
+ tab.x = x;
+ tab.y = y;
+ }
+
+ x = area.x + borderLeft;
+ for (int i=topTabIndex; i<items.length; i++) {
+ // continue laying out remaining, visible items left to right
+ CTabItem tab = items[i];
+ tab.x = x;
+ tab.y = y;
+ x = x + tab.width;
+ }
+ layoutButtons();
+ return changed;
+}
/**
* Layout the items and store the client area size.
*/
- void layoutItems() {
- if (isDisposed()) return;
-
+boolean layoutItems() {
+ if (isDisposed()) return false;
Rectangle area = super.getClientArea();
- int tabHeight = getTabHeight();
-
- shortenedTabs = false;
- if (items.length > 0) {
- int[] widths = new int[items.length];
- int totalWidth = 0;
- GC gc = new GC(this);
- for (int i = 0; i < items.length; i++) {
- widths[i] = items[i].preferredWidth(gc);
- totalWidth += widths[i];
- }
- gc.dispose();
- if (totalWidth < (area.width - borderLeft - borderRight) ) {
- topTabIndex = 0;
- } else {
-
- int oldAverageWidth = 0;
- int averageWidth = (area.width - borderLeft - borderRight) / items.length;
- while (averageWidth > oldAverageWidth) {
- int width = area.width - borderLeft - borderRight;
- int count = items.length;
- for (int i = 0; i < items.length; i++) {
- if (widths[i] < averageWidth) {
- width -= widths[i];
- count--;
- }
- }
- oldAverageWidth = averageWidth;
- if (count > 0) {
- averageWidth = width / count;
- }
- }
- if (averageWidth > MIN_TAB_WIDTH * tabHeight) {
- for (int i = 0; i < items.length; i++) {
- if (widths[i] > averageWidth) {
- widths[i] = averageWidth;
- }
- }
- topTabIndex = 0;
- shortenedTabs = true;
- }
- }
- int x = area.x;
- int y = area.y + borderTop;
- if (onBottom) {
- y = Math.max(0, area.y + area.height - borderBottom - tabHeight);
- }
- for (int i = topTabIndex - 1; i>=0; i--) {
- // if the first visible tab is not the first tab
- CTabItem tab = items[i];
- tab.width = widths[i];
- tab.height = getTabHeight();
- x -= tab.width;
- // layout tab items from right to left thus making them invisible
- tab.x = x;
- tab.y = y;
- }
-
- x = area.x + borderLeft;
- for (int i=topTabIndex; i<items.length; i++) {
- // continue laying out remaining, visible items left to right
- CTabItem tab = items[i];
- tab.x = x;
- tab.y = y;
- tab.height = tabHeight;
- tab.width = widths[i];
- x = x + tab.width;
- }
- }
+ int tabHeight = getTabHeight();
xClient = area.x + borderLeft + marginWidth;
if (onBottom) {
yClient = area.y + borderTop + marginHeight;
@@ -993,8 +973,83 @@
// +1 is for the line at the bottom of the tabs
}
- // resize the scrollbar and close butotns
- layoutButtons();
+ if (area.width == 0 || area.height == 0 || items.length == 0) return false;
+
+ shortenedTabs = false;
+ int[] widths = new int[items.length];
+ GC gc = new GC(this);
+ for (int i = 0; i < items.length; i++) {
+ widths[i] = items[i].preferredWidth(gc);
+ }
+ gc.dispose();
+
+ int oldAverageWidth = 0;
+ int averageWidth = (area.width - borderLeft - borderRight) / items.length;
+ while (averageWidth > oldAverageWidth) {
+ int width = area.width - borderLeft - borderRight;
+ int count = items.length;
+ for (int i = 0; i < items.length; i++) {
+ if (widths[i] < averageWidth) {
+ width -= widths[i];
+ count--;
+ }
+ }
+ oldAverageWidth = averageWidth;
+ if (count > 0) {
+ averageWidth = width / count;
+ }
+ }
+ if (averageWidth > MIN_TAB_WIDTH * tabHeight) {
+ for (int i = 0; i < items.length; i++) {
+ if (widths[i] > averageWidth) {
+ widths[i] = averageWidth;
+ }
+ }
+ topTabIndex = 0;
+ shortenedTabs = true;
+ }
+
+ boolean changed = false;
+ int totalWidth = 0;
+ for (int i = 0; i < items.length; i++) {
+ CTabItem tab = items[i];
+ if (tab.height != tabHeight || tab.width != widths[i]) changed = true;
+ tab.height = tabHeight;
+ tab.width = widths[i];
+ totalWidth += widths[i];
+ }
+
+ if (setItemsLocation()) changed = true;
+
+ int areaWidth = area.x + area.width - borderRight;
+ if (totalWidth <= areaWidth) {
+ // if all items can be displayed, show all items
+ if (topTabIndex != 0) {
+ topTabIndex = 0;
+ setItemsLocation();
+ changed = true;
+ }
+ } else {
+ // Is there a gap after last item showing
+ CTabItem lastItem = items[items.length -1];
+ if (lastItem.x + lastItem.width < areaWidth) {
+ int scrollWidth = arrowBar.getSize().x;
+ int maxWidth = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ maxWidth -= scrollWidth;
+ }
+ while (topTabIndex > 0 && maxWidth - lastItem.x - lastItem.width > items[topTabIndex - 1].width) {
+ topTabIndex--;
+ setItemsLocation();
+ changed = true;
+ maxWidth = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ maxWidth -= scrollWidth;
+ }
+ }
+ }
+ }
+ return changed;
}
boolean onMnemonic (Event event) {
char key = event.character;
@@ -1052,7 +1107,8 @@
rect.y += borderTop;
rect.width -= borderLeft + borderRight;
rect.height -= borderTop + borderBottom;
- gc.setClipping(rect);
+ Rectangle clip = gc.getClipping ();
+ gc.setClipping(clip.intersection(rect));
// Draw the unselected tabs first.
for (int i=0; i < items.length; i++) {
@@ -1155,6 +1211,7 @@
if (tabListeners.length == 1) {
tabListeners = new CTabFolderListener[0];
showClose = false;
+ layoutButtons();
return;
}
CTabFolderListener[] newTabListeners = new CTabFolderListener[tabListeners.length - 1];
@@ -1172,39 +1229,26 @@
redraw();
return;
}
-
+
+ if (layoutItems()) {
+ redrawTabArea(-1);
+ }
+
Rectangle area = super.getClientArea();
- if (oldArea == null || oldArea.width == 0 || oldArea.height == 0) {
- layoutItems();
+ if (oldArea == null) {
redraw();
} else {
- if (onBottom && oldArea.height != area.height){
- // move tabs up or down if tabs on bottom
- layoutItems();
+ if (onBottom && area.height != oldArea.height) {
redraw();
} else {
- int width = 0;
- if (oldArea.width < area.width) {
- width = area.width - oldArea.width + borderRight;
- } else if (oldArea.width > area.width) {
- width = borderRight;
- }
- redraw(area.x + area.width - width, area.y, width, area.height, false);
-
- int height = 0;
- if (oldArea.height < area.height) {
- height = area.height - oldArea.height + borderBottom;
- }
- if (oldArea.height > area.height) {
- height = borderBottom;
- }
- redraw(area.x, area.y + area.height - height, area.width, height, false);
-
- if (oldArea.width != area.width) {
- // resize the widths so that all tabs are visible
- layoutItems();
- redrawTabArea(-1);
- }
+ int x1 = Math.min(area.width, oldArea.width);
+ if (area.width != oldArea.width) x1 -= 10;
+ int y1 = Math.min(area.height, oldArea.height);
+ if (area.height != oldArea.height) y1 -= 10;
+ int x2 = Math.max(area.width, oldArea.width);
+ int y2 = Math.max(area.height, oldArea.height);
+ redraw(0, y1, x2 + 10, y2 - y1, false);
+ redraw(x1, 0, x2 - x1, y2, false);
}
}
oldArea = area;
@@ -1469,18 +1513,6 @@
if (index < 0 || index >= items.length) return;
if (selectedIndex == index) return;
- if (showClose) {
- inactiveCloseBar.setVisible(false);
- inactiveItem = null;
- if (arrowBar.isVisible()) {
- Rectangle arrowRect = arrowBar.getBounds();
- arrowRect.width += borderRight;
- closeBar.setVisible(!arrowRect.contains(closeBar.getLocation()));
- } else {
- closeBar.setVisible(true);
- }
- }
-
int oldIndex = selectedIndex;
selectedIndex = index;
@@ -1496,37 +1528,82 @@
control.setVisible(false);
}
}
- ensureVisible();
-
+ showItem(items[selectedIndex]);
+ layoutButtons();
redrawTabArea(-1);
}
-private void ensureVisible() {
- if (selectedIndex == -1) return;
- // make sure selected item is visible
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see CTabFolder#showSelection()
+ *
+ * @since 2.0
+ */
+public void showItem (CTabItem item) {
+ checkWidget();
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ int index = indexOf(item);
+ if (index < topTabIndex) {
+ topTabIndex = index;
+ setItemsLocation();
+ return;
+ }
Rectangle area = super.getClientArea();
if (area.width == 0) return;
int areaWidth = area.x + area.width - borderRight;
-
- CTabItem tabItem = items[selectedIndex];
- if (selectedIndex < topTabIndex) {
- topTabIndex = selectedIndex;
- }
- layoutItems();
-
int scrollWidth = arrowBar.getSize().x;
int width = areaWidth;
if (scroll_leftVisible() || scroll_rightVisible()) {
width -= scrollWidth;
}
- while (tabItem.x + tabItem.width > width && selectedIndex != topTabIndex) {
+ while (item.x + item.width > width && index != topTabIndex) {
topTabIndex++;
- layoutItems();
+ setItemsLocation();
width = areaWidth;
if (scroll_leftVisible() || scroll_rightVisible()) {
width -= scrollWidth;
}
}
}
+/**
+ * Shows the selection. If the selection is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see CTabFolder#showItem(CTabItem)
+ *
+ * @since 2.0
+ *
+ */
+public void showSelection () {
+ checkWidget ();
+ if (selectedIndex != -1) {
+ showItem(getSelection());
+ }
+}
char getMnemonic (String string) {
int index = 0;
@@ -1817,10 +1894,14 @@
private boolean scroll_rightVisible() {
if (topTabIndex < items.length - 1) {
// only show Scroll buttons if there is more than one item
- // and if we are not alread at the last item
+ // and if we are not already at the last item
CTabItem tabItem = items[items.length-1];
int tabStopX = tabItem.x + tabItem.width;
Rectangle area = super.getClientArea();
+ if (topTabIndex > 0) {
+ int scrollWidth = arrowBar.getSize().x;
+ area.width -= scrollWidth;
+ }
if (tabStopX > area.x + area.width - borderRight) {
return true; // not all tabs fit in the client area
}
@@ -1834,7 +1915,7 @@
private void scroll_scrollLeft() {
if (scroll_leftVisible()) {
--topTabIndex;
- layoutItems();
+ setItemsLocation();
redrawTabArea(-1);
}
}
@@ -1845,7 +1926,7 @@
private void scroll_scrollRight() {
if (scroll_rightVisible()) {
topTabIndex++;
- layoutItems();
+ setItemsLocation();
redrawTabArea(-1);
}
}
@@ -1869,6 +1950,8 @@
}
if (fixedTabHeight == height) return;
fixedTabHeight = height;
+ layoutItems();
+ redraw();
onClientAreaChange();
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 8ad3af5..a7b62ae 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -135,9 +135,6 @@
PaletteData caretPalette = null;
int lastCaretDirection = SWT.NULL;
- // optimization flag for non-Windows platforms
- boolean drawDirect = false;
-
/**
* The Printing class implements printing of a range of text.
* An instance of <class>Printing </class> is returned in the
@@ -1313,8 +1310,15 @@
* @param replaceCharCount the number of deleted characters
*/
public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
+ int startLine = visualContent.getLineAtOffset(startOffset);
+
visualContent.textChanged(startOffset, newLineCount, replaceLineCount, newCharCount, replaceCharCount);
- parent.internalRedraw();
+ if (startLine <= getPartialBottomIndex()) {
+ // only redraw if the text change is inside or above the
+ // visible lines. if it is below the visible lines it will
+ // not affect the word wrapping. fixes bug 14047.
+ parent.internalRedraw();
+ }
}
}
public StyledText(Composite parent, int style) {
@@ -1661,6 +1665,26 @@
}
}
/**
+ * Clears the widget margin.
+ *
+ * @param gc GC to render on
+ * @param background background color to use for clearing the margin
+ * @param clientArea widget client area dimensions
+ * @param renderHeight height in pixel of the rendered lines
+ */
+void clearMargin(GC gc, Color background, Rectangle clientArea, int renderHeight) {
+ // clear the margin background
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, clientArea.width, topMargin);
+ gc.fillRectangle(0, 0, leftMargin, renderHeight);
+ gc.fillRectangle(
+ 0, clientArea.height - bottomMargin,
+ clientArea.width, bottomMargin);
+ gc.fillRectangle(
+ clientArea.width - rightMargin, 0,
+ rightMargin, renderHeight);
+}
+/**
* Removes the widget selection.
* <p>
*
@@ -4605,28 +4629,27 @@
if (clientArea.width == 0 || event.height == 0) {
return;
}
- performPaint(event.gc, startLine, startY, renderHeight);
+ performPaint(event.gc, startLine, startY, renderHeight, false);
}
/**
* Render the specified area. Broken out as its own method to support
* direct drawing.
* <p>
*
- * @param gc
- * @param startLine
- * @param startY
- * @param renderHeight
+ * @param gc GC to render on
+ * @param startLine first line to render
+ * @param startY y pixel location to start rendering at
+ * @param renderHeight renderHeight widget area that needs to be filled with lines
+ * @param drawDirect rendering is done directly without invalidating the paint area
*/
-void performPaint(GC gc,int startLine,int startY, int renderHeight) {
+void performPaint(GC gc,int startLine,int startY, int renderHeight, boolean drawDirect) {
int lineCount = content.getLineCount();
int paintY = topMargin;
Rectangle clientArea = getClientArea();
Color background = getBackground();
Color foreground = getForeground();
- Image lineBuffer;
- GC lineGC;
- Font font;
- FontData fontData;
+ Font font = gc.getFont();
+ FontData fontData = font.getFontData()[0];
// Check if there is work to do. We never want to try and create
// an Image with 0 width or 0 height.
@@ -4639,12 +4662,11 @@
startLine = 1;
}
}
- font = gc.getFont();
- fontData = font.getFontData()[0];
// Do double buffering on direct draw operations only
if (drawDirect || SWT.getPlatform().equals("win32")) {
- lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight);
- lineGC = new GC(lineBuffer);
+ Image lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight);
+ GC lineGC = new GC(lineBuffer);
+
lineGC.setFont(font);
lineGC.setForeground(foreground);
lineGC.setBackground(background);
@@ -4671,17 +4693,7 @@
gc.fillRectangle(0, paintY + startY, clientArea.width, renderHeight - paintY);
}
}
-
- // clear the margin background
- gc.setBackground(background);
- gc.fillRectangle(0, 0, clientArea.width, topMargin);
- gc.fillRectangle(0, 0, leftMargin, renderHeight);
- gc.fillRectangle(
- 0, clientArea.height - bottomMargin,
- clientArea.width, bottomMargin);
- gc.fillRectangle(
- clientArea.width - rightMargin, 0,
- rightMargin, renderHeight);
+ clearMargin(gc, background, clientArea, renderHeight);
}
/**
* Recalculates the scroll bars. Rewraps all lines when in word
@@ -4750,6 +4762,20 @@
// fixes bug 8273
claimRightFreeSpace();
}
+ // do direct drawing if the text change is confined to a single line.
+ // optimization and fixes bug 13999. see also handleTextChanging.
+ if (lastTextChangeNewLineCount == 0 && lastTextChangeReplaceLineCount == 0) {
+ int startLine = content.getLineAtOffset(lastTextChangeStart);
+ int startY = startLine * lineHeight - verticalScrollOffset;
+ GC gc = new GC(this);
+ Caret caret = getCaret();
+ boolean caretVisible = caret.getVisible();
+
+ caret.setVisible(false);
+ performPaint(gc, startLine, startY, lineHeight, true);
+ caret.setVisible(caretVisible);
+ gc.dispose();
+ }
}
/**
* Updates the screen to reflect a pending content change.
@@ -4782,12 +4808,6 @@
if (isMultiLineChange) {
redrawMultiLineChange(textChangeY, event.newLineCount, event.replaceLineCount);
}
- else {
- // Optimization for non-Windows platforms. Do direct drawing during typing.
- if (drawDirect == false) {
- super.redraw(leftMargin, textChangeY, getClientArea().width - leftMargin - rightMargin, lineHeight, true);
- }
- }
// notify default line styler about text change
if (defaultLineStyler != null) {
defaultLineStyler.textChanging(event);
@@ -5088,10 +5108,6 @@
styledTextEvent.end = event.start + event.text.length();
styledTextEvent.text = content.getTextRange(event.start, replacedLength);
}
- // Optimization for non-Windows platforms. Do direct drawing during typing.
- if (SWT.getPlatform().equals("win32") == false) {
- drawDirect = (event.text.length() == 1) || (replacedLength == 1);
- }
content.replaceTextRange(event.start, replacedLength, event.text);
// set the caret position prior to sending the modify event.
// fixes 1GBB8NJ
@@ -5112,16 +5128,7 @@
else {
showCaret();
}
- }
- // Optimization for non-Windows platforms. Do direct drawing during typing.
- if (drawDirect) {
- int startLine = content.getLineAtOffset(event.start);
- int startY = startLine * lineHeight - verticalScrollOffset;
- GC gc = new GC(this);
- performPaint(gc, startLine, startY, lineHeight);
- drawDirect = false;
- gc.dispose();
- }
+ }
notifyListeners(SWT.Modify, event);
if (isListening(ExtendedModify)) {
notifyListeners(ExtendedModify, styledTextEvent);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
index 1c31b61..1390f05 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
@@ -29,6 +29,9 @@
* <dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
* <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
* </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p>
*/
public class TableTree extends Composite {
Table table;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
index b1ae206..7cef422 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
@@ -223,7 +223,7 @@
if (tableTree.isDisposed()) return;
if (item == null || item.isDisposed()) return;
Table table = tableTree.getTable();
- if (column < 0 || column >= table.getItemCount()) return;
+ if (column < 0 || column >= table.getColumnCount()) return;
super.resize();
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
index cb946ce..1751a1e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
index e2adf9d..e9f6028 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
@@ -8,6 +9,7 @@
SWT Drag and Drop support.
<h2>
Package Specification</h2>
-This package contains the classes which make up the public API of the SWT Drag and Drop support.
+This package contains the classes which make up the public API of the SWT
+Drag and Drop support.
</body>
</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
index ad36e69..049f8eb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
@@ -776,7 +776,7 @@
public boolean isFocusControl () {
checkWidget ();
int focusHwnd = OS.GetFocus();
- if (focusHwnd == handle) return true;
+ if (focusHwnd == handle) return (objIOleInPlaceObject == null);
if (objIOleInPlaceObject == null) return false;
int[] phwnd = new int[1];
objIOleInPlaceObject.GetWindow(phwnd);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
index 8282b6e..1e996cf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
@@ -222,28 +222,6 @@
* Adds the listener to receive events.
*
* @since 2.0
- * @deprecated - use OleControlSite.addEventListener(OleAutomation, int, OleListener)
- *
- * @param automation the automation object that provides the event notification
- *
- * @param guid the identifier of the events COM interface
- *
- * @param eventID the id of the event
- *
- * @param listener the listener
- *
- * @exception SWTError
- * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
- */
-public void addEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) {
- if (listener == null || automation == null || guid == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- addEventListener(automation.getAddress(), guid, eventID, listener);
-
-}
-/**
- * Adds the listener to receive events.
- *
- * @since 2.0
*
* @param automation the automation object that provides the event notification
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
index 740fc1e..f155f88 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
index 466dddd..3f930e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
@@ -17,7 +17,7 @@
/**
* SWT Minor version number (must be in the range 0..999)
*/
- static int MINOR_VERSION = 32;
+ static int MINOR_VERSION = 36;
/**
* SWT revision number (must be >= 0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
index e9b9438..0397be1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
@@ -17,7 +17,7 @@
/**
* SWT Minor version number (must be in the range 0..999)
*/
- static int MINOR_VERSION = 32;
+ static int MINOR_VERSION = 36;
/**
* SWT revision number (must be >= 0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
index b1228fa..7f7dd2d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
@@ -39,6 +39,9 @@
GtkCTreeRow_FID_CACHE GtkCTreeRowFc;
GtkCTree_FID_CACHE GtkCTreeFc;
+GtkTargetEntry_FID_CACHE GtkTargetEntryFc;
+GtkSelectionData_FID_CACHE GtkSelectionDataFc;
+
/* ----------- fid and class caches ----------- */
/*
* Used for Java objects passed into JNI that are
@@ -634,10 +637,11 @@
void setGdkEventExposeFields(JNIEnv *env, jobject lpObject, GdkEvent *lpGdkEvent, GdkEventExpose_FID_CACHE *lpGdkEventExposeFc)
{
GdkEventExpose *lpGdkEventExpose = (GdkEventExpose*)lpGdkEvent;
- (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->x, (jshort)lpGdkEventExpose->area.x);
- (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->y, (jshort)lpGdkEventExpose->area.y);
- (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->width, (jshort)lpGdkEventExpose->area.width);
- (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->height, (jshort)lpGdkEventExpose->area.height);
+ (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->x, (jint)lpGdkEventExpose->area.x);
+ (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->y, (jint)lpGdkEventExpose->area.y);
+ (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->width, (jint)lpGdkEventExpose->area.width);
+ (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->height, (jint)lpGdkEventExpose->area.height);
+ (*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->region, (jint)lpGdkEventExpose->region);
(*env)->SetIntField(env, lpObject, lpGdkEventExposeFc->count, (jint)lpGdkEventExpose->count);
}
@@ -1107,6 +1111,7 @@
lpGtkStyle->white.red = (*env)->GetShortField(env, lpObject, lpGtkStyleFc->white_red);
lpGtkStyle->white.green = (*env)->GetShortField(env, lpObject, lpGtkStyleFc->white_green);
lpGtkStyle->white.blue = (*env)->GetShortField(env, lpObject, lpGtkStyleFc->white_blue);
+ lpGtkStyle->font_desc = (PangoFontDescription*)(*env)->GetIntField(env, lpObject, lpGtkStyleFc->font_desc);
lpGtkStyle->fg_gc[0] = (GdkGC*)(*env)->GetIntField(env, lpObject, lpGtkStyleFc->fg_gc0);
lpGtkStyle->fg_gc[1] = (GdkGC*)(*env)->GetIntField(env, lpObject, lpGtkStyleFc->fg_gc1);
lpGtkStyle->fg_gc[2] = (GdkGC*)(*env)->GetIntField(env, lpObject, lpGtkStyleFc->fg_gc2);
@@ -1303,6 +1308,8 @@
(*env)->SetShortField(env, lpObject, lpGtkStyleFc->white_green, (jshort)lpGtkStyle->white.green);
(*env)->SetShortField(env, lpObject, lpGtkStyleFc->white_blue, (jshort)lpGtkStyle->white.blue);
+ (*env)->SetIntField(env, lpObject, lpGtkStyleFc->font_desc, (jint)lpGtkStyle->font_desc);
+
(*env)->SetIntField(env, lpObject, lpGtkStyleFc->fg_gc0, (jint)lpGtkStyle->fg_gc[0]);
(*env)->SetIntField(env, lpObject, lpGtkStyleFc->fg_gc1, (jint)lpGtkStyle->fg_gc[1]);
(*env)->SetIntField(env, lpObject, lpGtkStyleFc->fg_gc2, (jint)lpGtkStyle->fg_gc[2]);
@@ -1502,3 +1509,66 @@
(*env)->SetIntField(env, lpObject, lpGtkCTreeRowFc->is_leaf, (jint)lpGtkCTreeRow->is_leaf);
(*env)->SetIntField(env, lpObject, lpGtkCTreeRowFc->expanded, (jint)lpGtkCTreeRow->expanded);
}
+
+void cacheGtkSelectionDataFids(JNIEnv *env, jobject lpObject, PGtkSelectionData_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->selection = (*env)->GetFieldID(env, lpCache->clazz, "selection", "I");
+ lpCache->target = (*env)->GetFieldID(env, lpCache->clazz, "target", "I");
+ lpCache->type = (*env)->GetFieldID(env, lpCache->clazz, "type", "I");
+ lpCache->format = (*env)->GetFieldID(env, lpCache->clazz, "format", "I");
+ lpCache->data = (*env)->GetFieldID(env, lpCache->clazz, "data", "I");
+ lpCache->length = (*env)->GetFieldID(env, lpCache->clazz, "length", "I");
+ lpCache->cached = 1;
+}
+
+GtkSelectionData* getGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct, PGtkSelectionData_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheGtkSelectionDataFids(env, lpObject, lpCache);
+ lpStruct->selection = (GdkAtom)(*env)->GetIntField(env, lpObject, lpCache->selection);
+ lpStruct->target = (GdkAtom)(*env)->GetIntField(env, lpObject, lpCache->target);
+ lpStruct->type = (GdkAtom)(*env)->GetIntField(env, lpObject, lpCache->type);
+ lpStruct->format = (*env)->GetIntField(env, lpObject, lpCache->format);
+ lpStruct->data = (guchar*)(*env)->GetIntField(env, lpObject, lpCache->data);
+ lpStruct->length = (*env)->GetIntField(env, lpObject, lpCache->length);
+ return lpStruct;
+}
+
+void setGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct, PGtkSelectionData_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheGtkSelectionDataFids(env, lpObject, lpCache);
+ (*env)->SetIntField(env, lpObject, lpCache->selection, (jint) lpStruct->selection);
+ (*env)->SetIntField(env, lpObject, lpCache->target, (jint)lpStruct->target);
+ (*env)->SetIntField(env, lpObject, lpCache->type, (jint)lpStruct->type);
+ (*env)->SetIntField(env, lpObject, lpCache->format, lpStruct->format);
+ (*env)->SetIntField(env, lpObject, lpCache->data, (jint)lpStruct->data);
+ (*env)->SetIntField(env, lpObject, lpCache->length, lpStruct->length);
+}
+
+void cacheGtkTargetEntryFids(JNIEnv *env, jobject lpObject, PGtkTargetEntry_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->target = (*env)->GetFieldID(env, lpCache->clazz, "target", "I");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "I");
+ lpCache->info = (*env)->GetFieldID(env, lpCache->clazz, "info", "I");
+ lpCache->cached = 1;
+}
+
+GtkTargetEntry* getGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct, PGtkTargetEntry_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheGtkTargetEntryFids(env, lpObject, lpCache);
+ lpStruct->target = (gchar*)(*env)->GetIntField(env, lpObject, lpCache->target);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, lpCache->flags);
+ lpStruct->info = (*env)->GetIntField(env, lpObject, lpCache->info);
+ return lpStruct;
+}
+
+void setGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct, PGtkTargetEntry_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheGtkTargetEntryFids(env, lpObject, lpCache);
+ (*env)->SetIntField(env, lpObject, lpCache->target, (jint)lpStruct->target);
+ (*env)->SetIntField(env, lpObject, lpCache->flags, (jint)lpStruct->flags);
+ (*env)->SetIntField(env, lpObject, lpCache->info, (jint)lpStruct->info);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.h
index f3bb667..3c45045 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.h
@@ -245,6 +245,32 @@
typedef GtkCTree_FID_CACHE *PGtkCTree_FID_CACHE;
+
+/* GtkSelectionData struct */
+typedef struct GtkSelectionData_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID selection, target, type, format, data, length;
+} GtkSelectionData_FID_CACHE;
+typedef GtkSelectionData_FID_CACHE *PGtkSelectionData_FID_CACHE;
+
+void cacheGtkSelectionDataFids(JNIEnv *env, jobject lpObject, PGtkSelectionData_FID_CACHE lpCache);
+GtkSelectionData* getGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct, PGtkSelectionData_FID_CACHE lpCache);
+void setGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct, PGtkSelectionData_FID_CACHE lpCache);
+
+
+/* GtkTargetEntry struct */
+typedef struct GtkTargetEntry_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID target, flags, info;
+} GtkTargetEntry_FID_CACHE;
+typedef GtkTargetEntry_FID_CACHE *PGtkTargetEntry_FID_CACHE;
+
+void cacheGtkTargetEntryFids(JNIEnv *env, jobject lpObject, PGtkTargetEntry_FID_CACHE lpCache);
+GtkTargetEntry* getGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct, PGtkTargetEntry_FID_CACHE lpCache);
+void setGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct, PGtkTargetEntry_FID_CACHE lpCache);
+
/* ----------- cache function prototypes ----------- */
void cacheGdkColorFids(JNIEnv *env, jobject lpGdkColor, PGdkColor_FID_CACHE lpCache);
@@ -331,5 +357,7 @@
extern GtkRequisition_FID_CACHE GtkRequisitionFc;
extern GtkStyle_FID_CACHE GtkStyleFc;
extern GtkStyleClass_FID_CACHE GtkStyleClassFc;
+extern GtkSelectionData_FID_CACHE GtkSelectionDataFc;
+extern GtkTargetEntry_FID_CACHE GtkTargetEntryFc;
#endif // INC_structs_H
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
index faa4fa4..1cee22e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
@@ -88,6 +88,18 @@
}
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1region_1get_1rectangles
+ (JNIEnv *env, jclass that, jint region, jintArray rectangles, jintArray n_rectangles)
+{
+ jint *rectangles1 = NULL;
+ jint *n_rectangles1 = NULL;
+ if (rectangles) rectangles1 = (*env)->GetIntArrayElements(env, rectangles, NULL);
+ if (n_rectangles) n_rectangles1 = (*env)->GetIntArrayElements(env, n_rectangles, NULL);
+ gdk_region_get_rectangles((GdkRegion*)region, (GdkRectangle**)rectangles1, (gint *)n_rectangles1);
+ if (rectangles) (*env)->ReleaseIntArrayElements(env, rectangles, rectangles1, 0);
+ if (n_rectangles) (*env)->ReleaseIntArrayElements(env, n_rectangles, n_rectangles1, 0);
+}
+
JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1region_1empty
(JNIEnv *env, jclass that, jint region)
{
@@ -152,6 +164,17 @@
gdk_region_subtract((GdkRegion*)source1, (GdkRegion*)source2);
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1region_1intersect
+ (JNIEnv *env, jclass that, jint source1, jint source2)
+{
+ gdk_region_intersect((GdkRegion*)source1, (GdkRegion*)source2);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1region_1offset
+ (JNIEnv *env, jclass that, jint region, jint dx, jint dy)
+{
+ gdk_region_offset((GdkRegion*)region, dx, dy);
+}
/* ***** Graphics Contexts ***** */
@@ -934,24 +957,31 @@
}
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1get_1pointer
- (JNIEnv *env, jclass that, jint window, jintArray x, jintArray y, jint mask)
+ (JNIEnv *env, jclass that, jint window, jintArray x, jintArray y, jintArray mask)
{
jint rc;
jint *x1 = NULL;
jint *y1 = NULL;
+ jint *mask1 = NULL;
if (x) {
x1 = (*env)->GetIntArrayElements(env, x, NULL);
}
if (y) {
y1 = (*env)->GetIntArrayElements(env, y, NULL);
}
- rc = (jint)gdk_window_get_pointer((GdkWindow*)window, (gint*)x1, (gint*)y1, (GdkModifierType*)mask);
+ if (mask) {
+ mask1 = (*env)->GetIntArrayElements(env, mask, NULL);
+ }
+ rc = (jint)gdk_window_get_pointer((GdkWindow*)window, (gint*)x1, (gint*)y1, (GdkModifierType*)mask1);
if (x) {
(*env)->ReleaseIntArrayElements(env, x, x1, 0);
}
if (y) {
(*env)->ReleaseIntArrayElements(env, y, y1, 0);
}
+ if (mask) {
+ (*env)->ReleaseIntArrayElements(env, mask, mask1, 0);
+ }
return rc;
}
@@ -1214,3 +1244,70 @@
{
gdk_pointer_ungrab((guint32) time);
}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1set_1override_1redirect
+ (JNIEnv *env, jclass that, jint window, jint override_redirect)
+{
+ gdk_window_set_override_redirect((GdkWindow*)window, (gboolean)override_redirect);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1event_1focus_1get_1in
+ (JNIEnv *env, jclass that, jint event)
+{
+ return (jboolean) (((GdkEventFocus*)event) -> in);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1set_1back_1pixmap
+ (JNIEnv *env, jclass that, jint window, jint pixmap, jboolean parent_relative)
+{
+ gdk_window_set_back_pixmap((GdkWindow*)window, (GdkPixmap*)pixmap, (gboolean)parent_relative);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1scroll
+ (JNIEnv *env, jclass that, jint window, jint dx, jint dy)
+{
+ gdk_window_scroll((GdkWindow*)window, dx, dy);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1invalidate_1rect
+ (JNIEnv *env, jclass that, jint window, jobject rectangle, jboolean invalidate_children)
+{
+ DECL_GLOB(pGlob)
+ GdkRectangle rectangle_struct, *rectangle1 = NULL;
+ if (rectangle) {
+ rectangle1 = &rectangle_struct;
+ cacheGdkRectangleFids(env, rectangle, &PGLOB(GdkRectangleFc));
+ getGdkRectangleFields(env, rectangle, rectangle1, &PGLOB(GdkRectangleFc));
+ }
+ gdk_window_invalidate_rect((GdkWindow*)window, (GdkRectangle*)rectangle1, (gboolean) invalidate_children);
+ if (rectangle) {
+ setGdkRectangleFields(env, rectangle, rectangle1, &PGLOB(GdkRectangleFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1invalidate_1region
+ (JNIEnv *env, jclass that, jint window, jint region, jboolean invalidate_children)
+{
+ gdk_window_invalidate_region((GdkWindow*)window, (GdkRegion*)region, (gboolean) invalidate_children);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1drawable_1get_1visible_1region
+ (JNIEnv *env, jclass that, jint drawable)
+{
+ return (jint)gdk_drawable_get_visible_region((GdkDrawable*)drawable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1get_1internal_1paint_1info
+ (JNIEnv *env, jclass that, jint window, jintArray drawable, jintArray x_offset, jintArray y_offset)
+{
+ jint *drawable1 = NULL;
+ jint *x_offset1 = NULL;
+ jint *y_offset1 = NULL;
+ if (drawable) drawable1 = (*env)->GetIntArrayElements(env, drawable, NULL);
+ if (x_offset) x_offset1 = (*env)->GetIntArrayElements(env, x_offset, NULL);
+ if (y_offset) y_offset1 = (*env)->GetIntArrayElements(env, y_offset, NULL);
+ gdk_window_get_internal_paint_info((GdkWindow*)window, (GdkDrawable**)drawable1, (gint *)x_offset1, (gint *)y_offset1);
+ if (drawable) (*env)->ReleaseIntArrayElements(env, drawable, drawable1, 0);
+ if (x_offset) (*env)->ReleaseIntArrayElements(env, x_offset, x_offset1, 0);
+ if (y_offset) (*env)->ReleaseIntArrayElements(env, y_offset, y_offset1, 0);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontainers.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontainers.c
index eec4eb1..4426ee1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontainers.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontainers.c
@@ -60,10 +60,10 @@
gtk_container_remove((GtkContainer*)container, (GtkWidget*)widget);
}
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1container_1children
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1container_1get_1children
(JNIEnv *env, jclass that, jint container)
{
- return (jint)gtk_container_children((GtkContainer*)container);
+ return (jint)gtk_container_get_children((GtkContainer*)container);
}
/* gtk_event_box */
@@ -139,3 +139,9 @@
(*env)->ReleaseIntArrayElements(env, trims, ctrims, 0);
}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1container_1set_1border_1width
+ (JNIEnv *env, jclass that, jint container, jint border_width)
+{
+ gtk_container_set_border_width((GtkContainer*)container, border_width);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c
index 918ee1b..ffd3465 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c
@@ -518,7 +518,6 @@
return (jint) result;
}
-
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1frame_1get_1label_1widget
(JNIEnv *env, jclass that, jint frame)
{
@@ -528,3 +527,20 @@
return (jint)gtk_frame_get_label_widget((GtkFrame*)frame);
}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1frame_1set_1label_1widget
+ (JNIEnv *env, jclass that, jint frame, jint label)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_frame_set_label_widget");
+#endif
+
+ gtk_frame_set_label_widget((GtkFrame*)frame, (GtkWidget*)label);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1button_1set_1relief
+ (JNIEnv *env, jclass that, jint button, jint newstyle)
+{
+ gtk_button_set_relief((GtkButton*)button, (GtkReliefStyle)newstyle);
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
index 2c104bc..185d272 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
@@ -854,7 +854,11 @@
return rc;
}
-
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clist_1set_1row_1height
+ (JNIEnv *env, jclass that, jint clist, jint height)
+{
+ gtk_clist_set_row_height ((GtkCList*)clist, (gint)height);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
index 2d65fd0..f68eabd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
@@ -90,12 +90,6 @@
return (jboolean) GTK_WIDGET_TOPLEVEL((GtkWidget*)wid);
}
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1REALISED
- (JNIEnv *env, jclass that, jint wid)
-{
- return (jboolean) GTK_WIDGET_REALISED((GtkWidget*)wid);
-}
-
JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1VISIBLE
(JNIEnv *env, jclass that, jint wid)
{
@@ -442,6 +436,54 @@
}
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1modify_1fg
+ (JNIEnv *env, jclass that, jint widget, jint state, jobject color)
+{
+ DECL_GLOB(pGlob)
+ GdkColor color_struct, *color1 = NULL;
+ if (color) {
+ color1 = &color_struct;
+ cacheGdkColorFids(env, color, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+ gtk_widget_modify_fg((GtkWidget*)widget, (GtkStateType)state, (GdkColor*)color1);
+ if (color) {
+ setGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1modify_1text
+ (JNIEnv *env, jclass that, jint widget, jint state, jobject color)
+{
+ DECL_GLOB(pGlob)
+ GdkColor color_struct, *color1 = NULL;
+ if (color) {
+ color1 = &color_struct;
+ cacheGdkColorFids(env, color, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+ gtk_widget_modify_text((GtkWidget*)widget, (GtkStateType)state, (GdkColor*)color1);
+ if (color) {
+ setGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1modify_1base
+ (JNIEnv *env, jclass that, jint widget, jint state, jobject color)
+{
+ DECL_GLOB(pGlob)
+ GdkColor color_struct, *color1 = NULL;
+ if (color) {
+ color1 = &color_struct;
+ cacheGdkColorFids(env, color, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+ gtk_widget_modify_base((GtkWidget*)widget, (GtkStateType)state, (GdkColor*)color1);
+ if (color) {
+ setGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+}
+
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1scrolled_1window_1set_1shadow_1type
(JNIEnv *env, jclass that, jint scroll, jint type)
{
@@ -610,3 +652,95 @@
{
return GTK_WIDGET_MAPPED((GtkWidget*)wid);
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1send_1expose
+ (JNIEnv *env, jclass that, jint wid, jint event)
+{
+ return gtk_widget_send_expose((GtkWidget*)wid, (GdkEvent*)event);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_clipboard_clear
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clipboard_1clear
+ (JNIEnv *env, jclass that, jint clipboard)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_clipboard_clear");
+#endif
+ gtk_clipboard_clear((GtkClipboard*)clipboard);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_clipboard_get
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clipboard_1get
+ (JNIEnv *env, jclass that, jint selection)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_clipboard_get");
+#endif
+ return (jint) gtk_clipboard_get((GdkAtom)selection );
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_clipboard_set_with_data
+ * Signature: (IIIIII)B
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clipboard_1set_1with_1data
+ (JNIEnv *env, jclass that, jint clipboard, jint targets, jint n_targets, jint get_func, jint clear_func, jint user_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_clipboard_set_with_data");
+#endif
+ return gtk_clipboard_set_with_data((GtkClipboard*)clipboard, (GtkTargetEntry*)targets, n_targets, (GtkClipboardGetFunc)get_func, (GtkClipboardClearFunc)clear_func, (gpointer)user_data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_clipboard_wait_for_contents
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clipboard_1wait_1for_1contents
+ (JNIEnv *env, jclass that, jint clipboard, jint target)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_clipboard_wait_for_contents");
+#endif
+ return (jint)gtk_clipboard_wait_for_contents((GtkClipboard*)clipboard,(GdkAtom)target);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_selection_data_free
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1selection_1data_1free
+ (JNIEnv *env, jclass that, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_selection_data_free");
+#endif
+ gtk_selection_data_free((GtkSelectionData*)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_selection_data_set
+ * Signature: (IIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1selection_1data_1set
+ (JNIEnv *env, jclass that, jint selection_data, jint type, jint format, jint data, jint length)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_selection_data_set");
+#endif
+ gtk_selection_data_set((GtkSelectionData*)selection_data, (GdkAtom)type, format, (guchar*)data, length);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
index 39279e3..f7f0e05 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
@@ -122,6 +122,12 @@
* DIALOGS
*/
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1dialog_1run
+ (JNIEnv *env, jclass that, jint dialog)
+{
+ return (jint)gtk_dialog_run((GtkDialog*)dialog);
+}
+
/*
* Color selection
*/
@@ -265,6 +271,12 @@
return (jint)gtk_file_selection_get_filename((GtkFileSelection*)filesel);
}
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1file_1selection_1get_1selections
+ (JNIEnv *env, jclass that, jint filesel)
+{
+ return (jint)gtk_file_selection_get_selections((GtkFileSelection*)filesel);
+}
+
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1file_1selection_1complete
(JNIEnv *env, jclass that, jint filesel, jbyteArray pattern)
{
@@ -296,6 +308,11 @@
return (jint) (((GtkFileSelection*)fsd)->cancel_button);
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1file_1selection_1set_1select_1multiple
+ (JNIEnv *env, jclass that, jint filesel, jboolean select_multiple)
+{
+ gtk_file_selection_set_select_multiple((GtkFileSelection*)filesel, (gboolean)select_multiple);
+}
/*
@@ -361,3 +378,51 @@
{
gtk_window_set_default((GtkWindow*)window, (GtkWidget*)widget);
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1get_1default
+ (JNIEnv *env, jclass that, jint window)
+{
+ return (jint)(((GtkWindow*)window)->default_widget);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1activate_1default
+ (JNIEnv *env, jclass that, jint window)
+{
+ return (jboolean)gtk_window_activate_default((GtkWindow*)window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1iconify
+ (JNIEnv *env, jclass that, jint window)
+{
+ gtk_window_iconify((GtkWindow*)window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1deiconify
+ (JNIEnv *env, jclass that, jint window)
+{
+ gtk_window_deiconify((GtkWindow*)window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1maximize
+ (JNIEnv *env, jclass that, jint window)
+{
+ gtk_window_maximize((GtkWindow*)window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1unmaximize
+ (JNIEnv *env, jclass that, jint window)
+{
+ gtk_window_unmaximize((GtkWindow*)window);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1get_1focus
+ (JNIEnv *env, jclass that, jint window)
+{
+ return (jint)gtk_window_get_focus((GtkWindow*)window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1set_1destroy_1with_1parent
+ (JNIEnv *env, jclass that, jint window, jboolean setting)
+{
+ gtk_window_set_destroy_with_parent((GtkWindow*)window, (gboolean)setting);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-memmove.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-memmove.c
index 2d3ad9d..d4311c7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-memmove.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-memmove.c
@@ -269,3 +269,35 @@
(*env)->ReleaseByteArrayElements(env, src, src1, 0);
}
}
+
+/* Clipboard */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2I
+ (JNIEnv *env, jclass that, jobject dest, jint src)
+{
+ DECL_GLOB(pGlob)
+ if (dest) {
+ cacheGtkSelectionDataFids(env, dest, &PGLOB(GtkSelectionDataFc));
+ setGtkSelectionDataFields(env, dest, (GtkSelectionData *)src, &PGLOB(GtkSelectionDataFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2
+ (JNIEnv *env, jclass that, jint dest, jobject src)
+{
+ DECL_GLOB(pGlob)
+ if (src) {
+ cacheGtkTargetEntryFids(env, src, &PGLOB(GtkTargetEntryFc));
+ getGtkTargetEntryFields(env, src, (GtkTargetEntry *)dest, &PGLOB(GtkTargetEntryFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint size)
+{
+ DECL_GLOB(pGlob)
+ if (dest) {
+ cacheGdkRectangleFids(env, dest, &PGLOB(GdkRectangleFc));
+ setGdkRectangleFields(env, dest, (GdkRectangle *)src, &PGLOB(GdkRectangleFc));
+ }
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
index 647c966..a5b4f15 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
@@ -296,3 +296,28 @@
return rc;
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1layout_1set_1font_1description
+ (JNIEnv *env, jclass that, jint layout, jint descr)
+{
+ pango_layout_set_font_description((PangoLayout*)layout, (PangoFontDescription*)descr);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1language_1to_1string
+ (JNIEnv *env, jclass that, jint language)
+{
+ return (jint)pango_language_to_string((PangoLanguage*)language);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1layout_1set_1markup_1with_1accel
+ (JNIEnv *env, jclass that, jint layout, jbyteArray markup, jint length, jchar accel_marker, jcharArray accel_char)
+{
+ jbyte *markup1 = NULL;
+ jchar *accel_char1 = NULL;
+
+ if (markup != NULL) markup1 = (*env)->GetByteArrayElements(env, markup, NULL);
+ if (accel_char != NULL) accel_char1 = (*env)->GetCharArrayElements(env, accel_char, NULL);
+ pango_layout_set_markup_with_accel((PangoLayout*)layout, (const char *)markup1, length, (gunichar)accel_marker, (gunichar*)accel_char1);
+ if (markup != NULL) (*env)->ReleaseByteArrayElements(env, markup, markup1, 0);
+ if (accel_char != NULL) (*env)->ReleaseCharArrayElements(env, accel_char, accel_char1, 0);
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
index 29beaf1..d13ab34 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
@@ -626,17 +626,17 @@
/*
* Class: org_eclipse_swt_internal_gtk_OS
- * Method: gtk_notebook_append_page
+ * Method: gtk_notebook_insert_page
* Signature:
*/
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1notebook_1append_1page
- (JNIEnv *env, jclass that, jint notebook, jint child, jint tab_label)
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1notebook_1insert_1page
+ (JNIEnv *env, jclass that, jint notebook, jint child, jint tab_label, jint position)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "gtk_notebook_append_page");
+ fprintf(stderr, "gtk_notebook_insertpage");
#endif
- gtk_notebook_append_page((GtkNotebook*)notebook, (GtkWidget*)child, (GtkWidget*)tab_label);
+ gtk_notebook_insert_page((GtkNotebook*)notebook, (GtkWidget*)child, (GtkWidget*)tab_label, (gint) position);
}
/*
@@ -1172,16 +1172,23 @@
/*
* GtkEditable
*/
+
+/* Temporary code.
+ * We just minimize the changes until the PI is autogenerated.
+ */
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1selection_1start
(JNIEnv *env, jclass that, jint editable)
{
- return (jint)gtk_editable_get_selection_start((GtkEditable*)editable);
+ gint start, end;
+ gtk_editable_get_selection_bounds((GtkEditable*)editable, &start, &end);
+ return (jint)start;
}
-
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1selection_1end
(JNIEnv *env, jclass that, jint editable)
{
- return (jint)gtk_editable_get_selection_end((GtkEditable*)editable);
+ gint start, end;
+ gtk_editable_get_selection_bounds((GtkEditable*)editable, &start, &end);
+ return (jint)end;
}
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1editable
@@ -1760,9 +1767,58 @@
jbyte *detailed_signal1 = NULL;
if (detailed_signal) detailed_signal1 = (*env)->GetByteArrayElements(env, detailed_signal, NULL);
- rc = (jint)gtk_signal_connect((gpointer)instance, (const char*)detailed_signal1, (GCallback)c_handler, (gpointer)data);
+ rc = (jint)gtk_signal_connect_swapped((gpointer)instance, (const char*)detailed_signal1, (GCallback)c_handler, (gpointer)data);
if (detailed_signal) (*env)->ReleaseByteArrayElements(env, detailed_signal, detailed_signal1, 0);
return rc;
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1notebook_1set_1scrollable
+ (JNIEnv *env, jclass that, jint notebook, jboolean scrollable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_notebook_set_scrollable");
+#endif
+
+ gtk_notebook_set_scrollable((GtkNotebook*)notebook, (gboolean) scrollable);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1notebook_1get_1scrollable
+ (JNIEnv *env, jclass that, jint notebook)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_notebook_get_scrollable");
+#endif
+
+ return (jboolean)gtk_notebook_get_scrollable((GtkNotebook*)notebook);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1style_1set_1xthickness
+ (JNIEnv *env, jclass that, jint style, jboolean xthickness)
+{
+ ((GtkStyle*)style)->xthickness = xthickness;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1style_1set_1ythickness
+ (JNIEnv *env, jclass that, jint style, jboolean ythickness)
+{
+ ((GtkStyle*)style)->ythickness = ythickness;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_g_1strfreev
+ (JNIEnv *env, jclass that, jint string_array)
+{
+ g_strfreev ((gchar**)string_array);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_g_1filename_1to_1utf8
+ (JNIEnv *env, jclass that, jint opsysstring, jint len, jint bytes_read, jint bytes_written, jint error)
+{
+ return (jint) g_filename_to_utf8 ((const gchar*) opsysstring,
+ (gssize) len,
+ (gsize*) bytes_read,
+ (gsize*) bytes_written,
+ (GError**) error);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkStyleClass.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkStyleClass.java
deleted file mode 100644
index 445f494..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkStyleClass.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * Copyright (c) IBM Corp. 2000, 2001. All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkStyleClass {
- public int xthickness;
- public int ythickness;
-
- private GtkStyleClass() {}
- public GtkStyleClass(int ptr) {
- OS.memmove(this, ptr);
- }
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 2a2735b..ae5a39c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -81,6 +81,10 @@
public static final int GDK_End = 0xFF57;
public static final int GDK_Insert = 0xFF63;
public static final int GDK_Delete = 0xFFFF;
+ public static final int GDK_Return = 0xFF0D;
+ public static final int GDK_Escape = 0xFF1B;
+ public static final int GDK_Cancel = 0xFF69;
+ public static final int GDK_Tab = 0xFF09;
/* Functions Keys */
public static final int GDK_F1 = 0xFFBE;
public static final int GDK_F2 = 0xFFBF;
@@ -94,7 +98,6 @@
public static final int GDK_F10 = 0xFFC7;
public static final int GDK_F11 = 0xFFC8;
public static final int GDK_F12 = 0xFFC9;
- public static final int GDK_Return = 0xFF0D;
/* Numeric Keypad */
public static final int GDK_KP_Add = 0xFFAB;
public static final int GDK_KP_Subtract = 0xFFAD;
@@ -155,6 +158,7 @@
public static final int GDK_BUTTON_RELEASE = 7;
public static final int GDK_KEY_PRESS = 8;
public static final int GDK_KEY_RELEASE = 9;
+ public static final int GDK_FOCUS_CHANGE = 12;
public static final int GDK_NO_EXPOSE = 30;
/* The values for the GdkModifierType constants are specified in the
@@ -255,8 +259,7 @@
public static final int GTK_VISIBILITY_PARTIAL = 1;
public static final int GTK_VISIBILITY_FULL = 2;
public static final int GTK_WINDOW_TOPLEVEL = 0;
- public static final int GTK_WINDOW_DIALOG = 1;
- public static final int GTK_WINDOW_POPUP = 2;
+ public static final int GTK_WINDOW_POPUP = 1;
public static final int GTK_ACCEL_VISIBLE = 1 << 0;
public static final int GTK_NO_WINDOW = 1 << 5;
public static final int GTK_MAPPED = 1 << 7;
@@ -265,6 +268,7 @@
public static final int GTK_CAN_FOCUS = 1 << 11;
public static final int GTK_HAS_FOCUS = 1 << 12;
public static final int GTK_CAN_DEFAULT = 1 << 13;
+ public static final int GTK_WIDGET_DOUBLE_BUFFERED = 1 << 21;
public static final int GTK_CLIST_SHOW_TITLES = 1 << 2;
public static final int GTK_PROGRESS_CONTINUOUS = 0;
public static final int GTK_PROGRESS_DISCRETE = 1;
@@ -272,6 +276,7 @@
public static final int GTK_PROGRESS_RIGHT_TO_LEFT = 1;
public static final int GTK_PROGRESS_BOTTOM_TO_TOP = 2;
public static final int GTK_PROGRESS_TOP_TO_BOTTOM = 3;
+ public static final int GTK_RECEIVES_DEFAULT = 1<<20;
/* The values for the GdkGrabStatus constants are specified in
* the documentation, therefore there is no need to get them from the OS.
@@ -282,6 +287,21 @@
public static final int GDK_GRAB_NOT_VIEWABLE = 3;
public static final int GDK_GRAB_FROZEN = 4;
+ /* The values for the GtkResponseType constants are specified in
+ * the documentation, therefore there is no need to get them from the OS.
+ */
+ public static final int GTK_RESPONSE_NONE = -1;
+ public static final int GTK_RESPONSE_REJECT = -2;
+ public static final int GTK_RESPONSE_ACCEPT = -3;
+ public static final int GTK_RESPONSE_DELETE_EVENT = -4;
+ public static final int GTK_RESPONSE_OK = -5;
+ public static final int GTK_RESPONSE_CANCEL = -6;
+ public static final int GTK_RESPONSE_CLOSE = -7;
+ public static final int GTK_RESPONSE_YES = -8;
+ public static final int GTK_RESPONSE_NO = -9;
+ public static final int GTK_RESPONSE_APPLY = -10;
+ public static final int GTK_RESPONSE_HELP = -11;
+
public static final native int GTK_TOOLBAR_CHILD_SPACE();
public static final native int GTK_TOOLBAR_CHILD_BUTTON();
@@ -330,7 +350,6 @@
public static final native boolean GTK_WIDGET_SENSITIVE(int wid);
public static final native boolean GTK_WIDGET_IS_SENSITIVE(int wid);
public static final native boolean GTK_WIDGET_TOPLEVEL(int wid);
-public static final native boolean GTK_WIDGET_REALISED(int wid);
public static final native boolean GTK_WIDGET_MAPPED(int wid);
public static final native boolean GTK_WIDGET_VISIBLE(int wid);
public static final native boolean GTK_WIDGET_DRAWABLE(int wid);
@@ -343,8 +362,6 @@
public static final native int GTK_FONT_SELECTION_DIALOG_OK_BUTTON(int handle);
public static final native int GTK_FONT_SELECTION_DIALOG_CANCEL_BUTTON(int handle);
-public static final native int GTK_FILE_SELECTION_OK_BUTTON(int handle);
-public static final native int GTK_FILE_SELECTION_CANCEL_BUTTON(int handle);
public static final native int GTK_COLOR_SELECTION_OK_BUTTON(int handle);
public static final native int GTK_COLOR_SELECTION_CANCEL_BUTTON(int handle);
public static final native int GTK_COLOR_SELECTION_HELP_BUTTON(int handle);
@@ -486,9 +503,12 @@
public static final native int gdk_atom_intern(byte[] atom_name, int only_if_exists);
public static final native int gdk_event_get();
public static final native void gdk_region_get_clipbox(int region, GdkRectangle rectangle);
+public static final native void gdk_region_get_rectangles(int region, int[] rectangles, int[] n_rectangles);
public static final native int gdk_region_new();
public static final native void gdk_region_union_with_rect(int region, GdkRectangle rect);
public static final native void gdk_region_subtract(int source1, int source2);
+public static final native void gdk_region_intersect(int source1, int source2);
+public static final native void gdk_region_offset(int region, int dx, int dy);
public static final native void gdk_region_union(int source1, int source2);
public static final native void gdk_region_destroy(int region);
public static final native int gdk_pixmap_new(int window, int width, int height, int depth);
@@ -503,8 +523,8 @@
public static final native int gdk_string_height(int font, byte[] string);
public static final native int gdk_string_width(int font, byte[] string);
public static final native void gdk_window_copy_area(int window, int gc, int x, int y, int source_window, int source_x, int source_y, int width, int height);
-public static final native void gdk_window_clear_area(int window, int x, int y, int width, int height);
-public static final native void gdk_window_clear_area_e(int window, int x, int y, int width, int height);
+//public static final native void gdk_window_clear_area(int window, int x, int y, int width, int height);
+//public static final native void gdk_window_clear_area_e(int window, int x, int y, int width, int height);
public static final native void gdk_window_resize(int window, int width, int height);
public static final native void gdk_window_move (int window, int x, int y);
public static final native int gdk_window_at_pointer(int[] win_x, int[] win_y);
@@ -516,7 +536,7 @@
public static final native void gdk_window_raise(int window);
public static final native void gdk_window_lower(int window);
public static final native int gdk_window_get_origin(int window, int[] x, int[] y);
-public static final native int gdk_window_get_pointer(int window, int[] x, int[] y, int mask);
+public static final native int gdk_window_get_pointer(int window, int[] x, int[] y, int[] mask);
public static final native void gdk_window_set_cursor(int window, int cursor);
public static final native void gdk_window_set_icon(int window, int icon_window, int pixmap, int mask);
public static final native void gdk_window_set_user_data(int window, int user_data);
@@ -565,7 +585,7 @@
public static final native void gtk_clist_set_pixtext(int clist, int row, int column, byte[] text, byte spacing, int pixmap, int mask);
//public static final native void gtk_clist_set_pixmap(int clist, int row, int column, int pixmap, int mask);
public static final native void gtk_container_add(int container, int widget);
-public static final native int gtk_container_children(int container);
+public static final native int gtk_container_get_children(int container);
public static final native int gtk_color_selection_dialog_new(byte[] title);
public static final native void gtk_color_selection_get_color(int colorsel, double[] color);
public static final native void gtk_color_selection_set_color(int colorsel, double[] color);
@@ -666,7 +686,7 @@
public static final native void gtk_menu_item_set_submenu(int menu_item, int submenu);
public static final native void gtk_menu_item_remove_submenu(int menu_item);
public static final native int gtk_notebook_new();
-public static final native void gtk_notebook_append_page(int notebook, int child, int tab_label);
+public static final native void gtk_notebook_insert_page(int notebook, int child, int tab_label, int position);
public static final native int gtk_notebook_get_current_page(int notebook);
public static final native void gtk_object_ref(int object);
public static final native void gtk_notebook_set_show_tabs(int notebook, boolean show_tabs);
@@ -795,10 +815,13 @@
public static final native int pango_font_face_describe(int face);
public static final native int pango_language_from_string(byte[] language);
+public static final native int pango_language_to_string(int language);
public static final native int pango_layout_new(int context);
public static final native void pango_layout_set_text(int layout, byte[] text, int length);
public static final native void pango_layout_get_size(int layout, int[] width, int[] height);
+public static final native void pango_layout_set_font_description(int layout, int desc);
+public static final native void pango_layout_set_markup_with_accel(int layout, byte[] markup, int length, char accel_marker, char[] accel_char);
public static final native int pango_font_description_new();
public static final native int pango_font_description_from_string(byte[] str);
@@ -873,6 +896,7 @@
public static final native void memmove(int[] dest, byte[] src, int size);
public static final native void memmove(int dest, byte[] src, int size);
public static final native void memmove(int dest, int[] src, int size);
+public static final native void memmove(GdkRectangle dest, int src, int size);
/* Read memmoves */
@@ -885,7 +909,7 @@
static final native void memmove(GtkCombo dest, int src);
static final native void memmove(GtkEditable dest, int src);
static final native void memmove(GtkStyle dest, int src);
-static final native void memmove(GtkStyleClass dest, int src);
+//static final native void memmove(GtkStyleClass dest, int src);
static final native void memmove(GtkCListRow dest, int src);
static final native void memmove(GtkCListColumn dest, int src);
static final native void memmove(GtkCList dest, int src);
@@ -906,6 +930,7 @@
public static final native void gtk_label_set_text_with_mnemonic(int label, byte[] str);
public static final native int gtk_label_new_with_mnemonic(byte[] str);
public static final native int gtk_frame_get_label_widget(int frame);
+public static final native void gtk_frame_set_label_widget(int frame, int label_widget);
public static final native void gtk_widget_set_size_request(int widget, int width, int height);
public static final native void gtk_widget_get_size_request(int widget, int [] width, int [] height);
@@ -921,6 +946,9 @@
public static final native void gtk_fixed_set_has_window(int fixed, boolean has_window);
public static final native void gtk_scrolled_window_add_with_viewport (int scrolled_window, int child);
public static final native void gtk_widget_modify_bg (int widget, int state, GdkColor color);
+public static final native void gtk_widget_modify_fg (int widget, int state, GdkColor color);
+public static final native void gtk_widget_modify_base (int widget, int state, GdkColor color);
+public static final native void gtk_widget_modify_text (int widget, int state, GdkColor color);
public static final native void GTK_BIN_SET_CHILD (int bin, int child);
public static final native void gtk_scrolled_window_set_shadow_type(int scrolled_window, int type);
public static final native void gtk_widget_queue_resize(int widget);
@@ -930,4 +958,44 @@
public static final native int gdk_pointer_ungrab(int time);
public static final native int g_signal_connect_swapped(int instance, byte[] detailed_sigal, int c_handler, int data);
public static final native void gtk_window_set_default(int window, int widget);
-}
+public static final native int gtk_window_get_default(int window);
+public static final native boolean gtk_window_activate_default(int window);
+public static final native void gtk_widget_activate(int widget);
+public static final native void gtk_clist_set_row_height(int clist, int height);
+public static final native boolean gdk_event_focus_get_in(int event);
+public static final native void gdk_window_set_back_pixmap(int window, int pixmap, boolean parent_relative);
+public static final native void gdk_window_set_override_redirect(int window, boolean override_redirect);
+
+public static final native int gtk_widget_send_expose(int widget, int event);
+public static final native void gdk_window_scroll(int window, int dx, int dy);
+public static final native void gtk_container_set_border_width(int container, int border_width);
+public static final native int gdk_drawable_get_visible_region (int drawable);
+
+public static final native void gdk_window_invalidate_rect(int window, GdkRectangle rectangle, boolean invalidate_children);
+public static final native void gdk_window_invalidate_region(int window, int region, boolean invalidate_children);
+public static final native void gtk_notebook_set_scrollable(int notebook, boolean scrollable);
+public static final native boolean gtk_notebook_get_scrollable(int notebook);
+public static final native void gtk_button_set_relief(int button, int newstyle);
+
+/* Clipboard */
+public static final native int gtk_clipboard_clear( int clipboard );
+public static final native int gtk_clipboard_get( int selection );
+public static final native boolean gtk_clipboard_set_with_data (int clipboard, int targets, int n_targets, int get_func, int clear_func, int user_data);
+public static final native int gtk_clipboard_wait_for_contents (int clipboard, int target);
+public static final native int gtk_selection_data_free( int selection_data );
+public static final native void gtk_selection_data_set(int selection_data, int type, int format, int data, int length);
+public static final native void memmove(int dest, GtkTargetEntry src);
+public static final native void memmove(GtkSelectionData dest, int src);
+
+/* Temporary code */
+public static final native void gtk_style_set_xthickness(int style, int xthickness);
+public static final native void gtk_style_set_ythickness(int style, int ythickness);
+
+public static final native void gtk_window_set_destroy_with_parent (int window, boolean setting);
+public static final native void gdk_window_get_internal_paint_info(int window, int[] drawable, int[] x_offset, int[] y_offset);
+public static final native int gtk_dialog_run(int dialog);
+public static final native void gtk_file_selection_set_select_multiple(int filesel, boolean select_multiple);
+public static final native int gtk_file_selection_get_selections(int filesel);
+public static final native void g_strfreev(int string_array);
+public static final native int g_filename_to_utf8(int opsysstring, int len, int bytes_read, int bytes_written, int error);
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
index b32e310..994cd11 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
@@ -10,7 +10,7 @@
CC=cc_r
# Define the installation directories for various products.
-# JAVA_HOME - IBM's version of Java
+# JAVA_HOME - The JDK > 1.3
# CDE_HOME - CDE includes and libraries
# MOTIF_HOME - Motif includes and libraries
JAVA_HOME = /usr/java131
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak
index 61b67a3..76bbe5e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak
@@ -9,10 +9,10 @@
# Define the installation directories for various products.
-# IVE_HOME - IBM's version of Java (J9)
+# JAVA_HOME - The JDK > 1.3
# MOTIF_HOME - Motif includes and libraries
# QT_HOME - identifier namespace package (used by KDE)
-IVE_HOME = /bluebird/teamswt/swt-builddir/ive/bin
+JAVA_HOME = /bluebird/teamswt/swt-builddir/ive/bin
MOTIF_HOME = /bluebird/teamswt/swt-builddir/motif21
QT_HOME = /usr/lib/qt-2.3.0
@@ -47,7 +47,7 @@
-DLINUX -DMOTIF -DGNOME \
-fpic \
-I./ \
- -I$(IVE_HOME)/include \
+ -I$(JAVA_HOME)/include \
-I$(MOTIF_HOME)/include \
-I/usr/X11R6/include \
`gnome-config --cflags gnome gnomeui`
@@ -77,7 +77,7 @@
$(KDE_OBJ): kde.cc
g++ -c -O -I/usr/include/kde -I$(QT_HOME)/include -I./ \
- -I../ -I$(IVE_HOME)/include -fno-rtti -o kde.o kde.cc
+ -I../ -I$(JAVA_HOME)/include -fno-rtti -o kde.o kde.cc
clean:
rm -f *.so *.o
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_solaris.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_solaris.mak
index 22ce67a..9732ca8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_solaris.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_solaris.mak
@@ -9,7 +9,7 @@
# Define the installation directories for various products.
-# JAVA_HOME - Sun's version of Java (JDK2)
+# JAVA_HOME - The JDK > 1.3
# MOTIF_HOME - Motif includes and libraries
# CDE_HOME - CDE includes and libraries
JAVA_HOME = /tools/java1.3
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
index 7efdb08..93f7b21 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
@@ -264,14 +264,13 @@
// public static final int NorthEastGravity = 3;
// public static final int NorthGravity = 2;
public static final int NorthWestGravity = 1;
-// public static final int NorthWestGravity = 1;
public static final int NotifyAncestor = 0x0;
// public static final int NotifyDetailNone = 0x7;
// public static final int NotifyGrab = 0x1;
// public static final int NotifyHint = 0x1;
public static final int NotifyInferior = 0x2;
public static final int NotifyNonlinear = 0x3;
-// public static final int NotifyNonlinearVirtual = 0x4;
+ public static final int NotifyNonlinearVirtual = 0x4;
public static final int NotifyNormal = 0x0;
// public static final int NotifyPointer = 0x5;
// public static final int NotifyPointerRoot = 0x6;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
index 52bcb04..d600966 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
@@ -21,9 +21,11 @@
LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib oleacc.lib
# note: thoroughly test all examples after changing any optimization flags
-CFLAGS = -c -W3 -G6 -GD -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -nologo -D_X86_=1 -D_WIN32 -D_WIN95 -D_WIN32_WINDOWS=0x0400 -D_MT -MT -DWIN32 -D_WIN32_DCOM /I$(JAVA_HOME)\include /I.
+SWT_CDEBUG = #-Zi -Odi
+SWT_LDEBUG = #/DEBUG /DEBUGTYPE:both
+CFLAGS = -c -W3 -G6 -GD -O1 $(SWT_CDEBUG) -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -nologo -D_X86_=1 -D_WIN32 -D_WIN95 -D_WIN32_WINDOWS=0x0400 -D_MT -MT -DWIN32 -D_WIN32_DCOM /I$(JAVA_HOME)\include /I.
RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver)
-LFLAGS = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL
+LFLAGS = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO $(SWT_LDEBUG) -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL
SWT_OBJS = swt.obj structs.obj callback.obj swtole.obj
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
index d0d8b24..192b53a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
@@ -1868,10 +1868,12 @@
lpCache->iString = (*env)->GetFieldID(env, lpCache->clazz, "iString", "I");
lpCache->cchText = (*env)->GetFieldID(env, lpCache->clazz, "cchText", "I");
lpCache->pszText = (*env)->GetFieldID(env, lpCache->clazz, "pszText", "I");
+#ifndef _WIN32_WCE
lpCache->left = (*env)->GetFieldID(env, lpCache->clazz, "left", "I");
lpCache->top = (*env)->GetFieldID(env, lpCache->clazz, "top", "I");
lpCache->right = (*env)->GetFieldID(env, lpCache->clazz, "right", "I");
lpCache->bottom = (*env)->GetFieldID(env, lpCache->clazz, "bottom", "I");
+#endif // _WIN32_WCE
lpCache->cached = 1;
}
@@ -2436,12 +2438,12 @@
lpCache->cx = (*env)->GetFieldID(env, lpCache->clazz, "cx", "I");
lpCache->hbmBack = (*env)->GetFieldID(env, lpCache->clazz, "hbmBack", "I");
lpCache->wID = (*env)->GetFieldID(env, lpCache->clazz, "wID", "I");
-#ifndef _WIN32_WCE
lpCache->cyChild = (*env)->GetFieldID(env, lpCache->clazz, "cyChild", "I");
lpCache->cyMaxChild = (*env)->GetFieldID(env, lpCache->clazz, "cyMaxChild", "I");
lpCache->cyIntegral = (*env)->GetFieldID(env, lpCache->clazz, "cyIntegral", "I");
lpCache->cxIdeal = (*env)->GetFieldID(env, lpCache->clazz, "cxIdeal", "I");
lpCache->lParam = (*env)->GetFieldID(env, lpCache->clazz, "lParam", "I");
+#ifndef _WIN32_WCE
lpCache->cxHeader = (*env)->GetFieldID(env, lpCache->clazz, "cxHeader", "I");
#endif // _WIN32_WCE
lpCache->cached = 1;
@@ -2464,12 +2466,12 @@
lpStruct->cx = (*env)->GetIntField(env, lpObject, lpCache->cx);
lpStruct->hbmBack = (HBITMAP)(*env)->GetIntField(env, lpObject, lpCache->hbmBack);
lpStruct->wID = (*env)->GetIntField(env, lpObject, lpCache->wID);
-#ifndef _WIN32_WCE
lpStruct->cyChild = (*env)->GetIntField(env, lpObject, lpCache->cyChild);
lpStruct->cyMaxChild = (*env)->GetIntField(env, lpObject, lpCache->cyMaxChild);
lpStruct->cyIntegral = (*env)->GetIntField(env, lpObject, lpCache->cyIntegral);
lpStruct->cxIdeal = (*env)->GetIntField(env, lpObject, lpCache->cxIdeal);
lpStruct->lParam = (*env)->GetIntField(env, lpObject, lpCache->lParam);
+#ifndef _WIN32_WCE
lpStruct->cxHeader = (*env)->GetIntField(env, lpObject, lpCache->cxHeader);
#endif // _WIN32_WCE
return lpStruct;
@@ -2492,12 +2494,12 @@
(*env)->SetIntField(env, lpObject, lpCache->cx, lpStruct->cx);
(*env)->SetIntField(env, lpObject, lpCache->hbmBack, (jint)lpStruct->hbmBack);
(*env)->SetIntField(env, lpObject, lpCache->wID, lpStruct->wID);
-#ifndef _WIN32_WCE
(*env)->SetIntField(env, lpObject, lpCache->cyChild, lpStruct->cyChild);
(*env)->SetIntField(env, lpObject, lpCache->cyMaxChild, lpStruct->cyMaxChild);
(*env)->SetIntField(env, lpObject, lpCache->cyIntegral, lpStruct->cyIntegral);
(*env)->SetIntField(env, lpObject, lpCache->cxIdeal, lpStruct->cxIdeal);
(*env)->SetIntField(env, lpObject, lpCache->lParam, lpStruct->lParam);
+#ifndef _WIN32_WCE
(*env)->SetIntField(env, lpObject, lpCache->cxHeader, lpStruct->cxHeader);
#endif // _WIN32_WCE
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
index 7229f0c..6b64001 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
@@ -503,7 +503,10 @@
typedef struct NMTOOLBAR_FID_CACHE {
int cached;
jclass clazz;
- jfieldID hwndFrom, idFrom, code, iItem, iBitmap, idCommand, fsState, fsStyle, dwData, iString, cchText, pszText, left, top, right, bottom;
+ jfieldID hwndFrom, idFrom, code, iItem, iBitmap, idCommand, fsState, fsStyle, dwData, iString, cchText, pszText;
+#ifndef _WIN32_WCE
+ jfieldID left, top, right, bottom;
+#endif // _WIN32_WCE
} NMTOOLBAR_FID_CACHE;
typedef NMTOOLBAR_FID_CACHE *PNMTOOLBAR_FID_CACHE;
@@ -616,7 +619,10 @@
typedef struct REBARBANDINFO_FID_CACHE {
int cached;
jclass clazz;
- jfieldID cbSize, fMask, fStyle, clrFore, clrBack, lpText, cch, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID, cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader;
+ jfieldID cbSize, fMask, fStyle, clrFore, clrBack, lpText, cch, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID, cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam;
+#ifndef _WIN32_WCE
+ jfieldID cxHeader;
+#endif // _WIN32_WCE
} REBARBANDINFO_FID_CACHE;
typedef REBARBANDINFO_FID_CACHE *PREBARBANDINFO_FID_CACHE;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
index d4053b3..ea7f39e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
@@ -3843,6 +3843,7 @@
jshort *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL);
@@ -3857,6 +3858,7 @@
jfloat *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL);
@@ -3871,6 +3873,7 @@
jdouble *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL);
@@ -3885,6 +3888,7 @@
jshort *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL);
@@ -3899,6 +3903,7 @@
jfloat *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL);
@@ -3913,6 +3918,7 @@
jdouble *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL);
@@ -3929,6 +3935,7 @@
DROPFILES _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getDROPFILESFields(env, arg1, &_arg1, &PGLOB(DROPFILESFc));
@@ -3945,6 +3952,7 @@
MSG _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -3960,6 +3968,7 @@
WINDOWPOS _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -3975,6 +3984,7 @@
TVITEM _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -3990,6 +4000,7 @@
NMTOOLBAR _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4005,6 +4016,7 @@
NMLISTVIEW _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4021,6 +4033,7 @@
NMREBARCHEVRON _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4037,6 +4050,7 @@
NMHEADER _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4052,6 +4066,7 @@
NMHDR _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4067,6 +4082,7 @@
NMCUSTOMDRAW _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getNMCUSTOMDRAWFields(env, arg1, &_arg1, &PGLOB(NMCUSTOMDRAWFc));
@@ -4082,6 +4098,7 @@
NMLVCUSTOMDRAW _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getNMLVCUSTOMDRAWFields(env, arg1, &_arg1, &PGLOB(NMLVCUSTOMDRAWFc));
@@ -4097,6 +4114,7 @@
NMTVCUSTOMDRAW _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getNMTVCUSTOMDRAWFields(env, arg1, &_arg1, &PGLOB(NMTVCUSTOMDRAWFc));
@@ -4112,6 +4130,7 @@
NMCUSTOMDRAW _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = getNMCUSTOMDRAWFields(env, arg0, &_arg0, &PGLOB(NMCUSTOMDRAWFc));
@@ -4127,6 +4146,7 @@
NMLVCUSTOMDRAW _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
//if (arg0) lparg0 = getNMLVCUSTOMDRAWFields(env, arg0, &_arg0, &PGLOB(NMLVCUSTOMDRAWFc));
if (arg0) lparg0 = &_arg0;
@@ -4144,6 +4164,7 @@
NMTVCUSTOMDRAW _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = getNMTVCUSTOMDRAWFields(env, arg0, &_arg0, &PGLOB(NMTVCUSTOMDRAWFc));
@@ -4159,6 +4180,7 @@
MEASUREITEMSTRUCT _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4175,6 +4197,7 @@
HELPINFO _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4191,6 +4214,7 @@
HDITEM _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4206,6 +4230,7 @@
DRAWITEMSTRUCT _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4222,6 +4247,7 @@
TRIVERTEX _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getTRIVERTEXFields(env, arg1, &_arg1, &PGLOB(TRIVERTEXFc));
@@ -4236,6 +4262,7 @@
RECT _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1, &PGLOB(RECTFc));
@@ -4249,6 +4276,7 @@
WINDOWPOS _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getWINDOWPOSFields(env, arg1, &_arg1, &PGLOB(WINDOWPOSFc));
@@ -4262,6 +4290,7 @@
MEASUREITEMSTRUCT _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getMEASUREITEMSTRUCTFields(env, arg1, &_arg1, &PGLOB(MEASUREITEMSTRUCTFc));
@@ -4276,6 +4305,7 @@
GRADIENT_RECT _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getGRADIENT_RECTFields(env, arg1, &_arg1, &PGLOB(GRADIENT_RECTFc));
@@ -4289,6 +4319,7 @@
jint *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
@@ -4303,6 +4334,7 @@
jchar *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
@@ -4317,6 +4349,7 @@
jbyte *lparg1=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
@@ -4331,6 +4364,7 @@
jint *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
@@ -4362,6 +4396,7 @@
jbyte *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
@@ -4376,6 +4411,7 @@
jchar *lparg0=NULL;
DEBUG_CALL("MoveMemory\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
@@ -4392,6 +4428,7 @@
NMTTDISPINFOA _arg0={0}, *lparg0=NULL;
DEBUG_CALL("MoveMemoryA\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4407,6 +4444,7 @@
LOGFONTA _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemoryA\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4422,6 +4460,7 @@
NMTTDISPINFOA _arg1={0}, *lparg1=NULL;
DEBUG_CALL("MoveMemoryA\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getNMTTDISPINFOAFields(env, arg1, &_arg1, &PGLOB(NMTTDISPINFOFc));
@@ -4435,6 +4474,7 @@
LOGFONTA _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemoryA\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1, &PGLOB(LOGFONTFc));
@@ -4450,6 +4490,7 @@
NMTTDISPINFOW _arg0={0}, *lparg0=NULL;
DEBUG_CALL("MoveMemoryW\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4466,6 +4507,7 @@
LOGFONTW _arg0, *lparg0=NULL;
DEBUG_CALL("MoveMemoryW\n")
+ DEBUG_CHECK_NULL(env, arg1)
if (arg0) lparg0 = &_arg0;
@@ -4482,6 +4524,7 @@
NMTTDISPINFOW _arg1={0}, *lparg1=NULL;
DEBUG_CALL("MoveMemoryW\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getNMTTDISPINFOWFields(env, arg1, &_arg1, &PGLOB(NMTTDISPINFOFc));
@@ -4496,6 +4539,7 @@
LOGFONTW _arg1, *lparg1=NULL;
DEBUG_CALL("MoveMemoryW\n")
+ DEBUG_CHECK_NULL(env, arg0)
if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1, &PGLOB(LOGFONTFc));
@@ -6827,6 +6871,19 @@
return rc;
}
+#ifdef _WIN32_WCE
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TransparentImage
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4,
+ jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+ DEBUG_CALL("TransparentImage\n")
+
+ return (jboolean)TransparentImage((HDC) arg0, (LONG) arg1, (LONG) arg2,
+ (LONG) arg3, (LONG) arg4, (HANDLE) arg5, (LONG) arg6, (LONG) arg7,
+ (LONG) arg8, (LONG) arg9, (COLORREF) arg10);
+}
+#endif // _WIN32_WCE
+
#ifndef _WIN32_WCE
JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_UnhookWindowsHookEx
(JNIEnv *env, jclass that, jint arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/package.html
index 1c2f7fe..788f29f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
index 8723a2f..b1936e3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
@@ -17,5 +17,6 @@
public int pszText;
// RECT rcButton;
public int left, top, right, bottom;
- public static final int sizeof = 60;
+ /* Note in WinCE. The field rcButton is not defined. */
+ public static final int sizeof = OS.IsWinCE ? 44 : 60;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 47add52..ea26067 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -671,8 +671,10 @@
public static final int RBBS_BREAK = 0x1;
public static final int RBBS_GRIPPERALWAYS = 0x80;
public static final int RBBS_NOGRIPPER = 0x00000100;
+ public static final int RBBS_USECHEVRON = 0x00000200;
public static final int RBBS_VARIABLEHEIGHT = 0x40;
public static final int RBN_FIRST = 0xfffffcc1;
+ public static final int RBN_CHEVRONPUSHED = RBN_FIRST - 10;
public static final int RBN_HEIGHTCHANGE = 0xfffffcc1;
public static final int RBS_DBLCLKTOGGLE = 0x8000;
public static final int RBS_BANDBORDERS = 0x400;
@@ -1047,6 +1049,7 @@
public static final int WM_CUT = 0x300;
public static final int WM_DESTROY = 0x2;
public static final int WM_DRAWITEM = 0x2b;
+ public static final int WM_ENDSESSION = 0x16;
public static final int WM_ERASEBKGND = 0x14;
public static final int WM_GETDLGCODE = 0x87;
public static final int WM_GETFONT = 0x31;
@@ -1088,6 +1091,8 @@
public static final int WM_PAINT = 0xf;
public static final int WM_PALETTECHANGED = 0x311;
public static final int WM_PASTE = 0x302;
+ public static final int WM_PRINTCLIENT = 0x0318;
+ public static final int WM_QUERYENDSESSION = 0x11;
public static final int WM_QUERYNEWPALETTE = 0x30f;
public static final int WM_QUERYOPEN = 0x13;
public static final int WM_RBUTTONDBLCLK = 0x206;
@@ -2295,7 +2300,7 @@
public static final native int TranslateAcceleratorA (int hWnd, int hAccTable, MSG lpMsg);
public static final native boolean TranslateCharsetInfo(int lpSrc, int [] lpCs, int dwFlags);
public static final native boolean TranslateMessage (MSG lpmsg);
-public static final native boolean UnhookWindowsHookEx(int hhk);
+public static final native boolean TransparentImage (int hdcDest, int DstX, int DstY, int DstCx, int DstCy,int hSrc, int SrcX, int SrcY, int SrcCx, int SrcCy, int TransparentColor);public static final native boolean UnhookWindowsHookEx(int hhk);
public static final native boolean UnregisterClassW (char [] lpClassName, int hInstance);
public static final native boolean UnregisterClassA (byte [] lpClassName, int hInstance);
public static final native boolean UpdateWindow (int hWnd);
@@ -2307,5 +2312,4 @@
public static final native int WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, byte [] lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, boolean [] lpUsedDefaultChar);
public static final native int WindowFromDC (int lpPoint);
public static final native int WindowFromPoint (POINT lpPoint);
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
index 43aa7e3..4f71f48 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
@@ -25,5 +25,6 @@
public int cxIdeal;
public int lParam;
public int cxHeader;
+ /* Note in WinCE. The field cxHeader is not defined. */
public static final int sizeof = OS.IsWinCE ? 76 : 80;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/package.html
index 049087b..878a44b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
@@ -16,7 +17,5 @@
that the code is platform specific. Applications should not need to
reference the classes in this package directly.
</p>
-
-</p>
</body>
</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
index 8504b5e..28b4d3a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
@@ -1,3 +1,4 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
index 25df82c..76d7ffa 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
index 4aeb4c4..0dec379 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
@@ -526,6 +526,9 @@
}
static boolean kde_init () {
+ // TEMPORARY CODE
+ if (true) return false;
+
try {
Library.loadLibrary("swt-kde");
} catch (Throwable e) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak b/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
index 050aa5e..69234e1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
@@ -1,4 +1,4 @@
maj_ver=2
-min_ver=032
+min_ver=036
bld_num=0
-comma_ver=2,0,3,2
+comma_ver=2,0,3,6
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h b/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
index f2457ce..2160b77 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
@@ -22,11 +22,25 @@
/* define this to print out debug statements */
/* #define DEBUG_CALL_PRINTS */
+#define DEBUG_CHECK_NULL_EXCEPTIONS
#ifdef DEBUG_CALL_PRINTS
#define DEBUG_CALL(func) fprintf(stderr, func);
#else
#define DEBUG_CALL(func)
+#endif
+
+#ifdef DEBUG_CHECK_NULL_EXCEPTIONS
+#define DEBUG_CHECK_NULL(env, address) \
+ if (address == 0) { \
+ jclass clazz = (*env)->FindClass(env, "org/eclipse/swt/SWTError"); \
+ if (clazz != NULL) { \
+ (*env)->ThrowNew(env, clazz, "Argument cannot be NULL"); \
+ } \
+ return; \
+ }
+#else
+#define DEBUG_CHECK_NULL(func)
#endif
#define DECL_GLOB(pSym)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
index 6cb7203..36de268 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index ca7e26b..f6f93f2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -1683,6 +1683,7 @@
* (see ALPHA_MODE_xxx constants)
* @param alphaData the alpha blending or mask data, varies depending
* on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
* @param destData the destination byte array containing image data
* @param destDepth the destination depth: one of 8, 16, 24, 32
* @param destStride the destination number of bytes per line
@@ -2105,6 +2106,7 @@
* (see ALPHA_MODE_xxx constants)
* @param alphaData the alpha blending or mask data, varies depending
* on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
* @param destData the destination byte array containing image data
* @param destDepth the destination depth: one of 1, 2, 4, 8
* @param destStride the destination number of bytes per line
@@ -2629,6 +2631,7 @@
* (see ALPHA_MODE_xxx constants)
* @param alphaData the alpha blending or mask data, varies depending
* on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
* @param destData the destination byte array containing image data
* @param destDepth the destination depth: one of 8, 16, 24, 32
* @param destStride the destination number of bytes per line
@@ -2965,6 +2968,7 @@
* (see ALPHA_MODE_xxx constants)
* @param alphaData the alpha blending or mask data, varies depending
* on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
* @param destData the destination byte array containing image data
* @param destDepth the destination depth: one of 1, 2, 4, 8
* @param destStride the destination number of bytes per line
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
index c6a867e..92ffb70 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
index 055a6d5..dd90f68 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
@@ -12,7 +12,7 @@
final class GIFFileFormat extends FileFormat {
String signature, version;
boolean sorted;
- int screenWidth, screenHeight, backgroundPixel, aspect, bitsPerPixel;
+ int screenWidth, screenHeight, backgroundPixel, aspect, bitsPerPixel, defaultDepth;
boolean userInput = false;
int disposalMethod = 0;
int delayTime = 0;
@@ -85,17 +85,17 @@
backgroundPixel = block[5] & 0xFF;
aspect = block[6] & 0xFF;
bitsPerPixel = ((bitField >> 4) & 0x07) + 1;
- int depth = (bitField & 0x7) + 1;
+ defaultDepth = (bitField & 0x7) + 1;
PaletteData palette = null;
if ((bitField & 0x80) != 0) {
// Global palette.
sorted = (bitField & 0x8) != 0;
- palette = readPalette(1 << depth);
+ palette = readPalette(1 << defaultDepth);
} else {
// No global palette.
sorted = false;
backgroundPixel = -1;
- depth = bitsPerPixel;
+ defaultDepth = bitsPerPixel;
}
loader.backgroundPixel = backgroundPixel;
@@ -103,7 +103,7 @@
int id = readID();
ImageData[] images = new ImageData[0];
while (id == GIF_IMAGE_BLOCK_ID) {
- ImageData image = readImageBlock(depth, palette);
+ ImageData image = readImageBlock(palette);
if (loader.hasListeners()) {
loader.notifyListeners(new ImageLoaderEvent(loader, image, 3, true));
}
@@ -271,10 +271,18 @@
// Store the delay time.
delayTime = (controlBlock[1] & 0xFF) | ((controlBlock[2] & 0xFF) << 8);
// Store the transparent color.
- if ((bitField & 0x01) != 0)
- transparentPixel = controlBlock[3] & 0xFF;
- else
+ if ((bitField & 0x01) != 0) {
+ int colorIndex = controlBlock[3] & 0xFF;
+ /* Work around: a customer has a GIF that specifies an
+ * invalid color index that is larger than the number
+ * of entries in the palette. Detect this case, and
+ * ignore the specified color index. */
+ if (colorIndex <= 1 << defaultDepth) {
+ transparentPixel = colorIndex;
+ }
+ } else {
transparentPixel = -1;
+ }
// Read block terminator.
inputStream.read();
return controlBlock;
@@ -329,7 +337,7 @@
* image block at the current position in the input stream.
* Throw an error if an error occurs.
*/
- ImageData readImageBlock(int defaultDepth, PaletteData defaultPalette) {
+ ImageData readImageBlock(PaletteData defaultPalette) {
int depth;
PaletteData palette;
byte[] block = new byte[9];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
index 62fccda..457687f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
index da0cec5..41dec79 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
index 6f14ed3..c5678b0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
@@ -1,15 +1,15 @@
package org.eclipse.swt.layout;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All Rights Reserved
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
/**
* Instances of this class are used to define the edges of a control
- * within a <code>FormLayout</code>.
+ * within a <code>FormLayout</code>.
* <p>
* <code>FormAttachments</code> are set into the top, bottom, left,
* and right fields of the <code>FormData</code> for a control.
@@ -23,119 +23,237 @@
* button.setLayoutData(data);
* </pre>
* </p>
- * <p>
+ * <p>
* A <code>FormAttachment</code> defines where to attach the side of
- * a control by using the equation, y = ax + b. The "a" term represents
+ * a control by using the equation, y = ax + b. The "a" term represents
* a fraction of the parent composite's width (from the left) or height
* (from the top). It can be defined using a numerator and denominator,
* or just a percentage value. If a percentage is used, the denominator
* is set to 100. The "b" term in the equation represents an offset, in
- * pixels, from the attachment position. For example:
- * <pre>
- * FormAttachment attach = new FormAttachment (20, -5);
- * </pre>
- * specifies that the side to which the <code>FormAttachment</code>
- * object belongs will lie at 20% of the parent composite, minus 5 pixels.
- * </p>
- * <p>
- * Control sides can also be attached to the adjacent side of another control.
- * For example:
- * <pre>
- * FormAttachment attach = new FormAttachment (button, 10);
- * </pre>
- * specifies that the side to which the <code>FormAttachment</code>
- * object belongs will lie in the same position as the adjacent side of
- * the <code>button</code> control, plus 10 pixels.
- * </p>
- *
- * @see FormLayout
+ * pixels, from the attachment position. For example:
+ * <pre>
+ * FormAttachment attach = new FormAttachment (20, -5);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie at 20% of the parent composite, minus 5 pixels.
+ * </p>
+ * <p>
+ * Control sides can also be attached to another control.
+ * For example:
+ * <pre>
+ * FormAttachment attach = new FormAttachment (button, 10);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie in the same position as the adjacent side of
+ * the <code>button</code> control, plus 10 pixels. The control side can
+ * also be attached to the opposite side of the specified control.
+ * For example:
+ * <pre>
+ * FormData data = new FormData ();
+ * data.left = new FormAttachment (button, 0, SWT.LEFT);
+ * </pre>
+ * specifies that the left side of the control will lie in the same position
+ * as the left side of the <code>button</code> control. The control can also
+ * be attached in a position that will center the control on the specified
+ * control. For example:
+ * <pre>
+ * data.left = new FormAttachment (button, 0, SWT.CENTER);
+ * </pre>
+ * specifies that the left side of the control will be positioned so that it is
+ * centered between the left and right sides of the <code>button</code> control.
+ * If the alignment is not specified, the default is to attach to the adjacent side.
+ * </p>
+ *
+ * @see FormLayout
* @see FormData
*
* @since 2.0
*/
-public final class FormAttachment {
- /**
- * numerator specifies the numerator of the "a" term in the
- * equation, y = ax + b, which defines the attachment.
- */
- public int numerator;
- /**
- * denominator specifies the denominator of the "a" term in the
- * equation, y = ax + b, which defines the attachment.
- *
- * The default value is 100.
- */
- public int denominator = 100;
- /**
+public final class FormAttachment {
+ /**
+ * numerator specifies the numerator of the "a" term in the
+ * equation, y = ax + b, which defines the attachment.
+ */
+ public int numerator;
+ /**
+ * denominator specifies the denominator of the "a" term in the
+ * equation, y = ax + b, which defines the attachment.
+ *
+ * The default value is 100.
+ */
+ public int denominator = 100;
+ /**
* offset specifies the offset, in pixels, of the control side
- * from the attachment position.
+ * from the attachment position.
* If the offset is positive, then the control side is offset
* to the right of or below the attachment position. If it is
* negative, then the control side is offset to the left of or
* above the attachment position.
- *
+ *
* This is equivalent to the "b" term in the equation y = ax + b.
* The default value is 0.
- */
- public int offset;
- /**
- * control specifies the control to which the control side is
- * attached.
- */
- public Control control;
-
-FormAttachment () {
-}
-
-public FormAttachment (int numerator, int denominator, int offset) {
- if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- this.numerator = numerator;
- this.denominator = denominator;
- this.offset = offset;
-}
-
-public FormAttachment (int numerator, int offset) {
- this (numerator, 100, offset);
-}
-
-public FormAttachment (Control control, int offset) {
- this.control = control;
- this.offset = offset;
-}
-
-public FormAttachment (Control control) {
- this (control, 0);
+ */
+ public int offset;
+ /**
+ * control specifies the control to which the control side is
+ * attached.
+ */
+ public Control control;
+ /**
+ * alignment specifies the alignment of the control side that is
+ * attached to a control.
+ * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left
+ * and right attachments, LEFT, RIGHT and CENTER are used. If any other case
+ * occurs, the default will be used instead.
+ *
+ * Possible values are:
+ *
+ * TOP: Attach the side to the top side of the specified control.
+ * BOTTOM : Attach the side to the bottom side of the specified control.
+ * LEFT: Attach the side to the left side of the specified control.
+ * RIGHT: Attach the side to the right side of the specified control.
+ * CENTER: Attach the side at a position which will center the control on
+ * the specified control.
+ * DEFAULT: Attach the side to the adjacent side of the specified control.
+ */
+ public int alignment;
+
+FormAttachment () {
}
-
-FormAttachment minus (FormAttachment attachment) {
- FormAttachment solution = new FormAttachment();
- solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
- solution.denominator = denominator * attachment.denominator;
- solution.offset = offset - attachment.offset;
- return solution;
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * and denominator and an offset. The position of the side is
+ * given by the fraction of the form defined by the numerator
+ * and denominator.
+ *
+ * @param numerator the numerator of the position
+ * @param denominator the denominator of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int denominator, int offset) {
+ if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ this.numerator = numerator;
+ this.denominator = denominator;
+ this.offset = offset;
+}
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * and an offset. Since no denominator is specified, the default
+ * is to read the numerator as a percentage of the form, with a
+ * denominator of 100.
+ *
+ * @param numerator the percentage of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int offset) {
+ this (numerator, 100, offset);
+}
+
+/**
+ * Constructs a new instance of this class given a control,
+ * an offset and an alignment.
+ *
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ * @param alignment the alignment of the side to the control it is attached to
+ */
+public FormAttachment (Control control, int offset, int alignment) {
+ this.control = control;
+ this.offset = offset;
+ this.alignment = alignment;
+}
+
+/**
+ * Constructs a new instance of this class given a control
+ * and an offset. Since no alignment is specified, the default
+ * alignment is to attach the side to the adjacent side of the
+ * specified control.
+ *
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ */
+public FormAttachment (Control control, int offset) {
+ this (control, offset, SWT.DEFAULT);
+}
+
+/**
+ * Constructs a new instance of this class given a control.
+ * Since no alignment is specified, the default alignment is
+ * to attach the side to the adjacent side of the specified
+ * control. Since no offset is specified, an offset of 0 is
+ * used.
+ *
+ * @param control the control the side is attached to
+ */
+public FormAttachment (Control control) {
+ this (control, 0, SWT.DEFAULT);
+}
+
+FormAttachment divide (int value) {
+ return new FormAttachment (numerator, denominator * value, offset / value);
+}
+
+int gcd (int m, int n) {
+ int temp;
+ m = Math.abs (m); n = Math.abs (n);
+ if (m < n) {
+ temp = m;
+ m = n;
+ n = temp;
+ }
+ while (n != 0){
+ temp = m;
+ m = n;
+ n = temp % n;
+ }
+ return m;
+}
+
+FormAttachment minus (FormAttachment attachment) {
+ FormAttachment solution = new FormAttachment ();
+ solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
+ solution.denominator = denominator * attachment.denominator;
+ int gcd = gcd (solution.denominator, solution.numerator);
+ solution.numerator = solution.numerator / gcd;
+ solution.denominator = solution.denominator / gcd;
+ solution.offset = offset - attachment.offset;
+ return solution;
}
FormAttachment minus (int value) {
return new FormAttachment (numerator, denominator, offset - value);
-}
+}
+
+FormAttachment plus (FormAttachment attachment) {
+ FormAttachment solution = new FormAttachment ();
+ solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator;
+ solution.denominator = denominator * attachment.denominator;
+ int gcd = gcd (solution.denominator, solution.numerator);
+ solution.numerator = solution.numerator / gcd;
+ solution.denominator = solution.denominator / gcd;
+ solution.offset = offset + attachment.offset;
+ return solution;
+}
FormAttachment plus (int value) {
return new FormAttachment (numerator, denominator, offset + value);
}
-
-int solveX (int value) {
- if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- return ((numerator * value) / denominator) + offset;
-}
-
-int solveY (int value) {
- if (numerator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- return (value - offset) * denominator / numerator;
-}
-
-public String toString () {
- String string = control != null ? control.toString () : numerator + "/" + denominator;
- return "y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset));
+
+int solveX (int value) {
+ if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ return ((numerator * value) / denominator) + offset;
+}
+
+int solveY (int value) {
+ if (numerator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ return (value - offset) * denominator / numerator;
+}
+
+public String toString () {
+ String string = control != null ? control.toString () : numerator + "/" + denominator;
+ return "y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset));
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormData.java
index 38b430b..2b72feb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormData.java
@@ -1,12 +1,12 @@
package org.eclipse.swt.layout;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
* All Rights Reserved
*/
import org.eclipse.swt.*;
-
-/**
+
+/**
* Instances of this class are used to define the attachments
* of a control in a <code>FormLayout</code>.
* <p>
@@ -31,17 +31,15 @@
* @see FormLayout
* @see FormAttachment
*
- * @since 2.0
- */
+ * @since 2.0
+ */
public final class FormData {
/**
- * height specifies the desired height in pixels given
- * by the user
+ * height specifies the desired height in pixels
*/
public int height;
/**
- * width specifies the desired width in pixels given
- * by the user
+ * width specifies the desired width in pixels
*/
public int width;
/**
@@ -86,7 +84,13 @@
isVisited = true;
FormData bottomData = (FormData) bottom.control.getLayoutData ();
FormAttachment topAttachment = bottomData.getTopAttachment ();
+ FormAttachment bottomAttachment = bottomData.getBottomAttachment ();
isVisited = false;
+ if (bottom.alignment == SWT.BOTTOM) return bottomAttachment.plus (bottom.offset);
+ if (bottom.alignment == SWT.CENTER) {
+ FormAttachment bottomHeight = bottomAttachment.minus (topAttachment);
+ return bottomAttachment.minus (bottomHeight.minus (cacheHeight).divide (2));
+ }
return topAttachment.plus (bottom.offset);
}
@@ -100,7 +104,13 @@
isVisited = true;
FormData leftData = (FormData) left.control.getLayoutData ();
FormAttachment rightAttachment = leftData.getRightAttachment ();
+ FormAttachment leftAttachment = leftData.getLeftAttachment ();
isVisited = false;
+ if (left.alignment == SWT.LEFT) return leftAttachment.plus (left.offset);
+ if (left.alignment == SWT.CENTER) {
+ FormAttachment leftWidth = rightAttachment.minus (leftAttachment);
+ return leftAttachment.plus (leftWidth.minus (cacheWidth).divide (2));
+ }
return rightAttachment.plus (left.offset);
}
@@ -114,7 +124,13 @@
isVisited = true;
FormData rightData = (FormData) right.control.getLayoutData ();
FormAttachment leftAttachment = rightData.getLeftAttachment ();
+ FormAttachment rightAttachment = rightData.getRightAttachment ();
isVisited = false;
+ if (right.alignment == SWT.RIGHT) return rightAttachment.plus (right.offset);
+ if (right.alignment == SWT.CENTER) {
+ FormAttachment rightWidth = rightAttachment.minus (leftAttachment);
+ return rightAttachment.minus (rightWidth.minus (cacheWidth).divide (2));
+ }
return leftAttachment.plus (right.offset);
}
@@ -127,9 +143,15 @@
if (top.control == null) return top;
isVisited = true;
FormData topData = (FormData) top.control.getLayoutData ();
+ FormAttachment topAttachment = topData.getTopAttachment ();
FormAttachment bottomAttachment = topData.getBottomAttachment ();
isVisited = false;
+ if (top.alignment == SWT.TOP) return topAttachment.plus (top.offset);
+ if (top.alignment == SWT.CENTER) {
+ FormAttachment topHeight = bottomAttachment.minus (topAttachment);
+ return topAttachment.plus (topHeight.minus (cacheHeight).divide (2));
+ }
return bottomAttachment.plus (top.offset);
}
-
-}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
index d7a0a6c..329d1ed 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
@@ -1,7 +1,7 @@
package org.eclipse.swt.layout;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
* All Rights Reserved
*/
import org.eclipse.swt.*;
@@ -88,9 +88,28 @@
int [] pixelRowHeights;
int [] expandableColumns;
int [] expandableRows;
+
+/**
+ * Constructs a new instance of this class.
+ */
public GridLayout() {
- super();
}
+
+/**
+ * Constructs a new instance of this class given the
+ * number of columns, and whether or not the columns
+ * should be forced to have the same width.
+ *
+ * @param numColumns the number of columns in the grid
+ * @param makeColumnsEqualWidth whether or not the columns will have equal width
+ *
+ * @since 2.0
+ */
+public GridLayout(int numColumns, boolean makeColumnsEqualWidth) {
+ this.numColumns = numColumns;
+ this.makeColumnsEqualWidth = makeColumnsEqualWidth;
+}
+
void adjustGridDimensions(Composite composite, boolean flushCache) {
// Ensure that controls that span more than one row or column have enough space.
for (int row = 0; row < grid.size(); row++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
index 4408b8f..0b39569 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
@@ -8,6 +9,7 @@
SWT layout classes
<h2>
Package Specification</h2>
-This package contains several standard layout classes which provide automated positioning and sizing support for SWT widgets.
+This package contains several standard layout classes which provide
+automated positioning and sizing support for SWT widgets.
</body>
</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
index ec94fab..15fa6ee 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
@@ -1,3 +1,4 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
index b23d27b..daeabd3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
@@ -1,4 +1,5 @@
- <html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="IBM">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
index a6dbf21..d7ebc22 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
@@ -1 +1 @@
-version 2.032
+version 2.036
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
index f06f957..24db801 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
@@ -31,6 +31,7 @@
SWT_Charset_BalticRim=baltic rim
SWT_Charset_Celtic=celtic
SWT_Charset_Euro=euro
+SWT_Charset_Romanian=romanian
SWT_Charset_SimplifiedChinese=simplified chinese
SWT_Charset_TraditionalChinese=traditional chinese
SWT_Charset_Japanese=japanese
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
index bd11897..d57f354 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
@@ -5,9 +5,9 @@
* All Rights Reserved
*/
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
/**
* Instances of this class are selectable user interface
@@ -105,6 +105,43 @@
this.parent = parent;
parent.createItem (this, index);
}
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>SWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ *
+ * @since 2.0
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
@@ -255,6 +292,70 @@
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public Point getMinimumSize () {
+ return new Point (0, 0);
+}
+/**
+ * Sets the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (Point size) {
+ checkWidget ();
+ setMinimumSize (size.x, size.y);
+}
+
+/**
+ * Sets the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (int width, int height) {
+ checkWidget ();
+}
+/**
+ * @deprecated use getMinimumSize
+ */
+public int getMinimumWidth () {
+ return getMinimumSize().x;
+}
+/**
+ * @deprecated use setMinimumSize
+ */
+public void setMinimumWidth (int width) {
+ checkWidget ();
+ setMinimumSize (width, getMinimumSize().y);
+}
void setBounds (int x, int y, int width, int height) {
itemBounds.x = x;
itemBounds.y = y;
@@ -286,5 +387,30 @@
if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
setPreferredSize(size.x, size.y);
}
-
+/**
+ * Removes the listener from the collection of listeners that
+ * will be notified when the control is selected.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ *
+ * @since 2.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Header.java
index 32adb24..4e1b17b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Header.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Header.java
@@ -303,9 +303,7 @@
* Calculate and store the height of the receiver.
*/
void setHeaderHeight() {
- GC gc = new GC(this);
- int textHeight = gc.stringExtent("").y + VERTICAL_MARGIN;
- gc.dispose();
+ int textHeight = parent.getFontHeight() + VERTICAL_MARGIN;
int imageHeight = getImageExtent().y + VERTICAL_MARGIN;
Rectangle bounds = getBounds();
bounds.height = Math.max(textHeight,imageHeight);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
index 8e189f4..5d3ab8d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
@@ -30,6 +30,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -53,7 +55,8 @@
// by user defined columns
private TableColumn defaultColumn; // Default column that is created as soon as the table is created.
// Fix for 1FUSJY5
- private int dotsWidth = -1; // width of the static String dots (see above)
+ private int dotsWidth; // width of the static String dots (see above)
+ private int fontHeight; // font height, avoid use GC.stringExtend for each pain
/**
* Constructs a new instance of this class given its parent
@@ -84,7 +87,7 @@
* @see Widget#getStyle
*/
public Table(Composite parent, int style) {
- // use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw
+ // use NO_REDRAW_RESIZE to avoid flashing during widget resize redraw
super(parent, checkStyle(style| SWT.NO_REDRAW_RESIZE));
}
@@ -194,6 +197,7 @@
int columnIndex = column.getIndex();
if (widthChange != 0) {
+ getHeader().widthChange(columnIndex, widthChange);
if (columnIndex != TableColumn.FILL) {
if (getLinesVisible() == true) {
oldXPosition -= getGridLineWidth(); // include vertical grid line when scrolling resized column.
@@ -213,7 +217,6 @@
resizeRedraw(column, columnBounds.width, newBounds.width);
}
}
- getHeader().widthChange(columnIndex, widthChange);
}
/**
* The mouse pointer was double clicked on the receiver.
@@ -439,9 +442,10 @@
Vector items = getItemVector();
super.doDispose();
- while (items.size() > 0) { // TableItem objects are removed from vector during dispose()
- ((TableItem) items.lastElement()).dispose();
+ for (int i = items.size() - 1; i >= 0; i--) {
+ ((TableItem) items.elementAt(i)).dispose();
}
+ setItemVector(null);
items = getColumnVector();
while (items.size() > 0) { // TableColumn objects are removed from vector during dispose()
((TableColumn) items.lastElement()).dispose();
@@ -508,29 +512,7 @@
}
gc.setForeground(oldForeground);
}
-/**
- * Draw a filled rectangle indicating the selection state of 'item'
- * If 'item' is selected the rectangle will be filled with the
- * selection background color. Otherwise the rectangle will be filled
- * with the background color to remove selection.
- * The selection color depends on whether the table widget has
- * focus or not. See getSelectionBackgroundColor() for details.
- * The rectangle is drawn in either the first column or in all columns
- * for full row select.
- * @param item - item for which the selection state should be drawn
- * @param gc - GC to draw on.
- * @param position - position on the GC to draw at.
- * @param extent - extent of the selection rectangle.
- */
-void drawSelection(TableItem item, GC gc, Point position, Point extent) {
- if (item.isSelected() == true) {
- gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
- }
- gc.fillRectangle(position.x, position.y, extent.x, extent.y);
- if (item.isSelected() == true) {
- gc.setBackground(getBackground());
- }
-}
+
/**
* If the receiver has input focus draw a rectangle enclosing
* the label of 'item' to indicate the input focus.
@@ -705,9 +687,6 @@
* String
*/
int getDotsWidth(GC gc) {
- if (dotsWidth == -1) {
- dotsWidth = gc.stringExtent(DOT_STRING).x;
- }
return dotsWidth;
}
/**
@@ -1086,6 +1065,10 @@
return super.getSelectionCount();
}
+
+int getFontHeight(){
+ return fontHeight;
+}
/**
* Answer the size of the full row selection rectangle for 'item'.
*/
@@ -1354,6 +1337,11 @@
void initialize() {
columns = new Vector();
setItemVector(new Vector());
+ GC gc = new GC(this);
+ Point extent = gc.stringExtent(DOT_STRING);
+ dotsWidth = extent.x;
+ fontHeight = extent.y;
+ gc.dispose();
tableHeader = new Header(this);
tableHeader.setVisible(false); // SWT table header is invisible by default, too
fillColumn = TableColumn.createFillColumn(this);
@@ -1661,22 +1649,31 @@
TableItem paintItem;
TableItem focusItem = null;
Point selectionExtent;
- Point selectionPosition;
- int itemHeight = getItemHeight();
-
+ GC gc = event.gc;
+ Color selectionColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+ Point fullSelectionExtent;
+ int paintXPosition;
+ int paintYPosition;
+
topPaintIndex += getTopIndex();
bottomPaintIndex += getTopIndex();
for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
paintItem = (TableItem) getVisibleItem(i);
- selectionExtent = paintItem.getSelectionExtent();
- if (selectionExtent != null) {
- selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));
- drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);
- }
- columns = paintColumns.elements();
+ paintXPosition = paintItem.getSelectionX();
+ paintYPosition = getRedrawY(paintItem);
+ fullSelectionExtent = getFullSelectionExtent(paintItem);
+ gc.setBackground(paintItem.getBackground());
+ gc.fillRectangle(paintXPosition, paintYPosition, fullSelectionExtent.x, fullSelectionExtent.y);
+
+ if (paintItem.isSelected() == true) {
+ selectionExtent = paintItem.getSelectionExtent();
+ gc.setBackground(selectionColor);
+ gc.fillRectangle(paintXPosition, paintYPosition, selectionExtent.x, selectionExtent.y);
+ }
+ columns = paintColumns.elements();
while (columns.hasMoreElements() == true) {
column = (TableColumn) columns.nextElement();
- paintSubItem(event, paintItem, column, i * itemHeight);
+ paintSubItem(event, paintItem, column, paintYPosition);
}
if (hasFocus(paintItem)) {
focusItem = paintItem;
@@ -1697,6 +1694,7 @@
*/
void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {
Rectangle columnBounds = column.getBounds();
+ Point paintPosition;
int gridLineWidth = getGridLineWidth();
int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;
int clipX;
@@ -1705,9 +1703,10 @@
clipX = Math.max(columnBounds.x, event.x);
event.gc.setClipping( // clip the drawing area
clipX, event.y,
- itemDrawStopX - clipX, event.height);
+ Math.max(0, itemDrawStopX - clipX), event.height);
}
- column.paint(paintItem, event.gc, paintYPosition);
+ paintPosition = new Point(columnBounds.x, paintYPosition);
+ paintItem.paint(event.gc, paintPosition, column);
if (event.x + event.width > itemDrawStopX) {
event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle
}
@@ -1842,7 +1841,7 @@
setRedraw(false);
setRemovingAll(true);
- for (int i = 0; i < items.size(); i++) {
+ for (int i = items.size() - 1; i >= 0; i--) {
((TableItem) items.elementAt(i)).dispose();
}
setItemVector(new Vector());
@@ -1855,7 +1854,6 @@
* Remove 'column' from the receiver.
*/
void removeColumn(TableColumn column) {
- TableColumn lastColumn;
int index = column.getIndex();
int columnWidth = column.getWidth();
int columnCount;
@@ -1918,21 +1916,18 @@
* @param item - item that should be removed from the receiver
*/
void removeItem(TableItem item) {
+ if (isRemovingAll() == true) return;
+
Vector items = getItemVector();
int index = items.indexOf(item);
-
- if (index != -1) {
- if (isRemovingAll() == false) {
- removingItem(item);
- }
+ if (index != -1) {
+ removingItem(item);
items.removeElementAt(index);
for (int i = index; i < items.size(); i++) {
TableItem anItem = (TableItem) items.elementAt(i);
anItem.setIndex(anItem.getIndex() - 1);
}
- if (isRemovingAll() == false) {
- removedItem(item);
- }
+ removedItem(item);
}
}
/**
@@ -2193,7 +2188,6 @@
public void select(int start, int end) {
checkWidget();
SelectableItem item = null;
- int selectionCount = 1;
if (isMultiSelect() == false) {
if (start < 0 && end >= 0) {
@@ -2311,7 +2305,6 @@
}
public void setFont(Font font) {
checkWidget();
- SelectableItem item;
int itemCount = getItemCount();
if (font == null || font.equals(getFont()) == true) {
@@ -2320,6 +2313,13 @@
setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
resetItemData();
super.setFont(font);
+
+ GC gc = new GC(this);
+ Point extent = gc.stringExtent(DOT_STRING);
+ dotsWidth = extent.x;
+ fontHeight = extent.y;
+ gc.dispose();
+
for (int i = 0; i < itemCount; i++) {
itemChanged(getItem(i), 0, getClientArea().width);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
index 1363180..77baac3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
@@ -18,6 +18,8 @@
* <dd> Move, Resize, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -346,17 +348,7 @@
setWidth(parent.getPreferredColumnWidth(index));
}
}
-/**
- * Draw the 'item' at 'yPosition' in the receiver column.
- * @param item - TableItem that should be drawn.
- * @param gc - GC to draw on
- * @param yPosition - y position to draw at in the column.
- */
-void paint(TableItem item, GC gc, int yPosition) {
- Point paintPosition = new Point(bounds.x, bounds.y + yPosition);
- item.paint(gc, paintPosition, this);
-}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
index c2a8a89..033e1f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
@@ -41,6 +41,9 @@
// are indented. The multiplier is the image width.
private int index; // index of the item in the parent widget
+ Color background = null;
+ Color foreground = null;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>) and a style value
@@ -109,6 +112,7 @@
public TableItem(Table parent, int style, int index) {
super(parent, style);
parent.addItem(this, index);
+ trimmedLabels = new String[ parent.getColumnCount() ];
}
/**
@@ -175,6 +179,7 @@
Image image = getImage(index);
Rectangle sourceImageBounds;
Point destinationImageExtent = parent.getImageExtent();
+ int imageOffset;
if (image != null) {
sourceImageBounds = image.getBounds();
@@ -185,10 +190,11 @@
destinationPosition.x, destinationPosition.y,
destinationImageExtent.x, destinationImageExtent.y);
}
+ imageOffset = (parent.getItemHeight() - destinationImageExtent.y) / 2;
gc.drawImage(
image, 0, 0, // source x, y
sourceImageBounds.width, sourceImageBounds.height, // source width, height
- destinationPosition.x, destinationPosition.y, // destination x, y
+ destinationPosition.x, destinationPosition.y + imageOffset, // destination x, y
destinationImageExtent.x, destinationImageExtent.y); // destination width, height
}
if (((index == TableColumn.FIRST && // always add the image width for the first column
@@ -213,24 +219,18 @@
Table parent = getParent();
boolean drawSelection;
int textOffset;
- int textHeight;
if (label != null) {
drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
if (isSelected() == true && drawSelection == true) {
- gc.setBackground(getSelectionBackgroundColor());
gc.setForeground(getSelectionForegroundColor());
+ } else {
+ gc.setForeground(getForeground());
}
- textHeight = gc.stringExtent(label).y;
- textOffset = (parent.getItemHeight() - textHeight) / 2; // vertically center the text
- gc.drawString(label, position.x, position.y + textOffset);
- if (isSelected() == true && drawSelection == true) {
- gc.setBackground(parent.getBackground());
- gc.setForeground(parent.getForeground());
- }
+ textOffset = (parent.getItemHeight() - parent.getFontHeight()) / 2; // vertically center the text
+ gc.drawString(label, position.x, position.y + textOffset, true);
}
}
-
/**
* Returns the receiver's background color.
*
@@ -244,8 +244,9 @@
* @since 2.0
*
*/
-public Color getBackground () {
+public Color getBackground(){
checkWidget ();
+ if (background != null) return background;
Table parent = getParent();
return parent.getBackground();
}
@@ -296,6 +297,7 @@
}
return itemBounds;
}
+
/**
* Returns <code>true</code> if the receiver is checked,
* and false otherwise. When the parent does not have
@@ -374,8 +376,9 @@
* @since 2.0
*
*/
-public Color getForeground () {
+public Color getForeground(){
checkWidget ();
+ if (foreground != null) return foreground;
Table parent = getParent();
return parent.getForeground();
}
@@ -436,7 +439,6 @@
int itemIndex = parent.indexOf (this);
int imageWidth = 0;
Point imageExtent = parent.getImageExtent();
- Rectangle checkboxBounds;
Rectangle imageBounds = getBounds(index);
if (itemIndex == -1) {
@@ -746,6 +748,12 @@
imageData = new Image[images.size()];
images.copyInto(imageData);
setImage(imageData);
+
+ String[] tempTrimmed = new String[trimmedLabels.length + 1];
+ System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
+ System.arraycopy(trimmedLabels, index, tempTrimmed, index + 1, trimmedLabels.length - index);
+ trimmedLabels = tempTrimmed;
+
}
/**
* Sets the image at an index.
@@ -925,6 +933,16 @@
images.copyInto(imageData);
setImage(imageData);
}
+
+ if (trimmedLabels.length == 1) {
+ trimmedLabels = new String[0];
+ } else {
+ String[] tempTrimmed = new String[trimmedLabels.length - 1];
+ System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
+ System.arraycopy(trimmedLabels, index +1, tempTrimmed, index, trimmedLabels.length - index -1);
+ trimmedLabels = tempTrimmed;
+ }
+
}
/**
* Reset the cached trimmed label for the sub item identified by
@@ -941,6 +959,62 @@
selectionExtent = null;
}
}
+
+void redraw(){
+ Table parent = getParent();
+ int y = parent.getRedrawY(this);
+ parent.redraw(0, y, parent.getClientArea().width, parent.getItemHeight(), false);
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ background = color;
+ redraw();
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ foreground = color;
+ redraw();
+}
/**
* Sets the image for multiple columns in the Table.
*
@@ -1092,29 +1166,6 @@
}
}
/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-/**
* Sets the checked state of the receiver.
*
* @param checked the new checked state
@@ -1129,29 +1180,6 @@
super.setChecked(checked);
}
/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-/**
* Sets the grayed state of the receiver.
*
* @param checked the new grayed state
@@ -1172,4 +1200,4 @@
index = newIndex;
}
-}
\ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
index 4ba5a67..dd98a0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
@@ -32,6 +32,8 @@
* <dd>Selection, DefaultSelection, Collapse, Expand</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
index 07c3deb..b6655d4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
@@ -90,7 +90,9 @@
//Determine whether the item is being expanded
private boolean isExpanding = false;
-
+ Color background = null;
+ Color foreground = null;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>)
@@ -369,29 +371,6 @@
return destinationPosition;
}
/**
- * Draw a filled rectangle indicating the item selection state
- * The rectangle will be filled with the selection color if the
- * receiver is selected. Otherwise the rectangle will be filled
- * in the background color to remove the selection.
- * @param gc - GC to draw on.
- * @param position - position on the GC to draw at.
- */
-void drawSelection(GC gc, Point position) {
- Tree parent = getParent();
- Point selectionExtent = getSelectionExtent();
-
- if (selectionExtent == null) {
- return;
- }
- if (isSelected() == true) {
- gc.setBackground(getSelectionBackgroundColor());
- }
- gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);
- if (isSelected() == true) {
- gc.setBackground(parent.getBackground());
- }
-}
-/**
* Draw a rectangle enclosing the item label. The rectangle
* indicates that the receiver was selected last and that it has
* the input focus.
@@ -411,27 +390,6 @@
selectionExtent.x, selectionExtent.y);
}
}
-/**
- * Draw the item label at 'position' using 'gc'.
- * @param gc - GC to draw on.
- * @param position - position on the GC to draw at.
- */
-void drawText(GC gc, Point position) {
- Tree parent = getParent();
- String text = getText();
-
- if (text != null) {
- if (isSelected() == true) {
- gc.setBackground(getSelectionBackgroundColor());
- gc.setForeground(getSelectionForegroundColor());
- }
- gc.drawString(text, position.x, position.y);
- if (isSelected() == true) {
- gc.setBackground(parent.getBackground());
- gc.setForeground(parent.getForeground());
- }
- }
-}
/**
* Draw a vertical line connecting the horizontal connector line
* with that of the previous item.
@@ -512,7 +470,6 @@
}
return position;
}
-
/**
* Returns the receiver's background color.
*
@@ -528,10 +485,10 @@
*/
public Color getBackground () {
checkWidget ();
+ if (background != null) return background;
Tree parent = getParent();
return parent.getBackground();
}
-
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -586,6 +543,7 @@
*/
public Color getForeground () {
checkWidget ();
+ if (foreground != null) return foreground;
Tree parent = getParent();
return parent.getForeground();
}
@@ -1057,12 +1015,13 @@
* @param yPosition - y coordinate where the receiver should draw at.
*/
void paint(GC gc, int yPosition) {
- Tree parent = getParent();
- Point paintPosition = new Point(getPaintStartX(), yPosition);
-
if (isVisible() == false) {
return;
}
+
+ Tree parent = getParent();
+ Point paintPosition = new Point(getPaintStartX(), yPosition);
+ Point extent = getSelectionExtent();
gc.setForeground(parent.CONNECTOR_LINE_COLOR);
paintPosition = drawVerticalItemConnector(gc, paintPosition);
paintPosition = drawHierarchyIndicator(gc, paintPosition);
@@ -1073,13 +1032,31 @@
paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));
}
paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));
- drawSelection(gc, paintPosition);
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
+ } else {
+ gc.setBackground(getBackground());
+ gc.setForeground(getForeground());
+ if(getBackground() != parent.getBackground()){
+ gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
+ }
+ }
+ if (text != null) {
+ gc.drawString(text, getTextXPos(), paintPosition.y + getTextYPosition(gc), true);
+ }
if (this == parent.getInsertItem()) {
drawInsertMark(gc, paintPosition);
}
- drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));
drawSelectionFocus(gc, paintPosition);
}
+
+void redraw(){
+ Rectangle bounds = getBounds();
+ getParent().redraw(bounds.x, bounds.y, bounds.width, bounds.height, false);
+}
+
/**
* Update the display to reflect the expanded state of the
* receiver.
@@ -1312,6 +1289,8 @@
checkWidget ();
if (color != null && color.isDisposed ())
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ background = color;
+ redraw();
}
/**
* Sets the checked state of the receiver.
@@ -1355,6 +1334,8 @@
checkWidget ();
if (color != null && color.isDisposed ())
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ foreground = color;
+ redraw();
}
/**
* Sets the grayed state of the receiver.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
index b389d1a..cf768bd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
@@ -30,6 +30,9 @@
* CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
* </dd>
* </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
index ab85955..9f41408 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
@@ -167,7 +167,7 @@
if (object == this) return true;
if (!(object instanceof FontData)) return false;
FontData data = (FontData)object;
- return name == name && height == data.height && style == data.style;
+ return name.equals(data.name) && height == data.height && style == data.style;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 8f8e453..5905efd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -129,18 +129,34 @@
OS.gdk_gc_set_exposures(handle, false);
if (data.image != null) return;
boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
+ GdkRectangle rect = new GdkRectangle ();
if (disjoint) {
- OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
+ rect.x = srcX;
+ rect.y = srcY;
+ rect.width = width;
+ rect.height = height;
+ OS.gdk_window_invalidate_rect (drawable, rect, false);
+// OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
} else {
if (deltaX != 0) {
int newX = destX - deltaX;
if (deltaX < 0) newX = destX + width;
- OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
+ rect.x = newX;
+ rect.y = srcY;
+ rect.width = Math.abs(deltaX);
+ rect.height = height;
+ OS.gdk_window_invalidate_rect (drawable, rect, false);
+// OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
}
if (deltaY != 0) {
int newY = destY - deltaY;
if (deltaY < 0) newY = destY + height;
- OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
+ rect.x = srcX;
+ rect.y = newY;
+ rect.width = width;
+ rect.height = Math.abs(deltaY);
+ OS.gdk_window_invalidate_rect (drawable, rect, false);
+// OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
}
}
}
@@ -291,8 +307,9 @@
* different sized) rectangular area in the receiver. If the source
* and destination areas are of differing sizes, then the source
* area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any of the given coordinates
- * are negative or lie outside the bounds of their respective images.
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
*
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
@@ -307,7 +324,8 @@
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of their respective images</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 59b0565..544a1b5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -247,6 +247,16 @@
/* Apply transformation */
switch (flag) {
case SWT.IMAGE_DISABLE: {
+ Color zeroColor = device.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ RGB zeroRGB = zeroColor.getRGB();
+ byte zeroRed = (byte)zeroRGB.red;
+ byte zeroGreen = (byte)zeroRGB.green;
+ byte zeroBlue = (byte)zeroRGB.blue;
+ Color oneColor = device.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ RGB oneRGB = oneColor.getRGB();
+ byte oneRed = (byte)oneRGB.red;
+ byte oneGreen = (byte)oneRGB.green;
+ byte oneBlue = (byte)oneRGB.blue;
byte[] line = new byte[stride];
for (int y=0; y<height; y++) {
OS.memmove(line, pixels + (y * stride), stride);
@@ -256,8 +266,15 @@
int green = line[offset+1] & 0xFF;
int blue = line[offset+2] & 0xFF;
int intensity = red * red + green * green + blue * blue;
- byte value = (intensity < 9000) ? (byte)0 : (byte) 255;
- line[offset] = line[offset+1] = line[offset+2] = value;
+ if (intensity < 98304) {
+ line[offset] = zeroRed;
+ line[offset+1] = zeroGreen;
+ line[offset+2] = zeroBlue;
+ } else {
+ line[offset] = oneRed;
+ line[offset+1] = oneGreen;
+ line[offset+2] = oneBlue;
+ }
}
OS.memmove(pixels + (y * stride), line, stride);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 31bf01d..1e332cd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -22,11 +22,15 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
*/
public class Button extends Control {
+ int boxHandle, labelHandle, pixmapHandle, arrowHandle;
Image image;
String text;
@@ -108,6 +112,19 @@
addListener (SWT.DefaultSelection,typedListener);
}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ OS.gtk_widget_set_size_request (handle, wHint, hHint);
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (handle, requisition);
+ OS.gtk_widget_set_size_request (handle, width, height);
+ width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+ height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+ return new Point (width, height);
+}
+
void createHandle (int index) {
state |= HANDLE;
int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH;
@@ -116,49 +133,77 @@
OS.gtk_fixed_set_has_window (fixedHandle, true);
switch (style & bits) {
case SWT.ARROW:
+ int alignment = OS.GTK_ARROW_UP;
+ if ((style & SWT.UP) != 0) alignment = OS.GTK_ARROW_UP;
+ if ((style & SWT.DOWN) != 0) alignment = OS.GTK_ARROW_DOWN;
+ if ((style & SWT.LEFT) != 0) alignment = OS.GTK_ARROW_LEFT;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.GTK_ARROW_RIGHT;
handle = OS.gtk_button_new ();
- int arrow = OS.gtk_arrow_new (OS.GTK_ARROW_UP, OS.GTK_SHADOW_OUT);
- OS.gtk_container_add (handle, arrow);
- OS.gtk_widget_show (arrow);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ arrowHandle = OS.gtk_arrow_new (alignment, OS.GTK_SHADOW_OUT);
+ if (arrowHandle == 0) error (SWT.ERROR_NO_HANDLES);
break;
case SWT.TOGGLE:
handle = OS.gtk_toggle_button_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
break;
case SWT.CHECK:
handle = OS.gtk_check_button_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
break;
case SWT.RADIO:
handle = OS.gtk_radio_button_new (parent.radioGroup());
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
break;
case SWT.PUSH:
default:
handle = OS.gtk_button_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_DEFAULT);
break;
}
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.ARROW) != 0) {
+ OS.gtk_container_add (handle, arrowHandle);
+ OS.gtk_widget_show (arrowHandle);
+ } else {
+ boxHandle = OS.gtk_hbox_new (false, 0);
+ if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ labelHandle = OS.gtk_label_new_with_mnemonic (null);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), 1, 1, -1);
+ if (pixmap == 0) error (SWT.ERROR_NO_HANDLES);
+ pixmapHandle = OS.gtk_pixmap_new (pixmap, 0);
+ OS.g_object_unref (pixmap);
+ if (pixmapHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (handle, boxHandle);
+ OS.gtk_container_add (boxHandle, labelHandle);
+ OS.gtk_container_add (boxHandle, pixmapHandle);
+ OS.gtk_widget_show (boxHandle);
+ }
int parentHandle = parent.parentingHandle ();
OS.gtk_container_add (parentHandle, fixedHandle);
OS.gtk_container_add (fixedHandle, handle);
OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (handle);
-}
-
-void hookEvents () {
- //TEMPORARY CODE
- super.hookEvents();
- /*
- * Feature in GTK. For some reason, when the widget
- * is a check or radio button, mouse move and key
- * release events are not signaled. The fix is to
- * look for them on the parent.
- */
-// if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
-// int mask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_KEY_RELEASE_MASK;
-// OS.gtk_widget_add_events (boxHandle, mask);
-// signal_connect_after (boxHandle, "motion_notify_event", SWT.MouseMove, 3);
-// signal_connect_after (boxHandle, "key_release_event", SWT.KeyUp, 3);
-// }
- signal_connect (handle, "clicked", SWT.Selection, 2);
+
+ if ((style & SWT.LEFT) != 0) {
+ OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_LEFT);
+ OS.gtk_misc_set_alignment (pixmapHandle, 0.0f, 0.5f);
+ return;
+ }
+ if ((style & SWT.CENTER) != 0) {
+ OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER);
+ OS.gtk_misc_set_alignment (pixmapHandle, 0.5f, 0.5f);
+ return;
+ }
+ if ((style & SWT.RIGHT) != 0) {
+ OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_RIGHT);
+ OS.gtk_misc_set_alignment (pixmapHandle, 1.0f, 0.5f);
+ return;
+ }
}
void createWidget (int index) {
@@ -166,13 +211,16 @@
text = "";
}
+void deregister () {
+ super.deregister ();
+ if (boxHandle != 0) WidgetTable.remove (boxHandle);
+ if (labelHandle != 0) WidgetTable.remove (labelHandle);
+ if (pixmapHandle != 0) WidgetTable.remove (pixmapHandle);
+ if (arrowHandle != 0) WidgetTable.remove (arrowHandle);
+}
+
int fontHandle () {
- //FIX ME - font lost when no text
- int list = OS.gtk_container_children (handle);
- if (list != 0) {
- int widget = OS.g_list_nth_data (list, 0);
- if (widget != 0) return widget;
- }
+ if (labelHandle != 0) return labelHandle;
return super.fontHandle ();
}
@@ -250,6 +298,51 @@
}
/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+ checkWidget();
+ return text;
+}
+
+void hookEvents () {
+ super.hookEvents();
+ signal_connect (handle, "clicked", SWT.Selection, 2);
+}
+
+int processSelection (int int0, int int1, int int2) {
+ postEvent(SWT.Selection);
+ return 0;
+}
+
+void register () {
+ super.register ();
+ if (boxHandle != 0) WidgetTable.put (boxHandle, this);
+ if (labelHandle != 0) WidgetTable.put (labelHandle, this);
+ if (pixmapHandle != 0) WidgetTable.put (pixmapHandle, this);
+ if (arrowHandle != 0) WidgetTable.put (arrowHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ boxHandle = pixmapHandle = labelHandle = arrowHandle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+ text = null;
+}
+
+/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
*
@@ -298,48 +391,55 @@
style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
int arrow_type = OS.GTK_ARROW_UP;
switch (alignment) {
- case SWT.UP:
- arrow_type = OS.GTK_ARROW_UP;
- break;
- case SWT.DOWN:
- arrow_type = OS.GTK_ARROW_DOWN;
- break;
- case SWT.LEFT:
- arrow_type = OS.GTK_ARROW_LEFT;
- break;
- case SWT.RIGHT:
- arrow_type = OS.GTK_ARROW_RIGHT;
- break;
+ case SWT.UP: arrow_type = OS.GTK_ARROW_UP; break;
+ case SWT.DOWN: arrow_type = OS.GTK_ARROW_DOWN; break;
+ case SWT.LEFT: arrow_type = OS.GTK_ARROW_LEFT; break;
+ case SWT.RIGHT: arrow_type = OS.GTK_ARROW_RIGHT; break;
}
- int list = OS.gtk_container_children (handle);
- int arrow = OS.g_list_nth_data (list, 0);
- OS.gtk_arrow_set (arrow, arrow_type, OS.GTK_SHADOW_OUT);
+ OS.gtk_arrow_set (arrowHandle, arrow_type, OS.GTK_SHADOW_OUT);
return;
}
if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- int list = OS.gtk_container_children (handle);
- int label = OS.g_list_nth_data (list, 0);
- if (label == 0) return;
- boolean isText = OS.GTK_WIDGET_TYPE (handle) == OS.gtk_label_get_type ();
if ((style & SWT.LEFT) != 0) {
- OS.gtk_misc_set_alignment (label, 0.0f, 0.5f);
- if (isText) OS.gtk_label_set_justify (label, OS.GTK_JUSTIFY_LEFT);
+ OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_LEFT);
+ OS.gtk_misc_set_alignment (pixmapHandle, 0.0f, 0.5f);
return;
}
if ((style & SWT.CENTER) != 0) {
- OS.gtk_misc_set_alignment (label, 0.5f, 0.5f);
- if (isText) OS.gtk_label_set_justify (label, OS.GTK_JUSTIFY_CENTER);
+ OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER);
+ OS.gtk_misc_set_alignment (pixmapHandle, 0.5f, 0.5f);
return;
}
if ((style & SWT.RIGHT) != 0) {
- OS.gtk_misc_set_alignment (label, 1.0f, 0.5f);
- if (isText) OS.gtk_label_set_justify (label, OS.GTK_JUSTIFY_RIGHT);
+ OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.5f);
+ OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_RIGHT);
+ OS.gtk_misc_set_alignment (pixmapHandle, 1.0f, 0.5f);
return;
}
}
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ OS.gtk_widget_modify_bg (labelHandle, 0, color);
+ OS.gtk_widget_modify_bg (pixmapHandle, 0, color);
+}
+
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ OS.gtk_widget_modify_font (labelHandle, font);
+ OS.gtk_widget_modify_font (pixmapHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ OS.gtk_widget_modify_fg (labelHandle, 0, color);
+ OS.gtk_widget_modify_fg (pixmapHandle, 0, color);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -358,35 +458,21 @@
checkWidget ();
this.image = image;
if ((style & SWT.ARROW) != 0) return;
- int list = OS.gtk_container_children (handle);
- if (list != 0) {
- int widget = OS.g_list_nth_data (list, 0);
- if (widget != 0) OS.gtk_widget_destroy (widget);
- }
+ OS.gtk_widget_hide (labelHandle);
if (image != null) {
- int pixmap = OS.gtk_pixmap_new (image.pixmap, image.mask);
- OS.gtk_container_add (handle, pixmap);
- OS.gtk_widget_show (pixmap);
+ OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+ OS.gtk_widget_show (pixmapHandle);
+ } else {
+// int pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), 1, 1, -1);
+// if (pixmap == 0) error (SWT.ERROR_NO_HANDLES);
+// OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+// OS.g_object_unref (pixmap);
+ //??? REF
+ OS.gtk_widget_hide (pixmapHandle);
}
}
/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- return text;
-}
-
-/**
* Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
* <code>RADIO</code>, or <code>TOGGLE</code>.
*
@@ -438,25 +524,10 @@
for (int i=0; i<length; i++) {
if (text [i] == '&') text [i] = '_';
}
- int list = OS.gtk_container_children (handle);
- if (list != 0) {
- int widget = OS.g_list_nth_data (list, 0);
- if (widget != 0) OS.gtk_widget_destroy (widget);
- }
byte [] buffer = Converter.wcsToMbcs (null, text);
- int label = OS.gtk_label_new_with_mnemonic (buffer);
- OS.gtk_container_add (handle, label);
- OS.gtk_widget_show (label);
+ OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+ OS.gtk_widget_hide (pixmapHandle);
+ OS.gtk_widget_show (labelHandle);
}
-int processSelection (int int0, int int1, int int2) {
- postEvent(SWT.Selection);
- return 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
- text = null;
-}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index e164015..3d1d058 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -88,6 +88,42 @@
return caret;
}
+int processFocusIn (int int0, int int1, int int2) {
+ int result = super.processFocusIn (int0, int1, int2);
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+
+int processFocusOut(int int0, int int1, int int2) {
+ int result = super.processFocusOut (int0, int1, int2);
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int processPaint (int callData, int int1, int int2) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.processPaint (callData, int1, int2);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redrawWidget (x, y, width, height, all);
+ if (isFocus) caret.setFocus ();
+}
+
+void releaseWidget () {
+ if (caret != null) {
+ caret.releaseWidget ();
+ caret.releaseHandle ();
+ }
+ caret = null;
+ super.releaseWidget();
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
@@ -112,54 +148,82 @@
*/
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
checkWidget();
-
if (width <= 0 || height <= 0) return;
int deltaX = destX - x, deltaY = destY - y;
if (deltaX == 0 && deltaY == 0) return;
if (!isVisible ()) return;
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
- /* Hide the caret */
- boolean isVisible = (caret != null) && (caret.isVisible ());
- if (isVisible) caret.hideCaret ();
+// update ();
+// GC gc = new GC (this);
+// gc.copyArea (x, y, width, height, destX, destY);
+// gc.dispose ();
+
+ update ();
- int window = OS.GTK_WIDGET_WINDOW(paintHandle());
-
- /* Emit a NoExpose Event */
- int gc = OS.gdk_gc_new (window);
- OS.gdk_gc_set_exposures(gc, true);
- OS.gdk_window_copy_area (window, gc, x, y, window, x, y, width, height);
- OS.g_object_unref (gc);
-
- /* Flush outstanding Exposes */
- int eventHandle=0;
- while ((eventHandle = OS.gdk_event_get_graphics_expose(window)) != 0) {
- OS.gtk_widget_event(handle, eventHandle);
- OS.gdk_event_free(eventHandle);
- }
-
- /* Scroll the window */
- int gc1 = OS.gdk_gc_new (window);
- OS.gdk_gc_set_exposures(gc1, true);
- OS.gdk_window_copy_area (window, gc1, destX, destY, window, x, y, width, height);
- OS.g_object_unref (gc1);
+ int window = paintWindow ();
+ int visibleRegion = OS.gdk_drawable_get_visible_region (window);
+ GdkRectangle srcRect = new GdkRectangle ();
+ srcRect.x = x;
+ srcRect.y = y;
+ srcRect.width = width;
+ srcRect.height = height;
+ int copyRegion = OS.gdk_region_new ();
+ OS.gdk_region_union_with_rect (copyRegion, srcRect);
+ OS.gdk_region_intersect(copyRegion, visibleRegion);
+ int invalidateRegion = OS.gdk_region_new ();
+ OS.gdk_region_union_with_rect (invalidateRegion, srcRect);
+ OS.gdk_region_subtract (invalidateRegion, visibleRegion);
+ OS.gdk_region_offset (invalidateRegion, deltaX, deltaY);
+ GdkRectangle copyRect = new GdkRectangle();
+ OS.gdk_region_get_clipbox (copyRegion, copyRect);
+ int gdkGC = OS.gdk_gc_new (window);
+ OS.gdk_gc_set_exposures (gdkGC, true);
+ OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height);
+ OS.g_object_unref (gdkGC);
boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
+ GdkRectangle rect = new GdkRectangle ();
if (disjoint) {
- OS.gdk_window_clear_area(window, x, y, width, height);
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ OS.gdk_region_union_with_rect (invalidateRegion, rect);
} else {
if (deltaX != 0) {
int newX = destX - deltaX;
if (deltaX < 0) newX = destX + width;
- OS.gdk_window_clear_area_e(window, newX, y, Math.abs (deltaX), height);
+ rect.x = newX;
+ rect.y = y;
+ rect.width = Math.abs(deltaX);
+ rect.height = height;
+ OS.gdk_region_union_with_rect (invalidateRegion, rect);
}
if (deltaY != 0) {
int newY = destY - deltaY;
if (deltaY < 0) newY = destY + height;
- OS.gdk_window_clear_area_e (window, x, newY, width, Math.abs (deltaY));
+ rect.x = x;
+ rect.y = newY;
+ rect.width = width;
+ rect.height = Math.abs(deltaY);
+ OS.gdk_region_union_with_rect (invalidateRegion, rect);
}
- }
+ }
+ OS.gdk_window_invalidate_region(window, invalidateRegion, all);
+ OS.gdk_region_destroy (visibleRegion);
+ OS.gdk_region_destroy (copyRegion);
+ OS.gdk_region_destroy (invalidateRegion);
- /* Show the caret */
- if (isVisible) caret.showCaret ();
+ if (isFocus) caret.setFocus ();
+}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (isFocus) caret.setFocus ();
+ return changed;
}
/**
@@ -183,40 +247,23 @@
* </ul>
*/
public void setCaret (Caret caret) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
Caret newCaret = caret;
Caret oldCaret = this.caret;
this.caret = newCaret;
- if (isFocusControl()) {
+ if (hasFocus ()) {
if (oldCaret != null) oldCaret.killFocus ();
- if (newCaret != null) newCaret.setFocus ();
+ if (newCaret != null) {
+ if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ newCaret.setFocus ();
+ }
}
}
public boolean setFocus () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if ((style & SWT.NO_FOCUS) != 0) return false;
return super.setFocus ();
}
-int processFocusIn (int int0, int int1, int int2) {
- int result = super.processFocusIn (int0, int1, int2);
- if (caret != null) caret.setFocus ();
- return result;
-}
-
-int processFocusOut(int int0, int int1, int int2) {
- int result = super.processFocusOut (int0, int1, int2);
- if (caret != null) caret.killFocus ();
- return result;
-}
-
-void releaseWidget () {
- if (caret != null) caret.releaseWidget ();
- caret = null;
- super.releaseWidget ();
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index fc1b33b..e53339d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
@@ -28,8 +28,7 @@
public class Caret extends Widget {
Canvas parent;
int x, y, width, height;
- boolean moved, resized;
- boolean isVisible,isShowing;
+ boolean isVisible, isShowing;
int blinkRate = 500;
Image image;
@@ -84,25 +83,20 @@
boolean drawCaret () {
if (parent == null) return false;
- if (parent.isDisposed ()) return false;
-
- int window = OS.GTK_WIDGET_WINDOW (parent.handle);
+ if (parent.isDisposed ()) return false;
+ int window = parent.paintWindow ();
int gc = OS.gdk_gc_new (window);
-
- /* Actually, we should look at the background and foreground colors.
- * This would require distinguishing between the cases when the GC
- * gives the color as RGB or Pixel, and in the case of Pixel, we
- * would need to distinguish between direct and indexed color.
- * In general, it's not easy to find out the RGB value of a GdkColor
- * (somebody please correct me if I am wrong).
- */
- GdkColor c = new GdkColor ();
- c.red = c.green = c.blue = (short) 0xFFFF;
- OS.gdk_color_alloc (OS.gdk_colormap_get_system (), c);
- OS.gdk_gc_set_foreground (gc, c);
+ int fontHandle = parent.fontHandle ();
+ int hStyle = OS.gtk_widget_get_style (fontHandle);
+ GtkStyle style = new GtkStyle (hStyle);
+ GdkColor color = new GdkColor ();
+ color.red = (short) (style.fg0_red ^ style.bg0_red);
+ color.green = (short) (style.fg0_green ^ style.bg0_green);
+ color.blue = (short) (style.fg0_blue ^ style.bg0_blue);
+ int colormap = OS.gdk_colormap_get_system ();
+ OS.gdk_colormap_alloc_color (colormap, color, true, true);
+ OS.gdk_gc_set_foreground (gc, color);
OS.gdk_gc_set_function (gc, OS.GDK_XOR);
-
- /* Draw the caret */
int nWidth = width, nHeight = height;
if (image != null) {
Rectangle rect = image.getBounds ();
@@ -112,6 +106,7 @@
if (nWidth <= 0) nWidth = 2;
OS.gdk_draw_rectangle (window, gc, 1, x, y, nWidth, nHeight);
OS.g_object_unref (gc);
+ OS.gdk_colormap_free_colors (colormap, color, 1);
return true;
}
@@ -244,8 +239,6 @@
}
boolean hideCaret () {
- Display display = getDisplay ();
- if (display.currentCaret != this) return false;
if (!isShowing) return true;
isShowing = false;
return drawCaret ();
@@ -270,14 +263,19 @@
*/
public boolean isVisible () {
checkWidget();
- return isVisible && parent.isVisible () && parent.isFocusControl ();
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+boolean isFocusCaret () {
+ Display display = getDisplay ();
+ return this == display.currentCaret;
}
void killFocus () {
Display display = getDisplay ();
if (display.currentCaret != this) return;
- if (isVisible) hideCaret ();
display.setCurrentCaret (null);
+ if (isVisible) hideCaret ();
}
void releaseChild () {
@@ -289,7 +287,7 @@
super.releaseWidget ();
Display display = getDisplay ();
if (display.currentCaret == this) {
- if (isVisible) hideCaret ();
+ if (isShowing) hideCaret ();
display.setCurrentCaret (null);
}
parent = null;
@@ -314,26 +312,13 @@
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
- boolean samePosition, sameExtent, showing;
- samePosition = (this.x == x) && (this.y == y);
- sameExtent = (this.width == width) && (this.height == height);
- if ((samePosition) && (sameExtent)) return;
- if (isShowing) hideCaret ();
+ if (this.x == x && this.y == y && this.width == width && this.height == height) return;
+ boolean showing = isShowing;
+ boolean isFocus = isFocusCaret ();
+ if (isFocus && showing) hideCaret ();
this.x = x; this.y = y;
this.width = width; this.height = height;
- if (sameExtent) {
- moved = true;
- if (isVisible ()) {
- moved = false;
- }
- } else {
- resized = true;
- if (isVisible ()) {
- moved = false;
- resized = false;
- }
- }
- if (isShowing) showCaret ();
+ if (isFocus && showing) showCaret ();
}
/**
@@ -404,9 +389,11 @@
if (image != null && image.isDisposed ()) {
error (SWT.ERROR_INVALID_ARGUMENT);
}
- if (isShowing) hideCaret ();
+ boolean showing = isShowing;
+ boolean isFocus = isFocusCaret ();
+ if (isFocus && showing) hideCaret ();
this.image = image;
- if (isShowing) showCaret ();
+ if (isFocus && showing) showCaret ();
}
/**
@@ -500,7 +487,9 @@
public void setVisible (boolean visible) {
checkWidget();
if (visible == isVisible) return;
- if (isVisible = visible) {
+ isVisible = visible;
+ if (!isFocusCaret ()) return;
+ if (isVisible) {
showCaret ();
} else {
hideCaret ();
@@ -508,7 +497,6 @@
}
boolean showCaret () {
- if (getDisplay ().currentCaret != this) return false;
if (isShowing) return true;
isShowing = true;
return drawCaret ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
index 8a6baad..aa5fac8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
@@ -117,10 +117,12 @@
* </ul>
*/
public RGB open () {
- int handle;
- byte [] titleBytes;
- titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_color_selection_dialog_new (titleBytes);
+ byte [] buffer = Converter.wcsToMbcs (null, title, true);
+ int handle = OS.gtk_color_selection_dialog_new (buffer);
+ if (parent!=null) {
+ OS.gtk_window_set_modal(handle, true);
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
OS.gtk_widget_hide (OS.GTK_COLOR_SELECTION_OK_BUTTON(handle));
if (rgb != null) {
double [] color = new double [4];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 186892a..e0724d5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -39,6 +39,9 @@
* <dd>DefaultSelection, Modify, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
@@ -299,6 +302,7 @@
// TO DO - fix multiple selection events for one user action
signal_connect (listHandle, "select_child", SWT.Selection, 3);
signal_connect_after (entryHandle, "changed", SWT.Modify, 2);
+ signal_connect (entryHandle, "activate", SWT.DefaultSelection, 2);
int mask =
OS.GDK_POINTER_MOTION_MASK |
OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
@@ -307,15 +311,17 @@
int [] handles = new int [] {entryHandle, listHandle, /*combo.button*/};
for (int i=0; i<handles.length; i++) {
int handle = handles [i];
- if (!OS.GTK_WIDGET_NO_WINDOW (handle)) {
- OS.gtk_widget_add_events (handle, mask);
- }
- signal_connect_after (handle, "event", SWT.MouseDown, 3);
- signal_connect_after (handle, "motion_notify_event", SWT.MouseMove, 3);
-// signal_connect_after (handle, "button_press_event", SWT.MouseDown, 3);
-// signal_connect_after (handle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (handle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (handle, "key_release_event", SWT.KeyUp, 3);
+ OS.gtk_widget_add_events (handle, mask);
+ signal_connect (handle, "button_press_event", SWT.MouseDown, 3);
+ signal_connect (handle, "button_release_event", SWT.MouseUp, 3);
+ signal_connect (handle, "key_press_event", SWT.KeyDown, 3);
+ signal_connect (handle, "key_release_event", SWT.KeyUp, 3);
+ signal_connect (handle, "motion_notify_event", SWT.MouseMove, 3);
+ signal_connect_after (handle, "button_press_event", -SWT.MouseDown, 3);
+ signal_connect_after (handle, "button_release_event", -SWT.MouseUp, 3);
+ signal_connect_after (handle, "key_press_event", -SWT.KeyDown, 3);
+ signal_connect_after (handle, "key_release_event", -SWT.KeyUp, 3);
+ signal_connect_after (handle, "motion_notify_event", -SWT.MouseMove, 3);
}
}
@@ -627,6 +633,11 @@
return fixedHandle;
}
+int processDefaultSelection (int int0, int int1, int int2) {
+ postEvent (SWT.DefaultSelection);
+ return 0;
+}
+
int processModify (int arg0, int arg1, int int2) {
sendEvent (SWT.Modify);
return 0;
@@ -833,12 +844,30 @@
OS.gtk_signal_handler_unblock_by_data (listHandle, SWT.Selection);
}
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
+ if (listHandle != 0) OS.gtk_widget_modify_base (listHandle, 0, color);
+}
+
boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
checkWidget();
int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
return super.setBounds (x, y, width, newHeight, move, resize);
}
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
+ if (listHandle != 0) OS.gtk_widget_modify_font (listHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ if (entryHandle != 0) OS.gtk_widget_modify_text (entryHandle, 0, color);
+ if (listHandle != 0) OS.gtk_widget_modify_text (listHandle, 0, color);
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -940,9 +969,9 @@
*/
public void setSelection (Point selection) {
checkWidget();
- /*if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.gtk_editable_set_position (entryHandle, selection.x);
- OS.gtk_editable_select_region (entryHandle, selection.x, selection.y);*/
+ OS.gtk_editable_select_region (entryHandle, selection.x, selection.y);
}
/**
@@ -968,13 +997,13 @@
*/
public void setText (String string) {
checkWidget();
- /*if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.gtk_editable_delete_text (entryHandle, 0, -1);
int [] position = new int [1];
byte [] buffer = Converter.wcsToMbcs (null, string);
OS.gtk_editable_insert_text (entryHandle, buffer, buffer.length, position);
- OS.gtk_editable_set_position (entryHandle, 0);*/
+ OS.gtk_editable_set_position (entryHandle, 0);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index cd7385c..986ceef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -30,6 +30,7 @@
public class Composite extends Scrollable {
int radioHandle;
Layout layout;
+ Control[] tabList;
Composite () {
/* Do nothing */
@@ -67,6 +68,91 @@
super (parent, style);
}
+Control [] _getChildren () {
+ int parentHandle = parentingHandle ();
+ int list = OS.gtk_container_get_children (parentHandle);
+ if (list == 0) return new Control [0];
+ int count = OS.g_list_length (list);
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ while (i < count) {
+ int handle = OS.g_list_nth_data (list, i);
+ if (handle != 0) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [j++] = (Control) widget;
+ }
+ }
+ }
+ i++;
+ }
+ OS.g_list_free (list);
+ if (i == j) return children;
+ Control [] newChildren = new Control [j];
+ System.arraycopy (children, 0, newChildren, 0, j);
+ return newChildren;
+}
+
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ Point size;
+ if (layout != null) {
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = new Point (wHint, hHint);
+ }
+ } else {
+ size = minimumSize ();
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ return new Point (trim.width, trim.height);
+}
+
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? _getTabList () : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
void createHandle (int index) {
state |= HANDLE | CANVAS;
createScrolledHandle (parent.parentingHandle ());
@@ -94,14 +180,11 @@
if (isScrolled) {
OS.gtk_container_add (parentHandle, fixedHandle);
OS.gtk_container_add (fixedHandle, scrolledHandle);
-
-// /*
-// * Force the scrolledWindow to have a single child that is
-// * not scrolled automatically. Calling gtk_container_add
-// * seems to add the child correctly but cause a warning.
-// */
-// OS.GTK_BIN_SET_CHILD(scrolledHandle, handle);
-// OS.gtk_widget_set_parent(handle, scrolledHandle);
+ /*
+ * Force the scrolledWindow to have a single child that is
+ * not scrolled automatically. Calling gtk_container_add
+ * seems to add the child correctly but cause a warning.
+ */
Display display = getDisplay ();
boolean warnings = display.getWarnings ();
display.setWarnings (false);
@@ -113,7 +196,7 @@
int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
- //CHECK WITH IS THERE ALREADY THEN DON'T SET
+ //CHECK WIDTH IS THERE ALREADY THEN DON'T SET
if ((style & SWT.BORDER) != 0) {
OS.gtk_scrolled_window_set_shadow_type(scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
}
@@ -122,69 +205,33 @@
}
OS.gtk_widget_show (handle);
- //DOESN'T WORK RIGHT NOW
+ OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_WIDGET_DOUBLE_BUFFERED);
+ if ((style & SWT.NO_BACKGROUND) != 0) {
+ setBackgroundPixmap ();
+ }
if ((style & SWT.NO_REDRAW_RESIZE) != 0) {
OS.gtk_widget_set_redraw_on_allocate (handle, false);
}
}
-int parentingHandle () {
- if ((state & CANVAS) != 0) return handle;
- return fixedHandle != 0 ? fixedHandle : handle;
-}
-
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (changed && resize && layout != null) layout.layout (this, false);
- return changed;
-}
-
-// USE FOR TRIM ????
-//
-//Point getScrollableTrim() {
-// /*
-// * This is very tricky.
-// * In SWT/GTK, layout is not managed by the GtkContainers.
-// * Therefore, the native preferred minimum sizes are
-// * generally ignored. This allows us to set the native
-// * size of the fixed to whatever value we want, and it is
-// * guaranteed to be disregarded by the layout code.
-// * At this point, that size is requested by the Scrollable,
-// * gets added to by whatever is between the scrollable
-// * and the fixed, and serves as the basis for the native
-// * Scrollable size requisition (which is also guaranteed
-// * to be thrown away).
-// */
-// OS.GTK_WIDGET_SET_FLAGS(parentingHandle(), OS.GTK_VISIBLE);
-// OS.GTK_WIDGET_SET_FLAGS(boxHandle, OS.GTK_VISIBLE);
-// GtkRequisition clientReq = new GtkRequisition();
-// GtkRequisition req = new GtkRequisition();
-// OS.gtk_widget_size_request(parentingHandle(), clientReq);
-// OS.gtk_widget_size_request(scrolledHandle, req);
-// if ((style&SWT.H_SCROLL&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, req.height-clientReq.height);
-// if ((style&SWT.H_SCROLL)!=0) return new Point (0, req.height-clientReq.height);
-// if ((style&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, 0);
-// return new Point (0,0);
-//}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- Point size;
- if (layout != null) {
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = new Point (wHint, hHint);
- }
- } else {
- size = minimumSize ();
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
- return new Point (trim.width, trim.height);
+/**
+ * Returns an array containing the receiver's children.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of children, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return an array of children
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control [] getChildren () {
+ checkWidget();
+ return _getChildren ();
}
/**
@@ -219,65 +266,11 @@
return new Control [0];
}
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLayout (Layout layout) {
- checkWidget();
- this.layout = layout;
-}
-
-/**
- * Returns an array containing the receiver's children.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of children, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return an array of children
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control [] getChildren () {
- checkWidget();
- return _getChildren ();
-}
-
-Control [] _getChildren () {
- int parentHandle = parentingHandle ();
- int list = OS.gtk_container_children (parentHandle);
- int count = (list != 0) ? OS.g_list_length (list) : 0;
- if (count == 0) return new Control [0];
- Control [] children = new Control [count];
- int i = 0, j = 0;
- while (i < count) {
- int handle = OS.g_list_nth_data (list, i);
- if (handle != 0) {
- Widget widget = WidgetTable.get (handle);
- if (widget != null && widget != this) {
- if (widget instanceof Control) {
- children [j++] = (Control) widget;
- }
- }
- }
- i++;
+void hookEvents () {
+ super.hookEvents ();
+ if ((state & CANVAS) != 0) {
+ OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK);
}
- if (i == j) return children;
- Control [] newChildren = new Control [j];
- System.arraycopy (children, 0, newChildren, 0, j);
- return newChildren;
}
/**
@@ -330,18 +323,88 @@
}
return new Point (width, height);
}
+
+int parentingHandle () {
+ if ((state & CANVAS) != 0) return handle;
+ return fixedHandle != 0 ? fixedHandle : handle;
+}
+
+int processFocusIn(int int0, int int1, int int2) {
+ return super.processFocusIn(int0, int1, int2);
+}
+
+int processFocusOut(int int0, int int1, int int2) {
+ return super.processFocusOut(int0, int1, int2);
+}
+
+int processMouseDown (int callData, int arg1, int int2) {
+ int result = super.processMouseDown (callData, arg1, int2);
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ int count = 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list != 0) {
+ count = OS.g_list_length (list);
+ OS.g_list_free (list);
+ }
+ if (count == 0) OS.gtk_widget_grab_focus (handle);
+ }
+ }
+ return result;
+}
+
+int processMouseUp (int callData, int arg1, int int2) {
+ int result = super.processMouseUp (callData, arg1, int2);
+ return result;
+}
+
+int processPaint (int callData, int int1, int int2) {
+ if ((state & CANVAS) == 0) {
+ return super.processPaint (callData, int1, int2);
+ }
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+ int window = paintWindow ();
+ int gc = OS.gdk_gc_new (window);
+ OS.gdk_gc_set_foreground (gc, getBackgroundColor ());
+ GdkEventExpose gdkEvent = new GdkEventExpose (callData);
+ int x = gdkEvent.x, y = gdkEvent.y;
+ int width = gdkEvent.width, height = gdkEvent.height;
+ OS.gdk_gc_set_clip_region (gc, gdkEvent.region);
+ OS.gdk_draw_rectangle (window, gc, 1, x, y, width, height);
+ OS.g_object_unref (gc);
+ }
+ if ((style & SWT.NO_MERGE_PAINTS) == 0) {
+ return super.processPaint (callData, int1, int2);
+ }
+ if (!hooks (SWT.Paint)) return 0;
+ GdkEventExpose gdkEvent = new GdkEventExpose (callData);
+ int [] rectangles = new int [1];
+ int [] n_rectangles = new int [1];
+ OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles);
+ GdkRectangle rect = new GdkRectangle ();
+ for (int i=0; i<n_rectangles[0]; i++) {
+ Event event = new Event ();
+ OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
+ event.x = rect.x;
+ event.y = rect.y;
+ event.width = rect.width;
+ event.height = rect.height;
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ event.gc = null;
+ }
+ OS.g_free (rectangles [0]);
+ return 0;
+}
+
int radioGroup() {
- if (radioHandle==0) _initializeRadioGroup();
- return OS.gtk_radio_button_group(radioHandle);
-}
-
-public void redraw () {
- checkWidget();
- OS.gtk_widget_queue_draw(paintHandle());
-}
-
-void _initializeRadioGroup() {
- radioHandle = OS.gtk_radio_button_new(0);
+ if (radioHandle == 0) {
+ radioHandle = OS.gtk_radio_button_new (0);
+ if (radioHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ }
+ return OS.gtk_radio_button_group (radioHandle);
}
void releaseChildren () {
@@ -354,53 +417,35 @@
}
}
}
-void releaseWidget () {
- releaseChildren ();
- super.releaseWidget ();
- layout = null;
-}
+
void releaseHandle () {
super.releaseHandle ();
radioHandle = 0;
}
-int processMouseDown (int callData, int arg1, int int2) {
- int result = super.processMouseDown (callData, arg1, int2);
- if ((state & CANVAS) != 0) {
- //NOT DONE - only grab when not already grabbing
- OS.gtk_grab_add (handle);
- if ((style & SWT.NO_FOCUS) == 0) {
- int list = OS.gtk_container_children (handle);
- int count = list != 0 ? OS.g_list_length (list) : 0;
- if (count == 0) OS.gtk_widget_grab_focus (handle);
- }
- return 1;
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+}
+
+void setBackgroundPixmap () {
+ if ((style & SWT.NO_BACKGROUND) != 0) {
+ OS.gtk_widget_realize (handle);
+ int window = OS.GTK_WIDGET_WINDOW (handle);
+ OS.gdk_window_set_back_pixmap (window, 0, false);
}
- return result;
}
-int processMouseMove (int callData, int arg1, int int2) {
- int result = super.processMouseMove (callData, arg1, int2);
- return (state & CANVAS) != 0 ? 1 : result;
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ if ((state & CANVAS) != 0) setBackgroundPixmap ();
}
-int processMouseUp (int callData, int arg1, int int2) {
- int result = super.processMouseUp (callData, arg1, int2);
- //NOT DONE - only release when last button goes up
- if ((state & CANVAS) != 0) {
- OS.gtk_grab_remove (handle);
- return 1;
- }
- return result;
-}
-
-int processFocusIn(int int0, int int1, int int2) {
- OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_HAS_FOCUS);
- return super.processFocusIn(int0, int1, int2);
-}
-int processFocusOut(int int0, int int1, int int2) {
- OS.GTK_WIDGET_UNSET_FLAGS(handle, OS.GTK_HAS_FOCUS);
- return super.processFocusOut(int0, int1, int2);
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize && layout != null) layout.layout (this, false);
+ return changed;
}
public boolean setFocus () {
@@ -413,35 +458,39 @@
return super.setFocus ();
}
-void setInitialSize () {
- if (scrolledHandle != 0) {
- super.setInitialSize ();
- return;
- }
- /*
- * Bug in GTK. The scrollbars are not visible when a scrolled window
- * is resize and then shown. The fix is to change the scrolling policy
- * before and after resizing.
- */
- if ((state & CANVAS) != 0) {
- OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, OS.GTK_POLICY_NEVER);
- }
- super.setInitialSize ();
- if ((state & CANVAS) != 0) {
- int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
- int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
- OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
- }
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ if ((state & CANVAS) != 0) setBackgroundPixmap ();
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ if ((state & CANVAS) != 0) setBackgroundPixmap ();
+}
+
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+ checkWidget();
+ this.layout = layout;
}
/**
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
*
- * @param tabList the ordered list of controls representing the tab order; must not be null
+ * @param tabList the ordered list of controls representing the tab order or null
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the tabList is null</li>
* <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
* <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
* </ul>
@@ -451,10 +500,37 @@
* </ul>
*/
public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This code is intentionally commented.
+ * Tab lists are currently only supported
+ * for the direct children of a composite.
+ */
+// Shell shell = control.getShell ();
+// while (control != shell && control != this) {
+// control = control.parent;
+// }
+// if (control != this) error (SWT.ERROR_INVALID_PARENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control [] newList = new Control [tabList.length];
+ System.arraycopy (tabList, 0, newList, 0, tabList.length);
+ tabList = newList;
+ }
+ this.tabList = tabList;
}
-protected void checkSubclass () {
- /* Do nothing - Subclassing is allowed */
+int traversalCode(int key, int event) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return 0;
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) return 0;
+ }
+ return super.traversalCode (key, event);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index ea20d31..2e26e46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -85,57 +85,34 @@
return handle;
}
-/**
- * Connect the appropriate signal handlers.
- *
- * At a minimum, we must connect
- * <ul>
- * <li>expose_event
- * <li>button_press_event / button_release_event
- * <li>motion_notify_event
- * <li>enter_notify_event / leave_notify_event
- * <li>key_press_event / key_release_event
- * <li>focus_in_event / focus_out_event
- * </ul>
- *
- * The possible mask bits are:
- * <ul>
- * GDK_EXPOSURE_MASK |
- * GDK_POINTER_MOTION_MASK |
- * GDK_POINTER_MOTION_HINT_MASK |
- * GDK_ENTER_NOTIFY_MASK |
- * GDK_LEAVE_NOTIFY_MASK |
- * GDK_BUTTON_PRESS_MASK
- * GDK_BUTTON_RELEASE_MASK
- * GDK_KEY_PRESS_MASK
- * GDK_KEY_RELEASE_MASK
- * GDK_FOCUS_CHANGE_MASK
- * </ul>
- */
+boolean hasFocus () {
+ return OS.GTK_WIDGET_HAS_FOCUS(handle);
+}
+
void hookEvents () {
int eventHandle = eventHandle ();
- signal_connect_after (eventHandle, "expose_event", SWT.Paint, 3);
- //TEMPORARY CODE - always attempt to add events
- if (true || !OS.GTK_WIDGET_NO_WINDOW (eventHandle)) {
- int mask =
-// OS.GDK_EXPOSURE_MASK |
- OS.GDK_POINTER_MOTION_MASK |
- OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
- OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
- OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
- OS.GDK_FOCUS_CHANGE_MASK;
- OS.gtk_widget_add_events (eventHandle, mask);
- }
- signal_connect_after (eventHandle, "event", SWT.MouseDown, 3);
-// signal_connect_after (eventHandle, "button_press_event", SWT.MouseDown, 3);
-// signal_connect_after (eventHandle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (eventHandle, "motion_notify_event", SWT.MouseMove, 3);
+ int mask =
+ OS.GDK_EXPOSURE_MASK | OS.GDK_POINTER_MOTION_MASK |
+ OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
+ OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
+ OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
+ OS.GDK_FOCUS_CHANGE_MASK;
+ OS.gtk_widget_add_events (eventHandle, mask);
+ signal_connect (eventHandle, "button_press_event", SWT.MouseDown, 3);
+ signal_connect (eventHandle, "button_release_event", SWT.MouseUp, 3);
+ signal_connect (eventHandle, "key_press_event", SWT.KeyDown, 3);
+ signal_connect (eventHandle, "key_release_event", SWT.KeyUp, 3);
+ signal_connect (eventHandle, "motion_notify_event", SWT.MouseMove, 3);
+ signal_connect_after (eventHandle, "button_press_event", -SWT.MouseDown, 3);
+ signal_connect_after (eventHandle, "button_release_event", -SWT.MouseUp, 3);
+ signal_connect_after (eventHandle, "key_press_event", -SWT.KeyDown, 3);
+ signal_connect_after (eventHandle, "key_release_event", -SWT.KeyUp, 3);
+ signal_connect_after (eventHandle, "motion_notify_event", -SWT.MouseMove, 3);
signal_connect_after (eventHandle, "enter_notify_event", SWT.MouseEnter, 3);
signal_connect_after (eventHandle, "leave_notify_event", SWT.MouseExit, 3);
- signal_connect_after (eventHandle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (eventHandle, "key_release_event", SWT.KeyUp, 3);
signal_connect_after (eventHandle, "focus_in_event", SWT.FocusIn, 3);
signal_connect_after (eventHandle, "focus_out_event", SWT.FocusOut, 3);
+ signal_connect_after (eventHandle, "expose_event", SWT.Paint, 3);
}
int topHandle() {
@@ -179,6 +156,35 @@
return computeSize (wHint, hHint, true);
}
+Control computeTabGroup () {
+ if (isTabGroup()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control[] computeTabList() {
+ if (isTabGroup()) {
+ if (getVisible() && getEnabled()) {
+ return new Control[] {this};
+ }
+ }
+ return new Control[0];
+}
+
+Control computeTabRoot () {
+ Control[] tabList = parent._getTabList();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
void createWidget (int index) {
super.createWidget (index);
setInitialSize ();
@@ -338,14 +344,33 @@
if (topHandle != handle) {
OS.gtk_widget_set_size_request (handle, width, height);
}
- //FIXME - causes scrollbar problems when button child of table
+
+ /*
+ * Feature in GTK. Some widgets do not allocate the size
+ * of their internal children in gtk_widget_size_allocate().
+ * Instead this is done in gtk_widget_size_request(). This
+ * means that the client area of the widget is not correct.
+ * The fix is to call gtk_widget_size_request() (and throw
+ * the results away).
+ *
+ * Note: The following widgets rely on this feature:
+ * GtkScrolledWindow
+ * GtkNotebook
+ * GtkFrame
+ * GtkCombo
+ */
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (handle, requisition);
+
+ /*
+ * Force the container to allocate the size of its children.
+ */
int parentHandle = parent.parentingHandle ();
Display display = getDisplay ();
boolean warnings = display.getWarnings ();
display.setWarnings (false);
OS.gtk_container_resize_children (parentHandle);
display.setWarnings (warnings);
-
if ((flags & OS.GTK_VISIBLE) == 0) {
OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
}
@@ -1137,7 +1162,7 @@
public boolean forceFocus () {
checkWidget();
OS.gtk_widget_grab_focus (handle);
- return true;
+ return hasFocus ();
}
/**
@@ -1152,17 +1177,12 @@
*/
public Color getBackground () {
checkWidget();
- return Color.gtk_new (getDisplay (), _getBackgroundGdkColor());
+ return Color.gtk_new (getDisplay (), getBackgroundColor ());
}
-/*
- * Subclasses should override this to pass a meaningful handle
- */
-GdkColor _getBackgroundGdkColor() {
- /* Override this */
- int h = paintHandle();
-
- int hStyle = OS.gtk_widget_get_style (handle);
+GdkColor getBackgroundColor () {
+ int fontHandle = fontHandle ();
+ int hStyle = OS.gtk_widget_get_style (fontHandle);
GtkStyle style = new GtkStyle (hStyle);
GdkColor color = new GdkColor ();
color.pixel = style.bg0_pixel;
@@ -1233,15 +1253,15 @@
*/
public Font getFont () {
checkWidget();
- int fontHandle = fontHandle ();
- int context = OS.gtk_widget_get_pango_context (fontHandle);
- int font = OS.pango_context_get_font_description (context);
- return Font.gtk_new (getDisplay (), font);
+ return Font.gtk_new (getDisplay (), getFontDescription ());
}
-/*
- * Subclasses should override this, passing a meaningful handle
- */
-
+
+int getFontDescription () {
+ int fontHandle = fontHandle ();
+ int hStyle = OS.gtk_widget_get_style (fontHandle);
+ GtkStyle style = new GtkStyle (hStyle);
+ return style.font_desc;
+}
/**
* Returns the foreground color that the receiver will use to draw.
@@ -1255,17 +1275,12 @@
*/
public Color getForeground () {
checkWidget();
- return Color.gtk_new (getDisplay (), _getForegroundGdkColor());
+ return Color.gtk_new (getDisplay (), getForegroundColor ());
}
-/*
- * Subclasses should override this to pass a meaningful handle
- */
-GdkColor _getForegroundGdkColor() {
- /* Override this */
- int h = paintHandle();
-
- int hStyle = OS.gtk_widget_get_style (handle);
+GdkColor getForegroundColor () {
+ int fontHandle = fontHandle ();
+ int hStyle = OS.gtk_widget_get_style (fontHandle);
GtkStyle style = new GtkStyle (hStyle);
GdkColor color = new GdkColor ();
color.pixel = style.fg0_pixel;
@@ -1326,6 +1341,23 @@
return parent;
}
+Control [] getPath () {
+ int count = 0;
+ Shell shell = getShell ();
+ Control control = this;
+ while (control != shell) {
+ count++;
+ control = control.parent;
+ }
+ control = this;
+ Control [] result = new Control [count];
+ while (control != shell) {
+ result [--count] = control;
+ control = control.parent;
+ }
+ return result;
+}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -1407,11 +1439,24 @@
int gdkGC = OS.gdk_gc_new (window);
if (gdkGC == 0) error (SWT.ERROR_NO_HANDLES);
if (data != null) {
+ int fontHandle = fontHandle ();
+ int hStyle = OS.gtk_widget_get_style (fontHandle);
+ GtkStyle style = new GtkStyle (hStyle);
+ GdkColor foreground = new GdkColor ();
+ foreground.pixel = style.fg0_pixel;
+ foreground.red = style.fg0_red;
+ foreground.green = style.fg0_green;
+ foreground.blue = style.fg0_blue;
+ GdkColor background = new GdkColor ();
+ background.pixel = style.bg0_pixel;
+ background.red = style.bg0_red;
+ background.green = style.bg0_green;
+ background.blue = style.bg0_blue;
data.drawable = window;
data.device = getDisplay ();
- data.background = _getBackgroundGdkColor ();
- data.foreground = _getForegroundGdkColor ();
- data.font = getFont().handle;
+ data.background = background;
+ data.foreground = foreground;
+ data.font = style.font_desc;
}
return gdkGC;
}
@@ -1450,6 +1495,43 @@
checkWidget();
return false;
}
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 1 || size.y == 1) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+}
+boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int code = traversalCode (0, 0);
+ if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+ return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+}
+boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int code = traversalCode (0, 0);
+ return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
+}
/**
* Returns <code>true</code> if the receiver is enabled, and
@@ -1482,7 +1564,7 @@
*/
public boolean isFocusControl () {
checkWidget();
- return OS.GTK_WIDGET_HAS_FOCUS(handle);
+ return hasFocus ();
}
/**
@@ -1518,39 +1600,49 @@
int [] state = new int [1];
OS.gdk_event_get_state (callData, state);
int shellHandle = _getShell ().topHandle ();
- boolean accelResult = OS.gtk_accel_groups_activate (shellHandle, keyval, state [0]);
- if (!accelResult) sendKeyEvent (SWT.KeyDown, callData);
- return 1;
+// if (keyval==OS.GDK_Return && (state[0]&(OS.GDK_SHIFT_MASK|OS.GDK_CONTROL_MASK))==0)
+// if (OS.gtk_window_activate_default(shellHandle)) return 0;
+ sendKeyEvent (SWT.KeyDown, callData);
+ return 0;
}
int processKeyUp (int callData, int arg1, int int2) {
sendKeyEvent (SWT.KeyUp, callData);
- return 1;
+ return 0;
}
int processMouseDown (int callData, int arg1, int int2) {
+ Shell shell = _getShell ();
int type = OS.GDK_EVENT_TYPE (callData);
int eventType = type != OS.GDK_2BUTTON_PRESS ? SWT.MouseDown : SWT.MouseDoubleClick;
int button = OS.gdk_event_button_get_button (callData);
sendMouseEvent (eventType, button, callData);
- if (button == 3 && menu != null) menu.setVisible (true);
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
return 0;
}
-int processMouseEnter (int arg0, int arg1, int int2) {
- //NOT IMPLEMENTED - event state
- sendEvent (SWT.MouseEnter);
- return 1;
+int processMouseEnter (int callData, int arg1, int int2) {
+ sendMouseEvent(SWT.MouseEnter, 0, callData);
+ return 0;
}
-int processMouseExit (int arg0, int arg1, int int2) {
- //NOT IMPLEMENTED - event state
- sendEvent (SWT.MouseExit);
- return 1;
+int processMouseExit (int callData, int arg1, int int2) {
+ sendMouseEvent(SWT.MouseExit, 0, callData);
+ return 0;
}
int processMouseUp (int callData, int arg1, int int2) {
int button = OS.gdk_event_button_get_button (callData);
sendMouseEvent (SWT.MouseUp, button, callData);
+ if (button == 3 && menu != null) menu.setVisible (true);
return 0;
}
@@ -1560,30 +1652,57 @@
}
int processFocusIn(int int0, int int1, int int2) {
- postEvent(SWT.FocusIn);
+ Shell shell = _getShell ();
+ sendEvent (SWT.FocusIn);
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
return 0;
}
+
int processFocusOut(int int0, int int1, int int2) {
- postEvent(SWT.FocusOut);
+ Shell shell = _getShell ();
+ sendEvent (SWT.FocusOut);
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ Display display = shell.getDisplay ();
+ Control control = display.getFocusControl ();
+ if (control == null || shell != control.getShell () ) {
+ shell.setActiveControl (null);
+ }
+ }
return 0;
}
int processPaint (int callData, int int2, int int3) {
- if (!hooks (SWT.Paint)) return 1;
+ if (!hooks (SWT.Paint)) return 0;
GdkEventExpose gdkEvent = new GdkEventExpose (callData);
Event event = new Event ();
event.count = gdkEvent.count;
- event.x = gdkEvent.x; event.y = gdkEvent.y;
- event.width = gdkEvent.width; event.height = gdkEvent.height;
+ event.x = gdkEvent.x;
+ event.y = gdkEvent.y;
+ event.width = gdkEvent.width;
+ event.height = gdkEvent.height;
GC gc = event.gc = new GC (this);
- GdkRectangle rect = new GdkRectangle ();
- rect.x = gdkEvent.x; rect.y = gdkEvent.y;
- rect.width = gdkEvent.width; rect.height = gdkEvent.height;
- OS.gdk_gc_set_clip_rectangle (gc.handle, rect);
+ Region region = Region.gtk_new (gdkEvent.region);
+ gc.setClipping (region);
sendEvent (SWT.Paint, event);
gc.dispose ();
event.gc = null;
- return 1;
+ return 0;
}
void register () {
@@ -1609,7 +1728,7 @@
int topHandle = topHandle ();
int width = OS.GTK_WIDGET_WIDTH (topHandle);
int height = OS.GTK_WIDGET_HEIGHT (topHandle);
- redraw (0, 0, width, height, true);
+ redrawWidget (0, 0, width, height, true);
}
/**
* Causes the rectangular area of the receiver specified by
@@ -1636,14 +1755,25 @@
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
+ redrawWidget (x, y, width, height, all);
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean all) {
//?? TRANSLATE COORDINATES
int window = paintWindow ();
- OS.gdk_window_clear_area_e (window, x, y, width, height);
+ GdkRectangle rect = new GdkRectangle ();
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+ OS.gdk_window_invalidate_rect (window, rect, all);
}
+
void releaseHandle () {
super.releaseHandle ();
fixedHandle = 0;
}
+
void releaseWidget () {
super.releaseWidget ();
toolTipText = null;
@@ -1709,11 +1839,21 @@
* </ul>
*/
public void setBackground (Color color) {
- checkWidget ();
- //TEMPORARY CODE - should fix setBackground()/setForeground() everywhere
- //NULL CHECK
- if (color == null) return;
- OS.gtk_widget_modify_bg (handle, 0, color.handle);
+ checkWidget();
+ GdkColor gdkColor;
+ if (color == null) {
+// gdkColor = defaultBackground ();
+ return;
+ } else {
+ if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ gdkColor = color.handle;
+ }
+ setBackgroundColor (gdkColor);
+}
+
+void setBackgroundColor (GdkColor color) {
+ if (fixedHandle != 0) OS.gtk_widget_modify_bg (fixedHandle, 0, color);
+ OS.gtk_widget_modify_bg (handle, 0, color);
}
/**
@@ -1828,11 +1968,20 @@
*/
public void setFont (Font font) {
checkWidget();
-
- int fontHandle = fontHandle ();
- OS.gtk_widget_modify_font (fontHandle, font.handle);
+ int fontDesc;
+ if (font == null) {
+// fontDesc = defaultFont ();
+ return;
+ } else {
+ if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ fontDesc = font.handle;
+ }
+ setFontDescription (fontDesc);
}
-
+
+void setFontDescription (int font) {
+ OS.gtk_widget_modify_font (handle, font);
+}
/**
* Sets the receiver's foreground color to the color specified
@@ -1851,58 +2000,20 @@
*/
public void setForeground (Color color) {
checkWidget();
- int hStyle = OS.gtk_widget_get_style (handle);
- hStyle = OS.gtk_style_copy (hStyle);
- GtkStyle style = new GtkStyle (hStyle);
+ GdkColor gdkColor;
if (color == null) {
- int hDefaultStyle = OS.gtk_widget_get_default_style ();
- GtkStyle defaultStyle = new GtkStyle (hDefaultStyle);
- style.fg0_pixel = defaultStyle.fg0_pixel;
- style.fg0_red = defaultStyle.fg0_red;
- style.fg0_green = defaultStyle.fg0_green;
- style.fg0_blue = defaultStyle.fg0_blue;
- style.fg1_pixel = defaultStyle.fg1_pixel;
- style.fg1_red = defaultStyle.fg1_red;
- style.fg1_green = defaultStyle.fg1_green;
- style.fg1_blue = defaultStyle.fg1_blue;
- style.fg2_pixel = defaultStyle.fg2_pixel;
- style.fg2_red = defaultStyle.fg2_red;
- style.fg2_green = defaultStyle.fg2_green;
- style.fg2_blue = defaultStyle.fg2_blue;
- style.fg3_pixel = defaultStyle.fg3_pixel;
- style.fg3_red = defaultStyle.fg3_red;
- style.fg3_green = defaultStyle.fg3_green;
- style.fg3_blue = defaultStyle.fg3_blue;
- style.fg4_pixel = defaultStyle.fg4_pixel;
- style.fg4_red = defaultStyle.fg4_red;
- style.fg4_green = defaultStyle.fg4_green;
- style.fg4_blue = defaultStyle.fg4_blue;
+// gdkColor = defaultForeground ();
+ return;
} else {
- style.fg0_pixel = color.handle.pixel;
- style.fg0_red = color.handle.red;
- style.fg0_green = color.handle.green;
- style.fg0_blue = color.handle.blue;
- style.fg1_pixel = color.handle.pixel;
- style.fg1_red = color.handle.red;
- style.fg1_green = color.handle.green;
- style.fg1_blue = color.handle.blue;
- style.fg2_pixel = color.handle.pixel;
- style.fg2_red = color.handle.red;
- style.fg2_green = color.handle.green;
- style.fg2_blue = color.handle.blue;
- style.fg3_pixel = color.handle.pixel;
- style.fg3_red = color.handle.red;
- style.fg3_green = color.handle.green;
- style.fg3_blue = color.handle.blue;
- style.fg4_pixel = color.handle.pixel;
- style.fg4_red = color.handle.red;
- style.fg4_green = color.handle.green;
- style.fg4_blue = color.handle.blue;
+ if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ gdkColor = color.handle;
}
- /* FIXME */
- /* I believe there is now something like set_color? */
- /*OS.memmove (hStyle, style, GtkStyle.sizeof);
- OS.gtk_widget_set_style (handle, hStyle);*/
+ setForegroundColor (gdkColor);
+}
+
+void setForegroundColor (GdkColor color) {
+ if (fixedHandle != 0) OS.gtk_widget_modify_fg (fixedHandle, 0, color);
+ OS.gtk_widget_modify_fg (handle, 0, color);
}
void setInitialSize () {
@@ -1998,9 +2109,17 @@
* @see #update
*/
public void setRedraw (boolean redraw) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
}
+
+boolean setTabGroupFocus () {
+ return setTabItemFocus ();
+}
+boolean setTabItemFocus () {
+ if (!isShowing ()) return false;
+ return setFocus ();
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -2013,8 +2132,7 @@
* </ul>
*/
public void setToolTipText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
toolTipText = string;
}
/**
@@ -2083,34 +2201,152 @@
event.detail = traversal;
return traverse (event);
}
-
+boolean translateTraversal (int event) {
+ int detail = SWT.TRAVERSE_NONE;
+ int key = OS.gdk_event_key_get_keyval (event);
+ int code = traversalCode (key, event);
+ int [] state = new int [1];
+ OS.gdk_event_get_state (event, state);
+ int shellHandle = _getShell ().topHandle ();
+ boolean all = false;
+ switch (key) {
+ case OS.GDK_Escape:
+ case OS.GDK_Cancel: {
+ all = true;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.GDK_Return: {
+ all = true;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case OS.GDK_Tab: {
+ boolean next = (state[0] & OS.GDK_SHIFT_MASK) == 0;
+ /*
+ * NOTE: This code emulates a bug/feature on Windows where
+ * the default is that that Shift+Tab and Ctrl+Tab traverses
+ * instead of going to the widget. StyledText currently
+ * relies on this behavior.
+ */
+ switch (state[0]) {
+ case OS.GDK_SHIFT_MASK:
+ case OS.GDK_CONTROL_MASK:
+ code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT;
+ }
+ detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case OS.GDK_Up:
+ case OS.GDK_Left:
+ case OS.GDK_Down:
+ case OS.GDK_Right: {
+ boolean next = key == OS.GDK_Down || key == OS.GDK_Right;
+ detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case OS.GDK_Page_Up:
+ case OS.GDK_Page_Down: {
+ all = true;
+ if ((state[0] & OS.GDK_CONTROL_MASK) == 0) return false;
+ detail = key == OS.GDK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event swtEvent = new Event ();
+ swtEvent.doit = (code & detail) != 0;
+ swtEvent.detail = detail;
+ swtEvent.time = OS.gdk_event_get_time (event);
+ setInputState (swtEvent, event);
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (swtEvent)) return true;
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+int traversalCode (int key, int event) {
+ int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ Shell shell = getShell ();
+ if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+// FIXME - Needs to be implemented
+// if (getNavigationType () == OS.XmNONE) {
+// code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
+// }
+ return code;
+}
boolean traverse (Event event) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the traverse
- * event. If this happens, return true to stop further
- * event processing.
- */
sendEvent (SWT.Traverse, event);
if (isDisposed ()) return false;
if (!event.doit) return false;
switch (event.detail) {
- case SWT.TRAVERSE_NONE: return true;
- /*
+ case SWT.TRAVERSE_NONE: return true;
case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
- case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
+ case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event);
case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
- */
}
- error(SWT.ERROR_NOT_IMPLEMENTED);
return false;
}
+boolean traverseEscape () {
+ return false;
+}
+boolean traverseGroup (boolean next) {
+ // FIXME - Needs to be implemented
+ Control root = computeTabRoot();
+ Control group = computeTabGroup();
+ Control[] list = root.computeTabList();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ return group.setTabGroupFocus ();
+}
+boolean traverseItem (boolean next) {
+ // FIXME - Needs to be implemented
+ return true;
+}
+boolean traverseReturn () {
+ return false;
+}
+boolean traversePage (boolean next) {
+ return false;
+}
+boolean traverseMnemonic (Event event) {
+ // This code is intentionally commented.
+ // TraverseMnemonic always originates from the OS and
+ // never through the API, and on the GTK platform, accels
+ // are hooked by the OS before we get the key event.
+ // int shellHandle = _getShell ().topHandle ();
+ // return OS.gtk_accel_groups_activate (shellHandle, keyCode, stateMask);
+ return true;
+}
/**
@@ -2127,6 +2363,7 @@
public void update () {
checkWidget ();
//NOT DONE - should only dispatch paint events
+// OS.gdk_window_process_updates (window, all);
OS.gdk_flush ();
while ((OS.gtk_events_pending()) != 0) {
OS.gtk_main_iteration ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
index 42f0fed..a5950c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
@@ -87,9 +87,9 @@
public class Decorations extends Canvas {
String text;
Image image;
+ boolean minimized, maximized;
Menu menuBar;
Menu [] menus;
- Button defaultButton, saveDefault;
Decorations () {
/* Do nothing */
}
@@ -145,6 +145,14 @@
menus = newMenus;
}
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
void createWidget (int index) {
super.createWidget (index);
text = "";
@@ -165,7 +173,11 @@
*/
public Button getDefaultButton () {
checkWidget();
- return defaultButton;
+ int buttonHandle = OS.gtk_window_get_default(topHandle());
+ if (buttonHandle==0) return null;
+ Widget button = WidgetTable.get(buttonHandle);
+ if (!(button instanceof Button)) return null;
+ return (Button)button;
}
/**
* Returns the receiver's image if it had previously been
@@ -208,7 +220,7 @@
*/
public boolean getMaximized () {
checkWidget();
- return false;
+ return maximized;
}
/**
* Returns the receiver's menu bar if one had previously
@@ -241,7 +253,7 @@
*/
public boolean getMinimized () {
checkWidget();
- return false;
+ return minimized;
}
String getNameText () {
return getText ();
@@ -263,6 +275,15 @@
checkWidget();
return text;
}
+
+boolean isTabGroup () {
+ return true;
+}
+
+boolean isTabItem () {
+ return false;
+}
+
Decorations menuShell () {
return this;
}
@@ -294,7 +315,6 @@
menus = null;
super.releaseWidget ();
image = null;
- defaultButton = saveDefault = null;
}
/**
* If the argument is not null, sets the receiver's default
@@ -318,13 +338,12 @@
*/
public void setDefaultButton (Button button) {
checkWidget();
+ int buttonHandle= 0;
if (button != null) {
- if (button.isDisposed()) return;
- OS.GTK_WIDGET_SET_FLAGS(button.handle, OS.GTK_CAN_DEFAULT);
- OS.gtk_window_set_default(topHandle(), button.handle);
- return;
+ if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ buttonHandle = button.handle;
}
- else OS.gtk_window_set_default(topHandle(), 0);
+ OS.gtk_window_set_default(topHandle(), buttonHandle);
}
/**
@@ -380,6 +399,7 @@
*/
public void setMaximized (boolean maximized) {
checkWidget();
+ this.maximized = maximized;
}
/**
* Sets the receiver's menu bar to the argument, which
@@ -430,6 +450,7 @@
*/
public void setMinimized (boolean minimized) {
checkWidget();
+ this.minimized = minimized;
}
/**
* Sets the receiver's text, which is the string that the
@@ -451,4 +472,9 @@
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
text = string;
}
+boolean traverseReturn () {
+ int shellHandle = _getShell ().topHandle ();
+ boolean processed = OS.gtk_window_activate_default(shellHandle);
+ return processed;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
index 261a670..eb5ab0a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -21,7 +21,6 @@
public class DirectoryDialog extends GtkFileDialog {
String message = "", filterPath = "";
- String directoryPath;
/**
* Constructs a new instance of this class given only its
@@ -136,14 +135,30 @@
* @param string the message
*/
public void setMessage (String string) {
+ /*
+ * The native Gtk file selection dialog does not support message
+ * strings other than the dialog title. However, we maintain the set
+ * message so at least the application programs get back the same string.
+ */
message = string;
}
-boolean getAnswer() {
- String fileNameFromOS = getFileNameFromOS();
- int separatorIndex = calculateLastSeparatorIndex(fileNameFromOS);
- if (separatorIndex+1 != fileNameFromOS.length()) return false; // the user selected a file
- directoryPath = answer = fileNameFromOS;
- return true;
+void interpretOsAnswer(String osAnswer) {
+ if (osAnswer==null) return;
+ int separatorIndex = calculateLastSeparatorIndex(osAnswer);
+ if (separatorIndex+1 != osAnswer.length()) {
+ /*
+ * the selected thing is a file
+ */
+ answer = null;
+ return;
+ }
+ answer = osAnswer;
+}
+void preset() {
+ if (filterPath != null) {
+ byte [] filterBytes = Converter.wcsToMbcs (null, filterPath, true);
+ OS.gtk_file_selection_set_filename (handle, filterBytes);
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index c5abf34..b6e9e6a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -102,6 +102,8 @@
Runnable [] timerList;
Callback timerCallback;
int timerProc;
+ Callback windowTimerCallback;
+ int windowTimerProc;
/* Caret */
Caret currentCaret;
@@ -115,7 +117,9 @@
GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER;
GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
- GdkColor COLOR_INFO_BACKGROUND;
+ GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND;
+ GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT;
+ GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT;
/* Key Mappings */
static final int [] [] KeyTable = {
@@ -536,7 +540,7 @@
public Point getCursorLocation () {
checkDevice ();
int [] x = new int [1], y = new int [1];
- OS.gdk_window_get_pointer (0, x, y, 0);
+ OS.gdk_window_get_pointer (0, x, y, null);
return new Point (x [0], y [0]);
}
@@ -765,14 +769,14 @@
checkDevice ();
GdkColor gdkColor = null;
switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND;
- case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
- case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
+ case SWT.COLOR_INFO_FOREGROUND: gdkColor = COLOR_INFO_FOREGROUND; break;
+ case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND; break;
+ case SWT.COLOR_TITLE_FOREGROUND: gdkColor = COLOR_TITLE_FOREGROUND; break;
+ case SWT.COLOR_TITLE_BACKGROUND: gdkColor = COLOR_TITLE_BACKGROUND; break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_BACKGROUND_GRADIENT; break;
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: gdkColor = COLOR_TITLE_INACTIVE_FOREGROUND; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; break;
case SWT.COLOR_WIDGET_DARK_SHADOW: gdkColor = COLOR_WIDGET_DARK_SHADOW; break;
case SWT.COLOR_WIDGET_NORMAL_SHADOW: gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break;
case SWT.COLOR_WIDGET_LIGHT_SHADOW: gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break;
@@ -792,35 +796,32 @@
}
final void initializeSystemColors() {
-
- /* Get the theme colors */
- int colormap = OS.gdk_colormap_get_system();
- GtkStyle style = new GtkStyle(OS.gtk_widget_get_default_style());
-
- GdkColor gdkColor;
+ int shellHandle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL);
+ if (shellHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_widget_realize (shellHandle);
+ GdkColor gdkColor;
+ GtkStyle style = new GtkStyle(OS.gtk_widget_get_style (shellHandle));
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.black_pixel;
+ gdkColor.red = style.black_red;
+ gdkColor.green = style.black_green;
+ gdkColor.blue = style.black_blue;
+ COLOR_WIDGET_DARK_SHADOW = gdkColor;
+
gdkColor = new GdkColor();
gdkColor.pixel = style.dark0_pixel;
gdkColor.red = style.dark0_red;
gdkColor.green = style.dark0_green;
gdkColor.blue = style.dark0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
- COLOR_WIDGET_DARK_SHADOW = gdkColor;
-
- gdkColor = new GdkColor();
- gdkColor.pixel = style.mid0_pixel;
- gdkColor.red = style.mid0_red;
- gdkColor.green = style.mid0_green;
- gdkColor.blue = style.mid0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_WIDGET_NORMAL_SHADOW = gdkColor;
gdkColor = new GdkColor();
- gdkColor.pixel = style.light0_pixel;
- gdkColor.red = style.light0_red;
- gdkColor.green = style.light0_green;
- gdkColor.blue = style.light0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ gdkColor.pixel = style.bg0_pixel;
+ gdkColor.red = style.bg0_red;
+ gdkColor.green = style.bg0_green;
+ gdkColor.blue = style.bg0_blue;
COLOR_WIDGET_LIGHT_SHADOW = gdkColor;
gdkColor = new GdkColor();
@@ -828,7 +829,6 @@
gdkColor.red = style.light0_red;
gdkColor.green = style.light0_green;
gdkColor.blue = style.light0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor;
gdkColor = new GdkColor();
@@ -836,7 +836,6 @@
gdkColor.red = style.fg0_red;
gdkColor.green = style.fg0_green;
gdkColor.blue = style.fg0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_WIDGET_FOREGROUND = gdkColor;
gdkColor = new GdkColor();
@@ -844,7 +843,6 @@
gdkColor.red = style.bg0_red;
gdkColor.green = style.bg0_green;
gdkColor.blue = style.bg0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_WIDGET_BACKGROUND = gdkColor;
gdkColor = new GdkColor();
@@ -852,7 +850,6 @@
gdkColor.red = style.text0_red;
gdkColor.green = style.text0_green;
gdkColor.blue = style.text0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_LIST_FOREGROUND = gdkColor;
gdkColor = new GdkColor();
@@ -860,7 +857,6 @@
gdkColor.red = style.base0_red;
gdkColor.green = style.base0_green;
gdkColor.blue = style.base0_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_LIST_BACKGROUND = gdkColor;
gdkColor = new GdkColor();
@@ -868,7 +864,6 @@
gdkColor.red = style.fg3_red;
gdkColor.green = style.fg3_green;
gdkColor.blue = style.fg3_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_LIST_SELECTION_TEXT = gdkColor;
gdkColor = new GdkColor();
@@ -876,16 +871,65 @@
gdkColor.red = style.bg3_red;
gdkColor.green = style.bg3_green;
gdkColor.blue = style.bg3_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_LIST_SELECTION = gdkColor;
gdkColor = new GdkColor();
+ gdkColor.pixel = style.text3_pixel;
+ gdkColor.red = style.text3_red;
+ gdkColor.green = style.text3_green;
+ gdkColor.blue = style.text3_blue;
+ COLOR_INFO_FOREGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
gdkColor.pixel = style.base3_pixel;
gdkColor.red = style.base3_red;
gdkColor.green = style.base3_green;
gdkColor.blue = style.base3_blue;
- OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
COLOR_INFO_BACKGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.bg3_pixel;
+ gdkColor.red = style.bg3_red;
+ gdkColor.green = style.bg3_green;
+ gdkColor.blue = style.bg3_blue;
+ COLOR_TITLE_BACKGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.fg3_pixel;
+ gdkColor.red = style.fg3_red;
+ gdkColor.green = style.fg3_green;
+ gdkColor.blue = style.fg3_blue;
+ COLOR_TITLE_FOREGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.light3_pixel;
+ gdkColor.red = style.light3_red;
+ gdkColor.green = style.light3_green;
+ gdkColor.blue = style.light3_blue;
+ COLOR_TITLE_BACKGROUND_GRADIENT = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.bg4_pixel;
+ gdkColor.red = style.bg4_red;
+ gdkColor.green = style.bg4_green;
+ gdkColor.blue = style.bg4_blue;
+ COLOR_TITLE_INACTIVE_BACKGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.fg4_pixel;
+ gdkColor.red = style.fg4_red;
+ gdkColor.green = style.fg4_green;
+ gdkColor.blue = style.fg4_blue;
+ COLOR_TITLE_INACTIVE_FOREGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.light4_pixel;
+ gdkColor.red = style.light4_red;
+ gdkColor.green = style.light4_green;
+ gdkColor.blue = style.light4_blue;
+ COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor;
+
+ OS.gtk_widget_destroy (shellHandle);
}
/**
@@ -951,6 +995,10 @@
timerProc = timerCallback.getAddress ();
if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ windowTimerCallback = new Callback (this, "windowTimerProc", 2);
+ windowTimerProc = windowTimerCallback.getAddress ();
+ if (windowTimerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
caretCallback = new Callback(this, "caretProc", 2);
caretProc = caretCallback.getAddress();
if (caretProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
@@ -1085,8 +1133,6 @@
}
protected void release () {
-
- /* Release shells */
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
@@ -1095,20 +1141,15 @@
}
}
while (readAndDispatch ()) {};
-
- /* Run dispose list */
if (disposeList != null) {
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] != null) disposeList [i].run ();
}
}
disposeList = null;
-
- /* Release synchronizer */
synchronizer.releaseSynchronizer ();
synchronizer = null;
releaseDisplay ();
-
super.release ();
}
@@ -1135,6 +1176,9 @@
timerProc = 0;
timerCallback.dispose ();
timerCallback = null;
+ windowTimerProc = 0;
+ windowTimerCallback.dispose ();
+ windowTimerCallback = null;
messages = null; messageLock = null; thread = null;
messagesSize = windowProc2 = windowProc3 = windowProc4 = windowProc5 = 0;
@@ -1181,6 +1225,11 @@
Widget item = event.item;
if (item == null || !item.isDisposed ()) {
widget.notifyListeners (event.type, event);
+
+ /* Ask for the next mouse event */
+ if (event.type == SWT.MouseMove) {
+ OS.gdk_window_get_pointer (0, null, null, null);
+ }
}
}
@@ -1208,6 +1257,23 @@
}
/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ /* This is not supported on GTK */
+}
+
+/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
* <p>
@@ -1500,4 +1566,10 @@
return widget.processEvent (user_data, int0, int1, int2);
}
+int windowTimerProc (int handle, int id) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.processTimer (id);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
index 18f68b3..7875754 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
@@ -23,12 +23,13 @@
* within the SWT implementation.
* </p>
*/
-public class FileDialog extends Dialog {
+public class FileDialog extends GtkFileDialog {
String [] filterNames = new String [0];
String [] filterExtensions = new String [0];
- String filterPath = "", fileName = "";
+ String filterPath;
+ String fileName = "";
+ String[] fileNames;
String fullPath = "";
- boolean cancel = true;
/**
* Constructs a new instance of this class given only its
@@ -89,15 +90,6 @@
super (parent, style);
checkSubclass ();
}
-int cancelFunc (int widget, int callData) {
- cancel = true;
- OS.gtk_widget_destroy (callData);
- return 0;
-}
-int destroyFunc (int widget, int callData) {
- OS.gtk_main_quit ();
- return 0;
-}
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path,
@@ -116,7 +108,7 @@
* @return the relative paths of the files
*/
public String [] getFileNames () {
- return new String[] {fileName};
+ return fileNames;
}
/**
* Returns the file extensions which the dialog will
@@ -145,27 +137,7 @@
public String getFilterPath () {
return filterPath;
}
-int okFunc (int widget, int callData) {
- cancel = false;
- char separator = System.getProperty ("file.separator").charAt (0);
- int lpFilename = OS.gtk_file_selection_get_filename (callData);
- int filenameLength = OS.strlen (lpFilename);
- byte [] filenameBytes = new byte [filenameLength];
- OS.memmove (filenameBytes, lpFilename, filenameLength);
- fullPath = new String (Converter.mbcsToWcs (null, filenameBytes));
-
- /* Calculate fileName and filterPath */
- int separatorIndex = fullPath.indexOf (separator);
- int index = separatorIndex;
- while (index != -1) {
- separatorIndex = index;
- index = fullPath.indexOf (separator, index + 1);
- }
- fileName = fullPath.substring (separatorIndex + 1, fullPath.length ());
- filterPath = fullPath.substring (0, separatorIndex);
- OS.gtk_widget_destroy (callData);
- return 0;
-}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -179,69 +151,11 @@
* </ul>
*/
public String open () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- int handle = OS.gtk_file_selection_new (titleBytes);
-
- /* Calculate the fully-specified file name and convert to bytes */
- StringBuffer stringBuffer = new StringBuffer ();
- char separator = System.getProperty ("file.separator").charAt (0);
- if (filterPath == null) {
- filterPath = "";
- } else {
- if (filterPath.length () > 0) {
- stringBuffer.append (filterPath);
- if (filterPath.charAt (filterPath.length () - 1) != separator) {
- stringBuffer.append (separator);
- }
- }
- }
- if (fileName == null) {
- fileName = "";
- } else {
- stringBuffer.append (fileName);
- }
- fullPath = stringBuffer.toString ();
- byte [] fullPathBytes = Converter.wcsToMbcs (null, fullPath, true);
- OS.gtk_file_selection_set_filename (handle, fullPathBytes);
-
- /* Set the extension */
- if (filterNames == null) filterNames = new String [0];
- if (filterExtensions == null) filterExtensions = new String [0];
- if (filterExtensions.length == 1) {
- String ext = filterExtensions [0];
- byte [] extBytes = Converter.wcsToMbcs (null, ext, true);
- OS.gtk_file_selection_complete (handle, extBytes);
- }
-
- /* Hook callbacks */
- Callback destroyCallback = new Callback (this, "destroyFunc", 2);
- int destroyFunc = destroyCallback.getAddress ();
- byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
- OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
- byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
- Callback okCallback = new Callback (this, "okFunc", 2);
- int okFunc = okCallback.getAddress ();
- Callback cancelCallback = new Callback (this, "cancelFunc", 2);
- int cancelFunc = cancelCallback.getAddress ();
- OS.gtk_signal_connect (OS.GTK_FILE_SELECTION_OK_BUTTON(handle), clicked, okFunc, handle);
- OS.gtk_signal_connect (OS.GTK_FILE_SELECTION_CANCEL_BUTTON(handle), clicked, cancelFunc, handle);
-
- fileName = null;
- fullPath = null;
- filterPath = null;
-
- /* Show the dialog */
- cancel = true;
- OS.gtk_widget_show_now (handle);
- OS.gtk_main ();
-
- destroyCallback.dispose ();
- okCallback.dispose ();
- cancelCallback.dispose ();
-
- /* Return the full path or null */
- if (cancel) return null;
- return fullPath;
+ /*
+ * The only reason this method is not just left out to
+ * fall through to the superclass, is the JavaDoc comment.
+ */
+ return super.open();
}
/**
* Set the initial filename which the dialog will
@@ -284,4 +198,97 @@
public void setFilterPath (String string) {
filterPath = string;
}
+void preset() {
+ if ((style & SWT.MULTI) != 0) {
+ OS.gtk_file_selection_set_select_multiple(handle, true);
+ } else {
+ OS.gtk_file_selection_set_select_multiple(handle, false);
+ }
+ /* Calculate the fully-specified file name and convert to bytes */
+ StringBuffer stringBuffer = new StringBuffer ();
+ if (filterPath == null) {
+ filterPath = "";
+ } else {
+ if (filterPath.length () > 0) {
+ stringBuffer.append (filterPath);
+ if (filterPath.charAt (filterPath.length () - 1) != separator) {
+ stringBuffer.append (separator);
+ }
+ }
+ }
+ if (fileName == null) {
+ fileName = "";
+ } else {
+ stringBuffer.append (fileName);
+ }
+ fullPath = stringBuffer.toString ();
+ byte [] fullPathBytes = Converter.wcsToMbcs (null, fullPath, true);
+ OS.gtk_file_selection_set_filename (handle, fullPathBytes);
+
+ /* Set the extension */
+ if (filterNames == null) filterNames = new String [0];
+ if (filterExtensions == null) filterExtensions = new String [0];
+ if (filterExtensions.length == 1) {
+ String ext = filterExtensions [0];
+ byte [] extBytes = Converter.wcsToMbcs (null, ext, true);
+ OS.gtk_file_selection_complete (handle, extBytes);
+ }
+
+ fileName = null;
+ fullPath = null;
+ filterPath = null;
+}
+
+void interpretOsAnswer(String osAnswer) {
+ if (osAnswer==null) return;
+ int separatorIndex = calculateLastSeparatorIndex(osAnswer);
+ if (separatorIndex+1 == osAnswer.length()) {
+ /*
+ * the selected thing is a directory
+ */
+ answer = null;
+ return;
+ }
+ answer = fullPath = osAnswer;
+ fileName = answer.substring(separatorIndex+1);
+ if ((style&SWT.MULTI) == 0) {
+ fileNames = new String[] {fileName};
+ } else {
+ int namesPtr = OS.gtk_file_selection_get_selections(handle);
+ int namesPtr1 = namesPtr;
+ int[] namePtr = new int[1];
+ OS.memmove(namePtr, namesPtr1, 1);
+ int length=0;
+ while (namePtr[0] != 0) {
+ length++;
+ namesPtr1+=4; // PROBLEM CODE: depend on address size
+ OS.memmove(namePtr, namesPtr1, 1);
+ }
+ fileNames = new String[length];
+ namePtr = new int[length];
+ OS.memmove(namePtr, namesPtr, length*4);
+ for (int i=0; i<length; i++) {
+ /*
+ * NB: We can not use the Converter here, because
+ * the mount charset/iocharset is different than the locale!
+ */
+ int bytesPtr = OS.g_filename_to_utf8(namePtr[i], -1, 0, 0, 0);
+ if (bytesPtr==0) continue;
+ // Careful! The size, not the length of the string
+ byte[] bytes = new byte[OS.strlen(bytesPtr)];
+ OS.memmove(bytes, bytesPtr, bytes.length);
+ // The better way to do it would be:
+ // fileNames[i] = new String(bytes);
+ fileNames[i] = new String(Converter.mbcsToWcs(null, bytes));
+ /*
+ * NB: Unlike other similar functions (e.g., g_convert), the glib
+ * documentation does not say the resulting UTF8 string should be
+ * freed. However, the strdup makes me believe the free is necessary.
+ */
+ OS.g_free(bytesPtr);
+ }
+ OS.g_strfreev(namesPtr);
+ }
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
index aa7eb83..4ed71a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
@@ -100,7 +100,7 @@
int okFunc (int widget, int callData) {
int fontName = OS.gtk_font_selection_dialog_get_font_name (callData);
int length = OS.strlen (fontName);
- byte [] buffer = new byte [length];
+ byte [] buffer = new byte [length + 1];
OS.memmove (buffer, fontName, length);
int fontDesc = OS.pango_font_description_from_string (buffer);
Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
@@ -136,7 +136,7 @@
Font font = new Font (display, fontData);
int fontName = OS.pango_font_description_to_string (font.handle);
int length = OS.strlen (fontName);
- byte [] buffer = new byte [length];
+ byte [] buffer = new byte [length + 1];
OS.memmove (buffer, fontName, length);
font.dispose();
OS.g_free (fontName);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 8051ce9..3becd7a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -25,11 +25,13 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
public class Group extends Composite {
- int clientHandle;
+ int clientHandle, labelHandle;
String text = "";
/**
@@ -75,61 +77,6 @@
return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
}
-void createHandle(int index) {
- state |= HANDLE;
- fixedHandle = OS.gtk_fixed_new ();
- if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (fixedHandle, true);
- handle = OS.gtk_frame_new(null);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- clientHandle = OS.gtk_fixed_new();
- if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add (parentHandle, fixedHandle);
- OS.gtk_container_add (fixedHandle, handle);
- OS.gtk_container_add (handle, clientHandle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_show (clientHandle);
- OS.gtk_widget_show (fixedHandle);
-
- if ((style & SWT.SHADOW_IN) != 0) {
- OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_IN);
- }
- if ((style & SWT.SHADOW_OUT) != 0) {
- OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_OUT);
- }
- if ((style & SWT.SHADOW_ETCHED_IN) != 0) {
- OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_IN);
- }
- if ((style & SWT.SHADOW_ETCHED_OUT) != 0) {
- OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_OUT);
- }
-}
-
-void register () {
- super.register ();
- WidgetTable.put (clientHandle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- clientHandle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- text = null;
-}
-
-void deregister () {
- super.deregister ();
- WidgetTable.remove (clientHandle);
-}
-
-int parentingHandle() {
- return clientHandle;
-}
-
int clientHandle () {
return clientHandle;
}
@@ -178,6 +125,51 @@
return new Rectangle (x-trims[1], y-trims[0], width+trims[1]+trims[2], height+trims[0]+trims[3]);
}
+void createHandle(int index) {
+ state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ handle = OS.gtk_frame_new (null);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ labelHandle = OS.gtk_label_new (null);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ clientHandle = OS.gtk_fixed_new();
+ if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_container_add (handle, clientHandle);
+ OS.gtk_widget_show (handle);
+ OS.gtk_widget_show (clientHandle);
+ OS.gtk_widget_show (fixedHandle);
+
+ OS.gtk_frame_set_label_widget (handle, labelHandle);
+
+ if ((style & SWT.SHADOW_IN) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_IN);
+ }
+ if ((style & SWT.SHADOW_OUT) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_OUT);
+ }
+ if ((style & SWT.SHADOW_ETCHED_IN) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_IN);
+ }
+ if ((style & SWT.SHADOW_ETCHED_OUT) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_OUT);
+ }
+}
+
+void deregister () {
+ super.deregister ();
+ WidgetTable.remove (clientHandle);
+ WidgetTable.remove (labelHandle);
+}
+
+int eventHandle () {
+ return fixedHandle;
+}
+
public Rectangle getClientArea () {
checkWidget();
int width = OS.GTK_WIDGET_WIDTH (clientHandle);
@@ -206,21 +198,34 @@
return text;
}
-void resizeHandle (int width, int height) {
- int topHandle = topHandle ();
- int flags = OS.GTK_WIDGET_FLAGS (topHandle);
- OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_widget_set_size_request (fixedHandle, width, height);
- OS.gtk_widget_set_size_request (handle, width, height);
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.gtk_container_resize_children (parentHandle);
- display.setWarnings (warnings);
- if ((flags & OS.GTK_VISIBLE) == 0) {
- OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
- }
+int parentingHandle() {
+ return clientHandle;
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (clientHandle, this);
+ WidgetTable.put (labelHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ clientHandle = labelHandle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ text = null;
+}
+
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ OS.gtk_widget_modify_font (labelHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ OS.gtk_widget_modify_fg (labelHandle, 0, color);
}
/**
@@ -248,14 +253,9 @@
for (int i=0; i<length; i++) {
if (text [i] == '&') text [i] = '_';
}
- //FIXME - create label widget when frame handle is created
byte [] buffer = Converter.wcsToMbcs (null, text);
- int label = OS.gtk_frame_get_label_widget (handle);
- if (label == 0) {
- OS.gtk_frame_set_label (handle, buffer);
- label = OS.gtk_frame_get_label_widget (handle);
- }
- OS.gtk_label_set_text_with_mnemonic (label, buffer);
+ OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+ OS.gtk_widget_show (labelHandle);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java
index c84e98f..e84cc3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java
@@ -6,114 +6,50 @@
abstract class GtkFileDialog extends Dialog {
String answer;
- int handle, okButtonHandle, cancelButtonHandle;
+ int handle;
char separator = System.getProperty ("file.separator").charAt (0);
GtkFileDialog (Shell parent, int style) {
super (parent, style);
}
-/**
- * Actually create the GtkFileSelection dialog widget.
- * Set the correct title.
- * Get the pointers to the buttons.
- */
-void createGtkDialog() {
- /* create */
+public String open () {
byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
handle = OS.gtk_file_selection_new (titleBytes);
- okButtonHandle = OS.GTK_FILE_SELECTION_OK_BUTTON(handle);
- cancelButtonHandle = OS.GTK_FILE_SELECTION_OK_BUTTON(handle);
-}
-
-/**
- * Deals with the filter.
- */
-void setUpFilter() {
- /*
- // Calculate the fully-specified file name and convert to bytes
- StringBuffer stringBuffer = new StringBuffer ();
- if (filterPath == null) {
- filterPath = "";
- } else {
- if (filterPath.length () > 0) {
- stringBuffer.append (filterPath);
- if (filterPath.charAt (filterPath.length () - 1) != separator) {
- stringBuffer.append (separator);
- }
- }
+ if (parent!=null) {
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
}
- if (fileName == null) {
- fileName = "";
- } else {
- stringBuffer.append (fileName);
- }
- fullPath = stringBuffer.toString ();
- byte [] fullPathBytes = Converter.wcsToMbcs (null, fullPath, true);
- OS.gtk_file_selection_set_filename (handle, fullPathBytes);
-
- // Set the extension
- if (filterNames == null) filterNames = new String [0];
- if (filterExtensions == null) filterExtensions = new String [0];
- if (filterExtensions.length == 1) {
- String ext = filterExtensions [0];
- byte [] extBytes = Converter.wcsToMbcs (null, ext, true);
- OS.gtk_file_selection_complete (handle, extBytes);
- }
- */
-}
-
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the first selected file,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public String open () {
- createGtkDialog();
- setUpFilter();
-
- /* Hook callbacks */
- Callback destroyCallback = new Callback (this, "destroyFunc", 2);
- int destroyFunc = destroyCallback.getAddress ();
- byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
- OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
- byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
- Callback okCallback = new Callback (this, "okFunc", 2);
- int okFunc = okCallback.getAddress ();
- Callback cancelCallback = new Callback (this, "cancelFunc", 2);
- int cancelFunc = cancelCallback.getAddress ();
- OS.gtk_signal_connect (okButtonHandle, clicked, okFunc, handle);
- OS.gtk_signal_connect (cancelButtonHandle, clicked, cancelFunc, handle);
-
- /* Show the dialog */
answer = null;
- OS.gtk_widget_show_now (handle);
- OS.gtk_main ();
-
- destroyCallback.dispose ();
- okCallback.dispose ();
- cancelCallback.dispose ();
+ preset();
+ int response = OS.gtk_dialog_run(handle);
+ if (response == OS.GTK_RESPONSE_OK) {
+ int lpFilename = OS.gtk_file_selection_get_filename (handle);
+ int filenameLength = OS.strlen (lpFilename);
+ byte [] filenameBytes = new byte [filenameLength];
+ OS.memmove (filenameBytes, lpFilename, filenameLength);
+ String osAnswer = new String( Converter.mbcsToWcs (null, filenameBytes) );
+ interpretOsAnswer(osAnswer);
+ }
+ OS.gtk_widget_destroy(handle);
return answer;
}
-abstract boolean getAnswer();
+/*
+ * Subclasses must implement this to set things like
+ * the filter or the initial selection, just before opening
+ * the dialog.
+ */
+abstract void preset();
-String getFileNameFromOS() {
- int lpFilename = OS.gtk_file_selection_get_filename (handle);
- int filenameLength = OS.strlen (lpFilename);
- byte [] filenameBytes = new byte [filenameLength];
- OS.memmove (filenameBytes, lpFilename, filenameLength);
- return new String (Converter.mbcsToWcs (null, filenameBytes));
-}
+/*
+ * Subclasses must implement this to set the right state
+ * of the dialog just after its loop returned.
+ */
+abstract void interpretOsAnswer(String osAnswer);
+/*
+ * This is just a convenience function to help share code between subclasses
+ */
int calculateLastSeparatorIndex(String x) {
int separatorIndex = x.indexOf (separator);
int index = separatorIndex;
@@ -123,24 +59,4 @@
}
return separatorIndex;
}
-
-
-/*
- * The callback functions.
- */
-int okFunc (int widget, int callData) {
- if (getAnswer()) OS.gtk_widget_destroy (callData);
- return 0;
}
-int cancelFunc (int widget, int callData) {
- answer = null;
- OS.gtk_widget_destroy (callData);
- return 0;
-}
-int destroyFunc (int widget, int callData) {
- OS.gtk_main_quit ();
- return 0;
-}
-
-}
-
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index d5d5cf2..603d991 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -23,6 +23,10 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of SHADOW_IN and SHADOW_OUT may be specified. Only
+ * one of HORIZONTAL and VERTICAL may be specified. Only one of CENTER,
+ * LEFT and RIGHT may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -70,35 +74,73 @@
return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ if ((style & SWT.SEPARATOR) != 0) {
+ if ((style & SWT.HORIZONTAL) != 0) {
+ if (wHint == SWT.DEFAULT) wHint = DEFAULT_WIDTH;
+ } else {
+ if (hHint == SWT.DEFAULT) hHint = DEFAULT_HEIGHT;
+ }
+ }
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ int labelWidth = OS.GTK_WIDGET_WIDTH (handle);
+ int labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
+ GtkRequisition requisition = new GtkRequisition ();
+ if (frameHandle != 0) {
+ OS.gtk_widget_set_size_request (frameHandle, -1, -1);
+ /*
+ * Temporary code.
+ * If the wHint is set, the GtkLabel will believe it has
+ * more width at its disposal than it actually does (by a few pixels).
+ * In other words, the frame width is included in the hint and
+ * it shouldn't. It is possible (but unlikely) that this will
+ * cause the label to answer the wrong (smaller) height.
+ */
+ OS.gtk_widget_set_size_request (handle, wHint, hHint);
+ OS.gtk_widget_size_request (frameHandle, requisition);
+ OS.gtk_widget_set_size_request (frameHandle, width, height);
+ } else {
+ OS.gtk_widget_set_size_request (handle, wHint, hHint);
+ OS.gtk_widget_size_request (handle, requisition);
+ }
+ OS.gtk_widget_set_size_request (handle, labelWidth, labelHeight);
+ width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+ height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+ return new Point (width, height);
+}
+
void createHandle (int index) {
state |= HANDLE;
fixedHandle = OS.gtk_fixed_new ();
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_fixed_set_has_window (fixedHandle, true);
- frameHandle = OS.gtk_frame_new(null);
- if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
if ((style & SWT.SEPARATOR) != 0) {
if ((style & SWT.HORIZONTAL)!= 0) {
- handle = OS.gtk_hseparator_new();
+ handle = OS.gtk_hseparator_new ();
} else {
- handle = OS.gtk_vseparator_new();
+ handle = OS.gtk_vseparator_new ();
}
} else {
handle = OS.gtk_label_new (null);
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-
int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add(parentHandle, fixedHandle);
- OS.gtk_container_add(fixedHandle, frameHandle);
- OS.gtk_container_add(frameHandle, handle);
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ if ((style & SWT.BORDER) != 0) {
+ frameHandle = OS.gtk_frame_new (null);
+ if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (fixedHandle, frameHandle);
+ OS.gtk_container_add (frameHandle, handle);
+ OS.gtk_widget_show (frameHandle);
+ // CHECK THEME
+ OS.gtk_frame_set_shadow_type (frameHandle, OS.GTK_SHADOW_ETCHED_IN);
+ } else {
+ OS.gtk_container_add (fixedHandle, handle);
+ }
OS.gtk_widget_show (fixedHandle);
- OS.gtk_widget_show (frameHandle);
OS.gtk_widget_show (handle);
-
- // CHECK THEME
- int type = (style & SWT.BORDER) != 0 ? OS.GTK_SHADOW_ETCHED_IN : OS.GTK_SHADOW_NONE;
- OS.gtk_frame_set_shadow_type (frameHandle, type);
if ((style & SWT.SEPARATOR) != 0) return;
if ((style & SWT.WRAP) != 0) OS.gtk_label_set_line_wrap (handle, true);
if ((style & SWT.LEFT) != 0) {
@@ -123,43 +165,13 @@
text = "";
}
-void register () {
- super.register ();
- WidgetTable.put (frameHandle, this);
-}
-
void deregister () {
super.deregister ();
- WidgetTable.remove (frameHandle);
+ if (frameHandle != 0) WidgetTable.remove (frameHandle);
}
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
- text = null;
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- frameHandle = 0;
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- if ((style&SWT.SEPARATOR) != 0) {
- int w, h;
- if ((style&SWT.HORIZONTAL)!= 0) {
- w = 45;
- h = 6;
- } else { // vertical
- w = 6;
- h = 45;
- }
- if (wHint != SWT.DEFAULT) w = wHint;
- if (hHint != SWT.DEFAULT) h = hHint;
- return new Point(w,h);
- }
- return super.computeSize(wHint, hHint, changed);
+int eventHandle () {
+ return fixedHandle;
}
/**
@@ -223,6 +235,58 @@
return text;
}
+void register () {
+ super.register ();
+ if (frameHandle != 0) WidgetTable.put (frameHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ frameHandle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+ text = null;
+}
+
+void resizeHandle (int width, int height) {
+ /*
+ * Bug in GTK. For some reason, when the label is
+ * wrappable and the frame is resized, it does not
+ * cause the label to be wrapped. The fix is to
+ * determine the size that will wrap the label
+ * and expilictly set that size to force the label
+ * to wrap.
+ *
+ * This part of the fix causes the label to be
+ * resized to the preferred size but it still
+ * won't draw properly.
+ */
+ if (frameHandle != 0) {
+ OS.gtk_widget_set_size_request (frameHandle, width, height);
+ OS.gtk_widget_set_size_request (handle, -1, -1);
+ }
+ super.resizeHandle (width, height);
+ /*
+ * Bug in GTK. For some reason, when the label is
+ * wrappable and the frame is resized, it does not
+ * cause the label to be wrapped. The fix is to
+ * determine the size that will wrap the label
+ * and expilictly set that size to force the label
+ * to wrap.
+ *
+ * This part of the fix forces the label to be
+ * resized so that it will draw wrapped.
+ */
+ if (frameHandle != 0) {
+ int labelWidth = OS.GTK_WIDGET_WIDTH (handle);
+ int labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
+ OS.gtk_widget_set_size_request (handle, labelWidth, labelHeight);
+ }
+}
+
/**
* Controls how text and images will be displayed in the receiver.
* The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
@@ -286,7 +350,11 @@
} else {
handle = OS.gtk_pixmap_new (image.pixmap, image.mask);
}
- OS.gtk_container_add (frameHandle, handle);
+ if ((style & SWT.BORDER) != 0) {
+ OS.gtk_container_add (frameHandle, handle);
+ } else {
+ OS.gtk_container_add (fixedHandle, handle);
+ }
WidgetTable.put (handle, this);
int alignment = style & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
switch (alignment) {
@@ -294,6 +362,9 @@
case SWT.CENTER: OS.gtk_misc_set_alignment (handle, 0.5f, 0.0f); break;
case SWT.RIGHT: OS.gtk_misc_set_alignment (handle, 1.0f, 0.0f); break;
}
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ resizeHandle (width, height);
OS.gtk_widget_show (handle);
}
@@ -325,7 +396,11 @@
WidgetTable.remove (handle);
OS.gtk_widget_destroy (handle);
handle = OS.gtk_label_new (null);
- OS.gtk_container_add (frameHandle, handle);
+ if ((style & SWT.BORDER) != 0) {
+ OS.gtk_container_add (frameHandle, handle);
+ } else {
+ OS.gtk_container_add (fixedHandle, handle);
+ }
WidgetTable.put (handle, this);
int alignment = style & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
switch (alignment) {
@@ -342,6 +417,10 @@
OS.gtk_label_set_justify (handle, OS.GTK_JUSTIFY_RIGHT);
break;
}
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ resizeHandle (width, height);
+ OS.gtk_widget_show (handle);
}
int length = string.length ();
char [] text = new char [length + 1];
@@ -353,22 +432,4 @@
OS.gtk_label_set_text_with_mnemonic (handle, buffer);
}
-void resizeHandle (int width, int height) {
- int topHandle = topHandle ();
- int flags = OS.GTK_WIDGET_FLAGS (topHandle);
- OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
- OS.gtk_widget_set_size_request (fixedHandle, width, height);
- OS.gtk_widget_set_size_request (frameHandle, width, height);
- //FIXME - causes scrollbar problems when button child of table
- int parentHandle = parent.parentingHandle ();
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.gtk_container_resize_children (parentHandle);
- display.setWarnings (warnings);
- if ((flags & OS.GTK_VISIBLE) == 0) {
- OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
- }
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index a62deab..ec9b2b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -24,6 +24,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -185,6 +187,10 @@
OS.gtk_widget_show (scrolledHandle);
OS.gtk_widget_show (handle);
+ /* Force row_height to be computed */
+ OS.gtk_clist_set_row_height (handle, 0);
+
+ /* Single or Multiple Selection */
int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED :OS.GTK_SELECTION_BROWSE;
OS.gtk_clist_set_selection_mode (handle, mode);
@@ -202,6 +208,7 @@
super.hookEvents();
signal_connect (handle, "select_row", SWT.Selection, 5);
signal_connect (handle, "unselect_row", SWT.Selection, 5);
+ signal_connect (handle, "event_after", 0, 3);
}
public Point computeSize (int wHint, int hHint, boolean changed) {
@@ -430,9 +437,9 @@
*/
public String [] getSelection () {
checkWidget();
- GtkCList widget = new GtkCList (handle);
- int list = widget.selection;
- if (list==0) return new String[0];
+ GtkCList clist = new GtkCList (handle);
+ int list = clist.selection;
+ if (list == 0) return new String [0];
int length = OS.g_list_length (list);
String [] items = new String [length];
int [] buffer = new int [1];
@@ -463,8 +470,9 @@
*/
public int getSelectionCount () {
checkWidget();
- GtkCList widget = new GtkCList (handle);
- return OS.g_list_length (widget.selection);
+ GtkCList clist = new GtkCList (handle);
+ if (clist.selection == 0) return 0;
+ return OS.g_list_length (clist.selection);
}
/**
@@ -484,9 +492,9 @@
public int getSelectionIndex () {
checkWidget();
GtkCList clist = new GtkCList (handle);
- int list = clist.selection;
- if (OS.g_list_length (list) == 0) return -1;
- return OS.g_list_nth_data (list, 0);
+ if (clist.selection == 0) return 0;
+ if (OS.g_list_length (clist.selection) == 0) return -1;
+ return OS.g_list_nth_data (clist.selection, 0);
}
/**
@@ -509,8 +517,9 @@
*/
public int [] getSelectionIndices () {
checkWidget();
- GtkCList widget = new GtkCList (handle);
- int list = widget.selection;
+ GtkCList clist = new GtkCList (handle);
+ int list = clist.selection;
+ if (list == 0) return new int [0];
int length = OS.g_list_length (list);
int [] indices = new int [length];
for (int i=0; i<length; i++) {
@@ -624,52 +633,107 @@
return clist.clist_window;
}
-int processMouseDown (int callData, int arg1, int int2) {
- if ((style & SWT.MULTI) != 0) selected = true;
- return super.processMouseDown (callData, arg1, int2);
-}
-
-int processMouseUp (int callData, int arg1, int int2) {
- int result = super.processMouseUp (callData, arg1, int2);
- if ((style & SWT.MULTI) != 0) {
- /*
- * Feature in GTK. When an item is reselected, GTK
- * does not issue notification. The fix is to detect
- * that the mouse was released over a selected item when
- * no selection signal was set and issue a fake selection
- * event.
- */
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- int x = (int) (px[0]), y = (int) (py[0]);
- int [] row = new int [1], column = new int [1];
- int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
- if (code != 0) {
- GtkCList clist = new GtkCList (handle);
- if (selected && clist.selection != 0) {
- int list = clist.selection;
- int length = OS.g_list_length (list);
- for (int i=0; i<length; i++) {
- if (row [0] == OS.g_list_nth_data (list, i)) {
- postEvent (SWT.Selection);
+int processEvent (int eventNumber, int int0, int int1, int int2) {
+ if (eventNumber == 0) {
+ switch (OS.GDK_EVENT_TYPE (int0)) {
+ case OS.GDK_BUTTON_PRESS:
+ case OS.GDK_2BUTTON_PRESS: {
+ if ((style & SWT.MULTI) != 0) selected = true;
+ break;
+ }
+ case OS.GDK_BUTTON_RELEASE: {
+ if ((style & SWT.MULTI) != 0) {
+ /*
+ * Feature in GTK. When an item is reselected, GTK
+ * does not issue notification. The fix is to detect
+ * that the mouse was released over a selected item when
+ * no selection signal was set and issue a fake selection
+ * event.
+ */
+ double[] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (int0, px, py);
+ int x = (int) (px[0]), y = (int) (py[0]);
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, x, y, row, column) != 0) {
+ GtkCList clist = new GtkCList (handle);
+ if (selected && clist.selection != 0) {
+ int list = clist.selection;
+ int length = OS.g_list_length (list);
+ for (int i=0; i<length; i++) {
+ if (row [0] == OS.g_list_nth_data (list, i)) {
+ postEvent (SWT.Selection);
+ }
+ }
+ }
}
+ selected = false;
}
+ break;
}
}
- selected = false;
+ return 1;
+ }
+ return super.processEvent (eventNumber, int0, int1, int2);
+}
+
+int processKeyDown (int callData, int arg1, int int2) {
+ int result = super.processKeyDown (callData, arg1, int2);
+ /*
+ * Feature in GTK. When an item is reselected using
+ * the space bar, GTK does not issue notification.
+ * The fix is to ignore the notification that is sent
+ * by GTK and look for the space key.
+ */
+ int length = OS.gdk_event_key_get_length (callData);
+ if (length == 1) {
+ int string = OS.gdk_event_key_get_string (callData);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, string, length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ switch (unicode [0]) {
+ case ' ':
+ GtkCList clist = new GtkCList (handle);
+ if (clist.focus_row != -1) {
+ postEvent (SWT.Selection);
+ }
+ break;
+ }
}
return result;
}
+int processKeyUp (int callData, int arg1, int int2) {
+ int result = super.processKeyUp (callData, arg1, int2);
+ /*
+ * Feature in GTK. For some reason, when the selection
+ * is extended using the shift key, the notification is
+ * issued when the widget loses focus. The fix is to force
+ * the notification to be issued by temporarily losing and
+ * gaining focus every time the shift key is released.
+ */
+ int keyval = OS.gdk_event_key_get_keyval (callData);
+ switch (keyval) {
+ case OS.GDK_Shift_L:
+ case OS.GDK_Shift_R:
+ OS.gtk_widget_grab_focus (scrolledHandle);
+ OS.gtk_widget_grab_focus (handle);
+ }
+ return result;
+}
+
+
int processSelection (int int0, int int1, int int2) {
GtkCList clist = new GtkCList (handle);
if (int0 != clist.focus_row) return 0;
if ((style & SWT.MULTI) != 0) selected = false;
- int type = SWT.Selection;
- if (int2 != 0)
- if (OS.GDK_EVENT_TYPE(int2) == OS.GDK_2BUTTON_PRESS) type = SWT.DefaultSelection;
- postEvent (type);
+ int eventType = SWT.Selection;
+ if (int2 != 0) {
+ int type = OS.GDK_EVENT_TYPE (int2);
+ if (type == OS.GDK_2BUTTON_PRESS) {
+ eventType = SWT.DefaultSelection;
+ }
+ }
+ postEvent (eventType);
return 0;
}
@@ -912,6 +976,11 @@
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
}
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ OS.gtk_widget_modify_base (handle, 0, color);
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -986,6 +1055,15 @@
showSelection ();
}
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ if (redraw) {
+ OS.gtk_clist_thaw (handle);
+ } else {
+ OS.gtk_clist_freeze (handle);
+ }
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected if first cleared, then the new items are selected.
@@ -1106,9 +1184,9 @@
public void showSelection () {
checkWidget();
GtkCList clist = new GtkCList (handle);
- int list = clist.selection;
- if (OS.g_list_length (list) == 0) return;
- int index = OS.g_list_nth_data (list, 0);
+ if (clist.selection == 0) return;
+ if (OS.g_list_length (clist.selection) == 0) return;
+ int index = OS.g_list_nth_data (clist.selection, 0);
int visibility = OS.gtk_clist_row_is_visible (handle, index);
if (visibility == OS.GTK_VISIBILITY_FULL) return;
//BUG IN GTK - doesn't scroll correctly before shell open
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 029f509..ad1ce47 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -20,7 +20,9 @@
* <dt><b>Events:</b></dt>
* <dd>Help, Hide, Show </dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -193,9 +195,10 @@
*/
public MenuItem getItem (int index) {
checkWidget();
- int list = OS.gtk_container_children (handle);
+ int list = OS.gtk_container_get_children (handle);
if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
int data = OS.g_list_nth_data (list, index);
+ OS.g_list_free (list);
if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
return (MenuItem) WidgetTable.get (data);
}
@@ -212,8 +215,11 @@
*/
public int getItemCount () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- return list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return 0;
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ return itemCount;
}
/**
@@ -234,13 +240,15 @@
*/
public MenuItem [] getItems () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- int count = list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return new MenuItem [0];
+ int count = OS.g_list_length (list);
MenuItem [] items = new MenuItem [count];
for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
items [i] = (MenuItem) WidgetTable.get (data);
}
+ OS.g_list_free (list);
return items;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index 2a77a47..51cf33b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -20,7 +20,10 @@
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- *<p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -486,7 +489,7 @@
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int accel_group = parent.getShell ().accelGroup;
- if (accelerator != 0) removeAccelerator (accel_group);
+ if (this.accelerator != 0) removeAccelerator (accel_group);
this.accelerator = accelerator;
if (accelerator != 0) addAccelerator (accel_group);
}
@@ -599,8 +602,9 @@
for (int i=0; i<length; i++) {
if (text [i] == '&') text [i] = '_';
}
- int list = OS.gtk_container_children (handle);
+ int list = OS.gtk_container_get_children (handle);
int label = OS.g_list_nth_data (list, 0);
+ OS.g_list_free (list);
byte [] buffer = Converter.wcsToMbcs (null, text);
OS.gtk_label_set_text_with_mnemonic (label, buffer);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
index 28bc6ad..d18416b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
@@ -24,6 +24,9 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -147,7 +150,8 @@
public int open () {
createHandle();
createMessage(); // includes configuring
- createActionButtons();
+ Callback okCallback = new Callback (this, "activateFunc", 2);
+ createActionButtons(okCallback);
state=0;
Callback destroyCallback = new Callback (this, "destroyFunc", 2);
int destroyFunc = destroyCallback.getAddress ();
@@ -156,6 +160,8 @@
showHandle();
while(state==0) OS.gtk_main_iteration();
OS.gtk_widget_destroy(handle);
+ destroyCallback.dispose();
+ okCallback.dispose();
return state;
}
@@ -175,16 +181,16 @@
if (label==0) error(SWT.ERROR_NO_HANDLES);
OS.gtk_box_pack_start (OS.GTK_DIALOG_VBOX(handle), label, true, true, 5); // FIXME should we use container_add??
}
-private void createActionButtons() {
- if ((style & SWT.OK) != 0) buttonOK = createButton("OK");
- if ((style & SWT.CANCEL) != 0) buttonCANCEL = createButton("CANCEL");
+private void createActionButtons(Callback callback) {
+ if ((style & SWT.OK) != 0) buttonOK = createButton("OK", callback);
+ if ((style & SWT.CANCEL) != 0) buttonCANCEL = createButton("CANCEL", callback);
- if ((style & SWT.YES) != 0) buttonYES = createButton("YES");
- if ((style & SWT.NO) != 0) buttonNO = createButton("NO");
+ if ((style & SWT.YES) != 0) buttonYES = createButton("YES", callback);
+ if ((style & SWT.NO) != 0) buttonNO = createButton("NO", callback);
- if ((style & SWT.ABORT) != 0) buttonABORT = createButton("ABORT");
- if ((style & SWT.RETRY) != 0) buttonRETRY = createButton("RETRY");
- if ((style & SWT.IGNORE) != 0) buttonIGNORE = createButton("IGNORE");
+ if ((style & SWT.ABORT) != 0) buttonABORT = createButton("ABORT", callback);
+ if ((style & SWT.RETRY) != 0) buttonRETRY = createButton("RETRY", callback);
+ if ((style & SWT.IGNORE) != 0) buttonIGNORE = createButton("IGNORE", callback);
}
private void showHandle() {
OS.gtk_widget_show_all (handle);
@@ -202,19 +208,14 @@
OS.gtk_window_set_title(handle, bytes);
}
}
-int createButton(String buttonName) {
+int createButton(String buttonName, Callback callback) {
byte[] bytes = Converter.wcsToMbcs (null, buttonName, true);
int buttonHandle = OS.gtk_button_new_with_label(bytes);
OS.gtk_box_pack_start (OS.GTK_DIALOG_ACTION_AREA(handle), buttonHandle, true, true, 0);
- hookSelection(buttonHandle);
- return buttonHandle;
-}
-private void hookSelection(int h) {
byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
-
- Callback okCallback = new Callback (this, "activateFunc", 2);
- int okFunc = okCallback.getAddress ();
- OS.gtk_signal_connect (h, clicked, okFunc, h);
+ int function = callback.getAddress ();
+ OS.gtk_signal_connect (buttonHandle, clicked, function, buttonHandle);
+ return buttonHandle;
}
private static int checkStyle (int style) {
int mask = (SWT.YES | SWT.NO | SWT.OK | SWT.CANCEL | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
index 481e7df..d565e2b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
@@ -21,6 +21,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 4eb5c23..1c5184c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -22,14 +22,15 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
*/
public class Sash extends Control {
boolean dragging;
- int originX, originY;
- int lastX, lastY; /* relative to the receiver, not the parent */
+ int startX, startY, lastX, lastY;
int cursor;
/**
@@ -64,34 +65,6 @@
super (parent, checkStyle (style));
}
-void createHandle (int index) {
- state |= HANDLE;
- handle = OS.gtk_drawing_area_new();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add (parentHandle, handle);
- OS.gtk_widget_show (handle);
- int type = (style & SWT.VERTICAL) != 0 ? OS.GDK_SB_H_DOUBLE_ARROW:OS.GDK_SB_V_DOUBLE_ARROW;
- cursor = OS.gdk_cursor_new (type);
- OS.gtk_widget_realize (handle);
- int window = OS.GTK_WIDGET_WINDOW (handle);
- OS.gdk_window_set_cursor (window, cursor);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int border = getBorderWidth ();
- int width = border * 2, height = border * 2;
- if ((style & SWT.HORIZONTAL) != 0) {
- width += DEFAULT_WIDTH; height += 3;
- } else {
- width += 3; height += DEFAULT_HEIGHT;
- }
- if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
- if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
- return new Point (width, height);
-}
-
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -125,6 +98,159 @@
addListener (SWT.MouseDoubleClick,typedListener);
}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += DEFAULT_WIDTH; height += 3;
+ } else {
+ width += 3; height += DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ handle = OS.gtk_drawing_area_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, handle);
+ OS.gtk_widget_show (handle);
+ int type = (style & SWT.VERTICAL) != 0 ? OS.GDK_SB_H_DOUBLE_ARROW : OS.GDK_SB_V_DOUBLE_ARROW;
+ cursor = OS.gdk_cursor_new (type);
+ OS.gtk_widget_realize (handle);
+ int window = OS.GTK_WIDGET_WINDOW (handle);
+ OS.gdk_window_set_cursor (window, cursor);
+}
+
+void drawBand (int x, int y, int width, int height) {
+ int window = OS.GTK_WIDGET_WINDOW (parent.paintHandle());
+ if (window == 0) return;
+ byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
+ int stipplePixmap = OS.gdk_bitmap_create_from_data (window, bits, 8, 8);
+ int gc = OS.gdk_gc_new (window);
+ int colormap = OS.gdk_colormap_get_system();
+ GdkColor color = new GdkColor ();
+ OS.gdk_color_white (colormap, color);
+ OS.gdk_gc_set_foreground (gc, color);
+ OS.gdk_gc_set_stipple (gc, stipplePixmap);
+ OS.gdk_gc_set_subwindow (gc, OS.GDK_INCLUDE_INFERIORS);
+ OS.gdk_gc_set_fill (gc, OS.GDK_STIPPLED);
+ OS.gdk_gc_set_function (gc, OS.GDK_XOR);
+ OS.gdk_draw_rectangle (window, gc, 1, x, y, width, height);
+ OS.g_object_unref (stipplePixmap);
+ OS.g_object_unref (gc);
+}
+
+int processMouseDown (int callData, int int1, int int2) {
+ super.processMouseDown (callData, int1, int2);
+ int button = OS.gdk_event_button_get_button (callData);
+ if (button != 1) return 0;
+ double[] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (callData, px, py);
+ startX = (int)px [0]; startY = (int) py [0];
+ int border = 0;
+ int x = OS.GTK_WIDGET_X (handle);
+ int y = OS.GTK_WIDGET_Y (handle);
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
+ lastX = x - border; lastY = y - border;
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = OS.gdk_event_get_time (callData);
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return 0;
+ if (event.doit) {
+ dragging = true;
+// OS.XmUpdateDisplay (handle);
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ return 0;
+}
+
+int processMouseMove (int callData, int int1, int int2) {
+ super.processMouseMove (callData, int1, int2);
+ int [] state = new int [1];
+ OS.gdk_event_get_state (callData, state);
+ if (!dragging || (state [0] & OS.GDK_BUTTON1_MASK) == 0) return 0;
+ int x = OS.GTK_WIDGET_X (handle);
+ int y = OS.GTK_WIDGET_Y (handle);
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
+ int border = 0, parentBorder = 0;
+ int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
+ int parentHeight = OS.GTK_WIDGET_WIDTH (parent.handle);
+ double[] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (callData, px, py);
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, (int)px [0] + x - startX - parentBorder), parentWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, (int)py[0] + y - startY - parentBorder), parentHeight - height);
+ }
+ if (newX == lastX && newY == lastY) return 0;
+ drawBand (lastX, lastY, width, height);
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = OS.gdk_event_get_time (callData);
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return 0;
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+// OS.XmUpdateDisplay (handle);
+ drawBand (lastX, lastY, width, height);
+ }
+ return 0;
+}
+
+int processMouseUp (int callData, int int1, int int2) {
+ super.processMouseUp (callData, int1, int2);
+ int button = OS.gdk_event_button_get_button(callData);
+ if (button != 1) return 0;
+ if (!dragging) return 0;
+ dragging = false;
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.time = OS.gdk_event_get_time (callData);
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ drawBand (lastX, lastY, width, height);
+ sendEvent (SWT.Selection, event);
+ /* widget could be disposed here */
+ return 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (cursor != 0) OS.gdk_cursor_destroy (cursor);
+ cursor = 0;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -150,149 +276,4 @@
eventTable.unhook (SWT.MouseDoubleClick,listener);
}
-int processMouseDown (int callData, int arg1, int int2) {
- super.processMouseDown (callData,arg1,int2);
- if (OS.gdk_event_button_get_button(callData) != 1) return 0;
-
- originX = OS.GTK_WIDGET_X(handle);
- originY = OS.GTK_WIDGET_Y(handle);
- lastX = 0;
- lastY = 0;
-
- /* The event must be sent because its doit flag is used. */
- Event event = new Event ();
- event.detail = SWT.DRAG;
- event.time = OS.gdk_event_get_time(callData);
- event.x = originX;
- event.y = originY;
- event.width = OS.GTK_WIDGET_WIDTH (handle);
- event.height = OS.GTK_WIDGET_HEIGHT (handle);
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
- sendEvent (SWT.Selection, event);
- if (isDisposed ()) return 0;
- if (event.doit) {
- dragging = true;
- drawBand (originX, originY, event.width, event.height);
- }
- return 0;
-}
-
-int processMouseMove (int callData, int arg1, int int2) {
- super.processMouseMove (callData, arg1, int2);
- if (!dragging) return 0;
-
- /* Get the coordinates where the event happened, relative to the receiver */
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- int x = (int)(px[0]);
- int y = (int)(py[0]);
-
- int width = OS.GTK_WIDGET_WIDTH(handle);
- int height = OS.GTK_WIDGET_HEIGHT(handle);
-
- if ((style & SWT.VERTICAL) != 0) {
- /* Erase the old one */
- int oldDrawX = originX + lastX;
- drawBand(oldDrawX, originY, width, height);
- /* Draw the new */
- int drawX = originX + x;
- drawBand(drawX, originY, width, height);
- lastX = x;
- } else {
- /* Erase the old one */
- int oldDrawY = originY + lastY;
- drawBand(originX, oldDrawY, width, height);
- /* Draw the new */
- int drawY = originY + y;
- drawBand(originX, drawY, width, height);
- lastY = y;
- }
- return 0;
-}
-
-int processMouseUp (int callData, int arg1, int int2) {
- super.processMouseUp(callData, arg1,int2);
- int button = OS.gdk_event_button_get_button(callData);
- if (button != 1) return 0;
- if (!dragging) return 0;
- int width = OS.GTK_WIDGET_WIDTH(handle);
- int height = OS.GTK_WIDGET_HEIGHT(handle);
- int x = lastX + originX;
- int y = lastY + originY;
- drawBand(x, y, width, height);
- dragging = false;
-
- Event event = new Event ();
- event.time = OS.gdk_event_get_time(callData);
- event.x = x; event.y = y;
- event.width = width; event.height = height;
- sendEvent (SWT.Selection, event);
- return 0;
-}
-
-int processMouseEnter (int callData, int arg1, int int2) {
- int width = OS.GTK_WIDGET_WIDTH (handle);
- int height = OS.GTK_WIDGET_HEIGHT (handle);
- lastX = OS.GTK_WIDGET_X(handle); lastY = OS.GTK_WIDGET_Y(handle);
- Event event = new Event ();
- event.time = OS.gdk_event_get_time(callData);
- event.detail = SWT.DRAG;
- event.x = lastX; event.y = lastY;
- event.width = width; event.height = height;
- Cursor arrowCursor;
- if ((style & SWT.HORIZONTAL) != 0) {
- arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_SIZENS);
- } else {
- arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_SIZEWE);
- }
- setCursor(arrowCursor);
- sendEvent (SWT.Selection, event);
- return 0;
-}
-
-int processMouseExit (int callData, int arg1, int int2) {
- int width = OS.GTK_WIDGET_WIDTH (handle);
- int height = OS.GTK_WIDGET_HEIGHT (handle);
- Event event = new Event ();
- event.time = OS.gdk_event_get_time(callData);
- event.x = lastX; event.y = lastY;
- event.width = width; event.height = height;
- sendEvent (SWT.MouseExit, event);
- return 0;
-
-}
-
-void drawBand (int x, int y, int width, int height) {
- Display display= parent.getDisplay ();
- if (display == null) return;
- int window = OS.GTK_WIDGET_WINDOW(parent.paintHandle());
- if (window == 0) return;
- byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
- int stipplePixmap = OS.gdk_bitmap_create_from_data (window, bits, 8, 8);
- int gc = OS.gdk_gc_new(window);
- Color color = getDisplay().getSystemColor(SWT.COLOR_WHITE);
- OS.gdk_gc_set_foreground(gc, color.handle);
- OS.gdk_gc_set_stipple(gc, stipplePixmap);
- OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
- OS.gdk_gc_set_fill(gc, OS.GDK_STIPPLED);
- OS.gdk_gc_set_function(gc, OS.GDK_XOR);
- OS.gdk_draw_rectangle(window, gc, 1, x, y, width, height);
- OS.g_object_unref(stipplePixmap);
- OS.g_object_unref(gc);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (cursor != 0) OS.gdk_cursor_destroy (cursor);
- cursor = 0;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
index 69ff6e0..91068c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
@@ -22,6 +22,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index a8f0985..f9bd389 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -64,7 +64,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see Slider
* @see Scrollable
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index a74d9dd..6896e22 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -186,6 +186,11 @@
return verticalBar;
}
+boolean isTabGroup() {
+ if ((state&CANVAS) != 0) return true;
+ return super.isTabGroup();
+}
+
void register () {
super.register ();
if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
@@ -213,18 +218,38 @@
int topHandle = topHandle ();
int flags = OS.GTK_WIDGET_FLAGS (topHandle);
OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
- int parentHandle = parent.parentingHandle ();
if (fixedHandle != 0) {
OS.gtk_widget_set_size_request (fixedHandle, width, height);
}
+ /*
+ * Feature in GTK. Some widgets do not allocate the size
+ * of their internal children in gtk_widget_size_allocate().
+ * Instead this is done in gtk_widget_size_request(). This
+ * means that the client area of the widget is not correct.
+ * The fix is to call gtk_widget_size_request() (and throw
+ * the results away).
+ *
+ * Note: The following widgets rely on this feature:
+ * GtkScrolledWindow
+ * GtkNotebook
+ * GtkFrame
+ * GtkCombo
+ */
+ GtkRequisition requisition = new GtkRequisition ();
if (scrolledHandle != 0) {
OS.gtk_widget_set_size_request (scrolledHandle, width, height);
+ OS.gtk_widget_size_request (scrolledHandle, requisition);
} else {
OS.gtk_widget_set_size_request (handle, width, height);
+ OS.gtk_widget_size_request (handle, requisition);
}
+ /*
+ * Force the container to allocate the size of its children.
+ */
Display display = getDisplay ();
boolean warnings = display.getWarnings ();
display.setWarnings (false);
+ int parentHandle = parent.parentingHandle ();
OS.gtk_container_resize_children (parentHandle);
display.setWarnings (warnings);
if ((flags & OS.GTK_VISIBLE) == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 53b3177..db7ab2b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -84,6 +84,9 @@
* </dl>
* </p>
* <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
@@ -97,6 +100,7 @@
int accelGroup;
boolean hasFocus;
int oldX, oldY, oldWidth, oldHeight;
+ Control lastActive;
/**
* Constructs a new instance of this class. This is equivalent
@@ -363,52 +367,74 @@
if (event.doit && !isDisposed ()) dispose ();
}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ Rectangle trim = super.computeTrim (x, y, width, height);
+ int trimWidth = trimWidth (), trimHeight = trimHeight ();
+ trim.x -= trimWidth / 2; trim.y -= trimHeight - (trimWidth / 2);
+ trim.width += trimWidth; trim.height += trimHeight;
+ return trim;
+}
+
void createHandle (int index) {
state |= HANDLE | CANVAS;
- int type = true || parent == null ? OS.GTK_WINDOW_TOPLEVEL : OS.GTK_WINDOW_DIALOG;
+ int type = (style & SWT.NO_TRIM) == 0 ? OS.GTK_WINDOW_TOPLEVEL : OS.GTK_WINDOW_POPUP;
shellHandle = OS.gtk_window_new (type);
if (shellHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- OS.gtk_window_set_policy (shellHandle, 1, 1, 0);
- OS.gtk_window_set_title (shellHandle, new byte [1]);
if (parent != null) {
OS.gtk_window_set_transient_for (shellHandle, parent.topHandle ());
+ OS.gtk_window_set_destroy_with_parent(shellHandle, true);
}
+ // The following line represents the approach we used in 1.2.
+ // The set_policy call is deprecated, and we achieve the same effect
+ // with the two lines that follow.
+ // OS.gtk_window_set_policy (shellHandle, 1, 1, 0);
+ OS.gtk_widget_set_size_request(shellHandle, 0, 0);
+ OS.gtk_window_set_resizable(shellHandle, true);
createScrolledHandle (shellHandle);
-
- boolean modal = (style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0;
- OS.gtk_window_set_modal (shellHandle, modal);
- int decorations = 0;
- if ((style & SWT.NO_TRIM) == 0) {
- if ((style & SWT.MIN) != 0) decorations |= OS.GDK_DECOR_MINIMIZE;
- if ((style & SWT.MAX) != 0) decorations |= OS.GDK_DECOR_MAXIMIZE;
- if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_RESIZEH;
- if ((style & SWT.BORDER) != 0) decorations |= OS.GDK_DECOR_BORDER;
- if ((style & SWT.MENU) != 0) decorations |= OS.GDK_DECOR_MENU;
- if ((style & SWT.TITLE) != 0) decorations |= OS.GDK_DECOR_TITLE;
- /*
- * Under some Window Managers (Sawmill), in order
- * to get any border at all from the window manager it is necessary
- * to set GDK_DECOR_BORDER. The fix is to force these bits when any
- * kind of border is requested.
- */
- if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_BORDER;
- }
+ /*
+ * High level GTK helpers, like gtk_window_set_decorated, simply
+ * use gdk_window_set_decorations() with specific values.
+ * Therefore we use that function manually.
+ */
OS.gtk_widget_realize (shellHandle);
int window = OS.GTK_WIDGET_WINDOW (shellHandle);
- // TEMPORARY CODE - trim does not work for dialogs
-// OS.gdk_window_set_decorations (window, decorations);
-
+ if ((style & SWT.ON_TOP) != 0) {
+ OS.gdk_window_set_override_redirect (window, true);
+ } else {
+ int decorations = 0;
+ if ((style & SWT.NO_TRIM) == 0) {
+ if ((style & SWT.MIN) != 0) decorations |= OS.GDK_DECOR_MINIMIZE;
+ if ((style & SWT.MAX) != 0) decorations |= OS.GDK_DECOR_MAXIMIZE;
+ if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_RESIZEH;
+ if ((style & SWT.BORDER) != 0) decorations |= OS.GDK_DECOR_BORDER;
+ if ((style & SWT.MENU) != 0) decorations |= OS.GDK_DECOR_MENU;
+ if ((style & SWT.TITLE) != 0) decorations |= OS.GDK_DECOR_TITLE;
+ /*
+ * Feature in GTK. Under some Window Managers (Sawmill), in order
+ * to get any border at all from the window manager it is necessary
+ * to set GDK_DECOR_BORDER. The fix is to force these bits when any
+ * kind of border is requested.
+ */
+ if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_BORDER;
+ }
+ OS.gdk_window_set_decorations (window, decorations);
+ OS.gtk_window_set_title (shellHandle, new byte [1]);
+ }
+ boolean modal = (style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0;
+ OS.gtk_window_set_modal (shellHandle, modal);
accelGroup = OS.gtk_accel_group_new ();
OS.gtk_window_add_accel_group (shellHandle, accelGroup);
}
void hookEvents () {
super.hookEvents ();
- signal_connect_after(shellHandle, "map-event", SWT.Deiconify, 3);
- signal_connect_after(shellHandle, "unmap-event", SWT.Iconify, 3);
+ signal_connect(shellHandle, "map-event", SWT.Deiconify, 3);
+ signal_connect(shellHandle, "unmap-event", SWT.Iconify, 3);
signal_connect(shellHandle, "size-allocate", SWT.Resize, 3);
signal_connect(shellHandle, "configure-event", SWT.Move, 3);
signal_connect(shellHandle, "delete-event", SWT.Dispose, 3);
+ signal_connect(shellHandle, "event-after", SWT.Activate, 3);
}
void register () {
@@ -510,41 +536,53 @@
return result;
}
-
/**
* Moves the receiver to the top of the drawing order for
* the display on which it was created (so that all other
* shells on that display, which are not the receiver's
* children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one).
+ * and sets focus to its default button (if it has one)
+ * and asks the window manager to make the shell active.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
+ * @see Control#moveAbove
+ * @see Control#setFocus
* @see Control#setVisible
+ * @see Display#getActiveShell
* @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
public void open () {
- checkWidget();
setVisible (true);
}
+int processDeiconify (int int0, int int1, int int2) {
+ minimized = false;
+ sendEvent (SWT.Deiconify);
+ return 0;
+}
+
int processDispose (int int0, int int1, int int2) {
closeWidget ();
return 0;
}
-int processFocusIn(int int0, int int1, int int2) {
- hasFocus=true;
- postEvent(SWT.Activate);
+int processActivate (int int0, int int1, int int2) {
+ if (OS.GDK_EVENT_TYPE (int0) == OS.GDK_FOCUS_CHANGE) {
+ hasFocus = OS.gdk_event_focus_get_in (int0);
+ postEvent (hasFocus ? SWT.Activate : SWT.Deactivate);
+ }
return 0;
}
-int processFocusOut(int int0, int int1, int int2) {
- hasFocus=false;
- postEvent(SWT.Deactivate);
+int processIconify (int int0, int int1, int int2) {
+ minimized = true;
+ sendEvent (SWT.Iconify);
return 0;
}
@@ -598,6 +636,70 @@
eventTable.unhook (SWT.Deactivate, listener);
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void setActive () {
+ checkWidget ();
+ //NOT IMPLEMENTED
+ setVisible (true);
+}
+
+void setActiveControl (Control control) {
+ if (control != null && control.isDisposed ()) control = null;
+ if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+ if (lastActive == control) return;
+
+ /*
+ * Compute the list of controls to be activated and
+ * deactivated by finding the first common parent
+ * control.
+ */
+ Control [] activate = (control == null) ? new Control[0] : control.getPath ();
+ Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
+ lastActive = control;
+ int index = 0, length = Math.min (activate.length, deactivate.length);
+ while (index < length) {
+ if (activate [index] != deactivate [index]) break;
+ index++;
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=deactivate.length-1; i>=index; --i) {
+ if (!deactivate [i].isDisposed ()) {
+ deactivate [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ for (int i=activate.length-1; i>=index; --i) {
+ if (!activate [i].isDisposed ()) {
+ activate [i].sendEvent (SWT.Activate);
+ }
+ }
+}
+
void resizeBounds (int width, int height, boolean notify) {
int menuHeight = 0;
if (menuBar != null) {
@@ -633,7 +735,8 @@
int [] w = new int [1], h = new int [1];
OS.gtk_window_get_size (shellHandle, w, h);
oldWidth = w [0]; oldHeight = h [0];
- width -= trimWidth (); height -= trimHeight ();
+ width = Math.max (1, width - trimWidth ());
+ height = Math.max (1, height - trimHeight ());
OS.gtk_window_resize (shellHandle, width, height);
resizeBounds (width, height, true);
}
@@ -738,7 +841,12 @@
sendEvent (SWT.Hide);
}
}
-
+boolean traverseEscape () {
+ if (parent == null) return false;
+ if (!isVisible () || !isEnabled ()) return false;
+ close ();
+ return true;
+}
int trimHeight () {
if ((style & SWT.NO_TRIM) != 0) return 0;
boolean hasTitle = false, hasResize = false, hasBorder = false;
@@ -776,6 +884,33 @@
WidgetTable.remove (shellHandle);
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void forceActive () {
+ checkWidget ();
+ //NOT IMPLEMENTED
+ setVisible (true);
+}
+
public Rectangle getBounds () {
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x, y);
@@ -804,5 +939,7 @@
super.releaseWidget ();
if (accelGroup != 0) OS.gtk_accel_group_unref (accelGroup);
accelGroup = 0;
+ display = null;
+ lastActive = null;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index d335418..285ba9c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -52,7 +52,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see ScrollBar
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index a653383..ea0c061 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -68,115 +68,17 @@
super (parent, checkStyle (style));
}
-void createHandle (int index) {
- state |= HANDLE;
- fixedHandle = OS.gtk_fixed_new ();
- if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (fixedHandle, true);
- handle = OS.gtk_notebook_new ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add (parentHandle, fixedHandle);
- OS.gtk_container_add (fixedHandle, handle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_show (fixedHandle);
+static int checkStyle (int style) {
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
}
-void hookEvents () {
- super.hookEvents ();
- signal_connect (handle, "switch_page", SWT.Selection, 4);
-}
-
-void createWidget (int index) {
- super.createWidget(index);
- items = new TabItem [4];
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- //notebookHandle
-/* int width = _computeSize(wHint, hHint, changed).x;
- int height = 0;
- Point size;
- if (layout != null) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = minimumSize ();
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- Rectangle trim = computeTrim (0, 0, width, height);
- width = trim.width; height = trim.height;
- return new Point (width, height);*/
- /* FIXME */
- return new Point(300,300);
-}
-
-int clientHandle () {
- if (items [0] != null) return items [0].pageHandle;
- return handle;
-}
-
-/**
- * Computes the widget trim.
- */
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- return new Rectangle(x-2, y-33, width+4, height+35);
-}
-
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (changed && resize) {
- int index = getSelectionIndex ();
- if (index != -1) {
- TabItem item = items [index];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- }
- }
- }
- return changed;
-}
-
-void createItem (TabItem item, int index) {
- int list = OS.gtk_container_children (handle);
- int itemCount = (list != 0) ? OS.g_list_length (list) : 0;
- if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
- if (itemCount == items.length) {
- TabItem [] newItems = new TabItem [items.length + 4];
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
- }
-
- // create a new label
- int labelHandle = OS.gtk_label_new ("");
- if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- // create a new fake page
- int pageHandle = OS.gtk_fixed_new();
- if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- // put the label and the fake page inside the notebook
- OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_notebook_append_page(handle, pageHandle, labelHandle);
- OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
-
- OS.gtk_widget_show(labelHandle);
- OS.gtk_widget_show(pageHandle);
-
- item.state |= HANDLE;
- item.handle = labelHandle;
- item.pageHandle = pageHandle;
- System.arraycopy (items, index, items, index + 1, itemCount++ - index);
- items [index] = item;
- OS.gtk_notebook_set_show_tabs (handle, true);
-}
/**
* Adds the listener to the collection of listeners who will
@@ -203,14 +105,134 @@
* @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection,typedListener);
addListener(SWT.DefaultSelection,typedListener);
}
+int clientHandle () {
+ int index = OS.gtk_notebook_get_current_page (handle);
+ if (index != -1 && items [index] != null) {
+ return items [index].pageHandle;
+ }
+ return handle;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ OS.gtk_widget_set_size_request (handle, wHint, hHint);
+ GtkRequisition requisition = new GtkRequisition ();
+ boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
+ OS.gtk_notebook_set_scrollable (handle, false);
+ OS.gtk_widget_size_request (handle, requisition);
+ OS.gtk_notebook_set_scrollable (handle, scrollable);
+ OS.gtk_widget_set_size_request (handle, width, height);
+ width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+ height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ return new Rectangle(x-2, y-33, width+4, height+35);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ handle = OS.gtk_notebook_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_notebook_set_scrollable (handle, true);
+ OS.gtk_notebook_set_show_tabs (handle, true);
+}
+
+void createWidget (int index) {
+ super.createWidget(index);
+ items = new TabItem [4];
+}
+
+void createItem (TabItem item, int index) {
+ int list = OS.gtk_container_get_children (handle);
+ int itemCount = 0;
+ if (list != 0) {
+ itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ }
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (itemCount == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int labelHandle = OS.gtk_label_new (null);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int pageHandle = OS.gtk_fixed_new ();
+ if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
+ OS.gtk_notebook_insert_page (handle, pageHandle, labelHandle, index);
+ OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
+ OS.gtk_widget_show (labelHandle);
+ OS.gtk_widget_show (pageHandle);
+ item.state |= HANDLE;
+ item.handle = labelHandle;
+ item.pageHandle = pageHandle;
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+ item.setForegroundColor (getForegroundColor ());
+ item.setFontDescription (getFontDescription ());
+ if (itemCount == 1) {
+ fixPage ();
+ Event event = new Event();
+ event.item = items[0];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+}
+
+void fixPage () {
+ /*
+ * Feature in GTK. For some reason, the positioning of
+ * tab labels and pages become corrupted when when there
+ * is no current page. The fix is to force the notebook
+ * to resize which causes the current page to be set.
+ */
+// int index = OS.gtk_notebook_get_current_page (handle);
+// if (index != -1) return;
+ OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
+ int flags = OS.GTK_WIDGET_FLAGS (handle);
+ OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_VISIBLE);
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (handle, requisition);
+ OS.gtk_container_resize_children (handle);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(handle, OS.GTK_VISIBLE);
+ }
+ OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
+}
+
void destroyItem (TabItem item) {
int index = 0;
int itemCount = getItemCount();
@@ -219,10 +241,32 @@
index++;
}
if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ int oldIndex = OS.gtk_notebook_get_current_page (handle);
+ OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_notebook_remove_page (handle, index);
+ OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
item.handle = 0;
+ if (index == oldIndex) {
+ fixPage ();
+ int newIndex = OS.gtk_notebook_get_current_page (handle);
+ if (newIndex != -1) {
+ Control control = items [newIndex].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea());
+ control.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = items [newIndex];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+ }
+}
+
+int eventHandle () {
+ return fixedHandle;
}
/**
@@ -243,8 +287,10 @@
public TabItem getItem (int index) {
checkWidget();
- int list = OS.gtk_container_children (handle);
- int itemCount = list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
return items [index];
}
@@ -261,8 +307,11 @@
*/
public int getItemCount () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- return list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return 0;
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ return itemCount;
}
/**
@@ -283,8 +332,7 @@
*/
public TabItem [] getItems () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- int count = list != 0 ? OS.g_list_length (list) : 0;
+ int count = getItemCount ();
TabItem [] result = new TabItem [count];
System.arraycopy (items, 0, result, 0, count);
return result;
@@ -329,6 +377,11 @@
return OS.gtk_notebook_get_current_page (handle);
}
+void hookEvents () {
+ super.hookEvents ();
+ signal_connect (handle, "switch_page", SWT.Selection, 4);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -349,8 +402,10 @@
public int indexOf (TabItem item) {
checkWidget();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- int list = OS.gtk_container_children (handle);
- int count = list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return -1;
+ int count = OS.g_list_length (list);
+ OS.g_list_free (list);
for (int i=0; i<count; i++) {
if (items [i] == item) return i;
}
@@ -376,6 +431,16 @@
return 0;
}
+void releaseWidget () {
+ int count = getItemCount ();
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -394,13 +459,48 @@
* @see #addSelectionListener
*/
public void removeSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
eventTable.unhook (SWT.DefaultSelection,listener);
}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize) {
+ int index = getSelectionIndex ();
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ }
+ return changed;
+}
+
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ TabItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setFontDescription (font);
+ }
+ }
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ TabItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setForegroundColor (color);
+ }
+ }
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -415,11 +515,37 @@
* </ul>
*/
public void setSelection (int index) {
- checkWidget();
- if (index == -1) return;
+ checkWidget ();
+ setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+ if (index < 0) return;
+ int oldIndex = OS.gtk_notebook_get_current_page (handle);
+ if (oldIndex != -1) {
+ TabItem item = items [oldIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_notebook_set_page (handle, index);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
+ int newIndex = OS.gtk_notebook_get_current_page (handle);
+ if (newIndex != -1) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ sendEvent (SWT.Selection, event);
+ }
+ }
}
/**
@@ -447,24 +573,4 @@
}
}
-void releaseWidget () {
- int count = getItemCount ();
- for (int i=0; i<count; i++) {
- TabItem item = items [i];
- if (!item.isDisposed ()) item.releaseWidget ();
- }
- items = null;
- super.releaseWidget ();
-}
-
-static int checkStyle (int style) {
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index e6cb3b5..94accf4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -28,6 +28,7 @@
int pageHandle;
Control control;
TabFolder parent;
+ String toolTipText;
/**
* Constructs a new instance of this class given its parent
@@ -115,8 +116,7 @@
* </ul>
*/
public Control getControl () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return control;
}
@@ -137,8 +137,7 @@
* </ul>
*/
public TabFolder getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return parent;
}
@@ -154,9 +153,8 @@
* </ul>
*/
public String getToolTipText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return "";
+ checkWidget ();
+ return toolTipText;
}
void releaseChild () {
@@ -185,8 +183,7 @@
* </ul>
*/
public void setControl (Control control) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
Control oldControl = this.control, newControl = control;
this.control = control;
int index = parent.indexOf (this);
@@ -201,9 +198,16 @@
if (oldControl != null) oldControl.setVisible (false);
}
+void setFontDescription (int font) {
+ OS.gtk_widget_modify_font (handle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ OS.gtk_widget_modify_fg (handle, 0, color);
+}
+
public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
super.setImage (image);
}
@@ -219,6 +223,7 @@
}
byte [] buffer = Converter.wcsToMbcs (null, text);
OS.gtk_label_set_text_with_mnemonic (handle, buffer);
+ parent.fixPage ();
}
/**
@@ -233,8 +238,8 @@
* </ul>
*/
public void setToolTipText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ toolTipText = string;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 7754fd0..18bece5a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -6,6 +6,7 @@
*/
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
@@ -29,17 +30,17 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
public class Table extends Composite {
- int itemCount, columnCount;
+ boolean selected;
+ int itemCount, columnCount, imageHeight;
TableItem [] items;
TableColumn [] columns;
- TableItem itemBeingSelected;
- TableItem[] selection = new TableItem[0];
int check, uncheck;
- int check_width, check_height;
public static int MAX_COLUMNS = 32;
/**
@@ -74,52 +75,55 @@
super (parent, checkStyle (style));
}
-void createHandle (int index) {
- state |= HANDLE;
- fixedHandle = OS.gtk_fixed_new ();
- if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (fixedHandle, true);
- scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- handle = OS.gtk_clist_new (MAX_COLUMNS);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add (parentHandle, fixedHandle);
- OS.gtk_container_add (fixedHandle, scrolledHandle);
- OS.gtk_container_add (scrolledHandle, handle);
- OS.gtk_widget_show (fixedHandle);
- OS.gtk_widget_show (scrolledHandle);
- OS.gtk_widget_show (handle);
-
- /* Single or Multiple Selection */
- int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
- OS.gtk_clist_set_selection_mode (handle, mode);
-
- /* We fake the number of columns, because we have to know beforehand.
- * Initially all those fake columns are invisible
- */
- byte [] buffer = new byte [1];
- OS.gtk_clist_set_column_title (handle, 0, buffer);
- for (int i=1; i<MAX_COLUMNS; i++) {
- OS.gtk_clist_set_column_visibility (handle, i, false);
- }
-
- /* Scrolling policy */
- int hscrollbar_policy = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
- int vscrollbar_policy = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
- OS.gtk_scrolled_window_set_policy (scrolledHandle, hscrollbar_policy, vscrollbar_policy);
-
- if ((style & SWT.CHECK) != 0) {
- OS.gtk_widget_realize (handle);
- uncheck = createCheckPixmap(false);
- check = createCheckPixmap(true);
- }
+static int checkStyle (int style) {
+ /*
+ * To be compatible with Windows, force the H_SCROLL
+ * and V_SCROLL style bits. On Windows, it is not
+ * possible to create a table without scroll bars.
+ */
+ style |= SWT.H_SCROLL | SWT.V_SCROLL;
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}
-void hookEvents () {
- //TO DO - get rid of enter/exit for mouse crossing border
- super.hookEvents ();
- signal_connect (handle, "select_row", SWT.Selection, 5);
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ if (wHint == SWT.DEFAULT) wHint = 200;
+ return computeNativeSize (scrolledHandle, wHint, hHint, changed);
}
int createCheckPixmap(boolean checked) {
@@ -127,8 +131,8 @@
* The box will occupy the whole item width.
*/
GtkCList clist = new GtkCList (handle);
- check_height = clist.row_height-1;
- check_width = check_height;
+ int check_height = clist.row_height-2;
+ int check_width = check_height;
GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
int pixmap = OS.gdk_pixmap_new(0, check_width, check_height, visual.depth);
@@ -165,54 +169,51 @@
return pixmap;
}
-void createWidget (int index) {
- super.createWidget (index);
- items = new TableItem [4];
- columns = new TableColumn [4];
- itemCount = columnCount = 0;
+void createHandle (int index) {
+ state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ handle = OS.gtk_clist_new (MAX_COLUMNS);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, scrolledHandle);
+ OS.gtk_container_add (scrolledHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ OS.gtk_widget_show (handle);
+
+ /* Force row_height to be computed */
+ OS.gtk_clist_set_row_height (handle, 0);
+
+ /* Single or Multiple Selection */
+ int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
+ OS.gtk_clist_set_selection_mode (handle, mode);
+
+ /* We fake the number of columns, because we have to know beforehand.
+ * Initially all those fake columns are invisible
+ */
+ byte [] buffer = new byte [1];
+ OS.gtk_clist_set_column_title (handle, 0, buffer);
+ for (int i=1; i<MAX_COLUMNS; i++) {
+ OS.gtk_clist_set_column_visibility (handle, i, false);
+ }
+
+ /* Scrolling policy */
+ int hscrollbar_policy = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
+ int vscrollbar_policy = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hscrollbar_policy, vscrollbar_policy);
+
+ if ((style & SWT.CHECK) != 0) {
+ OS.gtk_widget_realize (handle);
+ uncheck = createCheckPixmap (false);
+ check = createCheckPixmap (true);
+ }
}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- if (wHint == SWT.DEFAULT) wHint = 200;
- return computeNativeSize (scrolledHandle, wHint, hHint, changed);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-/* The real work to create a new column */
void createItem (TableColumn column, int index) {
if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
if (columnCount == columns.length) {
@@ -221,7 +222,7 @@
columns = newColumns;
}
OS.gtk_clist_set_column_visibility (handle, index, true);
- OS.gtk_clist_column_titles_passive(handle); // paranoia
+ OS.gtk_clist_column_titles_passive (handle);
System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
columns [index] = column;
}
@@ -242,14 +243,19 @@
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
// OS.g_free (ptr);
if ((style & SWT.CHECK) != 0) {
- byte [] spacing = new byte [1];
- OS.gtk_clist_get_pixtext (handle, index, 0, null, spacing, null, null);
- OS.gtk_clist_set_pixtext (handle, index, 0, null, spacing [0], uncheck, 0);
+ OS.gtk_clist_set_pixtext (handle, index, 0, new byte [1], (byte) 2, uncheck, 0);
}
System.arraycopy (items, index, items, index + 1, itemCount++ - index);
items [index] = item;
}
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new TableItem [4];
+ columns = new TableColumn [4];
+ itemCount = columnCount = 0;
+}
+
/**
* Deselects the item at the given zero-relative index in the receiver.
* If the item at the index was already deselected, it remains
@@ -267,8 +273,8 @@
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_clist_unselect_row (handle, index, 0);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -291,8 +297,8 @@
OS.gtk_clist_unselect_row (handle, i, 0);
}
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -319,6 +325,7 @@
}
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
}
+
/**
* Deselects all selected items in the receiver.
*
@@ -332,7 +339,6 @@
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_clist_unselect_all (handle);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = new TableItem[0];
}
void destroyItem (TableColumn column) {
@@ -347,6 +353,7 @@
System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
columns [columnCount] = null;
}
+
void destroyItem (TableItem item) {
int index = 0;
while (index < itemCount) {
@@ -358,6 +365,7 @@
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
}
+
/**
* Returns the column at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -383,6 +391,7 @@
if (!(0 <= index && index < columnCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
return columns [index];
}
+
/**
* Returns the number of columns contained in the receiver.
* If no <code>TableColumn</code>s were created by the programmer,
@@ -404,6 +413,7 @@
checkWidget();
return columnCount;
}
+
/**
* Returns an array of <code>TableColumn</code>s which are the
* columns in the receiver. If no <code>TableColumn</code>s were
@@ -430,6 +440,7 @@
System.arraycopy (columns, 0, result, 0, columnCount);
return result;
}
+
/**
* Returns the width in pixels of a grid line.
*
@@ -482,17 +493,15 @@
*/
public TableItem getItem (Point pt) {
checkWidget();
-
GtkCList clist = new GtkCList (handle);
int clientX = pt.x;
int clientY = pt.y - clist.column_title_area_height;
if (clientY <= 0) return null;
-
- int[] row = new int[1], column = new int[1];
- row[0] = -1;
- OS.gtk_clist_get_selection_info(handle, clientX, clientY, row, column);
- if (row[0] == -1) return null;
- return items[row[0]];
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, clientX, clientY, row, column) == 0) {
+ return null;
+ }
+ return items [row [0]];
}
/**
@@ -506,10 +515,10 @@
* </ul>
*/
public int getItemCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return itemCount;
}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the receiver's.
@@ -526,6 +535,7 @@
GtkCList clist = new GtkCList (handle);
return clist.row_height;
}
+
/**
* Returns an array of <code>TableItem</code>s which are the items
* in the receiver.
@@ -565,59 +575,16 @@
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TableItem[] getSelection () {
+public TableItem [] getSelection () {
checkWidget();
- return selection;
-}
-
-/**
- * Get the selection from the OS.
- */
-private TableItem[] _getNativeSelection () {
GtkCList clist = new GtkCList (handle);
- switch (clist.selection_mode) {
- case OS.GTK_SELECTION_SINGLE: return getSelection_single();
- case OS.GTK_SELECTION_BROWSE: return getSelection_browse();
- case OS.GTK_SELECTION_MULTIPLE: return getSelection_multiple();
- case OS.GTK_SELECTION_EXTENDED: return getSelection_extended();
- }
- return new TableItem [0];
-}
-private TableItem[] getSelection_single () {
- GtkCList clist = new GtkCList(handle);
- if (clist.selection==0) return new TableItem[0];
- int length = OS.g_list_length (clist.selection);
- if (length == 0) return new TableItem[0];
- int index = OS.g_list_nth_data (clist.selection, 0);
- return new TableItem [] {items[index]};
-}
-private TableItem[] getSelection_browse () {
- /* same as single */
- GtkCList clist = new GtkCList(handle);
- if (clist.selection==0) return new TableItem[0];
- int length = OS.g_list_length (clist.selection);
- if (length == 0) return new TableItem[0];
- int index = OS.g_list_nth_data (clist.selection, 0);
- return new TableItem [] {items[index]};
-}
-private TableItem[] getSelection_multiple () {
- GtkCList clist = new GtkCList(handle);
- if (clist.selection==0) return new TableItem[0];
- int length = OS.g_list_length (clist.selection);
+ int list = clist.selection;
+ if (list == 0) return new TableItem [0];
+ int length = OS.g_list_length (list);
TableItem [] result = new TableItem [length];
+ int [] buffer = new int [1];
for (int i=0; i<length; i++) {
- int index = OS.g_list_nth_data (clist.selection, i);
- result [i] = items [index];
- }
- return result;
-}
-private TableItem[] getSelection_extended () {
- GtkCList clist = new GtkCList(handle);
- if (clist.selection==0) return new TableItem[0];
- int length = OS.g_list_length (clist.selection);
- TableItem [] result = new TableItem [length];
- for (int i=0; i<length; i++) {
- int index = OS.g_list_nth_data (clist.selection, i);
+ int index = OS.g_list_nth_data (list, i);
result [i] = items [index];
}
return result;
@@ -635,14 +602,11 @@
*/
public int getSelectionCount () {
checkWidget();
- return selection.length;
-}
-private int _getNativeSelectionCount () {
GtkCList clist = new GtkCList (handle);
- int selectionList = clist.selection;
- if (selectionList==0) return 0;
+ if (clist.selection == 0) return 0;
return OS.g_list_length (clist.selection);
}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -661,6 +625,7 @@
if (OS.g_list_length (list) == 0) return -1;
return OS.g_list_nth_data (list, 0);
}
+
/**
* Returns the zero-relative indices of the items which are currently
* selected in the receiver. The array is empty if no items are selected.
@@ -678,8 +643,8 @@
*/
public int [] getSelectionIndices () {
checkWidget();
- GtkCList widget = new GtkCList (handle);
- int list = widget.selection;
+ GtkCList clist = new GtkCList (handle);
+ int list = clist.selection;
int length = OS.g_list_length (list);
int [] indices = new int [length];
for (int i=0; i<length; i++) {
@@ -712,6 +677,148 @@
return false;
}
+int processSelection (int int0, int int1, int int2) {
+ GtkCList clist = new GtkCList (handle);
+ if (int0 != clist.focus_row) return 0;
+ if ((style & SWT.MULTI) != 0) selected = false;
+ int eventType = SWT.Selection;
+ if (int2 != 0) {
+ int type = OS.GDK_EVENT_TYPE (int2);
+ if (type == OS.GDK_2BUTTON_PRESS) {
+ eventType = SWT.DefaultSelection;
+ }
+ }
+ postEvent (eventType);
+ return 0;
+}
+
+int paintWindow () {
+ OS.gtk_widget_realize (handle);
+ GtkCList clist = new GtkCList (handle);
+ return clist.clist_window;
+}
+
+int processEvent (int eventNumber, int int0, int int1, int int2) {
+ if (eventNumber == 0) {
+ switch (OS.GDK_EVENT_TYPE (int0)) {
+ case OS.GDK_BUTTON_PRESS:
+ case OS.GDK_2BUTTON_PRESS: {
+ if ((style & SWT.MULTI) != 0) selected = true;
+ if ((style & SWT.CHECK) != 0) {
+ double [] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (int0, px, py);
+ GtkCList clist = new GtkCList (handle);
+ int x = (int) (px [0]);
+ int y = (int) (py [0]) - clist.column_title_area_height;
+ if (y > 0) {
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, x, y, row, column) != 0) {
+ int nX = clist.hoffset + 4;
+ int nY = clist.voffset + (clist.row_height + 1) * row [0] + 2;
+ int [] check_width = new int [1], check_height = new int [1];
+ OS.gdk_drawable_get_size (check, check_width, check_height);
+ if (nX <= x && x <= nX + check_width [0]) {
+ if (nY <= y && y <= nY + check_height [0]) {
+ TableItem item = items [row [0]];
+ byte [] spacing = new byte [1];
+ int [] pixmap = new int [1], mask = new int [1];
+ OS.gtk_clist_get_pixtext (handle, row [0], 0, null, spacing, pixmap, mask);
+ byte [] text = Converter.wcsToMbcs (null, item.getText (), true);
+ pixmap [0] = pixmap [0] == check ? uncheck : check;
+ OS.gtk_clist_set_pixtext (handle, row [0], 0, text, spacing [0], pixmap [0], mask [0]);
+ Event event = new Event ();
+ event.detail = SWT.CHECK;
+ event.item = item;
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ case OS.GDK_BUTTON_RELEASE: {
+ if ((style & SWT.MULTI) != 0) {
+ /*
+ * Feature in GTK. When an item is reselected, GTK
+ * does not issue notification. The fix is to detect
+ * that the mouse was released over a selected item when
+ * no selection signal was set and issue a fake selection
+ * event.
+ */
+ double[] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (int0, px, py);
+ int x = (int) (px[0]), y = (int) (py[0]);
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, x, y, row, column) != 0) {
+ GtkCList clist = new GtkCList (handle);
+ if (selected && clist.selection != 0) {
+ int list = clist.selection;
+ int length = OS.g_list_length (list);
+ for (int i=0; i<length; i++) {
+ if (row [0] == OS.g_list_nth_data (list, i)) {
+ postEvent (SWT.Selection);
+ }
+ }
+ }
+ }
+ selected = false;
+ }
+ break;
+ }
+ }
+ return 1;
+ }
+ return super.processEvent (eventNumber, int0, int1, int2);
+}
+
+int processKeyDown (int callData, int arg1, int int2) {
+ int result = super.processKeyDown (callData, arg1, int2);
+ /*
+ * Feature in GTK. When an item is reselected using
+ * the space bar, GTK does not issue notification.
+ * The fix is to ignore the notification that is sent
+ * by GTK and look for the space key.
+ */
+ int length = OS.gdk_event_key_get_length (callData);
+ if (length == 1) {
+ int string = OS.gdk_event_key_get_string (callData);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, string, length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ switch (unicode [0]) {
+ case ' ':
+ GtkCList clist = new GtkCList (handle);
+ if (clist.focus_row != -1) {
+ Event event = new Event ();
+ event.item = items [clist.focus_row];
+ postEvent (SWT.Selection, event);
+ }
+ break;
+ }
+ }
+ return result;
+}
+
+int processKeyUp (int callData, int arg1, int int2) {
+ int result = super.processKeyUp (callData, arg1, int2);
+ /*
+ * Feature in GTK. For some reason, when the selection
+ * is extended using the shift key, the notification is
+ * issued when the widget loses focus. The fix is to force
+ * the notification to be issued by temporarily losing and
+ * gaining focus every time the shift key is released.
+ */
+ int keyval = OS.gdk_event_key_get_keyval (callData);
+ switch (keyval) {
+ case OS.GDK_Shift_L:
+ case OS.GDK_Shift_R:
+ OS.gtk_widget_grab_focus (scrolledHandle);
+ OS.gtk_widget_grab_focus (handle);
+ }
+ return result;
+}
+
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
@@ -730,6 +837,14 @@
return -clist.voffset / (clist.row_height + 1);
}
+void hookEvents () {
+ //TO DO - get rid of enter/exit for mouse crossing border
+ super.hookEvents ();
+ signal_connect (handle, "select_row", SWT.Selection, 5);
+ signal_connect (handle, "unselect_row", SWT.Selection, 5);
+ signal_connect (handle, "event_after", 0, 3);
+}
+
/**
* Searches the receiver's list starting at the first column
* (index 0) until a column is found that is equal to the
@@ -755,6 +870,7 @@
}
return -1;
}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -792,12 +908,12 @@
if (!item.isDisposed ()) item.releaseWidget ();
}
items = null;
- itemBeingSelected = null;
if (check != 0) OS.g_object_unref (check);
if (uncheck != 0) OS.g_object_unref (uncheck);
check = uncheck = 0;
super.releaseWidget ();
}
+
/**
* Removes the item from the receiver at the given
* zero-relative index.
@@ -824,6 +940,7 @@
items [itemCount] = null;
item.releaseWidget ();
}
+
/**
* Removes the items from the receiver which are
* between the given zero-relative start and end
@@ -857,6 +974,7 @@
itemCount = itemCount - (last - first);
if (first > start) error (SWT.ERROR_ITEM_NOT_REMOVED);
}
+
/**
* Removes the items from the receiver's list at the given
* zero-relative indices.
@@ -893,6 +1011,7 @@
}
}
}
+
/**
* Removes all of the items from the receiver.
* <p>
@@ -907,6 +1026,7 @@
items = new TableItem [4];
itemCount = 0;
}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -931,6 +1051,7 @@
eventTable.unhook (SWT.Selection, listener);
eventTable.unhook (SWT.DefaultSelection,listener);
}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
@@ -948,7 +1069,6 @@
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_clist_select_row (handle, index, 0);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
}
/**
@@ -972,8 +1092,8 @@
OS.gtk_clist_select_row (handle, i, 0);
}
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -999,8 +1119,8 @@
OS.gtk_clist_select_row (handle, indices [i], 0);
}
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
}
+
/**
* Selects all the items in the receiver.
*
@@ -1014,7 +1134,11 @@
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
OS.gtk_clist_select_all (handle);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- selection = _getNativeSelection();
+}
+
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ OS.gtk_widget_modify_base (handle, 0, color);
}
/**
@@ -1036,7 +1160,20 @@
*/
public boolean getHeaderVisible () {
checkWidget();
- return (OS.GTK_WIDGET_FLAGS(handle)&OS.GTK_CLIST_SHOW_TITLES) != 0;
+ return (OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CLIST_SHOW_TITLES) != 0;
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ if (imageHeight != 0) {
+ OS.gtk_widget_realize (handle);
+ OS.gtk_clist_set_row_height (handle, 0);
+ GtkCList clist = new GtkCList (handle);
+ if (imageHeight > clist.row_height) {
+ OS.gtk_clist_set_row_height (handle, imageHeight);
+ }
+ }
}
/**
@@ -1056,23 +1193,13 @@
* </ul>
*/
public void setHeaderVisible (boolean show) {
- /* FIXME
- * We should investigate why this optimization is not working.
- */
-// boolean isVisibleNow = getHeaderVisible();
-// if (show==isVisibleNow) return;
-
-/* GTK2 FIXME.
- * FOR SOME REASON, titles_show CAUSES A SEGFAULT IN show_now ON THE SHELL.
- * VERY WEIRD.
- */
-
if (show) {
OS.gtk_clist_column_titles_show (handle);
} else {
OS.gtk_clist_column_titles_hide (handle);
}
}
+
/**
* Returns <code>true</code> if the receiver's lines are visible,
* and <code>false</code> otherwise.
@@ -1094,6 +1221,7 @@
checkWidget();
return false;
}
+
/**
* Marks the receiver's lines as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -1113,6 +1241,7 @@
public void setLinesVisible (boolean show) {
checkWidget();
}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* The current selected is first cleared, then the new item is selected.
@@ -1130,8 +1259,17 @@
public void setSelection (int index) {
deselectAll ();
select (index);
- selection = _getNativeSelection();
}
+
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ if (redraw) {
+ OS.gtk_clist_thaw (handle);
+ } else {
+ OS.gtk_clist_freeze (handle);
+ }
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected if first cleared, then the new items are selected.
@@ -1150,8 +1288,8 @@
public void setSelection (int start, int end) {
deselectAll ();
select (start, end);
- selection = _getNativeSelection();
}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected is first cleared, then the new items are selected.
@@ -1172,8 +1310,8 @@
public void setSelection (int [] indices) {
deselectAll ();
select (indices);
- selection = _getNativeSelection();
}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -1204,8 +1342,8 @@
int index = indexOf (items [i]);
if (index != -1) select (index);
}
- selection = items; /* FIXME */
}
+
/**
* Sets the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items
@@ -1267,77 +1405,4 @@
setTopIndex (getSelectionIndex ());
}
-int processSelection (int int0, int int1, int int2) {
- selection = _getNativeSelection();
- itemBeingSelected = items [int0];
- Event event = new Event ();
- event.item = itemBeingSelected;
- sendEvent (SWT.Selection, event);
- return 0;
-}
-
-int paintWindow () {
- OS.gtk_widget_realize (handle);
- GtkCList clist = new GtkCList (handle);
- return clist.clist_window;
-}
-
-int processMouseDown (int callData, int arg1, int int2) {
- int result = super.processMouseDown (callData, arg1, int2);
- OS.gtk_widget_grab_focus(handle);
-
- // First, see if we have a single or double click
- boolean isDoubleClick = (OS.gdk_event_button_get_button(callData)==2);
-
- // We can't just use the x and y coordinates from the Gdk event,
- // because the actual items are drawn on a special X window
- int[] ppx = new int[1], ppy = new int[1];
- OS.gdk_window_get_pointer(OS.GTK_WIDGET_WINDOW(handle), ppx, ppy, 0);
- int eventType;
- if (isDoubleClick) {
- eventType = SWT.MouseDoubleClick;
- Event event = new Event ();
- event.item=itemBeingSelected;
- event.x = ppx[0]; event.y = ppy[0];
- sendEvent (SWT.DefaultSelection, event);
- return result;
- }
-
- eventType = SWT.MouseDown;
- int button = OS.gdk_event_button_get_button(callData);
- sendMouseEvent (eventType, button, callData);
- if (button == 3 && menu != null) menu.setVisible (true);
-
- if ((style&SWT.CHECK) != 0) {
- GtkCList clist = new GtkCList (handle);
- int clientX = ppx[0];
- int clientY = ppy[0] - clist.column_title_area_height;
- if (clientY <= 0) return result;
- int[] row = new int[1], column = new int[1];
- row[0] = -1;
- OS.gtk_clist_get_selection_info(handle, clientX, clientY, row, column);
- if (row[0] == -1) return result;
- int leftmost = 2;
- if (clientX < leftmost) return result;
- if (clientX > leftmost+check_width) return result;
-
- TableItem item = items [row[0]];
- item.setChecked(!item.getChecked());
- Event event = new Event ();
- event.detail = SWT.CHECK;
- event.item = item;
- postEvent (SWT.Selection, event);
- }
- return result;
-}
-
-static int checkStyle (int style) {
- /*
- * To be compatible with Windows, force the H_SCROLL
- * and V_SCROLL style bits. On Windows, it is not
- * possible to create a table without scroll bars.
- */
- style |= SWT.H_SCROLL | SWT.V_SCROLL;
- return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index ab90cad..c092081 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -19,7 +19,9 @@
* <dt><b>Events:</b></dt>
* <dd> Move, Resize, Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 5d97b50..49974e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -443,9 +443,12 @@
*/
public void setImage (int index, Image image) {
checkWidget ();
+ if (image != null && image.isDisposed()) {
+ error(SWT.ERROR_INVALID_ARGUMENT);
+ }
if (index == 0) {
- setImage (image);
- return;
+ if ((parent.style & SWT.CHECK) != 0) return;
+ super.setImage (image);
}
int row = parent.indexOf (this);
if (row == -1) return;
@@ -454,27 +457,26 @@
if (image == null) {
OS.gtk_clist_set_text (clist, row, 0, buffer);
} else {
- byte [] spacing = new byte [1];
- OS.gtk_clist_get_pixtext(clist, row, index, null, spacing, null, null);
- OS.gtk_clist_set_pixtext(clist, row, index, buffer, spacing [0], image.pixmap, image.mask);
+ int pixmap = image.pixmap, mask = image.mask;
+ byte [] spacing = new byte [] {2};
+// OS.gtk_clist_get_pixtext (clist, row, index, null, spacing, null, null);
+ OS.gtk_clist_set_pixtext (clist, row, index, buffer, spacing [0], pixmap, mask);
+ if (parent.imageHeight == 0) {
+ int [] width = new int [1], height = new int [1];
+ OS.gdk_drawable_get_size (pixmap, width, height);
+ GtkCList widget = new GtkCList (clist);
+ if (height [0] > widget.row_height) {
+ parent.imageHeight = height [0];
+ OS.gtk_widget_realize (clist);
+ OS.gtk_clist_set_row_height (clist, height [0]);
+ }
+ }
}
}
public void setImage (Image image) {
checkWidget ();
- if ((parent.style & SWT.CHECK) != 0) return;
- int row = parent.indexOf (this);
- if (row == -1) return;
- super.setImage (image);
- int clist = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- if (image == null) {
- OS.gtk_clist_set_text (clist, row, 0, buffer);
- } else {
- byte [] spacing = new byte [1];
- OS.gtk_clist_get_pixtext(clist, row, 0, null, spacing, null, null);
- OS.gtk_clist_set_pixtext(clist, row, 0, buffer, spacing [0], image.pixmap, image.mask);
- }
+ setImage (0, image);
}
/**
@@ -533,8 +535,7 @@
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == 0) {
- setText (string);
- return;
+ super.setText (string);
}
int row = parent.indexOf (this);
if (row == -1) return;
@@ -552,20 +553,7 @@
public void setText (String string) {
checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int row = parent.indexOf (this);
- if (row == -1) return;
- super.setText (string);
- int clist = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- byte [] spacing = new byte [1];
- int [] pixmap = new int [1], mask = new int [1];
- OS.gtk_clist_get_pixtext (clist, row, 0, new int [1], spacing, pixmap, mask);
- if (pixmap [0] == 0) {
- OS.gtk_clist_set_text (clist, row, 0, buffer);
- } else {
- OS.gtk_clist_set_pixtext (clist, row, 0, buffer, spacing [0], pixmap [0], mask [0]);
- }
+ setText (0, string);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index d0430ab..2d83574 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -21,6 +21,10 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Verify</dd>
* </dl>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
*/
@@ -39,7 +43,7 @@
LIMIT = 0x7FFFFFFF;
DELIMITER = "\n";
}
-
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -72,6 +76,15 @@
super (parent, checkStyle (style));
}
+static int checkStyle (int style) {
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ if ((style & (SWT.SINGLE | SWT.MULTI)) != 0) return style;
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
+ return style | SWT.MULTI;
+ }
+ return style | SWT.SINGLE;
+}
+
void createHandle (int index) {
state |= HANDLE;
int parentHandle = parent.parentingHandle ();
@@ -90,7 +103,19 @@
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_container_add (parentHandle, fixedHandle);
OS.gtk_container_add (fixedHandle, scrolledHandle);
+
+ /*
+ * Feature in GTK. Calling gtk_container_add to add a
+ * GtkText correctly adds the widget but issues warnings
+ * about horizontal scrolling. The fix is to hide the
+ * the warnings.
+ */
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
OS.gtk_container_add (scrolledHandle, handle);
+ display.setWarnings (warnings);
+
OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (scrolledHandle);
OS.gtk_text_set_editable (handle, (style & SWT.READ_ONLY) == 0);
@@ -108,7 +133,7 @@
signal_connect_after (handle, "changed", SWT.Modify, 2);
signal_connect (handle, "insert-text", SWT.Verify, 5);
signal_connect (handle, "delete-text", SWT.Verify, 4);
- signal_connect (handle, "activate", SWT.Selection, 2);
+ signal_connect (handle, "activate", SWT.DefaultSelection, 2);
}
/**
@@ -453,8 +478,16 @@
OS.memmove(gdkfont, fontHandle, GdkFont.sizeof);
return gdkfont.ascent + gdkfont.descent;*/
return 10;
-
}
+
+int getLineNumberInString( String string,char delimiter) {
+ int count=0;
+ for (int i=0; i<string.length (); i++) {
+ if (string.charAt (i) == delimiter) count++;
+ }
+ return count;
+}
+
/**
* Gets the position of the selected text.
* <p>
@@ -779,7 +812,7 @@
return 0;
}
-int processSelection (int int0, int int1, int int2) {
+int processDefaultSelection (int int0, int int1, int int2) {
postEvent (SWT.DefaultSelection);
return 0;
}
@@ -867,7 +900,12 @@
*/
public void selectAll () {
checkWidget ();
- /*OS.gtk_editable_select_region (handle, 0, -1);*/
+ OS.gtk_editable_select_region (handle, 0, -1);
+}
+
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ OS.gtk_widget_modify_base (handle, 0, color);
}
/**
@@ -926,6 +964,11 @@
/*OS.gtk_editable_set_editable (handle, editable);*/
}
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ OS.gtk_widget_modify_text (handle, 0, color);
+}
+
/**
* Sets the selection.
* <p>
@@ -1180,6 +1223,22 @@
*/
}
+int traversalCode (int key, int event) {
+ int bits = super.traversalCode (key, event);
+ if ((style & SWT.MULTI) != 0) {
+ bits &= ~SWT.TRAVERSE_RETURN;
+ if (key == OS.GDK_Tab && event != 0) {
+ int [] state = new int [1];
+ OS.gdk_event_get_state (event, state);
+ boolean next = (state[0] & OS.GDK_SHIFT_MASK) == 0;
+ if (next && (state[0] & OS.GDK_CONTROL_MASK) == 0) {
+ bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+ }
+ }
+ }
+ return bits;
+}
+
String verifyText (String string, int start, int end) {
Event event = new Event ();
event.text = string;
@@ -1190,20 +1249,4 @@
return event.text;
}
-int getLineNumberInString( String string,char delimiter) {
- int count=0;
- for (int i=0; i<string.length (); i++) {
- if (string.charAt (i) == delimiter) count++;
- }
- return count;
-}
-
-static int checkStyle (int style) {
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
- if ((style & (SWT.SINGLE | SWT.MULTI)) != 0) return style;
- if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
- return style | SWT.MULTI;
- }
- return style | SWT.SINGLE;
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 49b2a09..246ec92 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -28,6 +28,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -88,6 +90,8 @@
OS.gtk_container_add (fixedHandle, handle);
OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (handle);
+ setForegroundColor (parent.getForegroundColor ());
+ setFontDescription (parent.getFontDescription ());
}
public Point computeSize (int wHint, int hHint, boolean changed) {
@@ -96,6 +100,10 @@
return computeNativeSize(handle, wHint, hHint, changed);
}
+int eventHandle () {
+ return fixedHandle;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -148,8 +156,11 @@
*/
public int getItemCount () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- return list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return 0;
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ return itemCount;
}
/**
@@ -170,14 +181,16 @@
*/
public ToolItem [] getItems () {
checkWidget();
- int list = OS.gtk_container_children (handle);
- int count = list != 0 ? OS.g_list_length (list) : 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return new ToolItem [0];
+ int count = OS.g_list_length (list);
ToolItem [] result = new ToolItem [count];
for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
Widget widget = WidgetTable.get (data);
result [i] = (ToolItem) widget;
}
+ OS.g_list_free (list);
return result;
}
@@ -253,4 +266,24 @@
return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
}
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ ToolItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setFontDescription (font);
+ }
+ }
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ ToolItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setForegroundColor (color);
+ }
+ }
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index ca396a8..a27a9b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -14,22 +14,26 @@
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
- * <p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class ToolItem extends Item {
ToolBar parent;
Control control;
Image hotImage, disabledImage;
+ String toolTipText;
- int boxHandle, arrowHandle;
+ int boxHandle, arrowHandle, arrowButtonHandle;
int currentpixmap;
boolean drawHotImage;
@@ -146,7 +150,7 @@
void createHandle (int index) {
state |= HANDLE;
- switch (style & (SWT.SEPARATOR | SWT.RADIO | SWT.CHECK | SWT.PUSH)) {
+ switch (style & (SWT.SEPARATOR | SWT.RADIO | SWT.CHECK | SWT.PUSH | SWT.DROP_DOWN)) {
case SWT.PUSH:
case 0:
handle = OS.gtk_toolbar_insert_element (parent.handle,
@@ -184,6 +188,40 @@
OS.gtk_widget_show(boxHandle);
OS.gtk_widget_show(handle);
return;
+ case SWT.DROP_DOWN:
+ /* create the box */
+ isVertical = (parent.getStyle()&SWT.VERTICAL) != 0;
+ boxHandle = isVertical? OS.gtk_vbox_new(false, 0) : OS.gtk_hbox_new(false, 0);
+ if (boxHandle==0) error(SWT.ERROR_NO_HANDLES);
+ /* create the button */
+ handle = OS.gtk_button_new();
+ if (handle==0) error(SWT.ERROR_NO_HANDLES);
+ OS.gtk_button_set_relief(handle, OS.GTK_RELIEF_NONE);
+ /* create the arrow */
+ arrowHandle = OS.gtk_arrow_new (OS.GTK_ARROW_DOWN, OS.GTK_SHADOW_NONE);
+ if (arrowHandle==0) error(SWT.ERROR_NO_HANDLES);
+ arrowButtonHandle = OS.gtk_button_new ();
+ if (arrowButtonHandle==0) error(SWT.ERROR_NO_HANDLES);
+ OS.gtk_button_set_relief(arrowButtonHandle, OS.GTK_RELIEF_NONE);
+ OS.gtk_container_set_border_width(arrowButtonHandle,0);
+ int style = OS.gtk_style_copy(OS.gtk_widget_get_style(arrowButtonHandle));
+ OS.gtk_style_set_xthickness(style, 0);
+ OS.gtk_widget_set_style(arrowButtonHandle, style);
+ // when the arrow gets destroyed, it will dereference the clone
+
+ OS.gtk_toolbar_insert_widget (
+ parent.handle,
+ boxHandle,
+ new byte[1], new byte[1],
+ index);
+ OS.gtk_box_pack_start(boxHandle, handle, true,true,0);
+ OS.gtk_box_pack_end(boxHandle, arrowButtonHandle, true,true,0);
+ OS.gtk_container_add (arrowButtonHandle, arrowHandle);
+ OS.gtk_widget_show(handle);
+ OS.gtk_widget_show (arrowHandle);
+ OS.gtk_widget_show (arrowButtonHandle);
+ OS.gtk_widget_show(boxHandle);
+ return;
default:
/*
* Can not specify more than one style
@@ -196,10 +234,14 @@
void register() {
super.register ();
if (boxHandle != 0) WidgetTable.put(boxHandle, this);
+ if (arrowButtonHandle != 0) WidgetTable.put(arrowButtonHandle, this);
+ if (arrowHandle != 0) WidgetTable.put(arrowHandle, this);
}
void deregister() {
super.deregister ();
if (boxHandle != 0) WidgetTable.remove (boxHandle);
+ if (arrowButtonHandle != 0) WidgetTable.remove (arrowButtonHandle);
+ if (arrowHandle != 0) WidgetTable.remove (arrowHandle);
}
int topHandle() {
@@ -354,7 +396,7 @@
*/
public String getToolTipText () {
checkWidget();
- return "";
+ return toolTipText;
}
/**
@@ -378,6 +420,7 @@
signal_connect(handle, "clicked", SWT.Selection, 2);
signal_connect(handle, "enter-notify-event", SWT.MouseEnter, 3);
signal_connect(handle, "leave-notify-event", SWT.MouseExit, 3);
+ if (arrowButtonHandle!=0) signal_connect(arrowButtonHandle, "clicked", SWT.DefaultSelection, 2);
}
/**
@@ -453,9 +496,15 @@
postEvent (SWT.Selection, event);
return 0;
}
+int processDefaultSelection (int int0, int int1, int int2) {
+ Event event = new Event ();
+ event.detail = SWT.ARROW;
+ postEvent (SWT.Selection, event);
+ return 0;
+}
void releaseWidget () {
super.releaseWidget ();
- tooltipsHandle = 0;
+ tooltipsHandle = arrowButtonHandle = arrowHandle = 0;
parent = null;
}
@@ -569,6 +618,28 @@
OS.gtk_widget_set_sensitive (handle, enabled);
}
+void setFontDescription (int font) {
+ int list = OS.gtk_container_get_children (handle);
+ if (list != 0) {
+ int fontHandle = OS.g_list_nth_data (list, 0);
+ OS.g_list_free (list);
+ OS.gtk_widget_modify_font (fontHandle, font);
+ return;
+ }
+ OS.gtk_widget_modify_font (handle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ int list = OS.gtk_container_get_children (handle);
+ if (list != 0) {
+ int colorHandle = OS.g_list_nth_data (list, 0);
+ OS.g_list_free (list);
+ OS.gtk_widget_modify_fg (colorHandle, 0, color);
+ return;
+ }
+ OS.gtk_widget_modify_fg (handle, 0, color);
+}
+
/**
* Sets the receiver's hot image to the argument, which may be
* null indicating that no hot image should be displayed.
@@ -595,10 +666,11 @@
checkWidget();
super.setImage (image);
if ((style & SWT.SEPARATOR) != 0) return;
- int list = OS.gtk_container_children (handle);
+ int list = OS.gtk_container_get_children (handle);
if (list != 0) {
int widget = OS.g_list_nth_data (list, 0);
if (widget != 0) OS.gtk_widget_destroy (widget);
+ OS.g_list_free (list);
}
if (image != null) {
int pixmap = OS.gtk_pixmap_new (image.pixmap, image.mask);
@@ -641,10 +713,11 @@
for (int i=0; i<length; i++) {
if (text [i] == '&') text [i] = '_';
}
- int list = OS.gtk_container_children (handle);
+ int list = OS.gtk_container_get_children (handle);
if (list != 0) {
int widget = OS.g_list_nth_data (list, 0);
if (widget != 0) OS.gtk_widget_destroy (widget);
+ OS.g_list_free (list);
}
byte [] buffer = Converter.wcsToMbcs (null, text);
int label = OS.gtk_label_new_with_mnemonic (buffer);
@@ -664,9 +737,11 @@
*/
public void setToolTipText (String string) {
checkWidget();
+ toolTipText = string;
if (tooltipsHandle == 0) tooltipsHandle = OS.gtk_tooltips_new();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- OS.gtk_tooltips_set_tip(tooltipsHandle, handle, buffer, null);
+ byte [] buffer = null;
+ if (string != null) buffer = Converter.wcsToMbcs (null, string, true);
+ OS.gtk_tooltips_set_tip (tooltipsHandle, handle, buffer, null);
}
/**
* Sets the width of the receiver.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 4ae2a3e..2e728d1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -272,7 +272,7 @@
int[] newY = new int[1];
int[] oldX = new int[1];
int[] oldY = new int[1];
- OS.gdk_window_get_pointer(xWindow, oldX,oldY, 0);
+ OS.gdk_window_get_pointer(xWindow, oldX,oldY, null);
grab();
/*
@@ -285,7 +285,7 @@
case OS.GDK_BUTTON_RELEASE:
case OS.GDK_MOTION_NOTIFY:
if (cursor != lastCursor) { ungrab(); grab(); }
- OS.gdk_window_get_pointer(xWindow, newX,newY, 0);
+ OS.gdk_window_get_pointer(xWindow, newX,newY, null);
if (oldX [0] != newX [0] || oldY [0] != newY [0]) {
drawRectangles ();
for (int i=0; i<rectangles.length; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 7cfdb44..b0df09b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -30,13 +30,15 @@
* <dd>Selection, DefaultSelection, Collapse, Expand</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
public class Tree extends Composite {
TreeItem [] items;
boolean selected, doubleSelected;
- int check, uncheck;
+ int check, uncheck, imageHeight, timerID;
static int CELL_SPACING = 1;
/*
@@ -173,11 +175,14 @@
OS.gtk_widget_show (scrolledHandle);
OS.gtk_widget_show (handle);
+ /* Force row_height to be computed */
+ OS.gtk_clist_set_row_height (handle, 0);
+
+ /* Single or Multiple Selection */
int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
OS.gtk_clist_set_selection_mode (handle, mode);
- //BUG - need realize to get scrollbars
- OS.gtk_widget_realize (handle);
+ /* Scrolling policy */
int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
@@ -196,6 +201,7 @@
signal_connect (handle, "tree_unselect_row", SWT.Selection, 4);
signal_connect (handle, "tree_expand", SWT.Expand, 3);
signal_connect (handle, "tree_collapse", SWT.Collapse, 3);
+ signal_connect (handle, "event_after", 0, 3);
}
int createCheckPixmap(boolean checked) {
@@ -203,7 +209,7 @@
* The box will occupy the whole item width.
*/
GtkCList clist = new GtkCList (handle);
- int check_height = clist.row_height-1;
+ int check_height = clist.row_height-2;
int check_width = check_height;
GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
@@ -249,38 +255,17 @@
System.arraycopy (items, 0, newItems, 0, items.length);
items = newItems;
}
-
- /* Feature in GTK.
- * When the selection policy is BROWSE (which is what we use for SINGLE),
- * the first item added gets automatically selected. This leads to some
- * nontrivial complications which one better avoid. The hack is to
- * temporarily put a value other than GTK_SELECTION_BROWSE into the
- * selectionMode field just for the insertion. Do not use the policy
- * changing API because this will cause a selection callback.
- */
-//// GtkCTree ctree = new GtkCTree ();
-//// OS.memmove (ctree, handle, GtkCTree.sizeof);
-//// int selection_mode = ctree.selection_mode;
-//// ctree.selection_mode = OS.GTK_SELECTION_MULTIPLE;
-//// OS.memmove (handle, ctree, GtkCTree.sizeof);
-// int [] sm = new int [1];
-// OS.memmove (sm, handle+148, 1);
-// int selectionMode = sm[0];
-// sm [0] = OS.GTK_SELECTION_MULTIPLE;
-// OS.memmove (handle+148, sm, 1);
-//// FIXME
int sibling = index == -1 ? 0 : findSibling (node, index);
+ if (timerID == 0) {
+ OS.gtk_clist_freeze (handle);
+ Display display = getDisplay ();
+ timerID = OS.gtk_timeout_add (0, display.windowTimerProc, handle);
+ }
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
item.handle = OS.gtk_ctree_insert_node (handle, node, sibling, null, (byte) 2, uncheck, 0, uncheck, 0, false, false);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
if (item.handle == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
OS.gtk_ctree_node_set_row_data (handle, item.handle, id + 1);
-
-// OS.memmove (ctree, handle, GtkCTree.sizeof);
-// ctree.selection_mode = selection_mode;
-// OS.memmove (handle, ctree, GtkCTree.sizeof);
-// sm [0] = selectionMode;
-// OS.memmove (handle+148, sm, 1);
items [id] = item;
}
@@ -299,10 +284,8 @@
*/
public void deselectAll() {
checkWidget();
- int root = OS.gtk_ctree_node_nth (handle, 0);
- if (root == 0) return;
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_ctree_unselect_recursive (handle, root);
+ OS.gtk_ctree_unselect_recursive (handle, 0);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
}
@@ -334,14 +317,6 @@
return Sibling;
}
-public boolean forceFocus () {
- checkWidget ();
- OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- boolean result = super.forceFocus ();
- OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
- return result;
-}
-
/**
* Returns the item at the given point in the receiver
* or null if no such item exists. The point is in the
@@ -361,8 +336,9 @@
public TreeItem getItem (Point point) {
checkWidget ();
int [] row = new int [1], column = new int [1];
- int code = OS.gtk_clist_get_selection_info (handle, point.x, point.y, row, column);
- if (code == 0) return null;
+ if (OS.gtk_clist_get_selection_info (handle, point.x, point.y, row, column) == 0) {
+ return null;
+ }
int node = OS.gtk_ctree_node_nth (handle, row [0]);
int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
return items [index];
@@ -578,6 +554,177 @@
return 0;
}
+int processKeyDown (int callData, int arg1, int int2) {
+ int result = super.processKeyDown (callData, arg1, int2);
+ /*
+ * Feature in GTK. When an item is reselected using
+ * the space bar, GTK does not issue notification.
+ * The fix is to ignore the notification that is sent
+ * by GTK and look for the space key.
+ */
+ int length = OS.gdk_event_key_get_length (callData);
+ if (length == 1) {
+ int string = OS.gdk_event_key_get_string (callData);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, string, length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ switch (unicode [0]) {
+ case ' ':
+ GtkCList clist = new GtkCList (handle);
+ if (clist.focus_row != -1) {
+ Event event = new Event ();
+ int focus = OS.gtk_ctree_node_nth (handle, clist.focus_row);
+ if (focus != 0) {
+ int index = OS.gtk_ctree_node_get_row_data (handle, focus) - 1;
+ event.item = items [index];
+ }
+ postEvent (SWT.Selection, event);
+ }
+ break;
+ }
+ }
+ return result;
+}
+
+int processKeyUp (int callData, int arg1, int int2) {
+ int result = super.processKeyUp (callData, arg1, int2);
+ /*
+ * Feature in GTK. For some reason, when the selection
+ * is extended using the shift key, the notification is
+ * issued when the widget loses focus. The fix is to force
+ * the notification to be issued by temporarily losing and
+ * gaining focus every time the shift key is released.
+ */
+ int keyval = OS.gdk_event_key_get_keyval (callData);
+ switch (keyval) {
+ case OS.GDK_Shift_L:
+ case OS.GDK_Shift_R:
+ OS.gtk_widget_grab_focus (scrolledHandle);
+ OS.gtk_widget_grab_focus (handle);
+ }
+ return result;
+}
+
+int processEvent (int eventNumber, int int0, int int1, int int2) {
+ if (eventNumber == 0) {
+ switch (OS.GDK_EVENT_TYPE (int0)) {
+ case OS.GDK_BUTTON_PRESS:
+ case OS.GDK_2BUTTON_PRESS: {
+ doubleSelected = false;
+ if ((style & SWT.MULTI) != 0) selected = true;
+ double [] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (int0, px, py);
+ int x = (int)(px[0]), y = (int)(py[0]);
+ if ((style & SWT.CHECK) != 0) {
+ if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, x, y, row, column) != 0) {
+ int node = OS.gtk_ctree_node_nth (handle, row [0]);
+ int crow = OS.g_list_nth_data (node, 0);
+ GtkCTreeRow row_data = new GtkCTreeRow (crow);
+ GtkCTree ctree = new GtkCTree (handle);
+ GtkCList clist = new GtkCList (handle);
+ int nX = clist.hoffset + ctree.tree_indent * row_data.level - 2;
+ int nY = clist.voffset + (clist.row_height + 1) * row [0] + 2;
+ int [] check_width = new int [1], check_height = new int [1];
+ OS.gdk_drawable_get_size (check, check_width, check_height);
+ if (nX <= x && x <= nX + check_width [0]) {
+ if (nY <= y && y <= nY + check_height [0]) {
+ byte [] spacing = new byte [1];
+ boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
+ int [] pixmap = new int [1], mask = new int [1];
+ int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
+ byte [] text = Converter.wcsToMbcs (null, items [index].getText (), true);
+ OS.gtk_ctree_get_node_info (handle, node, null, spacing, pixmap, mask, pixmap, mask, is_leaf, expanded);
+ pixmap [0] = pixmap [0] == check ? uncheck : check;
+ OS.gtk_ctree_set_node_info (handle, node, text, spacing [0], pixmap [0], mask [0], pixmap [0], mask [0], is_leaf [0], expanded [0]);
+ Event event = new Event ();
+ event.detail = SWT.CHECK;
+ event.item = items [index];
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ }
+ }
+ if (OS.GDK_EVENT_TYPE (int0) == OS.GDK_2BUTTON_PRESS) {
+ if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
+ int [] row = new int [1], column = new int [1];
+ if (OS.gtk_clist_get_selection_info (handle, x, y, row, column) != 0) {
+ doubleSelected = true;
+ }
+ }
+ }
+ break;
+ }
+ case OS.GDK_BUTTON_RELEASE: {
+ /*
+ * Feature in GTK. When an item is reselected in a
+ * multi-select tree, GTK does not issue notification.
+ * The fix is to detect that the mouse was released over
+ * a selected item when no selection signal was set and
+ * issue a fake selection event.
+ *
+ * Feature in GTK. Double selection can only be implemented
+ * in a mouse up handler for a tree unlike the list, the event
+ * that caused the select signal is not included when the select
+ * signal is issued.
+ */
+ double[] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (int0, px, py);
+ int x = (int)(px[0]), y = (int)(py[0]);
+ if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
+ if ((style & SWT.SINGLE) != 0) {
+ GtkCList clist = new GtkCList (handle);
+ int list = clist.selection;
+ if (list != 0 && OS.g_list_length (list) != 0) {
+ int node = OS.g_list_nth_data (list, 0);
+ int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
+ Event event = new Event ();
+ event.item = items [index];
+ if (doubleSelected) {
+ postEvent (SWT.DefaultSelection, event);
+ } else {
+ postEvent (SWT.Selection, event);
+ }
+ }
+ selected = false;
+ }
+ if ((style & SWT.MULTI) != 0) {
+ int [] row = new int [1], column = new int [1];
+ int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
+ if (code != 0) {
+ int focus = OS.gtk_ctree_node_nth (handle, row [0]);
+ GtkCList clist = new GtkCList (handle);
+ if (selected && clist.selection != 0) {
+ int length = OS.g_list_length (clist.selection);
+ for (int i=0; i<length; i++) {
+ int node = OS.g_list_nth_data (clist.selection, i);
+ if (node == focus) {
+ int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
+ Event event = new Event ();
+ event.item = items [index];
+ if (doubleSelected) {
+ postEvent (SWT.DefaultSelection, event);
+ } else {
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ }
+ }
+ selected = false;
+ }
+ }
+ doubleSelected = false;
+ break;
+ }
+ }
+ return 1;
+ }
+ return super.processEvent (eventNumber, int0, int1, int2);
+}
+
int processExpand (int int0, int int1, int int2) {
int index = OS.gtk_ctree_node_get_row_data (handle, int0) - 1;
Event event = new Event ();
@@ -595,122 +742,6 @@
return 0;
}
-int processMouseDown (int callData, int arg1, int int2) {
- doubleSelected = false;
- int result = super.processMouseDown (callData, arg1, int2);
- if ((style & SWT.MULTI) != 0) selected = true;
- double [] px = new double [1], py = new double [1];
- OS.gdk_event_get_coords (callData, px, py);
- int x = (int)(px[0]), y = (int)(py[0]);
- if ((style & SWT.CHECK) != 0) {
- if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
- int [] row = new int [1], column = new int [1];
- int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
- if (code != 0) {
- int node = OS.gtk_ctree_node_nth (handle, row [0]);
- int crow = OS.g_list_nth_data (node, 0);
- GtkCTreeRow row_data = new GtkCTreeRow (crow);
- GtkCTree ctree = new GtkCTree (handle);
- GtkCList clist = new GtkCList (handle);
- int nX = clist.hoffset + ctree.tree_indent * row_data.level - 2;
- int nY = clist.voffset + (clist.row_height + 1) * row [0] + 2;
-// int [] unused = new int [1], check_width = new int [1], check_height = new int [1];
-// OS.gdk_window_get_geometry (check, unused, unused, check_width, check_height, unused);
- int [] check_width = new int [1], check_height = new int [1];
- OS.gdk_drawable_get_size (check, check_width, check_height);
- if (nX <= x && x <= nX + check_width [0]) {
- if (nY <= y && y <= nY + check_height [0]) {
- byte [] spacing = new byte [1];
- boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
- int [] pixmap = new int [1], mask = new int [1];
- int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
- byte [] text = Converter.wcsToMbcs (null, items [index].getText (), true);
- OS.gtk_ctree_get_node_info (handle, node, null, spacing, pixmap, mask, pixmap, mask, is_leaf, expanded);
- pixmap [0] = pixmap [0] == check ? uncheck : check;
- OS.gtk_ctree_set_node_info (handle, node, text, spacing [0], pixmap [0], mask [0], pixmap [0], mask [0], is_leaf [0], expanded [0]);
- Event event = new Event ();
- event.detail = SWT.CHECK;
- event.item = items [index];
- postEvent (SWT.Selection, event);
- }
- }
- }
- }
- }
- if (OS.GDK_EVENT_TYPE (callData) == OS.GDK_2BUTTON_PRESS) {
- if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
- int [] row = new int [1], column = new int [1];
- int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
- if (code != 0) doubleSelected = true;
- }
- }
- return result;
-}
-
-int processMouseUp (int callData, int arg1, int int2) {
- int result = super.processMouseUp (callData, arg1, int2);
- /*
- * Feature in GTK. When an item is reselected in a
- * mulit-select tree, GTK does not issue notification.
- * The fix is to detect that the mouse was released over
- * a selected item when no selection signal was set and
- * issue a fake selection event.
- *
- * Feature in GTK. Double selection can only be implemented
- * in a mouse up handler for a tree unlike the list,the event
- * that caused the select signal is not included when the select
- * signal is issued.
- */
- double[] px = new double [1], py = new double [1];
- OS.gdk_event_get_coords(callData, px, py);
- int x = (int)(px[0]), y = (int)(py[0]);
- if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
- if ((style & SWT.SINGLE) != 0) {
- GtkCList clist = new GtkCList (handle);
- int list = clist.selection;
- if (list != 0 && OS.g_list_length (list) != 0) {
- int node = OS.g_list_nth_data (list, 0);
- int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
- Event event = new Event ();
- event.item = items [index];
- if (doubleSelected) {
- postEvent (SWT.DefaultSelection, event);
- } else {
- postEvent (SWT.Selection, event);
- }
- }
- selected = false;
- }
- if ((style & SWT.MULTI) != 0) {
- int [] row = new int [1], column = new int [1];
- int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
- if (code != 0) {
- int focus = OS.gtk_ctree_node_nth (handle, row [0]);
- GtkCList clist = new GtkCList (handle);
- if (selected && clist.selection != 0) {
- int length = OS.g_list_length (clist.selection);
- for (int i=0; i<length; i++) {
- int node = OS.g_list_nth_data (clist.selection, i);
- if (node == focus) {
- int index = OS.gtk_ctree_node_get_row_data (handle, node) - 1;
- Event event = new Event ();
- event.item = items [index];
- if (doubleSelected) {
- postEvent (SWT.DefaultSelection, event);
- } else {
- postEvent (SWT.Selection, event);
- }
- }
- }
- }
- }
- selected = false;
- }
- }
- doubleSelected = false;
- return result;
-}
-
int processSelection (int int0, int int1, int int2) {
if ((style & SWT.SINGLE) != 0) {
selected = true;
@@ -727,6 +758,12 @@
return 0;
}
+int processTimer (int id) {
+ if (timerID != 0) OS.gtk_clist_thaw (handle);
+ timerID = 0;
+ return 0;
+}
+
void releaseWidget () {
for (int i=0; i<items.length; i++) {
TreeItem item = items [i];
@@ -739,6 +776,7 @@
if (check != 0) OS.g_object_unref (check);
if (uncheck != 0) OS.g_object_unref (uncheck);
check = uncheck = 0;
+ if (timerID != 0) OS.gtk_timeout_remove (timerID);
super.releaseWidget ();
}
@@ -812,6 +850,18 @@
eventTable.unhook (SWT.Collapse, listener);
}
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ if (imageHeight != 0) {
+ OS.gtk_widget_realize (handle);
+ OS.gtk_clist_set_row_height (handle, 0);
+ GtkCList clist = new GtkCList (handle);
+ if (imageHeight > clist.row_height) {
+ OS.gtk_clist_set_row_height (handle, imageHeight);
+ }
+ }
+}
+
/**
* Selects all the items in the receiver.
*
@@ -822,13 +872,25 @@
*/
public void selectAll () {
checkWidget();
- int root = OS.gtk_ctree_node_nth (handle, 0);
- if (root == 0) return;
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_ctree_select_recursive (handle, root);
+ OS.gtk_ctree_select_recursive (handle, 0);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
}
+void setBackgroundColor (GdkColor color) {
+ super.setBackgroundColor (color);
+ OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ if (redraw) {
+ OS.gtk_clist_thaw (handle);
+ } else {
+ OS.gtk_clist_freeze (handle);
+ }
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -850,10 +912,10 @@
public void setSelection (TreeItem [] items) {
checkWidget();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- int root = OS.gtk_ctree_node_nth (handle, 0);
- if (root == 0) return;
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_ctree_unselect_recursive (handle, root);
+ if ((style & SWT.MULTI) != 0) {
+ OS.gtk_ctree_unselect_recursive (handle, 0);
+ }
int index = 0, length = items.length;
while (index < length) {
TreeItem item = items [index];
@@ -865,6 +927,7 @@
}
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
if (index != length) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (items.length != 0) showItem (items [0]);
}
/**
@@ -932,4 +995,14 @@
OS.gtk_ctree_node_moveto (handle, node, 0, 0.0f, 0.0f);
}
+public void update () {
+ checkWidget ();
+ if (timerID != 0) {
+ OS.gtk_clist_thaw (handle);
+ OS.gtk_timeout_remove (timerID);
+ timerID = 0;
+ }
+ super.update ();
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index a2d6806..47fab3b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -542,7 +542,9 @@
public void setImage (Image image) {
checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (image != null && image.isDisposed()) {
+ error(SWT.ERROR_INVALID_ARGUMENT);
+ }
if ((parent.style & SWT.CHECK) != 0) return;
this.image = image;
int pixmap = 0, mask = 0;
@@ -556,6 +558,17 @@
byte [] buffer = Converter.wcsToMbcs (null, text, true);
OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, null, null, null, null, is_leaf, expanded);
OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap, mask, pixmap, mask, is_leaf [0], expanded [0]);
+ if (image != null) {
+ if (parent.imageHeight == 0) {
+ int [] width = new int [1], height = new int [1];
+ OS.gdk_drawable_get_size (pixmap, width, height);
+ GtkCList widget = new GtkCList (ctree);
+ if (height [0] > widget.row_height) {
+ parent.imageHeight = height [0];
+ OS.gtk_clist_set_row_height (ctree, height [0]);
+ }
+ }
+ }
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 415d1a5..7051985 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -102,6 +102,7 @@
if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
this.style = style;
}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when an event of the given type occurs. When the
@@ -129,6 +130,7 @@
if (eventTable == null) eventTable = new EventTable ();
eventTable.hook (eventType, handler);
}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when the widget is disposed. When the widget is
@@ -155,6 +157,7 @@
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Dispose, typedListener);
}
+
static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
int mask = int0 | int1 | int2 | int3 | int4 | int5;
if ((style & mask) == 0) style |= int0;
@@ -227,23 +230,15 @@
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
+void createHandle (int index) {
+}
+
void createWidget (int index) {
createHandle (index);
hookEvents ();
register ();
}
-void register () {
- if (handle == 0) return;
- if ((state & HANDLE) != 0) WidgetTable.put (handle, this);
-}
-
-void createHandle (int index) {
-}
-
-void hookEvents () {
-}
-
void deregister () {
if (handle == 0) return;
if ((state & HANDLE) != 0) WidgetTable.remove (handle);
@@ -296,8 +291,6 @@
throw new SWTError (code);
}
-
-
/**
* Returns the application defined widget data associated
* with the receiver, or null if it has not been set. The
@@ -359,6 +352,7 @@
}
return null;
}
+
/**
* Returns the <code>Display</code> that is associated with
* the receiver.
@@ -376,6 +370,7 @@
* </ul>
*/
public abstract Display getDisplay ();
+
String getName () {
// String string = getClass ().getName ();
// int index = string.lastIndexOf ('.');
@@ -385,9 +380,11 @@
while ((--index > 0) && (string.charAt (index) != '.'));
return string.substring (index + 1, string.length ());
}
+
String getNameText () {
return "";
}
+
/**
* Returns the receiver's style information.
* <p>
@@ -450,6 +447,22 @@
return hooks (eventType);
}
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
+public boolean isValidWidget () {
+ if (handle != 0) return true;
+ if ((state & HANDLE) != 0) return false;
+ return (state & DISPOSED) == 0;
+}
+
+boolean isValidSubclass() {
+ return Display.isValidClass(getClass());
+}
+
+void hookEvents () {
+}
/*
* Returns <code>true</code> if the specified eventType is
@@ -469,19 +482,6 @@
return eventTable.hooks (eventType);
}
-boolean isValidThread () {
- return getDisplay ().isValidThread ();
-}
-public boolean isValidWidget () {
- if (handle != 0) return true;
- if ((state & HANDLE) != 0) return false;
- return (state & DISPOSED) == 0;
-}
-
-boolean isValidSubclass() {
- return Display.isValidClass(getClass());
-}
-
char mbcsToWcs (char ch) {
int key = ch & 0xFFFF;
if (key <= 0x7F) return ch;
@@ -498,6 +498,7 @@
if (result.length == 0) return 0;
return result [0];
}
+
/**
* Notifies all of the receiver's listeners for events
* of the given type that one such event has occurred by
@@ -522,10 +523,12 @@
event.widget = this;
eventTable.sendEvent (event);
}
+
void postEvent (int eventType) {
if (eventTable == null) return;
postEvent (eventType, new Event ());
}
+
void postEvent (int eventType, Event event) {
if (eventTable == null) return;
event.type = eventType;
@@ -534,115 +537,126 @@
}
int processEvent (int eventNumber, int int0, int int1, int int2) {
+ /*
+ * Feature in GTK. Events such as mouse move are propagate up
+ * the widget hierarchy and are seen by the parent. This is the
+ * correct GTK behavior but not correct for SWT. The fix is to
+ * hook a signal after and stop the propagation using a negative
+ * event number to distinguish this case.
+ */
+ if (eventNumber < 0) return 1;
switch (eventNumber) {
+ case SWT.Activate: return processActivate (int0, int1, int2);
case SWT.Arm: return processArm (int0, int1, int2);
case SWT.Collapse: return processCollapse (int0, int1, int2);
case SWT.Expand: return processExpand (int0, int1, int2);
case SWT.Dispose: return processDispose (int0, int1, int2);
- case SWT.DefaultSelection: return processDoubleSelection (int0, int1, int2);
+ case SWT.DefaultSelection: return processDefaultSelection (int0, int1, int2);
+ case SWT.Deiconify: return processDeiconify (int0, int1, int2);
case SWT.FocusIn: return processFocusIn (int0, int1, int2);
case SWT.FocusOut: return processFocusOut (int0, int1, int2);
case SWT.Help: return processHelp (int0, int1, int2);
case SWT.Hide: return processHide (int0, int1, int2);
- case SWT.KeyDown: return processKeyDown (int0, int1, int2);
- case SWT.KeyUp: return processKeyUp (int0, int1, int2);
+ case SWT.KeyDown: if (!translateTraversal(int0)) {
+ return processKeyDown (int0, int1, int2);
+ } else {
+ return 1;
+ }
+ case SWT.KeyUp: return processKeyUp (int0, int1, int2);
case SWT.Iconify: return processIconify (int0, int1, int2);
- case SWT.Deiconify: return processDeiconify (int0, int1, int2);
case SWT.Modify: return processModify (int0, int1, int2);
-// case SWT.MouseDown: return processMouseDown (int0, int1, int2);
- case SWT.MouseDown: return processMouse (int0, int1, int2);
+ case SWT.MouseDown: return processMouseDown (int0, int1, int2);
case SWT.MouseEnter: return processMouseEnter (int0, int1, int2);
- case SWT.MouseExit: return processMouseExit (int0, int1, int2);
+ case SWT.MouseExit: return processMouseExit (int0, int1, int2);
case SWT.MouseHover: return processMouseHover (int0, int1, int2);
- case SWT.MouseMove: return processMouseMove (int0, int1, int2);
-// case SWT.MouseUp: return processMouseUp (int0, int1, int2);
+ case SWT.MouseMove: return processMouseMove (int0, int1, int2);
+ case SWT.MouseUp: return processMouseUp (int0, int1, int2);
case SWT.Move: return processMove (int0, int1, int2);
- case SWT.Paint: return processPaint (int0, int1, int2);
+ case SWT.Paint: return processPaint (int0, int1, int2);
case SWT.Resize: return processResize (int0, int1, int2);
case SWT.Show: return processShow (int0, int1, int2);
- case SWT.Selection: return processSelection (int0, int1, int2);
+ case SWT.Selection: return processSelection (int0, int1, int2);
case SWT.Verify: return processVerify (int0, int1, int2);
}
return 0;
}
+int processActivate (int int0, int int1, int int2) {
+ return 0;
+}
+
int processArm (int int0, int int1, int int2) {
return 0;
}
-/*
- * Item expand/collapse in a tree.
- */
int processCollapse (int int0, int int1, int int2) {
return 1; // stop emission
}
+
int processExpand (int int0, int int1, int int2) {
return 1; // stop emission
}
-/*
- * Close a Shell, triggered by delete_event
- */
int processDispose (int arg0, int arg1, int int2) {
return 1;
}
-/*
- * The WM has Iconified/Deiconified a Shell.
- * The Gtk event is map_event/unmap_event
- */
-int processIconify (int int0, int int1, int int2) {
+int processDefaultSelection (int int0, int int1, int int2) {
return 0;
}
+
int processDeiconify (int int0, int int1, int int2) {
return 0;
}
+int processFocusIn(int int0, int int1, int int2) {
+ return 0;
+}
+
+int processFocusOut(int int0, int int1, int int2) {
+ return 0;
+}
+
int processHelp (int int0, int int1, int int2) {
return 0;
}
+
int processHide (int int0, int int1, int int2) {
return 0;
}
-int processFocusIn(int int0, int int1, int int2) {
+
+int processIconify (int int0, int int1, int int2) {
return 0;
}
-int processFocusOut(int int0, int int1, int int2) {
- return 0;
-}
+
int processKeyDown (int arg0, int arg1, int int2) {
return 0;
}
+
int processKeyUp (int arg0, int arg1, int int2) {
return 0;
}
+
int processModify (int arg0, int arg1, int int2) {
return 0;
}
-int processMouse (int callData, int arg1, int int2) {
- switch (OS.GDK_EVENT_TYPE(callData)) {
- case OS.GDK_BUTTON_PRESS:
- case OS.GDK_2BUTTON_PRESS:
- return processMouseDown (callData, arg1, int2);
- case OS.GDK_BUTTON_RELEASE:
- return processMouseUp (callData, arg1, int2);
- }
- return 0;
-}
+
int processMouseDown (int arg0, int arg1, int int2) {
return 0;
}
+
int processMouseEnter (int arg0, int arg1, int int2) {
return 0;
}
+
int processMouseExit (int arg0, int arg1, int int2) {
- /* Do nothing */
return 0;
}
+
int processMouseHover (int arg0, int arg1, int int2) {
- /* Do nothing */
return 0;
}
+
int processMouseMove (int arg0, int arg1, int int2) {
/* Do nothing */
/* Even though we do nothing, we still need to at least
@@ -663,62 +677,49 @@
int processPaint (int int0, int int1, int int2) {
return 0;
}
+
int processResize (int int0, int int1, int int2) {
return 0;
}
+
int processSelection (int int0, int int1, int int2) {
return 0;
}
+
int processShow (int int0, int int1, int int2) {
return 0;
}
-int processDoubleSelection (int int0, int int1, int int2) {
+
+int processTimer (int id) {
return 0;
}
+
int processVerify (int int0, int int1, int int2) {
sendEvent (SWT.Verify);
return 0;
}
-void signal_connect (int handle, String eventName, int swtEvent, int numArgs) {
- int proc=0;
- switch (numArgs) {
- case 2: proc=getDisplay().windowProc2; break;
- case 3: proc=getDisplay().windowProc3; break;
- case 4: proc=getDisplay().windowProc4; break;
- case 5: proc=getDisplay().windowProc5; break;
- default: error(SWT.ERROR_INVALID_ARGUMENT);
- }
- /*OS.g_signal_connect (handle, eventName, proc, swtEvent);*/
- byte [] buffer = Converter.wcsToMbcs (null, eventName, true);
- OS.gtk_signal_connect(handle, buffer, proc, swtEvent);
-}
-void signal_connect_after (int handle, String eventName, int swtEvent, int numArgs) {
- byte [] buffer = Converter.wcsToMbcs (null, eventName, true);
- int proc=0;
- switch (numArgs) {
- case 2: proc=getDisplay().windowProc2; break;
- case 3: proc=getDisplay().windowProc3; break;
- case 4: proc=getDisplay().windowProc4; break;
- case 5: proc=getDisplay().windowProc5; break;
- default: error(SWT.ERROR_INVALID_ARGUMENT);
- }
- OS.gtk_signal_connect_after (handle, buffer, proc, swtEvent);
+void register () {
+ if (handle == 0) return;
+ if ((state & HANDLE) != 0) WidgetTable.put (handle, this);
}
void releaseChild () {
/* Do nothing */
}
+
void releaseHandle () {
handle = 0;
state |= DISPOSED;
}
+
void releaseWidget () {
sendEvent (SWT.Dispose);
deregister ();
eventTable = null;
data = null;
}
+
/**
* Removes the listener from the collection of listeners who will
* be notifed when an event of the given type occurs.
@@ -744,6 +745,7 @@
if (eventTable == null) return;
eventTable.unhook (eventType, handler);
}
+
/**
* Warning: API under construction.
*/
@@ -754,6 +756,7 @@
if (eventTable == null) return;
eventTable.unhook (eventType, handler);
}
+
/**
* Removes the listener from the collection of listeners who will
* be notifed when the widget is disposed.
@@ -778,16 +781,19 @@
if (eventTable == null) return;
eventTable.unhook (SWT.Dispose, listener);
}
+
void sendEvent (int eventType) {
if (eventTable == null) return;
sendEvent (eventType, new Event ());
}
+
void sendEvent (int eventType, Event event) {
if (eventTable == null) return;
event.widget = this;
event.type = eventType;
eventTable.sendEvent (event);
}
+
/**
* Sets the application defined widget data associated
* with the receiver to be the argument. The <em>widget
@@ -812,6 +818,7 @@
checkWidget();
this.data = data;
}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given value.
@@ -884,6 +891,34 @@
keys = newKeys;
values = newValues;
}
+
+void signal_connect (int handle, String eventName, int swtEvent, int numArgs) {
+ int proc=0;
+ switch (numArgs) {
+ case 2: proc=getDisplay().windowProc2; break;
+ case 3: proc=getDisplay().windowProc3; break;
+ case 4: proc=getDisplay().windowProc4; break;
+ case 5: proc=getDisplay().windowProc5; break;
+ default: error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ /*OS.g_signal_connect (handle, eventName, proc, swtEvent);*/
+ byte [] buffer = Converter.wcsToMbcs (null, eventName, true);
+ OS.gtk_signal_connect(handle, buffer, proc, swtEvent);
+}
+
+void signal_connect_after (int handle, String eventName, int swtEvent, int numArgs) {
+ byte [] buffer = Converter.wcsToMbcs (null, eventName, true);
+ int proc=0;
+ switch (numArgs) {
+ case 2: proc=getDisplay().windowProc2; break;
+ case 3: proc=getDisplay().windowProc3; break;
+ case 4: proc=getDisplay().windowProc4; break;
+ case 5: proc=getDisplay().windowProc5; break;
+ default: error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ OS.gtk_signal_connect_after (handle, buffer, proc, swtEvent);
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
@@ -903,6 +938,10 @@
return handle;
}
+boolean translateTraversal (int event) {
+ return false;
+}
+
char wcsToMbcs (char ch) {
int key = ch & 0xFFFF;
if (key <= 0x7F) return ch;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Cursor.java
index 5265851..79d7ae7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Cursor.java
@@ -30,6 +30,9 @@
* CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
* </dd>
* </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GC.java
index 2437492..ad70692 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GC.java
@@ -828,8 +828,9 @@
* different sized) rectangular area in the receiver. If the source
* and destination areas are of differing sizes, then the source
* area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any of the given coordinates
- * are negative or lie outside the bounds of their respective images.
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
*
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
@@ -844,7 +845,8 @@
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of their respective images</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Button.java
index c08b892..95638b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Button.java
@@ -22,6 +22,9 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
index ebe8093..9e0bdc0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
@@ -123,7 +123,10 @@
byte [] titleBytes;
titleBytes = Converter.wcsToMbcs (null, title, true);
handle = OS.gtk_color_selection_dialog_new (titleBytes);
- GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+ if (parent!=null) {
+ OS.gtk_window_set_modal(handle, true);
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ } GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
OS.memmove (dialog, handle, GtkColorSelectionDialog.sizeof);
OS.gtk_widget_hide (dialog.help_button);
if (rgb != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Combo.java
index b192c92..e7b6066 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Combo.java
@@ -39,6 +39,9 @@
* <dd>DefaultSelection, Modify, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Display.java
index af330a3f7..bfec8ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Display.java
@@ -1237,6 +1237,23 @@
}
/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ /* This is not supported on GTK */
+}
+
+/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
* <p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Group.java
index 93cc92e..64575d9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Group.java
@@ -25,6 +25,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/GtkFileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/GtkFileDialog.java
index 1cfabc2..e304e40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/GtkFileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/GtkFileDialog.java
@@ -22,7 +22,10 @@
/* create */
byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
handle = OS.gtk_file_selection_new (titleBytes);
-
+ if (parent!=null) {
+ OS.gtk_window_set_modal(handle, true);
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
/* buttons */
GtkFileSelection dialog = new GtkFileSelection ();
OS.memmove (dialog, handle, GtkFileSelection.sizeof);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Label.java
index 84f872b..d054946 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Label.java
@@ -23,6 +23,10 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of SHADOW_IN and SHADOW_OUT may be specified. Only
+ * one of HORIZONTAL and VERTICAL may be specified. Only one of CENTER,
+ * LEFT and RIGHT may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/List.java
index 053ba6c..00c7f01 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/List.java
@@ -24,6 +24,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
index 7a77f50..c426e46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
@@ -20,7 +20,9 @@
* <dt><b>Events:</b></dt>
* <dd>Help, Hide, Show </dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
index 1de7188..35263f1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
@@ -20,7 +20,10 @@
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- *<p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MessageBox.java
index ed3a745..6575962 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MessageBox.java
@@ -24,6 +24,9 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ProgressBar.java
index b5b36ce..96f7f0d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ProgressBar.java
@@ -21,6 +21,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Sash.java
index cad77f4..8918306 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Sash.java
@@ -22,6 +22,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Scale.java
index 7baf8ad..f2c6e4b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Scale.java
@@ -22,6 +22,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ScrollBar.java
index 861a36e..b12ed1e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ScrollBar.java
@@ -64,7 +64,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see Slider
* @see Scrollable
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Shell.java
index d93c35d..9789ed1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Shell.java
@@ -84,6 +84,9 @@
* </dl>
* </p>
* <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Slider.java
index f01f6e5..19f3a31 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Slider.java
@@ -52,7 +52,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see ScrollBar
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Table.java
index d45196a..ff075c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Table.java
@@ -29,6 +29,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
index eab13db..3fddf71 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
@@ -19,7 +19,9 @@
* <dt><b>Events:</b></dt>
* <dd> Move, Resize, Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Text.java
index b6f5f5c..a22e0eb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Text.java
@@ -21,8 +21,11 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Verify</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class Text extends Scrollable {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
index e1e5bed..99d404a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
@@ -28,6 +28,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolItem.java
index e20c76f..b84a8f1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolItem.java
@@ -14,15 +14,18 @@
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
- * <p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class ToolItem extends Item {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tree.java
index 9583341..1c6f02e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tree.java
@@ -30,6 +30,8 @@
* <dd>Selection, DefaultSelection, Collapse, Expand</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
index 5792dea..ab67668 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
@@ -28,6 +28,9 @@
* CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
* </dd>
* </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
index d0e793e..601d930 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
@@ -277,36 +277,39 @@
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any of the given coordinates
- * are negative or lie outside the bounds of their respective images.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of their respective images</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
index ed3a853..187aa1c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
@@ -46,7 +46,7 @@
CodePage = new String (buffer);
if (OS.IsSunOS) {
if (length > 3 && CodePage.indexOf ("ISO") == 0) {
- CodePage = CodePage.substring (3, length - 3);
+ CodePage = CodePage.substring (3, length);
}
}
} else {
@@ -131,6 +131,7 @@
if (LastMBToWC == 0) {
LastMBToWCCodePage = cp;
LastMBToWC = OS.iconv_open (Unicode, getAsciiBytes (cp));
+ if (LastMBToWC == -1) LastMBToWC = 0;
}
int cd = LastMBToWC;
if (cd == 0) return EMPTY_CHAR_ARRAY;
@@ -229,6 +230,7 @@
if (LastWCToMB == 0) {
LastWCToMBCodePage = cp;
LastWCToMB = OS.iconv_open (getAsciiBytes (cp), Unicode);
+ if (LastWCToMB == -1) LastWCToMB = 0;
}
int cd = LastWCToMB;
if (cd == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
index 96e26b0..3357f54 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
@@ -22,6 +22,9 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
index d5c8848..8d4e5bc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
@@ -39,6 +39,9 @@
* <dd>DefaultSelection, Modify, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
@@ -691,6 +694,7 @@
OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, SWT.Modify);
OS.XtAddEventHandler (argList[1], OS.KeyPressMask, false, windowProc, SWT.KeyDown);
OS.XtAddEventHandler (argList[1], OS.KeyReleaseMask, false, windowProc, SWT.KeyUp);
+ OS.XtInsertEventHandler (argList[1], OS.FocusChangeMask, false, windowProc, SWT.FocusIn, OS.XtListTail);
}
/**
* Searches the receiver's list starting at the first item
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
index 4d6d879..3e67d9a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
@@ -93,16 +93,15 @@
}
Control [] _getTabList () {
if (tabList == null) return tabList;
- int index = 0, count = 0;
- while (index < tabList.length) {
- if (!tabList [index].isDisposed ()) count++;
- index++;
- }
- if (index == count) return tabList;
- Control [] newList = new Control [count];
- index = 0;
+ int count = 0;
for (int i=0; i<tabList.length; i++) {
- if (!tabList [index].isDisposed ()) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
newList [index++] = tabList [i];
}
}
@@ -471,17 +470,18 @@
if (xDisplay == 0) return 0;
Event event = new Event ();
GC gc = event.gc = new GC (this);
- OS.XSetRegion (xDisplay, gc.handle, damagedRegion);
+ Region region = Region.motif_new (damagedRegion);
+ gc.setClipping (region);
XRectangle rect = new XRectangle ();
OS.XClipBox (damagedRegion, rect);
- OS.XDestroyRegion (damagedRegion);
- damagedRegion = 0;
event.time = OS.XtLastTimestampProcessed (xDisplay);
event.x = rect.x; event.y = rect.y;
event.width = rect.width; event.height = rect.height;
sendEvent (SWT.Paint, event);
gc.dispose ();
event.gc = null;
+ OS.XDestroyRegion (damagedRegion);
+ damagedRegion = 0;
return 0;
}
void propagateChildren (boolean enabled) {
@@ -583,31 +583,44 @@
checkWidget();
this.layout = layout;
}
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order; must not be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the tabList is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
public void setTabList (Control [] tabList) {
checkWidget ();
- if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This code is intentionally commented.
+ * Tab lists are currently only supported
+ * for the direct children of a composite.
+ */
+// Shell shell = control.getShell ();
+// while (control != shell && control != this) {
+// control = control.parent;
+// }
+// if (control != this) error (SWT.ERROR_INVALID_PARENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control [] newList = new Control [tabList.length];
+ System.arraycopy (tabList, 0, newList, 0, tabList.length);
+ tabList = newList;
+ }
this.tabList = tabList;
}
boolean setTabGroupFocus () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
index 4f602d7..c7caee4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
@@ -1085,11 +1085,23 @@
return true;
}
boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
int code = traversalCode (0, null);
if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
}
boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
int code = traversalCode (0, null);
return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
}
@@ -1386,10 +1398,7 @@
event.x = xEvent.x; event.y = xEvent.y;
event.width = xEvent.width; event.height = xEvent.height;
GC gc = event.gc = new GC (this);
- XRectangle rect = new XRectangle ();
- rect.x = (short) xEvent.x; rect.y = (short) xEvent.y;
- rect.width = (short) xEvent.width; rect.height = (short) xEvent.height;
- OS.XSetClipRectangles (xDisplay, gc.handle, 0, 0, rect, 1, OS.Unsorted);
+ gc.setClipping (event.x, event.y, event.width, event.height);
sendEvent (SWT.Paint, event);
if (!gc.isDisposed ()) gc.dispose ();
event.gc = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
index c1a83d5..701f737 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
@@ -308,6 +308,12 @@
checkWidget();
return label;
}
+boolean isTabGroup () {
+ return true;
+}
+boolean isTabItem () {
+ return false;
+}
Decorations menuShell () {
return this;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
index fc7a4e8..da45171 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
@@ -666,9 +666,7 @@
public Point getCursorLocation () {
checkDevice ();
int window = OS.XDefaultRootWindow (xDisplay);
- int [] rootX = new int [1];
- int [] rootY = new int [1];
- int [] unused = new int [1];
+ int [] rootX = new int [1], rootY = new int [1], unused = new int [1];
OS.XQueryPointer(xDisplay, window, unused, unused, rootX, rootY, unused, unused, unused);
return new Point (rootX [0], rootY [0]);
}
@@ -1418,8 +1416,6 @@
Displays = newDisplays;
}
protected void release () {
-
- /* Release shells */
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
@@ -1428,20 +1424,15 @@
}
}
while (readAndDispatch ()) {};
-
- /* Run dispose list */
if (disposeList != null) {
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] != null) disposeList [i].run ();
}
}
- disposeList = null;
-
- /* Release synchronizer */
+ disposeList = null;
synchronizer.releaseSynchronizer ();
synchronizer = null;
releaseDisplay ();
-
super.release ();
}
void releaseDisplay () {
@@ -1574,6 +1565,26 @@
return true;
}
/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int x = point.x;
+ int y = point.y;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y);
+}
+/**
* On platforms which support it, sets the application name
* to be the argument. On Motif, for example, this can be used
* to set the name used for resource lookup.
@@ -1732,7 +1743,11 @@
if (xmString != 0) OS.XmStringFree (xmString);
} else {
int widgetClass = OS.OverrideShellWidgetClass ();
- int [] argList1 = {OS.XmNmwmDecorations, 0, OS.XmNborderWidth, 1};
+ int [] argList1 = {
+ OS.XmNmwmDecorations, 0,
+ OS.XmNborderWidth, 1,
+ OS.XmNallowShellResize, 1,
+ };
shellHandle = OS.XtCreatePopupShell (null, widgetClass, handle, argList1, argList1.length / 2);
Color infoForeground = getSystemColor (SWT.COLOR_INFO_FOREGROUND);
Color infoBackground = getSystemColor (SWT.COLOR_INFO_BACKGROUND);
@@ -1808,23 +1823,23 @@
OS.FD_SET (display_fd, fd_set);
OS.FD_SET (read_fd, fd_set);
timeout [0] = 0;
- timeout [1] = 100;
+ timeout [1] = 100000;
OS.select (max_fd + 1, fd_set, null, null, timeout);
return OS.FD_ISSET (display_fd, fd_set);
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes.
- *
- * @param runnable code to run on the user-interface thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @see #asyncExec
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
*/
public void syncExec (Runnable runnable) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
index 032bad5..60e2f7d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
@@ -61,7 +61,7 @@
private static final String PREFIX_TRADITIONALCHINESE = "cns";
private static final String PREFIX_KOREAN = "ks";
private static final String [] ISO_CHARSETS = new String [] {
- "", // undefined
+ "", // 0 undefined
SWT.getMessage ("SWT_Charset_Western"),
SWT.getMessage ("SWT_Charset_EastEuropean"),
SWT.getMessage ("SWT_Charset_SouthEuropean"),
@@ -73,10 +73,11 @@
SWT.getMessage ("SWT_Charset_Turkish"),
SWT.getMessage ("SWT_Charset_Nordic"),
SWT.getMessage ("SWT_Charset_Thai"),
- "", // undefined
+ "", // 12 undefined
SWT.getMessage ("SWT_Charset_BalticRim"),
SWT.getMessage ("SWT_Charset_Celtic"),
- SWT.getMessage ("SWT_Charset_Euro")
+ SWT.getMessage ("SWT_Charset_Euro"),
+ SWT.getMessage ("SWT_Charset_Romanian")
};
/**
@@ -444,9 +445,10 @@
* value is already specified above.
*/
}
-
- characterSet += "-" + charSetName;
- translatedCharSet = ISO_CHARSETS [charSetName];
+ if (charSetName < ISO_CHARSETS.length) {
+ characterSet += "-" + charSetName;
+ translatedCharSet = ISO_CHARSETS [charSetName];
+ }
}
else
if (characterSet.startsWith (PREFIX_ISO646)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
index 36e3af9..92d65cc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
@@ -25,6 +25,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
index ce75196..302a2e2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
@@ -24,6 +24,10 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of SHADOW_IN and SHADOW_OUT may be specified. Only
+ * one of HORIZONTAL and VERTICAL may be specified. Only one of CENTER,
+ * LEFT and RIGHT may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
index 7a56950..cbbde1a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
@@ -24,6 +24,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
index 036f385..6153756 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
@@ -19,6 +19,8 @@
* <dd>Help, Hide, Show </dd>
* </dl>
* <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
index 7d16560..4348071 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
@@ -20,7 +20,10 @@
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- *<p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
index f3c445e..26c488f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
@@ -24,6 +24,9 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
index a06fff2..6c5c14d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
@@ -20,6 +20,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
index 1e11582..8f0b7a0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
@@ -21,6 +21,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -173,6 +175,7 @@
byte [] buffer = new byte [1];
int [] keysym = new int [1];
OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
+
switch (keysym [0]) {
case OS.XK_Left:
case OS.XK_Right:
@@ -205,24 +208,49 @@
newY = Math.min (Math.max (0, lastY + yChange - parentBorder - startY), parentHeight - height);
}
if (newX == lastX && newY == lastY) return 0;
+
+ /* Ensure that the pointer image does not change */
+ int xDisplay = getDisplay().xDisplay;
+ int xWindow = OS.XtWindow (parent.handle);
+ int ptrGrabResult = OS.XGrabPointer (
+ xDisplay,
+ xWindow,
+ 1,
+ OS.None,
+ OS.GrabModeAsync,
+ OS.GrabModeAsync,
+ OS.None,
+ cursor,
+ OS.CurrentTime);
+
/* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.time = xEvent.time;
event.x = newX; event.y = newY;
event.width = width; event.height = height;
+ sendEvent (SWT.Selection, event);
+ if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+
/*
* It is possible (but unlikely) that client code could have disposed
* the widget in the selection event. If this happens end the processing
* of this message by returning.
*/
- sendEvent (SWT.Selection, event);
if (isDisposed ()) break;
if (event.doit) {
lastX = event.x; lastY = event.y;
+ /* Adjust the pointer position */
+ int cursorX = newX; int cursorY = newY;
+ if ((style & SWT.VERTICAL) != 0) {
+ cursorY += height / 2;
+ } else {
+ cursorX += width / 2;
+ }
+ OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, cursorX, cursorY);
}
break;
}
-
+
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
index f6fbf68..52d3497 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
@@ -21,6 +21,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
index 5a9038d..946aa1c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
@@ -63,8 +63,11 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
- *
+ * </p>
+ *
* @see Slider
* @see Scrollable
* @see Scrollable#getHorizontalBar
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
index 87ec885..748e8c8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
@@ -84,6 +84,9 @@
* </dl>
* </p>
* <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
@@ -582,6 +585,31 @@
super.enableWidget (enabled);
enableHandle (enabled, shellHandle);
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void forceActive () {
+ checkWidget ();
+ bringToTop ();
+}
public int getBorderWidth () {
checkWidget();
int [] argList = {OS.XmNborderWidth, 0};
@@ -746,15 +774,21 @@
* the display on which it was created (so that all other
* shells on that display, which are not the receiver's
* children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one).
+ * and sets focus to its default button (if it has one)
+ * and asks the window manager to make the shell active.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
+ * @see Control#moveAbove
+ * @see Control#setFocus
* @see Control#setVisible
+ * @see Display#getActiveShell
* @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
public void open () {
checkWidget();
@@ -825,14 +859,18 @@
int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window);
if (handle != shellHandle) return super.processSetFocus (callData);
if (xEvent.mode != OS.NotifyNormal) return 0;
- if (xEvent.detail != OS.NotifyNonlinear) return 0;
- switch (xEvent.type) {
- case OS.FocusIn:
- postEvent (SWT.Activate);
- break;
- case OS.FocusOut:
- postEvent (SWT.Deactivate);
- break;
+ switch (xEvent.detail) {
+ case OS.NotifyNonlinear:
+ case OS.NotifyNonlinearVirtual: {
+ switch (xEvent.type) {
+ case OS.FocusIn:
+ postEvent (SWT.Activate);
+ break;
+ case OS.FocusOut:
+ postEvent (SWT.Deactivate);
+ break;
+ }
+ }
}
return 0;
}
@@ -908,6 +946,32 @@
oldWidth = argList [1]; oldHeight = argList [3];
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
void setActiveControl (Control control) {
if (control != null && control.isDisposed ()) control = null;
if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
index e47e211..13ea606 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
@@ -51,7 +51,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see ScrollBar
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
index 8af4a8b..41abebc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
@@ -21,8 +21,11 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Verify</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class Text extends Scrollable {
char echoCharacter;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
index 10a0d35..7a5bcdf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
@@ -27,6 +27,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
index e23b5a5..0967720 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
@@ -14,15 +14,18 @@
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
- * <p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class ToolItem extends Item {
ToolBar parent;
@@ -575,6 +578,33 @@
this.control = control;
if (control != null && !control.isDisposed ()) {
control.setBounds (getBounds ());
+ /*
+ * It is possible that the control was created with a
+ * z-order below that of the current tool item. In this
+ * case, the control is not visible because it is
+ * obscured by the tool item. The fix is to move the
+ * control above this tool item in the z-order.
+ * The code below is similar to the code found in
+ * setZOrder.
+ */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ if (!OS.XtIsRealized (handle)) {
+ Shell shell = parent.getShell ();
+ shell.realizeWidget ();
+ }
+ int topHandle1 = control.topHandle ();
+ int window1 = OS.XtWindow (topHandle1);
+ if (window1 == 0) return;
+ int topHandle2 = this.topHandle ();
+ int window2 = OS.XtWindow (topHandle2);
+ if (window2 == 0) return;
+ XWindowChanges struct = new XWindowChanges ();
+ struct.sibling = window2;
+ struct.stack_mode = OS.Above;
+ int screen = OS.XDefaultScreen (xDisplay);
+ int flags = OS.CWStackMode | OS.CWSibling;
+ OS.XReconfigureWMWindow (xDisplay, window1, screen, flags, struct);
}
}
/**
@@ -741,10 +771,23 @@
int processKeyDown (int callData) {
XKeyEvent xEvent = new XKeyEvent ();
OS.memmove (xEvent, callData, XKeyEvent.sizeof);
-
+ int [] keysym = new int [1];
+ OS.XLookupString (xEvent, null, 0, keysym, null);
+ keysym [0] &= 0xFFFF;
+ switch (keysym [0]) {
+ case OS.XK_space:
+ click (false, xEvent);
+ break;
+ case OS.XK_Return:
+ click (true, xEvent);
+ break;
+ case OS.XK_Down:
+ if ((style & SWT.DROP_DOWN) != 0) click (true, xEvent);
+ break;
+ }
/*
* Forward the key event to the parent.
- * This is necessary so that mouse listeners
+ * This is necessary so that key listeners
* in the parent will be called, despite the
* fact that the event did not really occur
* in X in the parent. This is done to be
@@ -758,18 +801,10 @@
int processKeyUp (int callData) {
XKeyEvent xEvent = new XKeyEvent ();
OS.memmove (xEvent, callData, XKeyEvent.sizeof);
- int [] keysym = new int [1];
- OS.XLookupString (xEvent, null, 0, keysym, null);
- keysym [0] &= 0xFFFF;
- switch (keysym [0]) {
- case OS.XK_space:
- case OS.XK_Return:
- click (keysym [0] == OS.XK_Return, xEvent);
- break;
- }
+
/*
* Forward the key event to the parent.
- * This is necessary so that mouse listeners
+ * This is necessary so that key listeners
* in the parent will be called, despite the
* fact that the event did not really occur
* in X in the parent. This is done to be
@@ -844,6 +879,7 @@
return parent.translateMnemonic (key, xEvent);
}
boolean translateTraversal (int key, XKeyEvent xEvent) {
+ if (key == OS.XK_Down) return true;
return parent.translateTraversal (key, xEvent);
}
int processMouseHover (int id) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
index 2f1eff8..6a98049 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
@@ -28,6 +28,9 @@
* CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
* </dd>
* </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
index 26a0e17..09099c4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -245,7 +245,7 @@
if (object == this) return true;
if (!(object instanceof FontData)) return false;
FontData data = (FontData)object;
- return name == name && height == data.height && style == data.style;
+ return name.equals(data.name) && height == data.height && style == data.style;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
index 5942ace..eb0c21b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
@@ -557,36 +557,38 @@
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any of the given coordinates
- * are negative or lie outside the bounds of their respective images.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of their respective images</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
index 3581d59..133817a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -21,7 +21,10 @@
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
index 6e077c5..916df5e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -38,7 +38,10 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
index 0415396..b55d7ff 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -96,16 +96,15 @@
Control [] _getTabList () {
if (tabList == null) return tabList;
- int index = 0, count = 0;
- while (index < tabList.length) {
- if (!tabList [index].isDisposed ()) count++;
- index++;
- }
- if (index == count) return tabList;
- Control [] newList = new Control [count];
- index = 0;
+ int count = 0;
for (int i=0; i<tabList.length; i++) {
- if (!tabList [index].isDisposed ()) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
newList [index++] = tabList [i];
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
index a12129e..135b775 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -1176,9 +1176,6 @@
}
protected void release () {
- super.release ();
-
- /* Release shells */
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
@@ -1187,20 +1184,16 @@
}
}
while (readAndDispatch ()) {};
-
- /* Run dispose list */
if (disposeList != null) {
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] != null) disposeList [i].run ();
}
}
disposeList = null;
-
- /* Release synchronizer */
synchronizer.releaseSynchronizer ();
synchronizer = null;
-
- releaseDisplay ();
+ releaseDisplay ();
+ super.release ();
}
void releaseDisplay () {
@@ -1287,6 +1280,26 @@
return true;
}
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int x = point.x;
+ int y = point.y;
+ OS.PhMoveCursorAbs (OS.PhInputGroup (0), x, y);
+}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
index 4b34140..580dd0c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -24,7 +24,9 @@
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
index ac2d0a8..cebe323 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -22,7 +22,11 @@
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of SHADOW_IN and SHADOW_OUT may be specified. Only
+ * one of HORIZONTAL and VERTICAL may be specified. Only one of CENTER,
+ * LEFT and RIGHT may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index 5168810..66ae0b5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -22,7 +22,9 @@
* <dt><b>Events:</b></dt>
* <dd>Selection, DefaultSelection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
index b4e18b0..2978c2c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -19,7 +19,9 @@
* <dt><b>Events:</b></dt>
* <dd>Help, Hide, Show </dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
index f90b184..54c9ff5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -20,7 +20,10 @@
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- *<p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
index 53448d4..36a248b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
@@ -22,7 +22,10 @@
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
index 57f5131..1ef9641 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
@@ -19,7 +19,9 @@
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
index 8d7b8e1..27c1d9b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
@@ -20,7 +20,9 @@
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
index 9904441..83fc776 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
@@ -20,7 +20,9 @@
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
index ac2a431..a152a15 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -62,8 +62,11 @@
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see Slider
* @see Scrollable
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
index 871abc5..d6d4c33 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -84,6 +84,9 @@
* </dl>
* </p>
* <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
@@ -432,6 +435,32 @@
WidgetTable.remove (shellHandle);
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void forceActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
public Rectangle getBounds () {
checkWidget();
PhArea_t area = new PhArea_t ();
@@ -569,20 +598,26 @@
OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, SWT.Resize);
}
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one).
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#setVisible
- * @see Decorations#setDefaultButton
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it), marks it visible,
+ * and sets focus to its default button (if it has one)
+ * and asks the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
public void open () {
checkWidget();
@@ -719,6 +754,32 @@
eventTable.unhook (SWT.Deactivate, listener);
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
checkWidget();
if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
index 5e92487..76682cd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
@@ -50,8 +50,11 @@
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see ScrollBar
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
index 223585d..6805767 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
@@ -21,8 +21,11 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Verify</dd>
* </dl>
- * </p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class Text extends Scrollable {
char echoCharacter;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
index ec048da..daca669 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -26,7 +26,9 @@
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
- * <p>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
index 0cb41a8..7692c6f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
@@ -12,17 +12,20 @@
import org.eclipse.swt.events.*;
/**
- * Instances of this class represent a selectable user interface object
- * that represents a button in a tool bar.
- * <p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * </p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * Instances of this class represent a selectable user interface object
+ * that represents a button in a tool bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class ToolItem extends Item {
ToolBar parent;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
index 297c234..ee0fa71 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
@@ -28,6 +28,9 @@
* CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
* </dd>
* </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index 1eb1700..bff815e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -427,8 +427,9 @@
* different sized) rectangular area in the receiver. If the source
* and destination areas are of differing sizes, then the source
* area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any of the given coordinates
- * are negative or lie outside the bounds of their respective images.
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
*
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
@@ -443,7 +444,8 @@
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of their respective images</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
@@ -816,32 +818,43 @@
}
}
- /* Create the mask for the source image */
- int maskHdc = OS.CreateCompatibleDC(hDC);
- int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
- int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
- OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);
- OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
- if (originalColors != null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, originalColors);
-
- /* Draw the source bitmap transparently using invert/and mask/invert */
- int tempHdc = OS.CreateCompatibleDC(hDC);
- int tempBitmap = OS.CreateCompatibleBitmap(hDC, destWidth, destHeight);
- int oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap);
- OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
- if (!OS.IsWinCE) OS.SetStretchBltMode(tempHdc, OS.COLORONCOLOR);
- OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
- OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, maskHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCAND);
- OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
- OS.BitBlt(handle, destX, destY, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY);
-
- /* Release resources */
- OS.SelectObject(tempHdc, oldTempBitmap);
- OS.DeleteDC(tempHdc);
- OS.DeleteObject(tempBitmap);
- OS.SelectObject(maskHdc, oldMaskBitmap);
- OS.DeleteDC(maskHdc);
- OS.DeleteObject(maskBitmap);
+ if (OS.IsWinCE) {
+ /*
+ * Note in WinCE. TransparentImage uses the first entry of a palette
+ * based image when there are multiple entries that have the same
+ * transparent color.
+ */
+ int transparentColor = transBlue << 16 | transGreen << 8 | transRed;
+ OS.TransparentImage(handle, destX, destY, destWidth, destHeight,
+ srcHdc, srcX, srcY, srcWidth, srcHeight, transparentColor);
+ } else {
+ /* Create the mask for the source image */
+ int maskHdc = OS.CreateCompatibleDC(hDC);
+ int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
+ int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
+ OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);
+ OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ if (originalColors != null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, originalColors);
+
+ /* Draw the source bitmap transparently using invert/and mask/invert */
+ int tempHdc = OS.CreateCompatibleDC(hDC);
+ int tempBitmap = OS.CreateCompatibleBitmap(hDC, destWidth, destHeight);
+ int oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap);
+ OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
+ if (!OS.IsWinCE) OS.SetStretchBltMode(tempHdc, OS.COLORONCOLOR);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, maskHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCAND);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
+ OS.BitBlt(handle, destX, destY, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY);
+
+ /* Release resources */
+ OS.SelectObject(tempHdc, oldTempBitmap);
+ OS.DeleteDC(tempHdc);
+ OS.DeleteObject(tempBitmap);
+ OS.SelectObject(maskHdc, oldMaskBitmap);
+ OS.DeleteDC(maskHdc);
+ OS.DeleteObject(maskBitmap);
+ }
OS.SelectObject(srcHdc, oldSrcBitmap);
if (hBitmap != srcImage.handle) OS.DeleteObject(hBitmap);
OS.DeleteDC(srcHdc);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 5eb7edd..4c7314e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -22,6 +22,9 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -308,7 +311,8 @@
}
boolean isTabItem () {
- if ((style & SWT.PUSH) != 0) return true;
+ //TEMPORARY CODE
+ //if ((style & SWT.PUSH) != 0) return true;
return super.isTabItem ();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index 49ba265..76347de 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -39,6 +39,9 @@
* <dd>DefaultSelection, Modify, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index 57c57c0..fb8c23e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -96,16 +96,15 @@
Control [] _getTabList () {
if (tabList == null) return tabList;
- int index = 0, count = 0;
- while (index < tabList.length) {
- if (!tabList [index].isDisposed ()) count++;
- index++;
- }
- if (index == count) return tabList;
- Control [] newList = new Control [count];
- index = 0;
+ int count = 0;
for (int i=0; i<tabList.length; i++) {
- if (!tabList [index].isDisposed ()) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
newList [index++] = tabList [i];
}
}
@@ -363,10 +362,9 @@
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
*
- * @param tabList the ordered list of controls representing the tab order; must not be null
+ * @param tabList the ordered list of controls representing the tab order or null
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the tabList is null</li>
* <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
* <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
* </ul>
@@ -377,44 +375,27 @@
*/
public void setTabList (Control [] tabList) {
checkWidget ();
- if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
-// Shell shell = control.getShell ();
-// while (control != shell && control != this) {
-// control = control.parent;
-// }
-// if (control != this) error (SWT.ERROR_INVALID_PARENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- /*
- * This code is intentionally commented. It is
- * not yet clear whether setting the tab list
- * should force the widget to be a tab group
- * instead of a tab item or non-traversable.
- */
-// Control [] children = _getChildren ();
-// for (int i=0; i<children.length; i++) {
-// Control control = children [i];
-// if (control != null) {
-// if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
-// int index = 0;
-// while (index < tabList.length) {
-// if (tabList [index] == control) break;
-// index++;
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This code is intentionally commented.
+ * Tab lists are currently only supported
+ * for the direct children of a composite.
+ */
+// Shell shell = control.getShell ();
+// while (control != shell && control != this) {
+// control = control.parent;
// }
-// int hwnd = control.handle;
-// int bits = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
-// if (index == tabList.length) {
-// bits &= ~OS.WS_TABSTOP;
-// } else {
-// bits |= OS.WS_TABSTOP;
-// }
-// OS.SetWindowLong (hwnd, OS.GWL_STYLE, bits);
-// }
-// }
+// if (control != this) error (SWT.ERROR_INVALID_PARENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control [] newList = new Control [tabList.length];
+ System.arraycopy (tabList, 0, newList, 0, tabList.length);
+ tabList = newList;
+ }
this.tabList = tabList;
}
@@ -430,7 +411,7 @@
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
- if (child.isVisible () && child.setRadioFocus ()) return true;
+ if (child.isTabItem () && child.setRadioFocus ()) return true;
}
for (int i=0; i<children.length; i++) {
Control child = children [i];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index fc8f7d2..3a8aa67 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -1137,11 +1137,23 @@
}
boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
return (bits & OS.WS_TABSTOP) != 0;
}
boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.WS_TABSTOP) != 0) return false;
int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
@@ -2228,8 +2240,8 @@
* focus. If no window will take focus, set focus to the
* desktop.
*/
-// boolean fixFocus = false;
-// if (!visible) fixFocus = isFocusAncestor ();
+ boolean fixFocus = false;
+ if (!visible) fixFocus = isFocusAncestor ();
OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
if (!visible) {
/*
@@ -2240,7 +2252,7 @@
sendEvent (SWT.Hide);
if (isDisposed ()) return;
}
-// if (fixFocus) fixFocus ();
+ if (fixFocus) fixFocus ();
}
void sort (int [] items) {
@@ -2653,6 +2665,7 @@
case OS.WM_CUT: result = WM_CUT (wParam, lParam); break;
case OS.WM_DESTROY: result = WM_DESTROY (wParam, lParam); break;
case OS.WM_DRAWITEM: result = WM_DRAWITEM (wParam, lParam); break;
+ case OS.WM_ENDSESSION: result = WM_ENDSESSION (wParam, lParam); break;
case OS.WM_ERASEBKGND: result = WM_ERASEBKGND (wParam, lParam); break;
case OS.WM_GETDLGCODE: result = WM_GETDLGCODE (wParam, lParam); break;
case OS.WM_HELP: result = WM_HELP (wParam, lParam); break;
@@ -2687,6 +2700,8 @@
case OS.WM_PAINT: result = WM_PAINT (wParam, lParam); break;
case OS.WM_PALETTECHANGED: result = WM_PALETTECHANGED (wParam, lParam); break;
case OS.WM_PASTE: result = WM_PASTE (wParam, lParam); break;
+ case OS.WM_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break;
+ case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (wParam, lParam); break;
case OS.WM_QUERYNEWPALETTE: result = WM_QUERYNEWPALETTE (wParam, lParam); break;
case OS.WM_QUERYOPEN: result = WM_QUERYOPEN (wParam, lParam); break;
case OS.WM_RBUTTONDBLCLK: result = WM_RBUTTONDBLCLK (wParam, lParam); break;
@@ -2831,6 +2846,10 @@
return control.wmDrawChild (wParam, lParam);
}
+LRESULT WM_ENDSESSION (int wParam, int lParam) {
+ return null;
+}
+
LRESULT WM_ERASEBKGND (int wParam, int lParam) {
return null;
}
@@ -3630,6 +3649,14 @@
return null;
}
+LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_QUERYENDSESSION (int wParam, int lParam) {
+ return null;
+}
+
LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) {
return null;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
index ff66f0d..fbea138 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -1,7 +1,7 @@
package org.eclipse.swt.widgets;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
* All Rights Reserved
*/
@@ -34,6 +34,7 @@
public class CoolBar extends Composite {
CoolItem [] items;
CoolItem [] originalItems;
+ boolean locked;
static final int ReBarProc;
static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true);
static {
@@ -168,6 +169,9 @@
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID;
rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;
+ if ((item.style & SWT.DROP_DOWN) != 0) {
+ rbBand.fStyle |= OS.RBBS_USECHEVRON;
+ }
rbBand.lpText = lpText;
rbBand.wID = id;
if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) == 0) {
@@ -361,7 +365,7 @@
}
/**
- * Returns whether or not the coolbar is 'locked'. When a coolbar
+ * Returns whether or not the reciever is 'locked'. When a coolbar
* is locked, its items cannot be repositioned.
*
* @return true if the coolbar is locked, false otherwise
@@ -370,18 +374,12 @@
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
+ *
+ * @since 2.0
*/
public boolean getLocked () {
checkWidget ();
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_STYLE;
- for (int i=0; i<count; i++) {
- OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
- if ((rbBand.fStyle & OS.RBBS_NOGRIPPER) == 0) return false;
- }
- return true;
+ return locked;
}
/**
@@ -544,6 +542,10 @@
*
* @param sizes the new sizes for each of the receiver's items
*
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the array of sizes is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the array of sizes is not the same length as the number of items</li>
+ * </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -552,23 +554,18 @@
void setItemSizes (Point [] sizes) {
if (sizes == null) error (SWT.ERROR_NULL_ARGUMENT);
int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (sizes.length != count) error (SWT.ERROR_NULL_ARGUMENT);
+ if (sizes.length != count) error (SWT.ERROR_INVALID_ARGUMENT);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_ID;
for (int i=0; i<count; i++) {
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETBANDBORDERS, i, rect);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_SIZE | OS.RBBIM_IDEALSIZE;
- int width = sizes [i].x, height = sizes [i].y;
- rbBand.cx = width;
- rbBand.cxIdeal = width - rect.left - rect.right;
- rbBand.cyChild = rbBand.cyMinChild = rbBand.cyMaxChild = height;
- OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand);
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ items [rbBand.wID].setSize (sizes [i].x, sizes [i].y);
}
}
/**
- * Sets whether the reciever is 'locked' or not. When a coolbar
+ * Sets whether or not the reciever is 'locked'. When a coolbar
* is locked, its items cannot be repositioned.
*
* @param locked lock the coolbar if true, otherwise unlock the coolbar
@@ -577,9 +574,12 @@
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
+ *
+ * @since 2.0
*/
public void setLocked (boolean locked) {
checkWidget ();
+ this.locked = locked;
int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -650,18 +650,20 @@
/*
* Feature in Windows. When the coolbar window
* proc processes WM_COMMAND, it forwards this
- * message to the parent. This is done so that
- * children of the coolbar that send WM_COMMAND
- * messages to their parents will notify not only
- * the coolbar but also the parent of the coolbar,
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
* which is typically the application window and
- * the window that is looking for this message.
- * If the coolbar did not do this, applications
- * would have to subclass the coolbar window to
- * see WM_COMMAND messages. Because the coolbar
- * window is subclassed, the WM_COMMAND message
- * is delivered twice. The fix is to avoid
- * calling the coolbar window proc.
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
*/
LRESULT result = super.WM_COMMAND (wParam, lParam);
if (result != null) return result;
@@ -679,6 +681,30 @@
return null;
}
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the coolbar window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
LRESULT wmNotifyChild (int wParam, int lParam) {
NMHDR hdr = new NMHDR ();
OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
@@ -689,6 +715,18 @@
int height = OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
setSize (size.x, height + (border * 2));
break;
+ case OS.RBN_CHEVRONPUSHED:
+ NMREBARCHEVRON lpnm = new NMREBARCHEVRON ();
+ OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof);
+ CoolItem child = items [lpnm.wID];
+ if (child != null) {
+ Event event = new Event();
+ event.detail = SWT.ARROW;
+ event.x = lpnm.left;
+ event.y = lpnm.bottom;
+ child.postEvent (SWT.Selection, event);
+ }
+ break;
}
return super.wmNotifyChild (wParam, lParam);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
index 2317d0f..703e72a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -1,7 +1,7 @@
package org.eclipse.swt.widgets;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
* All Rights Reserved
*/
@@ -16,9 +16,9 @@
* areas of a <code>CoolBar</code>.
* <dl>
* <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
+ * <dd>DROP_DOWN</dd>
* <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
+ * <dd>Selection</dd>
* </dl>
* <p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
@@ -29,6 +29,7 @@
CoolBar parent;
Control control;
int id;
+ boolean ideal, minimum;
/**
* Constructs a new instance of this class given its parent
@@ -103,6 +104,44 @@
parent.createItem (this, index);
}
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>SWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ *
+ * @since 2.0
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
@@ -304,14 +343,22 @@
checkWidget ();
int index = parent.indexOf (this);
if (index == -1) return;
+ ideal = true;
int hwnd = parent.handle;
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
rbBand.cxIdeal = width - rect.left - rect.right;
- rbBand.cyMinChild = rbBand.cyMaxChild = height;
+ rbBand.cyMaxChild = height;
+ if (!minimum) rbBand.cyMinChild = height;
OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
}
@@ -342,10 +389,17 @@
OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_SIZE | OS.RBBIM_IDEALSIZE;
rbBand.cx = width;
- rbBand.cxIdeal = width - rect.left - rect.right;
- rbBand.cyChild = rbBand.cyMinChild = rbBand.cyMaxChild = height;
+ if (!ideal) rbBand.cxIdeal = width - rect.left - rect.right;
+ if (!minimum) rbBand.cyMinChild = height;
+ rbBand.cyChild = rbBand.cyMaxChild = height;
OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
}
@@ -354,6 +408,97 @@
setSize (size.x, size.y);
}
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public Point getMinimumSize () {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Point (0, 0);
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ return new Point (rbBand.cxMinChild, rbBand.cyMinChild);
+}
+
+/**
+ * Sets the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (Point size) {
+ checkWidget ();
+ setMinimumSize (size.x, size.y);
+}
+
+/**
+ * Sets the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (int width, int height) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ minimum = true;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
+ rbBand.cxMinChild = width;
+ rbBand.cyMinChild = height;
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+/**
+ * @deprecated use getMinimumSize
+ */
+public int getMinimumWidth () {
+ return getMinimumSize().x;
+}
+
+/**
+ * @deprecated use setMinimumSize
+ */
+public void setMinimumWidth (int width) {
+ checkWidget ();
+ setMinimumSize (width, getMinimumSize().y);
+}
+
boolean getWrap() {
int index = parent.indexOf (this);
int hwnd = parent.handle;
@@ -370,12 +515,40 @@
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_STYLE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
if (wrap) {
- rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS | OS.RBBS_BREAK;
+ rbBand.fStyle |= OS.RBBS_BREAK;
} else {
- rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;
+ rbBand.fStyle &= ~OS.RBBS_BREAK;
}
OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
}
+/**
+ * Removes the listener from the collection of listeners that
+ * will be notified when the control is selected.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ *
+ * @since 2.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index e1561a8..ffb12a7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -1249,8 +1249,6 @@
* @see #destroy
*/
protected void release () {
-
- /* Release shells */
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
@@ -1259,21 +1257,15 @@
}
}
while (readAndDispatch ()) {};
-
- /* Run dispose list */
if (disposeList != null) {
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] != null) disposeList [i].run ();
}
}
disposeList = null;
-
- /* Release synchronizer */
synchronizer.releaseSynchronizer ();
synchronizer = null;
-
releaseDisplay ();
-
super.release ();
}
@@ -1434,6 +1426,24 @@
}
/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.SetCursorPos (point.x, point.y);
+}
+
+/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
* <p>
@@ -1802,9 +1812,20 @@
}
int windowProc (int hwnd, int msg, int wParam, int lParam) {
- if (hwnd == hwndShell && msg == OS.WM_SETTINGCHANGE) updateFont ();
Control control = WidgetTable.get (hwnd);
- if (control != null) return control.windowProc (msg, wParam, lParam);
+ if (control != null) {
+ return control.windowProc (msg, wParam, lParam);
+ }
+ if (hwnd == hwndShell) {
+ switch (msg) {
+ case OS.WM_QUERYENDSESSION:
+ dispose ();
+ break;
+ case OS.WM_SETTINGCHANGE:
+ updateFont ();
+ break;
+ }
+ }
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
index 31ae9ee..062b1b0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
@@ -120,8 +120,15 @@
lpcf.Flags = OS.CF_SCREENFONTS | OS.CF_EFFECTS;
int lpLogFont = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, LOGFONT.sizeof);
if (fontData != null && fontData.data != null) {
+ LOGFONT logFont = fontData.data;
+ int lfHeight = logFont.lfHeight;
+ int hDC = OS.GetDC (0);
+ int pixels = -Compatibility.round (fontData.height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY), 72);
+ OS.ReleaseDC (0, hDC);
+ logFont.lfHeight = pixels;
lpcf.Flags |= OS.CF_INITTOLOGFONTSTRUCT;
- OS.MoveMemory (lpLogFont, fontData.data, LOGFONT.sizeof);
+ OS.MoveMemory (lpLogFont, logFont, LOGFONT.sizeof);
+ logFont.lfHeight = lfHeight;
}
lpcf.lpLogFont = lpLogFont;
fontData = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index 1e9d4bf..649f4ec 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -25,6 +25,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -258,6 +260,28 @@
return GroupProc;
}
+LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
+ LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. In version 6.00 of COMCTL32.DLL,
+ * when WM_PRINTCLIENT is sent from a child BS_GROUP
+ * control to a parent BS_GROUP, the parent BS_GROUP
+ * clears the font from the HDC. Normally, group boxes
+ * in Windows do not have children so this behavior is
+ * undefined. When the parent of a BS_GROUP is not a
+ * BS_GROUP, there is no problem. The fix is to save
+ * and restore the current font.
+ */
+ if (COMCTL32_MAJOR >= 6) {
+ int hFont = OS.GetCurrentObject (wParam, OS.OBJ_FONT);
+ int code = callWindowProc (OS.WM_PRINTCLIENT, wParam, lParam);
+ OS.SelectObject (wParam, hFont);
+ return new LRESULT (code);
+ }
+ return result;
+}
+
LRESULT WM_NCHITTEST (int wParam, int lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
if (result != null) return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 44f0d2f..aaeeb64 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -23,6 +23,10 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of SHADOW_IN and SHADOW_OUT may be specified. Only
+ * one of HORIZONTAL and VERTICAL may be specified. Only one of CENTER,
+ * LEFT and RIGHT may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -492,18 +496,20 @@
* WM_SIZE message.
*/
if (isDisposed ()) return result;
+ if ((style & SWT.SEPARATOR) != 0) {
+ OS.InvalidateRect (handle, null, true);
+ return result;
+ }
/*
* Bug in Windows. For some reason, a label with
* style SS_LEFT, SS_CENTER or SS_RIGHT does not
* redraw the text in the new position when resized.
- * Note that SS_LEFTNOWORDWRAP does no have the problem.
+ * Note that SS_LEFTNOWORDWRAP does not have the problem.
* The fix is to force the redraw.
*/
- if ((style & SWT.SEPARATOR) == 0) {
- if ((style & (SWT.WRAP | SWT.CENTER | SWT.RIGHT)) != 0) {
- OS.InvalidateRect (handle, null, true);
- }
+ if ((style & (SWT.WRAP | SWT.CENTER | SWT.RIGHT)) != 0) {
+ OS.InvalidateRect (handle, null, true);
}
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index da7aa8f..d680541 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -23,6 +23,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
index b301554..501d9c3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -19,6 +19,8 @@
* <dd>Help, Hide, Show </dd>
* </dl>
* <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
index b0485fa..431bd28 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
@@ -20,7 +20,10 @@
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- *<p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -721,17 +724,19 @@
/*
* Bug in WinCE PPC. Tool items on the menubar don't resize
* correctly when the character '&' is used (even when it
- * is a sequence '&&'.
- * The workaround is to remove all '&' in the string.
+ * is a sequence '&&'). The fix is to remove all '&' from
+ * the string.
*/
- int length = string.length();
- char[] text = new char[length];
- string.getChars(0, length, text, 0);
- int i = 0, j = 0;
- for (i = 0; i < length; i++) {
- if (text[i] != '&') text[j++] = text[i];
+ if (string.indexOf ('&') != -1) {
+ int length = string.length ();
+ char[] text = new char [length];
+ string.getChars( 0, length, text, 0);
+ int i = 0, j = 0;
+ for (i=0; i<length; i++) {
+ if (text[i] != '&') text [j++] = text [i];
+ }
+ if (j < i) string = new String (text, 0, j);
}
- if (j < i) string = new String(text, 0, j);
}
}
int hMenu = parent.handle;
@@ -747,9 +752,23 @@
info.fType = widgetStyle ();
info.dwTypeData = pszText;
boolean success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ /*
+ * Bug in Windows 2000. For some reason, when MIIM_TYPE is set
+ * on a menu item that also has MIIM_BITMAP, the MIIM_TYPE clears
+ * the MIIM_BITMAP style. The fix is to reset both MIIM_BITMAP.
+ * Note, this does not happen on Windows 98.
+ */
+ if (!OS.IsWinCE) {
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (4 << 16 | 10)) {
+ if (image != null) {
+ info.fMask = OS.MIIM_BITMAP;
+ info.hbmpItem = OS.HBMMENU_CALLBACK;
+ success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ }
+ }
+ }
if (fixPPCMenuBar) {
Decorations shell = parent.parent;
- /* set text on corresponding tool item */
TBBUTTONINFO info2 = new TBBUTTONINFO ();
info2.cbSize = TBBUTTONINFO.sizeof;
info2.dwMask = OS.TBIF_TEXT;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
index 0ae0aa3..9c04434 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
@@ -23,6 +23,9 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
index 0d77f37..0d9ef5f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -20,6 +20,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
index 6462db9..2d7be10 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -21,6 +21,8 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
@@ -209,7 +211,19 @@
newY = Math.min (Math.max (0, pt.y - startY), clientHeight - height);
}
if (newX == lastX && newY == lastY) return result;
-
+
+ /* Update the pointer position */
+ POINT cursorPt = new POINT ();
+ cursorPt.x = pt.x; cursorPt.y = pt.y;
+ OS.ClientToScreen (parent.handle, cursorPt);
+ if ((style & SWT.VERTICAL) != 0) {
+ cursorPt.y += height / 2;
+ }
+ else {
+ cursorPt.x += width / 2;
+ }
+ OS.SetCursorPos (cursorPt.x, cursorPt.y);
+
/* The event must be sent because doit flag is used */
Event event = new Event ();
event.x = newX; event.y = newY;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
index 2fb6597..4431fdf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
@@ -21,6 +21,9 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * <p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index e052e0c..04d3251 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -63,7 +63,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see Slider
* @see Scrollable
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index b998baa..5c8342d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -83,6 +83,9 @@
* </dl>
* </p>
* <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
@@ -431,6 +434,32 @@
return hCursor;
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void forceActive () {
+ checkWidget ();
+ OS.SetForegroundWindow (handle);
+}
+
public Rectangle getBounds () {
checkWidget ();
if (!OS.IsWinCE) {
@@ -551,15 +580,21 @@
* the display on which it was created (so that all other
* shells on that display, which are not the receiver's
* children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one).
+ * and sets focus to its default button (if it has one)
+ * and asks the window manager to make the shell active.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
+ * @see Control#moveAbove
+ * @see Control#setFocus
* @see Control#setVisible
+ * @see Display#getActiveShell
* @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
public void open () {
checkWidget ();
@@ -663,6 +698,32 @@
return (result > 0) ? LRESULT.ONE : LRESULT.ZERO;
}
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+*/
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
void setActiveControl (Control control) {
if (control != null && control.isDisposed ()) control = null;
if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
@@ -979,11 +1040,12 @@
LRESULT WM_COMMAND (int wParam, int lParam) {
if (OS.IsPPC) {
/*
- * Note in WinCE PPC: close the Shell when the "Done Button" has
- * been pressed.
+ * Note in WinCE PPC: Close the Shell when the "Done Button" has
+ * been pressed. lParam is either 0 (PocketPC 2002) or the handle
+ * to the Shell (PocketPC).
*/
int loWord = wParam & 0xFFFF;
- if (loWord == OS.IDOK) {
+ if (loWord == OS.IDOK && (lParam == 0 || lParam == handle)) {
OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
return LRESULT.ZERO;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
index 9091be2..fe410c4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
@@ -52,7 +52,10 @@
* <dd>Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*
* @see ScrollBar
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index 4097b68..54c6bd2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -679,6 +679,30 @@
return new LRESULT (hittest);
}
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the tab folder window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
LRESULT WM_SIZE (int wParam, int lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
index 79ffad0..4b58eef 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
@@ -214,6 +214,16 @@
int index = parent.indexOf (this);
if (index == -1) return;
super.setImage (image);
+ /*
+ * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
+ * items with an image and a label that includes '&' cause
+ * the tab to draw incorrectly (even when doubled '&&').
+ * The image overlaps the label. The fix is to remove
+ * all '&' characters from the string.
+ */
+ if (COMCTL32_MAJOR >= 6) {
+ if (text.indexOf ('&') != -1) setText (text);
+ }
int hwnd = parent.handle;
TCITEM tcItem = new TCITEM ();
tcItem.mask = OS.TCIF_IMAGE;
@@ -227,6 +237,25 @@
int index = parent.indexOf (this);
if (index == -1) return;
super.setText (string);
+ /*
+ * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
+ * items with an image and a label that includes '&' cause
+ * the tab to draw incorrectly (even when doubled '&&').
+ * The image overlaps the label. The fix is to remove
+ * all '&' characters from the string.
+ */
+ if (COMCTL32_MAJOR >= 6 && image != null) {
+ if (text.indexOf ('&') != -1) {
+ int length = string.length ();
+ char[] text = new char [length];
+ string.getChars ( 0, length, text, 0);
+ int i = 0, j = 0;
+ for (i=0; i<length; i++) {
+ if (text[i] != '&') text [j++] = text [i];
+ }
+ if (j < i) string = new String (text, 0, j);
+ }
+ }
int hwnd = parent.handle;
int hHeap = OS.GetProcessHeap ();
TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 6e07c5e..e164f29 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -29,6 +29,8 @@
* <dd>Selection, DefaultSelection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -1233,9 +1235,20 @@
// }
if (imageList != null) {
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (columnCount == 1 && columns [0] == null) columnCount = 0;
+ int i = 0;
+ while (i < columnCount) {
+ TableColumn column = columns [i];
+ if (column.getImage () != null) break;
+ i++;
+ }
+ if (i == columnCount) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
}
imageList = null;
items = new TableItem [4];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
index 0a2f12a..bf39785 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
@@ -20,6 +20,8 @@
* <dd> Move, Resize, Selection</dd>
* </dl>
* <p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
index 22bcc09..5d56e4c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
@@ -564,12 +564,11 @@
if (image != null && image.isDisposed ()) {
error(SWT.ERROR_INVALID_ARGUMENT);
}
- if (index == 0) {
- setImage (image);
- return;
- }
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return;
+ if (index == 0) {
+ super.setImage (image);
+ }
int hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_IMAGE;
@@ -577,27 +576,14 @@
lvItem.iSubItem = index;
lvItem.iImage = parent.imageIndex (image);
if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ if (index == 0) parent.setScrollWidth ();
parent.setCheckboxImageList (false);
}
}
public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error(SWT.ERROR_INVALID_ARGUMENT);
- }
- int index = parent.indexOf (this);
- if (index == -1) return;
- super.setImage (image);
- int hwnd = parent.handle;
- LVITEM lvItem = new LVITEM ();
- lvItem.mask = OS.LVIF_IMAGE;
- lvItem.iItem = index;
- lvItem.iImage = parent.imageIndex (image);
- if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
- parent.setScrollWidth ();
- parent.setCheckboxImageList (false);
- }
+ checkWidget ();
+ setImage (0, image);
}
/**
@@ -663,12 +649,11 @@
public void setText (int index, String string) {
checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (index == 0) {
- setText (string);
- return;
- }
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return;
+ if (index == 0) {
+ super.setText (string);
+ }
int hwnd = parent.handle;
int hHeap = OS.GetProcessHeap ();
TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
@@ -680,30 +665,15 @@
lvItem.iItem = itemIndex;
lvItem.pszText = pszText;
lvItem.iSubItem = index;
- OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+ if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ if (index == 0) parent.setScrollWidth ();
+ }
OS.HeapFree (hHeap, 0, pszText);
}
public void setText (String string) {
checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int index = parent.indexOf (this);
- if (index == -1) return;
- super.setText (string);
- int hwnd = parent.handle;
- LVITEM lvItem = new LVITEM ();
- lvItem.mask = OS.LVIF_TEXT;
- lvItem.iItem = index;
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- lvItem.pszText = pszText;
- if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
- parent.setScrollWidth ();
- }
- OS.HeapFree (hHeap, 0, pszText);
+ setText (0, string);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index 1208e5f..b29f97f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -21,8 +21,11 @@
* <dt><b>Events:</b></dt>
* <dd>DefaultSelection, Modify, Verify</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class Text extends Scrollable {
int tabs, oldStart, oldEnd;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index ccac02b..5edbb79 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -27,6 +27,8 @@
* <dd>(none)</dd>
* </dl>
* <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
@@ -328,6 +330,11 @@
lastFocusId = -1;
}
+int defaultBackground () {
+ if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_BTNFACE);
+ return super.defaultBackground ();
+}
+
void destroyItem (ToolItem item) {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
@@ -665,18 +672,20 @@
/*
* Feature in Windows. When the toolbar window
* proc processes WM_COMMAND, it forwards this
- * message to the parent. This is done so that
- * children of the toolbar that send WM_COMMAND
- * messages to their parents will notify not only
- * the toolbar but also the parent of the toolbar,
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
* which is typically the application window and
- * the window that is looking for this message.
- * If the toolbar did not do this, applications
- * would have to subclass the toolbar window to
- * see WM_COMMAND messages. Because the toolbar
- * window is subclassed, the WM_COMMAND message
- * is delivered twice. The fix is to avoid
- * calling the toolbar window proc.
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
*/
LRESULT result = super.WM_COMMAND (wParam, lParam);
if (result != null) return result;
@@ -693,22 +702,6 @@
if (index != -1) {
TBBUTTON lpButton = new TBBUTTON ();
int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
- if (code != 0) return LRESULT.ZERO;
- }
- }
- return result;
-}
-
-LRESULT WM_KEYUP (int wParam, int lParam) {
- LRESULT result = super.WM_KEYUP (wParam, lParam);
- if (result != null) return result;
- switch (wParam) {
- case OS.VK_RETURN:
- case OS.VK_SPACE:
- int index = OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
- if (index != -1) {
- TBBUTTON lpButton = new TBBUTTON ();
- int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
if (code != 0) {
items [lpButton.idCommand].click (wParam == OS.VK_RETURN);
return LRESULT.ZERO;
@@ -726,6 +719,30 @@
return super.WM_KILLFOCUS (wParam, lParam);
}
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the toolbar window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
LRESULT WM_SETFOCUS (int wParam, int lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
if (lastFocusId != -1 && handle == OS.GetFocus ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
index 55731a2..781f86c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -14,15 +14,18 @@
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
- * <p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
- * </p>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class ToolItem extends Item {
ToolBar parent;
@@ -455,14 +458,20 @@
void resizeControl () {
if (control != null && !control.isDisposed ()) {
+ /*
+ * Set the size and location of the control
+ * separately to minimize flashing in the
+ * case where the control does not resize
+ * to the size that was requested. This
+ * case can occur when the control is a
+ * combo box.
+ */
Rectangle itemRect = getBounds ();
- control.setBounds (itemRect);
+ control.setSize (itemRect.width, itemRect.height);
Rectangle rect = control.getBounds ();
- if (!rect.equals (itemRect)) {
- rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
- rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
- control.setBounds (rect);
- }
+ rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
+ rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
+ control.setLocation (rect.x, rect.y);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 4cdf88e..f5206a9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -29,6 +29,8 @@
* <dd>Selection, DefaultSelection, Collapse, Expand</dd>
* </dl>
* <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
diff --git a/bundles/org.eclipse.swt/buildnotes_swt.html b/bundles/org.eclipse.swt/buildnotes_swt.html
index b0d0721..da91106 100755
--- a/bundles/org.eclipse.swt/buildnotes_swt.html
+++ b/bundles/org.eclipse.swt/buildnotes_swt.html
@@ -11,7 +11,116 @@
<h1>
Eclipse Platform Build Notes<br>
SWT</h1>
-SWT Build 2.0 032 - Tueday March 28, 2002
+SWT Build 2.0 036 - Tuesday April 23, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4834: DCR - mnemonics do not work on tabbed pages (1GK7O0N)
+<br>7189: Method highlight in border does not match the method
+<br>8253: Right clicking does not bring up context menu
+<br>8306: Inconsistencies in SWT example descriptions
+<br>8538: Mismatch between selected tab and displayed tab
+<br>8544: Some problems with the editor-pane (repaint, focus)
+<br>9360: Text entry in cvs comment dialog can't deal with quick typing
+<br>9794: Linux-GTK KeyEvents bad/different from the other platforms
+<br>12947: Color Preferences in Preferences->Java->Editor
+<br>13826: Performance issue in Table.RemoveAll()
+<br>13922: Eclipse crashes when running LayoutExample
+<br>13999: StyledText - appending single line data doesn't update properly
+<br>14047: StyledText - inefficient redraw during text change with word wrap
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 035 - Thursday April 18, 2002
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+<ul>
+<li>Display.setCursorLocation</li>
+<li>GridLayout(int,boolean)</li>
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4602: GridLayout should have GridLayout(numColumns) constructor (1G9Z73D)
+<br>8549: org.eclipse.core.resources 4 Unhandled exception caught in event loop
+<br>9029: GC.setClipping(Rectangle) should handle null argument on GTK
+<br>10590: GTK Version / Tree View blanks...
+<br>10715: Code Assist dialog hide after press and release CTRL + SPACE
+<br>11182: Property Sheet does not allow editing when there is only one property
+<br>11515: computeTrim and getClientArea are inconsistent in CTabFolder
+<br>11713: Descriptions in preference pages aren't aligned
+<br>11715: Tab doesn't switch fields on gtk
+<br>11835: Strange behaviour of backspace in new Java Class dialog
+<br>11935: Can't Ctrl+Tab out of PDE Editor's dependencies page
+<br>12073: Moving shell above other shells does not work.
+<br>12882: DCR: Set Cursor location programmatically for accessibility
+<br>13194: Usability: editor tabs
+<br>13384: NPE on launching
+<br>13432: OleControlSIte doesn't propagate WM_SETFOCUS message to an ActiveX control
+<br>13639: Controls do not appear in tool items
+<br>13800: Can not get FocusEvent from Combo
+<br>13982: Eclipse won't start on GTK2
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 034 - Tuesday April 9, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6774: WinCE - items regarding Pocket PC (including 2002) integration
+<br>8806: Moving views is difficult
+<br>9245: ToolItems in a ToolBar not displaying images on WinCE
+<br>9616: Resize column leaves some cheese in the table
+<br>10603: Add Breakpoint keeps prompting me
+<br>10937: Converter problem on Solaris
+<br>11520: ShellAdapter.shellDeactivated() never called on Linux-Motif
+<br>11734: Focus not on "Finished" button
+<br>11940: Down arrow does not access drop-down portion of toolbar buttons
+<br>12241: Codeassist disappear after a few seconds
+<br>12573: Table sends selection event twice when in TabFolder
+<br>12787: Changing a menu item's text makes its icon disappear
+<br>12885: Label as a seperator doesn't resize properly
+<br>13006: Alt+1 with blank TabFolder results in NPE
+<br>13014: SetToolTipText called multiple times does not resize.
+<br>13049: CTabFolder focus traversing is busted
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 033 - Tuesday April 2, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+12446: SWT Table Column Image Corruption
+<br>12447: Tree.getSelection() is slow for large trees
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 032 - Thursday March 28, 2002
+
+<h2>
+<a NAME="StyledText Bidi Printing"></a>StyledText Bidi Printing</h2>
+<blockquote>
+<p>Support has been added for printing the contents of a StyledText widget on
+bidirectional language Windows platforms.</p>
+<p> Note however that printing English or local language text does not work properly with some
+printer drivers when using a non-TrueType font. This has been noticed on Windows
+NT systems with the HP Laserjet 4 series printer driver. Please use a TrueType
+font if text is printed garbled .
+<br></p>
+</blockquote>
<h2>
<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>