mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 01:39:10 +02:00
replaced wince checklistbox handling code by win32 code with little modifications (todo: check work on device)
git-svn-id: trunk@13377 -
This commit is contained in:
parent
2b2627a234
commit
f232f3ab9c
@ -488,13 +488,14 @@ Var
|
|||||||
MousePos.Y := LMMouse.Pos.Y;
|
MousePos.Y := LMMouse.Pos.Y;
|
||||||
for I := 0 to Windows.SendMessage(Window, LB_GETCOUNT, 0, 0) - 1 do
|
for I := 0 to Windows.SendMessage(Window, LB_GETCOUNT, 0, 0) - 1 do
|
||||||
begin
|
begin
|
||||||
Windows.SendMessage(Window, LB_GETITEMRECT, I, LongInt(@ItemRect));
|
Windows.SendMessage(Window, LB_GETITEMRECT, I, PtrInt(@ItemRect));
|
||||||
ItemRect.Right := ItemRect.Left + ItemRect.Bottom - ItemRect.Top;
|
ItemRect.Right := ItemRect.Left + ItemRect.Bottom - ItemRect.Top;
|
||||||
if Windows.PtInRect(@ItemRect, MousePos) then
|
if Windows.PtInRect(ItemRect, MousePos) then
|
||||||
begin
|
begin
|
||||||
// item clicked: toggle
|
// item clicked: toggle
|
||||||
if I < TCheckListBox(lWinControl).Items.Count then begin
|
if I < TCheckListBox(lWinControl).Items.Count then
|
||||||
TCheckListBox(lWinControl).Checked[I] := not TCheckListBox(lWinControl).Checked[I];
|
begin
|
||||||
|
TCheckListBox(lWinControl).Toggle(I);
|
||||||
Message.Msg := LM_CHANGED;
|
Message.Msg := LM_CHANGED;
|
||||||
Message.WParam := I;
|
Message.WParam := I;
|
||||||
DeliverMessage(lWinControl, Message);
|
DeliverMessage(lWinControl, Message);
|
||||||
|
@ -44,7 +44,7 @@ Uses
|
|||||||
Windows, Classes, ComCtrls, Controls, Buttons, Dialogs, DynHashArray,
|
Windows, Classes, ComCtrls, Controls, Buttons, Dialogs, DynHashArray,
|
||||||
ExtCtrls, Forms, GraphMath, GraphType, InterfaceBase, LCLIntf, LCLType,
|
ExtCtrls, Forms, GraphMath, GraphType, InterfaceBase, LCLIntf, LCLType,
|
||||||
LMessages, StdCtrls, SysUtils, Graphics, Menus, WinCEProc, WinCEExtra,
|
LMessages, StdCtrls, SysUtils, Graphics, Menus, WinCEProc, WinCEExtra,
|
||||||
WinExt, WinCEDef;
|
WinExt, WinCEDef, Themes;
|
||||||
|
|
||||||
const
|
const
|
||||||
IDC_NODROP = IDC_NO;
|
IDC_NODROP = IDC_NO;
|
||||||
|
@ -143,22 +143,29 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
|
||||||
procedure DrawCheckListBoxItem(CheckListBox: TCheckListBox; Data: PDrawItemStruct);
|
procedure DrawCheckListBoxItem(CheckListBox: TCheckListBox; Data: PDrawItemStruct);
|
||||||
|
const
|
||||||
|
ThemeStateMap: array[TCheckBoxState, Boolean] of TThemedButton =
|
||||||
|
(
|
||||||
|
{cbUnchecked} (tbCheckBoxUncheckedDisabled, tbCheckBoxUncheckedNormal),
|
||||||
|
{cbChecked } (tbCheckBoxCheckedDisabled, tbCheckBoxCheckedNormal),
|
||||||
|
{cbGrayed } (tbCheckBoxMixedDisabled, tbCheckBoxMixedNormal)
|
||||||
|
);
|
||||||
var
|
var
|
||||||
Selected: Boolean;
|
Enabled, Selected: Boolean;
|
||||||
lgBrush: LOGBRUSH;
|
lgBrush: LOGBRUSH;
|
||||||
Brush: HBRUSH;
|
Brush: HBRUSH;
|
||||||
Rect: Windows.Rect;
|
Rect: Windows.Rect;
|
||||||
Flags: Cardinal;
|
Details: TThemedElementDetails;
|
||||||
OldColor: COLORREF;
|
OldColor: COLORREF;
|
||||||
OldBackColor: COLORREF;
|
OldBackColor: COLORREF;
|
||||||
|
WideBuffer: WideString;
|
||||||
begin
|
begin
|
||||||
Selected := (Data^.itemState AND ODS_SELECTED)>0;
|
Selected := (Data^.itemState AND ODS_SELECTED)>0;
|
||||||
|
Enabled := CheckListBox.Enabled;
|
||||||
|
|
||||||
// fill the background
|
// fill the background
|
||||||
if Selected then
|
if Enabled and Selected then
|
||||||
lgBrush.lbColor := Windows.GetSysColor(COLOR_HIGHLIGHT)
|
lgBrush.lbColor := Windows.GetSysColor(COLOR_HIGHLIGHT)
|
||||||
else
|
else
|
||||||
lgBrush.lbColor := Windows.GetSysColor(COLOR_WINDOW);
|
lgBrush.lbColor := Windows.GetSysColor(COLOR_WINDOW);
|
||||||
@ -167,39 +174,46 @@ var
|
|||||||
Windows.FillRect(Data^._HDC, Windows.Rect(Data^.rcItem), Brush);
|
Windows.FillRect(Data^._HDC, Windows.Rect(Data^.rcItem), Brush);
|
||||||
DeleteObject(Brush);
|
DeleteObject(Brush);
|
||||||
|
|
||||||
// draw checkbox
|
Rect := Data^.rcItem;
|
||||||
Flags := DFCS_BUTTONCHECK;
|
InflateRect(Rect, -1, -1);
|
||||||
if CheckListBox.Checked[Data^.ItemID] then
|
|
||||||
Flags := Flags or DFCS_CHECKED;
|
|
||||||
Rect.Left := Data^.rcItem.Left + 2;
|
|
||||||
Rect.Top := Data^.rcItem.Top + 2;
|
|
||||||
Rect.Bottom := Data^.rcItem.Bottom - 2;
|
|
||||||
Rect.Right := Rect.Left + Rect.Bottom - Rect.Top;
|
Rect.Right := Rect.Left + Rect.Bottom - Rect.Top;
|
||||||
Windows.DrawFrameControl(Data^._HDC, Rect, DFC_BUTTON, Flags);
|
|
||||||
|
// draw all through ThemeServices. ThemeServices can decide itself hot to perform actual draw
|
||||||
|
Details := ThemeServices.GetElementDetails(ThemeStateMap[CheckListBox.State[Data^.ItemID], Enabled]);
|
||||||
|
ThemeServices.DrawElement(Data^._HDC, Details, Rect);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
Rect := Windows.Rect(Data^.rcItem);
|
Rect := Windows.Rect(Data^.rcItem);
|
||||||
Rect.Right := Data^.rcItem.Right;
|
Rect.Right := Data^.rcItem.Right;
|
||||||
Rect.Left := Rect.Bottom-Rect.Top + 5;
|
Rect.Left := Rect.Bottom-Rect.Top + 5;
|
||||||
if Selected then begin
|
if not Enabled then
|
||||||
|
OldColor := Windows.SetTextColor(Data^._HDC, Windows.GetSysColor(COLOR_GRAYTEXT))
|
||||||
|
else
|
||||||
|
if Selected then
|
||||||
|
begin
|
||||||
OldColor := Windows.SetTextColor(Data^._HDC, Windows.GetSysColor(COLOR_HIGHLIGHTTEXT));
|
OldColor := Windows.SetTextColor(Data^._HDC, Windows.GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||||
OldBackColor := Windows.SetBkColor(Data^._HDC, Windows.GetSysColor(COLOR_HIGHLIGHT));
|
OldBackColor := Windows.SetBkColor(Data^._HDC, Windows.GetSysColor(COLOR_HIGHLIGHT));
|
||||||
end;
|
end;
|
||||||
Windows.DrawText(Data^._HDC, PChar(CheckListBox.Items[Data^.ItemID]), -1,
|
WideBuffer := Utf8Decode(CheckListBox.Items[Data^.ItemID]);
|
||||||
|
Windows.DrawText(Data^._HDC, PWideChar(WideBuffer), -1,
|
||||||
Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
|
Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
|
||||||
if Selected then begin
|
if not Enabled then
|
||||||
|
Windows.SetTextColor(Data^._HDC, OldColor)
|
||||||
|
else
|
||||||
|
if Selected then
|
||||||
|
begin
|
||||||
Windows.SetTextColor(Data^._HDC, OldColor);
|
Windows.SetTextColor(Data^._HDC, OldColor);
|
||||||
Windows.SetBkColor(Data^._HDC, OldBackColor);
|
Windows.SetBkColor(Data^._HDC, OldBackColor);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
begin
|
begin
|
||||||
Handle := ObjectToHwnd(Sender);
|
Handle := ObjectToHwnd(Sender);
|
||||||
case TLMessage(Message).Msg of
|
case TLMessage(Message).Msg of
|
||||||
|
|
||||||
LM_PAINT:
|
LM_PAINT:
|
||||||
CallWinCEPaintHandler;
|
CallWinCEPaintHandler;
|
||||||
{
|
|
||||||
LM_DRAWITEM:
|
LM_DRAWITEM:
|
||||||
begin
|
begin
|
||||||
with TLMDrawItems(Message) do
|
with TLMDrawItems(Message) do
|
||||||
@ -225,7 +239,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
|
|
||||||
LM_GETDLGCODE:
|
LM_GETDLGCODE:
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user