gimp.h 8.32 KB
Newer Older
1 2
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
Manish Singh's avatar
Manish Singh committed
3
 *
4 5
 * gimp.h
 *
Manish Singh's avatar
Manish Singh committed
6
 * This library is free software; you can redistribute it and/or
Marc Lehmann's avatar
Marc Lehmann committed
7
 * modify it under the terms of the GNU Lesser General Public
Manish Singh's avatar
Manish Singh committed
8
 * License as published by the Free Software Foundation; either
9 10 11 12 13
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Manish Singh's avatar
Manish Singh committed
14
 * Lesser General Public License for more details.
Manish Singh's avatar
Manish Singh committed
15
 *
Marc Lehmann's avatar
Marc Lehmann committed
16
 * You should have received a copy of the GNU Lesser General Public
17 18 19
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
20 21
 */

Elliot Lee's avatar
Elliot Lee committed
22 23 24 25
#ifndef __GIMP_H__
#define __GIMP_H__

#include <glib.h>
26

27
#include <libgimpcolor/gimpcolor.h>
28
#include <libgimpmath/gimpmath.h>
29
#include <libgimpbase/gimpbase.h>
30

31
#include <libgimp/gimpenums.h>
32 33
#include <libgimp/gimptypes.h>

34
#include <libgimp/gimpchannel.h>
35
#include <libgimp/gimpdrawable.h>
36
#include <libgimp/gimpimage.h>
37
#include <libgimp/gimplayer.h>
38
#include <libgimp/gimpmisc.h>
39
#include <libgimp/gimppixelrgn.h>
40
#include <libgimp/gimpproceduraldb.h>
41
#include <libgimp/gimpselection.h>
42
#include <libgimp/gimptile.h>
43

44
#include <libgimp/gimp_pdb.h>
45

46
#ifdef G_OS_WIN32
47
#  include <stdlib.h>		/* For _-argc and __argv */
Tor Lillqvist's avatar
Tor Lillqvist committed
48 49 50 51 52
#  ifdef LIBGIMP_COMPILATION
#    define GIMPVAR __declspec(dllexport)
#  else  /* !LIBGIMP_COMPILATION */
#    define GIMPVAR extern __declspec(dllimport)
#  endif /* !LIBGIMP_COMPILATION */
53
#else  /* !G_OS_WIN32 */
Tor Lillqvist's avatar
Tor Lillqvist committed
54 55
#  define GIMPVAR extern
#endif
Elliot Lee's avatar
Elliot Lee committed
56

57
G_BEGIN_DECLS
Elliot Lee's avatar
Elliot Lee committed
58

59

60 61 62
#define gimp_get_data         gimp_procedural_db_get_data
#define gimp_get_data_size    gimp_procedural_db_get_data_size
#define gimp_set_data         gimp_procedural_db_set_data
63

Elliot Lee's avatar
Elliot Lee committed
64

Tor Lillqvist's avatar
Tor Lillqvist committed
65 66 67
GIMPVAR guint gimp_major_version;
GIMPVAR guint gimp_minor_version;
GIMPVAR guint gimp_micro_version;
68

Tor Lillqvist's avatar
Tor Lillqvist committed
69
GIMPVAR GIOChannel *_readchannel;
Manish Singh's avatar
Manish Singh committed
70

71 72 73 74 75 76 77 78 79 80 81
typedef void (* GimpInitProc)  (void);
typedef void (* GimpQuitProc)  (void);
typedef void (* GimpQueryProc) (void);
typedef void (* GimpRunProc)   (gchar      *name,
				gint        nparams,
				GimpParam  *param,
				gint       *nreturn_vals,
				GimpParam **return_vals);


struct _GimpPlugInInfo
Elliot Lee's avatar
Elliot Lee committed
82 83
{
  /* called when the gimp application initially starts up */
84
  GimpInitProc  init_proc;
Elliot Lee's avatar
Elliot Lee committed
85 86

  /* called when the gimp application exits */
87
  GimpQuitProc  quit_proc;
Elliot Lee's avatar
Elliot Lee committed
88 89 90 91 92

  /* called by the gimp so that the plug-in can inform the
   *  gimp of what it does. (ie. installing a procedure database
   *  procedure).
   */
93
  GimpQueryProc query_proc;
Elliot Lee's avatar
Elliot Lee committed
94 95 96 97

  /* called to run a procedure the plug-in installed in the
   *  procedure database.
   */
98
  GimpRunProc   run_proc;
Elliot Lee's avatar
Elliot Lee committed
99 100
};

101
struct _GimpParamDef
Elliot Lee's avatar
Elliot Lee committed
102
{
103 104 105
  GimpPDBArgType  type;
  gchar          *name;
  gchar          *description;
Elliot Lee's avatar
Elliot Lee committed
106 107
};

108
struct _GimpParamRegion
109 110 111 112 113 114 115
{
  gint32 x;
  gint32 y;
  gint32 width;
  gint32 height;
};

116
union _GimpParamData
117
{
118 119 120 121 122 123 124 125 126 127
  gint32            d_int32;
  gint16            d_int16;
  gint8             d_int8;
  gdouble           d_float;
  gchar            *d_string;
  gint32           *d_int32array;
  gint16           *d_int16array;
  gint8            *d_int8array;
  gdouble          *d_floatarray;
  gchar           **d_stringarray;
128
  GimpRGB           d_color;
129 130 131 132
  GimpParamRegion   d_region;
  gint32            d_display;
  gint32            d_image;
  gint32            d_layer;
133
  gint32            d_layer_mask;
134 135 136 137 138
  gint32            d_channel;
  gint32            d_drawable;
  gint32            d_selection;
  gint32            d_boundary;
  gint32            d_path;
139
  gint32            d_unit;
140
  GimpParasite      d_parasite;
141
  gint32            d_tattoo;
142
  GimpPDBStatusType d_status;
143 144
};

145
struct _GimpParam
Elliot Lee's avatar
Elliot Lee committed
146
{
147 148
  GimpPDBArgType type;
  GimpParamData  data;
Elliot Lee's avatar
Elliot Lee committed
149 150 151
};


152

153 154 155 156 157 158 159 160 161 162 163
/**
 * MAIN():
 *
 * A macro that expands to the appropriate main() function for the
 * platform being compiled for.
 *
 * To use this macro, simply place a line that contains just the code
 * MAIN() at the toplevel of your file.  No semicolon should be used. 
 *
 */

164
#ifdef G_OS_WIN32
165 166 167

void set_gimp_PLUG_IN_INFO_PTR(GimpPlugInInfo *);

Tor Lillqvist's avatar
Tor Lillqvist committed
168
/* Define WinMain() because plug-ins are built as GUI applications. Also
Tor Lillqvist's avatar
Tor Lillqvist committed
169 170 171
 * define a main() in case some plug-in still is built as a console
 * application.
 */
Tor Lillqvist's avatar
Tor Lillqvist committed
172
#  ifdef __GNUC__
173 174 175
#    ifndef _stdcall
#      define _stdcall __attribute__((stdcall))
#    endif
Tor Lillqvist's avatar
Tor Lillqvist committed
176 177
#  endif

Tor Lillqvist's avatar
Tor Lillqvist committed
178
#  define MAIN()			\
Tor Lillqvist's avatar
Tor Lillqvist committed
179
   static int				\
180
   win32_gimp_main (int argc, char **argv)	\
Tor Lillqvist's avatar
Tor Lillqvist committed
181 182 183 184 185
   {					\
     set_gimp_PLUG_IN_INFO_PTR(&PLUG_IN_INFO);	\
     return gimp_main (argc, argv);	\
   }					\
					\
186
   struct HINSTANCE__;			\
Tor Lillqvist's avatar
Tor Lillqvist committed
187
   int _stdcall				\
188 189
   WinMain (struct HINSTANCE__ *hInstance, \
	    struct HINSTANCE__ *hPrevInstance,	\
Tor Lillqvist's avatar
Tor Lillqvist committed
190
	    char *lpszCmdLine,		\
191
	    int   nCmdShow)		\
Tor Lillqvist's avatar
Tor Lillqvist committed
192
   {					\
Tor Lillqvist's avatar
Tor Lillqvist committed
193
     return win32_gimp_main (__argc, __argv);	\
Tor Lillqvist's avatar
Tor Lillqvist committed
194 195 196 197 198
   }					\
					\
   int					\
   main (int argc, char *argv[])	\
   {					\
Tor Lillqvist's avatar
Tor Lillqvist committed
199
     return win32_gimp_main (argc, argv);	\
Tor Lillqvist's avatar
Tor Lillqvist committed
200 201
   }
#else
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
202
#ifndef __EMX__
Tor Lillqvist's avatar
Tor Lillqvist committed
203 204 205 206 207 208
#  define MAIN()			\
   int					\
   main (int argc, char *argv[])	\
   {					\
     return gimp_main (argc, argv);	\
   }
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
209 210 211 212 213 214 215 216 217
#else
#  define MAIN()				\
   int						\
   main (int argc, char *argv[])		\
   {						\
     set_gimp_PLUG_IN_INFO(&PLUG_IN_INFO);	\
     return gimp_main (argc, argv);		\
   }
#endif
Tor Lillqvist's avatar
Tor Lillqvist committed
218
#endif
Elliot Lee's avatar
Elliot Lee committed
219 220 221 222 223


/* The main procedure that should be called with the
 *  'argc' and 'argv' that are passed to "main".
 */
224 225
gint        gimp_main                (gint      argc,
				      gchar    *argv[]);
Elliot Lee's avatar
Elliot Lee committed
226 227 228 229

/* Forcefully causes the gimp library to exit and
 *  close down its connection to main gimp application.
 */
230
void G_GNUC_NORETURN gimp_quit       (void);
Elliot Lee's avatar
Elliot Lee committed
231

Marc Lehmann's avatar
Marc Lehmann committed
232 233
/* Returns the default gdisplay (given at plug-in config time).
 */
234
gint32      gimp_default_display     (void);
Marc Lehmann's avatar
Marc Lehmann committed
235

Elliot Lee's avatar
Elliot Lee committed
236 237 238

/* Install a procedure in the procedure database.
 */
239 240 241 242 243 244 245 246 247 248 249 250 251
void        gimp_install_procedure   (gchar        *name,
				      gchar        *blurb,
				      gchar        *help,
				      gchar        *author,
				      gchar        *copyright,
				      gchar        *date,
				      gchar        *menu_path,
				      gchar        *image_types,
				      gint          type,
				      gint          nparams,
				      gint          nreturn_vals,
				      GimpParamDef *params,
				      GimpParamDef *return_vals);
Elliot Lee's avatar
Elliot Lee committed
252 253 254

/* Install a temporary procedure in the procedure database.
 */
255 256 257 258 259 260 261 262 263 264 265 266 267 268
void        gimp_install_temp_proc   (gchar        *name,
				      gchar        *blurb,
				      gchar        *help,
				      gchar        *author,
				      gchar        *copyright,
				      gchar        *date,
				      gchar        *menu_path,
				      gchar        *image_types,
				      gint          type,
				      gint          nparams,
				      gint          nreturn_vals,
				      GimpParamDef *params,
				      GimpParamDef *return_vals,
				      GimpRunProc   run_proc);
Elliot Lee's avatar
Elliot Lee committed
269 270 271

/* Uninstall a temporary procedure
 */
272
void        gimp_uninstall_temp_proc (gchar        *name);
Elliot Lee's avatar
Elliot Lee committed
273 274 275

/* Run a procedure in the procedure database. The parameters are
 *  specified via the variable length argument list. The return
276
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
277
 */
278 279 280
GimpParam * gimp_run_procedure       (gchar     *name,
				      gint      *nreturn_vals,
				      ...);
Elliot Lee's avatar
Elliot Lee committed
281 282

/* Run a procedure in the procedure database. The parameters are
283 284
 *  specified as an array of GimpParam.  The return
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
285
 */
286 287 288 289
GimpParam * gimp_run_procedure2      (gchar     *name,
				      gint      *nreturn_vals,
				      gint       nparams,
				      GimpParam *params);
Elliot Lee's avatar
Elliot Lee committed
290 291 292 293 294

/* Destroy the an array of parameters. This is useful for
 *  destroying the return values returned by a call to
 *  'gimp_run_procedure'.
 */
295 296
void        gimp_destroy_params      (GimpParam    *params,
				      gint          nparams);
Elliot Lee's avatar
Elliot Lee committed
297

298
/* Destroy the an array of GimpParamDef's. This is useful for
299 300 301
 *  destroying the return values returned by a call to
 *  'gimp_query_procedure'.
 */
302 303
void        gimp_destroy_paramdefs   (GimpParamDef *paramdefs,
				      gint          nparams);
Elliot Lee's avatar
Elliot Lee committed
304

305 306 307
gdouble     gimp_gamma               (void);
gboolean    gimp_install_cmap        (void);
gint        gimp_min_colors          (void);
Elliot Lee's avatar
Elliot Lee committed
308

309 310 311 312 313 314
gchar     * gimp_get_progname        (void);

void        gimp_attach_new_parasite (const gchar    *name,
				      gint            flags,
				      gint            size,
				      const gpointer  data);
Elliot Lee's avatar
Elliot Lee committed
315 316


317
G_END_DECLS
Elliot Lee's avatar
Elliot Lee committed
318 319

#endif /* __GIMP_H__ */