convert LM_LB_GETTOPINDEX and LM_LB_SETTOPINDEX message to interface methods

git-svn-id: trunk@6067 -
This commit is contained in:
micha 2004-09-24 15:31:02 +00:00
parent 879f1ff11a
commit 21199fcd5d
7 changed files with 79 additions and 80 deletions

View File

@ -140,7 +140,7 @@ end;
function TCustomListBox.GetTopIndex: Integer;
begin
if HandleAllocated then
FTopIndex:=CNSendMessage(LM_LB_GETTOPINDEX, Self, nil);
FTopIndex := TWSCustomListBoxClass(WidgetSetClass).GetTopIndex(Self);
Result := FTopIndex;
end;
@ -153,7 +153,7 @@ begin
// will make it complete visible.
FTopIndex:=AValue;
if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then
CNSendMessage(LM_LB_SETTOPINDEX, Self, Pointer(FTopIndex));
TWSCustomListBoxClass(WidgetSetClass).SetTopIndex(Self, AValue);
end;
{------------------------------------------------------------------------------

View File

@ -222,10 +222,6 @@ type
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);virtual;
procedure MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);virtual;
// listbox
function GetTopIndex(Sender: TObject): integer;virtual;
function SetTopIndex(Sender: TObject; NewTopIndex: integer): integer;virtual;
// forms and dialogs
procedure BringFormToFront(Sender: TObject);
procedure SetWindowSizeAndPosition(Window: PGtkWindow;
@ -453,6 +449,9 @@ end.
{ =============================================================================
$Log$
Revision 1.213 2004/09/24 15:31:01 micha
convert LM_LB_GETTOPINDEX and LM_LB_SETTOPINDEX message to interface methods
Revision 1.212 2004/09/24 14:50:57 micha
convert LM_SETDESIGNING message to TWidgetSet method

View File

@ -2932,64 +2932,6 @@ begin
gdk_pixmap_unref(TempMaskPixmap);
end;
{------------------------------------------------------------------------------
function TGtkWidgetSet.GetTopIndex(Sender: TObject): integer;
------------------------------------------------------------------------------}
function TGtkWidgetSet.GetTopIndex(Sender: TObject): integer;
begin
Result:=GetListBoxIndexAtY(Sender as TComponent,0);
end;
{------------------------------------------------------------------------------
function TGtkWidgetSet.SetTopIndex(Sender: TObject; NewTopIndex: integer
): integer;
------------------------------------------------------------------------------}
function TGtkWidgetSet.SetTopIndex(Sender: TObject; NewTopIndex: integer
): integer;
{$IFdef GTK2}
begin
DebugLn('TODO: TGtkWidgetSet.SetTopIndex');
end;
{$Else}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue, MaxAdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
i: Integer;
begin
Result:=0;
if not (Sender is TWinControl) then exit;
case TWinControl(Sender).fCompStyle of
csListBox, csCheckListBox:
begin
AWidget:=PGtkWidget(TWinControl(Sender).Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
AdjValue:=0;
GListItem:=ListWidget^.children;
i:=0;
while GListItem<>nil do begin
ListItemWidget:=PGtkWidget(GListItem^.data);
if i>=NewTopIndex then break;
inc(AdjValue,ListItemWidget^.Allocation.Height);
inc(i);
GListItem:=GListItem^.next;
end;
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
MaxAdjValue:=RoundToInt(VertAdj^.upper-VertAdj^.page_size);
if AdjValue>MaxAdjValue then AdjValue:=MaxAdjValue;
gtk_adjustment_set_value(VertAdj,AdjValue);
end;
end;
end;
{$EndIf}
{------------------------------------------------------------------------------
procedure TGtkWidgetSet.SetSelectionMode(Sender: TObject; Widget: PGtkWidget;
MultiSelect, ExtendedSelect: boolean);
@ -3092,9 +3034,6 @@ begin
LM_NB_UpdateTab: UpdateNotebookPageTab(nil,TCustomPage(Sender));
LM_LB_GETTOPINDEX: Result:=GetTopIndex(Sender);
LM_LB_SETTOPINDEX: Result:=SetTopIndex(Sender,integer(Data));
else
begin
Case LM_Message of
@ -7358,6 +7297,9 @@ end;
{ =============================================================================
$Log$
Revision 1.599 2004/09/24 15:31:01 micha
convert LM_LB_GETTOPINDEX and LM_LB_SETTOPINDEX message to interface methods
Revision 1.598 2004/09/24 14:50:57 micha
convert LM_SETDESIGNING message to TWidgetSet method

View File

@ -33,7 +33,7 @@ uses
{$ELSE}
glib, gdk, gtk, {$Ifndef NoGdkPixbufLib}gdkpixbuf,{$EndIf} GtkFontCache,
{$ENDIF}
WSStdCtrls, WSLCLClasses, GtkInt, Classes, LCLType, GtkDef,
WSStdCtrls, WSLCLClasses, GtkInt, Classes, LCLType, GtkDef, LCLProc,
GTKWinApiWindow, gtkglobals, gtkproc, InterfaceBase;
@ -105,12 +105,14 @@ type
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
AMultiSelect: boolean); override;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
end;
{ TGtkWSListBox }
@ -440,6 +442,11 @@ begin
{$endif}
end;
function TGtkWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result:=TGtkWidgetSet(InterfaceObject).GetListBoxIndexAtY(ACustomListBox, 0);
end;
procedure TGtkWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
var
Widget : PGtkWidget; // pointer to gtk-widget (local use when neccessary)
@ -555,6 +562,42 @@ begin
end
end;
procedure TGtkWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
{$IFdef GTK2}
begin
DebugLn('TODO: TGtkWSCustomListBox.SetTopIndex');
end;
{$Else}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue, MaxAdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
i: Integer;
begin
AWidget:=PGtkWidget(ACustomListBox.Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
AdjValue:=0;
GListItem:=ListWidget^.children;
i:=0;
while GListItem<>nil do begin
ListItemWidget:=PGtkWidget(GListItem^.data);
if i>=NewTopIndex then break;
inc(AdjValue,ListItemWidget^.Allocation.Height);
inc(i);
GListItem:=GListItem^.next;
end;
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
MaxAdjValue:=RoundToInt(VertAdj^.upper-VertAdj^.page_size);
if AdjValue>MaxAdjValue then AdjValue:=MaxAdjValue;
gtk_adjustment_set_value(VertAdj,AdjValue);
end;
{$EndIf}
{ TGtkWSCustomComboBox }
function TGtkWSCustomComboBox.GetSelStart(const ACustomComboBox: TCustomComboBox): integer;

View File

@ -105,6 +105,7 @@ type
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
@ -112,6 +113,7 @@ type
AMultiSelect: boolean); override;
class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
end;
{ TWin32WSListBox }
@ -331,6 +333,12 @@ begin
Windows.SetProp(Handle, 'List', dword(Result));
end;
function TWin32WSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
begin
// TODO: implement me!
Result := 0;
end;
procedure TWin32WSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
begin
if ACustomListBox.FCompStyle = csListBox then
@ -389,6 +397,11 @@ begin
end;
end;
procedure TWin32WSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
begin
// TODO: implement me!
end;
{ TWin32WSCustomComboBox }
function TWin32WSCustomComboBox.GetSelStart(const ACustomComboBox: TCustomComboBox): integer;

View File

@ -54,12 +54,6 @@ const
LM_NB_UpdateTab = LM_NB_First+0;
LM_NB_Last = LM_NB_UpdateTab;
// TListBox
LM_LB_First = LM_NB_Last +1;
LM_LB_GETTOPINDEX = LM_LB_First +0;
LM_LB_SETTOPINDEX = LM_LB_First +1;
LM_LB_Last = LM_LB_SETTOPINDEX;
//-------------
// lcl messages
@ -748,12 +742,6 @@ begin
LM_NB_UpdateTab :Result:='LM_NB_UpdateTab';
//LM_NB_Last :Result:='LM_NB_Last';
// TListBox
//LM_LB_First :Result:='LM_B_First';
LM_LB_GETTOPINDEX :Result:='LM_LB_GETTOPINDEX';
LM_LB_SETTOPINDEX :Result:='LM_LB_SETTOPINDEX';
//LM_LB_Last :Result:='LM_LB_Last';
//-------------
// lcl messages
//
@ -843,6 +831,9 @@ end.
{
$Log$
Revision 1.120 2004/09/24 15:31:01 micha
convert LM_LB_GETTOPINDEX and LM_LB_SETTOPINDEX message to interface methods
Revision 1.119 2004/09/24 14:50:57 micha
convert LM_SETDESIGNING message to TWidgetSet method

View File

@ -99,6 +99,7 @@ type
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; virtual;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; virtual;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); virtual;
class procedure SetBorder(const ACustomListBox: TCustomListBox); virtual;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); virtual;
@ -106,6 +107,7 @@ type
AMultiSelect: boolean); virtual;
class procedure SetStyle(const ACustomListBox: TCustomListBox); virtual;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); virtual;
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); virtual;
end;
TWSCustomListBoxClass = class of TWSCustomListBox;
@ -234,6 +236,11 @@ begin
Result := nil;
end;
function TWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result := 0;
end;
procedure TWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
begin
end;
@ -259,6 +266,10 @@ procedure TWSCustomListBox.SetSorted(const ACustomListBox: TCustomListBox; AList
begin
end;
procedure TWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
begin
end;
{ TWSCustomComboBox }
function TWSCustomComboBox.GetSelStart(const ACustomComboBox: TCustomComboBox): integer;