jvcllaz: Implement scaled imagelists for JvOutlookBar.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6346 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-04-23 23:18:49 +00:00
parent 3c9c2bf7a9
commit a4d0516ad9
5 changed files with 353 additions and 161 deletions

View File

@ -22,7 +22,9 @@
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<FormatVersion Value="2"/> <FormatVersion Value="2"/>
<Modes Count="0"/> <Modes Count="1">
<Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>
@ -56,6 +58,13 @@
<IncludeFiles Value="$(ProjOutDir)"/> <IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="3"> <Exceptions Count="3">

View File

@ -7,9 +7,7 @@ uses
{$R *.res} {$R *.res}
begin begin
{$IF LCL_FullVersion >= 1080000} Application.Scaled:=True; // Please remove this if Lazarus is older than 1.8
Application.Scaled := True;
{$ENDIF}
Application.Initialize; Application.Initialize;
Application.CreateForm(TOLBarMainForm, OLBarMainForm); Application.CreateForm(TOLBarMainForm, OLBarMainForm);
Application.Run; Application.Run;

View File

@ -1,12 +1,12 @@
object OLBarMainForm: TOLBarMainForm object OLBarMainForm: TOLBarMainForm
Left = 299 Left = 299
Height = 366 Height = 358
Top = 199 Top = 199
Width = 771 Width = 623
ActiveControl = Memo1 ActiveControl = Memo1
Caption = 'JvOutlookBar Demo' Caption = 'JvOutlookBar Demo'
ClientHeight = 366 ClientHeight = 358
ClientWidth = 771 ClientWidth = 623
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 300 Constraints.MinHeight = 300
Constraints.MinWidth = 220 Constraints.MinWidth = 220
@ -16,27 +16,28 @@ object OLBarMainForm: TOLBarMainForm
Position = poScreenCenter Position = poScreenCenter
ShowHint = True ShowHint = True
LCLVersion = '1.9.0.0' LCLVersion = '1.9.0.0'
Scaled = False
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 135 Left = 130
Height = 343 Height = 335
Top = 0 Top = 0
Width = 5 Width = 4
AutoSnap = False AutoSnap = False
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 23 Height = 23
Top = 343 Top = 335
Width = 771 Width = 623
Font.Color = clWindowText
Panels = <> Panels = <>
ParentFont = False
end end
object JvOutlookBar1: TJvOutlookBar object JvOutlookBar1: TJvOutlookBar
Left = 0 Left = 0
Height = 343 Height = 335
Hint = 'Right-click the bar to see the options' Hint = 'Right-click the bar to see the options'
Top = 0 Top = 0
Width = 135 Width = 130
Align = alLeft Align = alLeft
Pages = < Pages = <
item item
@ -151,8 +152,8 @@ object OLBarMainForm: TOLBarMainForm
ParentColor = False ParentColor = False
TopButtonIndex = 0 TopButtonIndex = 0
end> end>
LargeImages = ImageList1 LargeImages = LargeImages
SmallImages = ImageList2 SmallImages = SmallImages
ActivePageIndex = 1 ActivePageIndex = 1
OnButtonClick = JvOutlookBar1ButtonClick OnButtonClick = JvOutlookBar1ButtonClick
OnPageChange = JvOutlookBar1PageChange OnPageChange = JvOutlookBar1PageChange
@ -163,108 +164,129 @@ object OLBarMainForm: TOLBarMainForm
PopupMenu = popOL PopupMenu = popOL
TabOrder = 1 TabOrder = 1
OnContextPopup = JvOutlookBar1ContextPopup OnContextPopup = JvOutlookBar1ContextPopup
LargeImagesWidth = 0
SmallImagesWidth = 0
PageImagesWidth = 0
end end
object Panel1: TPanel object Panel1: TPanel
Left = 140 Left = 134
Height = 343 Height = 335
Top = 0 Top = 0
Width = 631 Width = 489
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 343 ClientHeight = 335
ClientWidth = 631 ClientWidth = 489
Font.Color = clWindowText
ParentFont = False
TabOrder = 2 TabOrder = 2
object Panel2: TPanel object Panel2: TPanel
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 56 Height = 56
Top = 287 Top = 279
Width = 631 Width = 489
Align = alBottom Align = alBottom
Anchors = [akLeft, akRight] Anchors = [akLeft, akRight]
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 56 ClientHeight = 56
ClientWidth = 631 ClientWidth = 489
Font.Color = clWindowText
ParentFont = False
TabOrder = 0 TabOrder = 0
object Button1: TButton object Button1: TButton
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2 AnchorSideTop.Control = Panel2
Left = 0 Left = 4
Height = 25 Height = 25
Top = 4 Top = 4
Width = 102 Width = 102
AutoSize = True AutoSize = True
BorderSpacing.Left = 4
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Caption = 'Assign images' Caption = 'Assign images'
Font.Color = clWindowText
OnClick = Button1Click OnClick = Button1Click
ParentFont = False
TabOrder = 0 TabOrder = 0
end end
object chkSmallImages: TCheckBox object chkSmallImages: TCheckBox
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 0 Left = 5
Height = 19 Height = 19
Top = 33 Top = 33
Width = 93 Width = 93
Action = acSmallButtons Action = acSmallButtons
BorderSpacing.Left = 5
BorderSpacing.Top = 4 BorderSpacing.Top = 4
BorderSpacing.Bottom = 4 BorderSpacing.Bottom = 4
Font.Color = clWindowText
ParentFont = False
TabOrder = 1 TabOrder = 1
end end
object Button2: TButton object Button2: TButton
AnchorSideLeft.Control = Button1 AnchorSideLeft.Control = Button1
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
Left = 106 Left = 110
Height = 25 Height = 25
Top = 4 Top = 4
Width = 110 Width = 110
AutoSize = True AutoSize = True
BorderSpacing.Left = 4 BorderSpacing.Left = 4
Caption = 'Remove images' Caption = 'Remove images'
Font.Color = clWindowText
OnClick = Button2Click OnClick = Button2Click
ParentFont = False
TabOrder = 2 TabOrder = 2
end end
object Button3: TButton object Button3: TButton
AnchorSideLeft.Control = Button2 AnchorSideLeft.Control = Button2
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
Left = 220 Left = 224
Height = 25 Height = 25
Top = 4 Top = 4
Width = 59 Width = 59
AutoSize = True AutoSize = True
BorderSpacing.Left = 4 BorderSpacing.Left = 4
Caption = 'Font...' Caption = 'Font...'
Font.Color = clWindowText
OnClick = Button3Click OnClick = Button3Click
ParentFont = False
TabOrder = 3 TabOrder = 3
end end
object chkButtonFont: TCheckBox object chkButtonFont: TCheckBox
AnchorSideLeft.Control = chkFlat AnchorSideLeft.Control = chkFlat
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkSmallImages AnchorSideTop.Control = chkSmallImages
Left = 180 Left = 185
Height = 19 Height = 19
Top = 33 Top = 33
Width = 125 Width = 125
BorderSpacing.Left = 24 BorderSpacing.Left = 24
Caption = 'Change button font' Caption = 'Change button font'
Font.Color = clWindowText
ParentFont = False
TabOrder = 4 TabOrder = 4
end end
object chkFlat: TCheckBox object chkFlat: TCheckBox
AnchorSideLeft.Control = chkSmallImages AnchorSideLeft.Control = chkSmallImages
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkSmallImages AnchorSideTop.Control = chkSmallImages
Left = 117 Left = 122
Height = 19 Height = 19
Top = 33 Top = 33
Width = 39 Width = 39
BorderSpacing.Left = 24 BorderSpacing.Left = 24
Caption = 'Flat' Caption = 'Flat'
Font.Color = clWindowText
OnClick = chkFlatClick OnClick = chkFlatClick
ParentFont = False
TabOrder = 5 TabOrder = 5
end end
object chkThemed: TCheckBox object chkThemed: TCheckBox
@ -272,52 +294,59 @@ object OLBarMainForm: TOLBarMainForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 329 Left = 334
Height = 19 Height = 19
Top = 7 Top = 7
Width = 64 Width = 64
BorderSpacing.Left = 24 BorderSpacing.Left = 24
Caption = 'Themed' Caption = 'Themed'
Checked = True Checked = True
Font.Color = clWindowText
OnChange = chkThemedChange OnChange = chkThemedChange
ParentFont = False
State = cbChecked State = cbChecked
TabOrder = 6 TabOrder = 6
end end
object ChkThemedBackground: TCheckBox object ChkThemedBackground: TCheckBox
AnchorSideLeft.Control = chkThemed AnchorSideLeft.Control = chkThemed
AnchorSideTop.Control = chkSmallImages AnchorSideTop.Control = chkSmallImages
Left = 329 Left = 334
Height = 19 Height = 19
Top = 33 Top = 33
Width = 131 Width = 131
Caption = 'Themed background' Caption = 'Themed background'
Checked = True Checked = True
Font.Color = clWindowText
OnChange = ChkThemedBackgroundChange OnChange = ChkThemedBackgroundChange
ParentFont = False
State = cbChecked State = cbChecked
TabOrder = 7 TabOrder = 7
end end
end end
object Memo1: TMemo object Memo1: TMemo
Left = 0 Left = 0
Height = 287 Height = 279
Top = 0 Top = 0
Width = 631 Width = 489
Align = alClient Align = alClient
Font.Color = clWindowText
Lines.Strings = ( Lines.Strings = (
'Right-click in the outlookbar to see the popup menus. There is one menu for the outlook bar itself, one for the pages and one for the buttons.' 'Right-click in the outlookbar to see the popup menus. There is one menu for the outlook bar itself, one for the pages '
'and one for the buttons.'
'' ''
'See the code for an example on how to detect and assign the popup menus at run-time (the OnContextPopup event).' 'See the code for an example on how to detect and assign the popup menus at run-time (the OnContextPopup event).'
'' ''
'Use the buttons to modify the look of the outlookbar, pages and buttons.' 'Use the buttons to modify the look of the outlookbar, pages and buttons.'
) )
ParentFont = False
ScrollBars = ssBoth ScrollBars = ssBoth
TabOrder = 1 TabOrder = 1
end end
end end
object popOL: TPopupMenu object popOL: TPopupMenu
Images = ImageList2 Images = SmallImages
left = 256 left = 160
top = 176 top = 136
object Defaultpopupmenu1: TMenuItem object Defaultpopupmenu1: TMenuItem
Caption = 'Default popup menu' Caption = 'Default popup menu'
end end
@ -325,11 +354,11 @@ object OLBarMainForm: TOLBarMainForm
Action = acSmallButtons Action = acSmallButtons
end end
end end
object ImageList1: TImageList object LargeImages: TImageList
Height = 32 Height = 32
Width = 32 Width = 32
left = 448 left = 160
top = 88 top = 192
Bitmap = { Bitmap = {
4C69180000002000000020000000000000000000000000000000000000000000 4C69180000002000000020000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
@ -3406,9 +3435,9 @@ object OLBarMainForm: TOLBarMainForm
0000000000000000000000000000 0000000000000000000000000000
} }
end end
object ImageList2: TImageList object SmallImages: TImageList
left = 520 left = 240
top = 88 top = 192
Bitmap = { Bitmap = {
4C69180000001000000010000000000000000000000000000000000000000000 4C69180000001000000010000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
@ -4182,17 +4211,17 @@ object OLBarMainForm: TOLBarMainForm
} }
end end
object popButton: TPopupMenu object popButton: TPopupMenu
Images = ImageList2 Images = SmallImages
left = 232 left = 240
top = 88 top = 136
object Editbuttoncaption1: TMenuItem object Editbuttoncaption1: TMenuItem
Action = acEditButtonCaption Action = acEditButtonCaption
end end
end end
object popPage: TPopupMenu object popPage: TPopupMenu
Images = ImageList2 Images = SmallImages
left = 296 left = 320
top = 88 top = 144
object Editpagecaption1: TMenuItem object Editpagecaption1: TMenuItem
Action = acEditPageCaption Action = acEditPageCaption
end end
@ -4201,8 +4230,8 @@ object OLBarMainForm: TOLBarMainForm
end end
end end
object ActionList1: TActionList object ActionList1: TActionList
left = 480 left = 320
top = 176 top = 192
object acSmallButtons: TAction object acSmallButtons: TAction
Caption = 'Small Buttons' Caption = 'Small Buttons'
OnExecute = acSmallButtonsExecute OnExecute = acSmallButtonsExecute

View File

@ -33,7 +33,7 @@ interface
uses uses
SysUtils, Classes, Graphics, Controls, Forms, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Menus, ExtCtrls, ActnList, Dialogs, ComCtrls, StdCtrls, Menus, ExtCtrls, ActnList,
JvExControls, JvOutlookBar; JvOutlookBar;
type type
@ -44,8 +44,8 @@ type
chkThemed: TCheckBox; chkThemed: TCheckBox;
popOL: TPopupMenu; popOL: TPopupMenu;
Splitter1: TSplitter; Splitter1: TSplitter;
ImageList1: TImageList; LargeImages: TImageList;
ImageList2: TImageList; SmallImages: TImageList;
Defaultpopupmenu1: TMenuItem; Defaultpopupmenu1: TMenuItem;
popButton: TPopupMenu; popButton: TPopupMenu;
popPage: TPopupMenu; popPage: TPopupMenu;
@ -96,12 +96,12 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Themes; Themes, LCLVersion;
procedure TOLBarMainForm.Button1Click(Sender: TObject); procedure TOLBarMainForm.Button1Click(Sender: TObject);
begin begin
JvOutlookBar1.LargeImages := ImageList1; JvOutlookBar1.LargeImages := LargeImages;
JvOutlookBar1.SmallImages := ImageList2; JvOutlookBar1.SmallImages := SmallImages;
end; end;
procedure TOLBarMainForm.Button2Click(Sender: TObject); procedure TOLBarMainForm.Button2Click(Sender: TObject);
@ -213,6 +213,10 @@ end;
procedure TOLBarMainForm.FormCreate(Sender: TObject); procedure TOLBarMainForm.FormCreate(Sender: TObject);
begin begin
{$IF LCL_FullVersion >= 1090000}
LargeImages.Scaled := true;
SmallImages.Scaled := true;
{$ENDIF}
Memo1.Wordwrap := True; Memo1.Wordwrap := True;
chkThemed.Visible := ThemeServices.ThemesEnabled; chkThemed.Visible := ThemeServices.ThemesEnabled;
end; end;

View File

@ -51,20 +51,22 @@ uses
Buttons, Controls, Graphics, ImgList, Forms, StdCtrls, ExtCtrls, Themes, Buttons, Controls, Graphics, ImgList, Forms, StdCtrls, ExtCtrls, Themes,
JvJCLUtils, JvComponent; JvJCLUtils, JvComponent;
(*
{$IF LCL_FullVersion >= 1090000}
{$DEFINE HAS_SCALED_IMAGELIST}
{$ENDIF}
*)
const const
CM_CAPTION_EDITING = CM_BASE + 756; CM_CAPTION_EDITING = CM_BASE + 756;
CM_CAPTION_EDIT_ACCEPT = CM_CAPTION_EDITING + 1; CM_CAPTION_EDIT_ACCEPT = CM_CAPTION_EDITING + 1;
CM_CAPTION_EDIT_CANCEL = CM_CAPTION_EDITING + 2; CM_CAPTION_EDIT_CANCEL = CM_CAPTION_EDITING + 2;
cTextMargins = 3;
cMinTextWidth = 32;
type type
TJvBarButtonSize = (olbsLarge, olbsSmall); TJvBarButtonSize = (olbsLarge, olbsSmall);
TJvCustomOutlookBar = class; TJvCustomOutlookBar = class;
TJvOutlookBarButton = class; TJvOutlookBarButton = class;
TJvOutlookBarButtonActionLink = class(TActionLink) TJvOutlookBarButtonActionLink = class(TActionLink)
private private
FClient: TJvOutlookBarButton; FClient: TJvOutlookBarButton;
@ -268,8 +270,10 @@ type
FPageChangeLink: TChangeLink; FPageChangeLink: TChangeLink;
FActivePageIndex: Integer; FActivePageIndex: Integer;
FButtonSize: TJvBarButtonSize; FButtonSize: TJvBarButtonSize;
FSmallImages: TCustomImageList;
FLargeImages: TCustomImageList; FLargeImages: TCustomImageList;
FLargeImagesWidth: Integer;
FSmallImages: TCustomImageList;
FSmallImagesWidth: Integer;
FPageButtonHeight: Integer; FPageButtonHeight: Integer;
FNextActivePage: Integer; FNextActivePage: Integer;
FPressedPageBtn: Integer; FPressedPageBtn: Integer;
@ -288,12 +292,14 @@ type
FOnEditPage: TOutlookBarEditCaption; FOnEditPage: TOutlookBarEditCaption;
FOnCustomDraw: TJvOutlookBarCustomDrawEvent; FOnCustomDraw: TJvOutlookBarCustomDrawEvent;
FPageImages: TCustomImageList; FPageImages: TCustomImageList;
FPageImagesWidth: Integer;
FDisabledFontColor1: TColor; FDisabledFontColor1: TColor;
FDisabledFontColor2: TColor; FDisabledFontColor2: TColor;
FWordWrap: Boolean; FWordWrap: Boolean;
function GetActivePage: TJvOutlookBarPage; function GetActivePage: TJvOutlookBarPage;
function GetActivePageIndex: Integer; function GetActivePageIndex: Integer;
function IsStoredPageButtonHeight: Boolean;
procedure SetActivePageIndex(const Value: Integer); procedure SetActivePageIndex(const Value: Integer);
procedure SetButtonSize(const Value: TJvBarButtonSize); procedure SetButtonSize(const Value: TJvBarButtonSize);
procedure SetDisabledFontColor1(const Value: TColor); procedure SetDisabledFontColor1(const Value: TColor);
@ -318,11 +324,10 @@ type
PreferredHeight: integer; WithThemeSpace: Boolean); override; PreferredHeight: integer; WithThemeSpace: Boolean); override;
procedure ColorChanged; override; procedure ColorChanged; override;
procedure CreateHandle; override; procedure CreateHandle; override;
{$IF LCL_FullVersion >= 1080000} {$IF LCL_FullVersion >= 1080000}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override; const AXProportion, AYProportion: Double); override;
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; {$ENDIF}
{$ENDIF}
procedure DoButtonClick(Index: Integer); virtual; procedure DoButtonClick(Index: Integer); virtual;
procedure DoButtonEdit(NewText: string; B: TJvOutlookBarButton); procedure DoButtonEdit(NewText: string; B: TJvOutlookBarButton);
@ -365,6 +370,7 @@ type
function GetPageButtonRect(Index: Integer): TRect; function GetPageButtonRect(Index: Integer): TRect;
function GetPageTextRect(Index: Integer): TRect; function GetPageTextRect(Index: Integer): TRect;
function GetPageRect(Index: Integer): TRect; function GetPageRect(Index: Integer): TRect;
function GetRealImageSize(AImageList: TCustomImageList; AImagesWidth: Integer): TSize;
function IsThemedStored: Boolean; function IsThemedStored: Boolean;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseEnter(Control: TControl); override; procedure MouseEnter(Control: TControl); override;
@ -389,7 +395,7 @@ type
property SmallImages: TCustomImageList read FSmallImages write SetSmallImages; property SmallImages: TCustomImageList read FSmallImages write SetSmallImages;
property PageImages: TCustomImageList read FPageImages write SetPageImages; property PageImages: TCustomImageList read FPageImages write SetPageImages;
property ButtonSize: TJvBarButtonSize read FButtonSize write SetButtonSize default olbsLarge; property ButtonSize: TJvBarButtonSize read FButtonSize write SetButtonSize default olbsLarge;
property PageButtonHeight: Integer read FPageButtonHeight write SetPageButtonHeight default 0; //DEFAULT_PAGEBUTTONHEIGHT; property PageButtonHeight: Integer read FPageButtonHeight write SetPageButtonHeight stored IsStoredPageButtonHeight;
property ActivePageIndex: Integer read GetActivePageIndex write SetActivePageIndex default 0; property ActivePageIndex: Integer read GetActivePageIndex write SetActivePageIndex default 0;
property Themed: Boolean read FThemed write SetThemed stored IsThemedStored; property Themed: Boolean read FThemed write SetThemed stored IsThemedStored;
property ThemedBackground: Boolean read FThemedBackGround write SetThemedBackground default True; property ThemedBackground: Boolean read FThemedBackGround write SetThemedBackground default True;
@ -403,10 +409,24 @@ type
property DisabledFontColor1:TColor read FDisabledFontColor1 write SetDisabledFontColor1; //clWhite; property DisabledFontColor1:TColor read FDisabledFontColor1 write SetDisabledFontColor1; //clWhite;
property DisabledFontColor2:TColor read FDisabledFontColor2 write SetDisabledFontColor2; //clGrayText; property DisabledFontColor2:TColor read FDisabledFontColor2 write SetDisabledFontColor2; //clGrayText;
{$IF LCL_FullVersion >= 1090000}
private
procedure SetLargeImagesWidth(const AValue: Integer);
procedure SetPageImagesWidth(const AValue: Integer);
procedure SetSmallImagesWidth(const AValue: Integer);
protected
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth default 0;
property SmallImagesWidth: Integer read FSmallImagesWidth write SetSmallImagesWidth default 0;
property PageImagesWidth: Integer read FPageImagesWidth write SetPageImagesWidth default 0;
{$ENDIF}
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure InitiateAction; override; procedure InitiateAction; override;
{$IF LCL_FullVersion >= 1080000}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
{$ENDIF}
function GetButtonAtPos(P: TPoint): TJvOutlookBarButton; function GetButtonAtPos(P: TPoint): TJvOutlookBarButton;
function GetPageButtonAtPos(P: TPoint): TJvOutlookBarPage; function GetPageButtonAtPos(P: TPoint): TJvOutlookBarPage;
public public
@ -468,6 +488,12 @@ type
property OnClick; property OnClick;
property OnDblClick; property OnDblClick;
property OnContextPopup; property OnContextPopup;
{$IF LCL_FullVersion >= 1090000}
property LargeImagesWidth;
property SmallImagesWidth;
property PageImagesWidth;
{$ENDIF}
end; end;
@ -481,6 +507,8 @@ uses
{$R ..\..\resource\JvOutlookBar.res} {$R ..\..\resource\JvOutlookBar.res}
const const
cTextMargins = 3;
cMinTextWidth = 32;
cButtonLeftOffset = 4; cButtonLeftOffset = 4;
cButtonTopOffset = 2; cButtonTopOffset = 2;
cInitRepeatPause = 400; cInitRepeatPause = 400;
@ -1570,7 +1598,12 @@ var
Flags: Cardinal; Flags: Cardinal;
HasImage: Boolean; HasImage: Boolean;
Details: TThemedElementDetails; Details: TThemedElementDetails;
margin: Integer; margin, w: Integer;
{$IF LCL_FullVersion >= 1090000}
pageImageRes: TScaledImageListResolution;
f: Double;
ppi: Integer;
{$ENDIF}
begin begin
Assert(Assigned(FPageBtnProps)); Assert(Assigned(FPageBtnProps));
ATop := R.Top + 1; ATop := R.Top + 1;
@ -1579,17 +1612,11 @@ begin
if Themed then begin if Themed then begin
if Pressed then if Pressed then
Details := StyleServices.GetElementDetails(tbPushButtonPressed) Details := StyleServices.GetElementDetails(tbPushButtonPressed)
// Details := StyleServices.GetElementDetails(ttbButtonPressed)
// Details := StyleServices.GetElementDetails(tebNormalGroupHead)
else else
if Index = FHotPageBtn then if Index = FHotPageBtn then
Details := StyleServices.GetElementDetails(tbPushButtonHot) Details := StyleServices.GetElementDetails(tbPushButtonHot)
// Details := StyleServices.GetElementDetails(ttbButtonHot)
// Details := StyleServices.GetElementDetails(tebNormalGroupHead)
else else
Details := StyleServices.GetElementDetails(tbPushButtonNormal); Details := StyleServices.GetElementDetails(tbPushButtonNormal);
// Details := StyleServices.GetElementDetails(ttbButtonNormal);
// Details := StyleServices.GetElementDetails(tebSpecialGroupHead);
InflateRect(R, 1, 1); InflateRect(R, 1, 1);
StyleServices.DrawElement(Canvas.Handle, Details, R); StyleServices.DrawElement(Canvas.Handle, Details, R);
end else end else
@ -1620,34 +1647,33 @@ begin
SavedDC := SaveDC(Canvas.Handle); SavedDC := SaveDC(Canvas.Handle);
try try
margin := Scale96ToForm(4); margin := Scale96ToForm(4);
if HasImage then begin
{$IF LCL_FullVersion >= 1090000}
f := GetCanvasScalefactor;
ppi := Font.PixelsPerInch;
if FPageImages <> nil then
pageImageRes := FPageImages.ResolutionForPPI[FPageImagesWidth, ppi, f];
pageImageRes.Draw(Canvas, margin, ATop, Pages[Index].ImageIndex, Pages[Index].Enabled);
{$ELSE}
PageImages.Draw(Canvas, margin, ATop, Pages[Index].ImageIndex, Pages[Index].Enabled);
{$ENDIF}
end;
case Pages[Index].Alignment of case Pages[Index].Alignment of
taLeftJustify: taLeftJustify:
begin begin
if HasImage then if HasImage then
begin Inc(R.Left, PageImages.Width + 2*margin)
PageImages.Draw(Canvas, margin, ATop, Pages[Index].ImageIndex,
Pages[Index].Enabled);
Inc(R.Left, PageImages.Width + 2*margin);
end
else else
Inc(R.Left, margin); Inc(R.Left, margin);
Flags := DT_LEFT or DT_VCENTER or DT_SINGLELINE; Flags := DT_LEFT or DT_VCENTER or DT_SINGLELINE;
end; end;
taCenter: taCenter:
if HasImage then if HasImage then
begin
PageImages.Draw(Canvas, margin, ATop, Pages[Index].ImageIndex,
Pages[Index].Enabled);
Inc(R.Left, PageImages.Width + margin); Inc(R.Left, PageImages.Width + margin);
end;
taRightJustify: taRightJustify:
begin begin
if HasImage then if HasImage then
begin Inc(R.Left, PageImages.Width + 2*margin);
PageImages.Draw(Canvas, margin, ATop, Pages[Index].ImageIndex,
Pages[Index].Enabled);
Inc(R.Left, PageImages.Width + margin*2);
end;
Dec(R.Right, margin); Dec(R.Right, margin);
Flags := DT_RIGHT or DT_VCENTER or DT_SINGLELINE; Flags := DT_RIGHT or DT_VCENTER or DT_SINGLELINE;
end; end;
@ -1665,7 +1691,6 @@ begin
if not Pages[Index].Enabled then begin if not Pages[Index].Enabled then begin
OffsetRect(R, 1, 1); OffsetRect(R, 1, 1);
Details := StyleServices.GetElementDetails(tbPushButtonPressed) Details := StyleServices.GetElementDetails(tbPushButtonPressed)
// Details := StyleServices.GetElementDetails(ttbButtonDisabled)
end; end;
StyleServices.DrawText(Canvas, Details, Pages[Index].Caption, R, Flags or DT_END_ELLIPSIS, 0); StyleServices.DrawText(Canvas, Details, Pages[Index].Caption, R, Flags or DT_END_ELLIPSIS, 0);
end else begin end else begin
@ -1756,6 +1781,13 @@ var
SavedColor: TColor; SavedColor: TColor;
flags: Integer; flags: Integer;
Details: TThemedElementDetails; Details: TThemedElementDetails;
w: Integer;
dist: Integer;
{$IF LCL_FullVersion >= 1090000}
LargeImageRes, SmallImageRes: TScaledImageListResolution;
f: Double;
ppi: Integer;
{$ENDIF}
begin begin
if csDestroying in ComponentState then if csDestroying in ComponentState then
Exit; Exit;
@ -1763,6 +1795,16 @@ begin
(Pages[Index].Buttons.Count <= 0) (Pages[Index].Buttons.Count <= 0)
then then
Exit; Exit;
{$IF LCL_FullVersion >= 1090000}
f := GetCanvasScalefactor;
ppi := Font.PixelsPerInch;
if FLargeImages <> nil then
LargeImageRes := FLargeImages.ResolutionForPPI[FLargeImagesWidth, ppi, f];
if FSmallImages <> nil then
smallImageRes := FSmallImages.ResolutionForPPI[SmallImagesWidth, ppi, f];
{$ENDIF}
R2 := GetPageRect(Index); R2 := GetPageRect(Index);
R := GetButtonRect(Index, Pages[Index].TopButtonIndex); R := GetButtonRect(Index, Pages[Index].TopButtonIndex);
C := Canvas.Pen.Color; C := Canvas.Pen.Color;
@ -1780,13 +1822,24 @@ begin
try try
SavedDC := SaveDC(Canvas.Handle); SavedDC := SaveDC(Canvas.Handle);
try try
if LargeImages <> nil then if LargeImages <> nil then begin
LargeImages.Draw(Canvas, dist := Scale96ToForm(4);
R.Left + ((R.Right - R.Left) - LargeImages.Width) div 2, {$IF LCL_FullVersion >= 1090000}
R.Top + 4, largeImageRes.Draw(Canvas,
R.Left + ((R.Right - R.Left) - largeImageRes.Width) div 2,
R.Top + dist,
Pages[Index].Buttons[I].ImageIndex, Pages[Index].Buttons[I].ImageIndex,
Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled
); );
{$ELSE}
LargeImages.Draw(Canvas,
R.Left + ((R.Right - R.Left) - LargeImages.Width) div 2,
R.Top + dist,
Pages[Index].Buttons[I].ImageIndex,
Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled
);
{$ENDIF}
end;
finally finally
RestoreDC(Canvas.Handle, SavedDC); RestoreDC(Canvas.Handle, SavedDC);
end; end;
@ -1827,15 +1880,27 @@ begin
try try
SavedDC := SaveDC(Canvas.Handle); SavedDC := SaveDC(Canvas.Handle);
try try
if SmallImages <> nil then if SmallImages <> nil then begin
SmallImages.Draw(Canvas, R.Left + 2, R.Top + 2, dist := Scale96ToForm(2);
{$IF LCL_FullVersion >= 1090000}
smallImageRes.Draw(Canvas,
R.Left + dist, R.Top + dist,
Pages[Index].Buttons[I].ImageIndex, Pages[Index].Buttons[I].ImageIndex,
Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled); Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled
);
{$ELSE}
SmallImages.Draw(Canvas,
R.Left + dist, R.Top + dist,
Pages[Index].Buttons[I].ImageIndex,
Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled
);
{$ENDIF}
end;
finally finally
RestoreDC(Canvas.Handle, SavedDC); RestoreDC(Canvas.Handle, SavedDC);
end; end;
R3 := GetButtonTextRect(ActivePageIndex, I); R3 := GetButtonTextRect(ActivePageIndex, I);
InflateRect(R3, -4, 0); // InflateRect(R3, -Scale96ToForm(4), 0);
SetBkMode(Canvas.Handle, TRANSPARENT); SetBkMode(Canvas.Handle, TRANSPARENT);
Flags := DT_EXPANDTABS or DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_NOCLIP or DT_EDITCONTROL; Flags := DT_EXPANDTABS or DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_NOCLIP or DT_EDITCONTROL;
if Themed and (Pages[Index].Color = clDefault) then if Themed and (Pages[Index].Color = clDefault) then
@ -2101,9 +2166,12 @@ begin
end; end;
function TJvCustomOutlookBar.GetPageTextRect(Index: Integer): TRect; function TJvCustomOutlookBar.GetPageTextRect(Index: Integer): TRect;
var
dist: Integer;
begin begin
Result := GetPageButtonRect(Index); Result := GetPageButtonRect(Index);
InflateRect(Result, -2, -2); dist := Scale96ToForm(2);
InflateRect(Result, -dist, -dist);
end; end;
function TJvCustomOutlookBar.GetButtonTextSize( function TJvCustomOutlookBar.GetButtonTextSize(
@ -2113,6 +2181,7 @@ var
DC: HDC; DC: HDC;
S: string; S: string;
OldFont: HFONT; OldFont: HFONT;
txtMargins, minTxtWidth: Integer;
begin begin
DC := Canvas.Handle; DC := Canvas.Handle;
OldFont := SelectObject(DC, Canvas.Font.Handle); OldFont := SelectObject(DC, Canvas.Font.Handle);
@ -2121,7 +2190,9 @@ begin
S := Pages[PageIndex].Buttons[ButtonIndex].Caption; S := Pages[PageIndex].Buttons[ButtonIndex].Caption;
if (Pages[PageIndex].ButtonSize = olbsLarge) and FWordWrap then if (Pages[PageIndex].ButtonSize = olbsLarge) and FWordWrap then
begin begin
R := Rect(0, 0, Max(ClientWidth - (2 * cTextMargins), cMinTextWidth), 0); txtMargins := Scale96ToForm(cTextMargins);
minTxtWidth := Scale96ToForm(cMinTextWidth);
R := Rect(0, 0, Max(ClientWidth - (2 * txtMargins), minTxtWidth), 0);
Result.cy := DrawText(DC, PChar(S), Length(S), R, DT_WORDBREAK or DT_CALCRECT or DT_CENTER or DT_VCENTER); Result.cy := DrawText(DC, PChar(S), Length(S), R, DT_WORDBREAK or DT_CALCRECT or DT_CENTER or DT_VCENTER);
Result.cx := R.Right; Result.cx := R.Right;
end else end else
@ -2149,6 +2220,23 @@ begin
end; end;
end; end;
function TJvCustomOutlookBar.GetRealImageSize(AImageList: TCustomImageList;
AImagesWidth: Integer): TSize;
{$IF LCL_FullVersion >= 1090000}
var
imgRes: TScaledImageListResolution;
begin
imgRes := AImageList.ResolutionForPPI[AImagesWidth, Font.PixelsPerInch, GetCanvasScaleFactor];
Result.CX := imgRes.Width;
Result.CY := imgRes.Height;
end;
{$ELSE}
begin
Result.CX := AImageList.Width;
Result.CY := AImageList.Height;
end;
{$ENDIF}
function TJvCustomOutlookBar.GetButtonAtPos(P: TPoint): TJvOutlookBarButton; function TJvCustomOutlookBar.GetButtonAtPos(P: TPoint): TJvOutlookBarButton;
var var
I: Integer; I: Integer;
@ -2174,97 +2262,121 @@ end;
function TJvCustomOutlookBar.GetButtonRect(PageIndex, ButtonIndex: Integer): TRect; function TJvCustomOutlookBar.GetButtonRect(PageIndex, ButtonIndex: Integer): TRect;
var var
H: Integer; H, W: Integer;
dist: Integer;
leftOffs, topOffs: Integer;
begin begin
Result := Rect(0, 0, 0, 0); Result := Rect(0, 0, 0, 0);
if (PageIndex < 0) or (PageIndex >= Pages.Count) or if (PageIndex < 0) or (PageIndex >= Pages.Count) or
(ButtonIndex < 0) or (ButtonIndex >= Pages[PageIndex].Buttons.Count) then (ButtonIndex < 0) or (ButtonIndex >= Pages[PageIndex].Buttons.Count) then
Exit; Exit;
H := GetButtonHeight(PageIndex, ButtonIndex); H := GetButtonHeight(PageIndex, ButtonIndex);
topOffs := Scale96ToForm(cButtonTopOffset);
leftOffs := Scale96ToForm(cButtonLeftOffset);
case Pages[PageIndex].ButtonSize of case Pages[PageIndex].ButtonSize of
olbsLarge: olbsLarge:
if LargeImages <> nil then if FLargeImages <> nil then
begin begin
Result := Rect(0, 0, Max(LargeImages.Width, GetButtonTextSize(PageIndex, ButtonIndex).cx) + W := GetRealImageSize(FLargeImages, FLargeImagesWidth).CX;
4, H); dist := Scale96ToForm(4);
OffsetRect(Result, (ClientWidth - (Result.Right - Result.Left)) div 2, cButtonTopOffset); Result := Rect(0, 0, Max(W, GetButtonTextSize(PageIndex, ButtonIndex).cx) + dist, H);
end OffsetRect(Result, (ClientWidth - (Result.Right - Result.Left)) div 2, topOffs);
else end else
Result := Rect(0, 0, ClientWidth, cButtonTopOffset + H); Result := Rect(0, 0, ClientWidth, cButtonTopOffset + H);
olbsSmall: olbsSmall:
if SmallImages <> nil then if FSmallImages <> nil then
begin begin
Result := Rect(0, 0, SmallImages.Width + GetButtonTextSize(PageIndex, ButtonIndex).cx + 8, W := GetRealImageSize(FSmallImages, FSmallImagesWidth).CX;
H); dist := Scale96ToForm(8);
OffsetRect(Result, cButtonLeftOffset, cButtonTopOffset); Result := Rect(0, 0, W + GetButtonTextSize(PageIndex, ButtonIndex).cx + dist, H);
end OffsetRect(Result, leftOffs, topOffs);
else end else
Result := Rect(0, 0, ClientWidth, cButtonTopOffset + H); Result := Rect(0, 0, ClientWidth, topOffs + H);
end; end;
OffsetRect(Result, 0, GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top); OffsetRect(Result, 0, GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top);
end; end;
function TJvCustomOutlookBar.GetButtonFrameRect(PageIndex, ButtonIndex: Integer): TRect; function TJvCustomOutlookBar.GetButtonFrameRect(PageIndex, ButtonIndex: Integer): TRect;
var
imgSize: TSize;
delta: Integer;
btnTopOffs, btnLeftOffs: Integer;
begin begin
Result := Rect(0, 0, 0, 0); Result := Rect(0, 0, 0, 0);
if (PageIndex < 0) or (PageIndex >= Pages.Count) or if (PageIndex < 0) or (PageIndex >= Pages.Count) or
(ButtonIndex < 0) or (ButtonIndex >= Pages[PageIndex].Buttons.Count) then (ButtonIndex < 0) or (ButtonIndex >= Pages[PageIndex].Buttons.Count) then
Exit; Exit;
btnTopOffs := Scale96ToForm(cButtonTopOffset);
btnLeftOffs := Scale96ToForm(cButtonLeftOffset);
case Pages[PageIndex].ButtonSize of case Pages[PageIndex].ButtonSize of
olbsLarge: olbsLarge:
if LargeImages <> nil then if FLargeImages <> nil then
begin begin
Result := Rect(0, 0, LargeImages.Width + 6, LargeImages.Height + 6); imgSize := GetRealImageSize(FLargeImages, FLargeImagesWidth);
OffsetRect(Result, (ClientWidth - (Result.Right - Result.Left)) div 2, delta := Scale96ToForm(6);
cButtonTopOffset + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top + 1); Result := Rect(0, 0, imgSize.CX + delta, imgSize.CY + delta);
end OffsetRect(Result,
else (ClientWidth - (Result.Right - Result.Left)) div 2,
btnTopOffs + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top + 1
);
end else
begin begin
Result := Rect(0, 0, ClientWidth, GetButtonHeight(PageIndex, ButtonIndex)); Result := Rect(0, 0, ClientWidth, GetButtonHeight(PageIndex, ButtonIndex));
OffsetRect(Result, 0, OffsetRect(Result, 0,
cButtonTopOffset + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top + 1); btnTopOffs + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top + 1);
end; end;
olbsSmall: olbsSmall:
if SmallImages <> nil then if FSmallImages <> nil then
begin begin
Result := Rect(0, 0, SmallImages.Width + 4, SmallImages.Height + 4); imgSize := GetRealImageSize(FSmallImages, FSmallImagesWidth);
OffsetRect(Result, cButtonLeftOffset, cButtonTopOffset + GetButtonTopHeight(PageIndex, ButtonIndex) + delta := Scale96ToForm(4);
GetPageRect(PageIndex).Top); Result := Rect(0, 0, imgSize.CX + delta, imgSize.CY + delta);
end OffsetRect(Result,
else btnLeftOffs,
btnTopOffs + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top
);
end else
begin begin
Result := Rect(0, 0, ClientWidth, GetButtonHeight(PageIndex, ButtonIndex)); Result := Rect(0, 0, ClientWidth, GetButtonHeight(PageIndex, ButtonIndex));
OffsetRect(Result, 0, cButtonTopOffset + GetButtonTopHeight(PageIndex, ButtonIndex) + OffsetRect(Result,
GetPageRect(PageIndex).Top); 0,
btnTopOffs + GetButtonTopHeight(PageIndex, ButtonIndex) + GetPageRect(PageIndex).Top
);
end; end;
end; end;
end; end;
function TJvCustomOutlookBar.GetButtonTextRect(PageIndex, ButtonIndex: Integer): TRect; function TJvCustomOutlookBar.GetButtonTextRect(PageIndex, ButtonIndex: Integer): TRect;
var var
TextSize: TSize; textSize, imgSize: TSize;
ButtonHeight: Integer; ButtonHeight: Integer;
dist2, dist4: Integer;
begin begin
Result := Rect(0, 0, 0, 0); Result := Rect(0, 0, 0, 0);
if Pages[PageIndex].Buttons.Count <= ButtonIndex then if Pages[PageIndex].Buttons.Count <= ButtonIndex then
Exit; Exit;
Result := GetButtonRect(PageIndex, ButtonIndex); Result := GetButtonRect(PageIndex, ButtonIndex);
dist2 := Scale96ToForm(2);
dist4 := Scale96ToForm(4);
case Pages[PageIndex].ButtonSize of case Pages[PageIndex].ButtonSize of
olbsLarge: olbsLarge:
if LargeImages <> nil then if FLargeImages <> nil then
begin begin
Result.Top := Result.Bottom - GetButtonTextSize(PageIndex, ButtonIndex).cy - 2; Result.Top := Result.Bottom - GetButtonTextSize(PageIndex, ButtonIndex).CY - dist2;
OffsetRect(Result, 0, -4); OffsetRect(Result, 0, -dist4);
end; end;
olbsSmall: olbsSmall:
if SmallImages <> nil then if FSmallImages <> nil then
begin begin
TextSize := GetButtonTextSize(PageIndex, ButtonIndex); textSize := GetButtonTextSize(PageIndex, ButtonIndex);
imgSize := GetRealImageSize(FSmallImages, FSmallImagesWidth);
ButtonHeight := GetButtonHeight(PageIndex, ButtonIndex); ButtonHeight := GetButtonHeight(PageIndex, ButtonIndex);
Result.Left := SmallImages.Width + 10; Result.Left := imgSize.CX + Scale96ToForm(14);
Result.Top := Result.Top + (ButtonHeight - TextSize.cy) div 2; Result.Top := Result.Top + (ButtonHeight - textSize.cy) div 2;
Result.Bottom := Result.Top + TextSize.cy + 2; Result.Bottom := Result.Top + textSize.cy + dist2;
Result.Right := Result.Left + TextSize.cx + 4; Result.Right := Result.Left + textSize.cx + dist4;
OffsetRect(Result, 0, -(ButtonHeight - (Result.Bottom - Result.Top)) div 4); OffsetRect(Result, 0, -(ButtonHeight - (Result.Bottom - Result.Top)) div 4);
end; end;
end; end;
@ -2433,6 +2545,20 @@ begin
Invalidate; Invalidate;
end; end;
{$IF LCL_FullVersion >= 1090000}
procedure TJvCustomOutlookBar.SetLargeImagesWidth(const AValue: Integer);
begin
if AValue = FLargeImagesWidth then exit;
FLargeImagesWidth := AValue;
Invalidate;
end;
{$ENDIF}
function TJvCustomOutlookBar.IsStoredPageButtonHeight: Boolean;
begin
Result := FPageButtonHeight <> 0;
end;
procedure TJvCustomOutlookBar.SetPageButtonHeight(const Value: Integer); procedure TJvCustomOutlookBar.SetPageButtonHeight(const Value: Integer);
begin begin
if FPageButtonHeight <> Value then if FPageButtonHeight <> Value then
@ -2453,6 +2579,15 @@ begin
Invalidate; Invalidate;
end; end;
{$IF LCL_FullVersion >= 1090000}
procedure TJvCustomOutlookBar.SetSmallImagesWidth(const AValue: Integer);
begin
if AValue = FSmallImagesWidth then exit;
FSmallImagesWidth := AValue;
Invalidate;
end;
{$ENDIF}
procedure TJvCustomOutlookBar.SetThemed(const Value: Boolean); procedure TJvCustomOutlookBar.SetThemed(const Value: Boolean);
begin begin
if Value and (not ThemeServices.ThemesEnabled) then if Value and (not ThemeServices.ThemesEnabled) then
@ -2691,13 +2826,13 @@ begin
end; end;
function TJvCustomOutlookBar.GetButtonHeight(PageIndex, ButtonIndex: Integer): Integer; function TJvCustomOutlookBar.GetButtonHeight(PageIndex, ButtonIndex: Integer): Integer;
const
cLargeOffset = 8;
cSmallOffset = 4;
var var
TM: TTextMetric; TM: TTextMetric;
TextSize: TSize; textSize: TSize;
imgSize: TSize;
OldFont: HFONT; OldFont: HFONT;
LargeOffset: Integer;
SmallOffset: Integer;
begin begin
OldFont := SelectObject(Canvas.Handle, Canvas.Font.Handle); OldFont := SelectObject(Canvas.Handle, Canvas.Font.Handle);
try try
@ -2706,23 +2841,26 @@ begin
Result := TM.tmHeight + TM.tmExternalLeading; Result := TM.tmHeight + TM.tmExternalLeading;
if (PageIndex >= 0) and (PageIndex < Pages.Count) then if (PageIndex >= 0) and (PageIndex < Pages.Count) then
begin begin
TextSize := GetButtonTextSize(PageIndex, ButtonIndex); textSize := GetButtonTextSize(PageIndex, ButtonIndex);
largeOffset := Scale96ToForm(8);
smallOffset := Scale96ToForm(4);
case Pages[PageIndex].ButtonSize of case Pages[PageIndex].ButtonSize of
olbsLarge: olbsLarge:
begin if FLargeImages <> nil then begin
if LargeImages <> nil then imgSize := GetRealImageSize(FLargeImages, FLargeImagesWidth);
Result := Max(Result, LargeImages.Height + TextSize.cy + cLargeOffset) Result := Max(Result, imgSize.CY + textSize.CY + largeOffset)
else end else
Result := TextSize.cy + cLargeOffset; Result := textSize.cy + largeOffset;
end;
olbsSmall: olbsSmall:
if SmallImages <> nil then if SmallImages <> nil then begin
Result := Max(SmallImages.Height, TextSize.cy) + cSmallOffset imgSize := GetRealImageSize(FSmallImages, FSmallImagesWidth);
else Result := Max(imgSize.CY, textSize.cy) + smallOffset
Result := TextSize.cy + cSmallOffset; end else
Result := textSize.cy + smallOffset;
end; end;
end; end;
Inc(Result, 4); Inc(Result, smallOffset);
finally finally
SelectObject(Canvas.Handle, OldFont); SelectObject(Canvas.Handle, OldFont);
end; end;
@ -2758,7 +2896,7 @@ begin
B := TJvOutlookBarButton(Msg.WParam); B := TJvOutlookBarButton(Msg.WParam);
R := GetButtonTextRect(ActivePageIndex, B.Index); R := GetButtonTextRect(ActivePageIndex, B.Index);
R.Left := Max(R.Left, 0); R.Left := Max(R.Left, 0);
R.Right := Min(R.Right, ClientWidth); R.Right := ClientWidth; //Min(R.Right, ClientWidth);
TJvOutlookBarEdit(FEdit).ShowEdit(B.Caption, R); TJvOutlookBarEdit(FEdit).ShowEdit(B.Caption, R);
end; end;
1: // page 1: // page
@ -2930,10 +3068,15 @@ end;
procedure TJvCustomOutlookBar.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure TJvCustomOutlookBar.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); const AXProportion, AYProportion: Double);
begin begin
inherited; inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
if AMode = lapAutoAdjustForDPI then begin if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
if FPageButtonHeight <> 0 then begin
FPageButtonHeight := round(FPageButtonHeight * AYProportion); DisableAutoSizing;
try
if IsStoredPageButtonHeight then
FPageButtonHeight := round(FPageButtonHeight * AYProportion);
finally
end;
end; end;
end; end;
@ -2994,6 +3137,15 @@ begin
Invalidate; Invalidate;
end; end;
{$IF LCL_FullVersion >= 1090000}
procedure TJvCustomOutlookBar.SetPageImagesWidth(const AValue: Integer);
begin
if AValue = FPageImagesWidth then exit;
FPageImagesWidth := AValue;
Invalidate;
end;
{$ENDIF}
procedure TJvCustomOutlookBar.InitiateAction; procedure TJvCustomOutlookBar.InitiateAction;
var var
I, J: Integer; I, J: Integer;