Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

softkbd.c File Reference

#include "precomp.h"
#include "softkbd.h"

Go to the source code of this file.

Functions

BOOL RegisterSoftKeyboard (UINT uType)
VOID GetSoftKeyboardDimension (UINT uType, LPINT lpnWidth, LPINT lpnHeight)
void GetAllMonitorSize (LPRECT lprc)
BOOL GetNearestMonitorSize (HWND hwndOwner, LPRECT lprc)
HWND WINAPI ImmCreateSoftKeyboard (UINT uType, HWND hOwner, int x, int y)
BOOL WINAPI ImmDestroySoftKeyboard (HWND hSKWnd)
BOOL WINAPI ImmShowSoftKeyboard (HWND hSKWnd, int nCmdShow)

Variables

CONST LPCWSTR SoftKeyboardClassName []


Function Documentation

void GetAllMonitorSize LPRECT  lprc  ) 
 

Definition at line 103 of file softkbd.c.

References GetSystemMetrics(), and SystemParametersInfo().

Referenced by GetNearestMonitorSize(), SKC1DrawDragBorder(), and SKT1SetCursor().

00104 { 00105 if (GetSystemMetrics(SM_CMONITORS) == 1) { 00106 SystemParametersInfo(SPI_GETWORKAREA, 0, lprc, 0); 00107 } else { 00108 // We have multi-monitor ! 00109 lprc->left = GetSystemMetrics(SM_XVIRTUALSCREEN); 00110 lprc->top = GetSystemMetrics(SM_YVIRTUALSCREEN); 00111 lprc->right = lprc->left + GetSystemMetrics(SM_CXVIRTUALSCREEN); 00112 lprc->bottom = lprc->top + GetSystemMetrics(SM_CYVIRTUALSCREEN); 00113 } 00114 }

BOOL GetNearestMonitorSize HWND  hwndOwner,
LPRECT  lprc
 

Definition at line 116 of file softkbd.c.

References BOOL, FALSE, GetAllMonitorSize(), GetSystemMetrics(), MonitorFromWindow(), NULL, and TRUE.

Referenced by ImmCreateSoftKeyboard().

00117 { 00118 if (GetSystemMetrics(SM_CMONITORS) == 1) { 00119 GetAllMonitorSize(lprc); 00120 } 00121 else { 00122 HMONITOR hmonitor = MonitorFromWindow(hwndOwner, MONITOR_DEFAULTTONEAREST); 00123 MONITORINFO mInfo = { 00124 sizeof(MONITORINFO), 00125 }; 00126 00127 if (hmonitor == NULL) { 00128 return FALSE; 00129 } 00130 GetMonitorInfoW(hmonitor, &mInfo); 00131 *lprc = mInfo.rcWork; 00132 } 00133 return TRUE; 00134 }

VOID GetSoftKeyboardDimension UINT  uType,
LPINT  lpnWidth,
LPINT  lpnHeight
 

Definition at line 65 of file softkbd.c.

References GetSKT1TextMetric(), GetSystemMetrics(), gptRaiseEdge, HEIGHT_SOFTKBD_C1, SKT1_LABEL_BMP_X, SKT1_LABEL_BMP_Y, SKT1_TOTAL_COLUMN_NUM, SKT1_TOTAL_ROW_NUM, SKT1_XIN, SKT1_XOUT, SKT1_XOVERLAP, SKT1_YIN, SKT1_YOUT, VOID(), and WIDTH_SOFTKBD_C1.

Referenced by ImmCreateSoftKeyboard().

00069 { 00070 switch (uType) { 00071 case SOFTKEYBOARD_TYPE_T1: 00072 { 00073 TEXTMETRIC tm; 00074 00075 GetSKT1TextMetric(&tm); 00076 00077 *lpnWidth = 2 * SKT1_XOUT + 2 * gptRaiseEdge.x + 00078 (tm.tmMaxCharWidth + SKT1_LABEL_BMP_X - SKT1_XOVERLAP + 00079 SKT1_XIN) * SKT1_TOTAL_COLUMN_NUM + 1 + 1; 00080 00081 *lpnHeight = 2 * SKT1_YOUT + 2 * gptRaiseEdge.y + 00082 (tm.tmHeight + SKT1_LABEL_BMP_Y + SKT1_YIN) * 00083 SKT1_TOTAL_ROW_NUM + 1; 00084 } 00085 break; 00086 case SOFTKEYBOARD_TYPE_C1: 00087 { 00088 *lpnWidth = WIDTH_SOFTKBD_C1 + 00089 2 * GetSystemMetrics(SM_CXBORDER) + 00090 2 * GetSystemMetrics(SM_CXEDGE); 00091 00092 *lpnHeight = HEIGHT_SOFTKBD_C1 + 00093 2 * GetSystemMetrics(SM_CXBORDER) + 00094 2 * GetSystemMetrics(SM_CXEDGE); 00095 } 00096 break; 00097 default: 00098 return; 00099 } 00100 }

HWND WINAPI ImmCreateSoftKeyboard UINT  uType,
HWND  hOwner,
int  x,
int  y
 

Definition at line 137 of file softkbd.c.

References BOOL, CreateWindowEx(), DWORD, FALSE, GetKeyboardLayout(), GetNearestMonitorSize(), GetSoftKeyboardDimension(), GetSystemMetrics(), ghInst, gptRaiseEdge, guScanCode, tagIMEDPI::ImeInfo, ImmLockImeDpi(), ImmUnlockImeDpi(), MapVirtualKey(), NULL, RegisterSoftKeyboard(), ShowWindow, SoftKeyboardClassName, TRUE, UI_MARGIN, UINT, and UpdateWindow().

00142 { 00143 static BOOL fFirstSoftKeyboard = TRUE; 00144 PIMEDPI pImeDpi; 00145 DWORD fdwUICaps; 00146 int nWidth, nHeight; 00147 HKL hCurrentKL; 00148 UINT i; 00149 HWND hSKWnd; 00150 RECT rcWork; 00151 SIZE szWork; 00152 00153 if (!uType) { 00154 return (HWND)NULL; 00155 } 00156 00157 if (uType >= sizeof(SoftKeyboardClassName) / sizeof(LPWSTR)) { 00158 return (HWND)NULL; 00159 } 00160 00161 hCurrentKL = GetKeyboardLayout(0); 00162 00163 pImeDpi = ImmLockImeDpi(hCurrentKL); 00164 if (pImeDpi == NULL) { 00165 RIPMSG1(RIP_WARNING, 00166 "ImmCreateSoftKeyboard, pImeDpi = NULL (hkl = 0x%x).\n", hCurrentKL); 00167 return (HWND)NULL; 00168 } 00169 00170 fdwUICaps = pImeDpi->ImeInfo.fdwUICaps; 00171 ImmUnlockImeDpi(pImeDpi); 00172 00173 if (!(fdwUICaps & UI_CAP_SOFTKBD)) { 00174 return (HWND)NULL; 00175 } 00176 00177 if (fFirstSoftKeyboard) { 00178 if (!GetNearestMonitorSize(hOwner, &rcWork)) { 00179 // failed 00180 return NULL; 00181 } 00182 00183 for (i = 0; i < sizeof(guScanCode) / sizeof(UINT); i++) { 00184 guScanCode[i] = MapVirtualKey(i, 0); 00185 } 00186 00187 00188 // LATER: have to consider the dynamic resolution change 00189 00190 szWork.cx = rcWork.right - rcWork.left; 00191 00192 UserAssert(szWork.cx > UI_MARGIN * 2); 00193 szWork.cy = rcWork.bottom - rcWork.top; 00194 UserAssert(szWork.cy > UI_MARGIN * 2); 00195 00196 gptRaiseEdge.x = GetSystemMetrics(SM_CXEDGE) + 00197 GetSystemMetrics(SM_CXBORDER); 00198 gptRaiseEdge.y = GetSystemMetrics(SM_CYEDGE) + 00199 GetSystemMetrics(SM_CYBORDER); 00200 00201 fFirstSoftKeyboard = FALSE; 00202 } 00203 00204 if (!RegisterSoftKeyboard(uType)) { 00205 return (HWND)NULL; 00206 } 00207 00208 GetSoftKeyboardDimension(uType, &nWidth, &nHeight); 00209 00210 // boundry check 00211 if (x < 0) { 00212 x = 0; 00213 } else if (x + nWidth > szWork.cx) { 00214 x = szWork.cx - nWidth; 00215 } 00216 00217 if (y < 0) { 00218 y = 0; 00219 } else if (y + nHeight > szWork.cy) { 00220 y = szWork.cy - nHeight; 00221 } 00222 00223 switch (uType) { 00224 case SOFTKEYBOARD_TYPE_T1: 00225 hSKWnd = CreateWindowEx(0, 00226 SoftKeyboardClassName[uType], 00227 (LPCWSTR)NULL, 00228 WS_POPUP|WS_DISABLED, 00229 x, y, nWidth, nHeight, 00230 (HWND)hOwner, (HMENU)NULL, ghInst, NULL); 00231 break; 00232 case SOFTKEYBOARD_TYPE_C1: 00233 hSKWnd = CreateWindowEx(WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME, 00234 SoftKeyboardClassName[uType], 00235 (LPCWSTR)NULL, 00236 WS_POPUP|WS_DISABLED|WS_BORDER, 00237 x, y, nWidth, nHeight, 00238 (HWND)hOwner, (HMENU)NULL, ghInst, NULL); 00239 break; 00240 default: 00241 return (HWND)NULL; 00242 } 00243 00244 ShowWindow(hSKWnd, SW_HIDE); 00245 UpdateWindow(hSKWnd); 00246 00247 return (hSKWnd); 00248 }

BOOL WINAPI ImmDestroySoftKeyboard HWND  hSKWnd  ) 
 

Definition at line 252 of file softkbd.c.

References DestroyWindow.

00254 { 00255 return DestroyWindow(hSKWnd); 00256 }

BOOL WINAPI ImmShowSoftKeyboard HWND  hSKWnd,
int  nCmdShow
 

Definition at line 260 of file softkbd.c.

References FALSE, and ShowWindow.

00263 { 00264 if (!hSKWnd) { 00265 return (FALSE); 00266 } 00267 return ShowWindow(hSKWnd, nCmdShow); 00268 }

BOOL RegisterSoftKeyboard UINT  uType  ) 
 

Definition at line 24 of file softkbd.c.

References BOOL, FALSE, GetClassInfoEx(), ghInst, NULL, RegisterClassEx, SKWndProcC1(), SKWndProcT1(), SoftKeyboardClassName, and TRUE.

Referenced by ImmCreateSoftKeyboard().

00026 { 00027 WNDCLASSEX wcWndCls; 00028 00029 if (GetClassInfoEx(ghInst, SoftKeyboardClassName[uType], &wcWndCls)) { 00030 return (TRUE); 00031 } 00032 00033 wcWndCls.cbSize = sizeof(WNDCLASSEX); 00034 wcWndCls.style = CS_IME; 00035 wcWndCls.cbClsExtra = 0; 00036 wcWndCls.cbWndExtra = sizeof(HGLOBAL); 00037 wcWndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION); 00038 wcWndCls.hInstance = ghInst; 00039 wcWndCls.hCursor = LoadCursor(NULL, IDC_SIZEALL); 00040 wcWndCls.lpszMenuName = (LPWSTR)NULL; 00041 wcWndCls.lpszClassName = SoftKeyboardClassName[uType]; 00042 wcWndCls.hIconSm = NULL; 00043 00044 switch (uType) { 00045 case SOFTKEYBOARD_TYPE_T1: 00046 wcWndCls.lpfnWndProc = SKWndProcT1; 00047 wcWndCls.hbrBackground = GetStockObject(NULL_BRUSH); 00048 break; 00049 case SOFTKEYBOARD_TYPE_C1: 00050 wcWndCls.lpfnWndProc = SKWndProcC1; 00051 wcWndCls.hbrBackground = GetStockObject(LTGRAY_BRUSH); 00052 break; 00053 default: 00054 return (TRUE); 00055 } 00056 00057 if (RegisterClassEx(&wcWndCls)) { 00058 return (TRUE); 00059 } else { 00060 return (FALSE); 00061 } 00062 }


Variable Documentation

CONST LPCWSTR SoftKeyboardClassName[]
 

Initial value:

{ L"", L"SoftKBDClsT1", L"SoftKBDClsC1" }

Definition at line 17 of file softkbd.c.

Referenced by ImmCreateSoftKeyboard(), and RegisterSoftKeyboard().


Generated on Sat May 15 19:45:39 2004 for test by doxygen 1.3.7