mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 01:39:53 +02:00
AJ: More changes for better code reuse between gnome & gtk interfaces
git-svn-id: trunk@1345 -
This commit is contained in:
parent
cce47eb0b1
commit
d3e86ec1ca
@ -195,96 +195,100 @@ end;
|
|||||||
|
|
||||||
procedure TGnomeObject.CreateComponent(Sender : TObject);
|
procedure TGnomeObject.CreateComponent(Sender : TObject);
|
||||||
var
|
var
|
||||||
|
Caption : AnsiString;
|
||||||
StrTemp : PChar; // same as "caption" but as PChar
|
StrTemp : PChar; // same as "caption" but as PChar
|
||||||
TempWidget,
|
TempWidget,
|
||||||
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
||||||
p : pointer; // ptr to the newly created GtkWidget
|
p : pointer; // ptr to the newly created GtkWidget
|
||||||
Box : Pointer; // currently only used for TBitBtn and TForm and TListView
|
Box : Pointer; // currently only used for TBitBtn and TForm and TListView
|
||||||
ParentForm: TCustomForm;
|
ParentForm: TCustomForm;
|
||||||
|
CompStyle : Longint;
|
||||||
|
DoFinishComp,
|
||||||
|
SetupProps : Boolean;
|
||||||
begin
|
begin
|
||||||
if (Sender is TCustomForm) and (TControl(Sender).FCompStyle = csForm) then begin
|
P := nil;
|
||||||
With (Sender as TCustomForm) do begin
|
DoFinishComp := True;
|
||||||
If Caption > '' then begin
|
SetupProps := False;
|
||||||
strTemp := StrAlloc(length(Caption) + 1);
|
|
||||||
StrPCopy(strTemp, Caption);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
strTemp := nil;
|
|
||||||
|
|
||||||
P := GNOME_APP_NEW(Argv[0], strTemp);
|
CompStyle := GetCompStyle(Sender);
|
||||||
gnome_app_enable_layout_config(p, True);
|
Caption := GetCaption(Sender);
|
||||||
gtk_window_set_policy (GTK_WINDOW (p), FormResizableMap[BorderStyle],
|
strTemp := nil;
|
||||||
FormResizableMap[BorderStyle], 0);
|
|
||||||
|
|
||||||
// the clipboard needs a widget
|
Case CompStyle of
|
||||||
if ClipboardWidget=nil then
|
csForm:
|
||||||
SetClipboardWidget(p);
|
begin
|
||||||
|
Assert(Sender is TCustomForm);
|
||||||
|
With TCustomForm(Sender) do begin
|
||||||
|
If Caption > '' then begin
|
||||||
|
strTemp := StrAlloc(length(Caption) + 1);
|
||||||
|
StrPCopy(strTemp, 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);
|
||||||
|
|
||||||
Box := gtk_vbox_new(False, 0);
|
// the clipboard needs a widget
|
||||||
gnome_app_set_contents(p, Box);
|
if ClipboardWidget=nil then
|
||||||
gtk_widget_show(Box);
|
SetClipboardWidget(p);
|
||||||
|
|
||||||
// Create the form client area
|
Box := gtk_vbox_new(False, 0);
|
||||||
TempWidget := gtk_scrolled_window_new(nil,nil);
|
gnome_app_set_contents(p, Box);
|
||||||
gtk_box_pack_end(Box, TempWidget, True, True, 0);
|
gtk_widget_show(Box);
|
||||||
gtk_widget_show(TempWidget);
|
|
||||||
|
|
||||||
gtk_object_set_data(P,'scroll_area', TempWidget);
|
// Create the form client area
|
||||||
|
TempWidget := gtk_scrolled_window_new(nil,nil);
|
||||||
|
gtk_box_pack_end(Box, TempWidget, True, True, 0);
|
||||||
|
gtk_widget_show(TempWidget);
|
||||||
|
|
||||||
TempWidget2 := gtk_layout_new(nil, nil);
|
gtk_object_set_data(P,'scroll_area', TempWidget);
|
||||||
gtk_container_add(PGTKContainer(TempWidget), TempWidget2);
|
|
||||||
gtk_widget_show(TempWidget2);
|
|
||||||
SetFixedWidget(p, TempWidget2);
|
|
||||||
SetMainWidget(p, TempWidget2);
|
|
||||||
|
|
||||||
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(TempWidget)^.hscrollbar, GTK_CAN_FOCUS);
|
TempWidget2 := gtk_layout_new(nil, nil);
|
||||||
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(TempWidget)^.vscrollbar, GTK_CAN_FOCUS);
|
gtk_container_add(PGTKContainer(TempWidget), TempWidget2);
|
||||||
gtk_scrolled_window_set_policy(PGtkScrolledWindow(TempWidget),
|
gtk_widget_show(TempWidget2);
|
||||||
|
SetFixedWidget(p, TempWidget2);
|
||||||
|
SetMainWidget(p, TempWidget2);
|
||||||
|
|
||||||
|
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(TempWidget)^.hscrollbar, GTK_CAN_FOCUS);
|
||||||
|
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(TempWidget)^.vscrollbar, GTK_CAN_FOCUS);
|
||||||
|
gtk_scrolled_window_set_policy(PGtkScrolledWindow(TempWidget),
|
||||||
GTK_POLICY_NEVER,
|
GTK_POLICY_NEVER,
|
||||||
GTK_POLICY_NEVER);
|
GTK_POLICY_NEVER);
|
||||||
|
|
||||||
//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;
|
||||||
SetLCLObject(p, Sender);
|
end;
|
||||||
gtk_object_set_data(pgtkObject(p),'Style',0);
|
csMainMenu:
|
||||||
gtk_object_set_data(pgtkObject(p),'ExStyle',0);
|
begin
|
||||||
|
p := gtk_menu_bar_new();
|
||||||
Handle := THandle(p);
|
ParentForm:=TCustomForm(TMenu(Sender).Parent);
|
||||||
gtk_object_set_data(pgtkobject(p),'Sender',Sender);
|
if (ParentForm=nil) or (not (ParentForm is TCustomForm)) then
|
||||||
SetResizeRequest(p);
|
RaiseException('MainMenu without form');
|
||||||
|
if ParentForm.Menu<>TMenu(Sender) then
|
||||||
Set_RC_Name(sender, p);
|
RaiseException('form has already a MainMenu');
|
||||||
|
gtk_widget_show(p);
|
||||||
StrDispose(StrTemp);
|
gnome_app_set_menus(Pointer(ParentForm.Handle), p);
|
||||||
gtk_widget_set_app_paintable(p,true);
|
end;
|
||||||
HookSignals(Sender);
|
else
|
||||||
end;
|
begin
|
||||||
end
|
inherited CreateComponent(Sender);
|
||||||
else
|
DoFinishComp := False;
|
||||||
If (Sender is TMenu) and (TMenu(Sender).FCompStyle = csMainMenu) then
|
end;
|
||||||
begin
|
|
||||||
p := gtk_menu_bar_new();
|
|
||||||
ParentForm:=TCustomForm(TMenu(Sender).Parent);
|
|
||||||
if (ParentForm=nil) or (not (ParentForm is TCustomForm)) then
|
|
||||||
RaiseException('MainMenu without form');
|
|
||||||
if ParentForm.Menu<>TMenu(Sender) then
|
|
||||||
RaiseException('form has already a MainMenu');
|
|
||||||
gtk_widget_show(p);
|
|
||||||
gnome_app_set_menus(Pointer(ParentForm.Handle), p);
|
|
||||||
TMenu(Sender).Items.Handle := HMenu(p);
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
inherited CreateComponent(Sender);
|
|
||||||
If (Sender is TCustomEdit) then
|
|
||||||
With (Sender as TCustomEdit) do
|
|
||||||
If Popupmenu = nil then
|
|
||||||
If Pointer(Handle) <> nil then
|
|
||||||
gnome_widget_add_help(Pointer(Handle), nil)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
If (Sender is TCustomEdit) then
|
||||||
|
With (Sender as TCustomEdit) do
|
||||||
|
If Popupmenu = nil then
|
||||||
|
If Pointer(Handle) <> nil then
|
||||||
|
gnome_widget_add_help(Pointer(Handle), nil);
|
||||||
|
|
||||||
|
If DoFinishComp then
|
||||||
|
FinishComponentCreate(Sender, P, SetupProps);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$I gnomewinapi.inc}
|
{$I gnomewinapi.inc}
|
||||||
@ -293,6 +297,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.10 2002/10/24 22:10:39 lazarus
|
||||||
|
AJ: More changes for better code reuse between gnome & gtk interfaces
|
||||||
|
|
||||||
Revision 1.9 2002/10/23 20:47:27 lazarus
|
Revision 1.9 2002/10/23 20:47:27 lazarus
|
||||||
AJ: Started Form Scrolling
|
AJ: Started Form Scrolling
|
||||||
Started StaticText FocusControl
|
Started StaticText FocusControl
|
||||||
|
Loading…
Reference in New Issue
Block a user