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

📄 combobox.c

📁 TN-kernel内核针对LPC系列ARM7处理器和S3C44B0X重新定制好的源代码包。内含Nano-X GUI。
💻 C
📖 第 1 页 / 共 5 页
字号:


static void
CBoxDrawButton(HWND hWnd,UINT wState,COMBOBOX *lp)
{
    HDC       hDC;
    int     x,y;
    int     dx,dy;
#if 0        /* jmt: fix: no LoadBitmap() */
    int     cx,cy;
    static int nWidth,nHeight;
    BITMAP    bmpCombo;
    static HBITMAP hbmpCombo = 0;
    HBITMAP   hbmpOld = 0;
    HDC       hdcSrc;
    COLORREF  rgbText, rgbBk;
#endif
    HBRUSH    hBrush;
    HPEN      hPenHigh,hPenShadow;
    RECT      rc;

    hDC = GetDC(hWnd);

    CopyRect(&rc,&lp->ButtonRect);
    x = rc.left;
    y = rc.top;
    dx = rc.right;
    dy = rc.bottom;

    hPenHigh = GetStockObject(WHITE_PEN);
#if 0
    hPenShadow = GetSysColorPen(COLOR_BTNSHADOW);
#else
    hPenShadow = CreatePen(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
#endif
#if 0
    hBrush = GetSysColorBrush(COLOR_BTNFACE);
#else
    hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
#endif
    FillRect(hDC, &rc, hBrush);
#if 0
    hBrush = GetStockObject(BLACK_BRUSH);
    FillRect/*FrameRect*/(hDC, &lp->ButtonRect, hBrush);
#else
    SelectObject(hDC,GetStockObject(BLACK_PEN));
    Rectangle(hDC,lp->ButtonRect.left,lp->ButtonRect.top,lp->ButtonRect.right,lp->ButtonRect.bottom);
#endif
    rc.left += 1; rc.right -= 1;
    rc.top += 1; rc.bottom -= 1;

    Draw3DButtonRect(hDC,hPenHigh,hPenShadow,rc,wState);

#if 0        /* jmt: fix: no LoadBitmap(),GetObject() */
    if (hbmpCombo == 0)
       {
       hbmpCombo = LoadBitmap(0,(LPSTR)OBM_COMBO);
       GetObject(hbmpCombo, sizeof(BITMAP), (LPVOID)&bmpCombo);
       nWidth  = bmpCombo.bmWidth;
       nHeight = bmpCombo.bmHeight;
       }
   /*
   **   MiD 08/15/95 changed to mono bitmap as it is in Windows. Convert
   **                it to colors on the fly
   */
   hdcSrc = CreateCompatibleDC(hDC);
   hbmpOld = SelectObject(hdcSrc, hbmpCombo);
   /*
   **   Source hdc ok. Prepare the target hdc, then BitBlt to it.
   */
   rgbText = SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
   rgbBk = SetBkColor(hDC,GetSysColor(COLOR_BTNFACE));

   cx = (dx - x - nWidth)/2;
   cy = (dy - y - nHeight)/2;
   if (wState)
      {  cx++; cy++;  }
   BitBlt(hDC, x+cx, y+cy, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);

   SetTextColor(hDC, rgbText);
   SetBkColor(hDC, rgbBk);
   SelectObject(hdcSrc,hbmpOld);
   DeleteDC(hdcSrc);
#endif        /* BitBlt Bitmap */
#if 1
   DeleteObject(hBrush);
   DeleteObject(hPenShadow);
#endif
   ReleaseDC(hWnd,hDC);

    if (wState)
        SET_STATE(lp,CSF_LOCALBUTTONDOWN);
    else
        CLEAR_STATE(lp,CSF_LOCALBUTTONDOWN);
}

#if 0        /* jmt: fix: no COMBOLBOX */
/* **********************************************************************
**
************************************************************************/
LRESULT DefCOMBOLBOXProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#if 0
    return DefLISTBOXProc(hWnd, msg, wParam,lParam);
#endif
    return ListboxCtrlProc(hWnd, msg, wParam,lParam);
}
#endif

/* **********************************************************************
**
************************************************************************/
static void CBoxSendMouseToLBox(COMBOBOX *lp, UINT uiMsg, WPARAM wParam, POINT ptScreen)
{
    POINT pt;
    int nNCHit;
#if 0        /* jmt: fix: no scrollbar */
    HWND hWndScroll;
#endif
    pt = ptScreen;
    ScreenToClient(lp->ListBoxControl,&pt);

    nNCHit = LOSHORT(SendMessage(lp->ListBoxControl, WM_NCHITTEST, 0, MAKELPARAM(ptScreen.x,ptScreen.y)));

    switch (nNCHit)
       {
       case HTCLIENT:
           if (uiMsg == WM_MOUSEMOVE && !IS_SET(lp,CSF_LBOXBUTTONDOWN))
              {
              SendMessage(lp->ListBoxControl, WM_LBUTTONDOWN, 0, MAKELONG((WORD)pt.x,(WORD)pt.y));

              SET_STATE(lp, CSF_BUTTONDOWN | CSF_LBOXBUTTONDOWN);
              }
           SendMessage(lp->ListBoxControl, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
           break;

#if 0        /* jmt: fix: no scrollbar */
       case HTVSCROLL:
           if (0 != (hWndScroll = TWIN_ConvertToSysScroll(lp->ListBoxControl, TRUE /* vertical */, &pt)))
              SendMessage(hWndScroll, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
           break;
#endif
       default:
           break;
    }
}

/* **********************************************************************
**
************************************************************************/
static void CBoxCapture(HWND hWnd, WORD wFunc)
{
    static HWND hWndCapture = (HWND)0;

    if (wFunc)
       {
       hWndCapture = SetCapture(hWnd);

       SetFocus(hWnd);
       }
    else {
         if (!hWndCapture)
            ReleaseCapture();
         else {
#ifdef  LATER
              SetCapture(hWndCapture);
#else
              ReleaseCapture();
#endif
              hWndCapture = (HWND)0;
              }
         }
}

/* **********************************************************************
**
************************************************************************/
static void CBoxDrawEdit(COMBOBOX *lp, HWND hWnd, UINT uiKey)
{
    int    nLen;
    LPVOID lpData;
#if 0        /* jmt: fix: no ownerdraw */
    HRGN   hRgn;
    DRAWITEMSTRUCT dis;
#endif
/*
    if (uiKey == (UINT)LB_ERR)
       return;

    if (!BOWNERDRAW(lp))
*/
    if (lp->wStyle & CBS_HASSTRINGS)
       {
       if (uiKey == (UINT)LB_ERR)
          return;
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, uiKey, 0L);
       if (nLen <= 0)
           return;
       lpData = (LPVOID)GdMalloc(nLen+1);
       SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
       SendMessage(lp->EditControl, WM_SETTEXT, strlen(lpData), (LPARAM)lpData);
       Edit_SetSel(lp->EditControl, 0, -1);
       WinFree((LPSTR)lpData);
       }
#if 0        /* jmt: fix: no ownerdraw */
    else {
         dis.CtlType = ODT_COMBOBOX;
         dis.CtlID = (UINT)lp->nID;
         dis.itemID = -1; /* used to be uiKey */
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemState = ODS_FOCUS;
         dis.hwndItem = hWnd;
         dis.itemData = 0;
         GetClientRect(lp->EditControl,&dis.rcItem);
         dis.rcItem.left += 3;
         dis.rcItem.right -= 3;
         dis.rcItem.top += 2;
         dis.rcItem.bottom -= 2;

         dis.hDC = GetDC(lp->EditControl);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         SelectClipRgn(dis.hDC,hRgn);
         SelectObject(dis.hDC, lp->hFont);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         ReleaseDC(lp->EditControl,dis.hDC);
         DeleteObject(hRgn);
         }
#endif        /* ownerdraw */
}

/* **********************************************************************
**
************************************************************************/
static void CBoxDrawStatic(COMBOBOX *lp, HWND hWnd, UINT uiKey)
{
    int    nLen;
    HDC    hdc;
    LPVOID lpData;
    RECT   rcClient;
    HFONT  hfonOld = 0;
#if 0        /* jmt: fix: no ownerdraw */
    HRGN   hRgn;
    DRAWITEMSTRUCT dis;
#endif
    HBRUSH hbrStatic, hbrOld;

    /*   Draw rectangle regardless of ownerdraw style...
    */
    hdc = GetDC(hWnd);
    rcClient.left   = 0;
    rcClient.top    = 0;
    rcClient.right  = lp->ButtonRect.left+1;
    rcClient.bottom = lp->uHeight;
    hbrStatic = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
    hbrOld = SelectObject(hdc, hbrStatic);
    SelectObject(hdc, GetStockObject(BLACK_PEN));/* ??? COLOR_WINDOWFRAME */
    Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    SelectObject(hdc, hbrOld);
    DeleteObject(hbrStatic);
    ReleaseDC(hWnd, hdc);

    if (uiKey == (UINT)LB_ERR)
       return;

/* jmt: no ownerdraw */
    if (1)        /* (!BOWNERDRAW(lp)) */
       {
       /* if necessary, draw text */
       hdc = GetDC(hWnd);
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, (WPARAM)uiKey, 0L);
       if (nLen > 0)
          {
          lpData = (LPVOID)GdMalloc(nLen+1);
          SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
          SetBkMode(hdc, TRANSPARENT);
          if (!IS_SET(lp, CSF_FOCUS))
             {
             SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
             rcClient.left += 2;
             }
          else {
               InflateRect(&rcClient, -2, -2);
               hbrStatic = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
               hbrOld = SelectObject(hdc, hbrStatic);
               FillRect(hdc, &rcClient, hbrStatic);
#if 0        /* jmt: fix: no DrawFocusRect() */
               DrawFocusRect(hdc, &rcClient);
#endif
               SelectObject(hdc, hbrOld);
               DeleteObject(hbrStatic);
               SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
               }
          if (lp->hFont)
             hfonOld = SelectObject(hdc, lp->hFont);
          DrawText(hdc, (LPSTR)lpData, nLen, &rcClient, DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
          if (lp->hFont)
             SelectObject(hdc, hfonOld);
          WinFree((LPVOID)lpData);
          }
       ReleaseDC(hWnd, hdc);
       }
#if 0        /* jmt: fix: no ownerdraw */
    else { /* fill OWNERDRAWSTRUCT and send WM_DRAWITEM message */
         dis.CtlType    = ODT_COMBOBOX;
         dis.CtlID      = (UINT)lp->nID;
         dis.itemID     = uiKey;
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemState  = ODS_FOCUS;
         dis.hwndItem   = hWnd;
         dis.itemData   = SendMessage(lp->ListBoxControl, LB_GETITEMDATA, uiKey, 0L);
         GetClientRect(hWnd, &dis.rcItem);
         dis.rcItem.left += 3;
         dis.rcItem.right = lp->ButtonRect.left - 2;  /* do not touch button */
         dis.rcItem.top += 2;
         dis.rcItem.bottom -= 2;

         dis.hDC = GetDC(hWnd);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         SelectClipRgn(dis.hDC, hRgn);
         SelectObject(dis.hDC, lp->hFont);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         ReleaseDC(hWnd, dis.hDC);
         DeleteObject(hRgn);
         }
#endif        /* ownerdraw */

}


/*------------------------- < Full Revision History > ----------------------
** Revision 1.2  2001/11/06 23:35:46  greg
**
** Revision 1.1.1.1  2001/06/21 06:32:42  greg
** Microwindows pre8 with patches
**
** Revision 1.1.1.1  2001/06/05 03:44:01  root
** First import of 5/5/2001 Microwindows to CVS
**
** Revision 1.8  2000/08/14 jmt
** ported to microwin(non-client/server mode)
**
** Revision 1.7  2000/06/28 jmt
** porting to microwin
**
** Revision 1.6  2000/01/21 02:48:47  robf
** remove dead code
**
** Revision 1.5  1999/11/29 05:07:54  robf
** removed extraneous call CreateCompatibleDC
**
** Revision 1.4  1999/07/08 18:52:50  mwalsh
** Updated Comments
**
**-------------------------------------------------------------------------*/

⌨️ 快捷键说明

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