home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / gimpcontext.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  10.9 KB  |  291 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * gimpcontext.h: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program 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
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. #ifndef __GIMP_CONTEXT_H__
  22. #define __GIMP_CONTEXT_H__
  23.  
  24.  
  25. #include "apptypes.h"
  26. #include "gdisplay.h"
  27. #include "gradient.h"
  28. #include "patterns.h"
  29. #include "toolsF.h"
  30.  
  31.  
  32. #define GIMP_TYPE_CONTEXT            (gimp_context_get_type ())
  33. #define GIMP_CONTEXT(obj)            (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONTEXT, GimpContext))
  34. #define GIMP_CONTEXT_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, GIMP_TYPE_CONTEXT, GimpContextClass))
  35. #define GIMP_IS_CONTEXT(obj)         (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONTEXT))
  36. #define GIMP_IS_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTEXT))
  37.  
  38. typedef enum
  39. {
  40.   GIMP_CONTEXT_ARG_IMAGE,
  41.   GIMP_CONTEXT_ARG_DISPLAY,
  42.   GIMP_CONTEXT_ARG_TOOL,
  43.   GIMP_CONTEXT_ARG_FOREGROUND,
  44.   GIMP_CONTEXT_ARG_BACKGROUND,
  45.   GIMP_CONTEXT_ARG_OPACITY,
  46.   GIMP_CONTEXT_ARG_PAINT_MODE,
  47.   GIMP_CONTEXT_ARG_BRUSH,
  48.   GIMP_CONTEXT_ARG_PATTERN,
  49.   GIMP_CONTEXT_ARG_GRADIENT,
  50.   GIMP_CONTEXT_NUM_ARGS
  51. } GimpContextArgType;
  52.  
  53. typedef enum
  54. {
  55.   GIMP_CONTEXT_IMAGE_MASK      = 1 << 0,
  56.   GIMP_CONTEXT_DISPLAY_MASK    = 1 << 1,
  57.   GIMP_CONTEXT_TOOL_MASK       = 1 << 2,
  58.   GIMP_CONTEXT_FOREGROUND_MASK = 1 << 3,
  59.   GIMP_CONTEXT_BACKGROUND_MASK = 1 << 4,
  60.   GIMP_CONTEXT_OPACITY_MASK    = 1 << 5,
  61.   GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 6,
  62.   GIMP_CONTEXT_BRUSH_MASK      = 1 << 7,
  63.   GIMP_CONTEXT_PATTERN_MASK    = 1 << 8,
  64.   GIMP_CONTEXT_GRADIENT_MASK   = 1 << 9,
  65.  
  66.   /*  aliases  */
  67.   GIMP_CONTEXT_PAINT_ARGS_MASK = GIMP_CONTEXT_FOREGROUND_MASK |
  68.                                  GIMP_CONTEXT_BACKGROUND_MASK |
  69.                                  GIMP_CONTEXT_OPACITY_MASK |
  70.                                  GIMP_CONTEXT_PAINT_MODE_MASK |
  71.                                  GIMP_CONTEXT_BRUSH_MASK |
  72.                                  GIMP_CONTEXT_PATTERN_MASK |
  73.                                  GIMP_CONTEXT_GRADIENT_MASK,
  74.   GIMP_CONTEXT_ALL_ARGS_MASK   = GIMP_CONTEXT_IMAGE_MASK |
  75.                                  GIMP_CONTEXT_DISPLAY_MASK |
  76.                                  GIMP_CONTEXT_TOOL_MASK |
  77.                                  GIMP_CONTEXT_PAINT_ARGS_MASK
  78. } GimpContextArgMask;
  79.  
  80. typedef struct _GimpContext GimpContext;
  81. typedef struct _GimpContextClass GimpContextClass;
  82.  
  83. struct _GimpContext
  84. {
  85.   GimpObject        object;
  86.  
  87.   gchar           *name;
  88.   GimpContext       *parent;
  89.  
  90.   guint32           defined_args;
  91.  
  92.   GimpImage       *image;
  93.   GDisplay       *display;
  94.  
  95.   ToolType          tool;
  96.  
  97.   guchar            foreground[3];
  98.   guchar            background[3];
  99.  
  100.   gdouble        opacity;
  101.   LayerModeEffects  paint_mode;
  102.  
  103.   GimpBrush        *brush;
  104.   gchar            *brush_name;
  105.  
  106.   GPattern         *pattern;
  107.   gchar            *pattern_name;
  108.  
  109.   gradient_t       *gradient;
  110.   gchar            *gradient_name;
  111. };
  112.  
  113. struct _GimpContextClass
  114. {
  115.   GimpObjectClass parent_class;
  116.  
  117.   void (* image_changed)      (GimpContext      *context,
  118.                    GimpImage        *image);
  119.   void (* display_changed)    (GimpContext      *context,
  120.                    GDisplay         *display);
  121.  
  122.   void (* tool_changed)       (GimpContext      *context,
  123.                    ToolType          tool);
  124.  
  125.   void (* foreground_changed) (GimpContext      *context,
  126.                    gint              r,
  127.                    gint              g,
  128.                    gint              b);
  129.   void (* background_changed) (GimpContext      *context,
  130.                    gint              r,
  131.                    gint              g,
  132.                    gint              b);
  133.   void (* opacity_changed)    (GimpContext      *context,
  134.                    gdouble           opacity);
  135.   void (* paint_mode_changed) (GimpContext      *context,
  136.                    LayerModeEffects  paint_mode);
  137.   void (* brush_changed)      (GimpContext      *context,
  138.                    GimpBrush        *brush);
  139.   void (* pattern_changed)    (GimpContext      *context,
  140.                    GPattern         *pattern);
  141.   void (* gradient_changed)   (GimpContext      *context,
  142.                    gradient_t       *gradient);
  143. };
  144.  
  145. GtkType       gimp_context_get_type          (void);
  146. GimpContext * gimp_context_new               (const gchar *name,
  147.                           GimpContext *template);
  148.  
  149. /*  TODO: - gimp_context_find ()
  150.  *
  151.  *        probably interacting with the context manager:
  152.  *        - gimp_context_push () which will call gimp_context_set_parent()
  153.  *        - gimp_context_push_new () to do a GL-style push
  154.  *        - gimp_context_pop ()
  155.  *
  156.  *        a proper mechanism to prevent silly operations like pushing
  157.  *        the user context to some client stack etc.
  158.  */
  159.  
  160.  
  161. /*  to be used by the context management system only
  162.  */
  163. void          gimp_context_set_current       (GimpContext *context);
  164. void          gimp_context_set_user          (GimpContext *context);
  165. void          gimp_context_set_default       (GimpContext *context);
  166.  
  167. /*  these are always available
  168.  */
  169. GimpContext * gimp_context_get_current       (void);
  170. GimpContext * gimp_context_get_user          (void);
  171. GimpContext * gimp_context_get_default       (void);
  172. GimpContext * gimp_context_get_standard      (void);
  173.  
  174. /*  functions for manipulating a single context
  175.  */
  176. gchar       * gimp_context_get_name          (GimpContext *context);
  177. void          gimp_context_set_name          (GimpContext *context,
  178.                           const gchar *name);
  179.  
  180. GimpContext * gimp_context_get_parent        (GimpContext *context);
  181. void          gimp_context_set_parent        (GimpContext *context,
  182.                           GimpContext *parent);
  183. void          gimp_context_unset_parent      (GimpContext *context);
  184.  
  185. /*  define / undefinine context arguments
  186.  *
  187.  *  the value of an undefined argument will be taken from the parent context.
  188.  */
  189. void          gimp_context_define_arg        (GimpContext        *context,
  190.                           GimpContextArgType  arg,
  191.                           gboolean            defined);
  192.  
  193. gboolean      gimp_context_arg_defined       (GimpContext        *context,
  194.                           GimpContextArgType  arg);
  195.  
  196. void          gimp_context_define_args       (GimpContext        *context,
  197.                           GimpContextArgMask  args_mask,
  198.                           gboolean            defined);
  199.  
  200. /*  copying context arguments
  201.  */
  202. void          gimp_context_copy_arg          (GimpContext        *src,
  203.                           GimpContext        *dest,
  204.                           GimpContextArgType  arg);
  205.  
  206. void          gimp_context_copy_args         (GimpContext        *src,
  207.                           GimpContext        *dest,
  208.                           GimpContextArgMask  args_mask);
  209.  
  210. /*  image  */
  211. GimpImage        * gimp_context_get_image          (GimpContext     *context);
  212. void               gimp_context_set_image          (GimpContext     *context,
  213.                             GimpImage       *image);
  214. void               gimp_context_image_changed      (GimpContext     *context);
  215.  
  216. /*  display  */
  217. GDisplay         * gimp_context_get_display        (GimpContext     *context);
  218. void               gimp_context_set_display        (GimpContext     *context,
  219.                             GDisplay        *display);
  220. void               gimp_context_display_changed    (GimpContext     *context);
  221.  
  222. /*  tool  */
  223. ToolType           gimp_context_get_tool           (GimpContext     *context);
  224. void               gimp_context_set_tool           (GimpContext     *context,
  225.                             ToolType         tool_type);
  226. void               gimp_context_tool_changed       (GimpContext     *context);
  227.  
  228. /*  foreground color  */
  229. void               gimp_context_get_foreground     (GimpContext     *context,
  230.                             guchar          *r,
  231.                             guchar          *g,
  232.                             guchar          *b);
  233. void               gimp_context_set_foreground     (GimpContext     *context,
  234.                             gint             r,
  235.                             gint             g,
  236.                             gint             b);
  237. void               gimp_context_foreground_changed (GimpContext     *context);
  238.  
  239. /*  background color  */
  240. void               gimp_context_get_background     (GimpContext     *context,
  241.                             guchar          *r,
  242.                             guchar          *g,
  243.                             guchar          *b);
  244. void               gimp_context_set_background     (GimpContext     *context,
  245.                             gint             r,
  246.                             gint             g,
  247.                             gint             b);
  248. void               gimp_context_background_changed (GimpContext     *context);
  249.  
  250. /*  color utility functions  */
  251. void               gimp_context_set_default_colors (GimpContext     *context);
  252. void               gimp_context_swap_colors        (GimpContext     *context);
  253.  
  254. /*  opacity  */
  255. gdouble            gimp_context_get_opacity        (GimpContext     *context);
  256. void               gimp_context_set_opacity        (GimpContext     *context,
  257.                             gdouble          opacity);
  258. void               gimp_context_opacity_changed    (GimpContext     *context);
  259.  
  260. /*  paint mode  */
  261. LayerModeEffects   gimp_context_get_paint_mode     (GimpContext     *context);
  262. void               gimp_context_set_paint_mode     (GimpContext     *context,
  263.                             LayerModeEffects paint_mode);
  264. void               gimp_context_paint_mode_changed (GimpContext     *context);
  265.  
  266. /*  brush  */
  267. GimpBrush        * gimp_context_get_brush          (GimpContext     *context);
  268. void               gimp_context_set_brush          (GimpContext     *context,
  269.                             GimpBrush       *brush);
  270. void               gimp_context_brush_changed      (GimpContext     *context);
  271. void               gimp_context_refresh_brushes    (void);
  272.  
  273. /*  pattern  */
  274. GPattern         * gimp_context_get_pattern        (GimpContext     *context);
  275. void               gimp_context_set_pattern        (GimpContext     *context,
  276.                             GPattern        *pattern);
  277. void               gimp_context_pattern_changed    (GimpContext     *context);
  278. void               gimp_context_refresh_patterns   (void);
  279. void               gimp_context_update_patterns    (GPattern        *pattern);
  280.  
  281. /*  gradient  */
  282. gradient_t       * gimp_context_get_gradient       (GimpContext     *context);
  283. void               gimp_context_set_gradient       (GimpContext     *context,
  284.                             gradient_t      *gradient);
  285. void               gimp_context_gradient_changed   (GimpContext     *context);
  286. void               gimp_context_refresh_gradients  (void);
  287. void               gimp_context_update_gradients   (gradient_t      *gradient);
  288.  
  289.  
  290. #endif /* __GIMP_CONTEXT_H__ */
  291.