mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 11:58:12 +02:00
convert LM_GETSEL message to interface method
git-svn-id: trunk@6010 -
This commit is contained in:
parent
dd214aee5a
commit
dea133d633
@ -283,7 +283,7 @@ function TCustomListBox.GetSelected(Index : integer) : boolean;
|
||||
begin
|
||||
CheckIndex(Index);
|
||||
if HandleAllocated then
|
||||
Result:= (CNSendMessage(LM_GETSEL, Self, @Index) > 0)
|
||||
Result:= TWSCustomListBoxClass(WidgetSetClass).GetSelected(Self, Index)
|
||||
else
|
||||
Result:= PCustomListBoxItemRecord(GetCachedData(Index))^.Selected;
|
||||
end;
|
||||
|
@ -3062,8 +3062,6 @@ function TGtkWidgetSet.IntSendMessage3(LM_Message : Integer; Sender : TObject;
|
||||
var
|
||||
handle : hwnd; // handle of sender
|
||||
Widget : PGtkWidget; // pointer to gtk-widget (local use when neccessary)
|
||||
GList : pGList; // Only used for listboxes, replace with widget!!!!!
|
||||
ListItem : PGtkListItem; // currently only used for listboxes
|
||||
Geometry : TGdkGeometry;
|
||||
begin
|
||||
Result := 0; //default value just in case nothing sets it
|
||||
@ -3126,43 +3124,6 @@ begin
|
||||
PLMScreenInit(Data)^.ColorDepth:= gdk_visual_get_system^.depth;
|
||||
end;
|
||||
|
||||
LM_GETSEL :
|
||||
{$IFdef GTK2}
|
||||
begin
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_GETSEL');
|
||||
end;
|
||||
{$Else}
|
||||
begin
|
||||
Result := 0; { assume: nothing found }
|
||||
if (Sender is TControl)
|
||||
and Assigned (data)
|
||||
then case TControl(Sender).fCompStyle of
|
||||
csListBox, csCheckListBox:
|
||||
begin
|
||||
{ Get the child in question of that index }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.CoreWidget;
|
||||
ListItem:= g_list_nth_data(PGtkList(Widget)^.children, Integer(Data^));
|
||||
if (ListItem<>nil)
|
||||
and (g_list_index(PGtkList(Widget)^.selection, ListItem)>=0)
|
||||
then Result:=1
|
||||
end;
|
||||
csCListBox:
|
||||
begin
|
||||
{ Get the selections }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.CoreWidget;
|
||||
GList:= PGtkCList(Widget)^.selection;
|
||||
while Assigned(GList) do begin
|
||||
if integer(GList^.data) = integer(Data^) then begin
|
||||
Result:= 1;
|
||||
Break;
|
||||
end else
|
||||
GList := GList^.Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
LM_SORT:
|
||||
begin
|
||||
if (Sender is TControl) and assigned (data) then
|
||||
@ -8049,6 +8010,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.573 2004/09/15 19:38:55 micha
|
||||
convert LM_GETSEL message to interface method
|
||||
|
||||
Revision 1.572 2004/09/15 19:04:39 micha
|
||||
convert LM_GETSELCOUNT message to interface method
|
||||
|
||||
|
@ -98,6 +98,7 @@ type
|
||||
protected
|
||||
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 procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
|
||||
@ -319,6 +320,46 @@ begin
|
||||
{$EndIf}
|
||||
end;
|
||||
|
||||
function TGtkWSCustomListBox.GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean;
|
||||
var
|
||||
Handle: HWND;
|
||||
Widget : PGtkWidget; // pointer to gtk-widget (local use when neccessary)
|
||||
GList : pGList; // Only used for listboxes, replace with widget!!!!!
|
||||
ListItem : PGtkListItem; // currently only used for listboxes
|
||||
begin
|
||||
{$IFdef GTK2}
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_GETSEL');
|
||||
{$Else}
|
||||
Result := false; { assume: nothing found }
|
||||
Handle := ACustomListBox.Handle;
|
||||
case ACustomListBox.fCompStyle of
|
||||
csListBox, csCheckListBox:
|
||||
begin
|
||||
{ Get the child in question of that index }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.CoreWidget;
|
||||
ListItem:= g_list_nth_data(PGtkList(Widget)^.children, AIndex);
|
||||
if (ListItem<>nil)
|
||||
and (g_list_index(PGtkList(Widget)^.selection, ListItem)>=0)
|
||||
then Result:=true
|
||||
end;
|
||||
csCListBox:
|
||||
begin
|
||||
{ Get the selections }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.CoreWidget;
|
||||
GList:= PGtkCList(Widget)^.selection;
|
||||
while Assigned(GList) do begin
|
||||
if integer(GList^.data) = AIndex then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end else
|
||||
GList := GList^.Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
end;
|
||||
|
||||
function TGtkWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings;
|
||||
var
|
||||
Widget : PGtkWidget; // pointer to gtk-widget
|
||||
|
@ -330,11 +330,6 @@ Begin
|
||||
Else
|
||||
Assert(False, Format('Trace:I don''t know how to destroy component %S', [Sender.ClassName]));
|
||||
End;
|
||||
LM_GETSEL:
|
||||
Begin
|
||||
If Sender Is TCustomListBox then
|
||||
Result := Windows.SendMessage(Handle, LB_GETSEL, Windows.WParam(Data^), 0);
|
||||
End;
|
||||
LM_SORT:
|
||||
Begin
|
||||
If (Sender Is TControl) And Assigned(Data) Then
|
||||
@ -2136,6 +2131,9 @@ End;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.266 2004/09/15 19:38:56 micha
|
||||
convert LM_GETSEL message to interface method
|
||||
|
||||
Revision 1.265 2004/09/15 19:04:39 micha
|
||||
convert LM_GETSELCOUNT message to interface method
|
||||
|
||||
|
@ -98,6 +98,7 @@ type
|
||||
protected
|
||||
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 procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
|
||||
@ -270,6 +271,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWin32WSCustomListBox.GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean;
|
||||
begin
|
||||
Result := Windows.SendMessage(ACustomListBox.Handle, LB_GETSEL, Windows.WParam(AIndex), 0) > 0;
|
||||
end;
|
||||
|
||||
function TWin32WSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings;
|
||||
var
|
||||
Handle: HWND;
|
||||
|
@ -73,7 +73,6 @@ const
|
||||
LM_GETSELTEXT = LM_COMUSER+66;
|
||||
LM_SETSELTEXT = LM_COMUSER+67;
|
||||
LM_SORT = LM_COMUSER+74;
|
||||
LM_GETSEL = LM_COMUSER+76;
|
||||
LM_SETSEL = LM_COMUSER+77;
|
||||
LM_SETSELMODE = LM_COMUSER+78;
|
||||
LM_SETBORDER = LM_COMUSER+79;
|
||||
@ -836,7 +835,6 @@ begin
|
||||
LM_GETSELTEXT :Result:='LM_GETSELTEXT';
|
||||
LM_SETSELTEXT :Result:='LM_SETSELTEXT';
|
||||
LM_SORT :Result:='LM_SORT';
|
||||
LM_GETSEL :Result:='LM_GETSEL';
|
||||
LM_SETSEL :Result:='LM_SETSEL';
|
||||
LM_SETSELMODE :Result:='LM_SETSELMODE';
|
||||
LM_SETBORDER :Result:='LM_SETBORDER';
|
||||
@ -949,6 +947,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.105 2004/09/15 19:38:55 micha
|
||||
convert LM_GETSEL message to interface method
|
||||
|
||||
Revision 1.104 2004/09/15 19:04:39 micha
|
||||
convert LM_GETSELCOUNT message to interface method
|
||||
|
||||
|
@ -93,6 +93,7 @@ type
|
||||
TWSCustomListBox = class(TWSWinControl)
|
||||
public
|
||||
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 procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); virtual;
|
||||
@ -197,6 +198,11 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TWSCustomListBox.GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings;
|
||||
begin
|
||||
Result := nil;
|
||||
|
Loading…
Reference in New Issue
Block a user