From f488863f7b4558ed3b9fb97f34ec62a142f5e198 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 8 Nov 2010 03:17:48 +0000 Subject: [PATCH] wince: implement clDefault support git-svn-id: trunk@28143 - --- lcl/interfaces/wince/wincecallback.inc | 6 +++++- lcl/interfaces/wince/winceextra.pp | 2 +- lcl/interfaces/wince/wincewinapi.inc | 21 +++++++------------ .../wince/wincewscustomlistview.inc | 9 ++++++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lcl/interfaces/wince/wincecallback.inc b/lcl/interfaces/wince/wincecallback.inc index 34b1c933e6..ebf4a0ee49 100644 --- a/lcl/interfaces/wince/wincecallback.inc +++ b/lcl/interfaces/wince/wincecallback.inc @@ -191,6 +191,7 @@ Var WindowInfo: PWindowInfo; Flags: dword; ChildWindowInfo: PWindowInfo; + WindowColor: Integer; LMScroll: TLMScroll; // used by WM_HSCROLL LMKey: TLMKey; // used by WM_KEYDOWN WM_KEYUP @@ -1299,7 +1300,10 @@ begin if ChildWinControl <> nil then begin Windows.SetTextColor(HDC(WParam), Windows.COLORREF(ColorToRGB(ChildWinControl.Font.Color))); - Windows.SetBkColor(HDC(WParam), Windows.COLORREF(ColorToRGB(ChildWinControl.Brush.Color))); + WindowColor := ChildWinControl.Brush.Color; + if WindowColor = clDefault then + WindowColor := TWSWinControlClass(ChildWinControl.WidgetSetClass).GetDefaultColor(ChildWinControl); + Windows.SetBkColor(WindowDC, Windows.COLORREF(ColorToRGB(WindowColor))); LMessage.Result := LResult(ChildWinControl.Brush.Reference.Handle); //DebugLn(['WindowProc ', ChildWinControl.Name, ' Brush: ', LMessage.Result]); // Override default handling diff --git a/lcl/interfaces/wince/winceextra.pp b/lcl/interfaces/wince/winceextra.pp index a8e11e6779..c0e4e0bf91 100644 --- a/lcl/interfaces/wince/winceextra.pp +++ b/lcl/interfaces/wince/winceextra.pp @@ -10,7 +10,7 @@ * * * This file is part of the Lazarus Component Library (LCL) * * * - * See the file COPYING.modifiedLGPL.txt, included in this distribution, * + * See the file COPYING.modifiedLGPL.txt, included in this distribution, * * for details about the copyright. * * * * This program is distributed in the hope that it will be useful, * diff --git a/lcl/interfaces/wince/wincewinapi.inc b/lcl/interfaces/wince/wincewinapi.inc index 36aedb6189..ea9779e36a 100644 --- a/lcl/interfaces/wince/wincewinapi.inc +++ b/lcl/interfaces/wince/wincewinapi.inc @@ -179,23 +179,19 @@ var Brush: HBRUSH; Rect: Windows.Rect; Details: TThemedElementDetails; - OldColor, OldBackColor: COLORREF; + OldColor: COLORREF; + OldBkMode: Integer; WideBuffer: widestring; begin Selected := (Data^.itemState AND ODS_SELECTED)>0; Enabled := CheckListBox.Enabled; { fill the background } - if Selected then - lgBrush.lbColor := LCLIntf.GetSysColor(COLOR_HIGHLIGHT) // $00D39137 - else - // if default COLOR_WINDOW: $00FFFFFF - lgBrush.lbColor := ColorToRGB(CheckListBox.Color); - lgBrush.lbStyle := BS_SOLID; - Brush := CreateBrushIndirect(lgBrush); Rect := Data^.rcItem; - Windows.FillRect(Data^._HDC, Rect, Brush); - DeleteObject(Brush); + if Selected then + Windows.FillRect(Data^._HDC, Rect, GetSysColorBrush(COLOR_HIGHLIGHT)) + else + Windows.FillRect(Data^._HDC, Rect, CheckListBox.Brush.Reference.Handle); // draw checkbox InflateRect(Rect, -1, -1); @@ -218,7 +214,7 @@ var because the LCLIntf version makes sure that SYS_COLOR_INDEX_FLAG is added to the constant. } - OldBackColor := Windows.SetBkColor(Data^._HDC, lgBrush.lbColor); + OldBkMode := Windows.SetBkMode(Data^._HDC, TRANSPARENT); if not Enabled then OldColor := Windows.SetTextColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_GRAYTEXT)) // $00BFBFBF @@ -233,7 +229,7 @@ var // Return to default text and background colors Windows.SetTextColor(Data^._HDC, OldColor); - Windows.SetBkColor(Data^._HDC, OldBackColor); + Windows.SetBkMode(Data^._HDC, OldBkMode); end; begin @@ -2833,7 +2829,6 @@ end; ------------------------------------------------------------------------------} function TWinCEWidgetSet.SetBkMode(DC: HDC; BkMode: Integer): Integer; begin - // Your code here Result := Windows.SetBkMode(DC, BkMode); end; diff --git a/lcl/interfaces/wince/wincewscustomlistview.inc b/lcl/interfaces/wince/wincewscustomlistview.inc index 09fc71c7e1..5bb876bf23 100644 --- a/lcl/interfaces/wince/wincewscustomlistview.inc +++ b/lcl/interfaces/wince/wincewscustomlistview.inc @@ -724,11 +724,16 @@ begin end; class procedure TWinCEWSCustomListView.SetColor(const AWinControl: TWinControl); +var + Color: TColor; begin if not WSCheckHandleAllocated(AWinControl, 'TWin32WSCustomListView.SetColor') then Exit; - Windows.SendMessage(AWinControl.Handle, LVM_SETBKCOLOR, 0, ColorToRGB(AWinControl.Color)); - Windows.SendMessage(AWinControl.Handle, LVM_SETTEXTBKCOLOR, 0, ColorToRGB(AWinControl.Color)); + Color := AWinControl.Color; + if Color = clDefault then + Color := TWSWinControlClass(AWinControl.WidgetSetClass).GetDefaultColor(AWinControl); + Windows.SendMessage(AWinControl.Handle, LVM_SETBKCOLOR, 0, ColorToRGB(Color)); + Windows.SendMessage(AWinControl.Handle, LVM_SETTEXTBKCOLOR, 0, ColorToRGB(Color)); end; class procedure TWinCEWSCustomListView.SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer);