aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/PlatWin.cxx27
-rw-r--r--win32/ScintillaWin.cxx48
2 files changed, 23 insertions, 52 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index de124ea10..bfedaaa2a 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -264,6 +264,10 @@ int Surface::LogPixelsY() {
return ::GetDeviceCaps(hdc, LOGPIXELSY);
}
+int Surface::DeviceHeightFont(int points) {
+ return ::MulDiv(points, LogPixelsY(), 72);
+}
+
void Surface::MoveTo(int x_, int y_) {
::MoveToEx(hdc, x_, y_, 0);
}
@@ -360,18 +364,10 @@ int Surface::WidthText(Font &font_, const char *s, int len) {
SetFont(font_);
SIZE sz={0,0};
if (unicodeMode) {
- int fit = 0;
wchar_t tbuf[MAX_US_LEN];
int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));
tbuf[tlen] = L'\0';
- fit = tlen;
- //::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz);
- if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, NULL, &sz)) {
- DWORD dw = GetLastError();
- Platform::DebugPrintf("Error for 1 GTEEPW %d\n", dw);
- } else {
- //Platform::DebugPrintf("OK 1 GTEEPW %d\n", len);
- }
+ ::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz);
} else {
::GetTextExtentPoint32(hdc, s, len, &sz);
}
@@ -388,13 +384,16 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)
tbuf[tlen] = L'\0';
int poses[MAX_US_LEN];
fit = tlen;
- SetLastError(0);
if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz)) {
- DWORD dw = GetLastError();
- Platform::DebugPrintf("Error for GTEEPW %d\n", dw);
- } else {
- //Platform::DebugPrintf("OK GTEEPW %d\n", len);
+ // Likely to have failed because on Windows 9x where function not available
+ // So measure the character widths by measuring each initial substring
+ // Turns a linear operation into a qudratic but seems fast enough on test files
+ for (int widthSS=0; widthSS < tlen; widthSS++) {
+ ::GetTextExtentPoint32W(hdc, tbuf, widthSS+1, &sz);
+ poses[widthSS] = sz.cx;
+ }
}
+ // Map the widths given for UCS-2 characters back onto the UTF-8 input string
int ui=0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
int i=0;
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 114f7aa41..2663dff2e 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -410,36 +410,9 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
} else
return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
- case WM_CHAR: {
- char utfval[4]="\0\0\0";
- if (IsUnicodeMode()) {
- if ((wParam > 0xff) || (!iscntrl(wParam))) {
- int inputCodePage = InputCodePage();
- char ansiChars[3];
- ansiChars[0] = static_cast<char>(wParam);
- ansiChars[1] = '\0';
- ansiChars[2] = '\0';
- wchar_t wcs[2];
- //int nRet =
- ::MultiByteToWideChar(inputCodePage, 0, ansiChars, 1, wcs, 1);
- wchar_t uchar = wcs[0];
- unsigned int len = UTF8Length(&uchar, 1);
- UTF8FromUCS2(&uchar, 1, utfval, len);
- utfval[len] = '\0';
- AddCharUTF(utfval,len);
- /*
- wchar_t uchar = wParam;
- unsigned int len = UTF8Length(&uchar, 1);
- UTF8FromUCS2(&uchar, 1, utfval, len);
- utfval[len] = '\0';
- AddCharUTF(utfval,len);
- */
- }
- } else {
- if (!iscntrl(wParam&0xff)) {
- AddChar(static_cast<char>(wParam&0xff));
- }
- }
+ case WM_CHAR:
+ if (!iscntrl(wParam&0xff)) {
+ AddChar(static_cast<char>(wParam&0xff));
}
return 1;
@@ -500,11 +473,11 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
break;
case WM_IME_STARTCOMPOSITION: // dbcs
- //ImeStartComposition();
+ ImeStartComposition();
return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
case WM_IME_ENDCOMPOSITION: // dbcs
- //ImeEndComposition();
+ ImeEndComposition();
return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
case WM_IME_COMPOSITION:
@@ -519,15 +492,13 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (inputCodePage) {
char utfval[4]="\0\0\0";
char ansiChars[3];
- ansiChars[0] = static_cast<char>(wParam & 0xff);
- ansiChars[1] = static_cast<char>(wParam >> 8);
+ ansiChars[0] = HIBYTE(wParam);
+ ansiChars[1] = LOBYTE(wParam);
ansiChars[2] = '\0';
wchar_t wcs[2];
nRet = ::MultiByteToWideChar(inputCodePage, 0, ansiChars, 2, wcs, 1);
- wchar_t uchar = wcs[0];
- uchar = wParam;
- unsigned int len = UTF8Length(&uchar, 1);
- UTF8FromUCS2(&uchar, 1, utfval, len);
+ unsigned int len = UTF8Length(wcs, 1);
+ UTF8FromUCS2(wcs, 1, utfval, len);
utfval[len] = '\0';
AddCharUTF(utfval,len);
}
@@ -1081,6 +1052,7 @@ void ScintillaWin::ImeStartComposition() {
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
sizeZoomed = 2;
Surface surface;
+ surface.Init();
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
// The negative is to allow for leading
lf.lfHeight = -(abs(deviceHeight));