Commit 694602ea authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/combo: Merge theming logic.

parent c9e98034
...@@ -35,7 +35,6 @@ C_SRCS = \ ...@@ -35,7 +35,6 @@ C_SRCS = \
syslink.c \ syslink.c \
tab.c \ tab.c \
taskdialog.c \ taskdialog.c \
theme_combo.c \
theme_dialog.c \ theme_dialog.c \
theme_listbox.c \ theme_listbox.c \
theme_scrollbar.c \ theme_scrollbar.c \
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Combo controls * Combo controls
* *
* Copyright 1997 Alex Korobka * Copyright 1997 Alex Korobka
* Copyright (c) 2005 by Frank Richter
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -32,6 +33,8 @@ ...@@ -32,6 +33,8 @@
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "commctrl.h" #include "commctrl.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -87,6 +90,7 @@ static UINT CBitHeight, CBitWidth; ...@@ -87,6 +90,7 @@ static UINT CBitHeight, CBitWidth;
#define CBF_NOTIFY 0x0100 #define CBF_NOTIFY 0x0100
#define CBF_NOREDRAW 0x0200 #define CBF_NOREDRAW 0x0200
#define CBF_SELCHANGE 0x0400 #define CBF_SELCHANGE 0x0400
#define CBF_HOT 0x0800
#define CBF_NOEDITNOTIFY 0x1000 #define CBF_NOEDITNOTIFY 0x1000
#define CBF_NOLBSELECT 0x2000 /* do not change current selection */ #define CBF_NOLBSELECT 0x2000 /* do not change current selection */
#define CBF_BEENFOCUSED 0x4000 /* has it ever had focus */ #define CBF_BEENFOCUSED 0x4000 /* has it ever had focus */
...@@ -472,6 +476,7 @@ static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG ...@@ -472,6 +476,7 @@ static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG
static const WCHAR clbName[] = {'C','o','m','b','o','L','B','o','x',0}; static const WCHAR clbName[] = {'C','o','m','b','o','L','B','o','x',0};
static const WCHAR editName[] = {'E','d','i','t',0}; static const WCHAR editName[] = {'E','d','i','t',0};
OpenThemeData( hwnd, WC_COMBOBOXW );
if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE; if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT; if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
...@@ -684,9 +689,7 @@ static HBRUSH COMBO_PrepareColors( ...@@ -684,9 +689,7 @@ static HBRUSH COMBO_PrepareColors(
* *
* Paint CBS_DROPDOWNLIST text field / update edit control contents. * Paint CBS_DROPDOWNLIST text field / update edit control contents.
*/ */
static void CBPaintText( static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint)
LPHEADCOMBO lphc,
HDC hdc_paint)
{ {
RECT rectEdit = lphc->textRect; RECT rectEdit = lphc->textRect;
INT id, size = 0; INT id, size = 0;
...@@ -828,64 +831,86 @@ static void CBPaintBorder( ...@@ -828,64 +831,86 @@ static void CBPaintBorder(
DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT); DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
} }
/*********************************************************************** static LRESULT COMBO_ThemedPaint(HTHEME theme, HEADCOMBO *lphc, HDC hdc)
* COMBO_Paint
*/
static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
{ {
PAINTSTRUCT ps; int button_state;
HDC hDC; RECT frame;
hDC = (hParamDC) ? hParamDC /* paint border */
: BeginPaint( lphc->self, &ps); if (CB_GETTYPE(lphc) != CBS_SIMPLE)
GetClientRect(lphc->self, &frame);
else
{
frame = lphc->textRect;
InflateRect(&frame, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
InflateRect(&frame, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
}
TRACE("hdc=%p\n", hDC); DrawThemeBackground(theme, hdc, 0, IsWindowEnabled(lphc->self) ? CBXS_NORMAL : CBXS_DISABLED, &frame, NULL);
if( hDC && !(lphc->wState & CBF_NOREDRAW) ) /* Paint button */
{ if (!IsRectEmpty(&lphc->buttonRect))
HBRUSH hPrevBrush, hBkgBrush; {
if (!IsWindowEnabled(lphc->self))
button_state = CBXS_DISABLED;
else if (lphc->wState & CBF_BUTTONDOWN)
button_state = CBXS_PRESSED;
else if (lphc->wState & CBF_HOT)
button_state = CBXS_HOT;
else
button_state = CBXS_NORMAL;
DrawThemeBackground(theme, hdc, CP_DROPDOWNBUTTON, button_state, &lphc->buttonRect, NULL);
}
/* if ((lphc->dwStyle & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
* Retrieve the background brush and select it in the CBPaintText(lphc, hdc);
* DC.
*/ return 0;
hBkgBrush = COMBO_PrepareColors(lphc, hDC); }
hPrevBrush = SelectObject( hDC, hBkgBrush ); /***********************************************************************
if (!(lphc->wState & CBF_EDIT)) * COMBO_Paint
FillRect(hDC, &lphc->textRect, hBkgBrush); */
static LRESULT COMBO_Paint(HEADCOMBO *lphc, HDC hdc)
{
HBRUSH hPrevBrush, hBkgBrush;
/* TRACE("hdc=%p\n", hdc);
* In non 3.1 look, there is a sunken border on the combobox
*/
CBPaintBorder(lphc->self, lphc, hDC);
if( !IsRectEmpty(&lphc->buttonRect) ) /*
{ * Retrieve the background brush and select it in the
CBPaintButton(lphc, hDC, lphc->buttonRect); * DC.
} */
hBkgBrush = COMBO_PrepareColors(lphc, hdc);
hPrevBrush = SelectObject(hdc, hBkgBrush);
if (!(lphc->wState & CBF_EDIT))
FillRect(hdc, &lphc->textRect, hBkgBrush);
/* paint the edit control padding area */ /*
if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST) * In non 3.1 look, there is a sunken border on the combobox
{ */
RECT rPadEdit = lphc->textRect; CBPaintBorder(lphc->self, lphc, hdc);
InflateRect(&rPadEdit, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING()); if (!IsRectEmpty(&lphc->buttonRect))
CBPaintButton(lphc, hdc, lphc->buttonRect);
FrameRect( hDC, &rPadEdit, GetSysColorBrush(COLOR_WINDOW) ); /* paint the edit control padding area */
} if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
{
RECT rPadEdit = lphc->textRect;
if( !(lphc->wState & CBF_EDIT) ) InflateRect(&rPadEdit, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
CBPaintText( lphc, hDC );
if( hPrevBrush ) FrameRect(hdc, &rPadEdit, GetSysColorBrush(COLOR_WINDOW));
SelectObject( hDC, hPrevBrush ); }
}
if (!(lphc->wState & CBF_EDIT))
CBPaintText( lphc, hdc );
if( !hParamDC ) if (hPrevBrush)
EndPaint(lphc->self, &ps); SelectObject( hdc, hPrevBrush );
return 0; return 0;
} }
/*********************************************************************** /***********************************************************************
...@@ -1727,6 +1752,7 @@ static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi) ...@@ -1727,6 +1752,7 @@ static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi)
LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{ {
HEADCOMBO *lphc = (HEADCOMBO *)GetWindowLongPtrW( hwnd, 0 ); HEADCOMBO *lphc = (HEADCOMBO *)GetWindowLongPtrW( hwnd, 0 );
HTHEME theme;
TRACE("[%p]: msg %#x wp %08lx lp %08lx\n", hwnd, message, wParam, lParam ); TRACE("[%p]: msg %#x wp %08lx lp %08lx\n", hwnd, message, wParam, lParam );
...@@ -1755,10 +1781,41 @@ LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARA ...@@ -1755,10 +1781,41 @@ LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
return COMBO_Create(hwnd, lphc, hwndParent, style); return COMBO_Create(hwnd, lphc, hwndParent, style);
} }
case WM_DESTROY:
theme = GetWindowTheme( hwnd );
CloseThemeData( theme );
break;
case WM_THEMECHANGED:
theme = GetWindowTheme( hwnd );
CloseThemeData( theme );
OpenThemeData( hwnd, WC_COMBOBOXW );
break;
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
case WM_PAINT: case WM_PAINT:
return COMBO_Paint(lphc, (HDC)wParam); {
LRESULT ret = 0;
PAINTSTRUCT ps;
HDC hdc;
hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
if (hdc && !(lphc->wState & CBF_NOREDRAW))
{
HTHEME theme = GetWindowTheme(hwnd);
if (theme)
ret = COMBO_ThemedPaint(theme, lphc, hdc);
else
ret = COMBO_Paint(lphc, hdc);
}
if (!wParam)
EndPaint(hwnd, &ps);
return ret;
}
case WM_ERASEBKGND: case WM_ERASEBKGND:
/* do all painting in WM_PAINT like Windows does */ /* do all painting in WM_PAINT like Windows does */
return 1; return 1;
...@@ -1912,6 +1969,28 @@ LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARA ...@@ -1912,6 +1969,28 @@ LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
return TRUE; return TRUE;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (!IsRectEmpty(&lphc->buttonRect))
{
POINT pt;
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
if (PtInRect(&lphc->buttonRect, pt))
{
if (!(lphc->wState & CBF_HOT))
{
lphc->wState |= CBF_HOT;
RedrawWindow(hwnd, &lphc->buttonRect, 0, RDW_INVALIDATE | RDW_UPDATENOW);
}
}
else if (lphc->wState & CBF_HOT)
{
lphc->wState &= ~CBF_HOT;
RedrawWindow(hwnd, &lphc->buttonRect, 0, RDW_INVALIDATE | RDW_UPDATENOW);
}
}
if ( lphc->wState & CBF_CAPTURE ) if ( lphc->wState & CBF_CAPTURE )
COMBO_MouseMove( lphc, wParam, lParam ); COMBO_MouseMove( lphc, wParam, lParam );
return TRUE; return TRUE;
......
...@@ -34,8 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(theming); ...@@ -34,8 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(theming);
typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM, typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM,
ULONG_PTR); ULONG_PTR);
extern LRESULT CALLBACK THEMING_ComboSubclassProc (HWND, UINT, WPARAM, LPARAM,
ULONG_PTR) DECLSPEC_HIDDEN;
extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM, extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM,
ULONG_PTR) DECLSPEC_HIDDEN; ULONG_PTR) DECLSPEC_HIDDEN;
extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM, extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM,
...@@ -53,7 +51,6 @@ static const struct ThemingSubclass ...@@ -53,7 +51,6 @@ static const struct ThemingSubclass
} subclasses[] = { } subclasses[] = {
/* Note: list must be sorted by class name */ /* Note: list must be sorted by class name */
{dialogClass, THEMING_DialogSubclassProc}, {dialogClass, THEMING_DialogSubclassProc},
{WC_COMBOBOXW, THEMING_ComboSubclassProc},
{comboLboxClass, THEMING_ListBoxSubclassProc}, {comboLboxClass, THEMING_ListBoxSubclassProc},
{WC_LISTBOXW, THEMING_ListBoxSubclassProc}, {WC_LISTBOXW, THEMING_ListBoxSubclassProc},
{WC_SCROLLBARW, THEMING_ScrollbarSubclassProc} {WC_SCROLLBARW, THEMING_ScrollbarSubclassProc}
...@@ -90,14 +87,12 @@ MAKE_SUBCLASS_PROC(0) ...@@ -90,14 +87,12 @@ MAKE_SUBCLASS_PROC(0)
MAKE_SUBCLASS_PROC(1) MAKE_SUBCLASS_PROC(1)
MAKE_SUBCLASS_PROC(2) MAKE_SUBCLASS_PROC(2)
MAKE_SUBCLASS_PROC(3) MAKE_SUBCLASS_PROC(3)
MAKE_SUBCLASS_PROC(4)
static const WNDPROC subclassProcs[NUM_SUBCLASSES] = { static const WNDPROC subclassProcs[NUM_SUBCLASSES] = {
subclass_proc0, subclass_proc0,
subclass_proc1, subclass_proc1,
subclass_proc2, subclass_proc2,
subclass_proc3, subclass_proc3,
subclass_proc4,
}; };
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment