From edc2a1aa7980ffb71ad665d737f6c783da1b165b Mon Sep 17 00:00:00 2001 From: alexs75 Date: Mon, 11 Sep 2017 08:30:46 +0000 Subject: [PATCH] RxFPC: RxDBGrid - code refactoring. thx LearnMagic git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6014 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../trunk/demos/RxDBVerticalGrid/project1.lps | 246 +++++++++--------- .../rx/trunk/demos/RxDBVerticalGrid/unit1.lfm | 4 +- .../rx/trunk/demos/RxDBVerticalGrid/unit1.pas | 3 +- components/rx/trunk/rxdb/rxdbgrid.pas | 17 +- components/rx/trunk/rxdb/rxdbverticalgrid.pas | 35 ++- 5 files changed, 156 insertions(+), 149 deletions(-) diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps index 33308997c..a089f2043 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps +++ b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps @@ -9,7 +9,7 @@ - + @@ -18,9 +18,10 @@ - - - + + + + @@ -29,14 +30,14 @@ - + - + @@ -45,7 +46,7 @@ - + @@ -54,7 +55,7 @@ - + @@ -62,7 +63,7 @@ - + @@ -70,14 +71,14 @@ - + - + @@ -85,7 +86,7 @@ - + @@ -93,7 +94,7 @@ - + @@ -101,69 +102,69 @@ - + - + - + - + - + - + - + - + - + - + @@ -171,14 +172,14 @@ - + - - - + + + @@ -188,90 +189,90 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -279,21 +280,21 @@ - + - + - + @@ -301,16 +302,14 @@ - + - - - - - - + + + + @@ -318,14 +317,14 @@ - + - + @@ -333,83 +332,83 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -417,14 +416,15 @@ - + - - + + + @@ -432,19 +432,19 @@ - + - + - + @@ -452,21 +452,21 @@ - + - + - + @@ -474,35 +474,35 @@ - + - + - + - + - + @@ -510,7 +510,7 @@ - + @@ -518,21 +518,21 @@ - + - + - + @@ -540,130 +540,122 @@ - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm index 545bfc79e..e5e46b5d6 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm +++ b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm @@ -148,7 +148,7 @@ object Form1: TForm1 FieldName = 'TB_CLEINT_MEMO' RowTitle.Caption = 'Описание' WordWrap = False - RowHeight = 27 + RowHeight = 90 ReadOnly = False end> TitleStyle = tsNative @@ -166,7 +166,7 @@ object Form1: TForm1 20 20 90 - 27 + 90 ) end object RxDBGrid1: TRxDBGrid diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas index f7035666f..9a6747923 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas +++ b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas @@ -106,6 +106,7 @@ begin 2:RxDBVerticalGrid1.Rows[11].Alignment:=taCenter; end; RxDBVerticalGrid1.Rows[11].ShowBlobImagesAndMemo:=CheckBox2.Checked; + RxDBVerticalGrid1.Rows[12].ShowBlobImagesAndMemo:=CheckBox2.Checked; end; @@ -142,7 +143,7 @@ end; begin rxData.Open; - AppendRecord(1, 1, '01000100101', 'JSC "BOOT"', 'Описание', 'test1@email.com', '5(555)-557-88-77', 'alexs', true, 'splash_logo.png'); + AppendRecord(1, 1, '01000100101', 'JSC "BOOT"', 'Описание'#13'Строка 2'#13'Строка 3', 'test1@email.com', '5(555)-557-88-77', 'alexs', true, 'splash_logo.png'); AppendRecord(2, 2, '02000100101', 'Wikimedia Foundation, Inc.', 'Описание', 'test2@email.com', '5(555)-557-88-77', 'boss', false, 'splash_logo.xpm'); AppendRecord(3, 3, '03000100101', 'LLC Pilot ', 'Описание', 'test3@email.com', '5(555)-557-88-77', 'master', false, 'powered_by.png'); AppendRecord(4, 4, '04000100101', 'Pilot, OOO', 'Описание', 'test4@email.com', '5(555)-557-88-77', 'onegin', false, 'folder.png'); diff --git a/components/rx/trunk/rxdb/rxdbgrid.pas b/components/rx/trunk/rxdb/rxdbgrid.pas index fd0a34642..c793e8082 100644 --- a/components/rx/trunk/rxdb/rxdbgrid.pas +++ b/components/rx/trunk/rxdb/rxdbgrid.pas @@ -3219,14 +3219,15 @@ end; procedure TRxDBGrid.CalcTitle; var i, j: integer; - H, H1, W, {H2,} W1: integer; + H, H1, W, W1, FDefRowH: integer; rxCol, rxColNext: TRxColumn; rxTit, rxTitleNext: TRxColumnTitle; MLRec1, P: TMLCaptionItem; MLRec2: TMLCaptionItem; tmpCanvas: TCanvas; - //S: string; begin + FDefRowH:=GetDefaultRowHeight; + { TODO -oalexs : need rewrite code - split to 2 step: 1. make links between column 2. calc title width for all linked column series } @@ -3324,14 +3325,14 @@ begin begin if rxTit.Orientation in [toVertical270, toVertical90] then H1 := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) + - tmpCanvas.TextWidth('W')) div GetDefaultRowHeight, H) + tmpCanvas.TextWidth('W')) div FDefRowH, 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, [' ']); + FWC:=WordCount(rxTit.Caption, [' ']); + if H1 > FWC then H1 := FWC; end else begin @@ -3374,9 +3375,9 @@ begin end; if not (rdgDisableWordWrapTitles in OptionsRx) then - RowHeights[0] := GetDefaultRowHeight * H + RowHeights[0] := FDefRowH * H else - RowHeights[0] := GetDefaultRowHeight; + RowHeights[0] := FDefRowH; if rdgFilter in OptionsRx then begin @@ -3386,7 +3387,7 @@ begin end else begin - RowHeights[0] := RowHeights[0] + GetDefaultRowHeight; + RowHeights[0] := RowHeights[0] + FDefRowH; end; end; diff --git a/components/rx/trunk/rxdb/rxdbverticalgrid.pas b/components/rx/trunk/rxdb/rxdbverticalgrid.pas index 35a4e66cf..ed028940a 100644 --- a/components/rx/trunk/rxdb/rxdbverticalgrid.pas +++ b/components/rx/trunk/rxdb/rxdbverticalgrid.pas @@ -1270,17 +1270,7 @@ begin DrawCellBitmap(AGridRow, aRect, aState, AImageIndex); end else - if AGridRow.Field.dataType <> ftBlob then - begin - S := AGridRow.Field.DisplayText; - if (AGridRow.KeyList.Count > 0) and (AGridRow.PickList.Count > 0) then - begin - J := AGridRow.KeyList.IndexOf(S); - if (J >= 0) and (J < AGridRow.PickList.Count) then - S := AGridRow.PickList[j]; - end; - end - else + if AGridRow.Field.dataType = ftBlob then begin if AGridRow.ShowBlobImagesAndMemo then begin @@ -1294,6 +1284,29 @@ begin else S := UTF8UpperCase(GridDefValues.FBlobText); end; + end + else + if AGridRow.Field.dataType = ftMemo then + begin + if AGridRow.ShowBlobImagesAndMemo then + S := AGridRow.Field.AsString + else + begin + if AGridRow.Field.IsNull then + S := GridDefValues.FBlobText + else + S := UTF8UpperCase(GridDefValues.FBlobText); + end; + end + else + begin + S := AGridRow.Field.DisplayText; + if (AGridRow.KeyList.Count > 0) and (AGridRow.PickList.Count > 0) then + begin + J := AGridRow.KeyList.IndexOf(S); + if (J >= 0) and (J < AGridRow.PickList.Count) then + S := AGridRow.PickList[j]; + end; end; WriteTextHeader(Canvas, aRect, S, AGridRow.Alignment);