Update of /cvsroot/htoolkit/port/src/cbits/Win32
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11977/src/cbits/Win32
Modified Files:
ListBox.c
Log Message:
Use bitmaps to get better look of checked list box
Index: ListBox.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ListBox.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ListBox.c 25 Nov 2003 14:12:22 -0000 1.8
--- ListBox.c 22 Feb 2004 22:20:25 -0000 1.9
***************
*** 3,7 ****
#include "Handlers_stub.h"
#include <windowsx.h>
!
void DrawCheckListBoxItem(LPDRAWITEMSTRUCT lpDIS)
{
--- 3,47 ----
#include "Handlers_stub.h"
#include <windowsx.h>
!
! static unsigned char bits[] =
! {0x42,0x4D,0x52,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x28,0x00,
! 0x00,0x00,0x21,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,
! 0x00,0x00,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
! 0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,
! 0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x80,
! 0x00,0x00,0xC0,0xC0,0xC0,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,
! 0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,
! 0x00,0x00,0xFF,0xFF,0xFF,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
! 0x88,0x88,0x88,0x88,0x88,0x88,0x80,0x00,0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,
! 0xFF,0xFF,0xFF,0xFF,0xF8,0x87,0x77,0x77,0x77,0x77,0x80,0x00,0x00,0x00,0x8F,0xFF,
! 0xFF,0xFF,0xFF,0x88,0xFF,0xF0,0xFF,0xFF,0xF8,0x87,0x77,0x87,0x77,0x77,0x80,0x00,
! 0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,0xFF,0x00,0x0F,0xFF,0xF8,0x87,0x78,0x88,
! 0x77,0x77,0x80,0x00,0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,0xF0,0x00,0x00,0xFF,
! 0xF8,0x87,0x88,0x88,0x87,0x77,0x80,0x00,0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,
! 0xF0,0x0F,0x00,0x0F,0xF8,0x87,0x88,0x78,0x88,0x77,0x80,0x00,0x00,0x00,0x8F,0xFF,
! 0xFF,0xFF,0xFF,0x88,0xF0,0xFF,0xF0,0x00,0xF8,0x87,0x87,0x77,0x88,0x87,0x80,0x00,
! 0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,0xFF,0xFF,0xFF,0x00,0xF8,0x87,0x77,0x77,
! 0x78,0x87,0x80,0x00,0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,0xFF,0xFF,0xFF,0xF0,
! 0xF8,0x87,0x77,0x77,0x77,0x87,0x80,0x00,0x00,0x00,0x8F,0xFF,0xFF,0xFF,0xFF,0x88,
! 0xFF,0xFF,0xFF,0xFF,0xF8,0x87,0x77,0x77,0x77,0x77,0x80,0x00,0x00,0x00,0x88,0x88,
! 0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x80,0x00,
! 0x00,0x00
! };
!
! static HBITMAP GetCheckListBitmap(HDC hDC)
! {
! static HBITMAP hCheckListBitmap = NULL;
!
! if (!hCheckListBitmap)
! {
! BITMAPINFO *lpbmi = (BITMAPINFO *) (bits+sizeof(BITMAPFILEHEADER));
! VOID *lpbInit = bits+((BITMAPFILEHEADER *) bits)->bfOffBits;
!
! hCheckListBitmap = CreateDIBitmap(hDC,&lpbmi->bmiHeader,CBM_INIT,lpbInit,lpbmi,DIB_RGB_COLORS);
! }
!
! return hCheckListBitmap;
! }
!
void DrawCheckListBoxItem(LPDRAWITEMSTRUCT lpDIS)
{
***************
*** 16,21 ****
--- 56,64 ----
int nTextLen;
LPCSTR lpszText;
+ HDC hMemDC;
+ int nItemData;
cyItem = SendMessage(lpDIS->hwndItem, LB_GETITEMHEIGHT, lpDIS->itemID, 0);
+ nItemData = SendMessage(lpDIS->hwndItem, LB_GETITEMDATA, lpDIS->itemID, 0);
fDisabled = !IsWindowEnabled(lpDIS->hwndItem);
***************
*** 48,66 ****
ETO_OPAQUE, &lpDIS->rcItem, lpszText, nTextLen, NULL);
! Rectangle(lpDIS->hDC, 1, lpDIS->rcItem.top+1, cyItem-1, lpDIS->rcItem.top+cyItem-1);
!
! if (SendMessage(lpDIS->hwndItem, LB_GETITEMDATA, lpDIS->itemID, 0) > 0)
! {
! HPEN hPen, hOldPen;
!
! hPen = CreatePen(PS_SOLID, 2, newTextColor);
! hOldPen = SelectObject(lpDIS->hDC, hPen);
!
! MoveToEx(lpDIS->hDC, 3, lpDIS->rcItem.top+cyItem/2-1, NULL);
! LineTo(lpDIS->hDC, cyItem/2, lpDIS->rcItem.top+cyItem-4);
! LineTo(lpDIS->hDC, cyItem-4, lpDIS->rcItem.top+3);
!
! SelectObject(lpDIS->hDC, hOldPen);
! }
rfree(lpszText);
--- 91,100 ----
ETO_OPAQUE, &lpDIS->rcItem, lpszText, nTextLen, NULL);
! hMemDC = CreateCompatibleDC(lpDIS->hDC);
! SelectObject(hMemDC, GetCheckListBitmap(lpDIS->hDC));
! BitBlt(lpDIS->hDC, 1, lpDIS->rcItem.top+(cyItem-11)/2, 11, 11,
! hMemDC, (nItemData <= 0) ? 0 : 11, 0,
! SRCCOPY);
! DeleteDC(hMemDC);
rfree(lpszText);
***************
*** 107,111 ****
handleControlCommand(hWnd);
!
SendMessage(hWnd, LB_GETITEMRECT, nIndex, (LPARAM)&rect);
rect.right = rect.left + cyItem;
--- 141,145 ----
handleControlCommand(hWnd);
!
SendMessage(hWnd, LB_GETITEMRECT, nIndex, (LPARAM)&rect);
rect.right = rect.left + cyItem;
|