AJ: TCustomLabel Autosize, TCustomCheckbox '&' shortcuts started

git-svn-id: trunk@3450 -
This commit is contained in:
lazarus 2002-10-03 00:08:50 +00:00
parent 25d5234def
commit adf826a1be
5 changed files with 78 additions and 4 deletions

View File

@ -55,7 +55,7 @@ begin
Try
R := Rect(0,0, Width, Height);
DrawText(DC, PChar(Caption), Length(Caption), R,
DT_CalcRect or DT_NOPrefix);
DT_CalcRect);
If R.Right > Width then
Width := R.Right + 25;
If R.Bottom > Height then
@ -70,6 +70,9 @@ end;
{
$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
MG: fixed TCheckBox.DoAutoSize on loading

View File

@ -165,8 +165,29 @@ begin
CNSendMessage(LM_SetValue,Self,@fState);
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$
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
MG: fixed TCheckBox.DoAutoSize on loading

View File

@ -68,6 +68,28 @@ begin
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
Params: Val - new property value
@ -144,6 +166,9 @@ end;
{ =============================================================================
$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
Intermediate UI patch to show a bug.

View File

@ -171,8 +171,13 @@ Begin
R.Left := R.Right;
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);
end;
End;
// included by comctrls.pp

View File

@ -137,8 +137,22 @@ type
property Align;
property Anchors;
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 OnClick;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
@ -149,8 +163,7 @@ type
property OnMouseUp;
property OnResize;
end;
{ TCustomComboBox }
TComboBoxStyle = (csDropDown, csSimple, csDropDownList, csOwnerDrawFixed,
@ -491,6 +504,7 @@ type
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
protected
function GetLabelText: String ; virtual;
procedure DoAutoSize; Override;
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
procedure SetFocusControl(Val : TWinControl); virtual;
procedure SetShowAccelChar(Val : boolean); virtual;
@ -510,6 +524,7 @@ type
published
property Align;
property Alignment;
property AutoSize;
property Anchors;
property Caption;
property Color;
@ -550,6 +565,7 @@ type
// FAlignment: TLeftRight;
FAllowGrayed: Boolean;
FState: TCheckBoxState;
FShortCut : TLMShortcut;
procedure SetState(Value: TCheckBoxState);
function GetState : TCheckBoxState;
protected
@ -557,6 +573,7 @@ type
procedure Toggle; virtual;
function GetChecked: Boolean; override;
procedure SetChecked(Value: Boolean); override;
procedure SetText(const Value: TCaption); override;
procedure ApplyChanges; virtual;
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed;
property State: TCheckBoxState read GetState write SetState;
@ -1282,6 +1299,9 @@ end.
{ =============================================================================
$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
MG: accelerated unitdependencies