You've already forked lazarus-ccr
Add property AutoButtonSize
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2645 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,8 +4,6 @@ TDBZVDateTimePicker control for Lazarus
|
|||||||
Author: Zoran Vučenović, January and February 2010
|
Author: Zoran Vučenović, January and February 2010
|
||||||
Зоран Вученовић, јануар и фебруар 2010.
|
Зоран Вученовић, јануар и фебруар 2010.
|
||||||
|
|
||||||
Last change: August 2012
|
|
||||||
|
|
||||||
This unit is part of ZVDateTimeCtrls package for Lazarus.
|
This unit is part of ZVDateTimeCtrls package for Lazarus.
|
||||||
TDBZVDateTimePicker is data-aware version of TZVDateTimePicker control.
|
TDBZVDateTimePicker is data-aware version of TZVDateTimePicker control.
|
||||||
|
|
||||||
@ -109,6 +107,7 @@ type
|
|||||||
property DateMode;
|
property DateMode;
|
||||||
property UseDefaultSeparators;
|
property UseDefaultSeparators;
|
||||||
property Cascade;
|
property Cascade;
|
||||||
|
property AutoButtonSize;
|
||||||
//events:
|
//events:
|
||||||
property OnChange;
|
property OnChange;
|
||||||
property OnCheckBoxChange;
|
property OnCheckBoxChange;
|
||||||
|
@ -4,8 +4,6 @@ TZVDateTimePicker control for Lazarus
|
|||||||
Author: Zoran Vučenović, January and February 2010
|
Author: Zoran Vučenović, January and February 2010
|
||||||
Зоран Вученовић, јануар и фебруар 2010.
|
Зоран Вученовић, јануар и фебруар 2010.
|
||||||
|
|
||||||
Last change: September 2012
|
|
||||||
|
|
||||||
This unit is part of ZVDateTimeCtrls package for Lazarus.
|
This unit is part of ZVDateTimeCtrls package for Lazarus.
|
||||||
|
|
||||||
Delphi's Visual Component Library (VCL) has a control named TDateTimePicker,
|
Delphi's Visual Component Library (VCL) has a control named TDateTimePicker,
|
||||||
@ -45,7 +43,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
clocale, // needed to initialize default local settings on Linux.
|
clocale, // needed to initialize default locale settings on Linux.
|
||||||
{$endif}
|
{$endif}
|
||||||
Classes, SysUtils, LCLProc, Controls, LCLType, Graphics, Math, StdCtrls,
|
Classes, SysUtils, LCLProc, Controls, LCLType, Graphics, Math, StdCtrls,
|
||||||
Buttons, ExtCtrls, Forms, Calendar, ComCtrls, Types, LMessages
|
Buttons, ExtCtrls, Forms, Calendar, ComCtrls, Types, LMessages
|
||||||
@ -115,6 +113,7 @@ type
|
|||||||
|
|
||||||
TCustomZVDateTimePicker = class(TCustomControl)
|
TCustomZVDateTimePicker = class(TCustomControl)
|
||||||
private
|
private
|
||||||
|
FAutoButtonSize: Boolean;
|
||||||
FCascade: Boolean;
|
FCascade: Boolean;
|
||||||
FCenturyFrom, FEffectiveCenturyFrom: Word;
|
FCenturyFrom, FEffectiveCenturyFrom: Word;
|
||||||
FDateDisplayOrder: TDateDisplayOrder;
|
FDateDisplayOrder: TDateDisplayOrder;
|
||||||
@ -172,6 +171,7 @@ type
|
|||||||
function GetShowCheckBox: Boolean;
|
function GetShowCheckBox: Boolean;
|
||||||
function GetTime: TTime;
|
function GetTime: TTime;
|
||||||
procedure SetArrowShape(const AValue: TArrowShape);
|
procedure SetArrowShape(const AValue: TArrowShape);
|
||||||
|
procedure SetAutoButtonSize(AValue: Boolean);
|
||||||
procedure SetCenturyFrom(const AValue: Word);
|
procedure SetCenturyFrom(const AValue: Word);
|
||||||
procedure SetChecked(const AValue: Boolean);
|
procedure SetChecked(const AValue: Boolean);
|
||||||
procedure CheckTextEnabled;
|
procedure CheckTextEnabled;
|
||||||
@ -232,9 +232,11 @@ type
|
|||||||
procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
|
procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
|
||||||
procedure CheckBoxChange(Sender: TObject);
|
procedure CheckBoxChange(Sender: TObject);
|
||||||
procedure SetFocusIfPossible;
|
procedure SetFocusIfPossible;
|
||||||
|
procedure AutoResizeButton;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
|
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
|
||||||
|
procedure WMSize(var Message: TLMSize); message LM_SIZE;
|
||||||
|
|
||||||
class function GetControlClassDefaultSize: TSize; override;
|
class function GetControlClassDefaultSize: TSize; override;
|
||||||
|
|
||||||
@ -343,6 +345,8 @@ type
|
|||||||
property Date: TDate read GetDate write SetDate;
|
property Date: TDate read GetDate write SetDate;
|
||||||
property DateMode: TDTDateMode read FDateMode write SetDateMode;
|
property DateMode: TDTDateMode read FDateMode write SetDateMode;
|
||||||
property Cascade: Boolean read FCascade write FCascade default False;
|
property Cascade: Boolean read FCascade write FCascade default False;
|
||||||
|
property AutoButtonSize: Boolean
|
||||||
|
read FAutoButtonSize write SetAutoButtonSize default False;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -404,6 +408,7 @@ type
|
|||||||
property Time;
|
property Time;
|
||||||
property UseDefaultSeparators;
|
property UseDefaultSeparators;
|
||||||
property Cascade;
|
property Cascade;
|
||||||
|
property AutoButtonSize;
|
||||||
// events:
|
// events:
|
||||||
property OnChange;
|
property OnChange;
|
||||||
property OnCheckBoxChange;
|
property OnCheckBoxChange;
|
||||||
@ -2939,6 +2944,27 @@ begin
|
|||||||
DrawArrowButtonGlyph;
|
DrawArrowButtonGlyph;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
DefaultUpDownWidth = 15;
|
||||||
|
DefaultArrowButtonWidth = DefaultUpDownWidth + 2;
|
||||||
|
|
||||||
|
procedure TCustomZVDateTimePicker.SetAutoButtonSize(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FAutoButtonSize <> AValue then begin
|
||||||
|
FAutoButtonSize := AValue;
|
||||||
|
|
||||||
|
if AValue then
|
||||||
|
AutoResizeButton
|
||||||
|
else begin
|
||||||
|
if Assigned(FUpDown) then
|
||||||
|
FUpDown.Width := DefaultUpDownWidth
|
||||||
|
else if Assigned(FArrowButton) then
|
||||||
|
FArrowButton.Width := DefaultArrowButtonWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomZVDateTimePicker.SetCenturyFrom(const AValue: Word);
|
procedure TCustomZVDateTimePicker.SetCenturyFrom(const AValue: Word);
|
||||||
begin
|
begin
|
||||||
if FCenturyFrom = AValue then Exit;
|
if FCenturyFrom = AValue then Exit;
|
||||||
@ -2975,6 +3001,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomZVDateTimePicker.AutoResizeButton;
|
||||||
|
begin
|
||||||
|
if Assigned(FArrowButton) then
|
||||||
|
FArrowButton.Width := MulDiv(ClientHeight, 9, 10)
|
||||||
|
else if Assigned(FUpDown) then
|
||||||
|
FUpDown.Width := MulDiv(ClientHeight, 79, 100);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomZVDateTimePicker.WMKillFocus(var Message: TLMKillFocus);
|
procedure TCustomZVDateTimePicker.WMKillFocus(var Message: TLMKillFocus);
|
||||||
begin
|
begin
|
||||||
// On Qt it seems that WMKillFocus happens even when focus jumps to some other
|
// On Qt it seems that WMKillFocus happens even when focus jumps to some other
|
||||||
@ -2985,6 +3020,14 @@ begin
|
|||||||
inherited WMKillFocus(Message);
|
inherited WMKillFocus(Message);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomZVDateTimePicker.WMSize(var Message: TLMSize);
|
||||||
|
begin
|
||||||
|
inherited WMSize(Message);
|
||||||
|
|
||||||
|
if FAutoButtonSize then
|
||||||
|
AutoResizeButton;
|
||||||
|
end;
|
||||||
|
|
||||||
{$ifdef LCLGtk2}
|
{$ifdef LCLGtk2}
|
||||||
// On Gtk2, it seems that if a non-modal form is shown on top
|
// On Gtk2, it seems that if a non-modal form is shown on top
|
||||||
// of a modal one, it can't get user interaction. So it is useless then.
|
// of a modal one, it can't get user interaction. So it is useless then.
|
||||||
@ -3150,7 +3193,7 @@ procedure TCustomZVDateTimePicker.UpdateShowArrowButton(
|
|||||||
FArrowButton.ControlStyle := FArrowButton.ControlStyle +
|
FArrowButton.ControlStyle := FArrowButton.ControlStyle +
|
||||||
[csNoFocus, csNoDesignSelectable];
|
[csNoFocus, csNoDesignSelectable];
|
||||||
TDTSpeedButton(FArrowButton).DTPicker := Self;
|
TDTSpeedButton(FArrowButton).DTPicker := Self;
|
||||||
FArrowButton.SetBounds(0, 0, 17, 1);
|
FArrowButton.SetBounds(0, 0, DefaultArrowButtonWidth, 1);
|
||||||
FArrowButton.Align := alRight;
|
FArrowButton.Align := alRight;
|
||||||
FArrowButton.BringToFront;
|
FArrowButton.BringToFront;
|
||||||
|
|
||||||
@ -3175,7 +3218,7 @@ procedure TCustomZVDateTimePicker.UpdateShowArrowButton(
|
|||||||
|
|
||||||
TDTUpDown(FUpDown).DTPicker := Self;
|
TDTUpDown(FUpDown).DTPicker := Self;
|
||||||
|
|
||||||
FUpDown.SetBounds(0, 0, 15, 1);
|
FUpDown.SetBounds(0, 0, DefaultUpDownWidth, 1);
|
||||||
FUpDown.Align := alRight;
|
FUpDown.Align := alRight;
|
||||||
FUpDown.BringToFront;
|
FUpDown.BringToFront;
|
||||||
|
|
||||||
@ -3312,6 +3355,7 @@ begin
|
|||||||
FCalendarForm := nil;
|
FCalendarForm := nil;
|
||||||
FDoNotArrangeControls := True;
|
FDoNotArrangeControls := True;
|
||||||
FCascade := False;
|
FCascade := False;
|
||||||
|
FAutoButtonSize := False;
|
||||||
|
|
||||||
AdjustEffectiveDateDisplayOrder;
|
AdjustEffectiveDateDisplayOrder;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user