You've already forked lazarus-ccr
spktoolbar: Add checkbox support to SpkPopupMenu.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8727 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -5,7 +5,7 @@ unit SpkPopup;
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLType, Types, Classes, Controls, SysUtils, Graphics, Menus,
|
||||
LCLIntf, LCLType, Types, SysUtils, Classes, Controls, Graphics, Menus, StdCtrls,
|
||||
spkt_Const, SpkGUITools, SpkMath, SpkGraphTools, spkt_Appearance;
|
||||
|
||||
type
|
||||
@@ -30,8 +30,13 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Themes;
|
||||
|
||||
procedure TSpkPopupMenu.DrawItemHandler(Sender: TObject; ACanvas: TCanvas;
|
||||
ARect: TRect; AState: TOwnerDrawState);
|
||||
const
|
||||
CHECKBOX_STYLES: array[boolean] of TSpkCheckboxStyle = (cbsCheckbox, cbsRadioButton);
|
||||
var
|
||||
menuItem: TMenuItem;
|
||||
FrameColor: TColor = clNone;
|
||||
@@ -40,11 +45,13 @@ var
|
||||
TextColor: TColor;
|
||||
GradientType: TBackgroundKind;
|
||||
P: T2DIntPoint;
|
||||
R, Rgutter: T2DIntRect;
|
||||
R, Rgutter, Rcheck: T2DIntRect;
|
||||
Radius: Integer;
|
||||
x, y, wGutter, hText: Integer;
|
||||
iconSize: TSize;
|
||||
checkboxSize: TSize;
|
||||
isHot: Boolean;
|
||||
te: TThemedElementDetails;
|
||||
begin
|
||||
if FAppearance = nil then
|
||||
exit;
|
||||
@@ -114,6 +121,64 @@ begin
|
||||
TGUITools.DrawVLine(ACanvas, Rgutter.Right+1, R.Top, R.Bottom, FrameColor);
|
||||
end;
|
||||
|
||||
// Checkbox
|
||||
if menuItem.Checked then
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
Rcheck := T2DIntRect.Create(
|
||||
{$ELSE}
|
||||
Rcheck := Create2DIntRect(
|
||||
{$ENDIF}
|
||||
ARect.Left,
|
||||
ARect.Top,
|
||||
ARect.Left + wGutter,
|
||||
ARect.Bottom// - 1
|
||||
);
|
||||
FrameColor := FAppearance.Popup.CheckedFrameColor;
|
||||
ColorFrom := FAppearance.Popup.CheckedGradientFromColor;
|
||||
ColorTo := FAppearance.Popup.CheckedGradientToColor;
|
||||
GradientType := FAppearance.Popup.CheckedGradientType;
|
||||
TGUITools.DrawPopupItemRect(ACanvas, Rcheck, Radius, ColorFrom, ColorTo, GradientType);
|
||||
TGUITools.DrawHLine(ACanvas, Rcheck.Left, Rcheck.Right-1, Rcheck.Top, FrameColor);
|
||||
TGUITools.DrawHLine(ACanvas, Rcheck.Left, Rcheck.Right-1, Rcheck.Bottom-1, FrameColor);
|
||||
TGUITools.DrawVLine(ACanvas, Rcheck.Left, Rcheck.Top, Rcheck.Bottom-1, FrameColor);
|
||||
TGUITools.DrawVLine(ACanvas, Rcheck.Right-1, Rcheck.Top, Rcheck.Bottom-1, FrameColor);
|
||||
|
||||
if not Assigned(Images) or (menuItem.ImageIndex = -1) then
|
||||
begin
|
||||
if ThemeServices.ThemesEnabled then
|
||||
begin
|
||||
if menuItem.Enabled then
|
||||
begin
|
||||
if menuItem.RadioItem then
|
||||
te := ThemeServices.GetElementDetails(tmPopupBulletNormal)
|
||||
else
|
||||
te := ThemeServices.GetElementDetails(tmPopupCheckmarkNormal);
|
||||
end else
|
||||
begin
|
||||
if menuItem.RadioItem then
|
||||
te := ThemeServices.GetElementDetails(tmPopupBulletDisabled)
|
||||
else
|
||||
te := ThemeServices.GetElementDetails(tmPopupCheckmarkDisabled);
|
||||
end;
|
||||
ThemeServices.DrawElement(ACanvas.Handle, te, Rect(Rcheck.Left, Rcheck.Top, Rcheck.Right, Rcheck.Bottom));
|
||||
end else
|
||||
begin
|
||||
checkboxSize.CX := GetSystemMetrics(SM_CYMENUCHECK);
|
||||
checkboxSize.CY := GetSystemMetrics(SM_CXMENUCHECK);
|
||||
x := (Rcheck.Left + Rcheck.Right - checkboxSize.CX) div 2;
|
||||
y := (Rcheck.Top + Rcheck.Bottom - checkboxSize.CY) div 2;
|
||||
TGUITools.DrawCheckbox(
|
||||
ACanvas,
|
||||
x, y,
|
||||
cbChecked,
|
||||
bsIdle,
|
||||
CHECKBOX_STYLES[menuItem.RadioItem]
|
||||
);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Draw icon
|
||||
if Assigned(Images) and (menuItem.ImageIndex > -1) then
|
||||
begin
|
||||
|
||||
Reference in New Issue
Block a user