1
0
mirror of synced 2024-11-24 02:43:51 +00:00

Added: ImagePosition property for MenuBar musikCube painter

This commit is contained in:
Mark van Renswoude 2012-09-24 14:45:27 +00:00
parent b54cdd968e
commit 9437806b34
2 changed files with 29 additions and 215 deletions

View File

@ -74,6 +74,8 @@ type
property Selected: TX2MenuBarmCColor read FSelected write SetSelected; property Selected: TX2MenuBarmCColor read FSelected write SetSelected;
end; end;
TImagePosition = (ipLeft, ipRight);
// #ToDo1 (MvR) 19-3-2006: Custom base class? // #ToDo1 (MvR) 19-3-2006: Custom base class?
TX2MenuBarmusikCubePainter = class(TX2CustomMenuBarPainter) TX2MenuBarmusikCubePainter = class(TX2CustomMenuBarPainter)
private private
@ -84,6 +86,7 @@ type
FItemColors: TX2MenuBarmCColors; FItemColors: TX2MenuBarmCColors;
FItemHeight: Integer; FItemHeight: Integer;
FItemDisabledColor: TColor; FItemDisabledColor: TColor;
FImagePosition: TImagePosition;
procedure SetColor(const Value: TColor); procedure SetColor(const Value: TColor);
procedure SetGroupColors(const Value: TX2MenuBarmCColors); procedure SetGroupColors(const Value: TX2MenuBarmCColors);
@ -92,6 +95,7 @@ type
procedure SetItemColors(const Value: TX2MenuBarmCColors); procedure SetItemColors(const Value: TX2MenuBarmCColors);
procedure SetItemHeight(const Value: Integer); procedure SetItemHeight(const Value: Integer);
procedure SetItemDisabledColor(const Value: TColor); procedure SetItemDisabledColor(const Value: TColor);
procedure SetImagePosition(const Value: TImagePosition);
protected protected
procedure ColorChange(Sender: TObject); procedure ColorChange(Sender: TObject);
@ -113,6 +117,7 @@ type
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;
property GroupHeight: Integer read FGroupHeight write SetGroupHeight stored False; property GroupHeight: Integer read FGroupHeight write SetGroupHeight stored False;
property ImagePosition: TImagePosition read FImagePosition write SetImagePosition default ipLeft;
property IndicatorColors: TX2MenuBarmCColors read FIndicatorColors write SetIndicatorColors stored False; property IndicatorColors: TX2MenuBarmCColors read FIndicatorColors write SetIndicatorColors stored False;
property ItemColors: TX2MenuBarmCColors read FItemColors write SetItemColors stored False; property ItemColors: TX2MenuBarmCColors read FItemColors write SetItemColors stored False;
property ItemHeight: Integer read FItemHeight write SetItemHeight stored False; property ItemHeight: Integer read FItemHeight write SetItemHeight stored False;
@ -133,6 +138,7 @@ begin
FItemDisabledColor := clGrayText; FItemDisabledColor := clGrayText;
FGroupColors := TX2MenuBarmCColors.Create; FGroupColors := TX2MenuBarmCColors.Create;
FGroupHeight := 22; FGroupHeight := 22;
FImagePosition := ipLeft;
FIndicatorColors := TX2MenuBarmCColors.Create; FIndicatorColors := TX2MenuBarmCColors.Create;
FItemColors := TX2MenuBarmCColors.Create; FItemColors := TX2MenuBarmCColors.Create;
FItemHeight := 22; FItemHeight := 22;
@ -300,6 +306,7 @@ var
indicatorColor: TX2MenuBarmCColor; indicatorColor: TX2MenuBarmCColor;
textBounds: TRect; textBounds: TRect;
imageList: TCustomImageList; imageList: TCustomImageList;
imgX: Integer;
imgY: Integer; imgY: Integer;
begin begin
@ -326,22 +333,32 @@ begin
textBounds := itemBounds; textBounds := itemBounds;
Inc(textBounds.Left, 4); Inc(textBounds.Left, 4);
Dec(textBounds.Right, 4);
imageList := MenuBar.Images; imageList := MenuBar.Images;
if Assigned(imageList) then if Assigned(imageList) then
begin begin
if AItem.ImageIndex > -1 then if AItem.ImageIndex > -1 then
begin begin
if ImagePosition = ipRight then
imgX := textBounds.Right - imageList.Width
else
imgX := textBounds.Left;
imgY := textBounds.Top + ((textBounds.Bottom - textBounds.Top - imgY := textBounds.Top + ((textBounds.Bottom - textBounds.Top -
imageList.Height) div 2); imageList.Height) div 2);
if (mdsHot in AState) or (mdsSelected in AState) then if (mdsHot in AState) or (mdsSelected in AState) then
imageList.Draw(ACanvas, textBounds.Left, imgY, AItem.ImageIndex) imageList.Draw(ACanvas, imgX, imgY, AItem.ImageIndex)
else else
DrawBlended(ACanvas, imageList, textBounds.Left, imgY, DrawBlended(ACanvas, imageList, imgX, imgY,
AItem.ImageIndex, 128); AItem.ImageIndex, 128);
if ImagePosition = ipRight then
Dec(textBounds.Right, imageList.Width + 4);
end; end;
if ImagePosition = ipLeft then
Inc(textBounds.Left, imageList.Width + 4); Inc(textBounds.Left, imageList.Width + 4);
end; end;
@ -369,6 +386,15 @@ begin
end; end;
procedure TX2MenuBarmusikCubePainter.SetImagePosition(const Value: TImagePosition);
begin
if Value <> FImagePosition then
begin
FImagePosition := Value;
NotifyObservers;
end;
end;
procedure TX2MenuBarmusikCubePainter.SetIndicatorColors(const Value: TX2MenuBarmCColors); procedure TX2MenuBarmusikCubePainter.SetIndicatorColors(const Value: TX2MenuBarmCColors);
begin begin
if Value <> FIndicatorColors then if Value <> FIndicatorColors then

View File

@ -1,215 +1,3 @@
{$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.
:: ::