home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / perl5 / Gtk2 / Install / gtk2perl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-07-11  |  7.2 KB  |  197 lines

  1. /*
  2.  * 
  3.  * Copyright (C) 2003-2004 by the gtk2-perl team (see the file AUTHORS for the
  4.  * full list)
  5.  * 
  6.  * This library is free software; you can redistribute it and/or modify it
  7.  * under the terms of the GNU Library General Public License as published by
  8.  * the Free Software Foundation; either version 2.1 of the License, or (at your
  9.  * option) any later version.
  10.  * 
  11.  * This library is distributed in the hope that it will be useful, but WITHOUT
  12.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  14.  * License for more details.
  15.  * 
  16.  * You should have received a copy of the GNU Library General Public License
  17.  * along with this library; if not, write to the Free Software Foundation,
  18.  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA.
  19.  * 
  20.  *
  21.  * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/gtk2perl.h,v 1.37 2005/07/11 22:39:12 kaffeetisch Exp $
  22.  */
  23.  
  24. #ifndef _GTK2PERL_H_
  25. #define _GTK2PERL_H_
  26.  
  27. #include <gperl.h>
  28. #include <gtk/gtk.h>
  29.  
  30. #include "gtk2perl-versions.h"
  31.  
  32. /* custom GType for GdkRegion */
  33. #ifndef GDK_TYPE_REGION
  34. # define GDK_TYPE_REGION (gtk2perl_gdk_region_get_type ())
  35.   GType gtk2perl_gdk_region_get_type (void) G_GNUC_CONST;
  36. #endif
  37.  
  38. /* custom GType for PangoLayoutIter */
  39. #ifndef PANGO_TYPE_LAYOUT_ITER
  40. # define PANGO_TYPE_LAYOUT_ITER (gtk2perl_pango_layout_iter_get_type ())
  41.   GType gtk2perl_pango_layout_iter_get_type (void) G_GNUC_CONST;
  42. #endif
  43.  
  44. /* custom GType for PangoScriptIter */
  45. #if PANGO_CHECK_VERSION (1, 4, 0)
  46. # ifndef PANGO_TYPE_SCRIPT_ITER
  47. #  define PANGO_TYPE_SCRIPT_ITER (gtk2perl_pango_script_iter_get_type ())
  48.    GType gtk2perl_pango_script_iter_get_type (void) G_GNUC_CONST;
  49. # endif
  50. #endif
  51.  
  52. #include "gtk2perl-autogen.h"
  53.  
  54. /* no plug/socket on non-X11 despite patches exist for years. */
  55. #ifndef GDK_WINDOWING_X11
  56. # undef GTK_TYPE_PLUG
  57. # undef GTK_TYPE_SOCKET
  58. #endif
  59.  
  60. /**
  61.  * gtk2perl_new_gtkobject:
  62.  * @object: object to wrap.
  63.  * 
  64.  * convenient wrapper around gperl_new_object() which always passes %TRUE
  65.  * for gperl_new_object()'s "own" parameter.  for #GtkObjects, that parameter
  66.  * merely results in gtk_object_sink() being called; if the object was not
  67.  * floating, this does nothing.  thus, everything just works out.
  68.  *
  69.  * returns: scalar wrapper for @object.
  70.  *
  71.  * in xs/GtkObject.xs 
  72.  */
  73. SV * gtk2perl_new_gtkobject (GtkObject * object);
  74.  
  75.  
  76. /*
  77. custom handling for GdkBitmaps, since there are no typemacros for them.
  78. */
  79. /* GObject derivative GdkBitmap */
  80. #define SvGdkBitmap(sv)       ((GdkBitmap*)gperl_get_object_check (sv, GDK_TYPE_DRAWABLE))
  81. typedef GdkBitmap GdkBitmap_ornull;
  82. #define SvGdkBitmap_ornull(sv)        (((sv) && SvOK (sv)) ? SvGdkBitmap(sv) : NULL)
  83. typedef GdkBitmap GdkBitmap_noinc;
  84. /* these are real functions, rather than macros, because there's some extra
  85.  * work involved in making sure it's blessed into Gtk2::Gdk::Bitmap when no
  86.  * GType exists for GdkBitmap. */
  87. SV * newSVGdkBitmap (GdkBitmap * bitmap);
  88. SV * newSVGdkBitmap_noinc (GdkBitmap * bitmap);
  89. #define newSVGdkBitmap_ornull(b) (b ? newSVGdkBitmap (b) : Nullsv)
  90.  
  91. /* exported for GtkGC */
  92. SV * newSVGdkGCValues (GdkGCValues * v);
  93. void SvGdkGCValues (SV * data, GdkGCValues * v, GdkGCValuesMask * m);
  94.  
  95. /* exported for various other parts of pango */
  96. SV * newSVPangoRectangle (PangoRectangle * rectangle);
  97.  
  98. /*
  99.  * GdkAtom, an opaque pointer
  100.  */
  101. SV * newSVGdkAtom (GdkAtom atom);
  102. GdkAtom SvGdkAtom (SV * sv);
  103.  
  104. SV * newSVGtkTargetEntry (GtkTargetEntry * target_entry);
  105. /* do not store GtkTargetEntry objects returned from this function -- 
  106.  * they are only good for the block of code in which they are created */
  107. GtkTargetEntry * SvGtkTargetEntry (SV * sv);
  108. void gtk2perl_read_gtk_target_entry (SV * sv, GtkTargetEntry * entry);
  109.  
  110. #define GTK2PERL_STACK_ITEMS_TO_TARGET_ENTRY_ARRAY(first, targets, ntargets) \
  111.     {                                    \
  112.     guint i;                                \
  113.     if (items <= first) {                                           \
  114.         ntargets = 0;                                           \
  115.         targets = NULL;                                         \
  116.     } else {                                                        \
  117.         ntargets = items - first;                \
  118.         targets = gperl_alloc_temp (sizeof (GtkTargetEntry) * ntargets); \
  119.         for (i = 0 ; i < ntargets ; i++)            \
  120.             gtk2perl_read_gtk_target_entry (ST (i + first),    \
  121.                                             targets + i);    \
  122.         }                                                       \
  123.     }
  124.  
  125. /* 
  126.  * get a list of GTypes from the xsub argument stack
  127.  * used to collect column types for creating and initializing GtkTreeStores
  128.  * and GtkListStores.
  129.  */
  130. #define GTK2PERL_STACK_ITEMS_TO_GTYPE_ARRAY(arrayvar, first, last)    \
  131.     (arrayvar) = g_array_new (FALSE, FALSE, sizeof (GType));    \
  132.     g_array_set_size ((arrayvar), (last) - (first) + 1);        \
  133.     {                                \
  134.     int i;                                \
  135.     for (i = (first) ; i <= (last) ; i++) {                \
  136.         char * package = SvPV_nolen (ST (i));            \
  137.         /* look up GType by package name. */            \
  138.         GType t = gperl_type_from_package (package);        \
  139.         if (t == 0) {                        \
  140.             g_array_free ((arrayvar), TRUE);        \
  141.             croak ("package %s is not registered with GPerl", \
  142.                    package);                \
  143.             g_assert ("not reached");            \
  144.         }                            \
  145.         g_array_index ((arrayvar), GType, i-(first)) = t;    \
  146.     }                                \
  147.     }
  148.  
  149.  
  150. /*
  151.  * some custom opaque object handling for private gtk structures needed 
  152.  * for doing drag and drop.
  153.  */
  154. typedef GtkTargetList GtkTargetList_ornull;
  155. SV * newSVGtkTargetList (GtkTargetList * list);
  156. #define newSVGtkTargetList_ornull(list)    ((list) ? newSVGtkTargetList (list) : &PL_sv_undef)
  157. GtkTargetList * SvGtkTargetList (SV * sv);
  158. #define SvGtkTargetList_ornull(sv)    (((sv) && SvOK (sv)) ? SvGtkTargetList (sv) : NULL)
  159.  
  160. /*
  161.  * exported so Gnome2 can reuse it in wrappers.  other modules might want to
  162.  * do the same.  the callback for it needn't worry about param_types or
  163.  * return type, as this does all the marshaling by hand (the C function writes
  164.  * through the params, so we have to handle the stack specially).
  165.  */
  166. void gtk2perl_menu_position_func (GtkMenu       * menu,
  167.                                   gint          * x,
  168.                                   gint          * y,
  169.                                   gboolean      * push_in,
  170.                                   GPerlCallback * callback);
  171.  
  172.  
  173. #if ! GTK_CHECK_VERSION (2, 4, 0)
  174.  /* in versions prior to 2.4.0, GtkTreeSearchFlags was declared such that
  175.   * glib-mkenums interpreted and registered it as a GEnum type.  sometime
  176.   * before 2.3.0, this was corrected, and the type is registered as a GFlags.
  177.   * The maps file has GFlags (since that's correct), but we have to mangle
  178.   * things somewhat for the bindings to work properly with older libraries. */
  179. # undef SvGtkTextSearchFlags
  180. # undef newSVGtkTextSearchFlags
  181. # define SvGtkTextSearchFlags(sv)    (gperl_convert_enum (GTK_TYPE_TEXT_SEARCH_FLAGS, sv))
  182. # define newSVGtkTextSearchFlags(val)    (gperl_convert_back_enum (GTK_TYPE_TEXT_SEARCH_FLAGS, val))
  183. #endif
  184.  
  185. /* object handling for GdkGeometry */
  186. SV * newSVGdkGeometry (GdkGeometry *geometry);
  187. GdkGeometry * SvGdkGeometry (SV *object);
  188. GdkGeometry * SvGdkGeometryReal (SV *object, GdkWindowHints *hints);
  189.  
  190. /* special handling for GdkPixbufFormat, which was introduced in gtk+ 2.2.0 */
  191. #if GTK_CHECK_VERSION (2, 2, 0)
  192. SV * newSVGdkPixbufFormat (GdkPixbufFormat * format);
  193. GdkPixbufFormat * SvGdkPixbufFormat (SV * sv);
  194. #endif
  195.  
  196. #endif /* _GTK2PERL_H_ */
  197.