diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 96fd4c069d..acc38d9d10 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -645,7 +645,7 @@ type procedure SetColumns(const AValue: TListColumns); procedure SetDefaultItemHeight(AValue: integer); procedure SetItems(const AValue : TListItems); - procedure SetItemVisible(const Avalue: TListItem); + procedure SetItemVisible(const Avalue: TListItem; const PartialOK: Boolean); procedure SetMultiSelect(const AValue: Boolean); procedure SetSmallImages(const AValue: TCustomImageList); procedure SetScrollBars(const Value: TScrollStyle); @@ -2456,6 +2456,9 @@ end. { ============================================================================= $Log$ + Revision 1.146 2004/09/08 23:05:35 mattias + improved TListView.SetItemVisible from Andrew Haines + Revision 1.145 2004/09/08 22:59:54 mattias started TTabControl diff --git a/lcl/include/customlistview.inc b/lcl/include/customlistview.inc index b9d07c2914..ac32f32b64 100644 --- a/lcl/include/customlistview.inc +++ b/lcl/include/customlistview.inc @@ -243,10 +243,12 @@ end; {------------------------------------------------------------------------------} { TCustomListView SetItemVisible } {------------------------------------------------------------------------------} -procedure TCustomListView.SetItemVisible(const AValue : TListItem); +procedure TCustomListView.SetItemVisible(const AValue : TListItem; + const PartialOK: Boolean); begin if (not HandleAllocated) or (csLoading in ComponentState) then exit; - TWSCustomListViewClass(WidgetSetClass).ItemShow(Self, AValue.Index, AValue); + TWSCustomListViewClass(WidgetSetClass).ItemShow( + Self, AValue.Index, AValue, PartialOK); end; {------------------------------------------------------------------------------} { TCustomListView Delete } @@ -613,6 +615,9 @@ end; { ============================================================================= $Log$ + Revision 1.40 2004/09/08 23:05:35 mattias + improved TListView.SetItemVisible from Andrew Haines + Revision 1.39 2004/07/24 00:00:33 mattias started TCollectionPropertyEditor diff --git a/lcl/include/listitem.inc b/lcl/include/listitem.inc index a20ed511a8..51120ded24 100644 --- a/lcl/include/listitem.inc +++ b/lcl/include/listitem.inc @@ -520,7 +520,7 @@ procedure TListItem.MakeVisible(PartialOK: Boolean); begin if (FOwner <> nil) and (FOwner.Fowner <> nil) - then FOwner.FOwner.SetItemVisible(Self); + then FOwner.FOwner.SetItemVisible(Self, PartialOK); end; {------------------------------------------------------------------------------} @@ -564,6 +564,9 @@ end; { ============================================================================= $Log$ + Revision 1.20 2004/09/08 23:05:35 mattias + improved TListView.SetItemVisible from Andrew Haines + Revision 1.19 2004/07/14 15:57:53 mattias fixed 1.0.10 compilation from Vincent diff --git a/lcl/interfaces/gtk/gtkwscomctrls.pp b/lcl/interfaces/gtk/gtkwscomctrls.pp index 27e7dde077..10d933da3c 100644 --- a/lcl/interfaces/gtk/gtkwscomctrls.pp +++ b/lcl/interfaces/gtk/gtkwscomctrls.pp @@ -94,7 +94,7 @@ type class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override; class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override; class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override; - class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override; + class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override; {$ENDIF} end; @@ -727,22 +727,40 @@ begin end; end; -procedure TGtkWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); +procedure TGtkWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); var WidgetInfo: PWidgetInfo; CListWidget: PGtkCList; + RowTopY: Integer; begin if not WSCheckHandleAllocated(ALV, 'ItemShow') then Exit; WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle)); CListWidget := PGtkCList(WidgetInfo^.CoreWidget); - - //0=NotVisible - //1=PartiallyVisible - //2=Fully Visible - if gtk_clist_row_is_visible(CListWidget, AIndex) < 2 - then gtk_clist_moveto(CListWidget, AIndex, 0, 1, 0); + + RowTopY := (CListWidget^.row_height * AIndex) + ((AIndex +1) * + {CELL} 1 {SPACING} + CListWidget^.voffset); + + // 0=NotVisible + // 1=PartiallyVisible + // 2=Fully Visible + // | + if gtk_clist_row_is_visible(CListWidget, AIndex) < (2 - Ord(PartialOK)) then begin + if (RowTopY + CListWidget^.row_height > CListWidget^.clist_window_height) then begin + gtk_clist_moveto (CListWidget, AIndex, -1, 1, 0); + // | | | | + // The Row | | | + // The Column | | + // Row Align | + end // Column Align + else if (RowTopY < 0) then begin + gtk_clist_moveto (CListWidget, AIndex, -1, 0, 0); + end;// | + end; // | + // | + // 0 = your row will be at the top. + // 1 = it will be at the bottom. end; {$ENDIF} diff --git a/lcl/interfaces/win32/win32wscomctrls.pp b/lcl/interfaces/win32/win32wscomctrls.pp index 8e3d5c9cdb..f910dd9466 100644 --- a/lcl/interfaces/win32/win32wscomctrls.pp +++ b/lcl/interfaces/win32/win32wscomctrls.pp @@ -86,7 +86,7 @@ type class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override; class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override; class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override; - class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override; + class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override; end; { TWin32WSListView } @@ -440,12 +440,12 @@ begin ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText)); end; -procedure TWin32WSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); +procedure TWin32WSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); begin if not WSCheckHandleAllocated(ALV, 'ItemShow') then Exit; - ListView_EnsureVisible(ALV.Handle, AIndex, 1); + ListView_EnsureVisible(ALV.Handle, AIndex, Ord(PartialOK)); end; diff --git a/lcl/widgetset/wscomctrls.pp b/lcl/widgetset/wscomctrls.pp index efa870571d..c972a1c8c0 100644 --- a/lcl/widgetset/wscomctrls.pp +++ b/lcl/widgetset/wscomctrls.pp @@ -91,7 +91,7 @@ type class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); virtual; class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); virtual; class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); virtual; - class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); virtual; + class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); virtual; end; { TWSListView } @@ -219,7 +219,7 @@ procedure TWSCustomListView.ItemSetText(const ALV: TCustomListView; const AIndex begin end; -procedure TWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); +procedure TWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); begin end;