mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-30 12:09:45 +02:00
gtk2 intf: fixed connecting events of TListBox
git-svn-id: trunk@11012 -
This commit is contained in:
parent
c5db4d9efc
commit
0cbf3340ac
@ -1064,12 +1064,14 @@ begin
|
||||
DbgS(FOldLeft,FOldTop,FOldWidth,FOldHeight),
|
||||
' User=',Dbgs(FLeft,FTop,FWidth,FHeight));
|
||||
{$ENDIF}
|
||||
//DebugLn(['TControlSelection.DoApplyUserBounds BEFORE ',Items[0].Left,' ',Items[0].Top]);
|
||||
Items[0].SetFormRelativeBounds(
|
||||
Min(NewLeft,NewRight),
|
||||
Min(NewTop,NewBottom),
|
||||
Abs(FWidth),
|
||||
Abs(FHeight)
|
||||
);
|
||||
//DebugLn(['TControlSelection.DoApplyUserBounds AFTER ',Items[0].Left,' ',Items[0].Top]);
|
||||
InvalidateGuideLinesCache;
|
||||
end else if Count>1 then begin
|
||||
// multi selection
|
||||
|
@ -442,6 +442,7 @@ begin
|
||||
if (AWidth>100000) or (AHeight>100000) then
|
||||
BoundsOutOfBounds;
|
||||
{$IFDEF CHECK_POSITION}
|
||||
if CheckPosition(Self) then
|
||||
if csDesigning in ComponentState then
|
||||
DebugLn('TControl.DoSetBounds ',Name,':',ClassName,
|
||||
' Old=',DbgS(Left,Top,Width,Height),
|
||||
@ -2173,6 +2174,7 @@ end;
|
||||
Procedure TControl.SetBoundsRect(const ARect : TRect);
|
||||
Begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('[TControl.SetBoundsRect] ',Name,':',ClassName);
|
||||
{$ENDIF}
|
||||
with ARect do
|
||||
@ -4088,6 +4090,7 @@ end;
|
||||
procedure TControl.WMSize(Var Message : TLMSize);
|
||||
begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('[TControl.WMSize] Name=',Name,':',ClassName,' Message.Width=',DbgS(Message.Width),' Message.Height=',DbgS(Message.Height),' Width=',DbgS(Width),' Height=',DbgS(Height));
|
||||
{$ENDIF}
|
||||
//Assert(False, Format('Trace:[TWinControl.WMSize] %s', [ClassName]));
|
||||
@ -4107,6 +4110,7 @@ end;
|
||||
procedure TControl.WMMove(var Message: TLMMove);
|
||||
begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('[TControl.WMMove] Name=',Name,':',ClassName,' Message.XPos=',DbgS(Message.XPos),' Message.YPos=',DbgS(Message.YPos),' OldLeft=',DbgS(Left),' OldTop=',DbgS(Top));
|
||||
{$ENDIF}
|
||||
{ Just sync the coordinates }
|
||||
|
@ -28,7 +28,7 @@
|
||||
{ $DEFINE CHECK_POSITION}
|
||||
{ $IFDEF CHECK_POSITION}
|
||||
const CheckPostionClassName = 'TButtonX';
|
||||
const CheckPostionName = 'OIDefaultItemHeightSpinEdit';
|
||||
const CheckPostionName = 'ListBox1';
|
||||
|
||||
function CheckPosition(AControl: TControl): boolean;
|
||||
begin
|
||||
@ -5711,13 +5711,14 @@ begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
//if csDesigning in ComponentState then
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('[TWinControl.SetBounds] START ',Name,':',ClassName,
|
||||
' Old=',DbgS(Left,Top,Width,Height),
|
||||
' -> New=',DbgS(ALeft,ATop,AWidth,AHeight),
|
||||
' Lock=',DbgS(BoundsLockCount),
|
||||
' Realized=',DbgS(FBoundsRealized.Left,FBoundsRealized.Top,
|
||||
FBoundsRealized.Right-FBoundsRealized.Left,FBoundsRealized.Bottom-FBoundsRealized.Top)
|
||||
);
|
||||
DebugLn(['[TWinControl.SetBounds] START ',DbgSName(Self),
|
||||
' Old=',dbgs(Bounds(Left,Top,Width,Height)),
|
||||
' -> New=',dbgs(Bounds(ALeft,ATop,AWidth,AHeight)),
|
||||
' Lock=',BoundsLockCount,
|
||||
' Realized=',dbgs(FBoundsRealized)
|
||||
]);
|
||||
if CheckPosition(Self) and (AWidth=128) then
|
||||
DumpStack;
|
||||
{$ENDIF}
|
||||
if BoundsLockCount<>0 then exit;
|
||||
OldBounds:=BoundsRect;
|
||||
@ -5732,9 +5733,9 @@ begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
//if csDesigning in ComponentState then
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('[TWinControl.SetBounds] Set LCL Bounds ',Name,':',ClassName,
|
||||
' OldBounds=',Dbgs(Left,Top,Left+Width,Top+Height),
|
||||
' -> New=',Dbgs(ALeft,ATop,ALeft+AWidth,ATop+AHeight));
|
||||
DebugLn(['[TWinControl.SetBounds] Set LCL Bounds ',DbgSName(Self),
|
||||
' OldBounds=',Dbgs(Bounds(Left,Top,Width,Height)),
|
||||
' -> New=',Dbgs(Bounds(ALeft,ATop,AWidth,AHeight))]);
|
||||
{$ENDIF}
|
||||
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
NewBounds:=Bounds(Left, Top, Width, Height);
|
||||
|
@ -3673,6 +3673,8 @@ procedure TGtkWidgetSet.SetCallback(const AMsg: LongInt;
|
||||
|
||||
var
|
||||
gObject, gFixed, gCore, Adjustment: PGTKObject;
|
||||
Info: PWidgetInfo;
|
||||
gMain: PGtkObject;
|
||||
begin
|
||||
//debugln('TGtkWidgetSet.SetCallback A ALCLObject=',DbgSName(ALCLObject),' AMsg=',dbgs(AMsg));
|
||||
if AGTKObject = nil
|
||||
@ -3684,8 +3686,14 @@ begin
|
||||
gFixed := PGTKObject(GetFixedWidget(gObject));
|
||||
if gFixed = nil then gFixed := gObject;
|
||||
|
||||
// gCore is the main widget (e.g. TListView has this)
|
||||
gCore:= PGtkObject(GetWidgetInfo(gObject, True)^.CoreWidget);
|
||||
// gCore is the working widget (e.g. TListBox has a scrolling widget (=main widget) and a tree widget (=core widget))
|
||||
Info:=GetWidgetInfo(gObject, True);
|
||||
gCore:=PGtkObject(Info^.CoreWidget);
|
||||
gMain:=GetMainWidget(gObject);
|
||||
if (gMain=nil) then
|
||||
gMain:=gObject;
|
||||
if (gMain<>gObject) then
|
||||
DebugLn(['TGtkWidgetSet.SetCallback WARNING: gObject<>MainWidget ',DbgSName(ALCLObject)]);
|
||||
|
||||
case AMsg of
|
||||
LM_SHOWWINDOW :
|
||||
|
@ -3620,6 +3620,10 @@ begin
|
||||
then raise EInterfaceException.Create('SetMainWidget ChildWidget=nil');
|
||||
if ParentWidget = ChildWidget
|
||||
then raise EInterfaceException.Create('SetMainWidget ParentWidget=ChildWidget');
|
||||
{$IFDEF Gtk2}
|
||||
if PGtkWidget(ParentWidget)^.parent=ChildWidget
|
||||
then raise EInterfaceException.Create('SetMainWidget Parent^.Parent=ChildWidget');
|
||||
{$ENDIF}
|
||||
|
||||
gtk_object_set_data(ChildWidget, 'Main', ParentWidget)
|
||||
end;
|
||||
|
@ -473,7 +473,7 @@ end;
|
||||
class function TGtk2WSCustomListBox.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle;
|
||||
var
|
||||
TempWidget: PGtkWidget;
|
||||
TVWidget: PGtkWidget;
|
||||
p: PGtkWidget; // ptr to the newly created GtkWidget
|
||||
liststore : PGtkListStore;
|
||||
Selection: PGtkTreeSelection;
|
||||
@ -495,24 +495,24 @@ begin
|
||||
|
||||
liststore := gtk_list_store_new (2, [G_TYPE_STRING, G_TYPE_POINTER, nil]);
|
||||
|
||||
TempWidget:= gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
|
||||
TVWidget:= gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
|
||||
g_object_unref (G_OBJECT (liststore));
|
||||
|
||||
renderer := LCLIntfCellRenderer_New();
|
||||
column := gtk_tree_view_column_new_with_attributes ('LISTITEMS', renderer,
|
||||
['text', 0, nil]);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (TempWidget), column);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (TVWidget), column);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (TempWidget), False);
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (TVWidget), False);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(p), TempWidget);
|
||||
gtk_widget_show(TempWidget);
|
||||
gtk_container_add(GTK_CONTAINER(p), TVWidget);
|
||||
gtk_widget_show(TVWidget);
|
||||
|
||||
SetMainWidget(p, TempWidget);
|
||||
GetWidgetInfo(p, True)^.CoreWidget := TempWidget;
|
||||
SetMainWidget(p, TVWidget);
|
||||
GetWidgetInfo(p, True)^.CoreWidget := TVWidget;
|
||||
|
||||
Selection := gtk_tree_view_get_selection(PGtkTreeView(TempWidget));
|
||||
Selection := gtk_tree_view_get_selection(PGtkTreeView(TVWidget));
|
||||
|
||||
case TCustomListBox(AWinControl).MultiSelect of
|
||||
True : gtk_tree_selection_set_mode(Selection, GTK_SELECTION_MULTIPLE);
|
||||
@ -520,7 +520,7 @@ begin
|
||||
end;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(p, False);
|
||||
SetCallbacks(TempWidget, WidgetInfo);
|
||||
SetCallbacks(p, WidgetInfo);
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomListBox.SetCallbacks(
|
||||
|
Loading…
Reference in New Issue
Block a user