comctl32/treeview: Fix default colors set on creation.

This commit is contained in:
Nikolay Sivov 2009-12-11 22:57:27 +03:00 committed by Alexandre Julliard
parent 28d5410596
commit b65a7a0052
2 changed files with 50 additions and 23 deletions

View File

@ -160,9 +160,9 @@ static const struct message test_get_set_textcolor_seq[] = {
{ TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 }, { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 },
{ TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, 0 }, { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, 0 },
{ TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 }, { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 },
{ TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, 0x00ffffff }, { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, RGB(255, 255, 255) },
{ TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 }, { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0, 0 },
{ TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, -1 }, { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0, CLR_NONE },
{ 0 } { 0 }
}; };
@ -728,7 +728,7 @@ static void test_get_set_textcolor(void)
ok(crColor == RGB(255,255,255), "White text color reported as 0x%.8x\n", crColor); ok(crColor == RGB(255,255,255), "White text color reported as 0x%.8x\n", crColor);
/* Reset the default text color */ /* Reset the default text color */
SendMessage( hTree, TVM_SETTEXTCOLOR, 0, -1 ); SendMessage( hTree, TVM_SETTEXTCOLOR, 0, CLR_NONE );
ok_sequence(MsgSequences, TREEVIEW_SEQ_INDEX, test_get_set_textcolor_seq, ok_sequence(MsgSequences, TREEVIEW_SEQ_INDEX, test_get_set_textcolor_seq,
"test get set text color", FALSE); "test get set text color", FALSE);
@ -990,6 +990,34 @@ static void test_treeview_classinfo(void)
expect(0, cls.cbClsExtra); expect(0, cls.cbClsExtra);
} }
static void test_get_linecolor(void)
{
COLORREF clr;
HWND hTree;
hTree = create_treeview_control();
/* newly created control has default color */
clr = (COLORREF)SendMessage(hTree, TVM_GETLINECOLOR, 0, 0);
expect(CLR_DEFAULT, clr);
DestroyWindow(hTree);
}
static void test_get_insertmarkcolor(void)
{
COLORREF clr;
HWND hTree;
hTree = create_treeview_control();
/* newly created control has default color */
clr = (COLORREF)SendMessage(hTree, TVM_GETINSERTMARKCOLOR, 0, 0);
expect(CLR_DEFAULT, clr);
DestroyWindow(hTree);
}
START_TEST(treeview) START_TEST(treeview)
{ {
HMODULE hComctl32; HMODULE hComctl32;
@ -1041,6 +1069,8 @@ START_TEST(treeview)
test_get_set_itemheight(); test_get_set_itemheight();
test_get_set_scrolltime(); test_get_set_scrolltime();
test_get_set_textcolor(); test_get_set_textcolor();
test_get_linecolor();
test_get_insertmarkcolor();
test_get_set_tooltips(); test_get_set_tooltips();
test_get_set_unicodeformat(); test_get_set_unicodeformat();
test_callback(); test_callback();

View File

@ -191,6 +191,10 @@ typedef struct tagTREEVIEW_INFO
#define OVERLAYIMAGEINDEX(x) (((x) >> 8) & 0x0f) #define OVERLAYIMAGEINDEX(x) (((x) >> 8) & 0x0f)
#define ISVISIBLE(x) ((x)->visibleOrder >= 0) #define ISVISIBLE(x) ((x)->visibleOrder >= 0)
#define GETLINECOLOR(x) ((x) == CLR_DEFAULT ? comctl32_color.clrGrayText : (x))
#define GETBKCOLOR(x) ((x) == CLR_NONE ? comctl32_color.clrWindow : (x))
#define GETTXTCOLOR(x) ((x) == CLR_NONE ? comctl32_color.clrWindowText : (x))
#define GETINSCOLOR(x) ((x) == CLR_DEFAULT ? comctl32_color.clrBtnText : (x))
static const WCHAR themeClass[] = { 'T','r','e','e','v','i','e','w',0 }; static const WCHAR themeClass[] = { 'T','r','e','e','v','i','e','w',0 };
@ -2322,8 +2326,7 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
& (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS)) & (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS))
> TVS_LINESATROOT); > TVS_LINESATROOT);
HBRUSH hbr, hbrOld; HBRUSH hbr, hbrOld;
COLORREF clrBk = infoPtr->clrBk == -1 ? comctl32_color.clrWindow: COLORREF clrBk = GETBKCOLOR(infoPtr->clrBk);
infoPtr->clrBk;
if (!lar && item->iLevel == 0) if (!lar && item->iLevel == 0)
return; return;
@ -2342,7 +2345,7 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
/* Get a dotted grey pen */ /* Get a dotted grey pen */
lb.lbStyle = BS_SOLID; lb.lbStyle = BS_SOLID;
lb.lbColor = infoPtr->clrLine; lb.lbColor = GETLINECOLOR(infoPtr->clrLine);
hNewPen = ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, NULL); hNewPen = ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, NULL);
hOldPen = SelectObject(hdc, hNewPen); hOldPen = SelectObject(hdc, hNewPen);
@ -2412,7 +2415,7 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
/* plussize = ceil(rectsize * 3/4) */ /* plussize = ceil(rectsize * 3/4) */
LONG plussize = (rectsize + 1) * 3 / 4; LONG plussize = (rectsize + 1) * 3 / 4;
HPEN hNewPen = CreatePen(PS_SOLID, 0, infoPtr->clrLine); HPEN hNewPen = CreatePen(PS_SOLID, 0, GETLINECOLOR(infoPtr->clrLine));
HPEN hOldPen = SelectObject(hdc, hNewPen); HPEN hOldPen = SelectObject(hdc, hNewPen);
Rectangle(hdc, centerx - rectsize - 1, centery - rectsize - 1, Rectangle(hdc, centerx - rectsize - 1, centery - rectsize - 1,
@ -2482,22 +2485,16 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem
else else
{ {
nmcdhdr.clrTextBk = comctl32_color.clrBtnFace; nmcdhdr.clrTextBk = comctl32_color.clrBtnFace;
if (infoPtr->clrText == -1) nmcdhdr.clrText = GETTXTCOLOR(infoPtr->clrText);
nmcdhdr.clrText = comctl32_color.clrWindowText;
else
nmcdhdr.clrText = infoPtr->clrText;
} }
} }
else else
{ {
nmcdhdr.clrTextBk = infoPtr->clrBk == -1 ? comctl32_color.clrWindow: nmcdhdr.clrTextBk = GETBKCOLOR(infoPtr->clrBk);
infoPtr->clrBk;
if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem)) if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem))
nmcdhdr.clrText = comctl32_color.clrHighlight; nmcdhdr.clrText = comctl32_color.clrHighlight;
else if (infoPtr->clrText == -1)
nmcdhdr.clrText = comctl32_color.clrWindowText;
else else
nmcdhdr.clrText = infoPtr->clrText; nmcdhdr.clrText = GETTXTCOLOR(infoPtr->clrText);
} }
hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, wineItem)); hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, wineItem));
@ -2629,7 +2626,7 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem
int offset; int offset;
int left, right; int left, right;
hNewPen = CreatePen(PS_SOLID, 2, infoPtr->clrInsertMark); hNewPen = CreatePen(PS_SOLID, 2, GETINSCOLOR(infoPtr->clrInsertMark));
hOldPen = SelectObject(hdc, hNewPen); hOldPen = SelectObject(hdc, hNewPen);
if (infoPtr->insertBeforeorAfter) if (infoPtr->insertBeforeorAfter)
@ -2801,8 +2798,8 @@ static void
TREEVIEW_FillBkgnd(const TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc) TREEVIEW_FillBkgnd(const TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
{ {
HBRUSH hBrush; HBRUSH hBrush;
COLORREF clrBk = infoPtr->clrBk == -1 ? comctl32_color.clrWindow: COLORREF clrBk = GETBKCOLOR(infoPtr->clrBk);
infoPtr->clrBk;
hBrush = CreateSolidBrush(clrBk); hBrush = CreateSolidBrush(clrBk);
FillRect(hdc, rc, hBrush); FillRect(hdc, rc, hBrush);
DeleteObject(hBrush); DeleteObject(hBrush);
@ -4998,10 +4995,10 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr->scrollX = 0; infoPtr->scrollX = 0;
infoPtr->clrBk = -1; /* use system color */ infoPtr->clrBk = CLR_NONE; /* use system color */
infoPtr->clrText = -1; /* use system color */ infoPtr->clrText = CLR_NONE; /* use system color */
infoPtr->clrLine = RGB(128, 128, 128); infoPtr->clrLine = CLR_DEFAULT;
infoPtr->clrInsertMark = comctl32_color.clrBtnText; infoPtr->clrInsertMark = CLR_DEFAULT;
/* hwndToolTip */ /* hwndToolTip */