From 066215c115068c56de4cffe7c7257c38080f878a Mon Sep 17 00:00:00 2001 From: ajgenius Date: Sat, 6 Sep 2003 20:23:53 +0000 Subject: [PATCH] fixes for gtk2 added more wrappers for gtk1/gtk2 converstion and sanity removed pointless version $Ifdef GTK2 etc IDE now "runs" Tcontrol drawing/using problems renders it unuseable however git-svn-id: trunk@4578 - --- lcl/interfaces/gtk/gtkdef.pp | 13 ++- lcl/interfaces/gtk/gtkobject.inc | 53 ++++------ lcl/interfaces/gtk/gtkproc.inc | 171 ++++++++++++++++--------------- lcl/interfaces/gtk/gtkproc.pp | 25 ++++- lcl/interfaces/gtk/gtkwinapi.inc | 16 ++- lcl/interfaces/gtk2/gtk2int.pas | 79 +++++++++----- 6 files changed, 206 insertions(+), 151 deletions(-) diff --git a/lcl/interfaces/gtk/gtkdef.pp b/lcl/interfaces/gtk/gtkdef.pp index d875d90169..693d0ad102 100644 --- a/lcl/interfaces/gtk/gtkdef.pp +++ b/lcl/interfaces/gtk/gtkdef.pp @@ -92,9 +92,13 @@ type GDIBrushPixMap: PGdkPixmap; ); gdiFont: ( + {$Ifdef USE_PANGO} // we should implement pango for gtk2 soon + GDIFontObject: PPangoFont; + {$else} GDIFontObject: PGdkFont; LogFont: TLogFont;// for now font info is stored as well, later query font params - ); + {$EndIf} + ); gdiPen: ( IsNullPen : Boolean;//GDK will bomb with a NULL Pen Hatch GDIPenColor: TGDIColor; @@ -456,6 +460,13 @@ end. { ============================================================================= $Log$ + Revision 1.43 2003/09/06 20:23:53 ajgenius + fixes for gtk2 + added more wrappers for gtk1/gtk2 converstion and sanity + removed pointless version $Ifdef GTK2 etc + IDE now "runs" Tcontrol drawing/using problems + renders it unuseable however + Revision 1.42 2003/08/29 21:21:07 mattias fixes for gtk2 diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index 009a84d8bc..9c48675239 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -511,8 +511,7 @@ begin if (List^.Data <> nil) then begin gdk_window_get_user_data(PGDKWindow(List^.Data), @Window); - if GtkWidgetIsA(PGtkWidget(Window), - {$IFDEF Gtk2}GTK_TYPE_WINDOW{$ELSE}GTK_WINDOW_TYPE{$ENDIF}) + if GtkWidgetIsA(PGtkWidget(Window), GTK_TYPE_WINDOW) then begin // visible window found -> add to list New(ATransientWindow); @@ -1067,13 +1066,11 @@ begin end; {$ENDIF} - if GtkWidgetIsA(Widget, - {$IFDEF Gtk2}GTK_TYPE_SCROLLBAR{$ELSE}GTK_SCROLLBAR_TYPE{$ENDIF}) then + if GtkWidgetIsA(Widget,GTK_TYPE_SCROLLBAR) then begin // the width of a scrollbar is fixed and depends only on the theme gtk_widget_size_request (widget, @Requisition); - if GtkWidgetIsA(Widget, - {$IFDEF Gtk2}GTK_TYPE_HSCROLLBAR{$ELSE}GTK_HSCROLLBAR_TYPE{$ENDIF}) then + if GtkWidgetIsA(Widget, GTK_TYPE_HSCROLLBAR) then begin NewHeight:=Requisition.height; end else begin @@ -1084,8 +1081,7 @@ begin gtk_widget_set_usize(Widget, NewWidth, NewHeight); - if GtkWidgetIsA(Widget, - {$IFDEF Gtk2}GTK_TYPE_COMBO{$ELSE}GTK_COMBO_TYPE{$ENDIF}) then + if GtkWidgetIsA(Widget, GTK_TYPE_COMBO) then begin // the combobox has an entry, which height is not resized // automatically. Do it manually. @@ -1144,8 +1140,7 @@ var // check if window belongs to another LCL control gdk_window_get_user_data(PaintWindow,@UserData); if (UserData<>nil) - and (GtkWidgetIsA(PGtkWidget(UserData), - {$IFDEF Gtk2}GTK_TYPE_WIDGET{$ELSE}GTK_WIDGET_TYPE{$ENDIF})) + and (GtkWidgetIsA(PGtkWidget(UserData), GTK_TYPE_WIDGET)) then begin LCLObject:=GetLCLObject(UserData); if (LCLObject<>nil) and (LCLObject<>AWinControl) then exit; @@ -1199,8 +1194,7 @@ var SendPaintMessageForGDkWindow(GetControlWindow(PaintWidget)); // search all child widgets - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_CONTAINER{$ELSE}GTK_CONTAINER_TYPE{$ENDIF}) then + if GtkWidgetIsA(PaintWidget, GTK_TYPE_CONTAINER) then begin // this is a container widget -> go through all childs {$IFDEF Gtk2} @@ -1219,24 +1213,20 @@ var end; {$ENDIF} end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_SCROLLED_WINDOW{$ELSE}GTK_SCROLLED_WINDOW_TYPE{$ENDIF}) + if GtkWidgetIsA(PaintWidget, GTK_TYPE_SCROLLED_WINDOW) then begin ForAllChilds(PGtkScrolledWindow(PaintWidget)^.hscrollbar); ForAllChilds(PGtkScrolledWindow(PaintWidget)^.vscrollbar); end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_BIN{$ELSE}GTK_BIN_TYPE{$ENDIF}) then + if GtkWidgetIsA(PaintWidget, GTK_TYPE_BIN) then begin ForAllChilds(PGtkBin(PaintWidget)^.child); end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_COMBO{$ELSE}GTK_COMBO_TYPE{$ENDIF}) then begin + if GtkWidgetIsA(PaintWidget, GTK_TYPE_COMBO) then begin ForAllChilds(PGtkCombo(PaintWidget)^.entry); ForAllChilds(PGtkCombo(PaintWidget)^.button); end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_RANGE{$ELSE}GTK_RANGE_TYPE{$ENDIF}) + if GtkWidgetIsA(PaintWidget, GTK_TYPE_RANGE) then begin {$IFDEF Gtk2} // Gtk2ToDo @@ -1248,13 +1238,11 @@ var SendPaintMessageForGDkWindow(PGtkRange(PaintWidget)^.step_back); {$ENDIF} end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_TEXT{$ELSE}GTK_TEXT_TYPE{$ENDIF}) then + if GtkWidgetIsA(PaintWidget, GTK_TYPE_TEXT) then begin SendPaintMessageForGDkWindow(PGtkText(PaintWidget)^.text_area); end; - if GtkWidgetIsA(PaintWidget, - {$IFDEF Gtk2}GTK_TYPE_ENTRY{$ELSE}GTK_ENTRY_TYPE{$ENDIF}) then + if GtkWidgetIsA(PaintWidget, GTK_TYPE_ENTRY) then begin SendPaintMessageForGDkWindow(PGtkEntry(PaintWidget)^.text_area); end; @@ -6524,11 +6512,7 @@ begin if fWindow<>nil then begin gdk_draw_pixmap(fwindow, - {$IfDef GTK2} - PGtkStyle(widget^.Style)^.fg_gc[GTK_WIDGET_STATE (widget)], - {$Else} - PGtkStyle(widget^.TheStyle)^.fg_gc[GTK_WIDGET_STATE (widget)], - {$EndIf} + gtk_widget_get_style(widget)^.fg_gc[GTK_WIDGET_STATE (widget)], pixmap, 0,0, 0,0, @@ -7181,7 +7165,7 @@ var var MenuClass: PGtkWidgetClass; begin if GtkWidgetIsA(ContainerMenu,GTK_TYPE_MENU) then begin - MenuClass:=GTK_WIDGET_CLASS(PGtkTypeObject(ContainerMenu)^.{$IfDef GTK2}g_Class{$Else}klass{$EndIf}); + MenuClass:=GTK_WIDGET_CLASS(gtk_object_get_class(ContainerMenu)); if OldMenuSizeRequestProc=nil then begin OldMenuSizeRequestProc:=MenuClass^.size_request; end; @@ -7683,7 +7667,7 @@ var GDIObject: PGDIObject; begin GDIObject := NewGDIObject(gdiRegion); - GDIObject^.GDIRegionObject:=CopyGDKRegion(PGdiObject(SrcRGN)^.GDIRegionObject); + GDIObject^.GDIRegionObject:=gdk_region_copy(PGdiObject(SrcRGN)^.GDIRegionObject); Result := hRgn(GDIObject); end; @@ -8164,6 +8148,13 @@ end; { ============================================================================= $Log$ + Revision 1.409 2003/09/06 20:23:53 ajgenius + fixes for gtk2 + added more wrappers for gtk1/gtk2 converstion and sanity + removed pointless version $Ifdef GTK2 etc + IDE now "runs" Tcontrol drawing/using problems + renders it unuseable however + Revision 1.408 2003/09/06 17:24:52 ajgenius gtk2 changes for pixmap, getcursorpos, mouse events workaround diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 45d39805db..c3ead64043 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -65,6 +65,29 @@ begin end; {$Ifdef GTK1} +function gtk_class_get_type(aclass : Pointer) : TGtkType; +begin + If (aclass <> nil) then + result := PGtkTypeClass(aclass)^.thetype + else + result := 0; +end; + +function gtk_object_get_class(anobject : Pointer) : Pointer; +begin + If (anobject <> nil) then + result := PGtkTypeObject(anobject)^.klass + else + result := nil; +end; + +function gtk_window_get_modal(window:PGtkWindow):gboolean; +begin + if assigned(Window) then + result := (Window^.flag0 and bm_modal)<>0 + else + result := False; +end; function gtk_bin_get_child(bin : PGTKBin) : PGTKWidget; begin @@ -74,11 +97,6 @@ begin result := nil; end; -function gtk_window_get_modal(window:PGtkWindow):gboolean; -begin - result := (Window^.flag0 and bm_modal)<>0; -end; - Procedure gtk_menu_item_set_right_justified(menu_item : PGtkMenuItem; right_justified : gboolean); begin if right_justified then @@ -107,6 +125,24 @@ begin result := gdk_regions_xor(source1, source2); end; +function gdk_region_copy(region: PGDKRegion): PGDKRegion; +var + EmptyRegion: PGdkRegion; +begin + EmptyRegion := gdk_region_new; + Result := gdk_regions_union(region, EmptyRegion); + gdk_region_destroy(EmptyRegion); +end; + +function gdk_region_rectangle(rect: PGdkRectangle): PGDKRegion; +var + EmptyRegion: PGdkRegion; +begin + EmptyRegion := gdk_region_new; + Result := gdk_region_union_with_rect(EmptyRegion,Rect); + gdk_region_destroy(EmptyRegion); +end; + Function gdk_drawable_get_depth(Drawable : PGDKDrawable) : gint; begin gdk_window_get_geometry(Drawable, nil, nil, nil, nil, @result); @@ -116,10 +152,33 @@ Procedure gdk_drawable_get_size(Drawable : PGDKDrawable; Width, Height : PGInt); begin gdk_window_get_geometry(Drawable, nil, nil, Width, Height, nil); end; - {$EndIf} {$Ifdef GTK2} +function gtk_class_get_type(aclass : Pointer) : TGtkType; +begin + If (aclass <> nil) then + result := PGtkTypeClass(aclass)^.g_Type + else + result := 0; +end; + +function gtk_object_get_class(anobject : Pointer) : Pointer; +begin + If (anobject <> nil) then + result := PGtkTypeObject(anobject)^.g_Class + else + result := nil; +end; + +function gtk_window_get_modal(window:PGtkWindow):gboolean; +begin + if assigned(Window) then + result := GTK2.gtk_window_get_modal(window) + else + result := False; +end; + Procedure gtk_signal_handlers_destroy(anObject : PGtkObject); begin g_signal_handlers_destroy(PGObject(anObject)); @@ -232,17 +291,9 @@ end; ------------------------------------------------------------------------------} function GtkWidgetIsA(Widget: PGtkWidget; AType: TGtkType): boolean; begin - {$IFDEF GTK2} Result:=(Widget<>nil) - and (PGtkTypeObject(Widget)^.g_class<>nil) - and gtk_type_is_a(PGtkTypeClass(PGtkTypeObject(Widget)^.g_class)^.g_type, - AType); - {$ELSE} - Result:=(Widget<>nil) - and (PGtkTypeObject(Widget)^.klass<>nil) - and gtk_type_is_a(PGtkTypeClass(PGtkTypeObject(Widget)^.klass)^.thetype, - AType); - {$ENDIF} + and (gtk_object_get_class(Widget)<>nil) + and gtk_type_is_a(gtk_class_get_type(gtk_object_get_class(Widget)), AType); end; {------------------------------------------------------------------------------ @@ -477,7 +528,6 @@ Function RegionType(RGN: PGDKRegion) : Longint; var aRect : TGDKRectangle; SimpleRGN: PGdkRegion; - EmptyRGN: PGdkRegion; begin If RGN = nil then Result := ERROR @@ -486,20 +536,12 @@ begin Result := NULLREGION else begin gdk_region_get_clipbox(RGN,@aRect); - EmptyRGN:=gdk_region_new; - {$IFDEF GTK2} - SimpleRGN:=EmptyRGN; - gdk_region_union_with_rect(SimpleRGN,@aRect); - {$ELSE} - SimpleRGN:=gdk_region_union_with_rect(EmptyRGN,@aRect); - {$ENDIF} + SimpleRGN := gdk_region_rectangle(@aRect); if gdk_region_equal(SimpleRGN, RGN) then Result := SIMPLEREGION else Result := COMPLEXREGION; - if SimpleRGN<>EmptyRGN then - gdk_region_destroy(SimpleRGN); - gdk_region_destroy(EmptyRGN); + gdk_region_destroy(SimpleRGN); end; end; @@ -528,21 +570,6 @@ begin end; end; -function CopyGDKRegion(RGN: PGDKRegion): PGDKRegion; -{$IFDEF GTK2} -begin - Result:=gdk_region_copy(RGN); -end; -{$ELSE} -var - EmptyRegion: PGdkRegion; -begin - EmptyRegion := gdk_region_new; - Result := gdk_regions_union(RGN, EmptyRegion); - gdk_region_destroy(EmptyRegion); -end; -{$ENDIF} - function GDKRegionAsString(RGN: PGDKRegion): string; var aRect: TGDKRectangle; @@ -556,22 +583,13 @@ end; function CreateRectGDKRegion(const ARect: TRect): PGDKRegion; var - {$IFNDEF Gtk2} - EmptyRegion: PGdkRegion; - {$ENDIF} GDkRect: TGDKRectangle; begin GDkRect.x:=ARect.Left; GDkRect.y:=ARect.Top; GDkRect.Width:=ARect.Right-ARect.Left; GDkRect.Height:=ARect.Bottom-ARect.Top; - {$IFDEF GTK2} Result:=gdk_region_rectangle(@GDKRect); - {$ELSE} - EmptyRegion := gdk_region_new; - Result := gdk_region_union_with_rect(EmptyRegion,@GDkRect); - gdk_region_destroy(EmptyRegion); - {$ENDIF} end; Procedure FreeGDIColor(GDIColor: PGDIColor); @@ -1980,19 +1998,6 @@ begin end; end; -function GtkWindowIsModal(GtkWindow: PGtkWindow): boolean; -begin - writeln('GtkWindowIsModal This test is buggy'); - 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; - {------------------------------------------------------------------------------- procedure ConnectSignal(const AnObject:PGTKObject; const ASignal: PChar; const ACallBackProc: Pointer; const ReqSignalMask: TGdkEventMask; @@ -2311,6 +2316,8 @@ begin gtk_menu_set_accel_group(PGtkMenu(Widget), AnAccelGroup) else begin {$IfDef GTK2} + // Gtk2ToDo + writeln('ToDo: gtkproc.inc SetAccelGroup'); {$else} gtk_accel_group_attach(AnAccelGroup, PGtkObject(Widget)); {$endif} @@ -2584,6 +2591,7 @@ begin ''); {$ENDIF} {$Ifdef GTK2} + writeln('ToDo: gtkproc.inc UnrealizeAccelerator'); {$else} gtk_widget_remove_accelerators(Widget, PChar(AccelKey^.Signal), false); {$EndIf} @@ -2698,11 +2706,7 @@ end; ------------------------------------------------------------------------------} function MENU_ITEM_CLASS(widget: PGtkWidget): PGtkMenuItemClass; begin - {$ifdef GTK2} Result:=GTK_MENU_ITEM_CLASS(gtk_object_get_class(widget)); - {$else} - Result:=GTK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass); - {$endif} end; {------------------------------------------------------------------------------ @@ -2712,11 +2716,7 @@ end; ------------------------------------------------------------------------------} function CHECK_MENU_ITEM_CLASS(widget: PGtkWidget): PGtkCheckMenuItemClass; begin - {$ifdef GTK2} Result:=GTK_CHECK_MENU_ITEM_CLASS(gtk_object_get_class(widget)); - {$else} - Result:=GTK_CHECK_MENU_ITEM_CLASS(PGtkObject(widget)^.klass); - {$endif} end; function MenuItemChecked(MenuWidget: PGtkCheckMenuItem): boolean; @@ -3783,10 +3783,10 @@ begin NoName:=nil; StyleObject^.Widget := // GTK2 does not allow to instantiate the abstract base Widget - // so we use the invisible HBOX, which is hopefully not defined in the - // theme + // so we use the "invisible" widget, which should never be defined + // by the theme GTK_WIDGET_NEW( - {$IFDEF Gtk2}GTK_TYPE_HBOX{$ELSE}GTK_WIDGET_TYPE{$ENDIF}, + {$IFDEF Gtk2}GTK_TYPE_INVISIBLE{$ELSE}GTK_WIDGET_TYPE{$ENDIF}, NoName,[]); end else @@ -4380,10 +4380,9 @@ end; ------------------------------------------------------------------------------} Function GDKPixel2GDIRGB(Pixel: Longint; Visual: PGDKVisual; Colormap: PGDKColormap) : TGDIRGB; -{$IFDEF Gtk2} -{$ELSE} var Color: TGDKColor; +{$IFDEF Gtk1} GdkColorContext: PGdkColorContext; {$ENDIF} begin @@ -4394,25 +4393,22 @@ begin Colormap := GDK_Colormap_Get_System; end; - {$IFDEF Gtk2} - // Gtk2ToDo - writeln('ToDo: GDKPixel2GDIRGB'); - if Pixel=0 then ; - FillChar(Result,SizeOf(Result),0); - {$ELSE} gdk_error_trap_push; + {$IFDEF Gtk2} + gdk_colormap_query_color(colormap, pixel, @color); + {$ELSE} Color.Pixel := Pixel; GdkColorContext := gdk_color_context_new(Visual,Colormap); gdk_color_context_query_color(GdkColorContext,@Color); gdk_color_context_free(GdkColorContext); + {$ENDIF} Result.Red := Color.Red shr 8; Result.Green := Color.Green shr 8; Result.Blue := Color.Blue shr 8; gdk_error_trap_pop; - {$ENDIF} end; {------------------------------------------------------------------------------ @@ -4534,6 +4530,13 @@ end; { ============================================================================= $Log$ + Revision 1.198 2003/09/06 20:23:53 ajgenius + fixes for gtk2 + added more wrappers for gtk1/gtk2 converstion and sanity + removed pointless version $Ifdef GTK2 etc + IDE now "runs" Tcontrol drawing/using problems + renders it unuseable however + Revision 1.197 2003/09/06 17:24:52 ajgenius gtk2 changes for pixmap, getcursorpos, mouse events workaround diff --git a/lcl/interfaces/gtk/gtkproc.pp b/lcl/interfaces/gtk/gtkproc.pp index 1d3c44dcec..f363b2019c 100644 --- a/lcl/interfaces/gtk/gtkproc.pp +++ b/lcl/interfaces/gtk/gtkproc.pp @@ -61,6 +61,12 @@ uses 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'; + function GTK_TYPE_TEXT : TGTKType; cdecl; external gtkdll name 'gtk_text_get_type'; + function GTK_TYPE_ENTRY : TGTKType; cdecl; external gtkdll name 'gtk_entry_get_type'; + function GTK_TYPE_RANGE : TGTKType; cdecl; external gtkdll name 'gtk_range_get_type'; + function GTK_TYPE_SCROLLBAR : TGTKType; cdecl; external gtkdll name 'gtk_scrollbar_get_type'; + function GTK_TYPE_HSCROLLBAR : TGTKType; cdecl; external gtkdll name 'gtk_hscrollbar_get_type'; + function GTK_TYPE_VSCROLLBAR : TGTKType; cdecl; external gtkdll name 'gtk_vscrollbar_get_type'; {$ENDIF} procedure laz_gdk_gc_set_dashes(gc:PGdkGC; dash_offset:gint; @@ -281,7 +287,6 @@ function CopyDCData(DestinationDC, SourceDC: TDeviceContext): Boolean; Function RegionType(RGN: PGDKRegion): Longint; Procedure SelectGDIRegion(const DC: HDC); -function CopyGDKRegion(RGN: PGDKRegion): PGDKRegion; function GDKRegionAsString(RGN: PGDKRegion): string; function CreateRectGDKRegion(const ARect: TRect): PGDKRegion; @@ -331,7 +336,6 @@ function TranslateGdkPointToClientArea(SourceWindow: PGdkWindow; procedure ReleaseMouseCapture(OnlyIfCapturedByLCL: boolean); procedure UpdateMouseCaptureControl; procedure SetCursor(AWinControl : TWinControl; Data: Pointer); -function GtkWindowIsModal(GtkWindow: PGtkWindow): boolean; type TConnectSignalFlag = ( @@ -477,6 +481,7 @@ Procedure FillScreenFonts(ScreenFonts : TStrings); function GetGDKMouseCursor(Cursor: TCursor): PGdkCursor; Procedure FreeGDKCursors; +// functions for easier GTK2<->GTK1 Compatibility/Consistancy ----> function gtk_widget_get_xthickness(Style : PGTKStyle) : gint; overload; function gtk_widget_get_ythickness(Style : PGTKStyle) : gint; overload; @@ -487,24 +492,36 @@ function gtk_widget_get_ythickness(Style : PGTKWidget) : gint; overload; type PGtkOldEditable = PGtkEditable; - Function gtk_bin_get_child(bin : PGTKBin) : PGTKWidget; + function gtk_class_get_type(aclass : Pointer) : TGtkType; + //routines to mimic similar GTK2 routines--> + function gtk_object_get_class(anobject : Pointer) : Pointer; Function gtk_window_get_modal(window:PGtkWindow):gboolean; - + Function gtk_bin_get_child(bin : PGTKBin) : PGTKWidget; Procedure gtk_menu_item_set_right_justified(menu_item : PGtkMenuItem; right_justified : gboolean); + //Wrapper around misnamed "regions" routines --> Function gdk_region_intersect(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; Function gdk_region_union(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; Function gdk_region_subtract(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; Function gdk_region_xor(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; + function gdk_region_copy(region: PGDKRegion): PGDKRegion; + function gdk_region_rectangle(rect: PGdkRectangle): PGDKRegion; + //Wrapper around window geometry like gtk2 --> Function gdk_drawable_get_depth(Drawable : PGDKDrawable) : gint; Procedure gdk_drawable_get_size(Drawable : PGDKDrawable; Width, Height : PGInt); {$EndIF} {$Ifdef GTK2} Procedure gtk_signal_handlers_destroy(anObject : PGtkObject); + function gtk_class_get_type(aclass : Pointer) : TGtkType; + //we wrap our own versions to handle nil tests --> + function gtk_object_get_class(anobject : Pointer) : Pointer; + Function gtk_window_get_modal(window:PGtkWindow):gboolean; + + //we wrap our own versions to do gtk1 style result = new region --> Function gdk_region_union_with_rect(region:PGdkRegion; rect:PGdkRectangle) : PGdkRegion; Function gdk_region_intersect(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; Function gdk_region_union(source1:PGdkRegion; source2:PGdkRegion) : PGdkRegion; diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index bff7e564a2..1e4ba6588b 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -1852,7 +1852,7 @@ begin RGN_AND : D := PGDKRegion(gdk_region_intersect(S1, S2)); RGN_COPY : - D := CopyGDKRegion(S1); + D := gdk_region_copy(S1); RGN_DIFF : D := PGDKRegion(gdk_region_subtract(S1, S2)); RGN_OR : @@ -1936,7 +1936,7 @@ function TgtkObject.ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean; if ((not show_hscroll) and (alloc_width < list_requisition^.width)) then begin work_height := work_height + popup^.hscrollbar^.requisition.height + - GTK_SCROLLED_WINDOW_CLASS(PGtkTypeObject(combo^.popup)^.{$IfDef GTK2}g_Class{$Else}klass{$EndIf})^.scrollbar_spacing; + GTK_SCROLLED_WINDOW_CLASS(gtk_object_get_class(combo^.popup))^.scrollbar_spacing; show_hscroll := TRUE; okay_to_exit := False; end; @@ -1949,7 +1949,7 @@ function TgtkObject.ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean; end; alloc_width := alloc_width - popup^.vscrollbar^.requisition.width + - GTK_SCROLLED_WINDOW_CLASS(PGtkTypeObject(combo^.popup)^.{$IfDef GTK2}g_Class{$Else}klass{$EndIf})^.scrollbar_spacing; + GTK_SCROLLED_WINDOW_CLASS(gtk_object_get_class(combo^.popup))^.scrollbar_spacing; show_vscroll := TRUE; okay_to_exit := False; end; @@ -3685,8 +3685,7 @@ begin else with TDeviceContext(DC) do begin // create a copy of the current clipregion - ClipRegionWithDCOffset:= - CopyGDKRegion(PGdiObject(ClipRegion)^.GDIRegionObject); + ClipRegionWithDCOffset:= gdk_region_copy(PGdiObject(ClipRegion)^.GDIRegionObject); // move it to the DC offset // Example: if the ClipRegion is at 10,10 and the DCOrigin is at 10,10, // then the ClipRegion must be moved to 0,0 @@ -8711,6 +8710,13 @@ end; { ============================================================================= $Log$ + Revision 1.275 2003/09/06 20:23:53 ajgenius + fixes for gtk2 + added more wrappers for gtk1/gtk2 converstion and sanity + removed pointless version $Ifdef GTK2 etc + IDE now "runs" Tcontrol drawing/using problems + renders it unuseable however + Revision 1.274 2003/09/06 17:24:52 ajgenius gtk2 changes for pixmap, getcursorpos, mouse events workaround diff --git a/lcl/interfaces/gtk2/gtk2int.pas b/lcl/interfaces/gtk2/gtk2int.pas index e21c213f58..e5cfecea03 100644 --- a/lcl/interfaces/gtk2/gtk2int.pas +++ b/lcl/interfaces/gtk2/gtk2int.pas @@ -33,9 +33,20 @@ interface uses Classes, SysUtils, {$IfNDef GTK2_2} - X, XLib, XUtil, + {$IfNDef Win32} + X, XLib, XUtil, + {$EndIf} {$EndIf} - gdk2pixbuf, gtk2, gdk2, glib2, gtkInt; + + gdk2pixbuf, gtk2, gdk2, glib2, + + LMessages, Controls, Forms, VclGlobals, LCLProc, + LCLStrConsts, LCLLinux, LCLType, DynHashArray, LazLinkedList, + GraphType, GraphMath, Graphics, Buttons, Menus, GTKWinApiWindow, StdCtrls, + ComCtrls, CListBox, KeyMap, Calendar, Arrow, Spin, CommCtrl, ExtCtrls, + Dialogs, ExtDlgs, FileCtrl, LResources, Math, GTKGlobals, + + gtkDef, gtkProc, gtkInt; type TGtk2Object = class(TGtkObject) @@ -48,8 +59,10 @@ type Procedure gdk_display_get_pointer(display : PGdkDisplay; screen :PGdkScreen; x :Pgint; y : Pgint; mask : PGdkModifierType); cdecl; external gdklib; function gdk_display_get_default:PGdkDisplay; cdecl; external gdklib; {$Else} -Function gdk_x11_drawable_get_xdisplay(drawable : PGdkDrawable) : PDisplay; cdecl; external gdklib; -Function gdk_x11_drawable_get_xid(drawable : PGdkDrawable) : Integer; cdecl; external gdklib; + {$IfNDef Win32} + Function gdk_x11_drawable_get_xdisplay(drawable : PGdkDrawable) : PDisplay; cdecl; external gdklib; + Function gdk_x11_drawable_get_xid(drawable : PGdkDrawable) : Integer; cdecl; external gdklib; + {$EndIf} {$EndIf} @@ -63,11 +76,13 @@ implementation ------------------------------------------------------------------------------} function Tgtk2Object.GetCursorPos(var lpPoint: TPoint ): Boolean; {$IfnDef GTK2_2} //we need a GTK2_2 FLAG somehow -var - root, child: pointer; - winx, winy: Integer; - xmask: Cardinal; - TopList, List: PGList; + {$IfNDef Win32} + var + root, child: pointer; + winx, winy: Integer; + xmask: Cardinal; + TopList, List: PGList; + {$EndIf} {$EndIf} begin Result := False; @@ -75,25 +90,30 @@ begin gdk_display_get_pointer(gdk_display_get_default(), nil, @lpPoint.X, @lpPoint.Y, nil); Result := True; {$Else} - TopList := gdk_window_get_toplevels; - List := TopList; - while List <> nil do - begin - if (List^.Data <> nil) - and gdk_window_is_visible(List^.Data) - then begin - XQueryPointer(gdk_x11_drawable_get_xdisplay (List^.Data), - gdk_x11_drawable_get_xid(List^.Data), - @root, @child, @lpPoint.X, @lpPoint.Y, @winx, @winy, @xmask); + {$IfNDef Win32} + TopList := gdk_window_get_toplevels; + List := TopList; + while List <> nil do + begin + if (List^.Data <> nil) + and gdk_window_is_visible(List^.Data) + then begin + XQueryPointer(gdk_x11_drawable_get_xdisplay (List^.Data), + gdk_x11_drawable_get_xid(List^.Data), + @root, @child, @lpPoint.X, @lpPoint.Y, @winx, @winy, @xmask); - Result := True; - Break; - end; - List := g_list_next(List); - end; + Result := True; + Break; + end; + List := g_list_next(List); + end; - if TopList <> nil - then g_list_free(TopList); + if TopList <> nil + then g_list_free(TopList); + {$Else} + // Win32 Todo + writeln('ToDo(Win32): Tgtk2object.GetCursorPos'); + {$EndIf} {$EndIf} end; @@ -101,6 +121,13 @@ end. { $Log$ + Revision 1.4 2003/09/06 20:23:53 ajgenius + fixes for gtk2 + added more wrappers for gtk1/gtk2 converstion and sanity + removed pointless version $Ifdef GTK2 etc + IDE now "runs" Tcontrol drawing/using problems + renders it unuseable however + Revision 1.3 2003/09/06 17:24:52 ajgenius gtk2 changes for pixmap, getcursorpos, mouse events workaround