summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2005-06-08 18:45:47 +0000
committerFelipe Heidrich <fheidric>2005-06-08 18:45:47 +0000
commit88eab8280b310a9da6d10aff37b2d05bdc27fc4f (patch)
treed074f12c3eb8f5dc1c24a7d2065af4f84bf1ab4a
parent90e10f87a7ae7a37da940bfc1c89a9d79a9fc04b (diff)
downloadeclipse.platform.swt-88eab8280b310a9da6d10aff37b2d05bdc27fc4f.tar.gz
eclipse.platform.swt-88eab8280b310a9da6d10aff37b2d05bdc27fc4f.tar.xz
eclipse.platform.swt-88eab8280b310a9da6d10aff37b2d05bdc27fc4f.zip
fixing wrong font in ime when input language changes and styledtext already has focus
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java45
2 files changed, 21 insertions, 31 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index e10134c8f2..e12142a52e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -231,7 +231,10 @@ public void setFont (Font font) {
LRESULT WM_INPUTLANGCHANGE (int wParam, int lParam) {
LRESULT result = super.WM_INPUTLANGCHANGE (wParam, lParam);
- if (caret != null) caret.resizeIME ();
+ if (caret != null && caret.isFocusCaret ()) {
+ caret.setIMEFont ();
+ caret.resizeIME ();
+ }
return result;
}
@@ -249,7 +252,7 @@ LRESULT WM_SETFOCUS (int wParam, int lParam) {
LRESULT WM_SIZE (int wParam, int lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
- if (caret != null) caret.resizeIME ();
+ if (caret != null && caret.isFocusCaret ()) caret.resizeIME ();
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
index b03086e018..ed54480ba8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
@@ -249,7 +249,7 @@ public boolean isVisible () {
void killFocus () {
OS.DestroyCaret ();
- if (font != null) restoreIMEFont ();
+ restoreIMEFont ();
}
void move () {
@@ -312,16 +312,6 @@ void restoreIMEFont () {
oldFont = null;
}
-void saveIMEFont () {
- if (!OS.IsDBLocale) return;
- if (oldFont != null) return;
- int hwnd = parent.handle;
- int hIMC = OS.ImmGetContext (hwnd);
- oldFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA ();
- if (!OS.ImmGetCompositionFont (hIMC, oldFont)) oldFont = null;
- OS.ImmReleaseContext (hwnd, hIMC);
-}
-
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -378,13 +368,7 @@ void setFocus () {
if (image != null) hBitmap = image.handle;
OS.CreateCaret (hwnd, hBitmap, width, height);
move ();
- if (OS.IsDBLocale) {
- int hFont = 0;
- if (font != null) hFont = font.handle;
- if (hFont == 0) hFont = defaultFont ();
- saveIMEFont ();
- setIMEFont (hFont);
- }
+ setIMEFont ();
if (isVisible) OS.ShowCaret (hwnd);
}
@@ -409,13 +393,7 @@ public void setFont (Font font) {
error (SWT.ERROR_INVALID_ARGUMENT);
}
this.font = font;
- if (isVisible && hasFocus ()) {
- int hFont = 0;
- if (font != null) hFont = font.handle;
- if (hFont == 0) hFont = defaultFont ();
- saveIMEFont ();
- setIMEFont (hFont);
- }
+ if (hasFocus ()) setIMEFont ();
}
/**
@@ -442,15 +420,24 @@ public void setImage (Image image) {
if (isVisible && hasFocus ()) resize ();
}
-void setIMEFont (int hFont) {
+void setIMEFont () {
if (!OS.IsDBLocale) return;
+ int hFont = 0;
+ if (font != null) hFont = font.handle;
+ if (hFont == 0) hFont = defaultFont ();
+ int hwnd = parent.handle;
+ int hIMC = OS.ImmGetContext (hwnd);
+ /* Save the current IME font */
+ if (oldFont == null) {
+ oldFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA ();
+ if (!OS.ImmGetCompositionFont (hIMC, oldFont)) oldFont = null;
+ }
+ /* Set new IME font */
LOGFONT logFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA ();
if (OS.GetObject (hFont, LOGFONT.sizeof, logFont) != 0) {
- int hwnd = parent.handle;
- int hIMC = OS.ImmGetContext (hwnd);
OS.ImmSetCompositionFont (hIMC, logFont);
- OS.ImmReleaseContext (hwnd, hIMC);
}
+ OS.ImmReleaseContext (hwnd, hIMC);
}
/**