You've already forked lazarus-ccr
jvcllaz: For TJvCustomHTLabel, fix property Align and Alignment, publish BorderSpacing.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6734 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -114,7 +114,7 @@ uses
|
|||||||
JvJVCLUtils {JvDataSourceIntf, JvExStdCtrls} ;
|
JvJVCLUtils {JvDataSourceIntf, JvExStdCtrls} ;
|
||||||
|
|
||||||
const
|
const
|
||||||
DefaultSuperSubScriptRatio: Double = 2/3;
|
DefaultSuperSubScriptRatio: Double = 0.67;
|
||||||
|
|
||||||
type
|
type
|
||||||
(*
|
(*
|
||||||
@ -337,25 +337,25 @@ type
|
|||||||
FMouseX, FMouseY: Integer;
|
FMouseX, FMouseY: Integer;
|
||||||
FHyperLinkMouseButtons: TJvHTLabelMouseButtons;
|
FHyperLinkMouseButtons: TJvHTLabelMouseButtons;
|
||||||
FSuperSubScriptRatio: Double;
|
FSuperSubScriptRatio: Double;
|
||||||
function ISuperSuperSubScriptRatioStored: Boolean;
|
function IsSuperSuperSubScriptRatioStored: Boolean;
|
||||||
procedure SetSuperSubScriptRation(const Value: Double);
|
procedure SetSuperSubScriptRatio(const Value: Double);
|
||||||
protected
|
protected
|
||||||
|
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
|
||||||
|
WithThemeSpace: Boolean); override;
|
||||||
|
procedure CalculateSize(MaxWidth: integer; var NeededWidth, NeededHeight: integer);
|
||||||
|
function ComputeLayoutRect: TRect;
|
||||||
|
procedure FontChanged(Sender: TObject); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure FontChanged(Sender: TObject); override;
|
|
||||||
procedure PrepareCanvas;
|
procedure PrepareCanvas;
|
||||||
function ComputeLayoutRect: TRect;
|
|
||||||
procedure SetAutoSize(Value: Boolean); override;
|
|
||||||
procedure Loaded; override;
|
|
||||||
|
|
||||||
property HyperLinkMouseButtons: TJvHTLabelMouseButtons read FHyperLinkMouseButtons write FHyperLinkMouseButtons default [mbLeft];
|
property HyperLinkMouseButtons: TJvHTLabelMouseButtons read FHyperLinkMouseButtons write FHyperLinkMouseButtons default [mbLeft];
|
||||||
property OnHyperLinkClick: TJvHyperLinkClickEvent read FOnHyperLinkClick write FOnHyperLinkClick;
|
property OnHyperLinkClick: TJvHyperLinkClickEvent read FOnHyperLinkClick write FOnHyperLinkClick;
|
||||||
property SuperSubScriptRatio: Double read FSuperSubScriptRatio write SetSuperSubScriptRation stored ISuperSuperSubScriptRatioStored;
|
property SuperSubScriptRatio: Double read FSuperSubScriptRatio write SetSuperSubScriptRatio stored IsSuperSuperSubScriptRatioStored;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure AdjustSize; override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TJvHTLabel = class(TJvCustomHTLabel)
|
TJvHTLabel = class(TJvCustomHTLabel)
|
||||||
@ -365,8 +365,10 @@ type
|
|||||||
procedure DefineProperties(Filer: TFiler); override; // ignore former published WordWrap
|
procedure DefineProperties(Filer: TFiler); override; // ignore former published WordWrap
|
||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
|
property Alignment;
|
||||||
property Anchors;
|
property Anchors;
|
||||||
property AutoSize;
|
property AutoSize;
|
||||||
|
property BorderSpacing;
|
||||||
property Caption;
|
property Caption;
|
||||||
property Color;
|
property Color;
|
||||||
property DragCursor;
|
property DragCursor;
|
||||||
@ -844,6 +846,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
|
|
||||||
//=== { TJvCustomHTLabel } ===================================================
|
//=== { TJvCustomHTLabel } ===================================================
|
||||||
|
|
||||||
constructor TJvCustomHTLabel.Create(AOwner: TComponent);
|
constructor TJvCustomHTLabel.Create(AOwner: TComponent);
|
||||||
@ -859,47 +862,11 @@ begin
|
|||||||
AdjustSize;
|
AdjustSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJvCustomHTLabel.ISuperSuperSubScriptRatioStored: Boolean;
|
function TJvCustomHTLabel.IsSuperSuperSubScriptRatioStored: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := FSuperSubScriptRatio <> DefaultSuperSubScriptRatio;
|
Result := FSuperSubScriptRatio <> DefaultSuperSubScriptRatio;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvCustomHTLabel.Loaded;
|
|
||||||
begin
|
|
||||||
inherited Loaded;
|
|
||||||
AdjustSize;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvCustomHTLabel.AdjustSize;
|
|
||||||
var
|
|
||||||
DC: HDC;
|
|
||||||
X: Integer;
|
|
||||||
Rect: TRect;
|
|
||||||
MaxWidth: Integer;
|
|
||||||
begin
|
|
||||||
if not (csReading in ComponentState) and AutoSize then
|
|
||||||
begin
|
|
||||||
Rect := ClientRect;
|
|
||||||
DC := GetDC(0{HWND_DESKTOP});
|
|
||||||
try
|
|
||||||
Canvas.Handle := DC;
|
|
||||||
Canvas.Font.Assign(Font);
|
|
||||||
Rect.Bottom := ItemHTHeight(Canvas, Caption, SuperSubScriptRatio);
|
|
||||||
MaxWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], Caption, SuperSubScriptRatio);
|
|
||||||
finally
|
|
||||||
Canvas.Handle := 0;
|
|
||||||
ReleaseDC(0{HWND_DESKTOP}, DC);
|
|
||||||
end;
|
|
||||||
Rect.Right := Rect.Left + MaxWidth;
|
|
||||||
X := Left;
|
|
||||||
if Alignment = taRightJustify then
|
|
||||||
Inc(X, Width - Rect.Right);
|
|
||||||
SetBounds(X, Top, Rect.Right, Rect.Bottom);
|
|
||||||
//Width := Rect.Right - X;
|
|
||||||
//Height := Rect.Bottom - Top;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvCustomHTLabel.PrepareCanvas;
|
procedure TJvCustomHTLabel.PrepareCanvas;
|
||||||
begin
|
begin
|
||||||
Canvas.Lock;
|
Canvas.Lock;
|
||||||
@ -911,29 +878,56 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ This code is copied from TCustomLabel.
|
||||||
|
Could be avoided if CalculateSize were virtual. }
|
||||||
|
procedure TJvCustomHTLabel.CalculatePreferredSize(
|
||||||
|
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
|
var
|
||||||
|
AWidth: Integer;
|
||||||
|
begin
|
||||||
|
if (Parent = nil) or (not Parent.HandleAllocated) then Exit;
|
||||||
|
if WidthIsAnchored and WordWrap then
|
||||||
|
AWidth := Width
|
||||||
|
else
|
||||||
|
AWidth := 10000;
|
||||||
|
AWidth := Constraints.MinMaxWidth(AWidth);
|
||||||
|
CalculateSize(AWidth,PreferredWidth,PreferredHeight);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvCustomHTLabel.CalculateSize(MaxWidth: integer;
|
||||||
|
var NeededWidth, NeededHeight: integer);
|
||||||
|
begin
|
||||||
|
Canvas.Handle;
|
||||||
|
Canvas.Font.Assign(Font);
|
||||||
|
NeededHeight := ItemHTHeight(Canvas, Caption, SuperSubScriptRatio);
|
||||||
|
NeededWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], Caption, SuperSubScriptRatio);
|
||||||
|
end;
|
||||||
|
|
||||||
function TJvCustomHTLabel.ComputeLayoutRect: TRect;
|
function TJvCustomHTLabel.ComputeLayoutRect: TRect;
|
||||||
|
var
|
||||||
|
W, H: Integer;
|
||||||
begin
|
begin
|
||||||
Result := ClientRect;
|
Result := ClientRect;
|
||||||
|
CalculateSize(Width, W, H);
|
||||||
|
case Alignment of
|
||||||
|
taLeftJustify:
|
||||||
|
;
|
||||||
|
taRightJustify:
|
||||||
|
Result.Left := Result.Right - W;
|
||||||
|
taCenter:
|
||||||
|
Result.Left := (Result.Left + Result.Right - W) div 2;
|
||||||
|
end;
|
||||||
case Layout of
|
case Layout of
|
||||||
tlTop:
|
tlTop:
|
||||||
;
|
;
|
||||||
tlBottom:
|
tlBottom:
|
||||||
Result.Top := Result.Bottom - ItemHTHeight(Canvas, Caption, SuperSubScriptRatio);
|
Result.Top := Result.Bottom - H;
|
||||||
tlCenter:
|
tlCenter:
|
||||||
Result.Top := (Result.Bottom - Result.Top - ItemHTHeight(Canvas, Caption, SuperSubScriptRatio)) div 2;
|
Result.Top := (Result.Top + Result.Bottom - H) div 2;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvCustomHTLabel.SetAutoSize(Value: Boolean);
|
procedure TJvCustomHTLabel.SetSuperSubScriptRatio(const Value: Double);
|
||||||
begin
|
|
||||||
if AutoSize <> Value then
|
|
||||||
begin
|
|
||||||
inherited SetAutoSize(Value);
|
|
||||||
AdjustSize;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvCustomHTLabel.SetSuperSubScriptRation(const Value: Double);
|
|
||||||
begin
|
begin
|
||||||
if FSuperSubScriptRatio <> Value then
|
if FSuperSubScriptRatio <> Value then
|
||||||
begin
|
begin
|
||||||
@ -1044,6 +1038,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TJvHTLabel }
|
{ TJvHTLabel }
|
||||||
|
|
||||||
procedure TJvHTLabel.DefineProperties(Filer: TFiler);
|
procedure TJvHTLabel.DefineProperties(Filer: TFiler);
|
||||||
|
Reference in New Issue
Block a user