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