- move TWidgetset.GetListBoxXXX to TWSCustomListBox.GetXXX (where XXX in [GetIndexAtY, GetItemRect]) *untested on Carbon and wince*

- implement GetIndexAtY and GetItemRect for TQtWsListBox

git-svn-id: trunk@11875 -
This commit is contained in:
paul 2007-08-28 17:44:28 +00:00
parent 66f6e87d4d
commit abe113718c
21 changed files with 375 additions and 377 deletions

View File

@ -574,7 +574,7 @@ function TCustomListBox.GetIndexAtY(Y: integer): integer;
begin
Result:=-1;
if (not HandleAllocated) then exit;
Result:=GetListBoxIndexAtY(Self, Y);
Result := TWSCustomListBoxClass(WidgetSetClass).GetIndexAtY(Self, Y);
end;
{------------------------------------------------------------------------------
@ -618,12 +618,16 @@ end;
------------------------------------------------------------------------------}
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);
if (Index>=0) and (Index<Items.Count) then
begin
TWSCustomListBoxClass(WidgetSetClass).GetItemRect(Self, Index, Result);
end else
if (Index=Items.Count) and (Index>0) then
begin
TWSCustomListBoxClass(WidgetSetClass).GetItemRect(Self, Index - 1, Result);
OffsetRect(Result,0,Result.Bottom-Result.Top);
end else begin
end else
begin
FillChar(Result,SizeOf(Result),0);
end;
end;
@ -639,8 +643,10 @@ var
begin
Result:=false;
if (Index<0) or (Index>=Items.Count) then exit;
if not GetListBoxItemRect(Self,Index,ARect) then exit;
if (ARect.Bottom<0) or (ARect.Top>ClientHeight) then exit;
if not TWSCustomListBoxClass(WidgetSetClass).GetItemRect(Self, Index, ARect) then
exit;
if (ARect.Bottom<0) or (ARect.Top>ClientHeight) then
exit;
Result:=true;
end;
@ -655,8 +661,10 @@ var
begin
Result:=false;
if (Index<0) or (Index>=Items.Count) then exit;
if not GetListBoxItemRect(Self,Index,ARect) then exit;
if (ARect.Top<0) or (ARect.Bottom>ClientHeight) then exit;
if not TWSCustomListBoxClass(WidgetSetClass).GetItemRect(Self, Index, ARect) then
exit;
if (ARect.Top<0) or (ARect.Bottom>ClientHeight) then
exit;
Result:=true;
end;

View File

@ -361,18 +361,6 @@ begin
else Result := nil;
end;
function TWidgetSet.GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer;
begin
Result := -1;
end;
function TWidgetSet.GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
begin
FillChar(ARect,SizeOf(ARect),0);
Result:=false;
end;
{$ifdef OldRawImageProcs}
function TWidgetSet.GetRawImageFromDevice(SrcDC: HDC;
const SrcRect: TRect; var NewRawImage: TRawImage): boolean;

View File

@ -294,17 +294,6 @@ begin
Result := WidgetSet.GetLCLOwnerObject(Handle);
end;
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer;
begin
Result := WidgetSet.GetListBoxIndexAtY(ListBox, y);
end;
function GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
begin
Result := WidgetSet.GetListBoxItemRect(ListBox,Index,ARect);
end;
{$ifdef OldRawImageProcs}
function GetRawImageFromDevice(SrcDC: HDC; const SrcRect: TRect;
var NewRawImage: TRawImage): boolean;

View File

@ -89,8 +89,6 @@ function GetDeviceRawImageDescription(DC: HDC; Desc: PRawImageDescription): bool
{$endif}
function GetDeviceSize(DC: HDC; var p: TPoint): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function GetLCLOwnerObject(Handle: HWnd): TObject; {$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}
{$ifdef OldRawImageProcs}
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}

View File

@ -104,117 +104,6 @@ begin
{$ENDIF}
end;
//It looks like there is no way to know the clientrect of a databrowser.
//border width (when active) should be 3 pixels
const DataBrowserBorderWidth = 3;
{------------------------------------------------------------------------------
Method: GetListBoxIndexAtY
Params: ListBox - LCL List Box component
Y
Returns: Index of list item at the specified Y coordinate
------------------------------------------------------------------------------}
function TCarbonWidgetSet.GetListBoxIndexAtY(ListBox: TComponent; y: integer
): integer;
var rowheight : UInt16;
atop, aleft : UInt32;
aWidget : ControlRef;
aListBox : TCustomListBox;
delta : integer;
const
SName = 'GetListBoxIndexAtY';
begin
Result:=0;
aListBox:=TCustomListBox(ListBox);
if aListBox=nil then exit;
if not CheckWidget(aListBox.Handle, SName) then Exit;
aWidget:=ControlRef(TCarbonListBox(aListBox.Handle).Widget);
if aWidget=nil then exit;
if OSError(
GetDataBrowserTableViewRowHeight(aWidget,rowheight),
Self,SName,'GetDataBrowserTableViewRowHeight')
then exit;
if OSError(
GetDataBrowserScrollPosition(aWidget,atop,aleft),
Self,SName,'GetDataBrowserScrollPosition')
then exit;
if aListBox.BorderStyle=bsSingle then delta:=DataBrowserBorderWidth
else delta:=0;
Result:=(atop+y-delta) div rowheight;
if Result>=aListBox.Items.Count then Result:=-1;
end;
{------------------------------------------------------------------------------
Method: GetListBoxItemRect
Params: ListBox - LCL List Box component
Index - Index of list item
ARect - Rectangle
Returns: If the function succeeds
Retrieves rectangle of list item with the specified index
------------------------------------------------------------------------------}
function TCarbonWidgetSet.GetListBoxItemRect(ListBox: TComponent;
Index: integer; var ARect: TRect): boolean;
var rowheight : UInt16;
atop, aleft : UInt32;
aWidget : ControlRef;
aListBox : TCustomListBox;
aHoriz, aVertical : boolean;
scrollwidth : Sint32;
delta : integer;
const
SName = 'GetListBoxItemRect';
begin
Result:=false;
aListBox:=TCustomListBox(ListBox);
if aListBox=nil then exit;
if not CheckWidget(aListBox.Handle, SName) then Exit;
aWidget:=ControlRef(TCarbonListBox(aListBox.Handle).Widget);
if aWidget=nil then exit;
if OSError(
GetDataBrowserTableViewRowHeight(aWidget,rowheight),
Self,SName,'GetDataBrowserTableViewRowHeight')
then exit;
if OSError(
GetDataBrowserScrollPosition(aWidget,atop,aleft),
Self,SName,'GetDataBrowserScrollPosition')
then exit;
if OSError(
GetDataBrowserHasScrollBars(aWidget,aHoriz,aVertical),
Self,SName,'GetDataBrowserHasScrollBars')
then exit;
if aVertical then
begin
if OSError(
GetThemeMetric(kThemeMetricScrollBarWidth,scrollwidth),
Self,SName,'GetThemeMetric')
then exit;
end
else scrollwidth:=0;
if aListBox.BorderStyle=bsSingle then delta:=DataBrowserBorderWidth
else delta:=0;
//note: itemrect.right and bottom are outside the "real" itemrect.
ARect.Top:=(Index*rowheight)-atop+delta;
ARect.Left:=delta;
ARect.Bottom:=Arect.Top+rowheight;
ARect.Right:=aListBox.Width-delta-scrollwidth;
Result:=true;
end;
{------------------------------------------------------------------------------
Method: IntfSendsUTF8KeyPress
Returns: If the interface sends UTF-8 key press events

View File

@ -38,8 +38,6 @@ function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState)
function GetControlConstraints(Constraints: TObject): boolean; override;
function GetDesignerDC(WindowHandle: HWND): HDC; override;
function GetLCLOwnerObject(Handle: HWnd): TObject; override;
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRect): boolean; override;
function IntfSendsUTF8KeyPress: boolean; override;

View File

@ -218,7 +218,7 @@ begin
//get the client rect (the carbon provided one usually is smaller than it
//should be)
idx:=idx-1;
if not WidgetSet.GetListBoxItemRect(aListBox,idx,arect) then exit;
arect := aListBox.ItemRect(idx);
if checklist then
begin
//shrink the rect so that it doesn't include the area used by checkbox

View File

@ -106,12 +106,15 @@ type
private
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
//class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
@ -275,6 +278,10 @@ implementation
uses
CarbonProc, CarbonStrings, CarbonDbgConsts;
//It looks like there is no way to know the clientrect of a databrowser.
//border width (when active) should be 3 pixels
const DataBrowserBorderWidth = 3;
{ TCarbonWSScrollBar }
{------------------------------------------------------------------------------
@ -529,6 +536,39 @@ begin
Result := TLCLIntfHandle(TCarbonListBox.Create(AWinControl, AParams));
end;
class function TCarbonWSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
var rowheight : UInt16;
atop, aleft : UInt32;
aWidget : ControlRef;
delta : integer;
const
SName = 'GetIndexAtY';
begin
Result:=0;
if ACustomListBox=nil then exit;
if not CheckWidget(ACustomListBox.Handle, SName) then Exit;
aWidget:=ControlRef(TCarbonListBox(ACustomListBox.Handle).Widget);
if aWidget=nil then exit;
if OSError(
GetDataBrowserTableViewRowHeight(aWidget,rowheight),
Self,SName,'GetDataBrowserTableViewRowHeight')
then exit;
if OSError(
GetDataBrowserScrollPosition(aWidget,atop,aleft),
Self,SName,'GetDataBrowserScrollPosition')
then exit;
if aListBox.BorderStyle=bsSingle then delta:=DataBrowserBorderWidth
else delta:=0;
Result:=(atop+y-delta) div rowheight;
if Result>=aListBox.Items.Count then Result:=-1;
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomListBox.GetSelCount
Params: ACustomListBox - LCL custom list box
@ -585,6 +625,62 @@ begin
Result := TCarbonListBox(ACustomListBox.Handle).GetItemIndex;
end;
class function TCarbonWSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
var rowheight : UInt16;
atop, aleft : UInt32;
aWidget : ControlRef;
aHoriz, aVertical : boolean;
scrollwidth : Sint32;
delta : integer;
const
SName = 'GetItemRect';
begin
Result:=false;
if ACustomListBox=nil then exit;
if not CheckWidget(ACustomListBox.Handle, SName) then Exit;
aWidget:=ControlRef(TCarbonListBox(ACustomListBox.Handle).Widget);
if aWidget=nil then exit;
if OSError(
GetDataBrowserTableViewRowHeight(aWidget,rowheight),
Self,SName,'GetDataBrowserTableViewRowHeight')
then exit;
if OSError(
GetDataBrowserScrollPosition(aWidget,atop,aleft),
Self,SName,'GetDataBrowserScrollPosition')
then exit;
if OSError(
GetDataBrowserHasScrollBars(aWidget,aHoriz,aVertical),
Self,SName,'GetDataBrowserHasScrollBars')
then exit;
if aVertical then
begin
if OSError(
GetThemeMetric(kThemeMetricScrollBarWidth,scrollwidth),
Self,SName,'GetThemeMetric')
then exit;
end
else scrollwidth:=0;
if aListBox.BorderStyle=bsSingle then delta:=DataBrowserBorderWidth
else delta:=0;
//note: itemrect.right and bottom are outside the "real" itemrect.
ARect.Top:=(Index*rowheight)-atop+delta;
ARect.Left:=delta;
ARect.Bottom:=Arect.Top+rowheight;
ARect.Right:=aListBox.Width-delta-scrollwidth;
Result:=true;
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomListBox.GetTopIndex
Params: ACustomListBox - LCL custom list box

View File

@ -623,145 +623,6 @@ begin
Result:=nil;
end;
{------------------------------------------------------------------------------
Function: GetListBoxIndexAtY
Params: ListBox:
y:
Returns:
------------------------------------------------------------------------------}
function TGtkWidgetSet.GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer;
{$IFdef GTK2}
var
aTreeView: PGtkTreeView;
aTreeColumn: PGtkTreeViewColumn;
aTreePath : PGtkTreePath;
AWinControl: TWinControl;
begin
Result:=-1;
if not (ListBox is TWinControl) then exit;
AWinControl:=TWinControl(ListBox);
case AWinControl.fCompStyle of
csListBox, csCheckListBox:
begin
aTreeView :=
GTK_TREE_VIEW(GetWidgetInfo(Pointer(AWinControl.Handle), True)
^.CoreWidget);
if gtk_tree_view_get_path_at_pos(aTreeView, 0, Y, aTreePath, aTreeColumn,
nil, nil)
then begin
Result := gtk_tree_path_get_indices(aTreePath)[0];
gtk_tree_path_free(aTreePath);
exit;
end;
end;
end;
end;
{$Else}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
begin
Result:=-1;
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)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
if VertAdj=nil then
AdjValue:=y
else
AdjValue:=RoundToInt(VertAdj^.value)+y;
GListItem:=ListWidget^.children;
while GListItem<>nil do begin
inc(Result);
ListItemWidget:=PGtkWidget(GListItem^.data);
dec(AdjValue,ListItemWidget^.Allocation.Height);
if AdjValue<0 then exit;
GListItem:=GListItem^.next;
end;
Result:=-1;
end;
end;
{$EndIf}
{------------------------------------------------------------------------------
function TGtkWidgetSet.GetListBoxItemRect(ListBox: TComponent; Index: integer;
var ARect: TRect): boolean;
------------------------------------------------------------------------------}
function TGtkWidgetSet.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)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
if VertAdj=nil then
AdjValue:=0
else
AdjValue:= (-RoundToInt(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 TGtkWidgetSet.IntfSendsUTF8KeyPress: boolean;

View File

@ -47,8 +47,6 @@ function FontIsMonoSpace(Font: HFont): boolean; override;
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
function GetControlConstraints(Constraints: TObject): boolean; override;
function GetLCLOwnerObject(Handle: HWnd): TObject; override;
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRect): boolean; override;
function IntfSendsUTF8KeyPress: boolean; override;

View File

@ -115,11 +115,13 @@ type
protected
public
{$IFDEF GTK1}
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; 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;
@ -374,6 +376,42 @@ end;
{ TGtkWSCustomListBox }
{$IFDEF GTK1}
class function TGtkWSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
begin
Result:=-1;
if ACustomListBox.FCompStyle in [csListBox, csCheckListBox] then
begin
AWidget:=PGtkWidget(ACustomListBox.Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
if VertAdj=nil then
AdjValue:=y
else
AdjValue:=RoundToInt(VertAdj^.value)+y;
GListItem:=ListWidget^.children;
while GListItem<>nil do begin
inc(Result);
ListItemWidget:=PGtkWidget(GListItem^.data);
dec(AdjValue,ListItemWidget^.Allocation.Height);
if AdjValue<0 then exit;
GListItem:=GListItem^.next;
end;
Result:=-1;
end;
end;
class function TGtkWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox
): integer;
var
@ -417,6 +455,49 @@ begin
{!$EndIf}
end;
class function TGtkWSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
begin
Result:=false;
FillChar(ARect,SizeOf(ARect),0);
if ACustomListBox.FCompStyle in [csListBox, csCheckListBox] then
begin
AWidget:=PGtkWidget(ACustomListBox.Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
if VertAdj=nil then
AdjValue:=0
else
AdjValue:= (-RoundToInt(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;
class function TGtkWSCustomListBox.GetSelCount(const ACustomListBox: TCustomListBox
): integer;
var
@ -505,7 +586,7 @@ end;
class function TGtkWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox
): integer;
begin
Result:=TGtkWidgetSet(WidgetSet).GetListBoxIndexAtY(ACustomListBox, 0);
Result := GetIndexAtY(ACustomListBox, 0);
end;
class procedure TGtkWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox;

View File

@ -146,11 +146,14 @@ type
protected
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
public
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AnIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
@ -372,10 +375,24 @@ begin
end;
end;
class function TGtk2WSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
begin
Result:=false;
FillChar(ARect,SizeOf(ARect),0);
case ACustomListBox.fCompStyle of
csListBox, csCheckListBox:
begin
// ToDo
end;
end;
end;
class function TGtk2WSCustomListBox.GetTopIndex(
const ACustomListBox: TCustomListBox): integer;
begin
Result:=TGtk2WidgetSet(WidgetSet).GetListBoxIndexAtY(ACustomListBox, 0);
Result := GetIndexAtY(ACustomListBox, 0);
end;
class procedure TGtk2WSCustomListBox.SelectItem(
@ -570,6 +587,32 @@ begin
SignalConnect(PGtkWidget(Selection), 'changed', @Gtk2WS_ListBoxChange, AWidgetInfo);
end;
class function TGtk2WSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
var
aTreeView: PGtkTreeView;
aTreeColumn: PGtkTreeViewColumn;
aTreePath: PGtkTreePath;
begin
Result:=-1;
case ACustomListBox.fCompStyle of
csListBox, csCheckListBox:
begin
aTreeView :=
GTK_TREE_VIEW(GetWidgetInfo(Pointer(ACustomListBox.Handle), True)
^.CoreWidget);
if gtk_tree_view_get_path_at_pos(aTreeView, 0, Y, aTreePath, aTreeColumn,
nil, nil)
then begin
Result := gtk_tree_path_get_indices(aTreePath)[0];
gtk_tree_path_free(aTreePath);
exit;
end;
end;
end;
end;
class function TGtk2WSCustomListBox.GetSelCount(
const ACustomListBox: TCustomListBox): integer;
var

View File

@ -560,6 +560,8 @@ type
procedure SetOwnerDrawn(const AValue: Boolean);
public
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
function modelIndex(row, column: Integer; parent: QModelIndexH = nil): QModelIndexH;
function visualRect(Index: QModelIndexH): TRect;
property OwnerDrawn: Boolean read GetOwnerDrawn write SetOwnerDrawn;
public
procedure ItemDelegateSizeHint(option: QStyleOptionViewItemH; index: QModelIndexH; Size: PSize); cdecl;
@ -594,6 +596,7 @@ type
procedure ItemDelegatePaint(painter: QPainterH; option: QStyleOptionViewItemH; index: QModelIndexH); cdecl; override;
public
function currentRow: Integer;
function IndexAt(APoint: PQtPoint): Integer;
procedure setCurrentRow(row: Integer);
end;
@ -4679,7 +4682,7 @@ begin
State := QStyleOption_state(option);
DrawStruct.ItemID := QModelIndex_row(index);
QAbstractItemView_visualRect(QAbstractItemViewH(Widget), @DrawStruct.Area, index);
DrawStruct.Area := visualRect(index);
DrawStruct.DC := HDC(TQtDeviceContext.CreateFromPainter(painter));
DrawStruct.ItemState := [];
@ -4722,6 +4725,15 @@ begin
Result := QListWidget_currentRow(QListWidgetH(Widget));
end;
function TQtListWidget.IndexAt(APoint: PQtPoint): Integer;
var
AModelIndex: QModelIndexH;
begin
AModelIndex := QModelIndex_create();
QListView_indexAt(QListWidgetH(Widget), AModelIndex, APoint);
Result := QModelIndex_row(AModelIndex);
end;
{------------------------------------------------------------------------------
Function: TQtListWidget.setCurrentRow
Params: None
@ -6114,6 +6126,20 @@ begin
FNewDelegate := nil;
end;
function TQtAbstractItemView.modelIndex(row, column: Integer; parent: QModelIndexH = nil): QModelIndexH;
var
AModel: QAbstractItemModelH;
begin
AModel := QAbstractItemView_model(QAbstractItemViewH(Widget));
Result := QModelIndex_create();
QAbstractItemModel_index(AModel, Result, row, column, parent);
end;
function TQtAbstractItemView.visualRect(Index: QModelIndexH): TRect;
begin
QAbstractItemView_visualRect(QAbstractItemViewH(Widget), @Result, Index);
end;
procedure TQtAbstractItemView.ItemDelegateSizeHint(
option: QStyleOptionViewItemH; index: QModelIndexH; Size: PSize); cdecl;
var

View File

@ -122,11 +122,13 @@ type
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
public
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; 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;
@ -469,6 +471,15 @@ begin
Result := THandle(QtListWidget);
end;
class function TQtWSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
var
APoint: TQtPoint;
begin
APoint := QtPoint(1, y);
Result := TQtListWidget(ACustomListBox.Handle).indexAt(@APoint);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListBox.GetSelCount
Params: None
@ -529,6 +540,17 @@ begin
Result := TQtListWidget(ACustomListBox.Handle).currentRow;
end;
class function TQtWSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
var
ModelIndex: QModelIndexH;
begin
ModelIndex := TQtListWidget(ACustomListBox.Handle).ModelIndex(Index, 0);
ARect := TQtListWidget(ACustomListBox.Handle).visualRect(ModelIndex);
Result := True;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListBox.GetTopIndex
Params: None

View File

@ -354,33 +354,6 @@ begin
end;
{$endif}
{------------------------------------------------------------------------------
Function: GetListBoxIndexAtY
Params: ListBox:
y:
Returns:
------------------------------------------------------------------------------}
function TWin32WidgetSet.GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer;
begin
Result := -1;
if ListBox is TCustomListBox then begin
Result := Windows.SendMessage(TCustomListBox(ListBox).Handle, LB_ITEMFROMPOINT, 0, MakeLParam(0,y));
if hi(Result)=0 then
Result := lo(Result)
else Result := -1;
end;
end;
function TWin32WidgetSet.GetListBoxItemRect(ListBox: TComponent;
Index: integer; var ARect: TRect): boolean;
begin
Result := false;
if ListBox is TCustomListBox then
Result := Windows.SendMessage(TCustomListBox(ListBox).Handle,
LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR;
end;
{$ifdef OldRawImageProcs}
function TWin32WidgetSet.GetRawImageFromBitmap(SrcBitmap, SrcMaskBitmap: HBITMAP; const SrcRect: TRect; var NewRawImage: TRawImage): boolean;
begin

View File

@ -49,8 +49,6 @@ function FontCanUTF8(Font: HFont): boolean; override;
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
function GetControlConstraints(Constraints: TObject): boolean; override;
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRect): boolean; override;
{$note todo: remove ---}
{$ifdef OldRawImageProcs}

View File

@ -124,11 +124,13 @@ type
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; 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;
@ -518,6 +520,16 @@ begin
Result := Params.Window;
end;
class function TWin32WSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
begin
Result := Windows.SendMessage(ACustomListBox.Handle, LB_ITEMFROMPOINT, 0, MakeLParam(0,y));
if hi(Result)=0 then
Result := lo(Result)
else
Result := -1;
end;
class function TWin32WSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
begin
if ACustomListBox.MultiSelect then
@ -533,6 +545,14 @@ begin
end;
end;
class function TWin32WSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
begin
Result := Windows.SendMessage(ACustomListBox.Handle, LB_GETITEMRECT, Index,
LPARAM(@ARect)) <> LB_ERR;
end;
class function TWin32WSCustomListBox.GetSelCount(const ACustomListBox: TCustomListBox): integer;
begin
// GetSelCount only works for multiple-selection listboxes

View File

@ -463,22 +463,4 @@ begin
end;
end;
{------------------------------------------------------------------------------
Function: GetListBoxIndexAtY
Params: ListBox:
y:
Returns:
------------------------------------------------------------------------------}
function TWinCEWidgetSet.GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer;
begin
Result := -1;
if ListBox is TCustomListBox then begin
Result := Windows.SendMessage(TCustomListBox(ListBox).Handle, LB_ITEMFROMPOINT, 0, MakeLParam(0,y));
if hi(Result)=0 then
Result := lo(Result)
else Result := -1;
end;
end;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line

View File

@ -41,7 +41,6 @@ procedure DrawArrow(Arrow: TComponent; Canvas: TPersistent); override;
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
function GetControlConstraints(Constraints: TObject): boolean; override;
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
function RawImage_CreateBitmaps(const ARawImage: TRawImage; out ABitmap, AMask: HBitmap; ASkipMask: Boolean = False): Boolean; override;
function RawImage_DescriptionFromBitmap(ABitmap: HBITMAP; out ADesc: TRawImageDescription): Boolean; override;

View File

@ -114,11 +114,13 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; 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;
@ -456,6 +458,16 @@ begin
Result := Params.Window;
end;
class function TWinCEWSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
begin
Result := Windows.SendMessage(ACustomListBox.Handle, LB_ITEMFROMPOINT, 0, MakeLParam(0,y));
if hi(Result)=0 then
Result := lo(Result)
else
Result := -1;
end;
//this should not be called in multiple selection things
class function TWinCEWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
begin

View File

@ -100,11 +100,14 @@ type
{ TWSCustomListBox }
TWSCustomListBox = class(TWSWinControl)
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; virtual;
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 function GetIndexAtY(const ACustomListBox: TCustomListBox; y: integer): integer; virtual;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; virtual;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; virtual;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; virtual;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; 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;
@ -223,11 +226,25 @@ end;
{ TWSCustomListBox }
class function TWSCustomListBox.GetIndexAtY(
const ACustomListBox: TCustomListBox; y: integer): integer;
begin
Result := -1;
end;
class function TWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result := 0;
end;
class function TWSCustomListBox.GetItemRect(
const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect
): boolean;
begin
FillChar(ARect,SizeOf(ARect),0);
Result:=false;
end;
class function TWSCustomListBox.GetSelCount(const ACustomListBox: TCustomListBox): integer;
begin
Result := 0;