Changeset 21303 for trunk/src/user32/edit.c
- Timestamp:
- Jun 18, 2009, 12:04:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/edit.c
r10607 r21303 31 31 #include "ctrlconf.h" 32 32 #include <heapstring.h> 33 #include <imm.h>34 33 #endif 35 34 … … 129 128 HLOCAL hloc32A; /* alias for ANSI control receiving EM_GETHANDLE 130 129 or EM_SETHANDLE */ 131 #ifdef __WIN32OS2__132 LPWSTR compStr;133 INT compStrLen;134 BOOL moveCaret;135 DWORD sentenceMode;136 #endif137 130 } EDITSTATE; 138 131 … … 1118 1111 else 1119 1112 { 1113 // always DBCS char 1120 1114 CHAR charA[ 2 ]; 1121 INT lenA = 1; 1122 1123 if( IsDBCSLeadByte(( CHAR )( wParam >> 8 ))) 1124 { 1115 1125 1116 charA[ 0 ] = ( CHAR )( wParam >> 8 ); 1126 1117 charA[ 1 ] = ( CHAR )wParam; 1127 lenA = 2; 1128 } 1129 else 1130 charA[ 0 ] = ( CHAR )wParam; 1131 1132 MultiByteToWideChar( CP_ACP, 0, ( LPSTR )charA, lenA, ( LPWSTR )&charW, 1); 1118 1119 MultiByteToWideChar( CP_ACP, 0, ( LPSTR )charA, 2, ( LPWSTR )&charW, 1); 1133 1120 } 1134 1121 … … 1136 1123 break; 1137 1124 } 1138 1139 case WM_IME_COMPOSITION:1140 {1141 HIMC himc;1142 LONG bufSize;1143 INT i;1144 BOOL passToDefWnd = FALSE;1145 #ifdef DEBUG1146 LPSTR strA;1147 INT lenA;1148 #endif1149 1150 DPRINTF_EDIT_MSG32("WM_IME_COMPOSITION");1151 1152 himc = ImmGetContext( hwnd );1153 1154 if( es->sentenceMode )1155 passToDefWnd = TRUE;1156 else if( lParam & GCS_RESULTSTR )1157 {1158 LPWSTR resultStr = NULL;1159 INT resultStrLen = 0;1160 1161 dprintf(("WM_IME_COMPOSITION : GCS_RESULTSTR"));1162 1163 bufSize = ImmGetCompositionStringW( himc, GCS_RESULTSTR, NULL, 0 );1164 if( bufSize > 0 )1165 {1166 INT i;1167 1168 resultStrLen = bufSize / sizeof( WCHAR );1169 resultStr = malloc( bufSize + sizeof( WCHAR ));1170 resultStr[ resultStrLen ] = 0;1171 1172 ImmGetCompositionStringW( himc, GCS_RESULTSTR, resultStr, bufSize );1173 1174 #ifdef DEBUG1175 lenA = WideCharToMultiByte( CP_ACP, 0, resultStr, resultStrLen, 0, 0, 0, 0 );1176 strA = malloc( lenA + 1 );1177 WideCharToMultiByte( CP_ACP, 0, resultStr, resultStrLen, strA, lenA, 0, 0 );1178 strA[ lenA ] = 0;1179 dprintf(("Result String : '%s'", strA ));1180 free( strA );1181 dprintf(("Composition Len %d", es->compStrLen ));1182 #endif1183 DestroyCaret();1184 if( es->compStrLen > 0 )1185 {1186 EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE);1187 for( i = 0; i < es->compStrLen; i++ )1188 EDIT_MoveForward(hwnd, es, TRUE);1189 EDIT_WM_Clear(hwnd, es);1190 }1191 1192 EDIT_EM_ReplaceSel(hwnd, es, TRUE, resultStr, TRUE);1193 1194 CreateCaret(hwnd, 0, 2, es->line_height);1195 EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);1196 ShowCaret(hwnd);1197 1198 free( resultStr );1199 1200 }1201 1202 if( es->compStr )1203 free( es->compStr );1204 1205 es->compStr = NULL;1206 es->compStrLen = 0;1207 }1208 else if( lParam & GCS_COMPSTR )1209 {1210 INT prevLen = es->compStrLen;1211 1212 dprintf(("WM_IME_COMPOSITION : GCS_COMPSTR"));1213 1214 if( es->compStr )1215 free( es->compStr );1216 1217 es->compStr = NULL;1218 es->compStrLen = 0;1219 1220 bufSize = ImmGetCompositionStringW( himc, GCS_COMPSTR, NULL, 0 );1221 if( bufSize > 0 )1222 {1223 HDC hdc;1224 SIZE size;1225 BOOL oldMoveCaret;1226 1227 es->compStrLen = bufSize / sizeof( WCHAR );1228 es->compStr = malloc( bufSize + sizeof( WCHAR ));1229 es->compStr[ es->compStrLen ] = 0;1230 1231 ImmGetCompositionStringW( himc, GCS_COMPSTR, es->compStr, bufSize );1232 1233 #ifdef DEBUG1234 lenA = WideCharToMultiByte( CP_ACP, 0, es->compStr, es->compStrLen, 0, 0, 0, 0 );1235 strA = malloc( lenA + 1 );1236 WideCharToMultiByte( CP_ACP, 0, es->compStr, es->compStrLen, strA, lenA, 0, 0 );1237 strA[ lenA ] = 0;1238 dprintf(("Composition String : '%s'", strA ));1239 free( strA );1240 #endif1241 hdc = GetDC( hwnd );1242 GetTextExtentPoint32W( hdc, es->compStr, es->compStrLen, &size);1243 ReleaseDC( hwnd, hdc );1244 1245 oldMoveCaret = es->moveCaret;1246 1247 es->moveCaret = FALSE; // to prevent cursor from flashing too many1248 1249 if( prevLen > 0 )1250 {1251 EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE);1252 for( i = 0; i < prevLen; i++ )1253 EDIT_MoveForward(hwnd, es, TRUE);1254 EDIT_WM_Clear(hwnd, es);1255 }1256 1257 EDIT_EM_ReplaceSel(hwnd, es, TRUE, es->compStr, TRUE);1258 1259 for( i = 0; i < es->compStrLen; i++ )1260 EDIT_MoveBackward(hwnd, es, FALSE);1261 1262 es->moveCaret = oldMoveCaret;1263 1264 CreateCaret(hwnd, 0, size.cx, es->line_height);1265 EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);1266 ShowCaret(hwnd);1267 }1268 }1269 else1270 passToDefWnd = TRUE;1271 1272 ImmReleaseContext( hwnd, himc );1273 1274 if( passToDefWnd )1275 {1276 if( unicode )1277 result = DefWindowProcW( hwnd, msg, wParam, lParam );1278 else1279 result = DefWindowProcA( hwnd, msg, wParam, lParam );1280 }1281 break;1282 }1283 1284 case WM_IME_COMPOSITIONFULL:1285 DPRINTF_EDIT_MSG32("WM_IME_COMPOSITIONFULL");1286 if( unicode )1287 result = DefWindowProcW( hwnd, msg, wParam, lParam );1288 else1289 result = DefWindowProcA( hwnd, msg, wParam, lParam );1290 break;1291 1292 case WM_IME_CONTROL:1293 DPRINTF_EDIT_MSG32("WM_IME_CONTROL");1294 if( unicode )1295 result = DefWindowProcW( hwnd, msg, wParam, lParam );1296 else1297 result = DefWindowProcA( hwnd, msg, wParam, lParam );1298 break;1299 1300 case WM_IME_ENDCOMPOSITION:1301 DPRINTF_EDIT_MSG32("WM_IME_ENDCOMPOSITION");1302 1303 if( es->compStr )1304 {1305 INT i;1306 1307 DestroyCaret();1308 1309 EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE);1310 for( i = 0; i < es->compStrLen; i++ )1311 EDIT_MoveForward(hwnd, es, TRUE);1312 EDIT_WM_Clear(hwnd, es);1313 1314 CreateCaret(hwnd, 0, 2, es->line_height);1315 EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);1316 ShowCaret(hwnd);1317 1318 free( es->compStr );1319 }1320 1321 es->compStr = NULL;1322 es->compStrLen = 0;1323 1324 if( unicode )1325 result = DefWindowProcW( hwnd, msg, wParam, lParam );1326 else1327 result = DefWindowProcA( hwnd, msg, wParam, lParam );1328 break;1329 1330 case WM_IME_NOTIFY:1331 DPRINTF_EDIT_MSG32("WM_IME_NOTIFY");1332 1333 if( wParam == IMN_SETSENTENCEMODE )1334 {1335 HIMC himc;1336 DWORD conversionMode;1337 1338 himc = ImmGetContext( hwnd );1339 1340 ImmGetConversionStatus( himc, &conversionMode, &es->sentenceMode );1341 1342 ImmReleaseContext( hwnd, himc );1343 }1344 1345 if( unicode )1346 result = DefWindowProcW( hwnd, msg, wParam, lParam );1347 else1348 result = DefWindowProcA( hwnd, msg, wParam, lParam );1349 break;1350 1351 case WM_IME_REQUEST:1352 DPRINTF_EDIT_MSG32("WM_IME_REQUEST");1353 if( unicode )1354 result = DefWindowProcW( hwnd, msg, wParam, lParam );1355 else1356 result = DefWindowProcA( hwnd, msg, wParam, lParam );1357 break;1358 1359 case WM_IME_SELECT:1360 DPRINTF_EDIT_MSG32("WM_IME_SELECT");1361 if( unicode )1362 result = DefWindowProcW( hwnd, msg, wParam, lParam );1363 else1364 result = DefWindowProcA( hwnd, msg, wParam, lParam );1365 break;1366 1367 case WM_IME_SETCONTEXT:1368 DPRINTF_EDIT_MSG32("WM_IME_SETCONTEXT");1369 1370 dprintf(("ImmGetProperty %08lx", ImmGetProperty( 0, IGP_CONVERSION )));1371 1372 if( unicode )1373 result = DefWindowProcW( hwnd, msg, wParam, lParam );1374 else1375 result = DefWindowProcA( hwnd, msg, wParam, lParam );1376 break;1377 1378 case WM_IME_STARTCOMPOSITION:1379 DPRINTF_EDIT_MSG32("WM_IME_STARTCOMPOSITION");1380 1381 es->compStr = NULL;1382 es->compStrLen = 0;1383 1384 if( unicode )1385 result = DefWindowProcW( hwnd, msg, wParam, lParam );1386 else1387 result = DefWindowProcA( hwnd, msg, wParam, lParam );1388 break;1389 1390 case EM_GETIMESTATUS:1391 DPRINTF_EDIT_MSG32("EM_GETIMESTATUS");1392 if( unicode )1393 result = DefWindowProcW( hwnd, msg, wParam, lParam );1394 else1395 result = DefWindowProcA( hwnd, msg, wParam, lParam );1396 break;1397 1398 case EM_SETIMESTATUS:1399 DPRINTF_EDIT_MSG32("EM_SETIMESTATUS");1400 if( unicode )1401 result = DefWindowProcW( hwnd, msg, wParam, lParam );1402 else1403 result = DefWindowProcA( hwnd, msg, wParam, lParam );1404 break;1405 1125 #endif 1406 1126 … … 2720 2440 { 2721 2441 LRESULT res = EDIT_EM_PosFromChar(hwnd, es, pos, after_wrap); 2722 2723 #ifdef __WIN32OS2__2724 if( es->moveCaret )2725 {2726 HIMC himc;2727 CANDIDATEFORM candForm;2728 2729 himc = ImmGetContext( hwnd );2730 2731 #endif2732 2442 SetCaretPos(SLOWORD(res), SHIWORD(res)); 2733 2734 #ifdef __WIN32OS2__2735 if( es->sentenceMode )2736 {2737 COMPOSITIONFORM cf;2738 2739 cf.dwStyle = CFS_POINT;2740 cf.ptCurrentPos.x = SLOWORD( res );2741 cf.ptCurrentPos.y = SHIWORD( res );2742 2743 ImmSetCompositionWindow( himc, &cf );2744 }2745 2746 candForm.dwIndex = 0;2747 candForm.dwStyle = CFS_CANDIDATEPOS;2748 candForm.ptCurrentPos.x = SLOWORD( res );2749 candForm.ptCurrentPos.y = SHIWORD( res ) + es->line_height;2750 2751 ImmSetCandidateWindow( himc, &candForm );2752 2753 ImmReleaseContext( hwnd, himc );2754 }2755 #endif2756 2443 } 2757 2444 … … 5086 4773 } 5087 4774 5088 #ifdef __WIN32OS2__5089 es->compStr = NULL;5090 es->compStrLen = 0;5091 es->moveCaret = TRUE;5092 {5093 HIMC himc;5094 DWORD conversionMode;5095 5096 himc = ImmGetContext( hwnd );5097 5098 ImmGetConversionStatus( himc, &conversionMode, &es->sentenceMode );5099 5100 ImmReleaseContext( hwnd, himc );5101 }5102 #endif5103 5104 4775 return TRUE; 5105 4776 } … … 5238 4909 es->line_height = tm.tmHeight; 5239 4910 es->char_width = tm.tmAveCharWidth; 5240 #ifdef __WIN32OS2__5241 // todo : set font of IME window5242 #endif5243 4911 if (font) 5244 4912 SelectObject(dc, old_font);
Note:
See TracChangeset
for help on using the changeset viewer.