gtk2 intf: fixed connecting events of TListBox

git-svn-id: trunk@11012 -
This commit is contained in:
mattias 2007-04-27 09:30:50 +00:00
parent c5db4d9efc
commit 0cbf3340ac
6 changed files with 42 additions and 23 deletions

View File

@ -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

View File

@ -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 }

View File

@ -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);

View File

@ -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 :

View File

@ -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;

View File

@ -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(