From: Olivier S. <ob...@us...> - 2005-04-25 20:54:31
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16320/dev/JVCL3/run Modified Files: JvDBGrid.pas Log Message: From Fred, corrections for Mantis 2903 and 2907 (see know issues for that one) Index: JvDBGrid.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvDBGrid.pas,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** JvDBGrid.pas 22 Apr 2005 10:08:57 -0000 1.109 --- JvDBGrid.pas 25 Apr 2005 20:54:05 -0000 1.110 *************** *** 26,29 **** --- 26,30 ---- ----------------------------------------------------------------------------- + INFO: Draw events are triggered in this order: *************** *** 37,50 **** OnGetCellProps and OnDrawDataCell are obsolete. ----------------------------------------------------------------------------- ! Known Issues: - THE AlwaysShowEditor OPTION IS NOT COMPATIBLE WITH THE CUSTOM INPLACE EDIT CONTROLS Custom inplace edit controls are deactivated when this option is set to True. ! 2004/07/08 - WPostma merged changes by Frédéric Leneuf-Magaud and ahuser. ! -----------------------------------------------------------------------------} // $Id$ ! unit JvDBGrid; --- 38,60 ---- OnGetCellProps and OnDrawDataCell are obsolete. + ----------------------------------------------------------------------------- ! KNOWN ISSUES: ! - THE AlwaysShowEditor OPTION IS NOT COMPATIBLE WITH THE CUSTOM INPLACE EDIT CONTROLS Custom inplace edit controls are deactivated when this option is set to True. ! - THE ColLines OPTION DOES NOT WORK WELL WITH HIDDEN COLUMNS - BUG SOURCE: DBGRID.PAS ! If a column is followed by hidden columns and ColLines is set to False, the display size ! of the column is smaller than its width. This is easy to notice when you give the focus ! to the cell (the focus rect is truncated) or when you use the AutoSize feature (there's ! a gap after the last column). This bug comes from DBGrid.pas. ! ! ----------------------------------------------------------------------------- ! 2004/07/08 - WPostma merged changes by Frédéric Leneuf-Magaud and ahuser.} ! // $Id$ ! unit JvDBGrid; *************** *** 475,488 **** { TitleRowHeight: title row height (cannot be resized with the mouse) } property TitleRowHeight: Integer read FTitleRowHeight write SetTitleRowHeight; ! { WordWrap: are memo and string fields displayed on many lines ? } property WordWrap: Boolean read FWordWrap write SetWordWrap default False; ! { ShowMemos: if true, Memo fields are shown as text } property ShowMemos: Boolean read FShowMemos write SetShowMemos default True; { BooleanEditor: if true, a checkbox is used to edit boolean fields } property BooleanEditor: Boolean read FBooleanEditor write SetBooleanEditor default True; - { OnColumnResized: event triggered each time a column is resized with the mouse } - property OnColumnResized: TJvDBColumnResizeEvent read FOnColumnResized write FOnColumnResized; { IsBooleanField: event used to treat integer fields as boolean fields } property IsBooleanField: TJvDBIsBoolFieldEvent read FIsBoolField write FIsBoolField; end; --- 485,498 ---- { TitleRowHeight: title row height (cannot be resized with the mouse) } property TitleRowHeight: Integer read FTitleRowHeight write SetTitleRowHeight; ! { WordWrap: if true, titles, memo and string fields are displayed on several lines } property WordWrap: Boolean read FWordWrap write SetWordWrap default False; ! { ShowMemos: if true, memo fields are shown as text } property ShowMemos: Boolean read FShowMemos write SetShowMemos default True; { BooleanEditor: if true, a checkbox is used to edit boolean fields } property BooleanEditor: Boolean read FBooleanEditor write SetBooleanEditor default True; { IsBooleanField: event used to treat integer fields as boolean fields } property IsBooleanField: TJvDBIsBoolFieldEvent read FIsBoolField write FIsBoolField; + { OnColumnResized: event triggered each time a column is resized with the mouse } + property OnColumnResized: TJvDBColumnResizeEvent read FOnColumnResized write FOnColumnResized; end; *************** *** 2284,2291 **** // characters of a word found in the list. // Remark: InplaceEditor is protected in TCustomGrid, published in TJvDBGrid. ! if (not DataSource.DataSet.CanModify) or ReadOnly ! or Columns[SelectedIndex].ReadOnly or Columns[SelectedIndex].Field.ReadOnly then ! Key := #0 ! else with Columns[SelectedIndex].Field do if (FieldKind = fkLookup) and (Key in CharList) then --- 2294,2299 ---- // characters of a word found in the list. // Remark: InplaceEditor is protected in TCustomGrid, published in TJvDBGrid. ! if DataSource.DataSet.CanModify and not (ReadOnly ! or Columns[SelectedIndex].ReadOnly or Columns[SelectedIndex].Field.ReadOnly) then with Columns[SelectedIndex].Field do if (FieldKind = fkLookup) and (Key in CharList) then *************** *** 3185,3192 **** // - if (max. width * nb. of columns) < total width --> result too small var ! TotalWidth, OrigWidth: Integer; ! I: Integer; ScaleFactor: Double; - AWidth, AUsedWidth, ALeftCol: Integer; begin if not AutoSizeColumns or FInAutoSize or (Columns.Count = 0) or (FGridState = gsColSizing) then --- 3193,3199 ---- // - if (max. width * nb. of columns) < total width --> result too small var ! ColLineWidth, AvailableWidth, TotalColWidth, AWidth: Integer; ! I, ALeftCol, LastColIndex: Integer; ScaleFactor: Double; begin if not AutoSizeColumns or FInAutoSize or (Columns.Count = 0) or (FGridState = gsColSizing) then *************** *** 3195,3224 **** ALeftCol := LeftCol; try ! // get useable width ! TotalWidth := ClientWidth - (Ord(dgIndicator in Options) * IndicatorWidth) ! - (Ord(dgColLines in Options) * Columns.Count * GridLineWidth); ! OrigWidth := 0; ! // get width currently occupied by columns if FixedCols = 0 then BeginLayout; try ! // autosize all columns proportionally if AutoSizeColumnIndex = JvGridResizeProportionally then begin for I := 0 to Columns.Count - 1 do if Columns[I].Visible then ! Inc(OrigWidth, Columns[I].Width); ! if OrigWidth = 0 then ! OrigWidth := 1; ! // calculate the relationship between what's available and what's in use ! ScaleFactor := TotalWidth / OrigWidth; if ScaleFactor = 1.0 then ! Exit; // no need to continue - resizing won't change anything ! AUsedWidth := 0; for I := 0 to Columns.Count - 1 do if Columns[I].Visible then begin if I = LastVisibleColumn then ! Columns[I].Width := TotalWidth - AUsedWidth else begin --- 3202,3236 ---- ALeftCol := LeftCol; try ! // Get useable width ! ColLineWidth := Ord(dgColLines in Options) * GridLineWidth; ! AvailableWidth := ClientWidth; ! if (dgIndicator in Options) then ! Dec(AvailableWidth, IndicatorWidth + ColLineWidth); ! TotalColWidth := 0; if FixedCols = 0 then BeginLayout; try ! // Autosize all columns proportionally if AutoSizeColumnIndex = JvGridResizeProportionally then begin + // Get width currently occupied by visible columns for I := 0 to Columns.Count - 1 do if Columns[I].Visible then ! begin ! Inc(TotalColWidth, Columns[I].Width); ! Dec(AvailableWidth, ColLineWidth); ! end; ! if TotalColWidth = 0 then ! TotalColWidth := 1; ! // Calculate the relationship between what's available and what's in use ! ScaleFactor := AvailableWidth / TotalColWidth; if ScaleFactor = 1.0 then ! Exit; // No need to continue - resizing won't change anything ! // Adjust the columns width for I := 0 to Columns.Count - 1 do if Columns[I].Visible then begin if I = LastVisibleColumn then ! Columns[I].Width := AvailableWidth else begin *************** *** 3227,3259 **** AWidth := 1; Columns[I].Width := AWidth; ! Inc(AUsedWidth, AWidth); end; end; end else ! // autosize the last visible column if AutoSizeColumnIndex = JvGridResizeLastVisibleCol then begin ! // reuse AUsedWidth as the actual resize column index ! AUsedWidth := LastVisibleColumn; ! if AUsedWidth < 0 then Exit; - OrigWidth := 0; for I := 0 to Columns.Count - 1 do ! if Columns[I].Visible and (I <> AUsedWidth) then ! Inc(OrigWidth, Columns[I].Width); ! AWidth := TotalWidth - OrigWidth; if AWidth > 0 then ! Columns[AUsedWidth].Width := AWidth; end else ! // only auto size one column if AutoSizeColumnIndex <= LastVisibleColumn then begin - OrigWidth := 0; for I := 0 to Columns.Count - 1 do if Columns[I].Visible and (I <> AutoSizeColumnIndex) then ! Inc(OrigWidth, Columns[I].Width); ! AWidth := TotalWidth - OrigWidth; if AWidth > 0 then Columns[AutoSizeColumnIndex].Width := AWidth; --- 3239,3268 ---- AWidth := 1; Columns[I].Width := AWidth; ! Dec(AvailableWidth, AWidth); end; end; end else ! // Autosize the last visible column if AutoSizeColumnIndex = JvGridResizeLastVisibleCol then begin ! LastColIndex := LastVisibleColumn; ! if LastColIndex < 0 then Exit; for I := 0 to Columns.Count - 1 do ! if Columns[I].Visible and (I < LastColIndex) then ! Inc(TotalColWidth, Columns[I].Width + ColLineWidth); ! AWidth := AvailableWidth - TotalColWidth - ColLineWidth; if AWidth > 0 then ! Columns[LastColIndex].Width := AWidth; end else ! // Only autosize one column if AutoSizeColumnIndex <= LastVisibleColumn then begin for I := 0 to Columns.Count - 1 do if Columns[I].Visible and (I <> AutoSizeColumnIndex) then ! Inc(TotalColWidth, Columns[I].Width + ColLineWidth); ! AWidth := AvailableWidth - TotalColWidth - ColLineWidth; if AWidth > 0 then Columns[AutoSizeColumnIndex].Width := AWidth; |