1 {
2    GDK - The GIMP Drawing Kit
3 
4    Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
5 
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2 of the License, or (at your option) any later version.
10 
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, write to the
18    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19    MA 02110-1301, USA.
20 }
21 unit gdk2; // keep unit name lowercase for kylix
22 
23 {$IFDEF FPC}
24   {$mode objfpc}
25 {$ENDIF}
26 {$IFDEF VER140}
27   {$DEFINE KYLIX}
28 {$ENDIF}
29 
30 interface
31 
32 uses glib2, gdk2pixbuf, pango, cairo;
33 
34 const
35 // OS dependent defines
36 {$ifdef windows}
37   {$DEFINE GDK_WINDOWING_WIN32}
38   gdklib = 'libgdk-win32-2.0-0.dll';
39   {$IFDEF FPC}
40     {$ifndef NO_SMART_LINK}
41       {$smartlink on}
42     {$endif}
43   {$ENDIF}
44   GDK_HAVE_WCHAR_H=1;
45   GDK_HAVE_WCTYPE_H=1;
46 {$else}
47   {$ifdef darwin}
48     gdklib = 'gdk-x11-2.0';
49     {$linklib gtk-x11-2.0}
50     {$linklib gdk-x11-2.0}
51     {$linklib pango-1.0.0}
52     {$linklib glib-2.0.0}
53     {$linklib gobject-2.0.0}
54     {$linklib gdk_pixbuf-2.0.0}
55     {$linklib atk-1.0.0}
56   {$else}
57     {$ifdef UseCustomLibs}
58     gdklib = '';
59     {$else}
60     gdklib = 'libgdk-x11-2.0.so';
61     {$endif}
62   {$endif}
63 {$endif}
64 
65 {$IFNDEF KYLIX}
66   {$PACKRECORDS C}
67 {$ELSE}
68   {$ALIGN 4}
69   {$WEAKPACKAGEUNIT}
70   {$WARNINGS OFF}
71 {$ENDIF}
72 
73 
74 // the included header files:
75 {
76    number of points to buffer before sending them off
77    to scanlines() :  Must be an even number
78   }
79 const
80   NUMPTSTOBUFFER = 200;
81   GDK_MAX_TIMECOORD_AXES = 128;
82 
83 type
84   PGdkDeviceClass = ^TGdkDeviceClass;
85   TGdkDeviceClass = record
86       parent_class: TGObjectClass;
87     end;
88 
89   PGdkVisualClass = ^TGdkVisualClass;
90   TGdkVisualClass = record
91       parent_class: TGObjectClass;
92     end;
93 
94 {$DEFINE read_forward_definitions}
95 {$include gdkincludes.inc}
96 {$UNDEF read_forward_definitions}
97 
98 {$DEFINE read_interface_types}
99 {$include gdkincludes.inc}
100 {$UNDEF read_interface_types}
101 
102 {$DEFINE read_interface_rest}
103 {$include gdkincludes.inc}
104 {$UNDEF read_interface_rest}
105 
106 procedure gdk_parse_args(argc:Pgint; var argv:PPgchar); cdecl; external gdklib;
107 procedure gdk_init(argc:Pgint; var argv:PPgchar); cdecl; external gdklib;
gdk_init_checknull108 function gdk_init_check(argc:Pgint; var argv:PPgchar):gboolean; cdecl; external gdklib;
109 procedure gdk_notify_startup_complete; cdecl; external gdklib;
110 
111 {$ifndef GDK_DISABLE_DEPRECATED}
112 procedure gdk_exit(error_code:gint); cdecl; external gdklib;
113 {$endif}
114 { GDK_DISABLE_DEPRECATED  }
115 
gdk_set_localenull116 function gdk_set_locale:Pgchar; cdecl; external gdklib;
gdk_get_program_classnull117 function gdk_get_program_class:Pchar; cdecl; external gdklib;
118 procedure gdk_set_program_class(program_class:Pchar); cdecl; external gdklib;
119 
120 { Push and pop error handlers for X errors }
121 procedure gdk_error_trap_push; cdecl; external gdklib;
gdk_error_trap_popnull122 function gdk_error_trap_pop:gint; cdecl; external gdklib;
123 
124 {$ifndef GDK_DISABLE_DEPRECATED}
125 procedure gdk_set_use_xshm(use_xshm:gboolean); cdecl; external gdklib;
gdk_get_use_xshmnull126 function gdk_get_use_xshm:gboolean; cdecl; external gdklib;
127 {$endif}
128 { GDK_DISABLE_DEPRECATED  }
129 
gdk_get_displaynull130 function gdk_get_display:Pgchar; cdecl; external gdklib;
gdk_get_display_arg_namenull131 function gdk_get_display_arg_name:Pgchar; cdecl; external gdklib;
132 
133 {$ifndef GDK_DISABLE_DEPRECATED}
gdk_input_add_fullnull134 function gdk_input_add_full(source:gint; condition:TGdkInputCondition; _function:TGdkInputFunction; data:gpointer; destroy:TGdkDestroyNotify):gint; cdecl; external gdklib;
gdk_input_addnull135 function gdk_input_add(source:gint; condition:TGdkInputCondition; _function:TGdkInputFunction; data:gpointer):gint; cdecl; external gdklib;
136 procedure gdk_input_remove(tag:gint); cdecl; external gdklib;
137 {$endif}
138 { GDK_DISABLE_DEPRECATED  }
139 
gdk_pointer_grabnull140 function gdk_pointer_grab(window:PGdkWindow; owner_events:gboolean; event_mask:TGdkEventMask; confine_to:PGdkWindow; cursor:PGdkCursor;
141            time:guint32):TGdkGrabStatus; cdecl; external gdklib;
gdk_keyboard_grabnull142 function gdk_keyboard_grab(window:PGdkWindow; owner_events:gboolean; time:guint32):TGdkGrabStatus; cdecl; external gdklib;
143 
144 {$ifndef GDK_MULTIHEAD_SAFE}
145 procedure gdk_pointer_ungrab(time:guint32); cdecl; external gdklib;
146 procedure gdk_keyboard_ungrab(time:guint32); cdecl; external gdklib;
gdk_pointer_is_grabbednull147 function gdk_pointer_is_grabbed:gboolean; cdecl; external gdklib;
gdk_screen_widthnull148 function gdk_screen_width:gint; cdecl; external gdklib;
gdk_screen_heightnull149 function gdk_screen_height:gint; cdecl; external gdklib;
gdk_screen_width_mmnull150 function gdk_screen_width_mm:gint; cdecl; external gdklib;
gdk_screen_height_mmnull151 function gdk_screen_height_mm:gint; cdecl; external gdklib;
152 procedure gdk_beep; cdecl; external gdklib;
153 {$endif}
154 { GDK_MULTIHEAD_SAFE  }
155 
156 procedure gdk_flush; cdecl; external gdklib;
157 
158 {$ifndef GDK_MULTIHEAD_SAFE}
159 procedure gdk_set_double_click_time(msec:guint); cdecl; external gdklib;
160 {$endif}
161 
162 { Rectangle utilities }
gdk_rectangle_intersectnull163 function gdk_rectangle_intersect(src1:PGdkRectangle; src2:PGdkRectangle; dest:PGdkRectangle):gboolean; cdecl; external gdklib;
164 procedure gdk_rectangle_union(src1:PGdkRectangle; src2:PGdkRectangle; dest:PGdkRectangle); cdecl; external gdklib;
gdk_rectangle_get_typenull165 function gdk_rectangle_get_type:GType; cdecl; external gdklib;
GDK_TYPE_RECTANGLEnull166 function GDK_TYPE_RECTANGLE : GType;
167 
168 { Conversion functions between wide char and multibyte strings. }
gdk_wcstombsnull169 function gdk_wcstombs(src:PGdkWChar):Pgchar; cdecl; external gdklib;
gdk_mbstowcsnull170 function gdk_mbstowcs(dest:PGdkWChar; src:Pgchar; dest_max:gint):gint; cdecl; external gdklib;
171 { Miscellaneous  }
172 
173 {$ifndef GDK_MULTIHEAD_SAFE}
gdk_event_send_client_messagenull174 function gdk_event_send_client_message(event:PGdkEvent; xid:guint32):gboolean; cdecl; external gdklib;
175 procedure gdk_event_send_clientmessage_toall(event:PGdkEvent); cdecl; external gdklib;
176 {$endif}
177 
178 
179 {$IFNDEF KYLIX}
180 { Threading }
181 var
182   {$IFDEF WINDOWS}
183   gdk_threads_mutex : PGMutex; external gdklib name 'gdk_threads_mutex';
184   {$ELSE}
185   gdk_threads_mutex : PGMutex; cvar; external;
186   {$ENDIF}
187 {$ENDIF}
188 
189 procedure gdk_threads_enter; cdecl; external gdklib;
190 procedure gdk_threads_leave; cdecl; external gdklib;
191 procedure gdk_threads_init; cdecl; external gdklib;
192 procedure gdk_threads_set_lock_functions(enter_fn: TGCallback; leave_fn: TGCallback); cdecl; external gdklib;
193 
194 procedure _GDK_THREADS_ENTER;
195 procedure _GDK_THREADS_LEAVE;
196 
197 
198 
199 implementation
200 
201 {$IFNDEF KYLIX}
202 { There is a bug in the compiler. If an external variable is not used, it will
203   create code, that can be relocated by the linker.
204   So, use them in this hidden procedure.
205 }
206 procedure CheckUnusedVariable; [Public];
207 begin
208   if (gdk_threads_mutex<>nil) then ;
209 end;
210 {$ENDIF}
211 
212 //------------------------------------------------------------------------------
213 
GDK_TYPE_RECTANGLEnull214 function GDK_TYPE_RECTANGLE : GType;
215 begin
216   GDK_TYPE_RECTANGLE:=gdk_rectangle_get_type;
217 end;
218 
219 procedure _GDK_THREADS_ENTER;
220 begin
221 {$ifdef G_THREADS_ENABLED}
222   if (gdk_threads_mutex) then
223     g_mutex_lock (gdk_threads_mutex);
224 {$endif}
225 end;
226 
227 procedure _GDK_THREADS_LEAVE;
228 begin
229 {$ifdef G_THREADS_ENABLED}
230   if (gdk_threads_mutex) then
231     g_mutex_unlock (gdk_threads_mutex);
232 {$endif}
233 end;
234 
235 // call implementation parts of header files
236 {$DEFINE read_implementation}
237 {$include gdkincludes.inc}
238 {$UNDEF read_implementation}
239 
240 end.
241