You've already forked lazarus-ccr
RxDBGrid - fix calc title row height. Less compiler hints
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3568 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -456,7 +456,7 @@ begin
|
|||||||
M := N1; D := N2;
|
M := N1; D := N2;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ScanChar(S, Pos, DateSeparator);
|
ScanChar(S, Pos, DefaultFormatSettings.DateSeparator);
|
||||||
ScanBlanks(S, Pos);
|
ScanBlanks(S, Pos);
|
||||||
(*
|
(*
|
||||||
{$IFDEF RX_D3}
|
{$IFDEF RX_D3}
|
||||||
@ -481,9 +481,9 @@ function MonthFromName(const S: string; MaxLen: Byte): Byte;
|
|||||||
begin
|
begin
|
||||||
if Length(S) > 0 then
|
if Length(S) > 0 then
|
||||||
for Result := 1 to 12 do begin
|
for Result := 1 to 12 do begin
|
||||||
if (Length(LongMonthNames[Result]) > 0) and
|
if (Length(DefaultFormatSettings.LongMonthNames[Result]) > 0) and
|
||||||
(AnsiCompareText(Copy(S, 1, MaxLen),
|
(AnsiCompareText(Copy(S, 1, MaxLen),
|
||||||
Copy(LongMonthNames[Result], 1, MaxLen)) = 0) then Exit;
|
Copy(DefaultFormatSettings.LongMonthNames[Result], 1, MaxLen)) = 0) then Exit;
|
||||||
end;
|
end;
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -559,7 +559,7 @@ end;
|
|||||||
|
|
||||||
function StrToDateDef(const S: string; Default: TDateTime): TDateTime;
|
function StrToDateDef(const S: string; Default: TDateTime): TDateTime;
|
||||||
begin
|
begin
|
||||||
if not InternalStrToDate(ShortDateFormat, S, Result) then
|
if not InternalStrToDate(DefaultFormatSettings.ShortDateFormat, S, Result) then
|
||||||
Result := Trunc(Default);
|
Result := Trunc(Default);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -572,14 +572,14 @@ end;
|
|||||||
function DefDateFormat(FourDigitYear: Boolean): string;
|
function DefDateFormat(FourDigitYear: Boolean): string;
|
||||||
begin
|
begin
|
||||||
if FourDigitYear then begin
|
if FourDigitYear then begin
|
||||||
case GetDateOrder(ShortDateFormat) of
|
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
|
||||||
doMDY: Result := 'MM/DD/YYYY';
|
doMDY: Result := 'MM/DD/YYYY';
|
||||||
doDMY: Result := 'DD/MM/YYYY';
|
doDMY: Result := 'DD/MM/YYYY';
|
||||||
doYMD: Result := 'YYYY/MM/DD';
|
doYMD: Result := 'YYYY/MM/DD';
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
case GetDateOrder(ShortDateFormat) of
|
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
|
||||||
doMDY: Result := 'MM/DD/YY';
|
doMDY: Result := 'MM/DD/YY';
|
||||||
doDMY: Result := 'DD/MM/YY';
|
doDMY: Result := 'DD/MM/YY';
|
||||||
doYMD: Result := 'YY/MM/DD';
|
doYMD: Result := 'YY/MM/DD';
|
||||||
@ -590,13 +590,13 @@ end;
|
|||||||
function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;
|
function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;
|
||||||
begin
|
begin
|
||||||
if FourDigitYear then begin
|
if FourDigitYear then begin
|
||||||
case GetDateOrder(ShortDateFormat) of
|
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
|
||||||
doMDY, doDMY: Result := '!99/99/9999;1;';
|
doMDY, doDMY: Result := '!99/99/9999;1;';
|
||||||
doYMD: Result := '!9999/99/99;1;';
|
doYMD: Result := '!9999/99/99;1;';
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
case GetDateOrder(ShortDateFormat) of
|
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
|
||||||
doMDY, doDMY: Result := '!99/99/99;1;';
|
doMDY, doDMY: Result := '!99/99/99;1;';
|
||||||
doYMD: Result := '!99/99/99;1;';
|
doYMD: Result := '!99/99/99;1;';
|
||||||
end;
|
end;
|
||||||
@ -638,7 +638,7 @@ end;
|
|||||||
{$IFNDEF USE_FOUR_DIGIT_YEAR}
|
{$IFNDEF USE_FOUR_DIGIT_YEAR}
|
||||||
function FourDigitYear: Boolean;
|
function FourDigitYear: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Pos('YYYY', AnsiUpperCase(ShortDateFormat)) > 0;
|
Result := Pos('YYYY', AnsiUpperCase(DefaultFormatSettings.ShortDateFormat)) > 0;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ procedure RegisterRxDBGridSortEngine(RxDBGridSortEngineClass: TRxDBGridSortEngin
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses Math, rxdconst, rxstrutils, rxdbgrid_findunit, rxdbgrid_columsunit,
|
uses Math, rxdconst, rxstrutils, strutils, rxdbgrid_findunit, rxdbgrid_columsunit,
|
||||||
rxlookup, tooledit, LCLProc, Clipbrd, rxfilterby, rxsortby, variants;
|
rxlookup, tooledit, LCLProc, Clipbrd, rxfilterby, rxsortby, variants;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -2167,7 +2167,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
tmpCanvas := GetWorkingCanvas(Canvas);
|
tmpCanvas := GetWorkingCanvas(Canvas);
|
||||||
try
|
try
|
||||||
H := 1;
|
// H := 1;
|
||||||
ClearMLCaptionPointers;
|
ClearMLCaptionPointers;
|
||||||
for i := 0 to Columns.Count - 1 do
|
for i := 0 to Columns.Count - 1 do
|
||||||
begin
|
begin
|
||||||
@ -2178,8 +2178,7 @@ begin
|
|||||||
if Assigned(rxTit) then
|
if Assigned(rxTit) then
|
||||||
begin
|
begin
|
||||||
if rxTit.Orientation in [toVertical270, toVertical90] then
|
if rxTit.Orientation in [toVertical270, toVertical90] then
|
||||||
H := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) +
|
// H := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) + tmpCanvas.TextWidth('W')*2) div DefaultRowHeight, H)
|
||||||
tmpCanvas.TextWidth('W')*2) div DefaultRowHeight, H)
|
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
rxColNext := nil;
|
rxColNext := nil;
|
||||||
@ -2190,11 +2189,11 @@ begin
|
|||||||
rxTitleNext := TRxColumnTitle(rxColNext.Title);
|
rxTitleNext := TRxColumnTitle(rxColNext.Title);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
W := Max(rxCol.Width - 6, 1);
|
// W := Max(rxCol.Width - 6, 1);
|
||||||
if rxTit.CaptionLinesCount > 0 then
|
if rxTit.CaptionLinesCount > 0 then
|
||||||
begin
|
begin
|
||||||
H2 := 0;
|
// H2 := 0;
|
||||||
H1 := 0;
|
// H1 := 0;
|
||||||
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
||||||
begin
|
begin
|
||||||
MLRec1 := rxTit.CaptionLine(j);
|
MLRec1 := rxTit.CaptionLine(j);
|
||||||
@ -2214,7 +2213,7 @@ begin
|
|||||||
|
|
||||||
MLRec1.Width := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
MLRec1.Width := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
||||||
|
|
||||||
if W > MLRec1.Width then
|
{ if W > MLRec1.Width then
|
||||||
H2 := 1
|
H2 := 1
|
||||||
else
|
else
|
||||||
H2 := MLRec1.Width div W + 1;
|
H2 := MLRec1.Width div W + 1;
|
||||||
@ -2222,16 +2221,16 @@ begin
|
|||||||
if H2 > WordCount(MLRec1.Caption, [' ']) then
|
if H2 > WordCount(MLRec1.Caption, [' ']) then
|
||||||
H2 := WordCount(MLRec1.Caption, [' ']);
|
H2 := WordCount(MLRec1.Caption, [' ']);
|
||||||
|
|
||||||
H1 := H1 + H2;
|
H1 := H1 + H2;}
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
{ else
|
||||||
begin
|
begin
|
||||||
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
|
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
|
||||||
if H1 > WordCount(rxTit.Caption, [' ']) then
|
if H1 > WordCount(rxTit.Caption, [' ']) then
|
||||||
H1 := WordCount(rxTit.Caption, [' ']);
|
H1 := WordCount(rxTit.Caption, [' ']);
|
||||||
end;
|
end;
|
||||||
H := Max(H1, H);
|
H := Max(H1, H); }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
||||||
@ -2246,12 +2245,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//Тут расчёт высоты заголовка каждой колонки - надо обработать слитые заголовки
|
//Тут расчёт высоты заголовка каждой колонки - надо обработать слитые заголовки
|
||||||
|
|
||||||
H := 1;
|
H := 1;
|
||||||
for i := 0 to Columns.Count - 1 do
|
for i := 0 to Columns.Count - 1 do
|
||||||
begin
|
begin
|
||||||
rxCol := TRxColumn(Columns[i]);
|
rxCol := TRxColumn(Columns[i]);
|
||||||
rxTit := TRxColumnTitle(rxCol.Title);
|
rxTit := TRxColumnTitle(rxCol.Title);
|
||||||
H1 := 0;
|
H1 := 0;
|
||||||
|
W := Max(rxCol.Width - 6, 1);
|
||||||
//Не забудем про вертикальную ориентацию
|
//Не забудем про вертикальную ориентацию
|
||||||
if Assigned(rxCol) and rxCol.Visible and Assigned(rxTit) then
|
if Assigned(rxCol) and rxCol.Visible and Assigned(rxTit) then
|
||||||
begin
|
begin
|
||||||
@ -2260,35 +2261,45 @@ begin
|
|||||||
tmpCanvas.TextWidth('W')) div DefaultRowHeight, H)
|
tmpCanvas.TextWidth('W')) div DefaultRowHeight, H)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if rxTit.CaptionLinesCount > H then
|
if rxTit.CaptionLinesCount = 0 then
|
||||||
H := rxTit.CaptionLinesCount;
|
|
||||||
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
|
||||||
begin
|
begin
|
||||||
MLRec1 := rxTit.CaptionLine(j);
|
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
|
||||||
S := MLRec1.Caption;
|
if H1 > WordCount(rxTit.Caption, [' ']) then
|
||||||
if not Assigned(MLRec1.Prior) then
|
H1 := WordCount(rxTit.Caption, [' ']);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if rxTit.CaptionLinesCount > H then
|
||||||
|
H := rxTit.CaptionLinesCount;
|
||||||
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
||||||
begin
|
begin
|
||||||
W := rxCol.Width;
|
MLRec1 := rxTit.CaptionLine(j);
|
||||||
P := MLRec1.Next;
|
S := MLRec1.Caption;
|
||||||
while Assigned(P) do
|
if not Assigned(MLRec1.Prior) then
|
||||||
begin
|
begin
|
||||||
Inc(W, P.Col.Width);
|
W := rxCol.Width;
|
||||||
P := P.Next;
|
P := MLRec1.Next;
|
||||||
end;
|
while Assigned(P) do
|
||||||
W1 := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
begin
|
||||||
if W1 > W then
|
Inc(W, P.Col.Width);
|
||||||
MLRec1.Hegth := Min(W1 div Max(W, 1) + 1, UTF8Length(MLRec1.Caption))
|
P := P.Next;
|
||||||
else
|
end;
|
||||||
MLRec1.Hegth := 1;
|
W1 := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
||||||
|
if W1 > W then
|
||||||
|
MLRec1.Hegth := Min(W1 div Max(W, 1) + 1, UTF8Length(MLRec1.Caption))
|
||||||
|
else
|
||||||
|
MLRec1.Hegth := 1;
|
||||||
|
|
||||||
P := MLRec1.Next;
|
P := MLRec1.Next;
|
||||||
while Assigned(P) do
|
while Assigned(P) do
|
||||||
begin
|
begin
|
||||||
P.Hegth := MLRec1.Hegth;
|
P.Hegth := MLRec1.Hegth;
|
||||||
P := P.Next;
|
P := P.Next;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
H1 := H1 + MLRec1.Hegth;
|
||||||
end;
|
end;
|
||||||
H1 := H1 + MLRec1.Hegth;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user