convert LM_SETPROPERTIES message to interface methods for TCustomListView

git-svn-id: trunk@6045 -
This commit is contained in:
micha 2004-09-22 18:06:32 +00:00
parent dcf9c0e76f
commit 9bb1cdbb19
6 changed files with 181 additions and 154 deletions

View File

@ -165,14 +165,14 @@ begin
exit;
end;
Exclude(FStates,lvPropertiesNeedsUpdate);
CNSendMessage(LM_SETPROPERTIES,self,nil);
TWSCustomListViewClass(WidgetSetClass).UpdateProperties(Self);
end;
procedure TCustomListView.InitializeWnd;
begin
inherited InitializeWnd;
Exclude(FStates,lvPropertiesNeedsUpdate);
CNSendMessage(LM_SETPROPERTIES,Self,nil);
TWSCustomListViewClass(WidgetSetClass).UpdateProperties(Self);
if FSelected <> nil
then TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index, FSelected, lisSelected, True);
end;
@ -615,6 +615,9 @@ end;
{ =============================================================================
$Log$
Revision 1.41 2004/09/22 18:06:32 micha
convert LM_SETPROPERTIES message to interface methods for TCustomListView
Revision 1.40 2004/09/08 23:05:35 mattias
improved TListView.SetItemVisible from Andrew Haines

View File

@ -6241,11 +6241,8 @@ const
cLabelAlignY : array[TTextLayout] of gfloat = (0.0, 0.5, 1.0);
cLabelAlign : array[TAlignment] of TGtkJustification = (GTK_JUSTIFY_LEFT, GTK_JUSTIFY_RIGHT, GTK_JUSTIFY_CENTER);
var
wHandle : Pointer;
Widget : PGtkWidget;
I,X : Integer;
pRowText : PChar;
BitImage : TBitMap;
wHandle : Pointer;
AnAdjustment: PGtkAdjustment;
begin
@ -6339,105 +6336,6 @@ begin
DebugLn('TODO: TGtkWidgetSet.SetProperties csListView');
{$Else}
begin
// set up columns..
Widget:= GetWidgetInfo(wHandle, True)^.CoreWidget;
gtk_clist_freeze(GTK_CLIST(Widget));
for I := 0 to TListview(sender).Columns.Count-1 do
begin
gtk_clist_set_column_title(GTK_CLIST(Widget),I,
PChar(TListview(sender).Columns[i].Caption));
// set column alignment
gtk_clist_set_column_justification(GTK_CLIST(Widget),I,
aGTKJUSTIFICATION[TListview(sender).Columns[i].Alignment]);
// set auto sizing
gtk_clist_set_column_auto_resize(GTK_CLIST(Widget),I,
TListview(sender).Columns[i].AutoSize);
// set width
gtk_clist_set_column_width(GTK_CLIST(Widget),I,
TListview(sender).Columns[i].Width);
// set Visible
gtk_clist_set_column_visibility(GTK_CLIST(Widget),I,
TListview(sender).Columns[i].Visible);
// set MinWidth
if TListview(sender).Columns[i].MinWidth>0 then
gtk_clist_set_column_min_width(GTK_CLIST(Widget), I,
TListview(sender).Columns[i].MinWidth);
// set MaxWidth
if (TListview(sender).Columns[i].MaxWidth>=
TListview(sender).Columns[i].MinWidth)
and (TListview(sender).Columns[i].MaxWidth>0) then
gtk_clist_set_column_max_width(GTK_CLIST(Widget), I,
TListview(sender).Columns[i].MaxWidth);
end;
//sorting
if (TListview(sender).ViewStyle = vsReport)
then gtk_clist_column_titles_show(GTK_CLIST(Widget))
else gtk_clist_column_titles_Hide(GTK_CLIST(Widget));
gtk_clist_set_sort_column(GTK_CLIST(Widget),
TListview(sender).SortColumn);
//multiselect
gtk_clist_set_selection_mode(GTK_CLIST(Widget),
aGTkSelectionMode[TListview(sender).MultiSelect]);
//TODO:This doesn't work right now
// gtk_clist_set_auto_sort(PgtkCList(handle),TListview(sender).Sorted);
//
//do items...
//
for I := 0 to TListview(sender).Items.Count-1 do
begin
pRowText:=PChar(TListItem(TListview(sender).Items[i]).Caption);
gtk_clist_set_text(GTK_CLIST(Widget),I,0,pRowText);
//do image if one is assigned....
// TODO: Largeimage support
if (TListview(sender).SmallImages <> nil)
and (TListItem(TListview(sender).Items[i]).ImageIndex > -1)
then begin
DebugLn('Checking images');
if (TListItem(TListview(sender).Items[i]).ImageIndex
< TListview(sender).SmallImages.Count)
then begin
//draw image
//DebugLn('drawing image');
//DebugLn('TListItem(TListview(sender).Items[i]).ImageIndex is ',TListItem(TListview(sender).Items[i]).ImageIndex);
BitImage := TBitmap.Create;
TListview(sender).SmallImages.GetBitmap(
TListItem(TListview(sender).Items[i]).ImageIndex,BitImage);
gtk_clist_set_pixmap(GTK_CLIST(Widget),I,0,
pgdkPixmap(PgdiObject(BitImage.handle)^.GDIBitmapObject),
nil);
gtk_clist_set_pixtext(GTK_CLIST(Widget),I,0,pRowText,3,
pgdkPixmap(PgdiObject(BitImage.handle)^.GDIBitmapObject),
nil);
// bitimage.Free;
end;
end;
if (TListview(sender).ViewStyle = vsReport)
then begin //columns showing
for X := 1 to TListview(sender).Columns.Count-1 do
begin
if ( X <= TListItem(TListview(sender).Items[i]).SubItems.Count)
then begin
pRowText:=PChar(TListItem(
TListview(sender).Items[i]).SubItems.Strings[X-1]);
gtk_clist_set_text(GTK_CLIST(Widget),I,X,pRowText);
end;
end; //for loop
end;
end;
gtk_clist_thaw(GTK_CLIST(Widget));
end;
{$EndIf}
@ -7597,6 +7495,9 @@ end;
{ =============================================================================
$Log$
Revision 1.593 2004/09/22 18:06:32 micha
convert LM_SETPROPERTIES message to interface methods for TCustomListView
Revision 1.592 2004/09/22 16:13:01 micha
convert LM_SETPROPERTIES message to interface methods for TCustomMemo

View File

@ -95,6 +95,8 @@ type
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; const PartialOK: Boolean); override;
class procedure UpdateProperties(const ACustomListView: TCustomListView); override;
{$ENDIF}
end;
@ -770,6 +772,113 @@ begin
// 0 = your row will be at the top.
// 1 = it will be at the bottom.
end;
procedure TGtkWSCustomListView.UpdateProperties(const ACustomListView: TCustomListView);
var
Widget : PGtkWidget;
pRowText : PChar;
BitImage : TBitMap;
I, X: integer;
begin
// set up columns..
Widget:= GetWidgetInfo(PGtkWidget(ACustomListView.Handle), True)^.CoreWidget;
gtk_clist_freeze(GTK_CLIST(Widget));
for I := 0 to TListView(ACustomListView).Columns.Count-1 do
begin
gtk_clist_set_column_title(GTK_CLIST(Widget),I,
PChar(TListView(ACustomListView).Columns[i].Caption));
// set column alignment
gtk_clist_set_column_justification(GTK_CLIST(Widget),I,
aGTKJUSTIFICATION[TListView(ACustomListView).Columns[i].Alignment]);
// set auto sizing
gtk_clist_set_column_auto_resize(GTK_CLIST(Widget),I,
TListView(ACustomListView).Columns[i].AutoSize);
// set width
gtk_clist_set_column_width(GTK_CLIST(Widget),I,
TListView(ACustomListView).Columns[i].Width);
// set Visible
gtk_clist_set_column_visibility(GTK_CLIST(Widget),I,
TListView(ACustomListView).Columns[i].Visible);
// set MinWidth
if TListView(ACustomListView).Columns[i].MinWidth>0 then
gtk_clist_set_column_min_width(GTK_CLIST(Widget), I,
TListView(ACustomListView).Columns[i].MinWidth);
// set MaxWidth
if (TListView(ACustomListView).Columns[i].MaxWidth>=
TListView(ACustomListView).Columns[i].MinWidth)
and (TListView(ACustomListView).Columns[i].MaxWidth>0) then
gtk_clist_set_column_max_width(GTK_CLIST(Widget), I,
TListView(ACustomListView).Columns[i].MaxWidth);
end;
//sorting
if (TListView(ACustomListView).ViewStyle = vsReport)
then gtk_clist_column_titles_show(GTK_CLIST(Widget))
else gtk_clist_column_titles_Hide(GTK_CLIST(Widget));
gtk_clist_set_sort_column(GTK_CLIST(Widget),
TListView(ACustomListView).SortColumn);
//multiselect
gtk_clist_set_selection_mode(GTK_CLIST(Widget),
aGTkSelectionMode[TListView(ACustomListView).MultiSelect]);
//TODO:This doesn't work right now
// gtk_clist_set_auto_sort(PgtkCList(handle),TListView(ACustomListView).Sorted);
//
//do items...
//
for I := 0 to TListView(ACustomListView).Items.Count-1 do
begin
pRowText:=PChar(TListItem(TListView(ACustomListView).Items[i]).Caption);
gtk_clist_set_text(GTK_CLIST(Widget),I,0,pRowText);
//do image if one is assigned....
// TODO: Largeimage support
if (TListView(ACustomListView).SmallImages <> nil)
and (TListItem(TListView(ACustomListView).Items[i]).ImageIndex > -1)
then begin
DebugLn('Checking images');
if (TListItem(TListView(ACustomListView).Items[i]).ImageIndex
< TListView(ACustomListView).SmallImages.Count)
then begin
//draw image
//DebugLn('drawing image');
//DebugLn('TListItem(TListView(ACustomListView).Items[i]).ImageIndex is ',TListItem(TListView(ACustomListView).Items[i]).ImageIndex);
BitImage := TBitmap.Create;
TListView(ACustomListView).SmallImages.GetBitmap(
TListItem(TListView(ACustomListView).Items[i]).ImageIndex,BitImage);
gtk_clist_set_pixmap(GTK_CLIST(Widget),I,0,
pgdkPixmap(PgdiObject(BitImage.handle)^.GDIBitmapObject),
nil);
gtk_clist_set_pixtext(GTK_CLIST(Widget),I,0,pRowText,3,
pgdkPixmap(PgdiObject(BitImage.handle)^.GDIBitmapObject),
nil);
// bitimage.Free;
end;
end;
if (TListView(ACustomListView).ViewStyle = vsReport)
then begin //columns showing
for X := 1 to TListView(ACustomListView).Columns.Count-1 do
begin
if ( X <= TListItem(TListView(ACustomListView).Items[i]).SubItems.Count)
then begin
pRowText:=PChar(TListItem(
TListView(ACustomListView).Items[i]).SubItems.Strings[X-1]);
gtk_clist_set_text(GTK_CLIST(Widget),I,X,pRowText);
end;
end; //for loop
end;
end;
gtk_clist_thaw(GTK_CLIST(Widget));
end;
{$ENDIF}
{ TGtkWSProgressBar }

View File

@ -1684,16 +1684,8 @@ end;
the calling object to the corresponding Window.
------------------------------------------------------------------------------}
Function TWin32WidgetSet.SetProperties(Sender: TObject): Integer;
const
LVS_TYPEMASK = LVS_LIST or LVS_REPORT or LVS_SMALLICON or LVS_ICON;
LISTVIEWSTYLES: array[TViewStyle] of DWORD = (
LVS_LIST, LVS_REPORT);
Var
Handle: HWND;
I, Count: Integer;
LVC: LV_COLUMN;
Style: dword;
H: THandle;
begin
Result := 0; // default if nobody sets it
@ -1708,47 +1700,6 @@ begin
Case TControl(Sender).FCompStyle Of
csListView:
With TListView(Sender) Do
Begin
Style := dword(GetWindowLong(Handle, GWL_STYLE));
if (Style and LVS_TYPEMASK) <> LISTVIEWSTYLES[ViewStyle]
then begin
Style := Style and not LVS_TYPEMASK or LISTVIEWSTYLES[ViewStyle];
SetWindowLong(Handle, GWL_STYLE, Style);
end;
if ViewStyle = vsReport Then
Begin
// H := ListView_GetHeader(Handle);
H := SendMessage(Handle, $1000 + 31 {LVM_GETHEADER}, 0, 0);
Count := Header_GetItemCount(H);
For I := 0 To Columns.Count - 1 Do
Begin
With LVC Do
Begin
Mask := LVCF_FMT Or LVCF_TEXT Or LVCF_WIDTH;
Fmt := Integer(Columns.Items[I].Alignment);
CX := Columns.Items[I].Width;
PSzText := PChar(Columns.Items[I].Caption);
End;
if i >= Count
then ListView_InsertColumn(Handle, i, lvc)
else ListView_SetColumn(Handle, I, LVC);
End;
for i := Columns.Count to Count - 1 do
ListView_DeleteColumn(Handle, i);
Count := Header_GetItemCount(H);
End;
//If Sorted Then
//ListView_SortItems(Handle, @CompareFunc, 0);
If MultiSelect Then
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) And Not LVS_SINGLESEL);
If SmallImages <> Nil Then
ListView_SetImageList(Handle, SmallImages.Handle, LVSIL_NORMAL);
End;
csProgressBar:
With TProgressBar(Sender) Do
Begin
@ -1846,6 +1797,9 @@ End;
{
$Log$
Revision 1.281 2004/09/22 18:06:32 micha
convert LM_SETPROPERTIES message to interface methods for TCustomListView
Revision 1.280 2004/09/22 14:50:18 micha
convert LM_SETPROPERTIES message for tcustomlabel to interface methods

View File

@ -87,6 +87,8 @@ type
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; const PartialOK: Boolean); override;
class procedure UpdateProperties(const ACustomListView: TCustomListView); override;
end;
{ TWin32WSListView }
@ -456,6 +458,58 @@ begin
ListView_EnsureVisible(ALV.Handle, AIndex, Ord(PartialOK));
end;
procedure TWin32WSCustomListView.UpdateProperties(const ACustomListView: TCustomListView);
const
LVS_TYPEMASK = LVS_LIST or LVS_REPORT or LVS_SMALLICON or LVS_ICON;
LISTVIEWSTYLES: array[TViewStyle] of DWORD = (
LVS_LIST, LVS_REPORT);
var
I, Count: Integer;
LVC: LV_COLUMN;
Style: dword;
H: THandle;
begin
with TListView(ACustomListView) do
begin
Style := dword(GetWindowLong(Handle, GWL_STYLE));
if (Style and LVS_TYPEMASK) <> LISTVIEWSTYLES[ViewStyle]
then begin
Style := Style and not LVS_TYPEMASK or LISTVIEWSTYLES[ViewStyle];
SetWindowLong(Handle, GWL_STYLE, Style);
end;
if ViewStyle = vsReport then
begin
// H := ListView_GetHeader(Handle);
H := SendMessage(Handle, $1000 + 31 {LVM_GETHEADER}, 0, 0);
Count := Header_GetItemCount(H);
for I := 0 to Columns.Count - 1 do
begin
with LVC do
begin
Mask := LVCF_FMT or LVCF_TEXT or LVCF_WIDTH;
Fmt := Integer(Columns.Items[I].Alignment);
CX := Columns.Items[I].Width;
PSzText := PChar(Columns.Items[I].Caption);
end;
if i >= Count
then ListView_InsertColumn(Handle, i, lvc)
else ListView_SetColumn(Handle, I, LVC);
end;
for i := Columns.Count to Count - 1 do
ListView_DeleteColumn(Handle, i);
Count := Header_GetItemCount(H);
end;
//If Sorted Then
//ListView_SortItems(Handle, @CompareFunc, 0);
if MultiSelect then
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not LVS_SINGLESEL);
if SmallImages <> Nil then
ListView_SetImageList(Handle, SmallImages.Handle, LVSIL_NORMAL);
end;
end;
{ TWin32WSProgressBar }
procedure TWin32WSProgressBar.SetPosition(const AProgressBar: TProgressBar; const NewPosition: integer);

View File

@ -92,6 +92,8 @@ type
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; const PartialOK: Boolean); virtual;
class procedure UpdateProperties(const ACustomListView: TCustomListView); virtual;
end;
{ TWSListView }
@ -234,6 +236,10 @@ procedure TWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: I
begin
end;
procedure TWSCustomListView.UpdateProperties(const ACustomListView: TCustomListView);
begin
end;
{ TWSProgressBar }
procedure TWSProgressBar.SetPosition(const AProgressBar: TProgressBar; const NewPosition: integer);