示例#1
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_usermConnect(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);

    if (mp1!=NULL)
        {
        int i;

        for (i=0;i<hia->notifListAllocSize;i++)
            if (hia->notifList[i].hwnd == (HWND)mp1)
                {
                HIA_NotifyToConnected(hia,HIAN_CONNECT,MPFROMLONG(FALSE));
                hia->responseTo = &(hia->notifList[i]);
                HIA_NotifyToConnected(hia,HIAN_CONNECT,MPFROMLONG(TRUE));
                return MRFROMLONG(TRUE);
                }
        return MRFROMLONG(FALSE);

        } else {

        if (hia->responseTo != &(hia->notifList[0]))
            {
            HIA_NotifyToConnected(hia,HIAN_CONNECT,MPFROMLONG(FALSE));
            hia->responseTo = &(hia->notifList[0]);
            HIA_NotifyToConnected(hia,HIAN_CONNECT,MPFROMLONG(TRUE));
            }
        }

    return MRFROMLONG(TRUE);
}
示例#2
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_usermCompleteHch(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
HANCHAR hch;

//  printf("HIAM_COMPLETEHCH\n");

    if (hia->inbuf->newpos == HIABUF_NONE) return 0L;
    hch = HIABufPeekHch(hia->inbuf);
    HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(hch,0));
    HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(hch,0));
    HIABufClear(hia->inbuf);

    return MRFROM2SHORT(hch,0);
}
示例#3
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_usermCancelKey(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
HANCHAR hch;

//  printf("HIAM_CANCELKEY\n");

    HIABufPop(hia->inbuf);
    hch = HIABufPeekHch(hia->inbuf);
    if (hia->inbuf->newpos)
        HIA_NotifyToConnected(hia,HIAN_COMPO_STEPBACK,
            MPFROM2SHORT(0,hch));
        else
        HIA_NotifyToConnected(hia,HIAN_COMPO_CANCEL,0);
    return MRFROM2SHORT(hch,0);
}
示例#4
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_usermCancelBuf(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
ULONG   temp;

//  printf("HIAM_CANCELBUF\n");

    temp = hia->inbuf->newpos;
    HIABufClear(hia->inbuf);
    HIA_NotifyToConnected(hia,HIAN_COMPO_CANCEL,0);
    return MRFROMLONG(temp);
}
示例#5
0
MRESULT hia_wmControl(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
    HIA     *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
    USHORT  id = SHORT1FROMMP( mp1 );
    USHORT  notifyCode = SHORT2FROMMP( mp1 );

    switch( id )
    {
        case IDHCHLB_HANJASEL :
        case IDHCHLB_SPECIALCHARSEL :
        {
            SHORT index = SHORT1FROMMP( mp2 );

            if( notifyCode == HCHLN_ENTER )
            {
                if( index != HCHLIT_NONE )
                {
                    HANCHAR hch = SHORT1FROMMR( WinSendMsg( hia->hwndHCHLB, HCHLM_QUERYHCH,
                                                MPFROMSHORT( index ), 0 ));

                    if( id == IDHCHLB_HANJASEL )
                        WinSendMsg( hwnd, HIAM_CANCELBUF, 0, 0 );
                    else
                        hia->scselIndex = index;

                    HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(hch,0));
                    HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(hch,0));
                }
                else if( id == IDHCHLB_HANJASEL )
                    WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

                hia_destroyHCHLB( hia );
            }
            break;
        }
    }

    return 0;
}
示例#6
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_wmChar(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
USHORT  fsFlags = SHORT1FROMMP(mp1);
UCHAR   ucVkey  = CHAR3FROMMP(mp2);
UCHAR   ucChar  = CHAR1FROMMP(mp2);
UCHAR   ucScancode = CHAR4FROMMP(mp1);

HIA     *hia    = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);

USHORT ckey;

//  printf("HIA:: WM_CHAR\n");

    if (fsFlags & KC_KEYUP) return 0L;

    if( hia->isHanjaKey != NULL )
    {
        if( hia->isHanjaKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            if( hia->inbuf->newpos != HIABUF_NONE )
            {
                HANCHAR hch = SHORT1FROMMR( WinSendMsg( hwnd, HIAM_QUERYWORKINGHCH, 0, 0 ));
                HANCHAR hj;

                hj = hjselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, hch );
                if( hj != HCH_SINGLE_SPACE )
                    hch = hj;

                WinSendMsg( hwnd, HIAM_CANCELBUF, 0, 0 );
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(hch));

                //WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
                //HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, MPFROMLONG( TRUE ));
            }
            else
                HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, 0);

            return MRFROMLONG( TRUE );
        }
    }

    if( hia->isSpecialCharKey != NULL )
    {
        if( hia->isSpecialCharKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            SCSELINFO scselInfo = { -1, -1, -1 };

            WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

            scselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, &scselInfo );
            if( scselInfo.hch != HCH_SINGLE_SPACE )
            {
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(scselInfo.hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(scselInfo.hch));
            }

            return MRFROMLONG( TRUE );
        }
    }

    if (fsFlags & KC_VIRTUALKEY)
        {
        switch (ucVkey) {
        case VK_SPACE:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_SHIFTONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEHANMODE,0L,0L);
            else if (FKC_CTRLONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEKBDTYPE,0L,0L);
            else if (FKC_NONE(fsFlags))
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(' ',0));
            return MRFROMLONG(TRUE);    // consumed
            break;
        case VK_TAB:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT('\t',0));
                return MPFROMLONG(TRUE);    // consumed
                } else {
                return MPFROMLONG(FALSE);
                }
            break;
        case VK_HOME:
        case VK_END:
        case VK_LEFT:
        case VK_UP:
        case VK_DOWN:
        case VK_PAGEUP:
        case VK_PAGEDOWN:
        case VK_PAGEDOWN + 0x90:
        case VK_DELETE:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;  // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);
            break;
        case VK_ENTER:
        case VK_NEWLINE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);   // not consumed
            break;
        case VK_RIGHT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);   // NOT consumed
                }
            break;
        case VK_BACKSPACE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_CANCELKEY,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_INSERT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                WinSendMsg(hwnd,HIAM_CHANGEINSERTMODE,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_ESC :
            WinSendMsg(hwnd,HIAM_CANCELBUF,0L,0L);

            return FALSE;

        case VK_SHIFT :
        case VK_CTRL :
        case VK_ALT :
            return FALSE;
        }   // switch

        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

        return FALSE;
        } // Virtualkey

    if(( fsFlags & ( KC_CTRL | KC_ALT )) || (ucChar < 32) || (ucChar > 127))
    {
        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
        return FALSE;
    }

    if (hia->hanmode == HCH_ENG)
        {
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    if ((hia_iskeypadkey(ucScancode))&&(fsFlags & KC_CHAR))
        {
        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    ucChar = hia_transkey( fsFlags, ucScancode, ucChar );

    if (WinGetKeyState(HWND_DESKTOP,VK_CAPSLOCK))
        {
        if (fsFlags & KC_SHIFT)
            {
            ucChar = toupper(ucChar);
            } else {
            ucChar = tolower(ucChar);
            }
        }
    ckey = hia_convertkey(hia->kbdtype,ucChar);
    {
    HANCHAR completedHch;
    HANCHAR workingHch;
    if (ckey & 0x80)    // if hangul key
        {
        ULONG oldbufState = hia->inbuf->newpos;
        if (hia->kbdtype == HAN_KBD_2)
            completedHch = HIAAutomata2(hia,ckey);
            else
            completedHch = HIAAutomata3(hia,ckey);
        workingHch = SHORT1FROMMR(WinSendMsg(hwnd,HIAM_QUERYWORKINGHCH,0L,0L));

        if (completedHch)       // if hch completed
            {
            HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(completedHch,workingHch));
            HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(completedHch,workingHch));
            if (workingHch)     // begin composition of new hch
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,MPFROM2SHORT(completedHch,workingHch));

            } else {    // if hch not completed

            if (workingHch)     // if exist composing hch
            if (oldbufState)
                HIA_NotifyToConnected(hia,HIAN_COMPO_STEP,
                    MPFROM2SHORT(0,workingHch));
                else
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,
                    MPFROM2SHORT(0,workingHch));
            }

        return MRFROMLONG(TRUE);    // consumed

        } else {  // !@#$%^&*() ,etc

        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,
            MPFROM2SHORT(ckey,0));
        return MRFROMLONG(TRUE);    // consumed

        }
        }
    return MRFROMLONG(FALSE);    // not consumed
}