You've already forked lazarus-ccr
Starting right-to-left languages support
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2809 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -110,6 +110,8 @@ type
|
|||||||
property AutoButtonSize;
|
property AutoButtonSize;
|
||||||
property AutoAdvance;
|
property AutoAdvance;
|
||||||
property HideDateTimeParts;
|
property HideDateTimeParts;
|
||||||
|
property BiDiMode;
|
||||||
|
property ParentBiDiMode;
|
||||||
//events:
|
//events:
|
||||||
property OnChange;
|
property OnChange;
|
||||||
property OnCheckBoxChange;
|
property OnCheckBoxChange;
|
||||||
|
@ -254,7 +254,7 @@ type
|
|||||||
function GetDateTimePartFromTextPart(TextPart: TTextPart): TDateTimePart;
|
function GetDateTimePartFromTextPart(TextPart: TTextPart): TDateTimePart;
|
||||||
function GetSelectedDateTimePart: TDateTimePart;
|
function GetSelectedDateTimePart: TDateTimePart;
|
||||||
procedure FontChanged(Sender: TObject); override;
|
procedure FontChanged(Sender: TObject); override;
|
||||||
function GetTextOrigin: TPoint;
|
function GetTextOrigin(IgnoreRightToLeft: Boolean = False): TPoint;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure KeyPress(var Key: char); override;
|
procedure KeyPress(var Key: char); override;
|
||||||
procedure SelectTextPartUnderMouse(XMouse: Integer);
|
procedure SelectTextPartUnderMouse(XMouse: Integer);
|
||||||
@ -270,6 +270,7 @@ type
|
|||||||
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
||||||
procedure CalculatePreferredSize(var PreferredWidth,
|
procedure CalculatePreferredSize(var PreferredWidth,
|
||||||
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||||
|
procedure SetBiDiMode(AValue: TBiDiMode); override;
|
||||||
|
|
||||||
procedure IncreaseCurrentTextPart;
|
procedure IncreaseCurrentTextPart;
|
||||||
procedure DecreaseCurrentTextPart;
|
procedure DecreaseCurrentTextPart;
|
||||||
@ -423,6 +424,8 @@ type
|
|||||||
property AutoButtonSize;
|
property AutoButtonSize;
|
||||||
property AutoAdvance;
|
property AutoAdvance;
|
||||||
property HideDateTimeParts;
|
property HideDateTimeParts;
|
||||||
|
property BiDiMode;
|
||||||
|
property ParentBiDiMode;
|
||||||
// events:
|
// events:
|
||||||
property OnChange;
|
property OnChange;
|
||||||
property OnCheckBoxChange;
|
property OnCheckBoxChange;
|
||||||
@ -563,7 +566,11 @@ begin
|
|||||||
H := Height;
|
H := Height;
|
||||||
W := Width;
|
W := Width;
|
||||||
|
|
||||||
|
if IsRightToLeft then
|
||||||
|
P := DTPicker.ControlToScreen(Point(DTPicker.Width - W, DTPicker.Height))
|
||||||
|
else
|
||||||
P := DTPicker.ControlToScreen(Point(0, DTPicker.Height));
|
P := DTPicker.ControlToScreen(Point(0, DTPicker.Height));
|
||||||
|
|
||||||
M := Screen.MonitorFromWindow(DTPicker.Handle);
|
M := Screen.MonitorFromWindow(DTPicker.Handle);
|
||||||
|
|
||||||
R := M.WorkareaRect;
|
R := M.WorkareaRect;
|
||||||
@ -711,6 +718,7 @@ begin
|
|||||||
FClosing := False;
|
FClosing := False;
|
||||||
|
|
||||||
DTPicker := ADTPicker;
|
DTPicker := ADTPicker;
|
||||||
|
BiDiMode := DTPicker.BiDiMode;
|
||||||
DTPickersParentForm := GetParentForm(DTPicker);
|
DTPickersParentForm := GetParentForm(DTPicker);
|
||||||
if Assigned(DTPickersParentForm) then begin
|
if Assigned(DTPickersParentForm) then begin
|
||||||
DTPickersParentForm.AddHandlerOnVisibleChanged(@VisibleOfParentChanged);
|
DTPickersParentForm.AddHandlerOnVisibleChanged(@VisibleOfParentChanged);
|
||||||
@ -720,6 +728,7 @@ begin
|
|||||||
P := Point(0, 0);
|
P := Point(0, 0);
|
||||||
|
|
||||||
Cal := TCalendar.Create(nil);
|
Cal := TCalendar.Create(nil);
|
||||||
|
Cal.ParentBiDiMode := True;
|
||||||
Cal.AutoSize := True;
|
Cal.AutoSize := True;
|
||||||
Cal.GetPreferredSize(P.x, P.y);
|
Cal.GetPreferredSize(P.x, P.y);
|
||||||
|
|
||||||
@ -977,6 +986,7 @@ begin
|
|||||||
|
|
||||||
FCheckBox.Parent := Self;
|
FCheckBox.Parent := Self;
|
||||||
|
|
||||||
|
FCheckBox.OnChange := @CheckBoxChange;
|
||||||
end else begin
|
end else begin
|
||||||
FCheckBox.OnChange := nil;
|
FCheckBox.OnChange := nil;
|
||||||
FreeAndNil(FCheckBox);
|
FreeAndNil(FCheckBox);
|
||||||
@ -1698,13 +1708,18 @@ end;
|
|||||||
---------------
|
---------------
|
||||||
Returns upper left corner of the rectangle where the text is written.
|
Returns upper left corner of the rectangle where the text is written.
|
||||||
Also used in calculating our preffered size. }
|
Also used in calculating our preffered size. }
|
||||||
function TCustomZVDateTimePicker.GetTextOrigin: TPoint;
|
function TCustomZVDateTimePicker.GetTextOrigin(IgnoreRightToLeft: Boolean
|
||||||
|
): TPoint;
|
||||||
begin
|
begin
|
||||||
Result.y := BorderSpacing.InnerBorder + BorderWidth;
|
Result.y := BorderSpacing.InnerBorder + BorderWidth;
|
||||||
if Assigned(FCheckBox) then
|
if Assigned(FCheckBox) then
|
||||||
Result.x := Result.y + FCheckBox.BorderSpacing.Left + FCheckBox.Width
|
Result.x := Result.y + FCheckBox.BorderSpacing.Left
|
||||||
|
+ FCheckBox.BorderSpacing.Right + FCheckBox.Width
|
||||||
else
|
else
|
||||||
Result.x := Result.y;
|
Result.x := Result.y;
|
||||||
|
|
||||||
|
if (not IgnoreRightToLeft) and IsRightToLeft then
|
||||||
|
Result.x := ClientWidth - Result.x - FTextWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ MoveSelectionLR
|
{ MoveSelectionLR
|
||||||
@ -2062,7 +2077,7 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
RecalculateTextSizesIfNeeded;
|
RecalculateTextSizesIfNeeded;
|
||||||
TextOrigin := GetTextOrigin;
|
TextOrigin := GetTextOrigin(True);
|
||||||
|
|
||||||
// We must use TextOrigin's x + y (x is, of course, left margin, but not right
|
// We must use TextOrigin's x + y (x is, of course, left margin, but not right
|
||||||
// margin if check box is shown. However, y, which is top margin, always
|
// margin if check box is shown. However, y, which is top margin, always
|
||||||
@ -2082,6 +2097,12 @@ begin
|
|||||||
PreferredHeight := 2 * TextOrigin.y + FTextHeight + M;
|
PreferredHeight := 2 * TextOrigin.y + FTextHeight + M;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomZVDateTimePicker.SetBiDiMode(AValue: TBiDiMode);
|
||||||
|
begin
|
||||||
|
inherited SetBiDiMode(AValue);
|
||||||
|
ArrangeCtrls;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomZVDateTimePicker.IncreaseCurrentTextPart;
|
procedure TCustomZVDateTimePicker.IncreaseCurrentTextPart;
|
||||||
begin
|
begin
|
||||||
if DateIsNull then begin
|
if DateIsNull then begin
|
||||||
@ -2658,15 +2679,39 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomZVDateTimePicker.ArrangeCtrls;
|
procedure TCustomZVDateTimePicker.ArrangeCtrls;
|
||||||
|
var
|
||||||
|
C: TControl;
|
||||||
begin
|
begin
|
||||||
if not FDoNotArrangeControls then begin //Read the note above CreateWnd procedure.
|
if not FDoNotArrangeControls then begin //Read the note above CreateWnd procedure.
|
||||||
DisableAlign;
|
DisableAlign;
|
||||||
try
|
try
|
||||||
if GetShowCheckBox then begin
|
if GetShowCheckBox then begin
|
||||||
|
if IsRightToLeft then begin
|
||||||
|
FCheckBox.Align := alRight;
|
||||||
|
FCheckBox.BorderSpacing.Left := 0;
|
||||||
|
FCheckBox.BorderSpacing.Right := 2;
|
||||||
|
end else begin
|
||||||
FCheckBox.Align := alLeft;
|
FCheckBox.Align := alLeft;
|
||||||
FCheckBox.BorderSpacing.Left := 2;
|
FCheckBox.BorderSpacing.Left := 2;
|
||||||
|
FCheckBox.BorderSpacing.Right := 0;
|
||||||
|
end;
|
||||||
FCheckBox.BringToFront;
|
FCheckBox.BringToFront;
|
||||||
FCheckBox.OnChange := @CheckBoxChange;
|
end;
|
||||||
|
|
||||||
|
if Assigned(FUpDown) then
|
||||||
|
C := FUpDown
|
||||||
|
else if Assigned(FArrowButton) then
|
||||||
|
C := FArrowButton
|
||||||
|
else
|
||||||
|
C := nil;
|
||||||
|
|
||||||
|
if Assigned(C) then begin
|
||||||
|
if IsRightToLeft then
|
||||||
|
C.Align := alLeft
|
||||||
|
else
|
||||||
|
C.Align := alRight;
|
||||||
|
|
||||||
|
C.BringToFront;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CheckTextEnabled;
|
CheckTextEnabled;
|
||||||
@ -2754,12 +2799,19 @@ begin
|
|||||||
TextStyle.Layout := tlCenter;
|
TextStyle.Layout := tlCenter;
|
||||||
TextStyle.Wordbreak := False;
|
TextStyle.Wordbreak := False;
|
||||||
TextStyle.Opaque := False;
|
TextStyle.Opaque := False;
|
||||||
|
TextStyle.RightToLeft := IsRightToLeft;
|
||||||
|
|
||||||
if DateIsNull and (FTextForNullDate > '')
|
if DateIsNull and (FTextForNullDate > '')
|
||||||
and (not (FTextEnabled and Focused)) then begin
|
and (not (FTextEnabled and Focused)) then begin
|
||||||
|
|
||||||
R.Right := MaxInt;
|
if IsRightToLeft then begin
|
||||||
|
TextStyle.Alignment := taRightJustify;
|
||||||
|
R.Right := R.Left + FTextWidth;
|
||||||
|
R.Left := 0;
|
||||||
|
end else begin
|
||||||
TextStyle.Alignment := taLeftJustify;
|
TextStyle.Alignment := taLeftJustify;
|
||||||
|
R.Right := Width;
|
||||||
|
end;
|
||||||
|
|
||||||
if FTextEnabled then
|
if FTextEnabled then
|
||||||
Canvas.Font.Color := Font.Color
|
Canvas.Font.Color := Font.Color
|
||||||
@ -3273,8 +3325,6 @@ procedure TCustomZVDateTimePicker.UpdateShowArrowButton(
|
|||||||
[csNoFocus, csNoDesignSelectable];
|
[csNoFocus, csNoDesignSelectable];
|
||||||
TDTSpeedButton(FArrowButton).DTPicker := Self;
|
TDTSpeedButton(FArrowButton).DTPicker := Self;
|
||||||
FArrowButton.SetBounds(0, 0, DefaultArrowButtonWidth, 1);
|
FArrowButton.SetBounds(0, 0, DefaultArrowButtonWidth, 1);
|
||||||
FArrowButton.Align := alRight;
|
|
||||||
FArrowButton.BringToFront;
|
|
||||||
|
|
||||||
DrawArrowButtonGlyph;
|
DrawArrowButtonGlyph;
|
||||||
|
|
||||||
@ -3298,8 +3348,6 @@ procedure TCustomZVDateTimePicker.UpdateShowArrowButton(
|
|||||||
TDTUpDown(FUpDown).DTPicker := Self;
|
TDTUpDown(FUpDown).DTPicker := Self;
|
||||||
|
|
||||||
FUpDown.SetBounds(0, 0, DefaultUpDownWidth, 1);
|
FUpDown.SetBounds(0, 0, DefaultUpDownWidth, 1);
|
||||||
FUpDown.Align := alRight;
|
|
||||||
FUpDown.BringToFront;
|
|
||||||
|
|
||||||
FUpDown.Parent := Self;
|
FUpDown.Parent := Self;
|
||||||
|
|
||||||
@ -3321,13 +3369,18 @@ begin
|
|||||||
|
|
||||||
if (ReallyShowArrowButton <> Assigned(FArrowButton)) or
|
if (ReallyShowArrowButton <> Assigned(FArrowButton)) or
|
||||||
(Assigned(FArrowButton) = Assigned(FUpDown)) then begin
|
(Assigned(FArrowButton) = Assigned(FUpDown)) then begin
|
||||||
|
DisableAlign;
|
||||||
|
try
|
||||||
if ReallyShowArrowButton then
|
if ReallyShowArrowButton then
|
||||||
CreateArrowBtn
|
CreateArrowBtn
|
||||||
else
|
else
|
||||||
CreateUpDown;
|
CreateUpDown;
|
||||||
|
|
||||||
ArrangeCtrls;
|
ArrangeCtrls;
|
||||||
|
|
||||||
|
finally
|
||||||
|
EnableAlign;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -211,10 +211,12 @@ var
|
|||||||
L, T, W, H: Integer;
|
L, T, W, H: Integer;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
M: TMonitor;
|
M: TMonitor;
|
||||||
|
AnchKindTrailing, AnchKindLeading: TAnchorKind;
|
||||||
begin
|
begin
|
||||||
if Assigned(Caller) then begin
|
if Assigned(Caller) then begin
|
||||||
CallerZVDateTimePicker := Caller;
|
CallerZVDateTimePicker := Caller;
|
||||||
Prop := UpperCase(PropertyName);
|
Prop := UpperCase(PropertyName);
|
||||||
|
BiDiMode := CallerZVDateTimePicker.BiDiMode;
|
||||||
|
|
||||||
Modified := False;
|
Modified := False;
|
||||||
ZVDateTimePicker1.Kind := dtkDateTime;
|
ZVDateTimePicker1.Kind := dtkDateTime;
|
||||||
@ -251,17 +253,25 @@ begin
|
|||||||
ZVDateTimePicker1.TimeDisplay := tdHMSMs;
|
ZVDateTimePicker1.TimeDisplay := tdHMSMs;
|
||||||
ZVDateTimePicker1.TimeFormat := CallerZVDateTimePicker.TimeFormat;
|
ZVDateTimePicker1.TimeFormat := CallerZVDateTimePicker.TimeFormat;
|
||||||
|
|
||||||
|
if IsRightToLeft then begin
|
||||||
|
AnchKindLeading := akRight;
|
||||||
|
AnchKindTrailing := akLeft;
|
||||||
|
end else begin
|
||||||
|
AnchKindLeading := akLeft;
|
||||||
|
AnchKindTrailing := akRight;
|
||||||
|
end;
|
||||||
|
|
||||||
ZVDateTimePickerMax.AnchorParallel(akTop, 20, Self);
|
ZVDateTimePickerMax.AnchorParallel(akTop, 20, Self);
|
||||||
ZVDateTimePickerMax.AnchorParallel(akRight, 20, Self);
|
ZVDateTimePickerMax.AnchorParallel(AnchKindTrailing, 20, Self);
|
||||||
LabelMax.AnchorVerticalCenterTo(ZVDateTimePickerMax);
|
LabelMax.AnchorVerticalCenterTo(ZVDateTimePickerMax);
|
||||||
LabelMax.AnchorToNeighbour(akRight, 2, ZVDateTimePickerMax);
|
LabelMax.AnchorToNeighbour(AnchKindTrailing, 2, ZVDateTimePickerMax);
|
||||||
ZVDateTimePickerMin.AnchorParallel(akTop, 20, Self);
|
ZVDateTimePickerMin.AnchorParallel(akTop, 20, Self);
|
||||||
ZVDateTimePickerMin.AnchorToNeighbour(akRight, 20, LabelMax);
|
ZVDateTimePickerMin.AnchorToNeighbour(AnchKindTrailing, 20, LabelMax);
|
||||||
LabelMin.AnchorToNeighbour(akRight, 2, ZVDateTimePickerMin);
|
LabelMin.AnchorToNeighbour(AnchKindTrailing, 2, ZVDateTimePickerMin);
|
||||||
LabelMin.AnchorVerticalCenterTo(ZVDateTimePickerMin);
|
LabelMin.AnchorVerticalCenterTo(ZVDateTimePickerMin);
|
||||||
ZVDateTimePicker1.AnchorParallel(akLeft, 0, ZVDateTimePickerMin);
|
ZVDateTimePicker1.AnchorParallel(AnchKindLeading, 0, ZVDateTimePickerMin);
|
||||||
ZVDateTimePicker1.AnchorToNeighbour(akTop, 20, ZVDateTimePickerMin);
|
ZVDateTimePicker1.AnchorToNeighbour(akTop, 20, ZVDateTimePickerMin);
|
||||||
Label1.AnchorToNeighbour(akRight, 2, ZVDateTimePicker1);
|
Label1.AnchorToNeighbour(AnchKindTrailing, 2, ZVDateTimePicker1);
|
||||||
Label1.AnchorVerticalCenterTo(ZVDateTimePicker1);
|
Label1.AnchorVerticalCenterTo(ZVDateTimePicker1);
|
||||||
LabelNull.AnchorToNeighbour(akTop, 2, ZVDateTimePicker1);
|
LabelNull.AnchorToNeighbour(akTop, 2, ZVDateTimePicker1);
|
||||||
LabelNull.AnchorHorizontalCenterTo(ZVDateTimePicker1);
|
LabelNull.AnchorHorizontalCenterTo(ZVDateTimePicker1);
|
||||||
|
Reference in New Issue
Block a user