mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 10:19:22 +02:00
some fixes toward gtk2
git-svn-id: trunk@2621 -
This commit is contained in:
parent
533191f591
commit
fcb3d8a490
@ -1708,8 +1708,15 @@ end;
|
|||||||
|
|
||||||
function GtkWindowIsModal(GtkWindow: PGtkWindow): boolean;
|
function GtkWindowIsModal(GtkWindow: PGtkWindow): boolean;
|
||||||
begin
|
begin
|
||||||
writeln('GtkWindowIsModal This test is buggy');
|
writeln('GtkWindowIsModal This test is buggy');
|
||||||
Result:=(GtkWindow^.flag0 and bm_modal)<>0;
|
Result := False;
|
||||||
|
{$IfDef GTK2}
|
||||||
|
if assigned(GtkWindow) then
|
||||||
|
result := gtk_window_get_modal(GtkWindow);
|
||||||
|
{$else}
|
||||||
|
if assigned(GtkWindow) then
|
||||||
|
Result:=(GtkWindow^.flag0 and bm_modal)<>0;
|
||||||
|
{$EndIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
@ -1923,7 +1930,10 @@ procedure ConnectInternalWidgetsSignals(AWidget: PGtkWidget;
|
|||||||
//if AWinControl is TListView then writeln('ConnectChilds B ');
|
//if AWinControl is TListView then writeln('ConnectChilds B ');
|
||||||
// this is a container widget -> connect all childs
|
// this is a container widget -> connect all childs
|
||||||
ContainerWidget:=PGtkContainer(TheWidget);
|
ContainerWidget:=PGtkContainer(TheWidget);
|
||||||
|
{$IfDef GTK2}
|
||||||
|
{$else}
|
||||||
ChildEntry:=ContainerWidget^.resize_widgets;
|
ChildEntry:=ContainerWidget^.resize_widgets;
|
||||||
|
{$endif}
|
||||||
while ChildEntry<>nil do begin
|
while ChildEntry<>nil do begin
|
||||||
ChildWidget:=PGtkWidget(ChildEntry^.Data);
|
ChildWidget:=PGtkWidget(ChildEntry^.Data);
|
||||||
ConnectSignals(ChildWidget);
|
ConnectSignals(ChildWidget);
|
||||||
@ -2025,7 +2035,10 @@ begin
|
|||||||
if GtkWidgetIsA(Widget,GTK_TYPE_MENU) then
|
if GtkWidgetIsA(Widget,GTK_TYPE_MENU) then
|
||||||
gtk_menu_set_accel_group(PGtkMenu(Widget), AnAccelGroup)
|
gtk_menu_set_accel_group(PGtkMenu(Widget), AnAccelGroup)
|
||||||
else begin
|
else begin
|
||||||
|
{$IfDef GTK2}
|
||||||
|
{$else}
|
||||||
gtk_accel_group_attach(AnAccelGroup, PGtkObject(Widget));
|
gtk_accel_group_attach(AnAccelGroup, PGtkObject(Widget));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2048,12 +2061,15 @@ procedure ShareWindowAccelGroups(AWindow: PGtkWidget);
|
|||||||
|
|
||||||
procedure AttachUnique(TheWindow: PGtkWidget; TheAccelGroup: PGTKAccelGroup);
|
procedure AttachUnique(TheWindow: PGtkWidget; TheAccelGroup: PGTKAccelGroup);
|
||||||
begin
|
begin
|
||||||
|
{$IfDef GTK2}
|
||||||
|
{$else}
|
||||||
if (TheAccelGroup=nil)
|
if (TheAccelGroup=nil)
|
||||||
or ((TheAccelGroup^.attach_objects<>nil)
|
or ((TheAccelGroup^.attach_objects<>nil)
|
||||||
and (g_slist_find(TheAccelGroup^.attach_objects, TheWindow)<>nil))
|
and (g_slist_find(TheAccelGroup^.attach_objects, TheWindow)<>nil))
|
||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
gtk_accel_group_attach(TheAccelGroup, PGtkObject(TheWindow));
|
gtk_accel_group_attach(TheAccelGroup, PGtkObject(TheWindow));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -2108,11 +2124,14 @@ procedure UnshareWindowAccelGroups(AWindow: PGtkWidget);
|
|||||||
|
|
||||||
procedure Detach(TheWindow: PGtkWidget; TheAccelGroup: PGTKAccelGroup);
|
procedure Detach(TheWindow: PGtkWidget; TheAccelGroup: PGTKAccelGroup);
|
||||||
begin
|
begin
|
||||||
|
{$IfDef GTK2}
|
||||||
|
{$else}
|
||||||
if (TheAccelGroup=nil)
|
if (TheAccelGroup=nil)
|
||||||
or (TheAccelGroup^.attach_objects=nil)
|
or (TheAccelGroup^.attach_objects=nil)
|
||||||
or (g_slist_find(TheAccelGroup^.attach_objects, TheWindow)=nil) then
|
or (g_slist_find(TheAccelGroup^.attach_objects, TheWindow)=nil) then
|
||||||
exit;
|
exit;
|
||||||
gtk_accel_group_detach(TheAccelGroup, PGtkObject(TheWindow));
|
gtk_accel_group_detach(TheAccelGroup, PGtkObject(TheWindow));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -2191,6 +2210,11 @@ begin
|
|||||||
Result := PAcceleratorKey(gtk_object_get_data(PGtkObject(Widget),'AccelKey'));
|
Result := PAcceleratorKey(gtk_object_get_data(PGtkObject(Widget),'AccelKey'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$Ifdef GTK2}
|
||||||
|
const
|
||||||
|
GDK_VOIDSYMBOL = $FFFFFF;
|
||||||
|
{$EndIf}
|
||||||
|
|
||||||
function SetAccelKey(const Widget: PGtkWidget;
|
function SetAccelKey(const Widget: PGtkWidget;
|
||||||
Key: guint; Mods: TGdkModifierType; const Signal: string): PAcceleratorKey;
|
Key: guint; Mods: TGdkModifierType; const Signal: string): PAcceleratorKey;
|
||||||
begin
|
begin
|
||||||
@ -2278,7 +2302,10 @@ begin
|
|||||||
' Key=',AccelKey^.Key,' Mods=',AccelKey^.Mods,
|
' Key=',AccelKey^.Key,' Mods=',AccelKey^.Mods,
|
||||||
'');
|
'');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$Ifdef GTK2}
|
||||||
|
{$else}
|
||||||
gtk_widget_remove_accelerators(Widget, PChar(AccelKey^.Signal), false);
|
gtk_widget_remove_accelerators(Widget, PChar(AccelKey^.Signal), false);
|
||||||
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
AccelKey^.Realized:=false;
|
AccelKey^.Realized:=false;
|
||||||
end;
|
end;
|
||||||
@ -2390,7 +2417,11 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function MENU_ITEM_CLASS(widget: PGtkWidget): PGtkMenuItemClass;
|
function MENU_ITEM_CLASS(widget: PGtkWidget): PGtkMenuItemClass;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef GTK2}
|
||||||
|
Result:=GTK_MENU_ITEM_CLASS(gtk_object_get_class(widget));
|
||||||
|
{$else}
|
||||||
Result:=GTK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass);
|
Result:=GTK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -2400,7 +2431,11 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function CHECK_MENU_ITEM_CLASS(widget: PGtkWidget): PGtkCheckMenuItemClass;
|
function CHECK_MENU_ITEM_CLASS(widget: PGtkWidget): PGtkCheckMenuItemClass;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef GTK2}
|
||||||
|
Result:=GTK_CHECK_MENU_ITEM_CLASS(gtk_object_get_class(widget));
|
||||||
|
{$else}
|
||||||
Result:=GTK_CHECK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass);
|
Result:=GTK_CHECK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -2423,10 +2458,10 @@ begin
|
|||||||
and (ParentMenuItem[i]<>LCLMenuItem)
|
and (ParentMenuItem[i]<>LCLMenuItem)
|
||||||
and ParentMenuItem[i].HandleAllocated
|
and ParentMenuItem[i].HandleAllocated
|
||||||
and GtkWidgetIsA(Pointer(ParentMenuItem[i].Handle),
|
and GtkWidgetIsA(Pointer(ParentMenuItem[i].Handle),
|
||||||
GTK_RADIO_MENU_ITEM_TYPE) then
|
GTK_TYPE_RADIO_MENU_ITEM) then
|
||||||
begin
|
begin
|
||||||
Result:=gtk_radio_menu_item_group(
|
Result:=gtk_radio_menu_item_group(
|
||||||
GTK_RADIO_MENU_ITEM(ParentMenuItem[i].Handle));
|
GTK_RADIO_MENU_ITEM(Pointer(ParentMenuItem[i].Handle)));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2570,8 +2605,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
ListItem:=ListItem^.Next;
|
ListItem:=ListItem^.Next;
|
||||||
end;
|
end;
|
||||||
|
{$Ifdef GTK2}
|
||||||
|
{$else}
|
||||||
if CheckMenuItem<>nil then
|
if CheckMenuItem<>nil then
|
||||||
MENU_ITEM_CLASS(PGtkWidget(CheckMenuItem))^.toggle_size:=MaxToggleSize;
|
MENU_ITEM_CLASS(PGtkWidget(CheckMenuItem))^.toggle_size:=MaxToggleSize;
|
||||||
|
{$EndIf}
|
||||||
OldMenuSizeRequestProc(Widget,requisition);
|
OldMenuSizeRequestProc(Widget,requisition);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2604,7 +2642,7 @@ var
|
|||||||
if ShortCutPos <> 0 then begin
|
if ShortCutPos <> 0 then begin
|
||||||
if (LCLMenuItem.Parent<>nil)
|
if (LCLMenuItem.Parent<>nil)
|
||||||
and (LCLMenuItem.Parent.HandleAllocated)
|
and (LCLMenuItem.Parent.HandleAllocated)
|
||||||
and GtkWidgetIsA(PGtkWidget(LCLMenuItem.Parent.Handle),GTK_MENU_BAR_TYPE)
|
and GtkWidgetIsA(PGtkWidget(LCLMenuItem.Parent.Handle),GTK_TYPE_MENU_BAR)
|
||||||
then begin
|
then begin
|
||||||
// this is a menu item in the main bar of a form
|
// this is a menu item in the main bar of a form
|
||||||
// -> accelerator should be Alt+Key
|
// -> accelerator should be Alt+Key
|
||||||
@ -2722,15 +2760,18 @@ begin
|
|||||||
MenuItemWidget:=gtk_check_menu_item_new;
|
MenuItemWidget:=gtk_check_menu_item_new;
|
||||||
end else
|
end else
|
||||||
MenuItemWidget:=gtk_menu_item_new;
|
MenuItemWidget:=gtk_menu_item_new;
|
||||||
if GtkWidgetIsA(MenuItemWidget,GTK_CHECK_MENU_ITEM_TYPE) then begin
|
if GtkWidgetIsA(MenuItemWidget,GTK_TYPE_CHECK_MENU_ITEM) then begin
|
||||||
// set 'ShowAlwaysCheckable'
|
// set 'ShowAlwaysCheckable'
|
||||||
gtk_check_menu_item_set_show_toggle(PGtkCheckMenuItem(MenuItemWidget),
|
gtk_check_menu_item_set_show_toggle(PGtkCheckMenuItem(MenuItemWidget),
|
||||||
LCLMenuItem.ShowAlwaysCheckable);
|
LCLMenuItem.ShowAlwaysCheckable);
|
||||||
// set 'Checked'
|
// set 'Checked'
|
||||||
gtk_check_menu_item_set_active(PGtkCheckMenuItem(MenuItemWidget),
|
gtk_check_menu_item_set_active(PGtkCheckMenuItem(MenuItemWidget),
|
||||||
LCLMenuItem.Checked);
|
LCLMenuItem.Checked);
|
||||||
|
{$ifdef GTK2}
|
||||||
|
{$else}
|
||||||
if (OldCheckMenuItemToggleSize=0) then
|
if (OldCheckMenuItemToggleSize=0) then
|
||||||
OldCheckMenuItemToggleSize:=MENU_ITEM_CLASS(MenuItemWidget)^.toggle_size;
|
OldCheckMenuItemToggleSize:=MENU_ITEM_CLASS(MenuItemWidget)^.toggle_size;
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// set attributes (enabled and rightjustify)
|
// set attributes (enabled and rightjustify)
|
||||||
@ -3138,14 +3179,23 @@ var
|
|||||||
StartTime, CurTime: TSystemTime;
|
StartTime, CurTime: TSystemTime;
|
||||||
Timer: cardinal;
|
Timer: cardinal;
|
||||||
|
|
||||||
|
function ValidDateSelection : boolean;
|
||||||
|
begin
|
||||||
|
{$ifdef GTK2}
|
||||||
|
result := c^.Data.Selection<>NIL;
|
||||||
|
{$else}
|
||||||
|
result := c^.Data.Selection<>0;
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
{$IFDEF DEBUG_CLIPBOARD}
|
{$IFDEF DEBUG_CLIPBOARD}
|
||||||
writeln('[TgtkObject.WaitForClipboardAnswer] A');
|
writeln('[TgtkObject.WaitForClipboardAnswer] A');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (c^.Data.Selection<>0) or (c^.Waiting) or (c^.Stopping) then begin
|
if (ValidDateSelection) or (c^.Waiting) or (c^.Stopping) then begin
|
||||||
//writeln('[TgtkObject.WaitForClipboardAnswer] B');
|
//writeln('[TgtkObject.WaitForClipboardAnswer] B');
|
||||||
Result:=(c^.Data.Selection<>0);
|
Result:=(ValidDateSelection);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
c^.Waiting:=true;
|
c^.Waiting:=true;
|
||||||
@ -3153,9 +3203,9 @@ begin
|
|||||||
//writeln('[TgtkObject.WaitForClipboardAnswer] C');
|
//writeln('[TgtkObject.WaitForClipboardAnswer] C');
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
//writeln('[TgtkObject.WaitForClipboardAnswer] D');
|
//writeln('[TgtkObject.WaitForClipboardAnswer] D');
|
||||||
if (c^.Data.Selection<>0) or (c^.Stopping) then begin
|
if (ValidDateSelection) or (c^.Stopping) then begin
|
||||||
//writeln('[TgtkObject.WaitForClipboardAnswer] E Yeah, Response received');
|
//writeln('[TgtkObject.WaitForClipboardAnswer] E Yeah, Response received');
|
||||||
Result:=(c^.Data.Selection<>0);
|
Result:=(ValidDateSelection);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
//writeln('[TgtkObject.WaitForClipboardAnswer] F');
|
//writeln('[TgtkObject.WaitForClipboardAnswer] F');
|
||||||
@ -3168,11 +3218,11 @@ begin
|
|||||||
writeln('[TgtkObject.WaitForClipboardAnswer] G');
|
writeln('[TgtkObject.WaitForClipboardAnswer] G');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Application.HandleMessage;
|
Application.HandleMessage;
|
||||||
if (c^.Data.Selection<>0) or (c^.Stopping) then begin
|
if (ValidDateSelection) or (c^.Stopping) then begin
|
||||||
{$IFDEF DEBUG_CLIPBOARD}
|
{$IFDEF DEBUG_CLIPBOARD}
|
||||||
writeln('[TgtkObject.WaitForClipboardAnswer] E Yeah, Response received');
|
writeln('[TgtkObject.WaitForClipboardAnswer] E Yeah, Response received');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=(c^.Data.Selection<>0);
|
Result:=(ValidDateSelection);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
DateTimeToSystemTime(Time,CurTime);
|
DateTimeToSystemTime(Time,CurTime);
|
||||||
@ -4102,6 +4152,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.181 2003/06/13 14:26:17 ajgenius
|
||||||
|
some fixes toward gtk2
|
||||||
|
|
||||||
Revision 1.180 2003/06/13 10:09:04 mattias
|
Revision 1.180 2003/06/13 10:09:04 mattias
|
||||||
fixed Set/GetPixel
|
fixed Set/GetPixel
|
||||||
|
|
||||||
|
@ -55,6 +55,10 @@ uses
|
|||||||
function GTK_TYPE_COMBO : TGTKType; cdecl; external gtkdll name 'gtk_combo_get_type';
|
function GTK_TYPE_COMBO : TGTKType; cdecl; external gtkdll name 'gtk_combo_get_type';
|
||||||
function GTK_TYPE_WINDOW : TGTKType; cdecl; external gtkdll name 'gtk_window_get_type';
|
function GTK_TYPE_WINDOW : TGTKType; cdecl; external gtkdll name 'gtk_window_get_type';
|
||||||
function GTK_TYPE_MENU : TGTKType; cdecl; external gtkdll name 'gtk_menu_get_type';
|
function GTK_TYPE_MENU : TGTKType; cdecl; external gtkdll name 'gtk_menu_get_type';
|
||||||
|
function GTK_TYPE_MENU_ITEM : TGTKType; cdecl; external gtkdll name 'gtk_menu_item_get_type';
|
||||||
|
function GTK_TYPE_MENU_BAR : TGTKType; cdecl; external gtkdll name 'gtk_menu_bar_get_type';
|
||||||
|
function GTK_TYPE_RADIO_MENU_ITEM : TGTKType; cdecl; external gtkdll name 'gtk_radio_menu_item_get_type';
|
||||||
|
function GTK_TYPE_CHECK_MENU_ITEM : TGTKType; cdecl; external gtkdll name 'gtk_check_menu_item_get_type';
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
procedure laz_gdk_gc_set_dashes(gc:PGdkGC; dash_offset:gint;
|
procedure laz_gdk_gc_set_dashes(gc:PGdkGC; dash_offset:gint;
|
||||||
|
Loading…
Reference in New Issue
Block a user