2006-03-24 05:56:59 +00:00
|
|
|
{
|
|
|
|
:: Implements a musikCube-style painter for the X2MenuBar.
|
|
|
|
::
|
2006-05-22 05:13:12 +00:00
|
|
|
:: Part of the X2Software Component Library
|
|
|
|
:: http://www.x2software.net/
|
|
|
|
::
|
2006-03-24 05:56:59 +00:00
|
|
|
:: Last changed: $Date$
|
|
|
|
:: Revision: $Rev$
|
|
|
|
:: Author: $Author$
|
|
|
|
}
|
2006-03-30 04:54:11 +00:00
|
|
|
unit X2CLmusikCubeMenuBarPainter;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
Classes,
|
|
|
|
Graphics,
|
|
|
|
ImgList,
|
|
|
|
Windows,
|
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
X2CLGraphics,
|
2006-03-24 05:56:59 +00:00
|
|
|
X2CLMenuBar;
|
|
|
|
|
|
|
|
type
|
|
|
|
TX2MenuBarmCColor = class(TPersistent)
|
|
|
|
private
|
2006-05-22 05:13:12 +00:00
|
|
|
FBorder: TX2Color32;
|
|
|
|
FFill: TX2Color32;
|
|
|
|
FDefaultBorder: TX2Color32;
|
|
|
|
FDefaultFill: TX2Color32;
|
|
|
|
FOnChange: TNotifyEvent;
|
|
|
|
|
|
|
|
procedure SetBorder(const Value: TX2Color32);
|
|
|
|
procedure SetFill(const Value: TX2Color32);
|
2009-04-22 14:22:01 +00:00
|
|
|
function IsBorderStored: Boolean;
|
|
|
|
function IsFillStored: Boolean;
|
2006-03-24 05:56:59 +00:00
|
|
|
protected
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
procedure SetDefaultColors(ABorder, AFill: TX2Color32);
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
property DefaultBorder: TX2Color32 read FDefaultBorder write FDefaultBorder;
|
|
|
|
property DefaultFill: TX2Color32 read FDefaultFill write FDefaultFill;
|
|
|
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
public
|
2006-04-17 18:41:43 +00:00
|
|
|
procedure Assign(Source: TPersistent); override;
|
2006-03-24 05:56:59 +00:00
|
|
|
published
|
2006-05-22 05:13:12 +00:00
|
|
|
property Border: TX2Color32 read FBorder write SetBorder stored IsBorderStored;
|
|
|
|
property Fill: TX2Color32 read FFill write SetFill stored IsFillStored;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TX2MenuBarmCColors = class(TPersistent)
|
|
|
|
private
|
|
|
|
FHot: TX2MenuBarmCColor;
|
|
|
|
FNormal: TX2MenuBarmCColor;
|
|
|
|
FSelected: TX2MenuBarmCColor;
|
|
|
|
FOnChange: TNotifyEvent;
|
|
|
|
|
|
|
|
procedure SetHot(const Value: TX2MenuBarmCColor);
|
|
|
|
procedure SetNormal(const Value: TX2MenuBarmCColor);
|
|
|
|
procedure SetSelected(const Value: TX2MenuBarmCColor);
|
|
|
|
protected
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
procedure ColorChange(Sender: TObject);
|
|
|
|
|
|
|
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
|
|
|
public
|
2009-04-22 14:22:01 +00:00
|
|
|
constructor Create;
|
|
|
|
destructor Destroy; override;
|
2006-04-17 18:41:43 +00:00
|
|
|
|
|
|
|
procedure Assign(Source: TPersistent); override;
|
2006-03-24 05:56:59 +00:00
|
|
|
published
|
|
|
|
property Hot: TX2MenuBarmCColor read FHot write SetHot;
|
|
|
|
property Normal: TX2MenuBarmCColor read FNormal write SetNormal;
|
|
|
|
property Selected: TX2MenuBarmCColor read FSelected write SetSelected;
|
|
|
|
end;
|
|
|
|
|
2012-09-24 14:45:27 +00:00
|
|
|
TImagePosition = (ipLeft, ipRight);
|
|
|
|
|
2006-04-01 19:51:46 +00:00
|
|
|
// #ToDo1 (MvR) 19-3-2006: Custom base class?
|
2006-03-30 04:54:11 +00:00
|
|
|
TX2MenuBarmusikCubePainter = class(TX2CustomMenuBarPainter)
|
2006-03-24 05:56:59 +00:00
|
|
|
private
|
|
|
|
FColor: TColor;
|
|
|
|
FGroupColors: TX2MenuBarmCColors;
|
|
|
|
FGroupHeight: Integer;
|
|
|
|
FIndicatorColors: TX2MenuBarmCColors;
|
|
|
|
FItemColors: TX2MenuBarmCColors;
|
|
|
|
FItemHeight: Integer;
|
2010-03-17 11:20:40 +00:00
|
|
|
FItemDisabledColor: TColor;
|
2012-09-24 14:45:27 +00:00
|
|
|
FImagePosition: TImagePosition;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
procedure SetColor(const Value: TColor);
|
|
|
|
procedure SetGroupColors(const Value: TX2MenuBarmCColors);
|
|
|
|
procedure SetGroupHeight(const Value: Integer);
|
|
|
|
procedure SetIndicatorColors(const Value: TX2MenuBarmCColors);
|
|
|
|
procedure SetItemColors(const Value: TX2MenuBarmCColors);
|
|
|
|
procedure SetItemHeight(const Value: Integer);
|
2010-03-17 11:20:40 +00:00
|
|
|
procedure SetItemDisabledColor(const Value: TColor);
|
2012-09-24 14:45:27 +00:00
|
|
|
procedure SetImagePosition(const Value: TImagePosition);
|
2006-03-24 05:56:59 +00:00
|
|
|
protected
|
|
|
|
procedure ColorChange(Sender: TObject);
|
|
|
|
|
|
|
|
function GetColor(AColors: TX2MenuBarmCColors; AState: TX2MenuBarDrawStates): TX2MenuBarmCColor;
|
|
|
|
procedure DrawBlended(ACanvas: TCanvas; AImageList: TCustomImageList; AX, AY, AImageIndex: Integer; AAlpha: Byte);
|
|
|
|
|
|
|
|
function GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer; override;
|
|
|
|
function GetItemHeight(AItem: TX2MenuBarItem): Integer; override;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure DrawBackground(ACanvas: TCanvas; const ABounds: TRect; const AOffset: TPoint); override;
|
2006-03-24 05:56:59 +00:00
|
|
|
procedure DrawGroupHeader(ACanvas: TCanvas; AGroup: TX2MenuBarGroup; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
|
|
|
|
procedure DrawItem(ACanvas: TCanvas; AItem: TX2MenuBarItem; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
2009-04-22 14:22:01 +00:00
|
|
|
destructor Destroy; override;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure ResetColors;
|
2006-03-24 05:56:59 +00:00
|
|
|
published
|
2010-03-17 11:20:40 +00:00
|
|
|
property Color: TColor read FColor write SetColor stored False;
|
|
|
|
property GroupColors: TX2MenuBarmCColors read FGroupColors write SetGroupColors stored False;
|
|
|
|
property GroupHeight: Integer read FGroupHeight write SetGroupHeight stored False;
|
2012-09-24 14:45:27 +00:00
|
|
|
property ImagePosition: TImagePosition read FImagePosition write SetImagePosition default ipLeft;
|
2010-03-17 11:20:40 +00:00
|
|
|
property IndicatorColors: TX2MenuBarmCColors read FIndicatorColors write SetIndicatorColors stored False;
|
|
|
|
property ItemColors: TX2MenuBarmCColors read FItemColors write SetItemColors stored False;
|
|
|
|
property ItemHeight: Integer read FItemHeight write SetItemHeight stored False;
|
|
|
|
property ItemDisabledColor: TColor read FItemDisabledColor write SetItemDisabledColor stored False;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
SysUtils;
|
|
|
|
|
|
|
|
|
|
|
|
{ TX2MenuBarmusikCubePainter }
|
|
|
|
constructor TX2MenuBarmusikCubePainter.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2010-03-17 11:20:40 +00:00
|
|
|
FColor := clBtnFace;
|
|
|
|
FItemDisabledColor := clGrayText;
|
|
|
|
FGroupColors := TX2MenuBarmCColors.Create;
|
|
|
|
FGroupHeight := 22;
|
2012-09-24 14:45:27 +00:00
|
|
|
FImagePosition := ipLeft;
|
2010-03-17 11:20:40 +00:00
|
|
|
FIndicatorColors := TX2MenuBarmCColors.Create;
|
|
|
|
FItemColors := TX2MenuBarmCColors.Create;
|
|
|
|
FItemHeight := 22;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
FGroupColors.OnChange := ColorChange;
|
|
|
|
FIndicatorColors.OnChange := ColorChange;
|
|
|
|
FItemColors.OnChange := ColorChange;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
ResetColors;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
destructor TX2MenuBarmusikCubePainter.Destroy;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
FreeAndNil(FItemColors);
|
2006-04-01 19:51:46 +00:00
|
|
|
FreeAndNil(FIndicatorColors);
|
2006-03-24 05:56:59 +00:00
|
|
|
FreeAndNil(FGroupColors);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure TX2MenuBarmusikCubePainter.ResetColors;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
{ Group buttons }
|
2006-05-22 05:13:12 +00:00
|
|
|
GroupColors.Hot.SetDefaultColors( Color32(clBtnShadow),
|
|
|
|
Color32(clBtnShadow, 128));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
GroupColors.Normal.SetDefaultColors( Color32(clBtnShadow, 64),
|
|
|
|
Color32(clBtnShadow, 64));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
GroupColors.Selected.SetDefaultColors(Color32(clBtnShadow),
|
|
|
|
Color32(clBtnHighlight));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
{ Indicator }
|
2006-05-22 05:13:12 +00:00
|
|
|
IndicatorColors.Selected.SetDefaultColors(Color32(clActiveCaption, 252),
|
|
|
|
Color32(clActiveCaption, 252));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
{ Item buttons }
|
2006-05-22 05:13:12 +00:00
|
|
|
ItemColors.Hot.SetDefaultColors( Color32(clBtnShadow),
|
|
|
|
Color32(clBtnHighlight, 114));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
ItemColors.Normal.SetDefaultColors( Color32(clBtnHighlight, 50),
|
|
|
|
Color32(clBtnHighlight, 50));
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
ItemColors.Selected.SetDefaultColors( Color32(clBtnShadow),
|
|
|
|
Color32(clBtnHighlight));
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2MenuBarmusikCubePainter.GetColor(AColors: TX2MenuBarmCColors;
|
|
|
|
AState: TX2MenuBarDrawStates): TX2MenuBarmCColor;
|
|
|
|
begin
|
|
|
|
if mdsSelected in AState then
|
|
|
|
Result := AColors.Selected
|
|
|
|
else if mdsHot in AState then
|
|
|
|
Result := AColors.Hot
|
|
|
|
else
|
|
|
|
Result := AColors.Normal;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.DrawBlended(ACanvas: TCanvas;
|
|
|
|
AImageList: TCustomImageList;
|
|
|
|
AX, AY, AImageIndex: Integer;
|
|
|
|
AAlpha: Byte);
|
|
|
|
var
|
|
|
|
backBuffer: Graphics.TBitmap;
|
|
|
|
iconBuffer: Graphics.TBitmap;
|
|
|
|
sourceRect: TRect;
|
|
|
|
destRect: TRect;
|
|
|
|
|
|
|
|
begin
|
2009-04-22 14:22:01 +00:00
|
|
|
backBuffer := Graphics.TBitmap.Create;
|
2006-03-24 05:56:59 +00:00
|
|
|
try
|
2006-04-01 19:51:46 +00:00
|
|
|
backBuffer.PixelFormat := pf32bit;
|
2006-03-24 05:56:59 +00:00
|
|
|
backBuffer.Width := AImageList.Width;
|
|
|
|
backBuffer.Height := AImageList.Height;
|
|
|
|
|
|
|
|
destRect := Rect(0, 0, backBuffer.Width, backBuffer.Height);
|
|
|
|
sourceRect := destRect;
|
|
|
|
OffsetRect(sourceRect, AX, AY);
|
|
|
|
backBuffer.Canvas.CopyRect(destRect, ACanvas, sourceRect);
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
iconBuffer := Graphics.TBitmap.Create;
|
2006-03-24 05:56:59 +00:00
|
|
|
try
|
|
|
|
iconBuffer.Assign(backBuffer);
|
|
|
|
AImageList.Draw(iconBuffer.Canvas, 0, 0, AImageIndex);
|
|
|
|
|
2007-04-02 14:49:00 +00:00
|
|
|
X2CLGraphics.DrawBlended(backBuffer, iconBuffer, AAlpha);
|
2006-03-24 05:56:59 +00:00
|
|
|
finally
|
|
|
|
FreeAndNil(iconBuffer);
|
|
|
|
end;
|
|
|
|
|
|
|
|
ACanvas.Draw(AX, AY, backBuffer);
|
|
|
|
finally
|
|
|
|
FreeAndNil(backBuffer);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2MenuBarmusikCubePainter.GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer;
|
|
|
|
begin
|
|
|
|
Result := FGroupHeight;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TX2MenuBarmusikCubePainter.GetItemHeight(AItem: TX2MenuBarItem): Integer;
|
|
|
|
begin
|
|
|
|
Result := FItemHeight;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.DrawBackground(ACanvas: TCanvas;
|
2009-04-22 14:22:01 +00:00
|
|
|
const ABounds: TRect;
|
|
|
|
const AOffset: TPoint);
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
with ACanvas do
|
|
|
|
begin
|
|
|
|
Brush.Color := FColor;
|
|
|
|
FillRect(ABounds);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.DrawGroupHeader(ACanvas: TCanvas;
|
|
|
|
AGroup: TX2MenuBarGroup;
|
|
|
|
const ABounds: TRect;
|
|
|
|
AState: TX2MenuBarDrawStates);
|
|
|
|
var
|
|
|
|
groupColor: TX2MenuBarmCColor;
|
|
|
|
textBounds: TRect;
|
|
|
|
|
|
|
|
begin
|
|
|
|
with ACanvas do
|
|
|
|
begin
|
|
|
|
groupColor := GetColor(GroupColors, AState);
|
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
Brush.Color := Blend(Color, groupColor.Fill);
|
2006-03-24 05:56:59 +00:00
|
|
|
Brush.Style := bsSolid;
|
2006-05-22 05:13:12 +00:00
|
|
|
Pen.Color := Blend(Color, groupColor.Border);
|
2006-03-24 05:56:59 +00:00
|
|
|
Pen.Style := psSolid;
|
|
|
|
Rectangle(ABounds);
|
|
|
|
|
|
|
|
textBounds := ABounds;
|
|
|
|
Inc(textBounds.Left, 12); // #ToDo3 (MvR) 19-3-2006: GroupIndent property?
|
2006-04-01 19:51:46 +00:00
|
|
|
Dec(textBounds.Right, 2);
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
ACanvas.Font.Style := [fsBold];
|
2006-04-02 20:00:02 +00:00
|
|
|
if AGroup.Enabled then
|
|
|
|
ACanvas.Font.Color := clWindowText
|
|
|
|
else
|
|
|
|
ACanvas.Font.Color := clGrayText;
|
|
|
|
|
2006-04-01 19:51:46 +00:00
|
|
|
DrawText(ACanvas, AGroup.Caption, textBounds, taLeftJustify,
|
|
|
|
taVerticalCenter, False, csEllipsis);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.DrawItem(ACanvas: TCanvas;
|
|
|
|
AItem: TX2MenuBarItem;
|
|
|
|
const ABounds: TRect;
|
|
|
|
AState: TX2MenuBarDrawStates);
|
|
|
|
var
|
|
|
|
itemColor: TX2MenuBarmCColor;
|
|
|
|
itemBounds: TRect;
|
|
|
|
indicatorBounds: TRect;
|
|
|
|
indicatorColor: TX2MenuBarmCColor;
|
|
|
|
textBounds: TRect;
|
|
|
|
imageList: TCustomImageList;
|
2012-09-24 14:45:27 +00:00
|
|
|
imgX: Integer;
|
2006-03-24 05:56:59 +00:00
|
|
|
imgY: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
with ACanvas do
|
|
|
|
begin
|
|
|
|
itemColor := GetColor(ItemColors, AState);
|
|
|
|
indicatorColor := GetColor(IndicatorColors, AState);
|
|
|
|
|
|
|
|
itemBounds := ABounds;
|
|
|
|
indicatorBounds := itemBounds;
|
|
|
|
indicatorBounds.Right := indicatorBounds.Left + 6;
|
2006-05-22 05:13:12 +00:00
|
|
|
Brush.Color := Blend(Color, indicatorColor.Fill);
|
2006-03-24 05:56:59 +00:00
|
|
|
Brush.Style := bsSolid;
|
2006-05-22 05:13:12 +00:00
|
|
|
Pen.Color := Blend(Color, indicatorColor.Border);
|
2006-03-24 05:56:59 +00:00
|
|
|
Pen.Style := psSolid;
|
|
|
|
Rectangle(itemBounds);
|
|
|
|
|
|
|
|
itemBounds.Left := indicatorBounds.Right;
|
2006-05-22 05:13:12 +00:00
|
|
|
Brush.Color := Blend(Color, itemColor.Fill);
|
2006-03-24 05:56:59 +00:00
|
|
|
Brush.Style := bsSolid;
|
2006-05-22 05:13:12 +00:00
|
|
|
Pen.Color := Blend(Color, itemColor.Border);
|
2006-03-24 05:56:59 +00:00
|
|
|
Pen.Style := psSolid;
|
|
|
|
Rectangle(itemBounds);
|
|
|
|
|
|
|
|
textBounds := itemBounds;
|
|
|
|
Inc(textBounds.Left, 4);
|
2012-09-24 14:45:27 +00:00
|
|
|
Dec(textBounds.Right, 4);
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2006-04-17 18:41:43 +00:00
|
|
|
imageList := MenuBar.Images;
|
2006-03-24 05:56:59 +00:00
|
|
|
if Assigned(imageList) then
|
|
|
|
begin
|
|
|
|
if AItem.ImageIndex > -1 then
|
|
|
|
begin
|
2012-09-24 14:45:27 +00:00
|
|
|
if ImagePosition = ipRight then
|
|
|
|
imgX := textBounds.Right - imageList.Width
|
|
|
|
else
|
|
|
|
imgX := textBounds.Left;
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
imgY := textBounds.Top + ((textBounds.Bottom - textBounds.Top -
|
|
|
|
imageList.Height) div 2);
|
|
|
|
|
|
|
|
if (mdsHot in AState) or (mdsSelected in AState) then
|
2012-09-24 14:45:27 +00:00
|
|
|
imageList.Draw(ACanvas, imgX, imgY, AItem.ImageIndex)
|
2006-03-24 05:56:59 +00:00
|
|
|
else
|
2012-09-24 14:45:27 +00:00
|
|
|
DrawBlended(ACanvas, imageList, imgX, imgY,
|
2006-03-24 05:56:59 +00:00
|
|
|
AItem.ImageIndex, 128);
|
2012-09-24 14:45:27 +00:00
|
|
|
|
|
|
|
if ImagePosition = ipRight then
|
|
|
|
Dec(textBounds.Right, imageList.Width + 4);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
2012-09-24 14:45:27 +00:00
|
|
|
if ImagePosition = ipLeft then
|
|
|
|
Inc(textBounds.Left, imageList.Width + 4);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
2010-03-17 11:20:40 +00:00
|
|
|
if AItem.Enabled then
|
|
|
|
ACanvas.Font.Color := clWindowText
|
|
|
|
else
|
|
|
|
ACanvas.Font.Color := ItemDisabledColor;
|
|
|
|
|
2006-04-02 20:00:02 +00:00
|
|
|
if not AItem.Visible then
|
|
|
|
{ Design-time }
|
|
|
|
ACanvas.Font.Style := [fsItalic]
|
|
|
|
else if mdsSelected in AState then
|
2006-03-24 05:56:59 +00:00
|
|
|
ACanvas.Font.Style := [fsBold]
|
|
|
|
else
|
|
|
|
ACanvas.Font.Style := [];
|
|
|
|
|
2006-04-02 20:00:02 +00:00
|
|
|
DrawText(ACanvas, AItem.Caption, textBounds, taLeftJustify, taVerticalCenter,
|
|
|
|
False, csEllipsis);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.ColorChange(Sender: TObject);
|
|
|
|
begin
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2012-09-24 14:45:27 +00:00
|
|
|
procedure TX2MenuBarmusikCubePainter.SetImagePosition(const Value: TImagePosition);
|
|
|
|
begin
|
|
|
|
if Value <> FImagePosition then
|
|
|
|
begin
|
|
|
|
FImagePosition := Value;
|
|
|
|
NotifyObservers;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
procedure TX2MenuBarmusikCubePainter.SetIndicatorColors(const Value: TX2MenuBarmCColors);
|
|
|
|
begin
|
|
|
|
if Value <> FIndicatorColors then
|
|
|
|
begin
|
|
|
|
FIndicatorColors.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.SetItemColors(const Value: TX2MenuBarmCColors);
|
|
|
|
begin
|
|
|
|
if Value <> FItemColors then
|
|
|
|
begin
|
|
|
|
FItemColors.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-03-17 11:20:40 +00:00
|
|
|
procedure TX2MenuBarmusikCubePainter.SetItemDisabledColor(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if Value <> FItemDisabledColor then
|
|
|
|
begin
|
|
|
|
FItemDisabledColor := Value;
|
|
|
|
NotifyObservers;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
procedure TX2MenuBarmusikCubePainter.SetItemHeight(const Value: Integer);
|
|
|
|
begin
|
|
|
|
if Value <> FItemHeight then
|
|
|
|
begin
|
|
|
|
FItemHeight := Value;
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.SetColor(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if Value <> FColor then
|
|
|
|
begin
|
|
|
|
FColor := Value;
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.SetGroupColors(const Value: TX2MenuBarmCColors);
|
|
|
|
begin
|
|
|
|
if Value <> FGroupColors then
|
|
|
|
begin
|
|
|
|
FGroupColors.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmusikCubePainter.SetGroupHeight(const Value: Integer);
|
|
|
|
begin
|
|
|
|
if Value <> FGroupHeight then
|
|
|
|
begin
|
|
|
|
FGroupHeight := Value;
|
2009-04-22 14:22:01 +00:00
|
|
|
NotifyObservers;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TX2MenuBarmCColor }
|
2006-04-17 18:41:43 +00:00
|
|
|
procedure TX2MenuBarmCColor.Assign(Source: TPersistent);
|
|
|
|
begin
|
|
|
|
if Source is TX2MenuBarmCColor then
|
|
|
|
with TX2MenuBarmCColor(Source) do
|
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
Self.DefaultBorder := DefaultBorder;
|
|
|
|
Self.DefaultFill := DefaultFill;
|
|
|
|
Self.Border := Border;
|
|
|
|
Self.Fill := Fill;
|
2006-04-17 18:41:43 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure TX2MenuBarmCColor.DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FOnChange) then
|
|
|
|
FOnChange(Self);
|
|
|
|
end;
|
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
procedure TX2MenuBarmCColor.SetDefaultColors(ABorder, AFill: TX2Color32);
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
FDefaultBorder := ABorder;
|
|
|
|
FDefaultFill := AFill;
|
|
|
|
FBorder := ABorder;
|
|
|
|
FFill := AFill;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
function TX2MenuBarmCColor.IsBorderStored: Boolean;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
Result := (FBorder <> FDefaultBorder);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
function TX2MenuBarmCColor.IsFillStored: Boolean;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
Result := (FFill <> FDefaultFill);
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
procedure TX2MenuBarmCColor.SetBorder(const Value: TX2Color32);
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
if Value <> FBorder then
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
FBorder := Value;
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2006-05-22 05:13:12 +00:00
|
|
|
procedure TX2MenuBarmCColor.SetFill(const Value: TX2Color32);
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
if Value <> FFill then
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
2006-05-22 05:13:12 +00:00
|
|
|
FFill := Value;
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TX2MenuBarmCColors }
|
2009-04-22 14:22:01 +00:00
|
|
|
constructor TX2MenuBarmCColors.Create;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
FHot := TX2MenuBarmCColor.Create;
|
|
|
|
FNormal := TX2MenuBarmCColor.Create;
|
|
|
|
FSelected := TX2MenuBarmCColor.Create;
|
2006-03-24 05:56:59 +00:00
|
|
|
|
|
|
|
FHot.OnChange := ColorChange;
|
|
|
|
FNormal.OnChange := ColorChange;
|
|
|
|
FSelected.OnChange := ColorChange;
|
|
|
|
end;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
destructor TX2MenuBarmCColors.Destroy;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
FreeAndNil(FSelected);
|
|
|
|
FreeAndNil(FNormal);
|
|
|
|
FreeAndNil(FHot);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2006-04-17 18:41:43 +00:00
|
|
|
procedure TX2MenuBarmCColors.Assign(Source: TPersistent);
|
|
|
|
begin
|
|
|
|
if Source is TX2MenuBarmCColors then
|
|
|
|
with TX2MenuBarmCColors(Source) do
|
|
|
|
begin
|
|
|
|
Self.Hot.Assign(Hot);
|
|
|
|
Self.Normal.Assign(Normal);
|
|
|
|
Self.Selected.Assign(Selected);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2006-03-24 05:56:59 +00:00
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
procedure TX2MenuBarmCColors.DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FOnChange) then
|
|
|
|
FOnChange(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmCColors.ColorChange(Sender: TObject);
|
|
|
|
begin
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2MenuBarmCColors.SetHot(const Value: TX2MenuBarmCColor);
|
|
|
|
begin
|
|
|
|
if FHot <> Value then
|
|
|
|
begin
|
|
|
|
FHot.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmCColors.SetNormal(const Value: TX2MenuBarmCColor);
|
|
|
|
begin
|
|
|
|
if FNormal <> Value then
|
|
|
|
begin
|
|
|
|
FNormal.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TX2MenuBarmCColors.SetSelected(const Value: TX2MenuBarmCColor);
|
|
|
|
begin
|
|
|
|
if FNormal <> Value then
|
|
|
|
begin
|
|
|
|
FSelected.Assign(Value);
|
2009-04-22 14:22:01 +00:00
|
|
|
DoChange;
|
2006-03-24 05:56:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-04-22 14:22:01 +00:00
|
|
|
end.
|