⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 medit.c

📁 TN-kernel内核针对LPC系列ARM7处理器和S3C44B0X重新定制好的源代码包。内含Nano-X GUI。
💻 C
📖 第 1 页 / 共 5 页
字号:
            pMLEditData->passwdChar     = '*';
            pMLEditData->leftMargin     = MARGIN_MEDIT_LEFT;
            pMLEditData->topMargin      = MARGIN_MEDIT_TOP;
            pMLEditData->rightMargin    = MARGIN_MEDIT_RIGHT;
            pMLEditData->bottomMargin   = MARGIN_MEDIT_BOTTOM;

            pMLEditData->hardLimit      = -1;

            /* undo information */
            pMLEditData->lastOp         = MEDIT_OP_NONE;
            pMLEditData->lastPos        = 0;
            pMLEditData->affectedLen    = 0;
            pMLEditData->undoBufferLen  = LEN_MLEDIT_UNDOBUFFER;
            pMLEditData->undoBuffer [0] = '\0';
                        SetWindowAdditionalData2(hWnd,(DWORD)pMLEditData);
                        SetWindowAdditionalData(hWnd,(DWORD)0);
            break;
        }
        case WM_DESTROY:
        {
                PLINEDATA temp;
                pMLEditData =(PMLEDITDATA) GetWindowAdditionalData2(hWnd);
                    DestroyCaret ();
                pLineData = pMLEditData->head;
                while(pLineData)
                {
                        /*printf("delete lineNO = %d,buffer=%s\n",pLineData->lineNO,pLineData->buffer);*/
                        temp = pLineData->next;
                        free(pLineData);
                        pLineData = temp;
                }
                    free(pMLEditData);
        }
        break;

        case WM_SETFONT:
        break;

        case WM_GETFONT:
        break;

#if 0        /* fix: no WM_SETCURSOR */
        case WM_SETCURSOR:
            if (dwStyle & WS_DISABLED) {
                SetCursor (GetSystemCursor (IDC_ARROW));
                return 0;
            }
        break;

           case WM_SIZECHANGED:
        {
        }
        return 0;
#endif
        case WM_KILLFOCUS:
        {
            dw= GetWindowAdditionalData(hWnd);
            dw&= ~EST_FOCUSED;
            SetWindowAdditionalData(hWnd,dw);

            HideCaret (hWnd);
            DestroyCaret ();

            SendMessage (GetParent (hWnd),
                         WM_COMMAND,
                         (WPARAM) MAKELONG (GetDlgCtrlID(hWnd), EN_KILLFOCUS),
                         (LPARAM)hWnd);
        }
        break;

        case WM_SETFOCUS:
                {
                        dw= GetWindowAdditionalData(hWnd);
            if (dw & EST_FOCUSED)
                return 0;

            dw |= EST_FOCUSED;
                        SetWindowAdditionalData(hWnd,dw);

            pMLEditData =(PMLEDITDATA) GetWindowAdditionalData2(hWnd);

            /* only implemented for ES_LEFT align format. */

            CreateCaret (hWnd, NULL, 1, /*GetSysCharWidth(hWnd)+1,*/
                    hWnd->clirect.bottom-hWnd->clirect.top-2);
            SetCaretPos (pMLEditData->caretPos * GetSysCharWidth (hWnd)
                    + pMLEditData->leftMargin, pMLEditData->topMargin);
            ShowCaret(hWnd);

            SendMessage (GetParent (hWnd),
                         WM_COMMAND,
                         (WPARAM) MAKELONG (GetDlgCtrlID(hWnd), EN_SETFOCUS),
                         (LPARAM) hWnd);
                }
        break;

        case WM_ENABLE:
            if ( (!(dwStyle & WS_DISABLED) && !wParam)
                    || ((dwStyle & WS_DISABLED) && wParam) ) {
                if (wParam)
                        ExcludeWindowStyle(hWnd,WS_DISABLED);
                else
                        IncludeWindowStyle(hWnd,WS_DISABLED);

                InvalidateRect (hWnd, NULL, FALSE);
            }
        return 0;

        case WM_NCPAINT:
        {
            RECT rc;
#if 0
            if (wParam)
                hdc = (HDC)wParam;
            else
                hdc = GetDC (hWnd);
#if 0        /* fix: no ClipRectIntersect() */
            if (lParam)
            ClipRectIntersect (hdc, (RECT*)lParam);
#endif
#else
            hdc = wParam? (HDC)wParam: GetWindowDC (hWnd);
            GetWindowRect(hWnd, &rc);
#endif
            if (dwStyle & WS_BORDER)
            {
#if 0
                RECT rc;
                GetWindowRect(hWnd,&rc);
                Draw3DDownFrame (hdc, 0, 0,
                                      rc.right - rc.left - 1,
                                      rc.bottom - rc.top - 1,
                                      PIXEL_invalid);
#else
                Draw3dInset(hdc, rc.left, rc.top,
                        rc.right-rc.left, rc.bottom-rc.top);
#endif
            }
            if (!wParam) {
                ReleaseDC(hWnd,hdc);
                }
        }
        return 0;

        case WM_PAINT:
        {
            int     dispLen,i;
            char*   dispBuffer;
            RECT    rect,rc;
            PAINTSTRUCT ps;
#ifdef USE_BIG5
            HGDIOBJ oldfont=NULL;
#endif

            hdc = BeginPaint (hWnd,&ps);
            GetClientRect (hWnd, &rect);

            if (dwStyle & WS_DISABLED)
            {
                rc.left=0; rc.top=0; rc.bottom=rect.bottom; rc.right=rect.right;
                FillRect(hdc,&rc,GetStockObject(LTGRAY_BRUSH));
                SetBkColor (hdc, LTGRAY/*PIXEL_lightgray*/);
            }
            else {
                rc.left=0; rc.top=0; rc.bottom=rect.bottom; rc.right=rect.right;
                FillRect(hdc,&rc,GetStockObject(WHITE_BRUSH));
                SetBkColor (hdc, WHITE/*PIXEL_lightwhite*/);
            }

            SetTextColor (hdc, BLACK/*PIXEL_black*/);

            pMLEditData =(PMLEDITDATA) GetWindowAdditionalData2(hWnd);
                        for(i = pMLEditData->StartlineDisp; i <= pMLEditData->EndlineDisp; i++)
                        {
                                pLineData= GetLineData(pMLEditData,i);
                    dispLen = edtGetDispLen (hWnd,pLineData);
                     if (dispLen == 0 && pMLEditData->EndlineDisp >= pMLEditData->lines) {
                        continue;
                            }

#ifdef _DEBUG
                           if (pMLEditData->dispPos > pLineData->dataEnd)
                        fprintf (stderr, "ASSERT failure: %s.\n", "Edit Paint");
#endif

                dispBuffer = alloca (LEN_MLEDIT_BUFFER+1);

                if (dwStyle & ES_PASSWORD)
                    memset (dispBuffer, '*', pLineData->dataEnd);
                                    memcpy (dispBuffer,
                               pLineData->buffer,        /* +pMLEditData->dispPos, */
                                                pLineData->dataEnd);        /* - pMLEditData->dispPos); */
                               dispBuffer[pLineData->dataEnd] = '\0';

            /* only implemented ES_LEFT align format for single line edit. */
                rect.left = pMLEditData->leftMargin;
                rect.top = pMLEditData->topMargin ;
                rect.right = pMLEditData->rightMargin;
                rect.bottom = pMLEditData->bottomMargin;
#if 0
                printf("lineNO=%d,lines=%d,editLine=%d\n",pLineData->lineNO,pMLEditData->lines,
                        pMLEditData->editLine);
                printf("--dispBuffer=%s--\n",dispBuffer);
                ClipRectIntersect (hdc, &rect);        /* fix: no ClipRectIntersect() */
#endif

#ifdef USE_BIG5
            oldfont=SelectObject(hdc,CreateFont(12,
                        0,0,0,0,0,0,0,0,0,0,0,
                        FF_DONTCARE|DEFAULT_PITCH,
                        "HZXFONT"));
#endif
                TextOut (hdc,
                                pMLEditData->leftMargin - pMLEditData->dispPos * GetSysCharWidth(hWnd) ,
                                GetSysCharHeight(hWnd)*(pLineData->lineNO - pMLEditData->StartlineDisp)
                                        + pMLEditData->topMargin,
                                dispBuffer,-1);
                        }
#ifdef USE_BIG5
                DeleteObject(SelectObject(hdc,oldfont));
#endif
            EndPaint (hWnd, &ps);
        }
        break;

        case WM_KEYDOWN:
        {
            BOOL    bChange = FALSE;
            int     i;
            int     deleted;
                        PLINEDATA temp = NULL;
                        char *  tempP = NULL;

            pMLEditData =(PMLEDITDATA) GetWindowAdditionalData2(hWnd);

            switch (LOWORD (wParam))
            {

                case VK_RETURN:         /* SCANCODE_ENTER: */
                                {
                                        pLineData = GetLineData(pMLEditData,pMLEditData->editLine);
                                        if (pMLEditData->editPos < pLineData->dataEnd)
                                                tempP = pLineData->buffer + pMLEditData->editPos;
                                    temp = pLineData->next;
                                        pLineData->next = GdMalloc( sizeof(LINEDATA) );
                                        pLineData->next->previous = pLineData;
                                        pLineData->next->next = temp;
                                        if(temp)
                                        {
                                                temp->previous = pLineData->next;
                                        }
                                        temp = pLineData->next;
                                        temp->lineNO  = pMLEditData->editLine + 1;
                                        if(tempP)
                                        {
                                                memcpy(temp->buffer,tempP,strlen(tempP));
                                                temp->dataEnd = strlen(tempP);
                                        }
                                        else
                                                temp->dataEnd = 0;
                                        temp->buffer[temp->dataEnd] = '\0';
                                        pLineData->dataEnd = pMLEditData->editPos;
                                        pLineData->buffer[pLineData->dataEnd]='\0';
                                        temp = temp->next;
                                        while (temp)
                                        {
                                                temp->lineNO++;
                                                temp = temp->next;
                                        }
                                        pMLEditData->editPos = 0;
                                        pMLEditData->caretPos= 0;
                                        pMLEditData->dispPos = 0;
                                        if(pMLEditData->linesDisp < pMLEditData->MaxlinesDisp)
                                        {
                                                pMLEditData->EndlineDisp++;
                                                pMLEditData->linesDisp++;
                                        }
                                        else if(pMLEditData->editLine == pMLEditData->EndlineDisp)
                                        {
                                                pMLEditData->StartlineDisp++;
                                                pMLEditData->EndlineDisp++;
                                        }
                                        pMLEditData->editLine++;
                                        pMLEditData->lines++;
                    SetCaretPos (pMLEditData->caretPos * GetSysCharWidth (hWnd)
                            + pMLEditData->leftMargin,
                        (pMLEditData->editLine - pMLEditData->StartlineDisp) * GetSysCharHeight(hWnd)
                                                        +pMLEditData->topMargin);
                        InvalidateRect (hWnd, NULL, FALSE);
                        return 0;
                                }
                case VK_HOME:         /* SCANCODE_HOME: */
                                {
                                        PLINEDATA temp;
                    if (pMLEditData->editPos == 0)
                        return 0;

                    pMLEditData->editPos  = 0;
                    pMLEditData->caretPos = 0;

                    SetCaretPos (pMLEditData->leftMargin,
                        (pMLEditData->editLine-pMLEditData->StartlineDisp) * GetSysCharHeight(hWnd)
                                                        +pMLEditData->topMargin);
                                        temp = GetLineData(pMLEditData,pMLEditData->editLine);
                    if (pMLEditData->dispPos != 0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -