|
@@ -136,6 +136,7 @@ type
|
|
|
FTextApplyGlobalOpacity: boolean;
|
|
FTextApplyGlobalOpacity: boolean;
|
|
|
AutoSizeExtraY: integer;
|
|
AutoSizeExtraY: integer;
|
|
|
AutoSizeExtraX: integer;
|
|
AutoSizeExtraX: integer;
|
|
|
|
|
+ FLastBorderWidth: integer;
|
|
|
// MORA
|
|
// MORA
|
|
|
FClickOffset: boolean;
|
|
FClickOffset: boolean;
|
|
|
FDropDownArrow: boolean;
|
|
FDropDownArrow: boolean;
|
|
@@ -150,7 +151,7 @@ type
|
|
|
FSaveDropDownClosed: TNotifyEvent;
|
|
FSaveDropDownClosed: TNotifyEvent;
|
|
|
FShowCaption: boolean;
|
|
FShowCaption: boolean;
|
|
|
procedure AssignDefaultStyle;
|
|
procedure AssignDefaultStyle;
|
|
|
- procedure CalculateGlyphSize(var NeededWidth, NeededHeight: integer);
|
|
|
|
|
|
|
+ procedure CalculateGlyphSize(out NeededWidth, NeededHeight: integer);
|
|
|
procedure DropDownClosed(Sender: TObject);
|
|
procedure DropDownClosed(Sender: TObject);
|
|
|
procedure RenderAll(ANow: boolean = False);
|
|
procedure RenderAll(ANow: boolean = False);
|
|
|
function GetButtonRect: TRect;
|
|
function GetButtonRect: TRect;
|
|
@@ -627,7 +628,7 @@ begin
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
-procedure TCustomBCButton.CalculateGlyphSize(var NeededWidth, NeededHeight: integer);
|
|
|
|
|
|
|
+procedure TCustomBCButton.CalculateGlyphSize(out NeededWidth, NeededHeight: integer);
|
|
|
begin
|
|
begin
|
|
|
if Assigned(FGlyph) and not FGlyph.Empty then
|
|
if Assigned(FGlyph) and not FGlyph.Empty then
|
|
|
begin
|
|
begin
|
|
@@ -755,10 +756,7 @@ begin
|
|
|
|
|
|
|
|
// Click offset for arrow
|
|
// Click offset for arrow
|
|
|
if FClickOffset and (AState = FStateClicked) then
|
|
if FClickOffset and (AState = FStateClicked) then
|
|
|
- begin
|
|
|
|
|
- Inc(r_a.Left, 2);
|
|
|
|
|
- Inc(r_a.Top, 2);
|
|
|
|
|
- end;
|
|
|
|
|
|
|
+ r_a.Offset(1,1);
|
|
|
|
|
|
|
|
if FFlipArrow then
|
|
if FFlipArrow then
|
|
|
RenderArrow(TBGRABitmap(ABGRA), r_a, FDropDownArrowSize, badUp,
|
|
RenderArrow(TBGRABitmap(ABGRA), r_a, FDropDownArrowSize, badUp,
|
|
@@ -770,10 +768,7 @@ begin
|
|
|
|
|
|
|
|
// Click offset for text and glyph
|
|
// Click offset for text and glyph
|
|
|
if FClickOffset and (AState = FStateClicked) then
|
|
if FClickOffset and (AState = FStateClicked) then
|
|
|
- begin
|
|
|
|
|
- Inc(r.Left, 2);
|
|
|
|
|
- Inc(r.Top, 2);
|
|
|
|
|
- end;
|
|
|
|
|
|
|
+ r.Offset(1,1);
|
|
|
|
|
|
|
|
// DropDown arrow
|
|
// DropDown arrow
|
|
|
if FDropDownArrow and (FStyle <> bbtDropDown) then
|
|
if FDropDownArrow and (FStyle <> bbtDropDown) then
|
|
@@ -838,7 +833,8 @@ end;
|
|
|
procedure TCustomBCButton.OnChangeState(Sender: TObject; AData: PtrInt);
|
|
procedure TCustomBCButton.OnChangeState(Sender: TObject; AData: PtrInt);
|
|
|
begin
|
|
begin
|
|
|
RenderControl;
|
|
RenderControl;
|
|
|
- if TBCButtonPropertyData(AData) = pdUpdateSize then
|
|
|
|
|
|
|
+ if (TBCButtonPropertyData(AData) = pdUpdateSize) or
|
|
|
|
|
+ (FStateNormal.Border.Width <> FLastBorderWidth) then
|
|
|
UpdateSize;
|
|
UpdateSize;
|
|
|
Invalidate;
|
|
Invalidate;
|
|
|
end;
|
|
end;
|
|
@@ -1108,56 +1104,106 @@ procedure TCustomBCButton.CalculatePreferredSize(
|
|
|
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: boolean);
|
|
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: boolean);
|
|
|
var
|
|
var
|
|
|
// AWidth: integer;
|
|
// AWidth: integer;
|
|
|
- gh: integer;
|
|
|
|
|
- gw: integer;
|
|
|
|
|
|
|
+ gh,gw: integer;
|
|
|
|
|
+ actualCaption: TCaption;
|
|
|
|
|
+ horizAlign, relHorizAlign: TAlignment;
|
|
|
|
|
+ vertAlign, relVertAlign: TTextLayout;
|
|
|
|
|
+ glyphHorzMargin, glyphVertMargin: integer;
|
|
|
|
|
+ tw, th, availW: integer;
|
|
|
begin
|
|
begin
|
|
|
- gh:= 0;
|
|
|
|
|
- gw:= 0;
|
|
|
|
|
-
|
|
|
|
|
if (Parent = nil) or (not Parent.HandleAllocated) then
|
|
if (Parent = nil) or (not Parent.HandleAllocated) then
|
|
|
Exit;
|
|
Exit;
|
|
|
-{ if WidthIsAnchored then
|
|
|
|
|
- AWidth := Width
|
|
|
|
|
- else
|
|
|
|
|
- AWidth := 10000;}
|
|
|
|
|
|
|
|
|
|
- PreferredWidth := 0;
|
|
|
|
|
- PreferredHeight := 0;
|
|
|
|
|
- if FShowCaption then
|
|
|
|
|
- CalculateTextSize(Caption, FStateNormal.FontEx, PreferredWidth, PreferredHeight);
|
|
|
|
|
|
|
+ FLastBorderWidth := FStateNormal.Border.Width;
|
|
|
|
|
+ CalculateGlyphSize(gw, gh);
|
|
|
|
|
|
|
|
- // Extra pixels for DropDown
|
|
|
|
|
- if Style = bbtDropDown then
|
|
|
|
|
- if FDropDownPosition in [bdpBottom] then
|
|
|
|
|
- Inc(PreferredHeight, GetDropDownWidth)
|
|
|
|
|
- else
|
|
|
|
|
- Inc(PreferredWidth, GetDropDownWidth);
|
|
|
|
|
|
|
+ if GlyphOldPlacement then
|
|
|
|
|
+ begin
|
|
|
|
|
+ { if WidthIsAnchored then
|
|
|
|
|
+ AWidth := Width
|
|
|
|
|
+ else
|
|
|
|
|
+ AWidth := 10000;}
|
|
|
|
|
|
|
|
- if (Style = bbtButton) and FDropDownArrow then
|
|
|
|
|
- Inc(PreferredWidth, FDropDownArrowSize);// GetDropDownWidth);
|
|
|
|
|
|
|
+ PreferredWidth := 0;
|
|
|
|
|
+ PreferredHeight := 0;
|
|
|
|
|
+ if FShowCaption then
|
|
|
|
|
+ CalculateTextSize(Caption, FStateNormal.FontEx, PreferredWidth, PreferredHeight);
|
|
|
|
|
|
|
|
- CalculateGlyphSize(gw, gh);
|
|
|
|
|
|
|
+ // Extra pixels for DropDown
|
|
|
|
|
+ if Style = bbtDropDown then
|
|
|
|
|
+ if FDropDownPosition in [bdpBottom] then
|
|
|
|
|
+ Inc(PreferredHeight, GetDropDownWidth)
|
|
|
|
|
+ else
|
|
|
|
|
+ Inc(PreferredWidth, GetDropDownWidth);
|
|
|
|
|
+
|
|
|
|
|
+ if (Style = bbtButton) and FDropDownArrow then
|
|
|
|
|
+ Inc(PreferredWidth, FDropDownArrowSize);// GetDropDownWidth);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //if (FGlyph <> nil) and (not FGlyph.Empty) then
|
|
|
|
|
+ if (gw > 0) and (gh > 0) then
|
|
|
|
|
+ begin
|
|
|
|
|
+ //if Caption = '' then
|
|
|
|
|
+ if PreferredWidth = 0 then
|
|
|
|
|
+ begin
|
|
|
|
|
+ Inc(PreferredWidth, gw{ - AutoSizeExtraY * 2});
|
|
|
|
|
+ Inc(PreferredHeight, gh);
|
|
|
|
|
+ end
|
|
|
|
|
+ else
|
|
|
|
|
+ begin
|
|
|
|
|
+ Inc(PreferredWidth, gw + FGlyphMargin);
|
|
|
|
|
+ if gh > PreferredHeight then
|
|
|
|
|
+ PreferredHeight := gh;
|
|
|
|
|
+ end;
|
|
|
|
|
+ end;
|
|
|
|
|
|
|
|
- //if (FGlyph <> nil) and (not FGlyph.Empty) then
|
|
|
|
|
- if (gw > 0) and (gh > 0) then
|
|
|
|
|
|
|
+ // Extra pixels for AutoSize
|
|
|
|
|
+ Inc(PreferredWidth, AutoSizeExtraX);
|
|
|
|
|
+ Inc(PreferredHeight, AutoSizeExtraY);
|
|
|
|
|
+ end else
|
|
|
begin
|
|
begin
|
|
|
- //if Caption = '' then
|
|
|
|
|
- if PreferredWidth = 0 then
|
|
|
|
|
|
|
+ if ShowCaption then actualCaption := Caption else actualCaption := '';
|
|
|
|
|
+ PreferredWidth := 0;
|
|
|
|
|
+ PreferredHeight := 0;
|
|
|
|
|
+ case FStyle of
|
|
|
|
|
+ bbtDropDown:
|
|
|
|
|
+ case FDropDownPosition of
|
|
|
|
|
+ bdpBottom: inc(PreferredHeight, GetDropDownWidth(False));
|
|
|
|
|
+ else{bdpLeft} inc(PreferredWidth, GetDropDownWidth(False));
|
|
|
|
|
+ end;
|
|
|
|
|
+ else{bbtButton} if FDropDownArrow then
|
|
|
|
|
+ inc(PreferredWidth, FDropDownWidth);
|
|
|
|
|
+ end;
|
|
|
|
|
+ inc(PreferredWidth, FStateNormal.Border.Width);
|
|
|
|
|
+ inc(PreferredHeight, FStateNormal.Border.Width);
|
|
|
|
|
+
|
|
|
|
|
+ if actualCaption='' then
|
|
|
begin
|
|
begin
|
|
|
- Inc(PreferredWidth, gw{ - AutoSizeExtraY * 2});
|
|
|
|
|
- Inc(PreferredHeight, gh);
|
|
|
|
|
- end
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ inc(PreferredWidth,gw);
|
|
|
|
|
+ inc(PreferredHeight,gh);
|
|
|
|
|
+ if gw>0 then inc(PreferredWidth, GlyphMargin*2);
|
|
|
|
|
+ if gh>0 then inc(PreferredHeight, GlyphMargin*2);
|
|
|
|
|
+ end else
|
|
|
begin
|
|
begin
|
|
|
- Inc(PreferredWidth, gw + FGlyphMargin);
|
|
|
|
|
- if gh > PreferredHeight then
|
|
|
|
|
- PreferredHeight := gh;
|
|
|
|
|
|
|
+ GetGlyphActualLayout(actualCaption, FStateNormal.FontEx, GlyphAlignment, GlyphMargin,
|
|
|
|
|
+ horizAlign, vertAlign, relHorizAlign, relVertAlign, glyphHorzMargin, glyphVertMargin);
|
|
|
|
|
+ availW := 65535;
|
|
|
|
|
+ if (Align in [alTop,alBottom]) and (Parent <> nil) then
|
|
|
|
|
+ availW := Parent.ClientWidth - PreferredWidth;
|
|
|
|
|
+ CalculateTextSizeEx(actualCaption, FStateNormal.FontEx, tw, th, availW);
|
|
|
|
|
+ if (tw<>0) and FStateNormal.FontEx.WordBreak then inc(tw);
|
|
|
|
|
+ if vertAlign<>relVertAlign then
|
|
|
|
|
+ begin
|
|
|
|
|
+ inc(PreferredWidth, max(gw+2*GlyphMargin,tw));
|
|
|
|
|
+ inc(PreferredHeight, GlyphMargin+gh+th);
|
|
|
|
|
+ end
|
|
|
|
|
+ else
|
|
|
|
|
+ begin
|
|
|
|
|
+ inc(PreferredWidth, GlyphMargin+gw+tw);
|
|
|
|
|
+ inc(PreferredHeight, max(gh+2*GlyphMargin,th));
|
|
|
|
|
+ end;
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
-
|
|
|
|
|
- // Extra pixels for AutoSize
|
|
|
|
|
- Inc(PreferredWidth, AutoSizeExtraX);
|
|
|
|
|
- Inc(PreferredHeight, AutoSizeExtraY);
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
class function TCustomBCButton.GetControlClassDefaultSize: TSize;
|
|
class function TCustomBCButton.GetControlClassDefaultSize: TSize;
|