simple forms can now be child controls

git-svn-id: trunk@5820 -
This commit is contained in:
mattias 2004-08-18 20:49:03 +00:00
parent 0ae50847ff
commit f576d2fccd
14 changed files with 272 additions and 182 deletions

View File

@ -123,30 +123,15 @@ begin
MenuEditorDlg.Show; MenuEditorDlg.Show;
end; end;
//This function find the Designer of a Component //This function finds the Designer of a Component
function GetDesignerOfComponent(aComponent: TComponent): TComponentEditorDesigner; function GetDesignerOfComponent(aComponent: TComponent): TComponentEditorDesigner;
var var
OwnerForm: TCustomForm; OwnerForm: TCustomForm;
begin begin
Result:=nil; Result:=nil;
if (aComponent is TCustomForm) and (TCustomForm(aComponent).Parent=nil) then OwnerForm:=GetDesignerForm(AComponent);
OwnerForm:=TCustomForm(aComponent) if (OwnerForm<>nil) then
else Result:=OwnerForm.Designer as TComponentEditorDesigner;
begin
OwnerForm:=TCustomForm(aComponent.Owner);
if OwnerForm=nil then
begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+aComponent.Name+' Owner=nil');
end;
if not (OwnerForm is TCustomForm) then
begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+aComponent.Name+' OwnerForm='+OwnerForm.ClassName);
end;
Result:=TComponentEditorDesigner(OwnerForm.Designer);
end;
end; end;

View File

@ -1014,9 +1014,9 @@ var
OwnerComponent: TComponent; OwnerComponent: TComponent;
begin begin
Result:=nil; Result:=nil;
OwnerComponent:=AComponent.Owner;
if OwnerComponent=nil then
OwnerComponent:=AComponent; OwnerComponent:=AComponent;
while OwnerComponent.Owner<>nil do
OwnerComponent:=OwnerComponent.Owner;
if OwnerComponent is TCustomForm then if OwnerComponent is TCustomForm then
Result:=TCustomForm(OwnerComponent) Result:=TCustomForm(OwnerComponent)
else else
@ -1628,13 +1628,10 @@ begin
or (FSelection.Count <= 0) then Exit; or (FSelection.Count <= 0) then Exit;
Instance := FSelection[0]; Instance := FSelection[0];
if Instance is TCustomForm if Instance is TComponent then
then CustomForm:=TCustomForm(Instance) CustomForm:=GetDesignerForm(TComponent(Instance))
else if (Instance is TComponent) else
and (TComponent(Instance).Owner <> nil) CustomForm:=nil;
and (TComponent(Instance).Owner is TCustomForm)
then CustomForm:=TCustomForm(TComponent(Instance).Owner)
else CustomForm:=nil;
if (CustomForm<>nil) and (CustomForm.Designer<>nil) then if (CustomForm<>nil) and (CustomForm.Designer<>nil) then
CustomForm.Designer.Modified; CustomForm.Designer.Modified;

View File

@ -420,6 +420,7 @@ type
procedure PaintWindow(dc : Hdc); override; procedure PaintWindow(dc : Hdc); override;
procedure RequestAlign; override; procedure RequestAlign; override;
procedure SetZOrder(Topmost: Boolean); override; procedure SetZOrder(Topmost: Boolean); override;
procedure SetParent(NewParent: TWinControl); override;
procedure UpdateShowing; override; procedure UpdateShowing; override;
procedure DoFirstShow; virtual; procedure DoFirstShow; virtual;
procedure UpdateWindowState; procedure UpdateWindowState;
@ -1280,15 +1281,16 @@ end;
function GetDesignerForm(AComponent: TComponent): TCustomForm; function GetDesignerForm(AComponent: TComponent): TCustomForm;
var var
Owner: TComponent; OwnerComponent: TComponent;
begin begin
Result:=nil; Result:=nil;
if AComponent=nil then exit; if AComponent=nil then exit;
if Assigned(OnGetDesignerForm) then if Assigned(OnGetDesignerForm) then
Result:=OnGetDesignerForm(AComponent) Result:=OnGetDesignerForm(AComponent)
else begin else begin
Owner:=AComponent.Owner; OwnerComponent:=AComponent;
if Owner is TCustomForm then Result:=TCustomForm(Owner); while OwnerComponent.Owner<>nil do OwnerComponent:=OwnerComponent.Owner;
if OwnerComponent is TCustomForm then Result:=TCustomForm(OwnerComponent);
end; end;
end; end;

View File

@ -51,9 +51,6 @@ procedure TControl.BeginDrag(Immediate: Boolean; Threshold: Integer);
var var
P : TPoint; P : TPoint;
begin begin
if (Self is TCustomForm) and (FDragKind <> dkDock) then
raise EInvalidOperation.Create('Forms can not be dragged, only docked');
// start a drag operation, if not already running // start a drag operation, if not already running
if (DragControl = nil) then begin if (DragControl = nil) then begin
@ -102,8 +99,10 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DoDock(NewDockSite: TWinControl; var ARect: TRect); procedure TControl.DoDock(NewDockSite: TWinControl; var ARect: TRect);
begin begin
BoundsRect := ARect;
if (NewDockSite = nil) then Parent := nil; if (NewDockSite = nil) then Parent := nil;
//debugln('TControl.DoDock BEFORE MOVE ',Name,' BoundsRect=',dbgs(BoundsRect),' NewRect=',dbgs(ARect));
BoundsRect := ARect;
//debugln('TControl.DoDock AFTER MOVE ',Name,' BoundsRect=',dbgs(BoundsRect),' NewRect=',dbgs(ARect));
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -968,13 +967,11 @@ Function TControl.PerformTab(ForwardTab: boolean): Boolean;
Function TopLevelAncestor(TopControl : TControl) : TWinControl; Function TopLevelAncestor(TopControl : TControl) : TWinControl;
begin begin
Result := nil; Result := nil;
If TopControl = nil then exit;
If TopControl = nil then If (TopControl.Parent=nil) then begin
exit; if TopControl is TWinControl then
Result := TWinControl(TopControl)
If TopControl is TForm then end else
Result := TForm(TopControl)
else
Result := TopLevelAncestor(TopControl.Parent); Result := TopLevelAncestor(TopControl.Parent);
end; end;
@ -2852,7 +2849,7 @@ begin
// create new float dock site and dock this control into it. // create new float dock site and dock this control into it.
if Result then begin if Result then begin
FloatHost := CreateFloatingDockSite(TheScreenRect); FloatHost := CreateFloatingDockSite(TheScreenRect);
//debugln('TControl.ManualFloat A '+Name,':',ClassName,' ',dbgs(TheScreenRect)); debugln('TControl.ManualFloat A '+Name,':',ClassName,' ',dbgs(TheScreenRect),' FloatHost=',dbgs(FloatHost<>nil));
if FloatHost<>nil then if FloatHost<>nil then
Dock(FloatHost,Rect(0,0,FloatHost.ClientWidth,FloatHost.ClientHeight)) Dock(FloatHost,Rect(0,0,FloatHost.ClientWidth,FloatHost.ClientHeight))
else else
@ -3230,6 +3227,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.210 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.209 2004/08/18 09:08:34 mattias Revision 1.209 2004/08/18 09:08:34 mattias
fixed deleting of collection item in prop editor fixed deleting of collection item in prop editor

View File

@ -730,6 +730,15 @@ begin
inherited SetZOrder(Topmost); inherited SetZOrder(Topmost);
end; end;
procedure TCustomForm.SetParent(NewParent: TWinControl);
begin
if Parent=NewParent then exit;
if HandleAllocated then DestroyHandle;
inherited SetParent(NewParent);
if (Parent=nil) and Visible then
HandleNeeded;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
procedure TCustomForm.VisibleChanging; procedure TCustomForm.VisibleChanging;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -1170,7 +1179,9 @@ begin
begin begin
// WndParent := Application.Handle; // WndParent := Application.Handle;
{ TODO : No application handle } { TODO : No application handle }
Style := Style and not Cardinal(WS_CHILD or WS_GROUP or WS_TABSTOP); Style := Style and not Cardinal(WS_GROUP or WS_TABSTOP);
if Parent=nil then
Style := Style and not Cardinal(WS_CHILD);
end; end;
end; end;
end; end;
@ -1296,11 +1307,21 @@ end;
TCustomForm Method SetFocusedControl TCustomForm Method SetFocusedControl
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean; function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean;
var
ParentForm: TCustomForm;
begin begin
Result := False; Result := False;
if (csDestroying in Control.ComponentState) then exit; if (csDestroying in Control.ComponentState) then exit;
if (Parent<>nil) then begin
ParentForm:=GetParentForm(Self);
if ParentForm<>nil then
ParentForm.SetFocusedControl(Control);
exit;
end;
// update FActiveControl // update FActiveControl
if FDesigner = nil then if FDesigner = nil then
if Control <> Self then if Control <> Self then
@ -1318,8 +1339,8 @@ begin
Screen.FActiveForm := nil; Screen.FActiveForm := nil;
{$IFDEF VerboseFocus} {$IFDEF VerboseFocus}
write('TCustomForm.SetFocusedControl Self=',Name,':',ClassName,' '); DbgOut('TCustomForm.SetFocusedControl Self=',Name,':',ClassName,' ');
write(' Control=',Control.Name,':',Control.ClassName,' Control.HandleAllocated=',Control.HandleAllocated); DbgOut(' Control=',Control.Name,':',Control.ClassName,' Control.HandleAllocated=',dbgs(Control.HandleAllocated));
DebugLn(); DebugLn();
{$ENDIF} {$ENDIF}
@ -1411,14 +1432,23 @@ end;
procedure TCustomForm.CreateWnd; procedure TCustomForm.CreateWnd;
var var
DC: HDC; DC: HDC;
ParentForm: TCustomForm;
begin begin
//DebugLn('TCustomForm.CreateWnd START ',ClassName); //DebugLn('TCustomForm.CreateWnd START ',ClassName);
FFormState:=FFormState-[fsBorderStyleChanged,fsFormStyleChanged]; FFormState:=FFormState-[fsBorderStyleChanged,fsFormStyleChanged];
inherited CreateWnd; inherited CreateWnd;
if Parent=nil then begin
CNSendMessage(LM_SETFORMICON, Self, Pointer(GetIconHandle)); CNSendMessage(LM_SETFORMICON, Self, Pointer(GetIconHandle));
DC:=GetDC(Handle); DC:=GetDC(Handle);
FPixelsPerInch:=GetDeviceCaps(DC,LOGPIXELSX); FPixelsPerInch:=GetDeviceCaps(DC,LOGPIXELSX);
ReleaseDC(Handle,DC); ReleaseDC(Handle,DC);
end else begin
ParentForm:=GetParentForm(Self);
if ParentForm<>nil then begin
FPixelsPerInch:=ParentForm.PixelsPerInch;
end;
end;
Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded'); Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
if FMenu <> nil then if FMenu <> nil then
@ -1489,6 +1519,7 @@ begin
{$ENDIF} {$ENDIF}
{ If the the form is about to show, calculate its metrics } { If the the form is about to show, calculate its metrics }
if Visible then begin if Visible then begin
if Parent=nil then begin
// first make sure X and Y are assigned // first make sure X and Y are assigned
X := Left; X := Left;
Y := Top; Y := Top;
@ -1523,6 +1554,7 @@ begin
if X < 0 then X := 0; if X < 0 then X := 0;
if Y < 0 then Y := 0; if Y < 0 then Y := 0;
SetBounds(X, Y, Width, Height); SetBounds(X, Y, Width, Height);
end;
if (fsFirstShow in FFormState) then begin if (fsFirstShow in FFormState) then begin
Exclude(FFormState,fsFirstShow); Exclude(FFormState,fsFirstShow);
@ -1722,6 +1754,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.152 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.151 2004/08/18 14:24:55 mattias Revision 1.151 2004/08/18 14:24:55 mattias
implemented TCustomForm.Release implemented TCustomForm.Release

View File

@ -2466,9 +2466,9 @@ begin
if (not AWinControl.Showing) or (not AWinControl.HandleAllocated) then Exit; if (not AWinControl.Showing) or (not AWinControl.HandleAllocated) then Exit;
end; end;
if (AWinControl is TCustomForm) if ((AWinControl is TCustomForm) and (AWinControl.Parent=nil))
or (AWinControl.FParentWindow <> 0) or (AWinControl.FParentWindow <> 0) then
then UpdateShowing; UpdateShowing;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -2502,19 +2502,19 @@ begin
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True)); Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True));
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------
{ TWinControl removeControl } TWinControl removeControl
{------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Procedure TWinControl.RemoveControl(AControl: TControl); Procedure TWinControl.RemoveControl(AControl: TControl);
var
AWinControl: TWinControl;
Begin Begin
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(False)); Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(False));
if AControl is TWinControl then if AControl is TWinControl then begin
with TWinControl(AControl) do AWinControl:=TWinControl(AControl);
begin AWinControl.RemoveFocus(True);
RemoveFocus(True); if AWinControl.HandleAllocated then AWinControl.DestroyHandle;
if HandleAllocated then DestroyHandle; end else
end
else
if HandleAllocated then if HandleAllocated then
AControl.InvalidateControl(AControl.Visible, False, True); AControl.InvalidateControl(AControl.Visible, False, True);
Remove(AControl); Remove(AControl);
@ -2522,9 +2522,9 @@ Begin
Realign; Realign;
End; End;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------
{ TWinControl AlignControl } TWinControl AlignControl
{------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWinControl.AlignControl(AControl: TControl); procedure TWinControl.AlignControl(AControl: TControl);
var var
ARect: TRect; ARect: TRect;
@ -3793,6 +3793,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.263 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.262 2004/08/17 19:01:36 mattias Revision 1.262 2004/08/17 19:01:36 mattias
gtk intf now ignores size notifications of unrealized widgets gtk intf now ignores size notifications of unrealized widgets

View File

@ -53,7 +53,7 @@ type
procedure InitStockItems; override; procedure InitStockItems; override;
procedure FreeStockItems; override; procedure FreeStockItems; override;
procedure CreateComponent(Sender : TObject); override; function CreateComponent(Sender: TObject): THandle; override;
public public
{$I gnomewinapih.inc} {$I gnomewinapih.inc}
end; end;
@ -194,7 +194,7 @@ begin
Dispose(LAZBTNIGNORE); Dispose(LAZBTNIGNORE);
end; end;
procedure TGnomeWidgetSet.CreateComponent(Sender : TObject); function TGnomeWidgetSet.CreateComponent(Sender : TObject): THandle;
var var
//Caption : AnsiString; //Caption : AnsiString;
StrTemp : PChar; // same as "caption" but as PChar StrTemp : PChar; // same as "caption" but as PChar
@ -205,6 +205,7 @@ var
CompStyle : Longint; CompStyle : Longint;
DoFinishComp, DoFinishComp,
SetupProps : Boolean; SetupProps : Boolean;
ACustomForm: TCustomForm;
begin begin
P := nil; P := nil;
DoFinishComp := True; DoFinishComp := True;
@ -217,31 +218,45 @@ begin
Case CompStyle of Case CompStyle of
csForm: csForm:
begin begin
Assert(Sender is TCustomForm); ACustomForm:=TCustomForm(Sender);
With TCustomForm(Sender) do begin if ACustomForm.Parent=nil then begin
If Caption > '' then begin If ACustomForm.Caption <> '' then begin
strTemp := StrAlloc(length(Caption) + 1); strTemp := StrAlloc(length(ACustomForm.Caption) + 1);
StrPCopy(strTemp, Caption); StrPCopy(strTemp, ACustomForm.Caption);
end; end;
P := GNOME_APP_NEW(Argv[0], strTemp); P := GNOME_APP_NEW(Argv[0], strTemp);
gnome_app_enable_layout_config(p, True); gnome_app_enable_layout_config(p, True);
gtk_window_set_policy (GTK_WINDOW (p), FormResizableMap[BorderStyle], gtk_window_set_policy (GTK_WINDOW (p),
FormResizableMap[BorderStyle], 0); FormResizableMap[ACustomForm.BorderStyle],
FormResizableMap[ACustomForm.BorderStyle], 0);
// the clipboard needs a widget // the clipboard needs a widget
if ClipboardWidget=nil then if ClipboardWidget=nil then
SetClipboardWidget(p); SetClipboardWidget(p);
end else begin
P:=gtk_hbox_new(false,1);
end;
Box := CreateFormContents(P); Box := CreateFormContents(ACustomForm,P);
if ACustomForm.Parent=nil then begin
gnome_app_set_contents(p, Box); gnome_app_set_contents(p, Box);
gtk_widget_show(Box);
//drag icons //drag icons
if Drag_Icon = nil then if Drag_Icon = nil then
Drag_Icon := gdk_pixmap_colormap_create_from_xpm_d (nil, Drag_Icon := gdk_pixmap_colormap_create_from_xpm_d (nil,
gtk_widget_get_colormap (p), Drag_Mask, gtk_widget_get_colormap (p), Drag_Mask,
nil, IMGDrag_Icon); nil, IMGDrag_Icon);
end else begin
gtk_container_add(PGtkContainer(P), Box);
end;
gtk_widget_show(Box);
// main menu
if (ACustomForm.Menu<>nil)
and (ACustomForm.Menu.HandleAllocated) then begin
gtk_box_pack_start(Box, PGtkWidget(ACustomForm.Menu.Handle),False,False,0);
end; end;
end; end;
csMainMenu: csMainMenu:
@ -257,7 +272,7 @@ begin
end; end;
else else
begin begin
inherited CreateComponent(Sender); P:=Pointer(inherited CreateComponent(Sender));
DoFinishComp := False; DoFinishComp := False;
end; end;
end; end;
@ -270,6 +285,8 @@ begin
If DoFinishComp then If DoFinishComp then
FinishComponentCreate(Sender, P, SetupProps); FinishComponentCreate(Sender, P, SetupProps);
Result:=THandle(P);
end; end;
{$I gnomewinapi.inc} {$I gnomewinapi.inc}
@ -278,6 +295,9 @@ end.
{ {
$Log$ $Log$
Revision 1.28 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.27 2004/08/18 09:31:21 mattias Revision 1.27 2004/08/18 09:31:21 mattias
removed obsolete unit vclglobals removed obsolete unit vclglobals

View File

@ -137,6 +137,7 @@ begin
if (Data<>nil) then begin if (Data<>nil) then begin
if TObject(Data) is TCustomForm then begin if TObject(Data) is TCustomForm then begin
TheForm:=TCustomForm(Data); TheForm:=TCustomForm(Data);
if TheForm.Parent=nil then begin
TheWindow:=GetControlWindow(Widget); TheWindow:=GetControlWindow(Widget);
//apart from none and sizeable, this will //apart from none and sizeable, this will
@ -149,6 +150,7 @@ begin
gdk_window_set_decorations(TheWindow, decor); gdk_window_set_decorations(TheWindow, decor);
gdk_window_set_functions(TheWindow, func); gdk_window_set_functions(TheWindow, func);
end; end;
end;
if (TObject(Data) is TWinControl) then if (TObject(Data) is TWinControl) then
UpdateWidgetStyleOfControl(TWinControl(Data)); UpdateWidgetStyleOfControl(TWinControl(Data));
@ -2877,6 +2879,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.245 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.244 2004/08/17 19:01:36 mattias Revision 1.244 2004/08/17 19:01:36 mattias
gtk intf now ignores size notifications of unrealized widgets gtk intf now ignores size notifications of unrealized widgets

View File

@ -138,7 +138,7 @@ type
// create and destroy // create and destroy
function CreateComboBox(ComboBoxObject: TObject): Pointer; function CreateComboBox(ComboBoxObject: TObject): Pointer;
function CreateAPIWidget(AWinControl: TWinControl): PGtkWidget; function CreateAPIWidget(AWinControl: TWinControl): PGtkWidget;
function CreateForm(ACustomForm: TCustomForm): PGtkWidget; function CreateForm(ACustomForm: TCustomForm): PGtkWidget; virtual;
function CreateListView(ListViewObject: TObject): PGtkWidget; function CreateListView(ListViewObject: TObject): PGtkWidget;
function CreatePairSplitter(PairSplitterObject: TObject): PGtkWidget; function CreatePairSplitter(PairSplitterObject: TObject): PGtkWidget;
function CreateStatusBar(StatusBar: TObject): PGtkWidget; function CreateStatusBar(StatusBar: TObject): PGtkWidget;
@ -459,6 +459,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.186 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.185 2004/08/18 09:31:21 mattias Revision 1.185 2004/08/18 09:31:21 mattias
removed obsolete unit vclglobals removed obsolete unit vclglobals

View File

@ -446,6 +446,7 @@ end;
procedure TGtkWidgetSet.ShowModal(Sender: TObject); procedure TGtkWidgetSet.ShowModal(Sender: TObject);
var var
GtkWindow: PGtkWindow; GtkWindow: PGtkWindow;
ACustomForm: TCustomForm;
begin begin
ReleaseMouseCapture; ReleaseMouseCapture;
@ -458,11 +459,14 @@ begin
TColorDialog(Sender).Color); TColorDialog(Sender).Color);
gtk_window_set_position(GtkWindow, GTK_WIN_POS_CENTER); gtk_window_set_position(GtkWindow, GTK_WIN_POS_CENTER);
end else if (Sender is TCustomForm) then begin end else if (Sender is TCustomForm) then begin
GtkWindow:=PGtkWindow(TCustomForm(Sender).Handle); ACustomForm:=TCustomForm(Sender);
if ACustomForm.Parent=nil then begin
GtkWindow:=PGtkWindow(ACustomForm.Handle);
gtk_window_set_default_size(GtkWindow, gtk_window_set_default_size(GtkWindow,
Max(1,TControl(Sender).Width),Max(1,TControl(Sender).Height)); Max(1,ACustomForm.Width),Max(1,ACustomForm.Height));
gtk_widget_set_uposition(PGtkWidget(GtkWindow), gtk_widget_set_uposition(PGtkWidget(GtkWindow),
TControl(Sender).Left, TControl(Sender).Top); ACustomForm.Left, ACustomForm.Top);
end;
end else begin end else begin
GtkWindow:=nil; GtkWindow:=nil;
DebugLn('WARNING: TGtkWidgetSet.ShowModal ',Sender.ClassName); DebugLn('WARNING: TGtkWidgetSet.ShowModal ',Sender.ClassName);
@ -550,7 +554,8 @@ begin
ATransientWindow^.IsModal:=(ATransientWindow^.SortIndex>=0) ATransientWindow^.IsModal:=(ATransientWindow^.SortIndex>=0)
and (GTK_WIDGET_VISIBLE(PGtkWidget(Window))); and (GTK_WIDGET_VISIBLE(PGtkWidget(Window)));
if not ATransientWindow^.IsModal then begin if not ATransientWindow^.IsModal then begin
if LCLObject is TCustomForm then if (LCLObject is TCustomForm)
and (TCustomForm(LCLObject).Parent=nil) then
ATransientWindow^.SortIndex:= ATransientWindow^.SortIndex:=
Screen.CustomFormIndex(TCustomForm(LCLObject)); Screen.CustomFormIndex(TCustomForm(LCLObject));
end; end;
@ -3152,13 +3157,13 @@ begin
LM_AddChild : LM_AddChild :
begin begin
Assert(False, 'Trace:Adding a child to Parent');
{$IFDEF OldToolBar} {$IFDEF OldToolBar}
If (TControl(Sender).Parent is TToolbar) then Begin If (TControl(Sender).Parent is TToolbar) then Begin
exit; exit;
end; end;
{$ENDIF} {$ENDIF}
AParent := (Sender as TWinControl).Parent; AParent := (Sender as TWinControl).Parent;
//debugln('LM_AddChild: ',TWinControl(Sender).Name,' ',dbgs(AParent<>nil));
if Not Assigned(AParent) then Begin if Not Assigned(AParent) then Begin
Assert(true, Format('Trace: [TGtkWidgetSet.IntSendMessage3] %s --> Parent is not assigned', [Sender.ClassName])); Assert(true, Format('Trace: [TGtkWidgetSet.IntSendMessage3] %s --> Parent is not assigned', [Sender.ClassName]));
end end
@ -3202,7 +3207,7 @@ begin
DebugLn('Inserted control ', TControl(Sender).Name); DebugLn('Inserted control ', TControl(Sender).Name);
end; end;
} }
if (Sender is TCustomForm) then if (Sender is TCustomForm) and (TCustomForm(Sender).Parent=nil) then
BringFormToFront(Sender); BringFormToFront(Sender);
end; end;
@ -3479,18 +3484,17 @@ begin
LM_SETFORMICON : LM_SETFORMICON :
begin begin
if Sender is TCustomForm then begin if (Sender is TCustomForm) and (TCustomForm(Sender).Parent=nil) then
begin
if (Handle<>0) and (Data<>nil) then begin if (Handle<>0) and (Data<>nil) then begin
FormIconGdiObject:=Data; FormIconGdiObject:=Data;
//DebugLn('LM_SETFORMICON ',FormIconGdiObject<>nil,' ',pgtkWidget(Handle)^.Window<>nil); //DebugLn('LM_SETFORMICON ',FormIconGdiObject<>nil,' ',pgtkWidget(Handle)^.Window<>nil);
if (FormIconGdiObject<>nil) then begin if (FormIconGdiObject<>nil) then begin
AWindow:=GetControlWindow(PGtkWidget(Handle)); AWindow:=GetControlWindow(PGtkWidget(Handle));
if AWindow<>nil then begin if AWindow<>nil then begin
BeginGDKErrorTrap;
gdk_window_set_icon(AWindow, nil, gdk_window_set_icon(AWindow, nil,
FormIconGdiObject^.GDIBitmapObject, FormIconGdiObject^.GDIBitmapObject,
FormIconGdiObject^.GDIBitmapMaskObject); FormIconGdiObject^.GDIBitmapMaskObject);
EndGDKErrorTrap;
end; end;
end; end;
end; end;
@ -4278,7 +4282,9 @@ begin
csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog, csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog,
csPreviewFileDialog, csPreviewFileDialog,
csColorDialog, csColorDialog,
csFontDialog : gtk_window_set_title(pGtkWindow(p),PLabel); csFontDialog:
if GtkWidgetIsA(p,GTK_WINDOW_TYPE) then
gtk_window_set_title(pGtkWindow(p),PLabel);
csLabel: csLabel:
begin begin
@ -4465,7 +4471,8 @@ begin
LM_ACTIVATE : LM_ACTIVATE :
begin begin
if (ALCLObject is TCustomForm) then begin if (ALCLObject is TCustomForm) and (TCustomForm(ALCLObject).Parent=nil)
then begin
ConnectSenderSignalAfter(gObject, 'focus-in-event', @gtkfrmactivateAfter); ConnectSenderSignalAfter(gObject, 'focus-in-event', @gtkfrmactivateAfter);
ConnectSenderSignalAfter(gObject, 'focus-out-event', @gtkfrmdeactivateAfter); ConnectSenderSignalAfter(gObject, 'focus-out-event', @gtkfrmdeactivateAfter);
end else if ALCLObject is TCustomMemo then end else if ALCLObject is TCustomMemo then
@ -5187,11 +5194,11 @@ begin
csForm: csForm:
Begin Begin
if (TControl(ALCLObject).Parent=nil) then begin
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject); SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject); SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
SetCallBack(LM_Activate, AGTKObject, ALCLObject); SetCallBack(LM_Activate, AGTKObject, ALCLObject);
//SetCallback(LM_MOUSEENTER, AGTKObject, ALCLObject); end;
//SetCallback(LM_MOUSELEAVE, AGTKObject, ALCLObject);
end; end;
csLabel: csLabel:
@ -5844,7 +5851,7 @@ begin
if AGTKObject <> nil then begin if AGTKObject <> nil then begin
{$IFNDEF NoStyle} {$IFNDEF NoStyle}
if ALCLObject is TCustomForm then if (ALCLObject is TCustomForm) and (TCustomForm(ALCLObject).Parent=nil) then
gtk_widget_set_app_paintable(AGTKObject, true); gtk_widget_set_app_paintable(AGTKObject, true);
{$ENDIF} {$ENDIF}
HookSignals(AGTKObject, ALCLObject); HookSignals(AGTKObject, ALCLObject);
@ -5925,16 +5932,21 @@ var
PCaption: PChar; PCaption: PChar;
WindowType: TGtkWindowType; WindowType: TGtkWindowType;
begin begin
if ACustomForm.Parent=nil then begin
if csDesigning in ACustomForm.ComponentState then if csDesigning in ACustomForm.ComponentState then
ABorderStyle:=bsSizeable ABorderStyle:=bsSizeable
else else
ABorderStyle:=ACustomForm.BorderStyle; ABorderStyle:=ACustomForm.BorderStyle;
end else
ABorderStyle:=bsNone;
WindowType:=FormStyleMap[ABorderStyle]; WindowType:=FormStyleMap[ABorderStyle];
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop)
and (not (csDesigning in ACustomForm.ComponentState)) then begin and (not (csDesigning in ACustomForm.ComponentState)) then begin
WindowType:=GTK_WINDOW_POPUP; WindowType:=GTK_WINDOW_POPUP;
end; end;
if ACustomForm.Parent=nil then begin
// create a floating form
Result := gtk_window_new(WindowType); Result := gtk_window_new(WindowType);
gtk_window_set_policy(GTK_WINDOW(Result), FormResizableMap[ABorderStyle], gtk_window_set_policy(GTK_WINDOW(Result), FormResizableMap[ABorderStyle],
@ -5947,22 +5959,32 @@ begin
if ClipboardWidget=nil then if ClipboardWidget=nil then
SetClipboardWidget(Result); SetClipboardWidget(Result);
//drag icons
if Drag_Icon = nil then begin
{$IFDEF DebugGDKTraps}
BeginGDKErrorTrap;
{$ENDIF}
Drag_Icon := gdk_pixmap_colormap_create_from_xpm_d (nil,
gtk_widget_get_colormap (Result), Drag_Mask,
nil, @IMGDrag_Icon);
{$IFDEF DebugGDKTraps}
EndGDKErrorTrap;
{$ENDIF}
end;
end else begin
// create a form as child control
Result := gtk_hbox_new(false,0);
end;
Box := CreateFormContents(ACustomForm,Result); Box := CreateFormContents(ACustomForm,Result);
gtk_container_add(PGtkContainer(Result), Box); gtk_container_add(PGtkContainer(Result), Box);
{$IfDef GTK2} {$IfDef GTK2}
//so we can double buffer ourselves, eg, the Form Designer //so we can double buffer ourselves, eg, the Form Designer
gtk_widget_set_double_buffered(Box, False); gtk_widget_set_double_buffered(Box, False);
{$EndIf} {$EndIf}
gtk_widget_show(Box); gtk_widget_show(Box);
//drag icons
if Drag_Icon = nil then begin
BeginGDKErrorTrap;
Drag_Icon := gdk_pixmap_colormap_create_from_xpm_d (nil,
gtk_widget_get_colormap (Result), Drag_Mask,
nil, @IMGDrag_Icon);
EndGDKErrorTrap;
end;
// main menu // main menu
if (ACustomForm.Menu<>nil) if (ACustomForm.Menu<>nil)
and (ACustomForm.Menu.HandleAllocated) then begin and (ACustomForm.Menu.HandleAllocated) then begin
@ -6847,7 +6869,7 @@ var FormIconGdiObject: PGDIObject;
begin begin
if not (Sender is TWinControl) then if not (Sender is TWinControl) then
RaiseWrongClass; RaiseWrongClass;
if Sender is TCustomForm then if (Sender is TCustomForm) then
ACustomForm:=TCustomForm(Sender) ACustomForm:=TCustomForm(Sender)
else else
ACustomForm:=nil; ACustomForm:=nil;
@ -6863,7 +6885,7 @@ begin
// ' Should=',LCLControl.HandleObjectShouldBeVisible); // ' Should=',LCLControl.HandleObjectShouldBeVisible);
if LCLControl.HandleObjectShouldBeVisible then if LCLControl.HandleObjectShouldBeVisible then
begin begin
if (Sender is TCustomForm) then begin if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
// update shared accelerators // update shared accelerators
ShareWindowAccelGroups(SenderWidget); ShareWindowAccelGroups(SenderWidget);
end; end;
@ -6873,7 +6895,7 @@ begin
// before making the widget visible, set the position and size // before making the widget visible, set the position and size
if FWidgetsWithResizeRequest.Contains(SenderWidget) then begin if FWidgetsWithResizeRequest.Contains(SenderWidget) then begin
if (ACustomForm<>nil) and (LCLControl.Parent=nil) then begin if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
// top level control (a form without parent) // top level control (a form without parent)
{$IFDEF VerboseFormPositioning} {$IFDEF VerboseFormPositioning}
DebugLn('VFP [TGtkWidgetSet.ShowHide] A set bounds ', DebugLn('VFP [TGtkWidgetSet.ShowHide] A set bounds ',
@ -6901,7 +6923,7 @@ begin
UnsetResizeRequest(SenderWidget); UnsetResizeRequest(SenderWidget);
end; end;
if (ACustomForm<>nil) then begin if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
If (ACustomForm.BorderStyle <> bsSizeable) or If (ACustomForm.BorderStyle <> bsSizeable) or
((ACustomForm.FormStyle in fsAllStayOnTop) ((ACustomForm.FormStyle in fsAllStayOnTop)
and (not (csDesigning in ACustomForm.ComponentState))) and (not (csDesigning in ACustomForm.ComponentState)))
@ -6925,7 +6947,7 @@ begin
UpdateWidgetStyleOfControl(LCLControl); UpdateWidgetStyleOfControl(LCLControl);
if (ACustomForm<>nil) then begin if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
AWindow:=GetControlWindow(SenderWidget); AWindow:=GetControlWindow(SenderWidget);
if (AWindow<>nil) and (ACustomForm.Icon<>nil) then begin if (AWindow<>nil) and (ACustomForm.Icon<>nil) then begin
FormIconGdiObject:=PGDIObject(ACustomForm.GetIconHandle); FormIconGdiObject:=PGDIObject(ACustomForm.GetIconHandle);
@ -9250,6 +9272,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.529 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.528 2004/08/18 09:08:34 mattias Revision 1.528 2004/08/18 09:08:34 mattias
fixed deleting of collection item in prop editor fixed deleting of collection item in prop editor

View File

@ -4260,7 +4260,8 @@ begin
if (TheForm=nil) or (not (TheForm is TCustomForm)) if (TheForm=nil) or (not (TheForm is TCustomForm))
or (not TheForm.Visible) or (TheForm.Parent<>nil) or (not TheForm.Visible) or (TheForm.Parent<>nil)
or (csDesigning in TheForm.ComponentState) or (csDesigning in TheForm.ComponentState)
then exit; then
exit;
// check if modal form // check if modal form
if fsModal in TheForm.FormState then begin if fsModal in TheForm.FormState then begin
@ -7129,6 +7130,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.294 2004/08/18 20:49:02 mattias
simple forms can now be child controls
Revision 1.293 2004/08/17 19:01:37 mattias Revision 1.293 2004/08/17 19:01:37 mattias
gtk intf now ignores size notifications of unrealized widgets gtk intf now ignores size notifications of unrealized widgets

View File

@ -835,6 +835,7 @@ var
procedure Set_RC_Name(Sender: TObject; AWidget: PGtkWidget); procedure Set_RC_Name(Sender: TObject; AWidget: PGtkWidget);
var RCName: string; var RCName: string;
AComponent: TComponent; AComponent: TComponent;
ACustomForm: TCustomForm;
begin begin
{$IFDEF NoStyle} {$IFDEF NoStyle}
exit; exit;
@ -858,12 +859,15 @@ begin
gtk_widget_set_name(AWidget,PChar(RCName)); gtk_widget_set_name(AWidget,PChar(RCName));
gtk_widget_set_rc_style(AWidget); gtk_widget_set_rc_style(AWidget);
end; end;
if (Sender is TCustomForm) if (Sender is TCustomForm) then begin
and ((Application.MainForm=TCustomForm(Sender)) ACustomForm:=TCustomForm(Sender);
if (ACustomForm.Parent=nil)
and ((Application.MainForm=ACustomForm)
or (Application.MainForm=nil)) or (Application.MainForm=nil))
then then
UpdateSysColorMap(AWidget); UpdateSysColorMap(AWidget);
end; end;
end;
{$IFDEF UNIX} {$IFDEF UNIX}
{$IFNDEF GTK2_2} {$IFNDEF GTK2_2}

View File

@ -206,11 +206,15 @@ begin
GdkWindow:=GetControlWindow(PgtkWidget(hwnd)); GdkWindow:=GetControlWindow(PgtkWidget(hwnd));
if GdkWindow<>nil then begin if GdkWindow<>nil then begin
AForm:=TCustomForm(GetLCLObject(PgtkWidget(hwnd))); AForm:=TCustomForm(GetLCLObject(PgtkWidget(hwnd)));
if (AForm<>nil) and (AForm is TCustomForm) then if (AForm<>nil) and (AForm is TCustomForm) and (AForm.Parent=nil) then
Screen.MoveFormToZFront(AForm); Screen.MoveFormToZFront(AForm);
{$IFDEF DebugGDKTraps}
BeginGDKErrorTrap; BeginGDKErrorTrap;
{$ENDIF}
gdk_window_raise(GdkWindow); gdk_window_raise(GdkWindow);
{$IFDEF DebugGDKTraps}
EndGDKErrorTrap; EndGDKErrorTrap;
{$ENDIF}
// how to set the keyboard focus to the raised window? // how to set the keyboard focus to the raised window?
{$ifdef gtk2} {$ifdef gtk2}
gtk_window_present(PGtkWindow(hWnd)); gtk_window_present(PGtkWindow(hWnd));
@ -8705,6 +8709,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.361 2004/08/18 20:49:03 mattias
simple forms can now be child controls
Revision 1.360 2004/08/13 20:40:27 mattias Revision 1.360 2004/08/13 20:40:27 mattias
fixed DebugLn for VerboseRawImage fixed DebugLn for VerboseRawImage

View File

@ -776,8 +776,8 @@ end;
function DbgS(const r: TRect): string; function DbgS(const r: TRect): string;
begin begin
Result:=' l='+IntToStr(r.Left)+',t='+IntToStr(r.Top) Result:=' x1='+IntToStr(r.Left)+',y1='+IntToStr(r.Top)
+',r='+IntToStr(r.Right)+',b='+IntToStr(r.Bottom); +',x2='+IntToStr(r.Right)+',y2='+IntToStr(r.Bottom);
end; end;
function DbgS(const p: TPoint): string; function DbgS(const p: TPoint): string;