Implemented the disabled state of the combobox.

This commit is contained in:
Francis Beaudet 1999-09-19 14:09:52 +00:00 committed by Alexandre Julliard
parent 56753621d3
commit f132872741
1 changed files with 153 additions and 118 deletions

View File

@ -722,6 +722,11 @@ static void CBPaintButton(
buttonState |= DFCS_PUSHED; buttonState |= DFCS_PUSHED;
} }
if (CB_DISABLED(lphc))
{
buttonState |= DFCS_INACTIVE;
}
DrawFrameControl(hdc, DrawFrameControl(hdc,
&rectButton, &rectButton,
DFC_SCROLL, DFC_SCROLL,
@ -764,25 +769,9 @@ static void CBPaintText(
SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1)); SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
} }
else /* paint text field ourselves */ else /* paint text field ourselves */
{
HBRUSH hPrevBrush = 0;
HDC hDC = hdc;
if( !hDC )
{
if ((hDC = GetDC(lphc->self->hwndSelf)))
{
HBRUSH hBrush = SendMessageA( lphc->owner,
WM_CTLCOLORLISTBOX,
hDC, lphc->self->hwndSelf );
hPrevBrush = SelectObject( hDC,
(hBrush) ? hBrush : GetStockObject(WHITE_BRUSH) );
}
}
if( hDC )
{ {
UINT itemState; UINT itemState;
HFONT hPrevFont = (lphc->hFont) ? SelectObject(hDC, lphc->hFont) : 0; HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
/* /*
* Give ourselves some space. * Give ourselves some space.
@ -794,9 +783,9 @@ static void CBPaintText(
{ {
/* highlight */ /* highlight */
FillRect( hDC, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) ); FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) );
SetBkColor( hDC, GetSysColor( COLOR_HIGHLIGHT ) ); SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
SetTextColor( hDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
itemState = ODS_SELECTED | ODS_FOCUS; itemState = ODS_SELECTED | ODS_FOCUS;
} }
else else
@ -814,7 +803,7 @@ static void CBPaintText(
*/ */
clipRegion = CreateRectRgnIndirect(&rectEdit); clipRegion = CreateRectRgnIndirect(&rectEdit);
if (GetClipRgn(hDC, clipRegion)!=1) if (GetClipRgn(hdc, clipRegion)!=1)
{ {
DeleteObject(clipRegion); DeleteObject(clipRegion);
clipRegion=(HRGN)NULL; clipRegion=(HRGN)NULL;
@ -829,7 +818,7 @@ static void CBPaintText(
dis.itemAction = ODA_DRAWENTIRE; dis.itemAction = ODA_DRAWENTIRE;
dis.itemID = id; dis.itemID = id;
dis.itemState = itemState; dis.itemState = itemState;
dis.hDC = hDC; dis.hDC = hdc;
dis.rcItem = rectEdit; dis.rcItem = rectEdit;
dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA,
(WPARAM)id, 0 ); (WPARAM)id, 0 );
@ -837,7 +826,7 @@ static void CBPaintText(
/* /*
* Clip the DC and have the parent draw the item. * Clip the DC and have the parent draw the item.
*/ */
IntersectClipRect(hDC, IntersectClipRect(hdc,
rectEdit.left, rectEdit.top, rectEdit.left, rectEdit.top,
rectEdit.right, rectEdit.bottom); rectEdit.right, rectEdit.bottom);
@ -847,11 +836,11 @@ static void CBPaintText(
/* /*
* Reset the clipping region. * Reset the clipping region.
*/ */
SelectClipRgn(hDC, clipRegion); SelectClipRgn(hdc, clipRegion);
} }
else else
{ {
ExtTextOutA( hDC, ExtTextOutA( hdc,
rectEdit.left + 1, rectEdit.left + 1,
rectEdit.top + 1, rectEdit.top + 1,
ETO_OPAQUE | ETO_CLIPPED, ETO_OPAQUE | ETO_CLIPPED,
@ -859,20 +848,11 @@ static void CBPaintText(
pText ? pText : "" , size, NULL ); pText ? pText : "" , size, NULL );
if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED)) if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
DrawFocusRect( hDC, &rectEdit ); DrawFocusRect( hdc, &rectEdit );
} }
if( hPrevFont ) if( hPrevFont )
SelectObject(hDC, hPrevFont ); SelectObject(hdc, hPrevFont );
if( !hdc )
{
if( hPrevBrush )
SelectObject( hDC, hPrevBrush );
ReleaseDC( lphc->self->hwndSelf, hDC );
}
}
} }
if (pText) if (pText)
HeapFree( GetProcessHeap(), 0, pText ); HeapFree( GetProcessHeap(), 0, pText );
@ -903,6 +883,59 @@ static void CBPaintBorder(
DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT); DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
} }
/***********************************************************************
* COMBO_PrepareColors
*
* This method will sent the appropriate WM_CTLCOLOR message to
* prepare and setup the colors for the combo's DC.
*
* It also returns the brush to use for the background.
*/
static HBRUSH COMBO_PrepareColors(
HWND hwnd,
LPHEADCOMBO lphc,
HDC hDC)
{
HBRUSH hBkgBrush;
/*
* Get the background brush for this control.
*/
if (CB_DISABLED(lphc))
{
hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC,
hDC, lphc->self->hwndSelf );
/*
* We have to change the text color since WM_CTLCOLORSTATIC will
* set it to the "enabled" color. This is the same behavior as the
* edit control
*/
SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
}
else
{
if (lphc->wState & CBF_EDIT)
{
hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT,
hDC, lphc->self->hwndSelf );
}
else
{
hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,
hDC, lphc->self->hwndSelf );
}
}
/*
* Catch errors.
*/
if( !hBkgBrush )
hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
return hBkgBrush;
}
/*********************************************************************** /***********************************************************************
* COMBO_EraseBackground * COMBO_EraseBackground
*/ */
@ -932,11 +965,10 @@ static LRESULT COMBO_EraseBackground(
InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE()); InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
} }
hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX, /*
hDC, hwnd); * Retrieve the background brush
*/
if( !hBkgBrush ) hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC);
hBkgBrush = GetStockObject(WHITE_BRUSH);
FillRect(hDC, &clientRect, hBkgBrush); FillRect(hDC, &clientRect, hBkgBrush);
@ -962,11 +994,11 @@ static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
{ {
HBRUSH hPrevBrush, hBkgBrush; HBRUSH hPrevBrush, hBkgBrush;
hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX, /*
hDC, lphc->self->hwndSelf ); * Retrieve the background brush and select it in the
* DC.
if( !hBkgBrush ) */
hBkgBrush = GetStockObject(WHITE_BRUSH); hBkgBrush = COMBO_PrepareColors(lphc->self->hwndSelf, lphc, hDC);
hPrevBrush = SelectObject( hDC, hBkgBrush ); hPrevBrush = SelectObject( hDC, hBkgBrush );
@ -1886,6 +1918,9 @@ static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
if( lphc->wState & CBF_EDIT ) if( lphc->wState & CBF_EDIT )
EnableWindow( lphc->hWndEdit, (BOOL)wParam ); EnableWindow( lphc->hWndEdit, (BOOL)wParam );
EnableWindow( lphc->hWndLBox, (BOOL)wParam ); EnableWindow( lphc->hWndLBox, (BOOL)wParam );
/* Force the control to repaint when the enabled state changes. */
InvalidateRect(CB_HWND(lphc), NULL, TRUE);
return TRUE; return TRUE;
case WM_SETREDRAW: case WM_SETREDRAW:
if( wParam ) if( wParam )