implemented TCustomListBox.ItemRect for gtk1 intf

git-svn-id: trunk@5047 -
This commit is contained in:
mattias 2004-01-11 11:57:54 +00:00
parent e365060c18
commit 28da3cef35
7 changed files with 127 additions and 1 deletions

View File

@ -437,12 +437,19 @@ end;
{------------------------------------------------------------------------------
procedure TCustomListBox.Clear
Delete all items.
------------------------------------------------------------------------------}
procedure TCustomListBox.Clear;
begin
FItems.Clear;
end;
{------------------------------------------------------------------------------
function TCustomListBox.GetIndexAtY(Y: integer): integer;
Returns item index at y coordinate (including scrolling)
------------------------------------------------------------------------------}
function TCustomListBox.GetIndexAtY(Y: integer): integer;
begin
Result:=-1;
@ -450,5 +457,23 @@ begin
Result:=GetListBoxIndexAtY(Self, Y);
end;
{------------------------------------------------------------------------------
function TCustomListBox.ItemRect(Index: Integer): TRect;
Returns coordinates of an item (including scrolling)
Special: If Index=Count the rectangle is guessed (like VCL).
------------------------------------------------------------------------------}
function TCustomListBox.ItemRect(Index: Integer): TRect;
begin
if (Index>=0) and (Index<Items.Count) then begin
GetListBoxItemRect(Self,Index,Result);
end else if (Index=Items.Count) and (Index>0) then begin
GetListBoxItemRect(Self,Index-1,Result);
OffsetRect(Result,0,Result.Bottom-Result.Top);
end else begin
FillChar(Result,SizeOf(Result),0);
end;
end;
// back to stdctrls.pp

View File

@ -172,6 +172,13 @@ begin
Result := -1;
end;
function TInterfaceBase.GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
begin
FillChar(ARect,SizeOf(ARect),0);
Result:=false;
end;
function TInterfaceBase.GetNotebookTabIndexAtPos(Handle: HWND;
const ClientPos: TPoint): integer;
begin
@ -502,6 +509,9 @@ end;
{ =============================================================================
$Log$
Revision 1.10 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.9 2004/01/10 18:00:42 mattias
fixed GetWindowOrgEx, added GetDCOriginRelativeToWindow

View File

@ -184,6 +184,12 @@ begin
Result := InterfaceObject.GetListBoxIndexAtY(ListBox, y);
end;
function GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
begin
Result := InterfaceObject.GetListBoxItemRect(ListBox,Index,ARect);
end;
function GetNotebookTabIndexAtPos(Handle: HWND;
const ClientPos: TPoint): integer;
begin
@ -485,6 +491,9 @@ end;
{ =============================================================================
$Log$
Revision 1.9 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.8 2004/01/10 18:00:42 mattias
fixed GetWindowOrgEx, added GetDCOriginRelativeToWindow

View File

@ -65,6 +65,7 @@ function GetDesignerDC(WindowHandle: HWND): HDC; {$IFDEF IF_BASE_MEMBER}virtual;
function GetDeviceRawImageDescription(DC: HDC; Desc: PRawImageDescription): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetDeviceSize(DC: HDC; var p: TPoint): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRect): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetNotebookTabIndexAtPos(Handle: HWND; const ClientPos: TPoint): integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetRawImageFromDevice(SrcDC: HDC; const SrcRect: TRect; var NewRawImage: TRawImage): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetRawImageFromBitmap(SrcBitmap, SrcMaskBitmap: HBITMAP; const SrcRect: TRect; var NewRawImage: TRawImage): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
@ -148,6 +149,9 @@ procedure RaiseLastOSError;
{ =============================================================================
$Log$
Revision 1.9 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.8 2004/01/10 18:00:42 mattias
fixed GetWindowOrgEx, added GetDCOriginRelativeToWindow

View File

@ -77,7 +77,8 @@ begin
Result:=-1;
if not (ListBox is TCustomListbox) then exit;
if TCustomListbox(ListBox).FCompStyle in [csListBox, csCheckListBox] then begin
if TCustomListbox(ListBox).FCompStyle in [csListBox, csCheckListBox] then
begin
AWidget:=PGtkWidget(TCustomListbox(ListBox).Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.ImplementationWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
@ -100,6 +101,72 @@ begin
end;
{$EndIf}
{------------------------------------------------------------------------------
function TGTKObject.GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
------------------------------------------------------------------------------}
function TGTKObject.GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
{$IFdef GTK2}
var
AWinControl: TWinControl;
begin
Result:=false;
FillChar(ARect,SizeOf(ARect),0);
if not (ListBox is TWinControl) then exit;
AWinControl:=TWinControl(ListBox);
case AWinControl.fCompStyle of
csListBox, csCheckListBox:
begin
// ToDo
end;
end;
end;
{$Else}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
begin
Result:=false;
FillChar(ARect,SizeOf(ARect),0);
if not (ListBox is TCustomListbox) then exit;
if TCustomListbox(ListBox).FCompStyle in [csListBox, csCheckListBox] then
begin
AWidget:=PGtkWidget(TCustomListbox(ListBox).Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.ImplementationWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
if VertAdj=nil then
AdjValue:=0
else
AdjValue:= (-round(VertAdj^.value));
GListItem:=ListWidget^.children;
while GListItem<>nil do begin
ListItemWidget:=PGtkWidget(GListItem^.data);
if Index=0 then begin
ARect.Left:=0;
ARect.Top:=AdjValue;
ARect.Right:=ListItemWidget^.Allocation.Width;
ARect.Bottom:=ARect.Top+ListItemWidget^.Allocation.Height;
Result:=true;
exit;
end;
inc(AdjValue,ListItemWidget^.Allocation.Height);
dec(Index);
GListItem:=GListItem^.next;
end;
end;
end;
{$EndIf}
{------------------------------------------------------------------------------
Function: LCLCheckMenuItem
Params: BaseMenuItem
@ -231,6 +298,9 @@ end;
{ =============================================================================
$Log$
Revision 1.8 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.7 2004/01/09 20:03:13 mattias
implemented new statusbar methods in gtk intf

View File

@ -31,6 +31,7 @@
//##apiwiz##sps## // Do not remove
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRect): boolean; override;
function LCLCheckMenuItem(BaseMenuItem: TComponent): Boolean; override;
function LCLEnableMenuItem(BaseMenuItem: TComponent): Boolean; override;
@ -46,6 +47,9 @@ procedure StatusBarSetStyle(StatusBar: TObject); override;
{ =============================================================================
$Log$
Revision 1.7 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.6 2004/01/09 20:03:13 mattias
implemented new statusbar methods in gtk intf

View File

@ -383,6 +383,7 @@ type
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
function GetIndexAtY(Y: integer): integer;
function ItemRect(Index: Integer): TRect;
procedure Clear;
public
property BorderStyle : TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
@ -1466,6 +1467,9 @@ end.
{ =============================================================================
$Log$
Revision 1.115 2004/01/11 11:57:54 mattias
implemented TCustomListBox.ItemRect for gtk1 intf
Revision 1.114 2004/01/06 17:58:06 mattias
fixed setting TRadioButton.Caption for gtk