mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:39:25 +02:00
AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started
git-svn-id: trunk@3450 -
This commit is contained in:
parent
25d5234def
commit
adf826a1be
@ -55,7 +55,7 @@ begin
|
|||||||
Try
|
Try
|
||||||
R := Rect(0,0, Width, Height);
|
R := Rect(0,0, Width, Height);
|
||||||
DrawText(DC, PChar(Caption), Length(Caption), R,
|
DrawText(DC, PChar(Caption), Length(Caption), R,
|
||||||
DT_CalcRect or DT_NOPrefix);
|
DT_CalcRect);
|
||||||
If R.Right > Width then
|
If R.Right > Width then
|
||||||
Width := R.Right + 25;
|
Width := R.Right + 25;
|
||||||
If R.Bottom > Height then
|
If R.Bottom > Height then
|
||||||
@ -70,6 +70,9 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.8 2002/10/03 00:08:50 lazarus
|
||||||
|
AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started
|
||||||
|
|
||||||
Revision 1.7 2002/09/10 07:33:37 lazarus
|
Revision 1.7 2002/09/10 07:33:37 lazarus
|
||||||
MG: fixed TCheckBox.DoAutoSize on loading
|
MG: fixed TCheckBox.DoAutoSize on loading
|
||||||
|
|
||||||
|
@ -165,8 +165,29 @@ begin
|
|||||||
CNSendMessage(LM_SetValue,Self,@fState);
|
CNSendMessage(LM_SetValue,Self,@fState);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomCheckBox.SetText(const Value: TCaption);
|
||||||
|
var
|
||||||
|
ParseStr : String;
|
||||||
|
AccelIndex : Longint;
|
||||||
|
begin
|
||||||
|
Inherited SetText(Value);
|
||||||
|
If (not HandleAllocated) or (csDesigning in ComponentState) then exit;
|
||||||
|
ParseStr := Value;
|
||||||
|
AccelIndex := DeleteAmpersands(ParseStr);
|
||||||
|
If AccelIndex > -1 then begin
|
||||||
|
With FShortcut do begin
|
||||||
|
Handle := Self.Handle;
|
||||||
|
OldKey := NewKey;
|
||||||
|
NewKey := Char2VK(ParseStr[AccelIndex]);
|
||||||
|
end;
|
||||||
|
CNSendMessage(LM_SETSHORTCUT, Self, @FShortcut);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.8 2002/10/03 00:08:50 lazarus
|
||||||
|
AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started
|
||||||
|
|
||||||
Revision 1.7 2002/09/10 07:33:37 lazarus
|
Revision 1.7 2002/09/10 07:33:37 lazarus
|
||||||
MG: fixed TCheckBox.DoAutoSize on loading
|
MG: fixed TCheckBox.DoAutoSize on loading
|
||||||
|
|
||||||
|
@ -68,6 +68,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TCustomLabel.DoAutoSize;
|
||||||
|
var
|
||||||
|
R : TRect;
|
||||||
|
DC : hDC;
|
||||||
|
begin
|
||||||
|
If AutoSizing or not AutoSize then
|
||||||
|
Exit;
|
||||||
|
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||||
|
AutoSizing := True;
|
||||||
|
DC := GetDC(Handle);
|
||||||
|
Try
|
||||||
|
R := Rect(0,0, Width, Height);
|
||||||
|
DrawText(DC, PChar(Caption + 'W'), Length(Caption) + 1, R,
|
||||||
|
DT_CalcRect or DT_NoPrefix or DT_Internal);
|
||||||
|
Width := R.Right;
|
||||||
|
Height := R.Bottom;
|
||||||
|
Finally
|
||||||
|
ReleaseDC(Handle, DC);
|
||||||
|
AutoSizing := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomLabel.SetFocusControl
|
Method: TCustomLabel.SetFocusControl
|
||||||
Params: Val - new property value
|
Params: Val - new property value
|
||||||
@ -144,6 +166,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.7 2002/10/03 00:08:50 lazarus
|
||||||
|
AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started
|
||||||
|
|
||||||
Revision 1.6 2002/09/03 20:02:01 lazarus
|
Revision 1.6 2002/09/03 20:02:01 lazarus
|
||||||
Intermediate UI patch to show a bug.
|
Intermediate UI patch to show a bug.
|
||||||
|
|
||||||
|
@ -171,8 +171,13 @@ Begin
|
|||||||
R.Left := R.Right;
|
R.Left := R.Right;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else begin
|
||||||
|
Style.Clipping := False;
|
||||||
|
InflateRect(R, -2, -2);
|
||||||
|
Canvas.FillRect(R);
|
||||||
|
InflateRect(R, 2, 2);
|
||||||
Canvas.TextRect(R, 2, 0, SimpleText, Style);
|
Canvas.TextRect(R, 2, 0, SimpleText, Style);
|
||||||
|
end;
|
||||||
End;
|
End;
|
||||||
// included by comctrls.pp
|
// included by comctrls.pp
|
||||||
|
|
||||||
|
@ -137,8 +137,22 @@ type
|
|||||||
property Align;
|
property Align;
|
||||||
property Anchors;
|
property Anchors;
|
||||||
property Caption;
|
property Caption;
|
||||||
|
property Color;
|
||||||
|
property Constraints;
|
||||||
|
property Ctl3D;
|
||||||
|
property Enabled;
|
||||||
|
property Font;
|
||||||
|
property ParentColor;
|
||||||
|
property ParentCtl3D;
|
||||||
|
property ParentFont;
|
||||||
|
property ParentShowHint;
|
||||||
|
property PopupMenu;
|
||||||
|
property ShowHint;
|
||||||
|
property TabOrder;
|
||||||
|
property TabStop;
|
||||||
property Visible;
|
property Visible;
|
||||||
property OnClick;
|
property OnClick;
|
||||||
|
property OnDblClick;
|
||||||
property OnEnter;
|
property OnEnter;
|
||||||
property OnExit;
|
property OnExit;
|
||||||
property OnKeyDown;
|
property OnKeyDown;
|
||||||
@ -149,8 +163,7 @@ type
|
|||||||
property OnMouseUp;
|
property OnMouseUp;
|
||||||
property OnResize;
|
property OnResize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TCustomComboBox }
|
{ TCustomComboBox }
|
||||||
|
|
||||||
TComboBoxStyle = (csDropDown, csSimple, csDropDownList, csOwnerDrawFixed,
|
TComboBoxStyle = (csDropDown, csSimple, csDropDownList, csOwnerDrawFixed,
|
||||||
@ -491,6 +504,7 @@ type
|
|||||||
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
||||||
protected
|
protected
|
||||||
function GetLabelText: String ; virtual;
|
function GetLabelText: String ; virtual;
|
||||||
|
procedure DoAutoSize; Override;
|
||||||
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
|
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
|
||||||
procedure SetFocusControl(Val : TWinControl); virtual;
|
procedure SetFocusControl(Val : TWinControl); virtual;
|
||||||
procedure SetShowAccelChar(Val : boolean); virtual;
|
procedure SetShowAccelChar(Val : boolean); virtual;
|
||||||
@ -510,6 +524,7 @@ type
|
|||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
property Alignment;
|
property Alignment;
|
||||||
|
property AutoSize;
|
||||||
property Anchors;
|
property Anchors;
|
||||||
property Caption;
|
property Caption;
|
||||||
property Color;
|
property Color;
|
||||||
@ -550,6 +565,7 @@ type
|
|||||||
// FAlignment: TLeftRight;
|
// FAlignment: TLeftRight;
|
||||||
FAllowGrayed: Boolean;
|
FAllowGrayed: Boolean;
|
||||||
FState: TCheckBoxState;
|
FState: TCheckBoxState;
|
||||||
|
FShortCut : TLMShortcut;
|
||||||
procedure SetState(Value: TCheckBoxState);
|
procedure SetState(Value: TCheckBoxState);
|
||||||
function GetState : TCheckBoxState;
|
function GetState : TCheckBoxState;
|
||||||
protected
|
protected
|
||||||
@ -557,6 +573,7 @@ type
|
|||||||
procedure Toggle; virtual;
|
procedure Toggle; virtual;
|
||||||
function GetChecked: Boolean; override;
|
function GetChecked: Boolean; override;
|
||||||
procedure SetChecked(Value: Boolean); override;
|
procedure SetChecked(Value: Boolean); override;
|
||||||
|
procedure SetText(const Value: TCaption); override;
|
||||||
procedure ApplyChanges; virtual;
|
procedure ApplyChanges; virtual;
|
||||||
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed;
|
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed;
|
||||||
property State: TCheckBoxState read GetState write SetState;
|
property State: TCheckBoxState read GetState write SetState;
|
||||||
@ -1282,6 +1299,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.50 2002/10/03 00:08:50 lazarus
|
||||||
|
AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started
|
||||||
|
|
||||||
Revision 1.49 2002/10/02 16:16:40 lazarus
|
Revision 1.49 2002/10/02 16:16:40 lazarus
|
||||||
MG: accelerated unitdependencies
|
MG: accelerated unitdependencies
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user