Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2001-07-10 10:22:59 -0400
committerVeronika Irvine2001-07-10 10:22:59 -0400
commita5fcaa898f4dc7b4148bea78875c0c028df99eb5 (patch)
tree0a1f693db9ed2ac346933ddb0c98a114a2373ddf
parent3e29ca9f36f2c360a276b69923ef7a27c89138dd (diff)
downloadeclipse.platform.swt-a5fcaa898f4dc7b4148bea78875c0c028df99eb5.tar.gz
eclipse.platform.swt-a5fcaa898f4dc7b4148bea78875c0c028df99eb5.tar.xz
eclipse.platform.swt-a5fcaa898f4dc7b4148bea78875c0c028df99eb5.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java113
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java83
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java18
19 files changed, 268 insertions, 155 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
index 78f73d66a2..94478c0783 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
@@ -271,4 +271,4 @@ public void setWarnings (boolean warnings) {
checkDevice ();
}
-}
+}
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 be8a0d3aeb..9dcdca3730 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
@@ -632,64 +632,55 @@ static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int sr
/* Scale alpha data */
if (alpha.src_alpha_map_map != 0) {
-// int[] palette = new int[256];
-// for (int i = 0; i < palette.length; i++) {
-// palette[i] = i;
-// }
-// int palettePtr = OS.malloc(palette.length * 4);
-// OS.memmove(palettePtr, palette, palette.length * 4);
-// /*
-// * Feature on Photon - It is only possible to draw on images of
-// * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
-// */
-// int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
-// if (alphaImage == 0) {
-// Image.destroyImage(memImage);
-// SWT.error(SWT.ERROR_NO_HANDLES);
-// }
-// mc = OS.PmMemCreateMC(alphaImage, scale, trans);
-// if (mc == 0) {
-// Image.destroyImage(alphaImage);
-// Image.destroyImage(memImage);
-// SWT.error(SWT.ERROR_NO_HANDLES);
-// }
-// OS.PmMemStart(mc);
-// OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);
-// OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);
-// OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
-// OS.PmMemFlush(mc, alphaImage);
-// OS.PmMemStop(mc);
-// OS.PmMemReleaseMC(mc);
-// OS.free(palettePtr);
-//
-// /* Transfer the image to the scaled image alpha data*/
-// PhImage_t phAlphaImage = new PhImage_t();
-// OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
-// alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
-// alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
-// alpha.src_alpha_map_map = phAlphaImage.image;
-//
-// /* Release the temporary image but not the image data */
-// phAlphaImage.image = 0;
-// phAlphaImage.bpl = 0;
-// phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
-// OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
-// OS.PhReleaseImage(alphaImage);
-// OS.free(alphaImage);
-
- // The code above can not be used because it generates an image with
- // scanline padding. It seems that Photon does not accept
- // padding in src_alpha_map, even though there is a field to specify
- // the number of bytes per line - src_alpha_map_map_bpl.
- byte[] srcAlphaData = new byte[alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h];
- OS.memmove(srcAlphaData, alpha.src_alpha_map_map, srcAlphaData.length);
- byte[] destAlphaData = new byte[destWidth * destHeight];
- ImageData.stretch8(srcAlphaData, alpha.src_alpha_map_dim_w, 0, 0, srcWidth, srcHeight, destAlphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);
- int ptr = OS.malloc(destAlphaData.length);
- OS.memmove(ptr, destAlphaData, destAlphaData.length);
- alpha.src_alpha_map_dim_w = (short)destWidth;
- alpha.src_alpha_map_dim_h = (short)destHeight;
- alpha.src_alpha_map_map = ptr;
+ int[] palette = new int[256];
+ for (int i = 0; i < palette.length; i++) {
+ palette[i] = i;
+ }
+ int palettePtr = OS.malloc(palette.length * 4);
+ OS.memmove(palettePtr, palette, palette.length * 4);
+ /*
+ * Feature on Photon - It is only possible to draw on images of
+ * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
+ if (alphaImage == 0) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ mc = OS.PmMemCreateMC(alphaImage, scale, trans);
+ if (mc == 0) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(alphaImage);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.PmMemStart(mc);
+ OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);
+ OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, alphaImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.free(palettePtr);
+
+ /* Transfer the image to the scaled image alpha data*/
+ PhImage_t phAlphaImage = new PhImage_t();
+ OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
+ alpha.src_alpha_map_bpl = (short)phAlphaImage.bpl;
+ alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
+ alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
+ alpha.src_alpha_map_map = phAlphaImage.image;
+
+ /* Release the temporary image but not the image data */
+ phAlphaImage.image = 0;
+ phAlphaImage.bpl = 0;
+ phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(alphaImage);
+ OS.free(alphaImage);
}
OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
@@ -933,9 +924,7 @@ public void fillOval (int x, int y, int width, int height) {
center.x = (short)x; center.y = (short)y;
PhPoint_t radii = new PhPoint_t();
radii.x = (short)(x + width);
- if (width != 2) radii.x--;
radii.y = (short)(y + height);
- if (height != 2) radii.y--;
int flags = OS.PtEnter(0);
try {
@@ -1401,7 +1390,7 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
/* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings) {
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
int temp_widget = topWidget;
while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
if (OS.PtWidgetIsRealized(temp_widget)) {
@@ -1548,4 +1537,4 @@ public static GC photon_new(Drawable drawable, GCData data) {
return gc;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
index 2dc3f904a3..cbd93c70f8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -531,6 +531,7 @@ void init(Device device, ImageData i) {
SWT.error(SWT.ERROR_NO_HANDLES);
}
OS.memmove(ptr, i.alphaData, i.alphaData.length);
+ alpha.src_alpha_map_bpl = (short)i.width;
alpha.src_alpha_map_dim_w = (short)i.width;
alpha.src_alpha_map_dim_h = (short)i.height;
alpha.src_alpha_map_map = ptr;
@@ -620,4 +621,4 @@ public String toString () {
return "Image {" + handle + "}";
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
index 1d03cac58f..595cf5e094 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
@@ -176,6 +176,9 @@ public class OS {
public static final int Pt_ARG_MODIFIER_KEYS = ( 7 * 1000 + 4 );
public static final byte [] Pg_PAT_HALF = {(byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55};
+
+ public static final int Pt_ARG_BEVEL_CONTRAST = ( 2 * 1000 + 20 );
+
/*** END MANUALLY ADDED/FIXED ***/
//public static final int Aw_ARG_ONOFF_STATE = ( 5 * 1000 + 1 );
@@ -2806,6 +2809,7 @@ public static final native void PtWindowToFront (int widget);
public static final native int PtFindDisjoint (int widget);
public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);
+public static final native int PtBlockWindow(int window, short cursor, int cursor_color);
public static final native void PtUnblockWindows(int bl);
public static final native int PtNextTopLevelWidget(int widget);
public static final native int PtWindowGetState(int widget);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
index 89c384775e..2def30344a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
@@ -13,4 +13,4 @@ public class PgDisplaySettings_t {
public int flags;
public int [] reserved = new int [22];
public static final int sizeof = 108;
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
index 61494500ac..2f0760c857 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
@@ -19,4 +19,4 @@ public class PgVideoModeInfo_t {
public int mode_capabilities6;
public byte [] refresh_rates = new byte [20];
public static final int sizeof = 56;
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
index 1f0d2211b7..9aee15ac9a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
@@ -10,12 +10,11 @@ public class PhKeyEvent_t {
public int key_flags;
public int key_cap;
public int key_sym;
- public byte key_scan;
- public byte key_zero1;
- public short key_zero2;
+ public short key_scan;
+ public short key_zero;
// PhPoint_t pos;
public short pos_x;
public short pos_y;
public short button_state;
public static final int sizeof = 26;
-}
+}
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 174460a8d0..65b0bb8122 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
@@ -174,6 +174,13 @@ public int getAlignment () {
return SWT.LEFT;
}
+boolean getDefault () {
+ if ((style & SWT.PUSH) == 0) return false;
+ int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] == 100;
+}
+
public Image getImage () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -248,6 +255,26 @@ int processActivate (int info) {
return OS.Pt_CONTINUE;
}
+int processFocusIn (int info) {
+ int result = super.processFocusIn (info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ getShell ().setDefaultButton (this, false);
+ return result;
+}
+
+int processFocusOut (int info) {
+ int result = super.processFocusOut (info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ if (getDefault ()) {
+ getShell ().setDefaultButton (null, false);
+ }
+ return result;
+}
+
int processPaint (int damage) {
if ((style & SWT.ARROW) != 0) {
OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
@@ -325,6 +352,13 @@ public void setAlignment (int alignment) {
OS.PtSetResources (handle, args.length / 3, args);
}
+void setDefault (boolean value) {
+ if ((style & SWT.PUSH) == 0) return;
+ if (getShell ().parent == null) return;
+ int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
public void setSelection (boolean selected) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -375,7 +409,7 @@ public void setText (String string) {
ptr2 = OS.malloc (buffer2.length);
OS.memmove (ptr2, buffer2, buffer2.length);
}
- replaceMnemonic (mnemonic, 0);
+ replaceMnemonic (mnemonic, true, true);
int [] args = {
OS.Pt_ARG_TEXT_STRING, ptr, 0,
OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
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 7fe9e578b3..526c789728 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
@@ -257,7 +257,10 @@ public String [] getItems () {
result [i] = new String (unicode);
}
return result;
+}
+String getNameText () {
+ return getText ();
}
public Point getSelection () {
@@ -535,4 +538,13 @@ int traversalCode (int key_sym, PhKeyEvent_t ke) {
return code;
}
-}
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if (!translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return true;
+ }
+ return translated;
+}
+
+}
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 e5908ee800..d4a86dc27d 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
@@ -87,6 +87,21 @@ void createScrollBars () {
}
}
+public boolean forceFocus () {
+ /*
+ * Bug in Photon. PtContainerGiveFocus() is supposed to give
+ * focus to the widget even if the widget's Pt_GET_FOCUS flag
+ * is not set. This does not happen when the widget is a
+ * PtContainer. The fix is to set the flag before calling it.
+ */
+ int [] args = {OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS};
+ OS.PtSetResources (handle, args.length / 3, args);
+ boolean result = super.forceFocus ();
+ args [1] = 0;
+ OS.PtSetResources (handle, args.length / 3, args);
+ return result;
+}
+
void createScrolledHandle (int parentHandle) {
int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
int [] args = new int [] {
@@ -135,7 +150,7 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
/* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings) {
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
int temp_widget = topWidget;
while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
if (OS.PtWidgetIsRealized(temp_widget)) {
@@ -450,4 +465,4 @@ int traversalCode (int key_sym, PhKeyEvent_t ke) {
return super.traversalCode (key_sym, ke);
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
index 014dca0453..ef603855d9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -14,6 +14,7 @@ public class Decorations extends Canvas {
Menu [] menus;
String text = "";
Image image;
+ Button defaultButton, saveDefault;
Decorations () {
/* Do nothing */
@@ -54,7 +55,7 @@ protected void checkSubclass () {
public Button getDefaultButton () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return null;
+ return defaultButton;
}
public Image getImage () {
@@ -112,8 +113,9 @@ void releaseWidget () {
menuBar = null;
menus = null;
image = null;
- text = null;
super.releaseWidget ();
+ defaultButton = saveDefault = null;
+ text = null;
}
void remove (Menu menu) {
@@ -155,7 +157,24 @@ void resizeBounds (int width, int height) {
public void setDefaultButton (Button button) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE
+ setDefaultButton (button, true);
+}
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) return;
+ } else {
+ if ((button.style & SWT.PUSH) == 0) return;
+ if (button == defaultButton) return;
+ }
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
+ }
+ if ((defaultButton = button) == null) defaultButton = saveDefault;
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
+ }
+ if (save || saveDefault == null) saveDefault = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
}
public void setImage (Image image) {
@@ -187,4 +206,4 @@ public void setText (String string) {
text = string;
}
-}
+}
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 48390bb046..35387ac1d6 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
@@ -175,13 +175,21 @@ public /*final*/ class Display extends Device {
static {
DeviceFinder = new Runnable () {
public void run () {
- CurrentDevice = getCurrent ();
- if (CurrentDevice == null) {
- CurrentDevice = getDefault ();
+ Device device = getCurrent ();
+ if (device == null) {
+ device = getDefault ();
}
+ setDevice (device);
}
};
}
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+ CurrentDevice = device;
+}
public Display () {
this (null);
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 b97c3fc575..c698ac276c 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
@@ -298,7 +298,7 @@ public void setText (String string) {
ptr2 = OS.malloc (buffer2.length);
OS.memmove (ptr2, buffer2, buffer2.length);
}
- replaceMnemonic (mnemonic, 0);
+ replaceMnemonic (mnemonic, true, true);
int [] args = {
OS.Pt_ARG_TEXT_STRING, ptr, 0,
OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
@@ -309,4 +309,4 @@ public void setText (String string) {
OS.free (ptr2);
}
-}
+}
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 535e47327f..46f59ea99a 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
@@ -324,6 +324,7 @@ public void setVisible (boolean visible) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.POP_UP) == 0) return;
+ if (visible == OS.PtWidgetIsRealized (handle)) return;
if (visible) {
PhPoint_t pt = new PhPoint_t ();
pt.x = (short) x;
@@ -347,4 +348,4 @@ public void setVisible (boolean visible) {
}
}
-}
+}
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 69268fe0a7..ee8dfbd5d0 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
@@ -165,7 +165,8 @@ public boolean isEnabled () {
}
int processActivate (int info) {
- return processArm (info);
+ showMenu ();
+ return OS.Pt_CONTINUE;
}
int processSelection (int info) {
@@ -196,42 +197,8 @@ int processShow (int info) {
}
int processArm(int info) {
- if (menu != null) {
- int menuHandle = menu.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- if ((parent.style & SWT.BAR) == 0) {
- int [] args = {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};
- OS.PtSetResources (menuHandle, args.length / 3, args);
- }
- OS.PtReParentWidget (menuHandle, handle);
-
- /*
- * Bug in Photon. PtPositionMenu does not position the menu
- * properly when the menu is a direct child a menu bar item.
- * The fix is to position the menu ourselfs.
- */
- if ((parent.style & SWT.BAR) != 0) {
- PhPoint_t pt = new PhPoint_t ();
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (handle, x, y);
- pt.x = x [0];
- pt.y = y [0];
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- pt.y += args [1];
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- args = new int [] {OS.Pt_ARG_POS, ptr, 0};
- OS.PtSetResources (menuHandle, args.length / 3, args);
- OS.free (ptr);
- } else {
- OS.PtPositionMenu (menuHandle, null);
- }
-
- menu.sendEvent (SWT.Show);
- OS.PtRealizeWidget (menuHandle);
- }
- }
+ postEvent (SWT.Arm);
+ showMenu ();
return OS.Pt_CONTINUE;
}
@@ -429,7 +396,7 @@ public void setText (String string) {
OS.memmove (ptr3, buffer3, buffer3.length);
}
if ((parent.style & SWT.BAR) != 0) {
- replaceMnemonic (mnemonic, OS.Pk_KM_Alt);
+ replaceMnemonic (mnemonic, false, true);
}
int [] args = {
OS.Pt_ARG_TEXT_STRING, ptr1, 0,
@@ -450,4 +417,42 @@ public void setText (String string) {
if (OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
}
-}
+void showMenu() {
+ if (menu == null) return;
+ int menuHandle = menu.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ if ((parent.style & SWT.BAR) == 0) {
+ int [] args = {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ }
+ OS.PtReParentWidget (menuHandle, handle);
+
+ /*
+ * Bug in Photon. PtPositionMenu does not position the menu
+ * properly when the menu is a direct child a menu bar item.
+ * The fix is to position the menu ourselfs.
+ */
+ if ((parent.style & SWT.BAR) != 0) {
+ PhPoint_t pt = new PhPoint_t ();
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (handle, x, y);
+ pt.x = x [0];
+ pt.y = y [0];
+ int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ pt.y += args [1];
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ args = new int [] {OS.Pt_ARG_POS, ptr, 0};
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ OS.free (ptr);
+ } else {
+ OS.PtPositionMenu (menuHandle, null);
+ }
+
+ menu.sendEvent (SWT.Show);
+ OS.PtRealizeWidget (menuHandle);
+ }
+}
+
+}
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 631c0d5785..af811f0ae4 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
@@ -14,7 +14,7 @@ import org.eclipse.swt.events.*;
public class Shell extends Decorations {
int shellHandle;
Display display;
- int modal, blockedList;
+ int blockedList;
Control lastFocus;
public Shell () {
@@ -75,6 +75,16 @@ void bringToTop () {
OS.PtWidgetToFront (shellHandle);
}
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
+ int bits = style & ~mask;
+ if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
+ if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
+ return bits;
+}
+
void closeWidget () {
Event event = new Event ();
event.time = (int) System.currentTimeMillis ();
@@ -173,7 +183,7 @@ void createHandle (int index) {
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
int [] args = {
OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, OS.Pt_ALL_OUTLINES,
+ OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,
};
OS.PtSetResources (scrolledHandle, args.length / 3, args);
}
@@ -539,19 +549,6 @@ public void setMinimized (boolean minimized) {
}
}
-public void setModal (int modal) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- switch (modal) {
- case SWT.MODELESS:
- case SWT.PRIMARY_MODAL:
- case SWT.APPLICATION_MODAL:
- case SWT.SYSTEM_MODAL:
- this.modal = modal;
- break;
- }
-}
-
public void setText (String string) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -569,6 +566,7 @@ public void setVisible (boolean visible) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
+
/*
* Feature in Photon. It is not possible to show a PtWindow
* whose parent is not realized. The fix is to temporarily
@@ -582,19 +580,27 @@ public void setVisible (boolean visible) {
OS.PtReParentWidget (shellHandle, visible ? 0 : parentHandle);
}
}
- switch (modal) {
- case SWT.PRIMARY_MODAL:
- //NOT DONE: should not disable all windows
- case SWT.APPLICATION_MODAL:
- case SWT.SYSTEM_MODAL:
- if (visible) {
+
+ if (visible) {
+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ switch (style & mask) {
+ case SWT.PRIMARY_MODAL:
+ if (parent != null) {
+ int parentHandle = parent.getShell ().shellHandle;
+ blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);
+ }
+ break;
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
- } else {
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- }
+ break;
+ }
+ } else {
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
}
super.setVisible (visible);
+
/*
* Feature in Photon. When a shell is shown, it may have child
* shells that have been temporarily reparented to NULL because
@@ -610,6 +616,7 @@ public void setVisible (boolean visible) {
}
}
}
+
OS.PtSyncWidget (shellHandle);
OS.PtFlush ();
}
@@ -618,4 +625,4 @@ int topHandle () {
return shellHandle;
}
-}
+}
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 d14ced445a..b088c05343 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
@@ -712,4 +712,13 @@ int traversalCode (int key_sym, PhKeyEvent_t ke) {
return SWT.TRAVERSE_ESCAPE;
}
-}
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if (!translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return true;
+ }
+ return translated;
+}
+
+}
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 fba9ac682a..5235cc36f8 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
@@ -468,4 +468,4 @@ public void setWidth (int width) {
control.setBounds (getBounds ());
}
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
index 1ca65f7b66..66b9eb5840 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -424,7 +424,7 @@ public void removeDisposeListener (DisposeListener listener) {
eventTable.unhook (SWT.Dispose, listener);
}
-void replaceMnemonic (int mnemonic, int mods) {
+void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {
Display display = getDisplay ();
int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -436,13 +436,23 @@ void replaceMnemonic (int mnemonic, int mods) {
char [] accelText = Converter.mbcsToWcs (null, buffer);
if (accelText.length > 0) {
char key = Character.toLowerCase (accelText [0]);
- OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ if (normal) {
+ OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, SWT.Activate, display.windowProc);
+ }
}
}
}
if (mnemonic == 0) return;
char key = Character.toLowerCase ((char)mnemonic);
- OS.PtAddHotkeyHandler (handle, key, mods, (short)0, SWT.Activate, display.windowProc);
+ if (normal) {
+ OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, SWT.Activate, display.windowProc);
+ }
}
void sendEvent (int eventType) {
@@ -528,4 +538,4 @@ int topHandle () {
return handle;
}
-}
+}

Back to the top