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;
end;
end;
ScanChar(S, Pos, DateSeparator);
ScanChar(S, Pos, DefaultFormatSettings.DateSeparator);
ScanBlanks(S, Pos);
(*
{$IFDEF RX_D3}
@ -481,9 +481,9 @@ function MonthFromName(const S: string; MaxLen: Byte): Byte;
begin
if Length(S) > 0 then
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),
Copy(LongMonthNames[Result], 1, MaxLen)) = 0) then Exit;
Copy(DefaultFormatSettings.LongMonthNames[Result], 1, MaxLen)) = 0) then Exit;
end;
Result := 0;
end;
@ -559,7 +559,7 @@ end;
function StrToDateDef(const S: string; Default: TDateTime): TDateTime;
begin
if not InternalStrToDate(ShortDateFormat, S, Result) then
if not InternalStrToDate(DefaultFormatSettings.ShortDateFormat, S, Result) then
Result := Trunc(Default);
end;
@ -572,14 +572,14 @@ end;
function DefDateFormat(FourDigitYear: Boolean): string;
begin
if FourDigitYear then begin
case GetDateOrder(ShortDateFormat) of
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY: Result := 'MM/DD/YYYY';
doDMY: Result := 'DD/MM/YYYY';
doYMD: Result := 'YYYY/MM/DD';
end;
end
else begin
case GetDateOrder(ShortDateFormat) of
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY: Result := 'MM/DD/YY';
doDMY: Result := 'DD/MM/YY';
doYMD: Result := 'YY/MM/DD';
@ -590,13 +590,13 @@ end;
function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;
begin
if FourDigitYear then begin
case GetDateOrder(ShortDateFormat) of
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY, doDMY: Result := '!99/99/9999;1;';
doYMD: Result := '!9999/99/99;1;';
end;
end
else begin
case GetDateOrder(ShortDateFormat) of
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY, doDMY: Result := '!99/99/99;1;';
doYMD: Result := '!99/99/99;1;';
end;
@ -638,7 +638,7 @@ end;
{$IFNDEF USE_FOUR_DIGIT_YEAR}
function FourDigitYear: Boolean;
begin
Result := Pos('YYYY', AnsiUpperCase(ShortDateFormat)) > 0;
Result := Pos('YYYY', AnsiUpperCase(DefaultFormatSettings.ShortDateFormat)) > 0;
end;
{$ENDIF}

View File

@ -902,7 +902,7 @@ procedure RegisterRxDBGridSortEngine(RxDBGridSortEngineClass: TRxDBGridSortEngin
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;
const
@ -2167,7 +2167,7 @@ begin
exit;
tmpCanvas := GetWorkingCanvas(Canvas);
try
H := 1;
// H := 1;
ClearMLCaptionPointers;
for i := 0 to Columns.Count - 1 do
begin
@ -2178,8 +2178,7 @@ begin
if Assigned(rxTit) then
begin
if rxTit.Orientation in [toVertical270, toVertical90] then
H := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) +
tmpCanvas.TextWidth('W')*2) div DefaultRowHeight, H)
// H := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) + tmpCanvas.TextWidth('W')*2) div DefaultRowHeight, H)
else
begin
rxColNext := nil;
@ -2190,11 +2189,11 @@ begin
rxTitleNext := TRxColumnTitle(rxColNext.Title);
end;
W := Max(rxCol.Width - 6, 1);
// W := Max(rxCol.Width - 6, 1);
if rxTit.CaptionLinesCount > 0 then
begin
H2 := 0;
H1 := 0;
// H2 := 0;
// H1 := 0;
for j := 0 to rxTit.CaptionLinesCount - 1 do
begin
MLRec1 := rxTit.CaptionLine(j);
@ -2214,7 +2213,7 @@ begin
MLRec1.Width := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
if W > MLRec1.Width then
{ if W > MLRec1.Width then
H2 := 1
else
H2 := MLRec1.Width div W + 1;
@ -2222,16 +2221,16 @@ begin
if H2 > WordCount(MLRec1.Caption, [' ']) then
H2 := WordCount(MLRec1.Caption, [' ']);
H1 := H1 + H2;
H1 := H1 + H2;}
end;
end
else
{ else
begin
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
if H1 > WordCount(rxTit.Caption, [' ']) then
H1 := WordCount(rxTit.Caption, [' ']);
end;
H := Max(H1, H);
H := Max(H1, H); }
end;
for j := 0 to rxTit.CaptionLinesCount - 1 do
@ -2246,12 +2245,14 @@ begin
end;
//Тут расчёт высоты заголовка каждой колонки - надо обработать слитые заголовки
H := 1;
for i := 0 to Columns.Count - 1 do
begin
rxCol := TRxColumn(Columns[i]);
rxTit := TRxColumnTitle(rxCol.Title);
H1 := 0;
W := Max(rxCol.Width - 6, 1);
//Не забудем про вертикальную ориентацию
if Assigned(rxCol) and rxCol.Visible and Assigned(rxTit) then
begin
@ -2259,6 +2260,14 @@ begin
H1 := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) +
tmpCanvas.TextWidth('W')) div DefaultRowHeight, H)
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
if rxTit.CaptionLinesCount > H then
H := rxTit.CaptionLinesCount;
@ -2290,6 +2299,8 @@ begin
end;
H1 := H1 + MLRec1.Hegth;
end;
end;
end;
end;
if H1 > H then