mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 20:47:58 +02:00
simple forms can now be child controls
git-svn-id: trunk@5820 -
This commit is contained in:
parent
0ae50847ff
commit
f576d2fccd
@ -123,30 +123,15 @@ begin
|
||||
MenuEditorDlg.Show;
|
||||
end;
|
||||
|
||||
//This function find the Designer of a Component
|
||||
function GetDesignerOfComponent(aComponent : TComponent): TComponentEditorDesigner;
|
||||
//This function finds the Designer of a Component
|
||||
function GetDesignerOfComponent(aComponent: TComponent): TComponentEditorDesigner;
|
||||
var
|
||||
OwnerForm: TCustomForm;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (aComponent is TCustomForm) and (TCustomForm(aComponent).Parent=nil) then
|
||||
OwnerForm:=TCustomForm(aComponent)
|
||||
else
|
||||
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;
|
||||
OwnerForm:=GetDesignerForm(AComponent);
|
||||
if (OwnerForm<>nil) then
|
||||
Result:=OwnerForm.Designer as TComponentEditorDesigner;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -1014,9 +1014,9 @@ var
|
||||
OwnerComponent: TComponent;
|
||||
begin
|
||||
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
|
||||
Result:=TCustomForm(OwnerComponent)
|
||||
else
|
||||
@ -1628,14 +1628,11 @@ begin
|
||||
or (FSelection.Count <= 0) then Exit;
|
||||
|
||||
Instance := FSelection[0];
|
||||
if Instance is TCustomForm
|
||||
then CustomForm:=TCustomForm(Instance)
|
||||
else if (Instance is TComponent)
|
||||
and (TComponent(Instance).Owner <> nil)
|
||||
and (TComponent(Instance).Owner is TCustomForm)
|
||||
then CustomForm:=TCustomForm(TComponent(Instance).Owner)
|
||||
else CustomForm:=nil;
|
||||
|
||||
if Instance is TComponent then
|
||||
CustomForm:=GetDesignerForm(TComponent(Instance))
|
||||
else
|
||||
CustomForm:=nil;
|
||||
|
||||
if (CustomForm<>nil) and (CustomForm.Designer<>nil) then
|
||||
CustomForm.Designer.Modified;
|
||||
end;
|
||||
|
@ -420,6 +420,7 @@ type
|
||||
procedure PaintWindow(dc : Hdc); override;
|
||||
procedure RequestAlign; override;
|
||||
procedure SetZOrder(Topmost: Boolean); override;
|
||||
procedure SetParent(NewParent: TWinControl); override;
|
||||
procedure UpdateShowing; override;
|
||||
procedure DoFirstShow; virtual;
|
||||
procedure UpdateWindowState;
|
||||
@ -1280,15 +1281,16 @@ end;
|
||||
|
||||
function GetDesignerForm(AComponent: TComponent): TCustomForm;
|
||||
var
|
||||
Owner: TComponent;
|
||||
OwnerComponent: TComponent;
|
||||
begin
|
||||
Result:=nil;
|
||||
if AComponent=nil then exit;
|
||||
if Assigned(OnGetDesignerForm) then
|
||||
Result:=OnGetDesignerForm(AComponent)
|
||||
else begin
|
||||
Owner:=AComponent.Owner;
|
||||
if Owner is TCustomForm then Result:=TCustomForm(Owner);
|
||||
OwnerComponent:=AComponent;
|
||||
while OwnerComponent.Owner<>nil do OwnerComponent:=OwnerComponent.Owner;
|
||||
if OwnerComponent is TCustomForm then Result:=TCustomForm(OwnerComponent);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -51,9 +51,6 @@ procedure TControl.BeginDrag(Immediate: Boolean; Threshold: Integer);
|
||||
var
|
||||
P : TPoint;
|
||||
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
|
||||
if (DragControl = nil) then begin
|
||||
|
||||
@ -102,8 +99,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.DoDock(NewDockSite: TWinControl; var ARect: TRect);
|
||||
begin
|
||||
BoundsRect := ARect;
|
||||
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;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -968,13 +967,11 @@ Function TControl.PerformTab(ForwardTab: boolean): Boolean;
|
||||
Function TopLevelAncestor(TopControl : TControl) : TWinControl;
|
||||
begin
|
||||
Result := nil;
|
||||
|
||||
If TopControl = nil then
|
||||
exit;
|
||||
|
||||
If TopControl is TForm then
|
||||
Result := TForm(TopControl)
|
||||
else
|
||||
If TopControl = nil then exit;
|
||||
If (TopControl.Parent=nil) then begin
|
||||
if TopControl is TWinControl then
|
||||
Result := TWinControl(TopControl)
|
||||
end else
|
||||
Result := TopLevelAncestor(TopControl.Parent);
|
||||
end;
|
||||
|
||||
@ -2852,7 +2849,7 @@ begin
|
||||
// create new float dock site and dock this control into it.
|
||||
if Result then begin
|
||||
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
|
||||
Dock(FloatHost,Rect(0,0,FloatHost.ClientWidth,FloatHost.ClientHeight))
|
||||
else
|
||||
@ -3230,6 +3227,9 @@ end;
|
||||
|
||||
{ =============================================================================
|
||||
$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
|
||||
fixed deleting of collection item in prop editor
|
||||
|
||||
|
@ -730,6 +730,15 @@ begin
|
||||
inherited SetZOrder(Topmost);
|
||||
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;
|
||||
------------------------------------------------------------------------------}
|
||||
@ -1170,7 +1179,9 @@ begin
|
||||
begin
|
||||
// WndParent := 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;
|
||||
@ -1296,10 +1307,20 @@ end;
|
||||
TCustomForm Method SetFocusedControl
|
||||
------------------------------------------------------------------------------}
|
||||
function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean;
|
||||
var
|
||||
ParentForm: TCustomForm;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
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
|
||||
if FDesigner = nil then
|
||||
@ -1318,8 +1339,8 @@ begin
|
||||
Screen.FActiveForm := nil;
|
||||
|
||||
{$IFDEF VerboseFocus}
|
||||
write('TCustomForm.SetFocusedControl Self=',Name,':',ClassName,' ');
|
||||
write(' Control=',Control.Name,':',Control.ClassName,' Control.HandleAllocated=',Control.HandleAllocated);
|
||||
DbgOut('TCustomForm.SetFocusedControl Self=',Name,':',ClassName,' ');
|
||||
DbgOut(' Control=',Control.Name,':',Control.ClassName,' Control.HandleAllocated=',dbgs(Control.HandleAllocated));
|
||||
DebugLn();
|
||||
{$ENDIF}
|
||||
|
||||
@ -1411,14 +1432,23 @@ end;
|
||||
procedure TCustomForm.CreateWnd;
|
||||
var
|
||||
DC: HDC;
|
||||
ParentForm: TCustomForm;
|
||||
begin
|
||||
//DebugLn('TCustomForm.CreateWnd START ',ClassName);
|
||||
FFormState:=FFormState-[fsBorderStyleChanged,fsFormStyleChanged];
|
||||
inherited CreateWnd;
|
||||
CNSendMessage(LM_SETFORMICON, Self, Pointer(GetIconHandle));
|
||||
DC:=GetDC(Handle);
|
||||
FPixelsPerInch:=GetDeviceCaps(DC,LOGPIXELSX);
|
||||
ReleaseDC(Handle,DC);
|
||||
|
||||
if Parent=nil then begin
|
||||
CNSendMessage(LM_SETFORMICON, Self, Pointer(GetIconHandle));
|
||||
DC:=GetDC(Handle);
|
||||
FPixelsPerInch:=GetDeviceCaps(DC,LOGPIXELSX);
|
||||
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');
|
||||
if FMenu <> nil then
|
||||
@ -1489,40 +1519,42 @@ begin
|
||||
{$ENDIF}
|
||||
{ If the the form is about to show, calculate its metrics }
|
||||
if Visible then begin
|
||||
// first make sure X and Y are assigned
|
||||
X := Left;
|
||||
Y := Top;
|
||||
if Parent=nil then begin
|
||||
// first make sure X and Y are assigned
|
||||
X := Left;
|
||||
Y := Top;
|
||||
|
||||
if (Position = poMainFormCenter)
|
||||
and (FormStyle = fsMDIChild)
|
||||
and (Self <> Application.Mainform)
|
||||
then begin
|
||||
X:= (Application.Mainform.ClientWidth - Width) div 2;
|
||||
Y:= (Application.Mainform.ClientHeight - Height) div 2;
|
||||
end
|
||||
else begin
|
||||
case Position of
|
||||
//TODO:poDefault, poDefaultPosOnly, poDefaultSizeOnly
|
||||
poScreenCenter, poDesktopCenter :
|
||||
begin
|
||||
X:= (Screen.Width - Width) div 2;
|
||||
Y:= (Screen.Height - Height) div 2;
|
||||
end;
|
||||
poMainFormCenter :
|
||||
if (Self <> Application.MainForm) then begin
|
||||
X:= ((Application.MainForm.Width - Width) div 2) + Application.MainForm.Left;
|
||||
Y:= ((Application.MainForm.Height - Height) div 2) + Application.MainForm.Top;
|
||||
end;
|
||||
poOwnerFormCenter :
|
||||
if (Owner is TCustomForm) then begin
|
||||
X:= ((TCustomForm(Owner).Width - Width) div 2) + TCustomForm(Owner).Left;
|
||||
Y:= ((TCustomForm(Owner).Height - Height) div 2) + TCustomForm(Owner).Top;
|
||||
if (Position = poMainFormCenter)
|
||||
and (FormStyle = fsMDIChild)
|
||||
and (Self <> Application.Mainform)
|
||||
then begin
|
||||
X:= (Application.Mainform.ClientWidth - Width) div 2;
|
||||
Y:= (Application.Mainform.ClientHeight - Height) div 2;
|
||||
end
|
||||
else begin
|
||||
case Position of
|
||||
//TODO:poDefault, poDefaultPosOnly, poDefaultSizeOnly
|
||||
poScreenCenter, poDesktopCenter :
|
||||
begin
|
||||
X:= (Screen.Width - Width) div 2;
|
||||
Y:= (Screen.Height - Height) div 2;
|
||||
end;
|
||||
poMainFormCenter :
|
||||
if (Self <> Application.MainForm) then begin
|
||||
X:= ((Application.MainForm.Width - Width) div 2) + Application.MainForm.Left;
|
||||
Y:= ((Application.MainForm.Height - Height) div 2) + Application.MainForm.Top;
|
||||
end;
|
||||
poOwnerFormCenter :
|
||||
if (Owner is TCustomForm) then begin
|
||||
X:= ((TCustomForm(Owner).Width - Width) div 2) + TCustomForm(Owner).Left;
|
||||
Y:= ((TCustomForm(Owner).Height - Height) div 2) + TCustomForm(Owner).Top;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if X < 0 then X := 0;
|
||||
if Y < 0 then Y := 0;
|
||||
SetBounds(X, Y, Width, Height);
|
||||
end;
|
||||
if X < 0 then X := 0;
|
||||
if Y < 0 then Y := 0;
|
||||
SetBounds(X, Y, Width, Height);
|
||||
|
||||
if (fsFirstShow in FFormState) then begin
|
||||
Exclude(FFormState,fsFirstShow);
|
||||
@ -1722,6 +1754,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
implemented TCustomForm.Release
|
||||
|
||||
|
@ -2466,15 +2466,15 @@ begin
|
||||
if (not AWinControl.Showing) or (not AWinControl.HandleAllocated) then Exit;
|
||||
end;
|
||||
|
||||
if (AWinControl is TCustomForm)
|
||||
or (AWinControl.FParentWindow <> 0)
|
||||
then UpdateShowing;
|
||||
if ((AWinControl is TCustomForm) and (AWinControl.Parent=nil))
|
||||
or (AWinControl.FParentWindow <> 0) then
|
||||
UpdateShowing;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TWinControl InsertControl }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TWinControl.InsertControl(AControl : TControl);
|
||||
Procedure TWinControl.InsertControl(AControl: TControl);
|
||||
Begin
|
||||
InsertControl(AControl,ControlCount);
|
||||
End;
|
||||
@ -2502,19 +2502,19 @@ begin
|
||||
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TWinControl removeControl }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TWinControl.RemoveControl(AControl : TControl);
|
||||
{------------------------------------------------------------------------------
|
||||
TWinControl removeControl
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TWinControl.RemoveControl(AControl: TControl);
|
||||
var
|
||||
AWinControl: TWinControl;
|
||||
Begin
|
||||
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(False));
|
||||
if AControl is TWinControl then
|
||||
with TWinControl(AControl) do
|
||||
begin
|
||||
RemoveFocus(True);
|
||||
if HandleAllocated then DestroyHandle;
|
||||
end
|
||||
else
|
||||
if AControl is TWinControl then begin
|
||||
AWinControl:=TWinControl(AControl);
|
||||
AWinControl.RemoveFocus(True);
|
||||
if AWinControl.HandleAllocated then AWinControl.DestroyHandle;
|
||||
end else
|
||||
if HandleAllocated then
|
||||
AControl.InvalidateControl(AControl.Visible, False, True);
|
||||
Remove(AControl);
|
||||
@ -2522,9 +2522,9 @@ Begin
|
||||
Realign;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TWinControl AlignControl }
|
||||
{------------------------------------------------------------------------------}
|
||||
{------------------------------------------------------------------------------
|
||||
TWinControl AlignControl
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TWinControl.AlignControl(AControl: TControl);
|
||||
var
|
||||
ARect: TRect;
|
||||
@ -3793,6 +3793,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
gtk intf now ignores size notifications of unrealized widgets
|
||||
|
||||
|
@ -53,7 +53,7 @@ type
|
||||
procedure InitStockItems; override;
|
||||
procedure FreeStockItems; override;
|
||||
|
||||
procedure CreateComponent(Sender : TObject); override;
|
||||
function CreateComponent(Sender: TObject): THandle; override;
|
||||
public
|
||||
{$I gnomewinapih.inc}
|
||||
end;
|
||||
@ -194,17 +194,18 @@ begin
|
||||
Dispose(LAZBTNIGNORE);
|
||||
end;
|
||||
|
||||
procedure TGnomeWidgetSet.CreateComponent(Sender : TObject);
|
||||
function TGnomeWidgetSet.CreateComponent(Sender : TObject): THandle;
|
||||
var
|
||||
//Caption : AnsiString;
|
||||
StrTemp : PChar; // same as "caption" but as PChar
|
||||
p : pointer; // ptr to the newly created GtkWidget
|
||||
Box : Pointer; // currently only used for TCustomBitBtn
|
||||
// and TCustomForm and TCustomListView
|
||||
StrTemp : PChar; // same as "caption" but as PChar
|
||||
p : pointer; // ptr to the newly created GtkWidget
|
||||
Box : Pointer; // currently only used for TCustomBitBtn
|
||||
// and TCustomForm and TCustomListView
|
||||
ParentForm: TCustomForm;
|
||||
CompStyle : Longint;
|
||||
DoFinishComp,
|
||||
SetupProps : Boolean;
|
||||
ACustomForm: TCustomForm;
|
||||
begin
|
||||
P := nil;
|
||||
DoFinishComp := True;
|
||||
@ -217,31 +218,45 @@ begin
|
||||
Case CompStyle of
|
||||
csForm:
|
||||
begin
|
||||
Assert(Sender is TCustomForm);
|
||||
With TCustomForm(Sender) do begin
|
||||
If Caption > '' then begin
|
||||
strTemp := StrAlloc(length(Caption) + 1);
|
||||
StrPCopy(strTemp, Caption);
|
||||
ACustomForm:=TCustomForm(Sender);
|
||||
if ACustomForm.Parent=nil then begin
|
||||
If ACustomForm.Caption <> '' then begin
|
||||
strTemp := StrAlloc(length(ACustomForm.Caption) + 1);
|
||||
StrPCopy(strTemp, ACustomForm.Caption);
|
||||
end;
|
||||
|
||||
P := GNOME_APP_NEW(Argv[0], strTemp);
|
||||
gnome_app_enable_layout_config(p, True);
|
||||
gtk_window_set_policy (GTK_WINDOW (p), FormResizableMap[BorderStyle],
|
||||
FormResizableMap[BorderStyle], 0);
|
||||
gtk_window_set_policy (GTK_WINDOW (p),
|
||||
FormResizableMap[ACustomForm.BorderStyle],
|
||||
FormResizableMap[ACustomForm.BorderStyle], 0);
|
||||
|
||||
// the clipboard needs a widget
|
||||
if ClipboardWidget=nil then
|
||||
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);
|
||||
gtk_widget_show(Box);
|
||||
|
||||
//drag icons
|
||||
if Drag_Icon = nil then
|
||||
Drag_Icon := gdk_pixmap_colormap_create_from_xpm_d (nil,
|
||||
gtk_widget_get_colormap (p), Drag_Mask,
|
||||
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;
|
||||
csMainMenu:
|
||||
@ -257,7 +272,7 @@ begin
|
||||
end;
|
||||
else
|
||||
begin
|
||||
inherited CreateComponent(Sender);
|
||||
P:=Pointer(inherited CreateComponent(Sender));
|
||||
DoFinishComp := False;
|
||||
end;
|
||||
end;
|
||||
@ -270,6 +285,8 @@ begin
|
||||
|
||||
If DoFinishComp then
|
||||
FinishComponentCreate(Sender, P, SetupProps);
|
||||
|
||||
Result:=THandle(P);
|
||||
end;
|
||||
|
||||
{$I gnomewinapi.inc}
|
||||
@ -278,6 +295,9 @@ end.
|
||||
|
||||
{
|
||||
$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
|
||||
removed obsolete unit vclglobals
|
||||
|
||||
|
@ -137,17 +137,19 @@ begin
|
||||
if (Data<>nil) then begin
|
||||
if TObject(Data) is TCustomForm then begin
|
||||
TheForm:=TCustomForm(Data);
|
||||
TheWindow:=GetControlWindow(Widget);
|
||||
if TheForm.Parent=nil then begin
|
||||
TheWindow:=GetControlWindow(Widget);
|
||||
|
||||
//apart from none and sizeable, this will
|
||||
//only work if WM supports motif flags
|
||||
//properly, which very few actually do.
|
||||
//apart from none and sizeable, this will
|
||||
//only work if WM supports motif flags
|
||||
//properly, which very few actually do.
|
||||
|
||||
Decor := GetWindowDecorations(TheForm);
|
||||
Func := GetWindowFunction(TheForm);
|
||||
Decor := GetWindowDecorations(TheForm);
|
||||
Func := GetWindowFunction(TheForm);
|
||||
|
||||
gdk_window_set_decorations(TheWindow, decor);
|
||||
gdk_window_set_functions(TheWindow, func);
|
||||
gdk_window_set_decorations(TheWindow, decor);
|
||||
gdk_window_set_functions(TheWindow, func);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (TObject(Data) is TWinControl) then
|
||||
@ -2877,6 +2879,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
gtk intf now ignores size notifications of unrealized widgets
|
||||
|
||||
|
@ -138,7 +138,7 @@ type
|
||||
// create and destroy
|
||||
function CreateComboBox(ComboBoxObject: TObject): Pointer;
|
||||
function CreateAPIWidget(AWinControl: TWinControl): PGtkWidget;
|
||||
function CreateForm(ACustomForm: TCustomForm): PGtkWidget;
|
||||
function CreateForm(ACustomForm: TCustomForm): PGtkWidget; virtual;
|
||||
function CreateListView(ListViewObject: TObject): PGtkWidget;
|
||||
function CreatePairSplitter(PairSplitterObject: TObject): PGtkWidget;
|
||||
function CreateStatusBar(StatusBar: TObject): PGtkWidget;
|
||||
@ -459,6 +459,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
removed obsolete unit vclglobals
|
||||
|
||||
|
@ -446,6 +446,7 @@ end;
|
||||
procedure TGtkWidgetSet.ShowModal(Sender: TObject);
|
||||
var
|
||||
GtkWindow: PGtkWindow;
|
||||
ACustomForm: TCustomForm;
|
||||
begin
|
||||
ReleaseMouseCapture;
|
||||
|
||||
@ -458,11 +459,14 @@ begin
|
||||
TColorDialog(Sender).Color);
|
||||
gtk_window_set_position(GtkWindow, GTK_WIN_POS_CENTER);
|
||||
end else if (Sender is TCustomForm) then begin
|
||||
GtkWindow:=PGtkWindow(TCustomForm(Sender).Handle);
|
||||
gtk_window_set_default_size(GtkWindow,
|
||||
Max(1,TControl(Sender).Width),Max(1,TControl(Sender).Height));
|
||||
gtk_widget_set_uposition(PGtkWidget(GtkWindow),
|
||||
TControl(Sender).Left, TControl(Sender).Top);
|
||||
ACustomForm:=TCustomForm(Sender);
|
||||
if ACustomForm.Parent=nil then begin
|
||||
GtkWindow:=PGtkWindow(ACustomForm.Handle);
|
||||
gtk_window_set_default_size(GtkWindow,
|
||||
Max(1,ACustomForm.Width),Max(1,ACustomForm.Height));
|
||||
gtk_widget_set_uposition(PGtkWidget(GtkWindow),
|
||||
ACustomForm.Left, ACustomForm.Top);
|
||||
end;
|
||||
end else begin
|
||||
GtkWindow:=nil;
|
||||
DebugLn('WARNING: TGtkWidgetSet.ShowModal ',Sender.ClassName);
|
||||
@ -550,7 +554,8 @@ begin
|
||||
ATransientWindow^.IsModal:=(ATransientWindow^.SortIndex>=0)
|
||||
and (GTK_WIDGET_VISIBLE(PGtkWidget(Window)));
|
||||
if not ATransientWindow^.IsModal then begin
|
||||
if LCLObject is TCustomForm then
|
||||
if (LCLObject is TCustomForm)
|
||||
and (TCustomForm(LCLObject).Parent=nil) then
|
||||
ATransientWindow^.SortIndex:=
|
||||
Screen.CustomFormIndex(TCustomForm(LCLObject));
|
||||
end;
|
||||
@ -3152,13 +3157,13 @@ begin
|
||||
|
||||
LM_AddChild :
|
||||
begin
|
||||
Assert(False, 'Trace:Adding a child to Parent');
|
||||
{$IFDEF OldToolBar}
|
||||
If (TControl(Sender).Parent is TToolbar) then Begin
|
||||
exit;
|
||||
end;
|
||||
{$ENDIF}
|
||||
AParent := (Sender as TWinControl).Parent;
|
||||
//debugln('LM_AddChild: ',TWinControl(Sender).Name,' ',dbgs(AParent<>nil));
|
||||
if Not Assigned(AParent) then Begin
|
||||
Assert(true, Format('Trace: [TGtkWidgetSet.IntSendMessage3] %s --> Parent is not assigned', [Sender.ClassName]));
|
||||
end
|
||||
@ -3202,7 +3207,7 @@ begin
|
||||
DebugLn('Inserted control ', TControl(Sender).Name);
|
||||
end;
|
||||
}
|
||||
if (Sender is TCustomForm) then
|
||||
if (Sender is TCustomForm) and (TCustomForm(Sender).Parent=nil) then
|
||||
BringFormToFront(Sender);
|
||||
end;
|
||||
|
||||
@ -3479,18 +3484,17 @@ begin
|
||||
|
||||
LM_SETFORMICON :
|
||||
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
|
||||
FormIconGdiObject:=Data;
|
||||
//DebugLn('LM_SETFORMICON ',FormIconGdiObject<>nil,' ',pgtkWidget(Handle)^.Window<>nil);
|
||||
if (FormIconGdiObject<>nil) then begin
|
||||
AWindow:=GetControlWindow(PGtkWidget(Handle));
|
||||
if AWindow<>nil then begin
|
||||
BeginGDKErrorTrap;
|
||||
gdk_window_set_icon(AWindow, nil,
|
||||
FormIconGdiObject^.GDIBitmapObject,
|
||||
FormIconGdiObject^.GDIBitmapMaskObject);
|
||||
EndGDKErrorTrap;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -4278,7 +4282,9 @@ begin
|
||||
csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog,
|
||||
csPreviewFileDialog,
|
||||
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:
|
||||
begin
|
||||
@ -4465,7 +4471,8 @@ begin
|
||||
|
||||
LM_ACTIVATE :
|
||||
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-out-event', @gtkfrmdeactivateAfter);
|
||||
end else if ALCLObject is TCustomMemo then
|
||||
@ -5187,11 +5194,11 @@ begin
|
||||
|
||||
csForm:
|
||||
Begin
|
||||
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
||||
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
|
||||
SetCallBack(LM_Activate, AGTKObject, ALCLObject);
|
||||
//SetCallback(LM_MOUSEENTER, AGTKObject, ALCLObject);
|
||||
//SetCallback(LM_MOUSELEAVE, AGTKObject, ALCLObject);
|
||||
if (TControl(ALCLObject).Parent=nil) then begin
|
||||
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
||||
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
|
||||
SetCallBack(LM_Activate, AGTKObject, ALCLObject);
|
||||
end;
|
||||
end;
|
||||
|
||||
csLabel:
|
||||
@ -5844,7 +5851,7 @@ begin
|
||||
|
||||
if AGTKObject <> nil then begin
|
||||
{$IFNDEF NoStyle}
|
||||
if ALCLObject is TCustomForm then
|
||||
if (ALCLObject is TCustomForm) and (TCustomForm(ALCLObject).Parent=nil) then
|
||||
gtk_widget_set_app_paintable(AGTKObject, true);
|
||||
{$ENDIF}
|
||||
HookSignals(AGTKObject, ALCLObject);
|
||||
@ -5925,44 +5932,59 @@ var
|
||||
PCaption: PChar;
|
||||
WindowType: TGtkWindowType;
|
||||
begin
|
||||
if csDesigning in ACustomForm.ComponentState then
|
||||
ABorderStyle:=bsSizeable
|
||||
else
|
||||
ABorderStyle:=ACustomForm.BorderStyle;
|
||||
if ACustomForm.Parent=nil then begin
|
||||
if csDesigning in ACustomForm.ComponentState then
|
||||
ABorderStyle:=bsSizeable
|
||||
else
|
||||
ABorderStyle:=ACustomForm.BorderStyle;
|
||||
end else
|
||||
ABorderStyle:=bsNone;
|
||||
WindowType:=FormStyleMap[ABorderStyle];
|
||||
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop)
|
||||
and (not (csDesigning in ACustomForm.ComponentState)) then begin
|
||||
WindowType:=GTK_WINDOW_POPUP;
|
||||
end;
|
||||
|
||||
Result := gtk_window_new(WindowType);
|
||||
if ACustomForm.Parent=nil then begin
|
||||
// create a floating form
|
||||
Result := gtk_window_new(WindowType);
|
||||
|
||||
gtk_window_set_policy(GTK_WINDOW(Result), FormResizableMap[ABorderStyle],
|
||||
FormResizableMap[ABorderStyle], 0);
|
||||
PCaption:=PChar(ACustomForm.Caption);
|
||||
if PCaption=nil then PCaption:=#0;
|
||||
gtk_window_set_title(pGtkWindow(Result), PCaption);
|
||||
|
||||
gtk_window_set_policy(GTK_WINDOW(Result), FormResizableMap[ABorderStyle],
|
||||
FormResizableMap[ABorderStyle], 0);
|
||||
PCaption:=PChar(ACustomForm.Caption);
|
||||
if PCaption=nil then PCaption:=#0;
|
||||
gtk_window_set_title(pGtkWindow(Result), PCaption);
|
||||
// the clipboard needs a widget
|
||||
if ClipboardWidget=nil then
|
||||
SetClipboardWidget(Result);
|
||||
|
||||
// the clipboard needs a widget
|
||||
if ClipboardWidget=nil then
|
||||
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);
|
||||
gtk_container_add(PGtkContainer(Result), Box);
|
||||
|
||||
{$IfDef GTK2}
|
||||
//so we can double buffer ourselves, eg, the Form Designer
|
||||
gtk_widget_set_double_buffered(Box, False);
|
||||
{$EndIf}
|
||||
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
|
||||
if (ACustomForm.Menu<>nil)
|
||||
and (ACustomForm.Menu.HandleAllocated) then begin
|
||||
@ -6438,7 +6460,7 @@ begin
|
||||
csWinControl:
|
||||
p:=CreateAPIWidget(TWinControl(Sender));
|
||||
|
||||
csForm :
|
||||
csForm:
|
||||
p:=CreateForm(TCustomForm(Sender));
|
||||
(*
|
||||
csFrame :
|
||||
@ -6847,7 +6869,7 @@ var FormIconGdiObject: PGDIObject;
|
||||
begin
|
||||
if not (Sender is TWinControl) then
|
||||
RaiseWrongClass;
|
||||
if Sender is TCustomForm then
|
||||
if (Sender is TCustomForm) then
|
||||
ACustomForm:=TCustomForm(Sender)
|
||||
else
|
||||
ACustomForm:=nil;
|
||||
@ -6863,7 +6885,7 @@ begin
|
||||
// ' Should=',LCLControl.HandleObjectShouldBeVisible);
|
||||
if LCLControl.HandleObjectShouldBeVisible then
|
||||
begin
|
||||
if (Sender is TCustomForm) then begin
|
||||
if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
|
||||
// update shared accelerators
|
||||
ShareWindowAccelGroups(SenderWidget);
|
||||
end;
|
||||
@ -6873,7 +6895,7 @@ begin
|
||||
|
||||
// before making the widget visible, set the position and size
|
||||
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)
|
||||
{$IFDEF VerboseFormPositioning}
|
||||
DebugLn('VFP [TGtkWidgetSet.ShowHide] A set bounds ',
|
||||
@ -6901,7 +6923,7 @@ begin
|
||||
UnsetResizeRequest(SenderWidget);
|
||||
end;
|
||||
|
||||
if (ACustomForm<>nil) then begin
|
||||
if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
|
||||
If (ACustomForm.BorderStyle <> bsSizeable) or
|
||||
((ACustomForm.FormStyle in fsAllStayOnTop)
|
||||
and (not (csDesigning in ACustomForm.ComponentState)))
|
||||
@ -6925,7 +6947,7 @@ begin
|
||||
|
||||
UpdateWidgetStyleOfControl(LCLControl);
|
||||
|
||||
if (ACustomForm<>nil) then begin
|
||||
if (ACustomForm<>nil) and (ACustomForm.Parent=nil) then begin
|
||||
AWindow:=GetControlWindow(SenderWidget);
|
||||
if (AWindow<>nil) and (ACustomForm.Icon<>nil) then begin
|
||||
FormIconGdiObject:=PGDIObject(ACustomForm.GetIconHandle);
|
||||
@ -9250,6 +9272,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
fixed deleting of collection item in prop editor
|
||||
|
||||
|
@ -4260,7 +4260,8 @@ begin
|
||||
if (TheForm=nil) or (not (TheForm is TCustomForm))
|
||||
or (not TheForm.Visible) or (TheForm.Parent<>nil)
|
||||
or (csDesigning in TheForm.ComponentState)
|
||||
then exit;
|
||||
then
|
||||
exit;
|
||||
|
||||
// check if modal form
|
||||
if fsModal in TheForm.FormState then begin
|
||||
@ -7129,6 +7130,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
gtk intf now ignores size notifications of unrealized widgets
|
||||
|
||||
|
@ -835,6 +835,7 @@ var
|
||||
procedure Set_RC_Name(Sender: TObject; AWidget: PGtkWidget);
|
||||
var RCName: string;
|
||||
AComponent: TComponent;
|
||||
ACustomForm: TCustomForm;
|
||||
begin
|
||||
{$IFDEF NoStyle}
|
||||
exit;
|
||||
@ -858,11 +859,14 @@ begin
|
||||
gtk_widget_set_name(AWidget,PChar(RCName));
|
||||
gtk_widget_set_rc_style(AWidget);
|
||||
end;
|
||||
if (Sender is TCustomForm)
|
||||
and ((Application.MainForm=TCustomForm(Sender))
|
||||
or (Application.MainForm=nil))
|
||||
then
|
||||
UpdateSysColorMap(AWidget);
|
||||
if (Sender is TCustomForm) then begin
|
||||
ACustomForm:=TCustomForm(Sender);
|
||||
if (ACustomForm.Parent=nil)
|
||||
and ((Application.MainForm=ACustomForm)
|
||||
or (Application.MainForm=nil))
|
||||
then
|
||||
UpdateSysColorMap(AWidget);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF UNIX}
|
||||
|
@ -206,11 +206,15 @@ begin
|
||||
GdkWindow:=GetControlWindow(PgtkWidget(hwnd));
|
||||
if GdkWindow<>nil then begin
|
||||
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);
|
||||
{$IFDEF DebugGDKTraps}
|
||||
BeginGDKErrorTrap;
|
||||
{$ENDIF}
|
||||
gdk_window_raise(GdkWindow);
|
||||
{$IFDEF DebugGDKTraps}
|
||||
EndGDKErrorTrap;
|
||||
{$ENDIF}
|
||||
// how to set the keyboard focus to the raised window?
|
||||
{$ifdef gtk2}
|
||||
gtk_window_present(PGtkWindow(hWnd));
|
||||
@ -8705,6 +8709,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
fixed DebugLn for VerboseRawImage
|
||||
|
||||
|
@ -776,8 +776,8 @@ end;
|
||||
|
||||
function DbgS(const r: TRect): string;
|
||||
begin
|
||||
Result:=' l='+IntToStr(r.Left)+',t='+IntToStr(r.Top)
|
||||
+',r='+IntToStr(r.Right)+',b='+IntToStr(r.Bottom);
|
||||
Result:=' x1='+IntToStr(r.Left)+',y1='+IntToStr(r.Top)
|
||||
+',x2='+IntToStr(r.Right)+',y2='+IntToStr(r.Bottom);
|
||||
end;
|
||||
|
||||
function DbgS(const p: TPoint): string;
|
||||
|
Loading…
Reference in New Issue
Block a user