1
0
mirror of synced 2024-11-22 01:53:50 +00:00

Added: support for a background image in the UnameIT menubar painter

This commit is contained in:
Mark van Renswoude 2009-04-22 14:22:01 +00:00
parent a9c1bcc0d6
commit 57ba59dc96
8 changed files with 852 additions and 415 deletions

View File

@ -31,9 +31,9 @@
-M -M
-$M16384,1048576 -$M16384,1048576
-K$00400000 -K$00400000
-N"P:\algemeen\lib" -N"P:\algemeen\lib\D7"
-LE"P:\algemeen\bin" -LE"P:\algemeen\bin\D7"
-LN"P:\algemeen\lib" -LN"P:\algemeen\lib\D7"
-Z -Z
-w-UNSAFE_TYPE -w-UNSAFE_TYPE
-w-UNSAFE_CODE -w-UNSAFE_CODE

View File

@ -105,10 +105,6 @@ HostApplication=
Launcher= Launcher=
UseLauncher=0 UseLauncher=0
DebugCWD= DebugCWD=
[Language]
ActiveLang=
ProjectLang=
RootDir=C:\Program Files\Borland\Delphi7\Bin\
[Version Info] [Version Info]
IncludeVerInfo=1 IncludeVerInfo=1
AutoIncBuild=0 AutoIncBuild=0
@ -154,6 +150,7 @@ Item0=$(DELPHIBIN)
Item1=..\..\Lib\D7 Item1=..\..\Lib\D7
Item2=Lib\D7 Item2=Lib\D7
[HistoryLists\hlDCPOutput] [HistoryLists\hlDCPOutput]
Count=2 Count=3
Item0=$(DELPHILIB) Item0=$(DELPHIBIN)
Item1=..\..\Lib\D7 Item1=$(DELPHILIB)
Item2=..\..\Lib\D7

View File

@ -130,8 +130,6 @@ OriginalFilename=
ProductName= ProductName=
ProductVersion=1.0.0.0 ProductVersion=1.0.0.0
Comments= Comments=
[Excluded Packages]
C:\Program Files\Borland\Indy\D7\dclIndy70.bpl=Internet Direct (Indy) for D7 Property and Component Editors
[HistoryLists\hlUnitAliases] [HistoryLists\hlUnitAliases]
Count=1 Count=1
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;

File diff suppressed because it is too large Load Diff

View File

@ -25,18 +25,18 @@ type
public public
constructor Create(AMenuBar: TX2CustomMenuBar; AGroup: TX2MenuBarGroup; constructor Create(AMenuBar: TX2CustomMenuBar; AGroup: TX2MenuBarGroup;
AAnimator: TX2CustomMenuBarAnimator); AAnimator: TX2CustomMenuBarAnimator);
destructor Destroy(); override; destructor Destroy; override;
procedure Start(); override; procedure Start; override;
procedure BeforePaint(); override; procedure BeforePaint; override;
procedure GetItemHeight(AItem: TX2CustomMenuBarItem; var AHeight: Integer; procedure GetItemHeight(AItem: TX2CustomMenuBarItem; var AHeight: Integer;
var AHandled: Boolean); override; var AHandled: Boolean); override;
procedure DrawMenuItem(ACanvas: TCanvas; APainter: TX2CustomMenuBarPainter; procedure DrawMenuItem(ACanvas: TCanvas; APainter: TX2CustomMenuBarPainter;
AItem: TX2CustomMenuBarItem; const AMenuBounds: TRect; AItem: TX2CustomMenuBarItem; const AMenuBounds: TRect;
const AItemBounds: TRect; AState: TX2MenuBarDrawStates; const AItemBounds: TRect; AState: TX2MenuBarDrawStates;
var AHandled: Boolean); override; var AHandled: Boolean); override;
procedure AfterPaint(); override; procedure AfterPaint; override;
end; end;
@ -49,26 +49,26 @@ type
private private
FAnimateActions: TObjectList; FAnimateActions: TObjectList;
function GetCount(): Integer; function GetCount: Integer;
protected protected
function GetAnimateAction(AIndex: Integer): TX2MenuBarAnimateAction; function GetAnimateAction(AIndex: Integer): TX2MenuBarAnimateAction;
function GetTerminated(): Boolean; override; function GetTerminated: Boolean; override;
property AnimateActions: TObjectList read FAnimateActions; property AnimateActions: TObjectList read FAnimateActions;
public public
constructor Create(AMenuBar: TX2CustomMenuBar); constructor Create(AMenuBar: TX2CustomMenuBar);
destructor Destroy(); override; destructor Destroy; override;
procedure Add(AAction: TX2MenuBarAnimateAction); procedure Add(AAction: TX2MenuBarAnimateAction);
procedure BeforePaint(); override; procedure BeforePaint; override;
procedure GetItemHeight(AItem: TX2CustomMenuBarItem; var AHeight: Integer; procedure GetItemHeight(AItem: TX2CustomMenuBarItem; var AHeight: Integer;
var AHandled: Boolean); override; var AHandled: Boolean); override;
procedure DrawMenuItem(ACanvas: TCanvas; APainter: TX2CustomMenuBarPainter; procedure DrawMenuItem(ACanvas: TCanvas; APainter: TX2CustomMenuBarPainter;
AItem: TX2CustomMenuBarItem; const AMenuBounds: TRect; AItem: TX2CustomMenuBarItem; const AMenuBounds: TRect;
const AItemBounds: TRect; AState: TX2MenuBarDrawStates; const AItemBounds: TRect; AState: TX2MenuBarDrawStates;
var AHandled: Boolean); override; var AHandled: Boolean); override;
procedure AfterPaint(); override; procedure AfterPaint; override;
property Count: Integer read GetCount; property Count: Integer read GetCount;
end; end;
@ -88,7 +88,7 @@ type
constructor Create(AMenuBar: TX2CustomMenuBar; AGroup: TX2MenuBarGroup; constructor Create(AMenuBar: TX2CustomMenuBar; AGroup: TX2MenuBarGroup;
AExpanding: Boolean); AExpanding: Boolean);
procedure Start(); override; procedure Start; override;
end; end;
@ -104,7 +104,7 @@ type
public public
constructor Create(AMenuBar: TX2CustomMenuBar; AItem: TX2CustomMenuBarItem); constructor Create(AMenuBar: TX2CustomMenuBar; AItem: TX2CustomMenuBarItem);
procedure Start(); override; procedure Start; override;
end; end;
@ -131,7 +131,7 @@ begin
end; end;
destructor TX2MenuBarAnimateAction.Destroy(); destructor TX2MenuBarAnimateAction.Destroy;
begin begin
FreeAndNil(FAnimator); FreeAndNil(FAnimator);
@ -139,21 +139,21 @@ begin
end; end;
procedure TX2MenuBarAnimateAction.Start(); procedure TX2MenuBarAnimateAction.Start;
begin begin
inherited; inherited;
Animator.ResetStartTime(); Animator.ResetStartTime;
end; end;
procedure TX2MenuBarAnimateAction.BeforePaint(); procedure TX2MenuBarAnimateAction.BeforePaint;
begin begin
inherited; inherited;
Animator.Update(); Animator.Update;
if Animator.Terminated then if Animator.Terminated then
Terminate(); Terminate;
end; end;
@ -196,7 +196,7 @@ begin
end; end;
procedure TX2MenuBarAnimateAction.AfterPaint(); procedure TX2MenuBarAnimateAction.AfterPaint;
begin begin
inherited; inherited;
@ -205,8 +205,8 @@ begin
{ Prevent 100% CPU usage } { Prevent 100% CPU usage }
Sleep(5); Sleep(5);
TProtectedX2CustomMenuBar(MenuBar).TestMousePos(); TProtectedX2CustomMenuBar(MenuBar).TestMousePos;
MenuBar.Invalidate(); MenuBar.Invalidate;
end; end;
end; end;
@ -220,7 +220,7 @@ begin
end; end;
destructor TX2MenuBarAnimateMultipleAction.Destroy(); destructor TX2MenuBarAnimateMultipleAction.Destroy;
begin begin
FreeAndNil(FAnimateActions); FreeAndNil(FAnimateActions);
@ -234,7 +234,7 @@ begin
end; end;
procedure TX2MenuBarAnimateMultipleAction.BeforePaint(); procedure TX2MenuBarAnimateMultipleAction.BeforePaint;
var var
actionIndex: Integer; actionIndex: Integer;
@ -242,7 +242,7 @@ begin
inherited; inherited;
for actionIndex := 0 to Pred(AnimateActions.Count) do for actionIndex := 0 to Pred(AnimateActions.Count) do
GetAnimateAction(actionIndex).BeforePaint(); GetAnimateAction(actionIndex).BeforePaint;
end; end;
@ -289,7 +289,7 @@ begin
end; end;
procedure TX2MenuBarAnimateMultipleAction.AfterPaint(); procedure TX2MenuBarAnimateMultipleAction.AfterPaint;
var var
actionIndex: Integer; actionIndex: Integer;
@ -297,7 +297,7 @@ begin
inherited; inherited;
for actionIndex := 0 to Pred(AnimateActions.Count) do for actionIndex := 0 to Pred(AnimateActions.Count) do
GetAnimateAction(actionIndex).AfterPaint(); GetAnimateAction(actionIndex).AfterPaint;
end; end;
@ -307,18 +307,18 @@ begin
end; end;
function TX2MenuBarAnimateMultipleAction.GetCount(): Integer; function TX2MenuBarAnimateMultipleAction.GetCount: Integer;
begin begin
Result := FAnimateActions.Count; Result := FAnimateActions.Count;
end; end;
function TX2MenuBarAnimateMultipleAction.GetTerminated(): Boolean; function TX2MenuBarAnimateMultipleAction.GetTerminated: Boolean;
var var
actionIndex: Integer; actionIndex: Integer;
begin begin
Result := inherited GetTerminated(); Result := inherited GetTerminated;
if not Result then if not Result then
begin begin
@ -344,12 +344,12 @@ begin
end; end;
procedure TX2MenuBarExpandAction.Start(); procedure TX2MenuBarExpandAction.Start;
begin begin
inherited; inherited;
TProtectedX2CustomMenuBar(MenuBar).InternalSetExpanded(FGroup, FExpanding); TProtectedX2CustomMenuBar(MenuBar).InternalSetExpanded(FGroup, FExpanding);
Terminate(); Terminate;
end; end;
@ -363,13 +363,12 @@ begin
end; end;
procedure TX2MenuBarSelectAction.Start(); procedure TX2MenuBarSelectAction.Start;
begin begin
inherited; inherited;
TProtectedX2CustomMenuBar(MenuBar).InternalSetSelected(FItem); TProtectedX2CustomMenuBar(MenuBar).InternalSetSelected(FItem);
Terminate(); Terminate;
end; end;
end. end.

View File

@ -27,9 +27,9 @@ type
private private
FSlideHeight: Integer; FSlideHeight: Integer;
protected protected
function GetHeight(): Integer; override; function GetHeight: Integer; override;
public public
procedure Update(); override; procedure Update; override;
procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override; procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override;
end; end;
@ -47,10 +47,10 @@ type
property ItemsState: Graphics.TBitmap read FItemsState; property ItemsState: Graphics.TBitmap read FItemsState;
property Mask: Graphics.TBitmap read FMask; property Mask: Graphics.TBitmap read FMask;
public public
constructor Create(AItemsBuffer: Graphics.TBitmap); override; constructor Create(AItemsBuffer: TX2CustomMenuBarAnimatorBuffer); override;
destructor Destroy(); override; destructor Destroy; override;
procedure Update(); override; procedure Update; override;
procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override; procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override;
end; end;
@ -61,9 +61,7 @@ type
private private
FAlpha: Byte; FAlpha: Byte;
public public
constructor Create(AItemsBuffer: Graphics.TBitmap); override; procedure Update; override;
procedure Update(); override;
procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override; procedure Draw(ACanvas: TCanvas; const ABounds: TRect); override;
end; end;
@ -74,9 +72,9 @@ type
private private
FSlideHeight: Integer; FSlideHeight: Integer;
protected protected
function GetHeight(): Integer; override; function GetHeight: Integer; override;
public public
procedure Update(); override; procedure Update; override;
end; end;
implementation implementation
@ -87,12 +85,12 @@ uses
{ TX2MenuBarSlideAnimator } { TX2MenuBarSlideAnimator }
function TX2MenuBarSlideAnimator.GetHeight(): Integer; function TX2MenuBarSlideAnimator.GetHeight: Integer;
begin begin
Result := FSlideHeight; Result := FSlideHeight;
end; end;
procedure TX2MenuBarSlideAnimator.Update(); procedure TX2MenuBarSlideAnimator.Update;
var var
elapsed: Cardinal; elapsed: Cardinal;
@ -108,7 +106,7 @@ begin
FSlideHeight := 0; FSlideHeight := 0;
if elapsed >= AnimationTime then if elapsed >= AnimationTime then
Terminate(); Terminate;
end; end;
procedure TX2MenuBarSlideAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect); procedure TX2MenuBarSlideAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect);
@ -121,12 +119,12 @@ begin
destRect := ABounds; destRect := ABounds;
destRect.Bottom := destRect.Top + FSlideHeight; destRect.Bottom := destRect.Top + FSlideHeight;
ACanvas.CopyRect(destRect, ItemsBuffer.Canvas, sourceRect); ACanvas.CopyRect(destRect, ItemsBuffer.Bitmap.Canvas, sourceRect);
end; end;
{ TX2MenuBarDissolveAnimator } { TX2MenuBarDissolveAnimator }
constructor TX2MenuBarDissolveAnimator.Create(AItemsBuffer: Graphics.TBitmap); constructor TX2MenuBarDissolveAnimator.Create(AItemsBuffer: TX2CustomMenuBarAnimatorBuffer);
var var
pixelIndex: Integer; pixelIndex: Integer;
pixelPos: Integer; pixelPos: Integer;
@ -138,20 +136,20 @@ begin
{ The bitmaps need to be 32-bits since we'll be accessing the scanlines as { The bitmaps need to be 32-bits since we'll be accessing the scanlines as
one big array, not by using Scanline on each row. In 24-bit mode, the one big array, not by using Scanline on each row. In 24-bit mode, the
scanlines are still aligned on a 32-bits boundary, thus causing problems. } scanlines are still aligned on a 32-bits boundary, thus causing problems. }
ItemsBuffer.PixelFormat := pf32bit; ItemsBuffer.Bitmap.PixelFormat := pf32bit;
FMask := Graphics.TBitmap.Create(); FMask := Graphics.TBitmap.Create;
FMask.PixelFormat := pf32bit; FMask.PixelFormat := pf32bit;
FMask.Width := AItemsBuffer.Width; FMask.Width := AItemsBuffer.Width;
FMask.Height := AItemsBuffer.Height; FMask.Height := AItemsBuffer.Height;
FItemsState := Graphics.TBitmap.Create(); FItemsState := Graphics.TBitmap.Create;
FItemsState.PixelFormat := pf32bit; FItemsState.PixelFormat := pf32bit;
FItemsState.Width := AItemsBuffer.Width; FItemsState.Width := AItemsBuffer.Width;
FItemsState.Height := AItemsBuffer.Height; FItemsState.Height := AItemsBuffer.Height;
if RandSeed = 0 then if RandSeed = 0 then
Randomize(); Randomize;
{ Prepare an array of pixel indices which will be used to pick random { Prepare an array of pixel indices which will be used to pick random
unique pixels in the Update method. unique pixels in the Update method.
@ -160,7 +158,7 @@ begin
be randomly picked and deleted in Update. Now we pre-shuffle the list, be randomly picked and deleted in Update. Now we pre-shuffle the list,
then Delete only from the end, which does not reallocate or move any then Delete only from the end, which does not reallocate or move any
memory (TList.Count decreases, Capacity stays the same), a LOT faster. } memory (TList.Count decreases, Capacity stays the same), a LOT faster. }
FPixels := TList.Create(); FPixels := TList.Create;
FPixels.Count := AItemsBuffer.Width * AItemsBuffer.Height; FPixels.Count := AItemsBuffer.Width * AItemsBuffer.Height;
for pixelIndex := Pred(FPixels.Count) downto 0 do for pixelIndex := Pred(FPixels.Count) downto 0 do
@ -178,7 +176,7 @@ begin
end; end;
end; end;
destructor TX2MenuBarDissolveAnimator.Destroy(); destructor TX2MenuBarDissolveAnimator.Destroy;
begin begin
FreeAndNil(FItemsState); FreeAndNil(FItemsState);
FreeAndNil(FMask); FreeAndNil(FMask);
@ -187,7 +185,7 @@ begin
end; end;
procedure TX2MenuBarDissolveAnimator.Update(); procedure TX2MenuBarDissolveAnimator.Update;
const const
RGBBlack: TRGBQuad = (rgbBlue: 0; RGBBlack: TRGBQuad = (rgbBlue: 0;
rgbGreen: 0; rgbGreen: 0;
@ -225,7 +223,7 @@ begin
itemsPixels := nil; itemsPixels := nil;
if Expanding then if Expanding then
itemsPixels := GetScanlinePointer(ItemsBuffer); itemsPixels := GetScanlinePointer(ItemsBuffer.Bitmap);
for pixel := Pred(FPixels.Count - pixelsRemaining) downto 0 do for pixel := Pred(FPixels.Count - pixelsRemaining) downto 0 do
begin begin
@ -248,7 +246,7 @@ begin
end; end;
if elapsed >= AnimationTime then if elapsed >= AnimationTime then
Terminate(); Terminate;
end; end;
procedure TX2MenuBarDissolveAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect); procedure TX2MenuBarDissolveAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect);
@ -290,7 +288,7 @@ begin
begin begin
{ Start with a visible group } { Start with a visible group }
FMask.Canvas.Brush.Color := clBlack; FMask.Canvas.Brush.Color := clBlack;
FItemsState.Canvas.Draw(0, 0, ItemsBuffer); FItemsState.Canvas.Draw(0, 0, ItemsBuffer.Bitmap);
end; end;
FMask.Canvas.FillRect(Rect(0, 0, FMask.Width, FMask.Height)); FMask.Canvas.FillRect(Rect(0, 0, FMask.Width, FMask.Height));
@ -300,15 +298,7 @@ end;
{ TX2MenuBarFadeAnimator } { TX2MenuBarFadeAnimator }
constructor TX2MenuBarFadeAnimator.Create(AItemsBuffer: Graphics.TBitmap); procedure TX2MenuBarFadeAnimator.Update;
begin
inherited;
ItemsBuffer.PixelFormat := pf32bit;
end;
procedure TX2MenuBarFadeAnimator.Update();
var var
elapsed: Cardinal; elapsed: Cardinal;
newAlpha: Integer; newAlpha: Integer;
@ -326,7 +316,7 @@ begin
FAlpha := newAlpha; FAlpha := newAlpha;
if elapsed >= AnimationTime then if elapsed >= AnimationTime then
Terminate(); Terminate;
end; end;
procedure TX2MenuBarFadeAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect); procedure TX2MenuBarFadeAnimator.Draw(ACanvas: TCanvas; const ABounds: TRect);
@ -339,20 +329,21 @@ begin
if ABounds.Bottom - ABounds.Top <= 0 then if ABounds.Bottom - ABounds.Top <= 0 then
exit; exit;
backBuffer := Graphics.TBitmap.Create(); backBuffer := Graphics.TBitmap.Create;
try try
backBuffer.PixelFormat := pf32bit; backBuffer.PixelFormat := pf32bit;
backBuffer.Width := ItemsBuffer.Width; backBuffer.Width := ItemsBuffer.Width;
backBuffer.Height := ItemsBuffer.Height; backBuffer.Height := ItemsBuffer.Height;
destRect := Rect(0, 0, backBuffer.Width, backBuffer.Height); destRect := Rect(0, 0, backBuffer.Width, ABounds.Bottom - ABounds.Top);
backBuffer.Canvas.CopyRect(destRect, ACanvas, ABounds); backBuffer.Canvas.CopyRect(destRect, ACanvas, ABounds);
X2CLGraphics.DrawBlended(backBuffer, ItemsBuffer, FAlpha); X2CLGraphics.DrawBlended(backBuffer, ItemsBuffer.Bitmap, FAlpha);
sourceRect := Rect(0, 0, ItemsBuffer.Width, Self.Height); sourceRect := Rect(0, 0, ItemsBuffer.Width, Self.Height);
destRect := ABounds; destRect := ABounds;
destRect.Bottom := destRect.Top + Self.Height; destRect.Bottom := destRect.Top + Self.Height;
ACanvas.CopyRect(destRect, backBuffer.Canvas, sourceRect); ACanvas.CopyRect(destRect, backBuffer.Canvas, sourceRect);
finally finally
FreeAndNil(backBuffer); FreeAndNil(backBuffer);
@ -361,12 +352,12 @@ end;
{ TX2MenuBarSlideFadeAnimator } { TX2MenuBarSlideFadeAnimator }
function TX2MenuBarSlideFadeAnimator.GetHeight(): Integer; function TX2MenuBarSlideFadeAnimator.GetHeight: Integer;
begin begin
Result := FSlideHeight; Result := FSlideHeight;
end; end;
procedure TX2MenuBarSlideFadeAnimator.Update(); procedure TX2MenuBarSlideFadeAnimator.Update;
var var
elapsed: Cardinal; elapsed: Cardinal;

View File

@ -31,10 +31,10 @@ type
procedure SetBorder(const Value: TX2Color32); procedure SetBorder(const Value: TX2Color32);
procedure SetFill(const Value: TX2Color32); procedure SetFill(const Value: TX2Color32);
function IsBorderStored(): Boolean; function IsBorderStored: Boolean;
function IsFillStored(): Boolean; function IsFillStored: Boolean;
protected protected
procedure DoChange(); procedure DoChange;
procedure SetDefaultColors(ABorder, AFill: TX2Color32); procedure SetDefaultColors(ABorder, AFill: TX2Color32);
@ -59,13 +59,13 @@ type
procedure SetNormal(const Value: TX2MenuBarmCColor); procedure SetNormal(const Value: TX2MenuBarmCColor);
procedure SetSelected(const Value: TX2MenuBarmCColor); procedure SetSelected(const Value: TX2MenuBarmCColor);
protected protected
procedure DoChange(); procedure DoChange;
procedure ColorChange(Sender: TObject); procedure ColorChange(Sender: TObject);
property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChange: TNotifyEvent read FOnChange write FOnChange;
public public
constructor Create(); constructor Create;
destructor Destroy(); override; destructor Destroy; override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
published published
@ -99,14 +99,14 @@ type
function GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer; override; function GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer; override;
function GetItemHeight(AItem: TX2MenuBarItem): Integer; override; function GetItemHeight(AItem: TX2MenuBarItem): Integer; override;
procedure DrawBackground(ACanvas: TCanvas; const ABounds: TRect); override; procedure DrawBackground(ACanvas: TCanvas; const ABounds: TRect; const AOffset: TPoint); override;
procedure DrawGroupHeader(ACanvas: TCanvas; AGroup: TX2MenuBarGroup; const ABounds: TRect; AState: TX2MenuBarDrawStates); override; procedure DrawGroupHeader(ACanvas: TCanvas; AGroup: TX2MenuBarGroup; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
procedure DrawItem(ACanvas: TCanvas; AItem: TX2MenuBarItem; const ABounds: TRect; AState: TX2MenuBarDrawStates); override; procedure DrawItem(ACanvas: TCanvas; AItem: TX2MenuBarItem; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy(); override; destructor Destroy; override;
procedure ResetColors(); procedure ResetColors;
published published
property Color: TColor read FColor write SetColor stored False; property Color: TColor read FColor write SetColor stored False;
property GroupColors: TX2MenuBarmCColors read FGroupColors write SetGroupColors stored False; property GroupColors: TX2MenuBarmCColors read FGroupColors write SetGroupColors stored False;
@ -127,20 +127,20 @@ begin
inherited; inherited;
FColor := clBtnFace; FColor := clBtnFace;
FGroupColors := TX2MenuBarmCColors.Create(); FGroupColors := TX2MenuBarmCColors.Create;
FGroupHeight := 22; FGroupHeight := 22;
FIndicatorColors := TX2MenuBarmCColors.Create(); FIndicatorColors := TX2MenuBarmCColors.Create;
FItemColors := TX2MenuBarmCColors.Create(); FItemColors := TX2MenuBarmCColors.Create;
FItemHeight := 22; FItemHeight := 22;
FGroupColors.OnChange := ColorChange; FGroupColors.OnChange := ColorChange;
FIndicatorColors.OnChange := ColorChange; FIndicatorColors.OnChange := ColorChange;
FItemColors.OnChange := ColorChange; FItemColors.OnChange := ColorChange;
ResetColors(); ResetColors;
end; end;
destructor TX2MenuBarmusikCubePainter.Destroy(); destructor TX2MenuBarmusikCubePainter.Destroy;
begin begin
FreeAndNil(FItemColors); FreeAndNil(FItemColors);
FreeAndNil(FIndicatorColors); FreeAndNil(FIndicatorColors);
@ -150,7 +150,7 @@ begin
end; end;
procedure TX2MenuBarmusikCubePainter.ResetColors(); procedure TX2MenuBarmusikCubePainter.ResetColors;
begin begin
{ Group buttons } { Group buttons }
GroupColors.Hot.SetDefaultColors( Color32(clBtnShadow), GroupColors.Hot.SetDefaultColors( Color32(clBtnShadow),
@ -200,7 +200,7 @@ var
destRect: TRect; destRect: TRect;
begin begin
backBuffer := Graphics.TBitmap.Create(); backBuffer := Graphics.TBitmap.Create;
try try
backBuffer.PixelFormat := pf32bit; backBuffer.PixelFormat := pf32bit;
backBuffer.Width := AImageList.Width; backBuffer.Width := AImageList.Width;
@ -211,7 +211,7 @@ begin
OffsetRect(sourceRect, AX, AY); OffsetRect(sourceRect, AX, AY);
backBuffer.Canvas.CopyRect(destRect, ACanvas, sourceRect); backBuffer.Canvas.CopyRect(destRect, ACanvas, sourceRect);
iconBuffer := Graphics.TBitmap.Create(); iconBuffer := Graphics.TBitmap.Create;
try try
iconBuffer.Assign(backBuffer); iconBuffer.Assign(backBuffer);
AImageList.Draw(iconBuffer.Canvas, 0, 0, AImageIndex); AImageList.Draw(iconBuffer.Canvas, 0, 0, AImageIndex);
@ -240,7 +240,8 @@ end;
procedure TX2MenuBarmusikCubePainter.DrawBackground(ACanvas: TCanvas; procedure TX2MenuBarmusikCubePainter.DrawBackground(ACanvas: TCanvas;
const ABounds: TRect); const ABounds: TRect;
const AOffset: TPoint);
begin begin
with ACanvas do with ACanvas do
begin begin
@ -355,7 +356,7 @@ end;
procedure TX2MenuBarmusikCubePainter.ColorChange(Sender: TObject); procedure TX2MenuBarmusikCubePainter.ColorChange(Sender: TObject);
begin begin
NotifyObservers(); NotifyObservers;
end; end;
@ -364,7 +365,7 @@ begin
if Value <> FIndicatorColors then if Value <> FIndicatorColors then
begin begin
FIndicatorColors.Assign(Value); FIndicatorColors.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -373,7 +374,7 @@ begin
if Value <> FItemColors then if Value <> FItemColors then
begin begin
FItemColors.Assign(Value); FItemColors.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -382,7 +383,7 @@ begin
if Value <> FItemHeight then if Value <> FItemHeight then
begin begin
FItemHeight := Value; FItemHeight := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -391,7 +392,7 @@ begin
if Value <> FColor then if Value <> FColor then
begin begin
FColor := Value; FColor := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -400,7 +401,7 @@ begin
if Value <> FGroupColors then if Value <> FGroupColors then
begin begin
FGroupColors.Assign(Value); FGroupColors.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -409,7 +410,7 @@ begin
if Value <> FGroupHeight then if Value <> FGroupHeight then
begin begin
FGroupHeight := Value; FGroupHeight := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -430,7 +431,7 @@ begin
end; end;
procedure TX2MenuBarmCColor.DoChange(); procedure TX2MenuBarmCColor.DoChange;
begin begin
if Assigned(FOnChange) then if Assigned(FOnChange) then
FOnChange(Self); FOnChange(Self);
@ -445,12 +446,12 @@ begin
end; end;
function TX2MenuBarmCColor.IsBorderStored(): Boolean; function TX2MenuBarmCColor.IsBorderStored: Boolean;
begin begin
Result := (FBorder <> FDefaultBorder); Result := (FBorder <> FDefaultBorder);
end; end;
function TX2MenuBarmCColor.IsFillStored(): Boolean; function TX2MenuBarmCColor.IsFillStored: Boolean;
begin begin
Result := (FFill <> FDefaultFill); Result := (FFill <> FDefaultFill);
end; end;
@ -460,7 +461,7 @@ begin
if Value <> FBorder then if Value <> FBorder then
begin begin
FBorder := Value; FBorder := Value;
DoChange(); DoChange;
end; end;
end; end;
@ -469,26 +470,26 @@ begin
if Value <> FFill then if Value <> FFill then
begin begin
FFill := Value; FFill := Value;
DoChange(); DoChange;
end; end;
end; end;
{ TX2MenuBarmCColors } { TX2MenuBarmCColors }
constructor TX2MenuBarmCColors.Create(); constructor TX2MenuBarmCColors.Create;
begin begin
inherited; inherited;
FHot := TX2MenuBarmCColor.Create(); FHot := TX2MenuBarmCColor.Create;
FNormal := TX2MenuBarmCColor.Create(); FNormal := TX2MenuBarmCColor.Create;
FSelected := TX2MenuBarmCColor.Create(); FSelected := TX2MenuBarmCColor.Create;
FHot.OnChange := ColorChange; FHot.OnChange := ColorChange;
FNormal.OnChange := ColorChange; FNormal.OnChange := ColorChange;
FSelected.OnChange := ColorChange; FSelected.OnChange := ColorChange;
end; end;
destructor TX2MenuBarmCColors.Destroy(); destructor TX2MenuBarmCColors.Destroy;
begin begin
FreeAndNil(FSelected); FreeAndNil(FSelected);
FreeAndNil(FNormal); FreeAndNil(FNormal);
@ -511,7 +512,7 @@ begin
end; end;
procedure TX2MenuBarmCColors.DoChange(); procedure TX2MenuBarmCColors.DoChange;
begin begin
if Assigned(FOnChange) then if Assigned(FOnChange) then
FOnChange(Self); FOnChange(Self);
@ -519,7 +520,7 @@ end;
procedure TX2MenuBarmCColors.ColorChange(Sender: TObject); procedure TX2MenuBarmCColors.ColorChange(Sender: TObject);
begin begin
DoChange(); DoChange;
end; end;
@ -528,7 +529,7 @@ begin
if FHot <> Value then if FHot <> Value then
begin begin
FHot.Assign(Value); FHot.Assign(Value);
DoChange(); DoChange;
end; end;
end; end;
@ -537,7 +538,7 @@ begin
if FNormal <> Value then if FNormal <> Value then
begin begin
FNormal.Assign(Value); FNormal.Assign(Value);
DoChange(); DoChange;
end; end;
end; end;
@ -546,7 +547,7 @@ begin
if FNormal <> Value then if FNormal <> Value then
begin begin
FSelected.Assign(Value); FSelected.Assign(Value);
DoChange(); DoChange;
end; end;
end; end;

View File

@ -1,3 +1,215 @@
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
{$WARN SYMBOL_DEPRECATED ON}
{$WARN SYMBOL_LIBRARY ON}
{$WARN SYMBOL_PLATFORM ON}
{$WARN UNIT_LIBRARY ON}
{$WARN UNIT_PLATFORM ON}
{$WARN UNIT_DEPRECATED ON}
{$WARN HRESULT_COMPAT ON}
{$WARN HIDING_MEMBER ON}
{$WARN HIDDEN_VIRTUAL ON}
{$WARN GARBAGE ON}
{$WARN BOUNDS_ERROR ON}
{$WARN ZERO_NIL_COMPAT ON}
{$WARN STRING_CONST_TRUNCED ON}
{$WARN FOR_LOOP_VAR_VARPAR ON}
{$WARN TYPED_CONST_VARPAR ON}
{$WARN ASG_TO_TYPED_CONST ON}
{$WARN CASE_LABEL_RANGE ON}
{$WARN FOR_VARIABLE ON}
{$WARN CONSTRUCTING_ABSTRACT ON}
{$WARN COMPARISON_FALSE ON}
{$WARN COMPARISON_TRUE ON}
{$WARN COMPARING_SIGNED_UNSIGNED ON}
{$WARN COMBINING_SIGNED_UNSIGNED ON}
{$WARN UNSUPPORTED_CONSTRUCT ON}
{$WARN FILE_OPEN ON}
{$WARN FILE_OPEN_UNITSRC ON}
{$WARN BAD_GLOBAL_SYMBOL ON}
{$WARN DUPLICATE_CTOR_DTOR ON}
{$WARN INVALID_DIRECTIVE ON}
{$WARN PACKAGE_NO_LINK ON}
{$WARN PACKAGED_THREADVAR ON}
{$WARN IMPLICIT_IMPORT ON}
{$WARN HPPEMIT_IGNORED ON}
{$WARN NO_RETVAL ON}
{$WARN USE_BEFORE_DEF ON}
{$WARN FOR_LOOP_VAR_UNDEF ON}
{$WARN UNIT_NAME_MISMATCH ON}
{$WARN NO_CFG_FILE_FOUND ON}
{$WARN MESSAGE_DIRECTIVE ON}
{$WARN IMPLICIT_VARIANTS ON}
{$WARN UNICODE_TO_LOCALE ON}
{$WARN LOCALE_TO_UNICODE ON}
{$WARN IMAGEBASE_MULTIPLE ON}
{$WARN SUSPICIOUS_TYPECAST ON}
{$WARN PRIVATE_PROPACCESSOR ON}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_CAST OFF}
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
{$WARN SYMBOL_DEPRECATED ON}
{$WARN SYMBOL_LIBRARY ON}
{$WARN SYMBOL_PLATFORM ON}
{$WARN UNIT_LIBRARY ON}
{$WARN UNIT_PLATFORM ON}
{$WARN UNIT_DEPRECATED ON}
{$WARN HRESULT_COMPAT ON}
{$WARN HIDING_MEMBER ON}
{$WARN HIDDEN_VIRTUAL ON}
{$WARN GARBAGE ON}
{$WARN BOUNDS_ERROR ON}
{$WARN ZERO_NIL_COMPAT ON}
{$WARN STRING_CONST_TRUNCED ON}
{$WARN FOR_LOOP_VAR_VARPAR ON}
{$WARN TYPED_CONST_VARPAR ON}
{$WARN ASG_TO_TYPED_CONST ON}
{$WARN CASE_LABEL_RANGE ON}
{$WARN FOR_VARIABLE ON}
{$WARN CONSTRUCTING_ABSTRACT ON}
{$WARN COMPARISON_FALSE ON}
{$WARN COMPARISON_TRUE ON}
{$WARN COMPARING_SIGNED_UNSIGNED ON}
{$WARN COMBINING_SIGNED_UNSIGNED ON}
{$WARN UNSUPPORTED_CONSTRUCT ON}
{$WARN FILE_OPEN ON}
{$WARN FILE_OPEN_UNITSRC ON}
{$WARN BAD_GLOBAL_SYMBOL ON}
{$WARN DUPLICATE_CTOR_DTOR ON}
{$WARN INVALID_DIRECTIVE ON}
{$WARN PACKAGE_NO_LINK ON}
{$WARN PACKAGED_THREADVAR ON}
{$WARN IMPLICIT_IMPORT ON}
{$WARN HPPEMIT_IGNORED ON}
{$WARN NO_RETVAL ON}
{$WARN USE_BEFORE_DEF ON}
{$WARN FOR_LOOP_VAR_UNDEF ON}
{$WARN UNIT_NAME_MISMATCH ON}
{$WARN NO_CFG_FILE_FOUND ON}
{$WARN MESSAGE_DIRECTIVE ON}
{$WARN IMPLICIT_VARIANTS ON}
{$WARN UNICODE_TO_LOCALE ON}
{$WARN LOCALE_TO_UNICODE ON}
{$WARN IMAGEBASE_MULTIPLE ON}
{$WARN SUSPICIOUS_TYPECAST ON}
{$WARN PRIVATE_PROPACCESSOR ON}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_CAST OFF}
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
{$WARN SYMBOL_DEPRECATED ON}
{$WARN SYMBOL_LIBRARY ON}
{$WARN SYMBOL_PLATFORM ON}
{$WARN UNIT_LIBRARY ON}
{$WARN UNIT_PLATFORM ON}
{$WARN UNIT_DEPRECATED ON}
{$WARN HRESULT_COMPAT ON}
{$WARN HIDING_MEMBER ON}
{$WARN HIDDEN_VIRTUAL ON}
{$WARN GARBAGE ON}
{$WARN BOUNDS_ERROR ON}
{$WARN ZERO_NIL_COMPAT ON}
{$WARN STRING_CONST_TRUNCED ON}
{$WARN FOR_LOOP_VAR_VARPAR ON}
{$WARN TYPED_CONST_VARPAR ON}
{$WARN ASG_TO_TYPED_CONST ON}
{$WARN CASE_LABEL_RANGE ON}
{$WARN FOR_VARIABLE ON}
{$WARN CONSTRUCTING_ABSTRACT ON}
{$WARN COMPARISON_FALSE ON}
{$WARN COMPARISON_TRUE ON}
{$WARN COMPARING_SIGNED_UNSIGNED ON}
{$WARN COMBINING_SIGNED_UNSIGNED ON}
{$WARN UNSUPPORTED_CONSTRUCT ON}
{$WARN FILE_OPEN ON}
{$WARN FILE_OPEN_UNITSRC ON}
{$WARN BAD_GLOBAL_SYMBOL ON}
{$WARN DUPLICATE_CTOR_DTOR ON}
{$WARN INVALID_DIRECTIVE ON}
{$WARN PACKAGE_NO_LINK ON}
{$WARN PACKAGED_THREADVAR ON}
{$WARN IMPLICIT_IMPORT ON}
{$WARN HPPEMIT_IGNORED ON}
{$WARN NO_RETVAL ON}
{$WARN USE_BEFORE_DEF ON}
{$WARN FOR_LOOP_VAR_UNDEF ON}
{$WARN UNIT_NAME_MISMATCH ON}
{$WARN NO_CFG_FILE_FOUND ON}
{$WARN MESSAGE_DIRECTIVE ON}
{$WARN IMPLICIT_VARIANTS ON}
{$WARN UNICODE_TO_LOCALE ON}
{$WARN LOCALE_TO_UNICODE ON}
{$WARN IMAGEBASE_MULTIPLE ON}
{$WARN SUSPICIOUS_TYPECAST ON}
{$WARN PRIVATE_PROPACCESSOR ON}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_CAST OFF}
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
{$WARN SYMBOL_DEPRECATED ON}
{$WARN SYMBOL_LIBRARY ON}
{$WARN SYMBOL_PLATFORM ON}
{$WARN UNIT_LIBRARY ON}
{$WARN UNIT_PLATFORM ON}
{$WARN UNIT_DEPRECATED ON}
{$WARN HRESULT_COMPAT ON}
{$WARN HIDING_MEMBER ON}
{$WARN HIDDEN_VIRTUAL ON}
{$WARN GARBAGE ON}
{$WARN BOUNDS_ERROR ON}
{$WARN ZERO_NIL_COMPAT ON}
{$WARN STRING_CONST_TRUNCED ON}
{$WARN FOR_LOOP_VAR_VARPAR ON}
{$WARN TYPED_CONST_VARPAR ON}
{$WARN ASG_TO_TYPED_CONST ON}
{$WARN CASE_LABEL_RANGE ON}
{$WARN FOR_VARIABLE ON}
{$WARN CONSTRUCTING_ABSTRACT ON}
{$WARN COMPARISON_FALSE ON}
{$WARN COMPARISON_TRUE ON}
{$WARN COMPARING_SIGNED_UNSIGNED ON}
{$WARN COMBINING_SIGNED_UNSIGNED ON}
{$WARN UNSUPPORTED_CONSTRUCT ON}
{$WARN FILE_OPEN ON}
{$WARN FILE_OPEN_UNITSRC ON}
{$WARN BAD_GLOBAL_SYMBOL ON}
{$WARN DUPLICATE_CTOR_DTOR ON}
{$WARN INVALID_DIRECTIVE ON}
{$WARN PACKAGE_NO_LINK ON}
{$WARN PACKAGED_THREADVAR ON}
{$WARN IMPLICIT_IMPORT ON}
{$WARN HPPEMIT_IGNORED ON}
{$WARN NO_RETVAL ON}
{$WARN USE_BEFORE_DEF ON}
{$WARN FOR_LOOP_VAR_UNDEF ON}
{$WARN UNIT_NAME_MISMATCH ON}
{$WARN NO_CFG_FILE_FOUND ON}
{$WARN MESSAGE_DIRECTIVE ON}
{$WARN IMPLICIT_VARIANTS ON}
{$WARN UNICODE_TO_LOCALE ON}
{$WARN LOCALE_TO_UNICODE ON}
{$WARN IMAGEBASE_MULTIPLE ON}
{$WARN SUSPICIOUS_TYPECAST ON}
{$WARN PRIVATE_PROPACCESSOR ON}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_CAST OFF}
{ {
:: Implements a Uname-IT-style painter for the X2MenuBar. :: Implements a Uname-IT-style painter for the X2MenuBar.
:: ::
@ -24,7 +236,7 @@ type
private private
FOnChange: TNotifyEvent; FOnChange: TNotifyEvent;
protected protected
procedure Changed(); procedure Changed;
public public
property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChange: TNotifyEvent read FOnChange write FOnChange;
end; end;
@ -41,10 +253,10 @@ type
FNormal: TColor; FNormal: TColor;
FSelected: TColor; FSelected: TColor;
function IsDisabledStored(): Boolean; function IsDisabledStored: Boolean;
function IsHotStored(): Boolean; function IsHotStored: Boolean;
function IsNormalStored(): Boolean; function IsNormalStored: Boolean;
function IsSelectedStored(): Boolean; function IsSelectedStored: Boolean;
procedure SetDisabled(const Value: TColor); procedure SetDisabled(const Value: TColor);
procedure SetHot(const Value: TColor); procedure SetHot(const Value: TColor);
procedure SetNormal(const Value: TColor); procedure SetNormal(const Value: TColor);
@ -78,7 +290,7 @@ type
protected protected
procedure ColorChange(Sender: TObject); procedure ColorChange(Sender: TObject);
public public
constructor Create(); constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
@ -115,7 +327,7 @@ type
procedure SetImageOffsetX(const Value: Integer); procedure SetImageOffsetX(const Value: Integer);
procedure SetImageOffsetY(const Value: Integer); procedure SetImageOffsetY(const Value: Integer);
public public
constructor Create(); constructor Create;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
published published
@ -133,19 +345,26 @@ type
end; end;
THorzAlignment = (haLeft, haCenter, haRight);
TVertAlignment = (vaTop, vaCenter, vaBottom);
TX2MenuBarunaPainter = class(TX2CustomMenuBarPainter) TX2MenuBarunaPainter = class(TX2CustomMenuBarPainter)
private private
FArrowColor: TColor; FArrowColor: TColor;
FBlurShadow: Boolean; FBlurShadow: Boolean;
FColor: TColor; FColor: TColor;
FGroupColors: TX2MenuBarunaGroupColors; FGroupColors: TX2MenuBarunaGroupColors;
FItemColors: TX2MenuBarunaColor; FItemColors: TX2MenuBarunaColor;
FMetrics: TX2MenuBarunaMetrics; FMetrics: TX2MenuBarunaMetrics;
FShadowColor: TColor; FShadowColor: TColor;
FShadowOffset: Integer; FShadowOffset: Integer;
FGroupGradient: Integer; FGroupGradient: Integer;
FArrowImages: TCustomImageList; FArrowImages: TCustomImageList;
FArrowImageIndex: TImageIndex; FArrowImageIndex: TImageIndex;
FBackground: TPicture;
FBackgroundHorzAlignment: THorzAlignment;
FBackgroundVertAlignment: TVertAlignment;
procedure SetBlurShadow(const Value: Boolean); procedure SetBlurShadow(const Value: Boolean);
procedure SetGroupColors(const Value: TX2MenuBarunaGroupColors); procedure SetGroupColors(const Value: TX2MenuBarunaGroupColors);
@ -156,17 +375,22 @@ type
procedure SetGroupGradient(const Value: Integer); procedure SetGroupGradient(const Value: Integer);
procedure SetArrowImageIndex(const Value: TImageIndex); procedure SetArrowImageIndex(const Value: TImageIndex);
procedure SetArrowImages(const Value: TCustomImageList); procedure SetArrowImages(const Value: TCustomImageList);
procedure SetBackground(const Value: TPicture);
procedure SetBackgroundHorzAlignment(const Value: THorzAlignment);
procedure SetBackgroundVertAlignment(const Value: TVertAlignment);
protected protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
function HasArrowImage(): Boolean; function HasArrowImage: Boolean;
function ApplyMargins(const ABounds: TRect): TRect; override; function ApplyMargins(const ABounds: TRect): TRect; override;
function UndoMargins(const ABounds: TRect): TRect; override;
function GetSpacing(AElement: TX2MenuBarSpacingElement): Integer; override; function GetSpacing(AElement: TX2MenuBarSpacingElement): Integer; override;
function GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer; override; function GetGroupHeaderHeight(AGroup: TX2MenuBarGroup): Integer; override;
function GetItemHeight(AItem: TX2MenuBarItem): Integer; override; function GetItemHeight(AItem: TX2MenuBarItem): Integer; override;
procedure DrawBackground(ACanvas: TCanvas; const ABounds: TRect); override; procedure DrawBackground(ACanvas: TCanvas; const ABounds: TRect; const AOffset: TPoint); override;
procedure DrawGroupHeader(ACanvas: TCanvas; AGroup: TX2MenuBarGroup; const ABounds: TRect; AState: TX2MenuBarDrawStates); override; procedure DrawGroupHeader(ACanvas: TCanvas; AGroup: TX2MenuBarGroup; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
procedure DrawItem(ACanvas: TCanvas; AItem: TX2MenuBarItem; const ABounds: TRect; AState: TX2MenuBarDrawStates); override; procedure DrawItem(ACanvas: TCanvas; AItem: TX2MenuBarItem; const ABounds: TRect; AState: TX2MenuBarDrawStates); override;
procedure DrawArrow(ACanvas: TCanvas; ABounds: TRect); procedure DrawArrow(ACanvas: TCanvas; ABounds: TRect);
@ -174,21 +398,24 @@ type
procedure ColorChange(Sender: TObject); procedure ColorChange(Sender: TObject);
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy(); override; destructor Destroy; override;
procedure ResetColors(); procedure ResetColors;
published published
property ArrowImageIndex: TImageIndex read FArrowImageIndex write SetArrowImageIndex default -1; property ArrowColor: TColor read FArrowColor write FArrowColor default clBlue;
property ArrowImages: TCustomImageList read FArrowImages write SetArrowImages; property ArrowImageIndex: TImageIndex read FArrowImageIndex write SetArrowImageIndex default -1;
property ArrowColor: TColor read FArrowColor write FArrowColor default clBlue; property ArrowImages: TCustomImageList read FArrowImages write SetArrowImages;
property BlurShadow: Boolean read FBlurShadow write SetBlurShadow default True; property Background: TPicture read FBackground write SetBackground;
property Color: TColor read FColor write FColor default clWindow; property BackgroundHorzAlignment: THorzAlignment read FBackgroundHorzAlignment write SetBackgroundHorzAlignment default haLeft;
property GroupColors: TX2MenuBarunaGroupColors read FGroupColors write SetGroupColors; property BackgroundVertAlignment: TVertAlignment read FBackgroundVertAlignment write SetBackgroundVertAlignment default vaTop;
property ItemColors: TX2MenuBarunaColor read FItemColors write SetItemColors; property BlurShadow: Boolean read FBlurShadow write SetBlurShadow default True;
property Metrics: TX2MenuBarunaMetrics read FMetrics write SetMetrics; property Color: TColor read FColor write FColor default clWindow;
property ShadowColor: TColor read FShadowColor write SetShadowColor default clBtnShadow; property GroupColors: TX2MenuBarunaGroupColors read FGroupColors write SetGroupColors;
property ShadowOffset: Integer read FShadowOffset write SetShadowOffset default 2; property GroupGradient: Integer read FGroupGradient write SetGroupGradient default 0;
property GroupGradient: Integer read FGroupGradient write SetGroupGradient default 0; property ItemColors: TX2MenuBarunaColor read FItemColors write SetItemColors;
property Metrics: TX2MenuBarunaMetrics read FMetrics write SetMetrics;
property ShadowColor: TColor read FShadowColor write SetShadowColor default clBtnShadow;
property ShadowOffset: Integer read FShadowOffset write SetShadowOffset default 2;
end; end;
implementation implementation
@ -221,7 +448,7 @@ var
begin begin
ASource.PixelFormat := pf32bit; ASource.PixelFormat := pf32bit;
refBitmap := Graphics.TBitmap.Create(); refBitmap := Graphics.TBitmap.Create;
try try
refBitmap.Assign(ASource); refBitmap.Assign(ASource);
@ -297,7 +524,7 @@ end;
{ TX2MenuBarunaMetrics } { TX2MenuBarunaMetrics }
constructor TX2MenuBarunaMetrics.Create(); constructor TX2MenuBarunaMetrics.Create;
begin begin
inherited; inherited;
@ -338,7 +565,7 @@ begin
if Value <> FAfterGroupHeader then if Value <> FAfterGroupHeader then
begin begin
FAfterGroupHeader := Value; FAfterGroupHeader := Value;
Changed(); Changed;
end; end;
end; end;
@ -347,7 +574,7 @@ begin
if Value <> FAfterItem then if Value <> FAfterItem then
begin begin
FAfterItem := Value; FAfterItem := Value;
Changed(); Changed;
end; end;
end; end;
@ -356,7 +583,7 @@ begin
if Value <> FAfterLastItem then if Value <> FAfterLastItem then
begin begin
FAfterLastItem := Value; FAfterLastItem := Value;
Changed(); Changed;
end; end;
end; end;
@ -365,7 +592,7 @@ begin
if Value <> FBeforeFirstItem then if Value <> FBeforeFirstItem then
begin begin
FBeforeFirstItem := Value; FBeforeFirstItem := Value;
Changed(); Changed;
end; end;
end; end;
@ -374,7 +601,7 @@ begin
if Value <> FBeforeGroupHeader then if Value <> FBeforeGroupHeader then
begin begin
FBeforeGroupHeader := Value; FBeforeGroupHeader := Value;
Changed(); Changed;
end; end;
end; end;
@ -383,7 +610,7 @@ begin
if Value <> FBeforeItem then if Value <> FBeforeItem then
begin begin
FBeforeItem := Value; FBeforeItem := Value;
Changed(); Changed;
end; end;
end; end;
@ -392,7 +619,7 @@ begin
if Value <> FGroupHeight then if Value <> FGroupHeight then
begin begin
FGroupHeight := Value; FGroupHeight := Value;
Changed(); Changed;
end; end;
end; end;
@ -401,7 +628,7 @@ begin
if Value <> FItemHeight then if Value <> FItemHeight then
begin begin
FItemHeight := Value; FItemHeight := Value;
Changed(); Changed;
end; end;
end; end;
@ -410,7 +637,7 @@ begin
if Value <> FMargin then if Value <> FMargin then
begin begin
FMargin := Value; FMargin := Value;
Changed(); Changed;
end; end;
end; end;
@ -420,7 +647,7 @@ begin
if Value <> FImageOffsetX then if Value <> FImageOffsetX then
begin begin
FImageOffsetX := Value; FImageOffsetX := Value;
Changed(); Changed;
end; end;
end; end;
@ -430,7 +657,7 @@ begin
if Value <> FImageOffsetY then if Value <> FImageOffsetY then
begin begin
FImageOffsetY := Value; FImageOffsetY := Value;
Changed(); Changed;
end; end;
end; end;
@ -442,21 +669,26 @@ begin
FArrowImageIndex := -1; FArrowImageIndex := -1;
FBlurShadow := True; FBlurShadow := True;
FGroupColors := TX2MenuBarunaGroupColors.Create(); FGroupColors := TX2MenuBarunaGroupColors.Create;
FItemColors := TX2MenuBarunaColor.Create(); FItemColors := TX2MenuBarunaColor.Create;
FMetrics := TX2MenuBarunaMetrics.Create(); FMetrics := TX2MenuBarunaMetrics.Create;
FShadowOffset := 2; FShadowOffset := 2;
FBackground := TPicture.Create;
FBackgroundHorzAlignment := haLeft;
FBackgroundVertAlignment := vaTop;
FGroupColors.OnChange := ColorChange; FGroupColors.OnChange := ColorChange;
FItemColors.OnChange := ColorChange; FItemColors.OnChange := ColorChange;
FMetrics.OnChange := ColorChange; FMetrics.OnChange := ColorChange;
ResetColors(); ResetColors;
end; end;
destructor TX2MenuBarunaPainter.Destroy(); destructor TX2MenuBarunaPainter.Destroy;
begin begin
SetArrowImages(nil); SetArrowImages(nil);
FreeAndNil(FBackground);
FreeAndNil(FMetrics); FreeAndNil(FMetrics);
FreeAndNil(FItemColors); FreeAndNil(FItemColors);
FreeAndNil(FGroupColors); FreeAndNil(FGroupColors);
@ -465,7 +697,7 @@ begin
end; end;
procedure TX2MenuBarunaPainter.ResetColors(); procedure TX2MenuBarunaPainter.ResetColors;
const const
PurpleBlue = $00BE6363; PurpleBlue = $00BE6363;
@ -497,7 +729,7 @@ begin
if Value <> FBlurShadow then if Value <> FBlurShadow then
begin begin
FBlurShadow := Value; FBlurShadow := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -508,6 +740,14 @@ begin
InflateRect(Result, -Metrics.Margin, -Metrics.Margin); InflateRect(Result, -Metrics.Margin, -Metrics.Margin);
end; end;
function TX2MenuBarunaPainter.UndoMargins(const ABounds: TRect): TRect;
begin
Result := inherited UndoMargins(ABounds);
InflateRect(Result, Metrics.Margin, Metrics.Margin);
end;
function TX2MenuBarunaPainter.GetSpacing(AElement: TX2MenuBarSpacingElement): Integer; function TX2MenuBarunaPainter.GetSpacing(AElement: TX2MenuBarSpacingElement): Integer;
begin begin
Result := inherited GetSpacing(AElement); Result := inherited GetSpacing(AElement);
@ -534,12 +774,38 @@ end;
procedure TX2MenuBarunaPainter.DrawBackground(ACanvas: TCanvas; procedure TX2MenuBarunaPainter.DrawBackground(ACanvas: TCanvas;
const ABounds: TRect); const ABounds: TRect;
const AOffset: TPoint);
var
pos: TPoint;
begin begin
ACanvas.Brush.Color := Self.Color; ACanvas.Brush.Color := Self.Color;
ACanvas.FillRect(ABounds); ACanvas.FillRect(ABounds);
if (Background.Width > 0) and
(Background.Height > 0) then
begin
case BackgroundHorzAlignment of
haLeft: pos.X := 0;
haCenter: pos.X := (MenuBar.ClientWidth - Background.Width) div 2;
haRight: pos.X := ABounds.Right - Background.Width;
end;
case BackgroundVertAlignment of
vaTop: pos.Y := 0;
vaCenter: pos.Y := (MenuBar.ClientHeight - Background.Height) div 2;
vaBottom: pos.Y := MenuBar.ClientHeight - Background.Height;
end;
Dec(pos.X, AOffset.X);
Dec(pos.Y, AOffset.Y);
ACanvas.Draw(pos.X, pos.Y, Background.Graphic);
end;
end; end;
procedure TX2MenuBarunaPainter.DrawGroupHeader(ACanvas: TCanvas; procedure TX2MenuBarunaPainter.DrawGroupHeader(ACanvas: TCanvas;
AGroup: TX2MenuBarGroup; AGroup: TX2MenuBarGroup;
const ABounds: TRect; const ABounds: TRect;
@ -579,6 +845,7 @@ var
clipRegion: HRGN; clipRegion: HRGN;
startColor: TColor; startColor: TColor;
endColor: TColor; endColor: TColor;
groupOffset: TPoint;
begin begin
if not ((mdsSelected in AState) or (mdsGroupSelected in AState)) then if not ((mdsSelected in AState) or (mdsGroupSelected in AState)) then
@ -586,14 +853,16 @@ begin
{ Shadow } { Shadow }
if BlurShadow then if BlurShadow then
begin begin
shadowBitmap := Graphics.TBitmap.Create(); shadowBitmap := Graphics.TBitmap.Create;
try try
shadowBitmap.PixelFormat := pf32bit; shadowBitmap.PixelFormat := pf32bit;
shadowBitmap.Width := (ABounds.Right - ABounds.Left + (ShadowMargin * 2)); shadowBitmap.Width := (ABounds.Right - ABounds.Left + (ShadowMargin * 2));
shadowBitmap.Height := (ABounds.Bottom - ABounds.Top + (ShadowMargin * 2)); shadowBitmap.Height := (ABounds.Bottom - ABounds.Top + (ShadowMargin * 2));
DrawBackground(shadowBitmap.Canvas, Rect(0, 0, shadowBitmap.Width, shadowBounds := Rect(0, 0, shadowBitmap.Width, shadowBitmap.Height);
shadowBitmap.Height)); groupOffset := ABounds.TopLeft;
DrawBackground(shadowBitmap.Canvas, shadowBounds, groupOffset);
DrawShadowOutline(shadowBitmap.Canvas, Rect(0, 0, shadowBitmap.Width - (ShadowMargin * 2), DrawShadowOutline(shadowBitmap.Canvas, Rect(0, 0, shadowBitmap.Width - (ShadowMargin * 2),
shadowBitmap.Height - (ShadowMargin * 2))); shadowBitmap.Height - (ShadowMargin * 2)));
@ -690,7 +959,7 @@ var
begin begin
focusBounds := ABounds; focusBounds := ABounds;
if HasArrowImage() then if HasArrowImage then
Dec(focusBounds.Right, ArrowImages.Width + ArrowMargin) Dec(focusBounds.Right, ArrowImages.Width + ArrowMargin)
else else
Dec(focusBounds.Right, ArrowWidth + ArrowMargin); Dec(focusBounds.Right, ArrowWidth + ArrowMargin);
@ -727,7 +996,7 @@ var
arrowPoints: array[0..2] of TPoint; arrowPoints: array[0..2] of TPoint;
begin begin
if HasArrowImage() then if HasArrowImage then
begin begin
arrowX := ABounds.Right - ArrowImages.Width; arrowX := ABounds.Right - ArrowImages.Width;
arrowY := ABounds.Top + ((ABounds.Bottom - ABounds.Top - ArrowImages.Height) div 2); arrowY := ABounds.Top + ((ABounds.Bottom - ABounds.Top - ArrowImages.Height) div 2);
@ -750,11 +1019,11 @@ end;
procedure TX2MenuBarunaPainter.ColorChange(Sender: TObject); procedure TX2MenuBarunaPainter.ColorChange(Sender: TObject);
begin begin
NotifyObservers(); NotifyObservers;
end; end;
function TX2MenuBarunaPainter.HasArrowImage(): Boolean; function TX2MenuBarunaPainter.HasArrowImage: Boolean;
begin begin
Result := Assigned(ArrowImages) and (ArrowImageIndex > -1); Result := Assigned(ArrowImages) and (ArrowImageIndex > -1);
end; end;
@ -774,7 +1043,7 @@ begin
if Value <> FGroupColors then if Value <> FGroupColors then
begin begin
FGroupColors.Assign(Value); FGroupColors.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -783,7 +1052,7 @@ begin
if Value <> FItemColors then if Value <> FItemColors then
begin begin
FItemColors.Assign(Value); FItemColors.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -792,7 +1061,7 @@ begin
if Value <> FMetrics then if Value <> FMetrics then
begin begin
FMetrics.Assign(Value); FMetrics.Assign(Value);
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -801,7 +1070,7 @@ begin
if Value <> FShadowColor then if Value <> FShadowColor then
begin begin
FShadowColor := Value; FShadowColor := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -810,7 +1079,7 @@ begin
if Value <> FShadowOffset then if Value <> FShadowOffset then
begin begin
FShadowOffset := Value; FShadowOffset := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -820,7 +1089,7 @@ begin
if Value <> FGroupGradient then if Value <> FGroupGradient then
begin begin
FGroupGradient := Value; FGroupGradient := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -830,7 +1099,7 @@ begin
if Value <> FArrowImageIndex then if Value <> FArrowImageIndex then
begin begin
FArrowImageIndex := Value; FArrowImageIndex := Value;
NotifyObservers(); NotifyObservers;
end; end;
end; end;
@ -847,13 +1116,40 @@ begin
if Assigned(FArrowImages) then if Assigned(FArrowImages) then
FArrowImages.FreeNotification(Self); FArrowImages.FreeNotification(Self);
NotifyObservers(); NotifyObservers;
end;
end;
procedure TX2MenuBarunaPainter.SetBackground(const Value: TPicture);
begin
FBackground.Assign(Value);
NotifyObservers;
end;
procedure TX2MenuBarunaPainter.SetBackgroundHorzAlignment(const Value: THorzAlignment);
begin
if Value <> FBackgroundHorzAlignment then
begin
FBackgroundHorzAlignment := Value;
NotifyObservers;
end;
end;
procedure TX2MenuBarunaPainter.SetBackgroundVertAlignment(const Value: TVertAlignment);
begin
if Value <> FBackgroundVertAlignment then
begin
FBackgroundVertAlignment := Value;
NotifyObservers;
end; end;
end; end;
{ TX2MenuBarunaProperty } { TX2MenuBarunaProperty }
procedure TX2MenuBarunaProperty.Changed(); procedure TX2MenuBarunaProperty.Changed;
begin begin
if Assigned(FOnChange) then if Assigned(FOnChange) then
FOnChange(Self); FOnChange(Self);
@ -879,22 +1175,22 @@ begin
inherited; inherited;
end; end;
function TX2MenuBarunaColor.IsDisabledStored(): Boolean; function TX2MenuBarunaColor.IsDisabledStored: Boolean;
begin begin
Result := (FDisabled <> FDefaultDisabled); Result := (FDisabled <> FDefaultDisabled);
end; end;
function TX2MenuBarunaColor.IsHotStored(): Boolean; function TX2MenuBarunaColor.IsHotStored: Boolean;
begin begin
Result := (FHot <> FDefaultHot); Result := (FHot <> FDefaultHot);
end; end;
function TX2MenuBarunaColor.IsNormalStored(): Boolean; function TX2MenuBarunaColor.IsNormalStored: Boolean;
begin begin
Result := (FNormal <> FDefaultNormal); Result := (FNormal <> FDefaultNormal);
end; end;
function TX2MenuBarunaColor.IsSelectedStored(): Boolean; function TX2MenuBarunaColor.IsSelectedStored: Boolean;
begin begin
Result := (FSelected <> FDefaultSelected); Result := (FSelected <> FDefaultSelected);
end; end;
@ -916,7 +1212,7 @@ begin
if Value <> FDisabled then if Value <> FDisabled then
begin begin
FDisabled := Value; FDisabled := Value;
Changed(); Changed;
end; end;
end; end;
@ -925,7 +1221,7 @@ begin
if Value <> FHot then if Value <> FHot then
begin begin
FHot := Value; FHot := Value;
Changed(); Changed;
end; end;
end; end;
@ -934,7 +1230,7 @@ begin
if Value <> FNormal then if Value <> FNormal then
begin begin
FNormal := Value; FNormal := Value;
Changed(); Changed;
end; end;
end; end;
@ -943,26 +1239,26 @@ begin
if Value <> FSelected then if Value <> FSelected then
begin begin
FSelected := Value; FSelected := Value;
Changed(); Changed;
end; end;
end; end;
{ TX2MenuBarunaGroupColors } { TX2MenuBarunaGroupColors }
constructor TX2MenuBarunaGroupColors.Create(); constructor TX2MenuBarunaGroupColors.Create;
begin begin
inherited; inherited;
FBorder := TX2MenuBarunaColor.Create(); FBorder := TX2MenuBarunaColor.Create;
FFill := TX2MenuBarunaColor.Create(); FFill := TX2MenuBarunaColor.Create;
FText := TX2MenuBarunaColor.Create(); FText := TX2MenuBarunaColor.Create;
FBorder.OnChange := ColorChange; FBorder.OnChange := ColorChange;
FFill.OnChange := ColorChange; FFill.OnChange := ColorChange;
FText.OnChange := ColorChange; FText.OnChange := ColorChange;
end; end;
destructor TX2MenuBarunaGroupColors.Destroy(); destructor TX2MenuBarunaGroupColors.Destroy;
begin begin
FreeAndNil(FText); FreeAndNil(FText);
FreeAndNil(FFill); FreeAndNil(FFill);
@ -988,7 +1284,7 @@ end;
procedure TX2MenuBarunaGroupColors.ColorChange(Sender: TObject); procedure TX2MenuBarunaGroupColors.ColorChange(Sender: TObject);
begin begin
Changed(); Changed;
end; end;
@ -997,7 +1293,7 @@ begin
if Value <> FBorder then if Value <> FBorder then
begin begin
FBorder.Assign(Value); FBorder.Assign(Value);
Changed(); Changed;
end; end;
end; end;
@ -1006,7 +1302,7 @@ begin
if Value <> FFill then if Value <> FFill then
begin begin
FFill.Assign(Value); FFill.Assign(Value);
Changed(); Changed;
end; end;
end; end;
@ -1015,7 +1311,7 @@ begin
if Value <> FText then if Value <> FText then
begin begin
FText.Assign(Value); FText.Assign(Value);
Changed(); Changed;
end; end;
end; end;