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:
alexs75
2014-09-15 11:27:14 +00:00
parent ce34aeb405
commit b7abdabd0b
2 changed files with 54 additions and 43 deletions

View File

@ -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}

View File

@ -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
@ -2259,6 +2260,14 @@ begin
H1 := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) + H1 := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) +
tmpCanvas.TextWidth('W')) div DefaultRowHeight, H) tmpCanvas.TextWidth('W')) div DefaultRowHeight, H)
else else
begin
if rxTit.CaptionLinesCount = 0 then
begin
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
if H1 > WordCount(rxTit.Caption, [' ']) then
H1 := WordCount(rxTit.Caption, [' ']);
end
else
begin begin
if rxTit.CaptionLinesCount > H then if rxTit.CaptionLinesCount > H then
H := rxTit.CaptionLinesCount; H := rxTit.CaptionLinesCount;
@ -2290,6 +2299,8 @@ begin
end; end;
H1 := H1 + MLRec1.Hegth; H1 := H1 + MLRec1.Hegth;
end; end;
end;
end; end;
end; end;
if H1 > H then if H1 > H then