test: sftkbdc1.c File Reference

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

# sftkbdc1.c File Reference

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

Go to the source code of this file.

## Defines

#define | CHECK_RECT(name)

## Functions

VOID | InitSKC1ButtonPos ()
VOID | SKC1DrawConvexRect (HDC hDC, int x, int y, int nWidth, int nHeight)
VOID | SKC1InvertButton (HDC hDC, int uKeyIndex)
VOID | SKC1DrawBitmap (HDC hDC, int x, int y, int nWidth, int nHeight, LPWSTR lpszBitmap)
VOID | SKC1DrawLabel (HDC hDC, LPWSTR lpszLabel)
VOID | InitSKC1Bitmap (HDC hDC, RECT rcClient)
LRESULT | CreateC1Window (HWND hSKWnd)
VOID | DestroyC1Window (HWND hSKWnd)
VOID | ShowSKC1Window (HDC hDC, HWND hSKWnd)
BOOL | UpdateSKC1Window (HWND hSKWnd, LPSOFTKBDDATA lpSoftKbdData)
VOID | SKC1DrawDragBorder (HWND hWnd, LPPOINT lpptCursor, LPPOINT lpptOffset)
INT | SKC1MousePosition (LPPOINT lpptCursor)
VOID | SKC1ButtonDown (HWND hSKWnd, PSKC1CTXT pSKC1Ctxt)
BOOL | SKC1SetCursor (HWND hSKWnd, LPARAM lParam)
BOOL | SKC1MouseMove (HWND hSKWnd, WPARAM wParam, LPARAM lParam)
BOOL | SKC1ButtonUp (HWND hSKWnd, WPARAM wParam, LPARAM lParam)
LRESULT | SKWndProcC1 (HWND hSKWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

## Variables

CONST BYTE | SKC1VirtKey [BUTTON_NUM_C1]
POINT | gptButtonPos [BUTTON_NUM_C1]
BOOL | gfSoftKbdC1Init = FALSE

## Define Documentation

#define CHECK_RECT | ( | name |  | ) |

Value:

    if (ImmPtInRect(gptButtonPos[name ## _TYPE_C1].x,   \
                gptButtonPos[name ## _TYPE_C1].y,           \
                W_ ## name ## _C1 + 2 * BORDER_C1,          \
                H_ ## name ## _C1 + 2 * BORDER_C1,          \
                lpptCursor)) {                              \
            return name ## _TYPE_C1;                        \
        }

Definition at line 670 of file sftkbdc1.c.

Referenced by SKC1MousePosition().

## Function Documentation

LRESULT CreateC1Window | ( | HWND | hSKWnd | ) |

Definition at line 342 of file sftkbdc1.c.

References GetClientRect(), GetDC, gfSoftKbdC1Init, _tagSKC1CTXT::hSoftkbd, InitSKC1Bitmap(), InitSKC1ButtonPos(), L, _tagSKC1CTXT::lfCharSet, PSKC1CTXT, ReleaseDC(), SetWindowLongPtr(), SKC1_CONTEXT, SKC1CTXT, TRUE, and _tagSKC1CTXT::uKeyIndex.

Referenced by SKWndProcC1().

    00344 {
    00345     HGLOBAL   hSKC1Ctxt;
    00346     PSKC1CTXT pSKC1Ctxt;
    00347
    00348     // alloc and lock hSKC1CTxt
    00349     hSKC1Ctxt = GlobalAlloc(GHND, sizeof(SKC1CTXT));
    00350     if (!hSKC1Ctxt) {
    00351         return (-1L);
    00352     }
    00353
    00354     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00355     if (!pSKC1Ctxt) {
    00356         GlobalFree(hSKC1Ctxt);
    00357         return (-1L);
    00358     }
    00359
    00360     // save handle in SKC1_CONTEXT
    00361     SetWindowLongPtr(hSKWnd, SKC1_CONTEXT, (LONG_PTR)hSKC1Ctxt);
    00362
    00363     // init global varialbles
    00364     if (!gfSoftKbdC1Init){
    00365       InitSKC1ButtonPos();
    00366       gfSoftKbdC1Init = TRUE;
    00367     }
    00368
    00369     // no index and default char set
    00370     pSKC1Ctxt->uKeyIndex = -1;
    00371     pSKC1Ctxt->lfCharSet = GB2312_CHARSET;
    00372
    00373     // init softkeyboard
    00374     {
    00375       HDC        hDC, hMemDC;
    00376       HBITMAP    hBitmap, hOldBmp;
    00377       RECT       rcClient;
    00378
    00379       GetClientRect(hSKWnd, &rcClient);
    00380
    00381       hDC = GetDC(hSKWnd);
    00382       hMemDC = CreateCompatibleDC(hDC);
    00383       hBitmap = CreateCompatibleBitmap(hDC, rcClient.right - rcClient.left,
    00384                                        rcClient.bottom - rcClient.top);
    00385       ReleaseDC(hSKWnd, hDC);
    00386
    00387       hOldBmp = SelectObject(hMemDC, hBitmap);
    00388
    00389       InitSKC1Bitmap(hMemDC, rcClient);
    00390
    00391       SelectObject(hMemDC, hOldBmp);
    00392       pSKC1Ctxt->hSoftkbd = hBitmap; // save hBitmap in SKC1CTXT
    00393
    00394       DeleteDC(hMemDC);
    00395     }
    00396
    00397     // unlock hSKC1CTxt
    00398     GlobalUnlock(hSKC1Ctxt);
    00399
    00400     return (0L);
    00401 }

VOID DestroyC1Window | ( | HWND | hSKWnd | ) |

Definition at line 410 of file sftkbdc1.c.

References FLAG_DRAG_C1, GetWindow(), GetWindowLongPtr(), _tagSKC1CTXT::hSoftkbd, _tagSKC1CTXT::ptSkCursor, _tagSKC1CTXT::ptSkOffset, SendMessage(), SKC1_CONTEXT, SKC1DrawDragBorder(), _tagSKC1CTXT::uState, and VOID().

Referenced by SKWndProcC1().

    00412 {
    00413     HGLOBAL   hSKC1Ctxt;
    00414     PSKC1CTXT pSKC1Ctxt;
    00415     HWND      hUIWnd;
    00416
    00417     // Get and Lock hSKC1Ctxt
    00418     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00419     if (!hSKC1Ctxt) return;
    00420
    00421     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00422     if (!pSKC1Ctxt) return;
    00423
    00424     if (pSKC1Ctxt->uState & FLAG_DRAG_C1) {
    00425        SKC1DrawDragBorder(hSKWnd, &pSKC1Ctxt->ptSkCursor,
    00426                           &pSKC1Ctxt->ptSkOffset);
    00427     }
    00428
    00429     DeleteObject(pSKC1Ctxt->hSoftkbd); // delete hBitmap
    00430
    00431     // Unlock and Free hSKC1Ctxt
    00432     GlobalUnlock(hSKC1Ctxt);
    00433     GlobalFree(hSKC1Ctxt);
    00434
    00435     // send message to parent window
    00436     hUIWnd = GetWindow(hSKWnd, GW_OWNER);
    00437     if (hUIWnd) {
    00438       SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_SOFTKBDDESTROYED, 0);\
    00439     }
    00440
    00441     return;
    00442 }

VOID InitSKC1Bitmap | ( | HDC | hDC,
|  | RECT | rcClient
| ) |

Definition at line 269 of file sftkbdc1.c.

References BACKSP_C1, BACKSP_TYPE_C1, BORDER_C1, CAPS_C1, CAPS_TYPE_C1, DEL_C1, DEL_TYPE_C1, ENTER_C1, ENTER_TYPE_C1, ESC_C1, ESC_TYPE_C1, gptButtonPos, H_BACKSP_C1, H_BOTTOM_BTN_C1, H_CAPS_C1, H_DEL_C1, H_ENTER_C1, H_ESC_C1, H_INS_C1, H_LETTER_BTN_C1, H_SHIFT_C1, H_TAB_C1, INS_C1, INS_TYPE_C1, LABEL_C1, LETTER_NUM_C1, SHIFT_C1, SHIFT_TYPE_C1, SKC1DrawBitmap(), SKC1DrawConvexRect(), SKC1DrawLabel(), SPACE_TYPE_C1, TAB_C1, TAB_TYPE_C1, VOID(), W_BACKSP_C1, W_CAPS_C1, W_DEL_C1, W_ENTER_C1, W_ESC_C1, W_INS_C1, W_LETTER_BTN_C1, W_SHIFT_C1, W_SPACE_C1, and W_TAB_C1.

Referenced by CreateC1Window().

    00272 {
    00273     int  i;
    00274
    00275     // draw softkbd rectangle
    00276     SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
    00277     SelectObject(hDC, GetStockObject(NULL_PEN));
    00278     Rectangle(hDC, rcClient.left, rcClient.top, rcClient.right + 1, rcClient.bottom + 1);
    00279
    00280     // draw letter buttons
    00281     for (i = 0; i < LETTER_NUM_C1; i++) {
    00282       SKC1DrawConvexRect(hDC, gptButtonPos[i].x, gptButtonPos[i].y,
    00283                          W_LETTER_BTN_C1, H_LETTER_BTN_C1);
    00284     }
    00285     // draw letter label
    00286     SKC1DrawLabel(hDC, MAKEINTRESOURCEW(LABEL_C1));
    00287
    00288     // draw other buttons
    00289     SKC1DrawConvexRect(hDC, gptButtonPos[BACKSP_TYPE_C1].x, gptButtonPos[BACKSP_TYPE_C1].y,
    00290                        W_BACKSP_C1 + 2 * BORDER_C1, H_LETTER_BTN_C1);
    00291     SKC1DrawBitmap(hDC, gptButtonPos[BACKSP_TYPE_C1].x + BORDER_C1, gptButtonPos[BACKSP_TYPE_C1].y + BORDER_C1,
    00292                    W_BACKSP_C1, H_BACKSP_C1, MAKEINTRESOURCEW(BACKSP_C1));
    00293
    00294     SKC1DrawConvexRect(hDC, gptButtonPos[TAB_TYPE_C1].x, gptButtonPos[TAB_TYPE_C1].y,
    00295                        W_TAB_C1 + 2 * BORDER_C1, H_LETTER_BTN_C1);
    00296     SKC1DrawBitmap(hDC, gptButtonPos[TAB_TYPE_C1].x + BORDER_C1, gptButtonPos[TAB_TYPE_C1].y + BORDER_C1,
    00297                    W_TAB_C1, H_TAB_C1, MAKEINTRESOURCEW(TAB_C1));
    00298
    00299     SKC1DrawConvexRect(hDC, gptButtonPos[CAPS_TYPE_C1].x, gptButtonPos[CAPS_TYPE_C1].y,
    00300                        W_CAPS_C1 + 2 * BORDER_C1, H_LETTER_BTN_C1);
    00301     SKC1DrawBitmap(hDC, gptButtonPos[CAPS_TYPE_C1].x + BORDER_C1, gptButtonPos[CAPS_TYPE_C1].y + BORDER_C1,
    00302                    W_CAPS_C1, H_CAPS_C1, MAKEINTRESOURCEW(CAPS_C1));
    00303
    00304     SKC1DrawConvexRect(hDC, gptButtonPos[ENTER_TYPE_C1].x, gptButtonPos[ENTER_TYPE_C1].y,
    00305                        W_ENTER_C1 + 2 * BORDER_C1, H_LETTER_BTN_C1);
    00306     SKC1DrawBitmap(hDC, gptButtonPos[ENTER_TYPE_C1].x + BORDER_C1, gptButtonPos[ENTER_TYPE_C1].y + BORDER_C1,
    00307                    W_ENTER_C1, H_ENTER_C1, MAKEINTRESOURCEW(ENTER_C1));
    00308
    00309     SKC1DrawConvexRect(hDC, gptButtonPos[SHIFT_TYPE_C1].x, gptButtonPos[SHIFT_TYPE_C1].y,
    00310                        W_SHIFT_C1 + 2 * BORDER_C1, H_LETTER_BTN_C1);
    00311     SKC1DrawBitmap(hDC, gptButtonPos[SHIFT_TYPE_C1].x + BORDER_C1, gptButtonPos[SHIFT_TYPE_C1].y + BORDER_C1,
    00312                    W_SHIFT_C1, H_SHIFT_C1, MAKEINTRESOURCEW(SHIFT_C1));
    00313
    00314     SKC1DrawConvexRect(hDC, gptButtonPos[INS_TYPE_C1].x, gptButtonPos[INS_TYPE_C1].y,
    00315                        W_INS_C1 + 2 * BORDER_C1, H_BOTTOM_BTN_C1);
    00316     SKC1DrawBitmap(hDC, gptButtonPos[INS_TYPE_C1].x + BORDER_C1, gptButtonPos[INS_TYPE_C1].y + BORDER_C1,
    00317                    W_INS_C1, H_INS_C1, MAKEINTRESOURCEW(INS_C1));
    00318
    00319     SKC1DrawConvexRect(hDC, gptButtonPos[DEL_TYPE_C1].x, gptButtonPos[DEL_TYPE_C1].y,
    00320                        W_DEL_C1 + 2 * BORDER_C1, H_BOTTOM_BTN_C1);
    00321     SKC1DrawBitmap(hDC, gptButtonPos[DEL_TYPE_C1].x + BORDER_C1, gptButtonPos[DEL_TYPE_C1].y + BORDER_C1,
    00322                    W_DEL_C1, H_DEL_C1, MAKEINTRESOURCEW(DEL_C1));
    00323
    00324     SKC1DrawConvexRect(hDC, gptButtonPos[SPACE_TYPE_C1].x, gptButtonPos[SPACE_TYPE_C1].y,
    00325                        W_SPACE_C1 + 2 * BORDER_C1, H_BOTTOM_BTN_C1);
    00326
    00327     SKC1DrawConvexRect(hDC, gptButtonPos[ESC_TYPE_C1].x, gptButtonPos[ESC_TYPE_C1].y,
    00328                        W_ESC_C1 + 2 * BORDER_C1, H_BOTTOM_BTN_C1);
    00329     SKC1DrawBitmap(hDC, gptButtonPos[ESC_TYPE_C1].x + BORDER_C1, gptButtonPos[ESC_TYPE_C1].y + BORDER_C1,
    00330                    W_ESC_C1, H_ESC_C1, MAKEINTRESOURCEW(ESC_C1));
    00331
    00332     return;
    00333 }

VOID InitSKC1ButtonPos | ( |  | ) |

Definition at line 33 of file sftkbdc1.c.

References BACKSP_TYPE_C1, BORDER_C1, CAPS_TYPE_C1, COL2_LETTER_C1, COL3_LETTER_C1, COL4_LETTER_C1, COL_LETTER_C1, DEL_TYPE_C1, ENTER_TYPE_C1, ESC_TYPE_C1, gptButtonPos, H_LETTER_BTN_C1, INS_TYPE_C1, SHIFT_TYPE_C1, SPACE_TYPE_C1, TAB_TYPE_C1, VOID(), W_DEL_C1, W_LETTER_BTN_C1, X_DEL_C1, X_ESC_C1, X_ROW2_LETTER_C1, X_ROW3_LETTER_C1, X_ROW4_LETTER_C1, and X_ROW_LETTER_C1.

Referenced by CreateC1Window().

    00034 {
    00035     int  i, x, y;
    00036
    00037     // init the first row
    00038     y = 0;
    00039     for (i=0, x=X_ROW_LETTER_C1; i < COL_LETTER_C1; i++, x += W_LETTER_BTN_C1) {
    00040       gptButtonPos[i].x = x;
    00041       gptButtonPos[i].y = y;
    00042     }
    00043     gptButtonPos[BACKSP_TYPE_C1].x = x;
    00044     gptButtonPos[BACKSP_TYPE_C1].y = y;
    00045
    00046     // init the second row
    00047     y += H_LETTER_BTN_C1;
    00048     x = 0;
    00049     gptButtonPos[TAB_TYPE_C1].x = x;
    00050     gptButtonPos[TAB_TYPE_C1].y = y;
    00051     for (i=0, x=X_ROW2_LETTER_C1; i < COL2_LETTER_C1; i++, x += W_LETTER_BTN_C1) {
    00052       gptButtonPos[i + COL_LETTER_C1].x = x;
    00053       gptButtonPos[i + COL_LETTER_C1].y = y;
    00054     }
    00055
    00056     // init the third row
    00057     y += H_LETTER_BTN_C1;
    00058     x = 0;
    00059     gptButtonPos[CAPS_TYPE_C1].x = x;
    00060     gptButtonPos[CAPS_TYPE_C1].y = y;
    00061     for (i=0, x=X_ROW3_LETTER_C1; i < COL3_LETTER_C1; i++, x += W_LETTER_BTN_C1) {
    00062       gptButtonPos[i + COL_LETTER_C1 + COL2_LETTER_C1].x = x;
    00063       gptButtonPos[i + COL_LETTER_C1 + COL2_LETTER_C1].y = y;
    00064     }
    00065     gptButtonPos[ENTER_TYPE_C1].x = x;
    00066     gptButtonPos[ENTER_TYPE_C1].y = y;
    00067
    00068     // init the forth row
    00069     y += H_LETTER_BTN_C1;
    00070     x = 0;
    00071     gptButtonPos[SHIFT_TYPE_C1].x = x;
    00072     gptButtonPos[SHIFT_TYPE_C1].y = y;
    00073     for (i=0, x=X_ROW4_LETTER_C1; i < COL4_LETTER_C1; i++, x += W_LETTER_BTN_C1) {
    00074       gptButtonPos[i + COL_LETTER_C1 + COL2_LETTER_C1 + COL3_LETTER_C1].x = x;
    00075       gptButtonPos[i + COL_LETTER_C1 + COL2_LETTER_C1 + COL3_LETTER_C1].y = y;
    00076     }
    00077
    00078     // init the bottom row
    00079     y += H_LETTER_BTN_C1;
    00080     x = 0;
    00081     gptButtonPos[INS_TYPE_C1].x = x;
    00082     gptButtonPos[INS_TYPE_C1].y = y;
    00083     x = X_DEL_C1;
    00084     gptButtonPos[DEL_TYPE_C1].x = x;
    00085     gptButtonPos[DEL_TYPE_C1].y = y;
    00086     x += W_DEL_C1 + 2 * BORDER_C1;
    00087     gptButtonPos[SPACE_TYPE_C1].x = x;
    00088     gptButtonPos[SPACE_TYPE_C1].y = y;
    00089     x = X_ESC_C1;
    00090     gptButtonPos[ESC_TYPE_C1].x = x;
    00091     gptButtonPos[ESC_TYPE_C1].y = y;
    00092
    00093     return;
    00094 }

VOID ShowSKC1Window | ( | HDC | hDC,
|  | HWND | hSKWnd
| ) |

Definition at line 449 of file sftkbdc1.c.

References GetClientRect(), GetWindowLongPtr(), _tagSKC1CTXT::hSoftkbd, SKC1_CONTEXT, and VOID().

Referenced by SKWndProcC1().

    00452 {
    00453     HGLOBAL   hSKC1Ctxt;
    00454     PSKC1CTXT pSKC1Ctxt;
    00455
    00456     // Get and Lock hSKC1Ctxt
    00457     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00458     if (!hSKC1Ctxt) return;
    00459
    00460     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00461     if (!pSKC1Ctxt) return;
    00462
    00463     // create mem dc to show softkeyboard
    00464     {
    00465        HDC      hMemDC;
    00466        HBITMAP  hOldBmp;
    00467        RECT     rcClient;
    00468
    00469        hMemDC = CreateCompatibleDC(hDC);
    00470        hOldBmp = SelectObject(hMemDC, pSKC1Ctxt->hSoftkbd);
    00471        GetClientRect(hSKWnd, &rcClient);
    00472        BitBlt(hDC, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
    00473               hMemDC, 0, 0, SRCCOPY);
    00474        SelectObject(hMemDC, hOldBmp);
    00475        DeleteDC(hMemDC);
    00476     }
    00477
    00478     // Unlock hSKC1Ctxt
    00479     GlobalUnlock(hSKC1Ctxt);
    00480
    00481     return;
    00482 }

VOID SKC1ButtonDown | ( | HWND | hSKWnd,
|  | PSKC1CTXT | pSKC1Ctxt
| ) |

Definition at line 716 of file sftkbdc1.c.

References BOOL, FALSE, FLAG_DRAG_C1, FLAG_FOCUS_C1, FLAG_SHIFT_C1, GetDC, _tagSKC1CTXT::hSoftkbd, LETTER_NUM_C1, MessageBeep(), _tagSKC1CTXT::ptSkCursor, _tagSKC1CTXT::ptSkOffset, ReleaseDC(), SetCapture, SHIFT_TYPE_C1, SKC1DrawDragBorder(), SKC1InvertButton(), TRUE, UINT, _tagSKC1CTXT::uKeyIndex, _tagSKC1CTXT::uState, VOID(), _tagSKC1CTXT::wNonShiftCode, and _tagSKC1CTXT::wShiftCode.

Referenced by SKC1SetCursor().

    00719 {
    00720     // capture the mouse activity
    00721     SetCapture(hSKWnd);
    00722
    00723     // in drag area
    00724     if (pSKC1Ctxt->uKeyIndex == -1) {
    00725        pSKC1Ctxt->uState |= FLAG_DRAG_C1;
    00726
    00727        SKC1DrawDragBorder(hSKWnd, &pSKC1Ctxt->ptSkCursor, &pSKC1Ctxt->ptSkOffset);
    00728     } else {
    00729        UINT uVirtKey = 0xff;
    00730        BOOL bRet = FALSE;
    00731
    00732        if (pSKC1Ctxt->uKeyIndex == SHIFT_TYPE_C1) {
    00733           if (!(pSKC1Ctxt->uState & FLAG_SHIFT_C1)) {
    00734              bRet = TRUE;
    00735           }
    00736        } else if (pSKC1Ctxt->uKeyIndex < LETTER_NUM_C1) {
    00737           if (pSKC1Ctxt->uState & FLAG_SHIFT_C1) {
    00738              uVirtKey = pSKC1Ctxt->wShiftCode[pSKC1Ctxt->uKeyIndex];
    00739           }
    00740           else {
    00741              uVirtKey = pSKC1Ctxt->wNonShiftCode[pSKC1Ctxt->uKeyIndex];
    00742           }
    00743
    00744           if (uVirtKey) {
    00745              bRet = TRUE;
    00746           } else {
    00747              MessageBeep(0xFFFFFFFF);
    00748              pSKC1Ctxt->uKeyIndex = -1;
    00749           }
    00750        } else {
    00751           bRet = TRUE;
    00752        }
    00753
    00754        if (bRet) {
    00755           HDC      hDC, hMemDC;
    00756           HBITMAP  hOldBmp;
    00757
    00758           hDC = GetDC(hSKWnd);
    00759           hMemDC = CreateCompatibleDC(hDC);
    00760           hOldBmp = SelectObject(hMemDC, pSKC1Ctxt->hSoftkbd);
    00761
    00762           SKC1InvertButton(hDC, pSKC1Ctxt->uKeyIndex);
    00763           SKC1InvertButton(hMemDC, pSKC1Ctxt->uKeyIndex);
    00764
    00765           SelectObject(hMemDC, hOldBmp);
    00766           DeleteDC(hMemDC);
    00767           ReleaseDC(hSKWnd,hDC);
    00768        }
    00769
    00770        if(uVirtKey) {
    00771           pSKC1Ctxt->uState |= FLAG_FOCUS_C1;
    00772        }
    00773     }
    00774
    00775     return;
    00776 }

BOOL SKC1ButtonUp | ( | HWND | hSKWnd,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) |

Definition at line 914 of file sftkbdc1.c.

References BOOL, BYTE, DWORD, FALSE, FLAG_DRAG_C1, FLAG_FOCUS_C1, FLAG_SHIFT_C1, GetDC, GetWindow(), GetWindowLongPtr(), guScanCode, _tagSKC1CTXT::hSoftkbd, ImmLockIMC(), ImmUnlockIMC(), keybd_event(), LETTER_NUM_C1, NULL, _tagSKC1CTXT::ptSkCursor, _tagSKC1CTXT::ptSkOffset, ReleaseCapture(), ReleaseDC(), SetWindowPos, SHIFT_TYPE_C1, SKC1_CONTEXT, SKC1DrawDragBorder(), SKC1InvertButton(), SKC1VirtKey, TRUE, UINT, _tagSKC1CTXT::uKeyIndex, and _tagSKC1CTXT::uState.

Referenced by SKWndProcC1().

    00918 {
    00919     HGLOBAL   hSKC1Ctxt;
    00920     PSKC1CTXT pSKC1Ctxt;
    00921     POINT     pt;
    00922     UINT      uVirtKey;
    00923     BOOL      bRet = FALSE;
    00924
    00925     UNREFERENCED_PARAMETER(wParam);
    00926     UNREFERENCED_PARAMETER(lParam);
    00927
    00928     // Get and lock hSKC1Ctxt
    00929     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00930     if (!hSKC1Ctxt) {
    00931         return (bRet);
    00932     }
    00933
    00934     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00935     if (!pSKC1Ctxt) {
    00936         return (bRet);
    00937     }
    00938
    00939     ReleaseCapture();
    00940
    00941     if (pSKC1Ctxt->uState & FLAG_DRAG_C1) {
    00942        pSKC1Ctxt->uState &= ~(FLAG_DRAG_C1);
    00943
    00944        SKC1DrawDragBorder(hSKWnd, &pSKC1Ctxt->ptSkCursor, &pSKC1Ctxt->ptSkOffset);
    00945
    00946        pt.x = pSKC1Ctxt->ptSkCursor.x - pSKC1Ctxt->ptSkOffset.x;
    00947        pt.y = pSKC1Ctxt->ptSkCursor.y - pSKC1Ctxt->ptSkOffset.y;
    00948
    00949        SetWindowPos(hSKWnd, (HWND)NULL, pt.x, pt.y,
    00950                      0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
    00951
    00952        // update IMC
    00953        bRet = TRUE;
    00954        {
    00955           HWND          hUIWnd;
    00956           HIMC          hImc;
    00957           PINPUTCONTEXT pInputContext;
    00958
    00959           hUIWnd = GetWindow(hSKWnd, GW_OWNER);
    00960           hImc = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
    00961           if (hImc) {
    00962              pInputContext = ImmLockIMC(hImc);
    00963              if (pInputContext) {
    00964                 pInputContext->ptSoftKbdPos = pt;
    00965                 pInputContext->fdwInit |= INIT_SOFTKBDPOS;
    00966                 ImmUnlockIMC(hImc);
    00967              }
    00968           }
    00969        }
    00970     } else if (pSKC1Ctxt->uKeyIndex != -1) {
    00971        if (pSKC1Ctxt->uState & FLAG_FOCUS_C1) {
    00972           if (pSKC1Ctxt->uKeyIndex == SHIFT_TYPE_C1) {
    00973              if (pSKC1Ctxt->uState & FLAG_SHIFT_C1) {
    00974                 bRet = TRUE;
    00975              } else {
    00976                 pSKC1Ctxt->uState |= FLAG_SHIFT_C1;
    00977              }
    00978           } else if ((pSKC1Ctxt->uKeyIndex < LETTER_NUM_C1) &&
    00979                      (pSKC1Ctxt->uState & FLAG_SHIFT_C1)) {
    00980                 keybd_event((BYTE)VK_SHIFT, (BYTE)guScanCode[VK_SHIFT],
    00981                             0, 0);
    00982                 uVirtKey = SKC1VirtKey[pSKC1Ctxt->uKeyIndex];
    00983                 keybd_event((BYTE)uVirtKey, (BYTE)guScanCode[uVirtKey],
    00984                            0, 0);
    00985                 keybd_event((BYTE)uVirtKey, (BYTE)guScanCode[uVirtKey],
    00986                            (DWORD)KEYEVENTF_KEYUP, 0);
    00987                 keybd_event((BYTE)VK_SHIFT, (BYTE)guScanCode[VK_SHIFT],
    00988                             (DWORD)KEYEVENTF_KEYUP, 0);
    00989                 bRet = TRUE;
    00990           } else {
    00991                 uVirtKey = SKC1VirtKey[pSKC1Ctxt->uKeyIndex];
    00992                 keybd_event((BYTE)uVirtKey, (BYTE)guScanCode[uVirtKey],
    00993                          0, 0);
    00994                 keybd_event((BYTE)uVirtKey, (BYTE)guScanCode[uVirtKey],
    00995                          (DWORD)KEYEVENTF_KEYUP, 0);
    00996                 bRet = TRUE;
    00997           }
    00998
    00999           if (bRet){
    01000              HDC      hDC, hMemDC;
    01001              HBITMAP  hOldBmp;
    01002
    01003              hDC = GetDC(hSKWnd);
    01004              hMemDC = CreateCompatibleDC(hDC);
    01005              hOldBmp = SelectObject(hMemDC, pSKC1Ctxt->hSoftkbd);
    01006
    01007              SKC1InvertButton(hDC, pSKC1Ctxt->uKeyIndex);
    01008              SKC1InvertButton(hMemDC, pSKC1Ctxt->uKeyIndex);
    01009
    01010              if ((pSKC1Ctxt->uKeyIndex != SHIFT_TYPE_C1) &&
    01011                  (pSKC1Ctxt->uKeyIndex < LETTER_NUM_C1) &&
    01012                  (pSKC1Ctxt->uState & FLAG_SHIFT_C1)) {
    01013                 SKC1InvertButton(hDC, SHIFT_TYPE_C1);
    01014                 SKC1InvertButton(hMemDC, SHIFT_TYPE_C1);
    01015              }
    01016
    01017              if ((pSKC1Ctxt->uKeyIndex < LETTER_NUM_C1) ||
    01018                  (pSKC1Ctxt->uKeyIndex == SHIFT_TYPE_C1)) {
    01019                 pSKC1Ctxt->uState &= ~(FLAG_SHIFT_C1);
    01020              }
    01021
    01022              SelectObject(hMemDC, hOldBmp);
    01023              DeleteDC(hMemDC);
    01024              ReleaseDC(hSKWnd,hDC);
    01025           }
    01026           pSKC1Ctxt->uState &= ~ (FLAG_FOCUS_C1);
    01027        }
    01028        pSKC1Ctxt->uKeyIndex = -1;
    01029     }
    01030
    01031     // unlock hSKC1Ctxt
    01032     GlobalUnlock(hSKC1Ctxt);
    01033
    01034     return (bRet);
    01035 }

VOID SKC1DrawBitmap | ( | HDC | hDC,
|  | int | x,
|  | int | y,
|  | int | nWidth,
|  | int | nHeight,
|  | LPWSTR | lpszBitmap
| ) |

Definition at line 211 of file sftkbdc1.c.

References ghInst, and VOID().

Referenced by InitSKC1Bitmap().

    00218 {
    00219     HDC     hMemDC;
    00220     HBITMAP hBitmap, hOldBmp;
    00221
    00222     hBitmap = LoadBitmap(ghInst, lpszBitmap);
    00223     hMemDC = CreateCompatibleDC(hDC);
    00224     hOldBmp = SelectObject(hMemDC, hBitmap);
    00225
    00226     BitBlt(hDC, x, y, nWidth, nHeight, hMemDC, 0 , 0, SRCCOPY);
    00227
    00228     SelectObject(hMemDC, hOldBmp);
    00229     DeleteDC(hMemDC);
    00230     DeleteObject(hBitmap);
    00231
    00232     return;
    00233 }

VOID SKC1DrawConvexRect | ( | HDC | hDC,
|  | int | x,
|  | int | y,
|  | int | nWidth,
|  | int | nHeight
| ) |

Definition at line 117 of file sftkbdc1.c.

References BORDER_C1, and VOID().

Referenced by InitSKC1Bitmap().

    00123 {
    00124     // paint background
    00125     SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
    00126     SelectObject(hDC, GetStockObject(BLACK_PEN));
    00127     Rectangle(hDC, x, y, x + nWidth, y + nHeight);
    00128
    00129     // paint white border
    00130     SelectObject(hDC, GetStockObject(WHITE_BRUSH));
    00131     PatBlt(hDC, x, y + nHeight - 1, BORDER_C1, -nHeight + 1, PATCOPY);
    00132     PatBlt(hDC, x, y, nWidth - 1 , BORDER_C1, PATCOPY);
    00133
    00134     // paint dark gray border
    00135     SelectObject(hDC, GetStockObject(GRAY_BRUSH));
    00136     PatBlt(hDC, x + 1, y + nHeight -1, nWidth - BORDER_C1, -1, PATCOPY);
    00137     PatBlt(hDC, x + nWidth - 1, y + nHeight - 1, -1, -nHeight + BORDER_C1, PATCOPY);
    00138
    00139     return;
    00140 }

VOID SKC1DrawDragBorder | ( | HWND | hWnd,
|  | LPPOINT | lpptCursor,
|  | LPPOINT | lpptOffset
| ) |

Definition at line 601 of file sftkbdc1.c.

References GetAllMonitorSize(), GetSystemMetrics(), GetWindowRect(), hWnd, L, NULL, and VOID().

Referenced by DestroyC1Window(), SKC1ButtonDown(), SKC1ButtonUp(), and SKC1MouseMove().

    00605 {
    00606     HDC     hDC;
    00607     RECT    rcWnd, rcWorkArea;
    00608     int     cxBorder, cyBorder;
    00609     int     x, y;
    00610     extern void GetAllMonitorSize(LPRECT lprc);
    00611
    00612     // get rectangle of work area
    00613     GetAllMonitorSize(&rcWorkArea);
    00614
    00615     cxBorder = GetSystemMetrics(SM_CXBORDER);   // width of border
    00616     cyBorder = GetSystemMetrics(SM_CYBORDER);   // height of border
    00617
    00618     // create DISPLAY dc to draw track
    00619     hDC = CreateDC(L"DISPLAY", NULL, NULL, NULL);
    00620     SelectObject(hDC, GetStockObject(GRAY_BRUSH));
    00621
    00622     // start point (left,top)
    00623     x = lpptCursor->x - lpptOffset->x;
    00624     y = lpptCursor->y - lpptOffset->y;
    00625
    00626     // check for the min boundary of the display
    00627     if (x < rcWorkArea.left) {
    00628         x = rcWorkArea.left;
    00629     }
    00630
    00631     if (y < rcWorkArea.top) {
    00632         y = rcWorkArea.top;
    00633     }
    00634
    00635     // check for the max boundary of the display
    00636     GetWindowRect(hWnd, &rcWnd);
    00637
    00638     if (x + rcWnd.right - rcWnd.left > rcWorkArea.right) {
    00639         x = rcWorkArea.right - (rcWnd.right - rcWnd.left);
    00640     }
    00641
    00642     if (y + rcWnd.bottom - rcWnd.top > rcWorkArea.bottom) {
    00643         y = rcWorkArea.bottom - (rcWnd.bottom - rcWnd.top);
    00644     }
    00645
    00646     // adjust Offset
    00647     lpptOffset->x = lpptCursor->x - x;
    00648     lpptOffset->y = lpptCursor->y - y;
    00649
    00650     // draw rectangle
    00651     PatBlt(hDC, x, y, rcWnd.right - rcWnd.left - cxBorder, cyBorder, PATINVERT);
    00652     PatBlt(hDC, x, y + cyBorder, cxBorder, rcWnd.bottom - rcWnd.top - cyBorder, PATINVERT);
    00653     PatBlt(hDC, x + cxBorder, y + rcWnd.bottom - rcWnd.top, rcWnd.right -
    00654            rcWnd.left - cxBorder, -cyBorder, PATINVERT);
    00655     PatBlt(hDC, x + rcWnd.right - rcWnd.left, y, - cxBorder, rcWnd.bottom -
    00656            rcWnd.top - cyBorder, PATINVERT);
    00657
    00658     // delete DISPLAY DC
    00659     DeleteDC(hDC);
    00660
    00661     return;
    00662 }

VOID SKC1DrawLabel | ( | HDC | hDC,
|  | LPWSTR | lpszLabel
| ) |

Definition at line 240 of file sftkbdc1.c.

References ghInst, gptButtonPos, LETTER_NUM_C1, SIZELABEL_C1, VOID(), X_LABEL_C1, and Y_LABEL_C1.

Referenced by InitSKC1Bitmap().

    00243 {
    00244     HDC     hMemDC;
    00245     HBITMAP hBitmap, hOldBmp;
    00246     int     i, x;
    00247
    00248     hBitmap = LoadBitmap(ghInst, lpszLabel);
    00249     hMemDC = CreateCompatibleDC(hDC);
    00250     hOldBmp = SelectObject(hMemDC, hBitmap);
    00251
    00252     for (i=x=0; i < LETTER_NUM_C1; i++, x += SIZELABEL_C1){
    00253      BitBlt(hDC, gptButtonPos[i].x + X_LABEL_C1, gptButtonPos[i].y + Y_LABEL_C1,
    00254             SIZELABEL_C1, SIZELABEL_C1, hMemDC, x , 0, SRCCOPY);
    00255     }
    00256
    00257     SelectObject(hMemDC, hOldBmp);
    00258     DeleteDC(hMemDC);
    00259     DeleteObject(hBitmap);
    00260
    00261     return;
    00262 }

VOID SKC1InvertButton | ( | HDC | hDC,
|  | int | uKeyIndex
| ) |

Definition at line 147 of file sftkbdc1.c.

References BACKSP_TYPE_C1, BORDER_C1, CAPS_TYPE_C1, DEL_TYPE_C1, ENTER_TYPE_C1, ESC_TYPE_C1, gptButtonPos, H_BOTTOM_BTN_C1, H_LETTER_BTN_C1, INS_TYPE_C1, LETTER_NUM_C1, SHIFT_TYPE_C1, SPACE_TYPE_C1, TAB_TYPE_C1, VOID(), W_BACKSP_C1, W_CAPS_C1, W_DEL_C1, W_ENTER_C1, W_ESC_C1, W_INS_C1, W_LETTER_BTN_C1, W_SHIFT_C1, W_SPACE_C1, and W_TAB_C1.

Referenced by SKC1ButtonDown(), SKC1ButtonUp(), SKC1MouseMove(), and UpdateSKC1Window().

    00150 {
    00151     int  nWidth, nHeight;
    00152
    00153     if (uKeyIndex < 0) return;
    00154
    00155     if (uKeyIndex < LETTER_NUM_C1) {
    00156       nWidth = W_LETTER_BTN_C1;
    00157       nHeight = H_LETTER_BTN_C1;
    00158     } else {
    00159       switch (uKeyIndex) {
    00160         case BACKSP_TYPE_C1:
    00161              nWidth = W_BACKSP_C1 + 2 * BORDER_C1;
    00162              nHeight = H_LETTER_BTN_C1;
    00163              break;
    00164         case TAB_TYPE_C1:
    00165              nWidth = W_TAB_C1 + 2 * BORDER_C1;
    00166              nHeight = H_LETTER_BTN_C1;
    00167              break;
    00168         case CAPS_TYPE_C1:
    00169              nWidth = W_CAPS_C1 + 2 * BORDER_C1;
    00170              nHeight = H_LETTER_BTN_C1;
    00171              break;
    00172         case ENTER_TYPE_C1:
    00173              nWidth = W_ENTER_C1 + 2 * BORDER_C1;
    00174              nHeight = H_LETTER_BTN_C1;
    00175              break;
    00176         case SHIFT_TYPE_C1:
    00177              nWidth = W_SHIFT_C1 + 2 * BORDER_C1;
    00178              nHeight = H_LETTER_BTN_C1;
    00179              break;
    00180         case INS_TYPE_C1:
    00181              nWidth = W_INS_C1 + 2 * BORDER_C1;
    00182              nHeight = H_BOTTOM_BTN_C1;
    00183              break;
    00184         case DEL_TYPE_C1:
    00185              nWidth = W_DEL_C1 + 2 * BORDER_C1;
    00186              nHeight = H_BOTTOM_BTN_C1;
    00187              break;
    00188         case SPACE_TYPE_C1:
    00189              nWidth = W_SPACE_C1 + 2 * BORDER_C1;
    00190              nHeight = H_BOTTOM_BTN_C1;
    00191              break;
    00192         case ESC_TYPE_C1:
    00193              nWidth = W_ESC_C1 + 2 * BORDER_C1;
    00194              nHeight = H_BOTTOM_BTN_C1;
    00195              break;
    00196       }
    00197     }
    00198
    00199     BitBlt(hDC, gptButtonPos[uKeyIndex].x, gptButtonPos[uKeyIndex].y,
    00200            nWidth, nHeight, hDC, gptButtonPos[uKeyIndex].x , gptButtonPos[uKeyIndex].y,
    00201            DSTINVERT);
    00202
    00203     return;
    00204 }

BOOL SKC1MouseMove | ( | HWND | hSKWnd,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) |

Definition at line 844 of file sftkbdc1.c.

References BOOL, FALSE, FLAG_DRAG_C1, FLAG_FOCUS_C1, FLAG_SHIFT_C1, GetCursorPos(), GetDC, GetWindowLongPtr(), _tagSKC1CTXT::hSoftkbd, _tagSKC1CTXT::ptSkCursor, _tagSKC1CTXT::ptSkOffset, ReleaseDC(), ScreenToClient(), SHIFT_TYPE_C1, SKC1_CONTEXT, SKC1DrawDragBorder(), SKC1InvertButton(), SKC1MousePosition(), TRUE, _tagSKC1CTXT::uKeyIndex, and _tagSKC1CTXT::uState.

Referenced by SKWndProcC1().

    00848 {
    00849     HGLOBAL   hSKC1Ctxt;
    00850     PSKC1CTXT pSKC1Ctxt;
    00851
    00852     UNREFERENCED_PARAMETER(wParam);
    00853     UNREFERENCED_PARAMETER(lParam);
    00854
    00855     // get and lock hSKC1Ctxt
    00856     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00857     if (!hSKC1Ctxt) {
    00858        return (FALSE);
    00859     }
    00860
    00861     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00862     if (!pSKC1Ctxt) {
    00863        return (FALSE);
    00864     }
    00865
    00866     if (pSKC1Ctxt->uState & FLAG_DRAG_C1) {
    00867        SKC1DrawDragBorder(hSKWnd, &pSKC1Ctxt->ptSkCursor,
    00868                           &pSKC1Ctxt->ptSkOffset);
    00869
    00870        GetCursorPos(&pSKC1Ctxt->ptSkCursor);
    00871
    00872        SKC1DrawDragBorder(hSKWnd, &pSKC1Ctxt->ptSkCursor,
    00873                           &pSKC1Ctxt->ptSkOffset);
    00874     } else if (pSKC1Ctxt->uKeyIndex != -1) {
    00875        HDC      hDC, hMemDC;
    00876        HBITMAP  hOldBmp;
    00877        POINT    ptSkOffset;
    00878        int      uKeyIndex;
    00879
    00880        GetCursorPos(&ptSkOffset);
    00881        ScreenToClient(hSKWnd, &ptSkOffset);
    00882        uKeyIndex = SKC1MousePosition(&ptSkOffset);
    00883
    00884        hDC = GetDC(hSKWnd);
    00885        hMemDC = CreateCompatibleDC(hDC);
    00886        hOldBmp = SelectObject(hMemDC, pSKC1Ctxt->hSoftkbd);
    00887
    00888        if (((pSKC1Ctxt->uState & FLAG_FOCUS_C1) && (uKeyIndex != pSKC1Ctxt->uKeyIndex)) ||
    00889            (!(pSKC1Ctxt->uState & FLAG_FOCUS_C1) && (uKeyIndex == pSKC1Ctxt->uKeyIndex))) {
    00890           if ((pSKC1Ctxt->uKeyIndex != SHIFT_TYPE_C1) ||
    00891               !(pSKC1Ctxt->uState & FLAG_SHIFT_C1)) {
    00892              SKC1InvertButton(hDC, pSKC1Ctxt->uKeyIndex);
    00893              SKC1InvertButton(hMemDC, pSKC1Ctxt->uKeyIndex);
    00894           }
    00895           pSKC1Ctxt->uState ^= FLAG_FOCUS_C1;
    00896        }
    00897
    00898        SelectObject(hMemDC, hOldBmp);
    00899        DeleteDC(hMemDC);
    00900        ReleaseDC(hSKWnd,hDC);
    00901     }
    00902
    00903     // unlock hSKC1Ctxt
    00904     GlobalUnlock(hSKC1Ctxt);
    00905
    00906     return (TRUE);
    00907 }

INT SKC1MousePosition | ( | LPPOINT | lpptCursor | ) |

Definition at line 679 of file sftkbdc1.c.

References CHECK_RECT, ENTER, gptButtonPos, H_LETTER_BTN_C1, ImmPtInRect(), INT, LETTER_NUM_C1, SHIFT, SPACE, and W_LETTER_BTN_C1.

Referenced by SKC1MouseMove(), and SKC1SetCursor().

    00681 {
    00682     int   i;
    00683
    00684     // letter buttons
    00685     for (i = 0; i < LETTER_NUM_C1; i++){
    00686
    00687        if (ImmPtInRect(gptButtonPos[i].x,
    00688                 gptButtonPos[i].y,
    00689                 W_LETTER_BTN_C1,
    00690                 H_LETTER_BTN_C1,
    00691                 lpptCursor)) {
    00692            return i;
    00693        }
    00694     }
    00695
    00696     CHECK_RECT(BACKSP);
    00697     CHECK_RECT(TAB);
    00698     CHECK_RECT(CAPS);
    00699     CHECK_RECT(ENTER);
    00700     CHECK_RECT(SHIFT);
    00701     CHECK_RECT(ESC);
    00702     CHECK_RECT(SPACE);
    00703     CHECK_RECT(INS);
    00704     CHECK_RECT(DEL);
    00705
    00706     return -1;
    00707 }

BOOL SKC1SetCursor | ( | HWND | hSKWnd,
|  | LPARAM | lParam
| ) |

Definition at line 783 of file sftkbdc1.c.

References BOOL, FALSE, FLAG_DRAG_C1, GetCursorPos(), GetWindowLongPtr(), NULL, _tagSKC1CTXT::ptSkCursor, _tagSKC1CTXT::ptSkOffset, ScreenToClient(), SetCursor, SKC1_CONTEXT, SKC1ButtonDown(), SKC1MousePosition(), TRUE, _tagSKC1CTXT::uKeyIndex, and _tagSKC1CTXT::uState.

Referenced by SKWndProcC1().

    00786 {
    00787     HGLOBAL   hSKC1Ctxt;
    00788     PSKC1CTXT pSKC1Ctxt;
    00789     POINT     ptSkCursor, ptSkOffset;
    00790     int       uKeyIndex;
    00791
    00792     // Get and lock hSKC1Ctxt
    00793     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00794     if (!hSKC1Ctxt) {
    00795         return (FALSE);
    00796     }
    00797
    00798     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00799     if (!pSKC1Ctxt) {
    00800         return (FALSE);
    00801     }
    00802
    00803     if (pSKC1Ctxt->uState & FLAG_DRAG_C1){
    00804         // in drag operation
    00805         SetCursor(LoadCursor(NULL, IDC_SIZEALL));
    00806         GlobalUnlock(hSKC1Ctxt);
    00807         return (TRUE);
    00808     }
    00809
    00810     GetCursorPos(&ptSkCursor);
    00811     ptSkOffset = ptSkCursor;
    00812     ScreenToClient(hSKWnd, &ptSkOffset);
    00813
    00814     uKeyIndex = SKC1MousePosition(&ptSkOffset);
    00815
    00816     if (uKeyIndex != -1) {
    00817        SetCursor(LoadCursor(NULL, IDC_HAND));
    00818     } else {
    00819        SetCursor(LoadCursor(NULL, IDC_SIZEALL));
    00820     }
    00821
    00822     if (HIWORD(lParam) != WM_LBUTTONDOWN){
    00823        // unlock hSKC1Ctxt
    00824        GlobalUnlock(hSKC1Ctxt);
    00825        return (TRUE);
    00826     }
    00827
    00828     pSKC1Ctxt->ptSkCursor = ptSkCursor;
    00829     pSKC1Ctxt->ptSkOffset = ptSkOffset;
    00830     pSKC1Ctxt->uKeyIndex = uKeyIndex;
    00831
    00832     SKC1ButtonDown(hSKWnd, pSKC1Ctxt);
    00833
    00834     // unlock hSKC1Ctxt
    00835     GlobalUnlock(hSKC1Ctxt);
    00836     return (TRUE);
    00837 }

LRESULT SKWndProcC1 | ( | HWND | hSKWnd,
|  | UINT | uMsg,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) |

Definition at line 1042 of file sftkbdc1.c.

References BeginPaint, CreateC1Window(), DefWindowProc(), DestroyC1Window(), FALSE, GetDC, GetWindowLongPtr(), GetWindowRect(), L, _tagSKC1CTXT::lfCharSet, LPSKC1CTXT, NULL, ReleaseDC(), SetWindowPos, ShowSKC1Window(), SKC1_CONTEXT, SKC1ButtonUp(), SKC1MouseMove(), SKC1SetCursor(), UINT, UpdateSKC1Window(), and _tagSKC1CTXT::uSubtype.

Referenced by RegisterSoftKeyboard().

    01047 {
    01048     LRESULT    lRet = 0L;
    01049
    01050     switch (uMsg) {
    01051        case WM_CREATE:
    01052             lRet = CreateC1Window(hSKWnd);
    01053             break;
    01054
    01055        case WM_DESTROY:
    01056             DestroyC1Window(hSKWnd);
    01057             break;
    01058
    01059        case WM_PAINT:
    01060             {
    01061                HDC         hDC;
    01062                PAINTSTRUCT ps;
    01063
    01064                hDC = BeginPaint(hSKWnd, &ps);
    01065                ShowSKC1Window(hDC, hSKWnd);
    01066                EndPaint(hSKWnd, &ps);
    01067             }
    01068             break;
    01069
    01070        case WM_MOUSEACTIVATE:
    01071             lRet = MA_NOACTIVATE;
    01072             break;
    01073
    01074        case WM_SETCURSOR:
    01075             if (!SKC1SetCursor(hSKWnd, lParam)) {
    01076                lRet = DefWindowProc(hSKWnd, uMsg, wParam, lParam);
    01077             }
    01078             break;
    01079
    01080        case WM_MOUSEMOVE:
    01081             if (!SKC1MouseMove(hSKWnd, wParam, lParam)) {
    01082                lRet = DefWindowProc(hSKWnd, uMsg, wParam, lParam);
    01083             }
    01084             break;
    01085
    01086        case WM_LBUTTONUP:
    01087             if (!SKC1ButtonUp(hSKWnd, wParam, lParam)) {
    01088                lRet = DefWindowProc(hSKWnd, uMsg, wParam, lParam);
    01089             }
    01090             break;
    01091
    01092        case WM_IME_CONTROL:
    01093             switch (wParam) {
    01094                case IMC_GETSOFTKBDFONT:
    01095                     {
    01096                        HDC        hDC;
    01097                        LOGFONT    lfFont;
    01098
    01099                        hDC = GetDC(hSKWnd);
    01100                        GetObject(GetStockObject(DEFAULT_GUI_FONT),
    01101                                  sizeof(lfFont), &lfFont);
    01102                        ReleaseDC(hSKWnd, hDC);
    01103                        *(LPLOGFONT)lParam = lfFont;
    01104                     }
    01105                     break;
    01106
    01107                case IMC_SETSOFTKBDFONT:
    01108                     {
    01109                        LOGFONT lfFont;
    01110
    01111                        GetObject(GetStockObject(DEFAULT_GUI_FONT),
    01112                            sizeof(lfFont), &lfFont);
    01113
    01114                        // in differet version of Windows
    01115                        if (lfFont.lfCharSet != ((LPLOGFONT)lParam)->lfCharSet) {
    01116                            HGLOBAL    hSKC1Ctxt;
    01117                            LPSKC1CTXT lpSKC1Ctxt;
    01118
    01119                            hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd,
    01120                                SKC1_CONTEXT);
    01121                            if (!hSKC1Ctxt) {
    01122                                return 1;
    01123                            }
    01124
    01125                            lpSKC1Ctxt = (LPSKC1CTXT)GlobalLock(hSKC1Ctxt);
    01126                            if (!lpSKC1Ctxt) {
    01127                                return 1;
    01128                            }
    01129
    01130                            lpSKC1Ctxt->lfCharSet =
    01131                                ((LPLOGFONT)lParam)->lfCharSet;
    01132
    01133                            GlobalUnlock(hSKC1Ctxt);
    01134                        }
    01135                     }
    01136                     break;
    01137
    01138                case IMC_GETSOFTKBDPOS:
    01139                     {
    01140                        RECT rcWnd;
    01141
    01142                        GetWindowRect(hSKWnd, &rcWnd);
    01143
    01144                        return MAKELRESULT(rcWnd.left, rcWnd.top);
    01145                     }
    01146                     break;
    01147
    01148                case IMC_SETSOFTKBDPOS:
    01149                     {
    01150                        SetWindowPos(hSKWnd, NULL,
    01151                             ((LPPOINTS)lParam)->x, ((LPPOINTS)lParam)->y,
    01152                             0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
    01153                        return (0);
    01154                     }
    01155                     break;
    01156
    01157                case IMC_SETSOFTKBDDATA:
    01158                     if (UpdateSKC1Window(hSKWnd, (LPSOFTKBDDATA)lParam)) {
    01159                        InvalidateRect(hSKWnd, NULL, FALSE);
    01160                     } else lRet = -1L;
    01161                     break;
    01162
    01163                case IMC_GETSOFTKBDSUBTYPE:
    01164                case IMC_SETSOFTKBDSUBTYPE:
    01165                     {
    01166                        HGLOBAL   hSKC1Ctxt;
    01167                        PSKC1CTXT pSKC1Ctxt;
    01168
    01169                        lRet = -1L;
    01170
    01171                        hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    01172                        if (!hSKC1Ctxt) break;
    01173
    01174                        pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    01175                        if (!pSKC1Ctxt) break;
    01176
    01177                        if (wParam == IMC_GETSOFTKBDSUBTYPE) {
    01178                           lRet = pSKC1Ctxt->uSubtype;
    01179                        } else {
    01180                           lRet = pSKC1Ctxt->uSubtype;
    01181                           pSKC1Ctxt->uSubtype = (UINT)lParam;
    01182                        }
    01183
    01184                        GlobalUnlock(hSKC1Ctxt);
    01185                     }
    01186                     break;
    01187             }
    01188             break;
    01189
    01190        default:
    01191             lRet = DefWindowProc(hSKWnd, uMsg, wParam, lParam);
    01192     }
    01193
    01194     return (lRet);
    01195 }

BOOL UpdateSKC1Window | ( | HWND | hSKWnd,
|  | LPSOFTKBDDATA | lpSoftKbdData
| ) |

Definition at line 489 of file sftkbdc1.c.

References BOOL, BYTE, FALSE, FLAG_SHIFT_C1, GetDC, GetWindowLongPtr(), gptButtonPos, _tagSKC1CTXT::hSoftkbd, LETTER_NUM_C1, _tagSKC1CTXT::lfCharSet, NULL, ReleaseDC(), SHIFT_TYPE_C1, SIZEFONT_C1, SKC1_CONTEXT, SKC1InvertButton(), SKC1VirtKey, TRUE, _tagSKC1CTXT::uState, _tagSKC1CTXT::wNonShiftCode, _tagSKC1CTXT::wShiftCode, X_NONSHIFT_CHAR_C1, X_SHIFT_CHAR_C1, Y_NONSHIFT_CHAR_C1, and Y_SHIFT_CHAR_C1.

Referenced by SKWndProcC1().

    00492 {
    00493     HGLOBAL   hSKC1Ctxt;
    00494     PSKC1CTXT pSKC1Ctxt;
    00495     LOGFONT   lfFont;
    00496     HFONT     hOldFont, hFont;
    00497     HDC       hDC, hMemDC;
    00498     HBITMAP   hOldBmp;
    00499     int       i;
    00500
    00501     // check the lpSoftKbdData
    00502     if (lpSoftKbdData->uCount!=2) return FALSE;
    00503
    00504     // Get and Lock hSKC1Ctxt
    00505     hSKC1Ctxt = (HGLOBAL)GetWindowLongPtr(hSKWnd, SKC1_CONTEXT);
    00506     if (!hSKC1Ctxt) return FALSE;
    00507
    00508     pSKC1Ctxt = (PSKC1CTXT)GlobalLock(hSKC1Ctxt);
    00509     if (!pSKC1Ctxt) return FALSE;
    00510
    00511     // create font
    00512     hDC = GetDC(hSKWnd);
    00513     hMemDC = CreateCompatibleDC(hDC);
    00514     hOldBmp = SelectObject(hMemDC, pSKC1Ctxt->hSoftkbd);
    00515
    00516     GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lfFont), &lfFont);
    00517     lfFont.lfHeight = -SIZEFONT_C1;
    00518     if (pSKC1Ctxt->lfCharSet != DEFAULT_CHARSET) {
    00519         lfFont.lfCharSet = (BYTE)pSKC1Ctxt->lfCharSet;
    00520     }
    00521
    00522     hFont = CreateFontIndirect(&lfFont);
    00523     hOldFont = SelectObject(hMemDC, hFont);
    00524
    00525
    00526     // update shift/non-shift chars
    00527     for (i=0; i < LETTER_NUM_C1; i++) {
    00528         pSKC1Ctxt->wNonShiftCode[i] = lpSoftKbdData->wCode[0][SKC1VirtKey[i]];
    00529         pSKC1Ctxt->wShiftCode[i] = lpSoftKbdData->wCode[1][SKC1VirtKey[i]];
    00530     }
    00531
    00532     SetBkColor(hMemDC, 0x00BFBFBF);  // set text bk color ??
    00533
    00534     for (i=0; i < LETTER_NUM_C1; i++) {
    00535         int  nchar;
    00536         RECT rc;
    00537
    00538         // draw shift char.
    00539         rc.left = gptButtonPos[i].x + X_SHIFT_CHAR_C1;
    00540         rc.top = gptButtonPos[i].y + Y_SHIFT_CHAR_C1;
    00541         rc.right = rc.left + SIZEFONT_C1;
    00542         rc.bottom = rc.top + SIZEFONT_C1;
    00543
    00544         nchar = (pSKC1Ctxt->wShiftCode[i] == 0) ? 0 : 1;
    00545
    00546 #if (WINVER >= 0x0400)
    00547         DrawTextEx(hMemDC, (LPWSTR)&pSKC1Ctxt->wShiftCode[i],
    00548                    nchar, &rc, DT_CENTER, NULL);
    00549 #else
    00550         ExtTextOut(hMemDC,
    00551             rc.left,
    00552             rc.top,
    00553             ETO_OPAQUE, &rc,
    00554             (LPWSTR)&pSKC1Ctxt->wShiftCode[i], nchar, NULL);
    00555 #endif
    00556
    00557         // draw non-shift char.
    00558         rc.left = gptButtonPos[i].x + X_NONSHIFT_CHAR_C1;
    00559         rc.top = gptButtonPos[i].y + Y_NONSHIFT_CHAR_C1;
    00560         rc.right = rc.left + SIZEFONT_C1;
    00561         rc.bottom = rc.top + SIZEFONT_C1;
    00562
    00563         nchar = (pSKC1Ctxt->wNonShiftCode[i] == 0) ? 0 : 1;
    00564
    00565 #if (WINVER >= 0x0400)
    00566         DrawTextEx(hMemDC, (LPWSTR)&pSKC1Ctxt->wNonShiftCode[i],
    00567                    nchar, &rc, DT_CENTER, NULL);
    00568 #else
    00569         ExtTextOut(hMemDC,
    00570             rc.left,
    00571             rc.top,
    00572             ETO_OPAQUE, &rc,
    00573             (LPWSTR)&pSKC1Ctxt->wNonShiftCode[i], nchar, NULL);
    00574 #endif
    00575     }
    00576
    00577     // init states
    00578     if (pSKC1Ctxt->uState & FLAG_SHIFT_C1){
    00579        SKC1InvertButton(hMemDC, SHIFT_TYPE_C1);
    00580     }
    00581     pSKC1Ctxt->uState = 0;
    00582
    00583     SelectObject(hMemDC, hOldBmp);
    00584     SelectObject(hMemDC, hOldFont);
    00585     DeleteDC(hMemDC);
    00586
    00587     DeleteObject(hFont);
    00588     ReleaseDC(hSKWnd,hDC);
    00589
    00590     // Unlock hSKC1Ctxt
    00591     GlobalUnlock(hSKC1Ctxt);
    00592
    00593     return TRUE;
    00594 }

## Variable Documentation

BOOL gfSoftKbdC1Init = FALSE

| Definition at line 27 of file sftkbdc1.c. Referenced by CreateC1Window().

POINT gptButtonPos[BUTTON_NUM_C1]

| Definition at line 26 of file sftkbdc1.c. Referenced by InitSKC1Bitmap(), InitSKC1ButtonPos(), SKC1DrawLabel(), SKC1InvertButton(), SKC1MousePosition(), and UpdateSKC1Window().

CONST BYTE SKC1VirtKey[BUTTON_NUM_C1]

Initial value:

     {
       VK_OEM_3, '1', '2', '3', '4', '5', '6','7', '8', '9', '0', VK_OEM_MINUS, VK_OEM_EQUAL,
       'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', VK_OEM_LBRACKET, VK_OEM_RBRACKET, VK_OEM_BSLASH,
       'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', VK_OEM_SEMICLN, VK_OEM_QUOTE,
       'Z', 'X', 'C', 'V', 'B', 'N', 'M', VK_OEM_COMMA, VK_OEM_PERIOD, VK_OEM_SLASH,
       VK_BACK, VK_TAB, VK_CAPITAL, VK_RETURN, VK_SHIFT, VK_INSERT, VK_DELETE, VK_SPACE,
       VK_ESCAPE
    }

Definition at line 17 of file sftkbdc1.c.

Referenced by SKC1ButtonUp(), and UpdateSKC1Window().