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

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #ifndef __TOOLS_H__
  20. #define __TOOLS_H__
  21.  
  22. #include "gimpcontext.h"
  23. #include "tool_options.h"
  24. #include "channel.h"
  25. #include "cursorutil.h"
  26.  
  27. #include "toolsF.h"
  28.  
  29.  
  30. /*  The possible states for tools  */
  31. typedef enum
  32. {
  33.   INACTIVE,
  34.   ACTIVE,
  35.   PAUSED
  36. } ToolState;
  37.  
  38. /* Selection Boolean operations that rect, */
  39. /* ellipse, freehand, and fuzzy tools may  */
  40. /* perform.                                */
  41.  
  42. typedef enum
  43. {
  44.   SELECTION_ADD       = ADD,
  45.   SELECTION_SUB       = SUB,
  46.   SELECTION_REPLACE   = REPLACE,
  47.   SELECTION_INTERSECT = INTERSECT,
  48.   SELECTION_MOVE_MASK,
  49.   SELECTION_MOVE,
  50.   SELECTION_ANCHOR
  51. } SelectOps;
  52.  
  53. /*  The possibilities for where the cursor lies  */
  54. #define  ACTIVE_LAYER      (1 << 0)
  55. #define  SELECTION         (1 << 1)
  56. #define  NON_ACTIVE_LAYER  (1 << 2)
  57.  
  58. /*  The types of tools...  */
  59. struct _Tool
  60. {
  61.   /*  Data  */
  62.   ToolType   type;          /*  Tool type                                   */
  63.   gint       ID;            /*  unique tool ID                              */
  64.  
  65.   ToolState  state;         /*  state of tool activity                      */
  66.   gint       paused_count;  /*  paused control count                        */
  67.   gboolean   scroll_lock;   /*  allow scrolling or not                      */
  68.   gboolean   auto_snap_to;  /*  snap to guides automatically                */
  69.  
  70.   gboolean   preserve;      /*  Preserve this tool across drawable changes  */
  71.   void      *gdisp_ptr;     /*  pointer to currently active gdisp           */
  72.   void      *drawable;      /*  pointer to the tool's current drawable      */
  73.  
  74.   gboolean   toggled;       /*  Bad hack to let the paint_core show the     */
  75.                             /*  right toggle cursors                        */
  76.  
  77.  
  78.   void      *private;       /*  Tool-specific information                   */
  79.  
  80.   /*  Action functions  */
  81.   ButtonPressFunc    button_press_func;
  82.   ButtonReleaseFunc  button_release_func;
  83.   MotionFunc         motion_func;
  84.   ArrowKeysFunc      arrow_keys_func;
  85.   ModifierKeyFunc    modifier_key_func;
  86.   CursorUpdateFunc   cursor_update_func;
  87.   OperUpdateFunc     oper_update_func;
  88.   ToolCtlFunc        control_func;
  89. };
  90.  
  91. struct _ToolInfo
  92. {
  93.   ToolOptions *tool_options;
  94.  
  95.   gchar       *tool_name;
  96.  
  97.   gchar       *menu_path;  
  98.   gchar       *menu_accel; 
  99.  
  100.   gchar      **icon_data;
  101.   GdkPixmap   *icon_pixmap;
  102.   GdkBitmap   *icon_mask;
  103.  
  104.   gchar       *tool_desc;
  105.   const gchar *private_tip;
  106.  
  107.   ToolType     tool_id;
  108.  
  109.   ToolInfoNewFunc  new_func;
  110.   ToolInfoFreeFunc free_func;
  111.   ToolInfoInitFunc init_func;
  112.  
  113.   GtkWidget *tool_widget;
  114.  
  115.   GimpContext *tool_context;
  116.  
  117.   BitmapCursor tool_cursor;
  118.   BitmapCursor toggle_cursor;
  119. };
  120.  
  121. /*  Global Data Structures  */
  122. extern Tool     * active_tool;
  123. extern ToolInfo   tool_info[];
  124. extern gint       num_tools;
  125.  
  126. /*  Function declarations  */
  127. Tool   * tools_new_tool             (ToolType     tool_type);
  128.  
  129. void     tools_select               (ToolType     tool_type);
  130. void     tools_initialize           (ToolType     tool_type,
  131.                      GDisplay    *gdisplay);
  132.  
  133. void     active_tool_control        (ToolAction   action,
  134.                      void        *gdisp_ptr);
  135.  
  136. void     tools_help_func            (const gchar *help_data);
  137.  
  138. void     tools_register             (ToolType     tool_type,
  139.                      ToolOptions *tool_options);
  140.  
  141. void     tool_options_dialog_new   (void);
  142. void     tool_options_dialog_show  (void);
  143. void     tool_options_dialog_free  (void);
  144.  
  145. gchar  * tool_active_PDB_string    (void);
  146.  
  147. /* don't unref this pixmaps, they are static! */
  148. GdkPixmap * tool_get_pixmap        (ToolType     tool_type);
  149. GdkBitmap * tool_get_mask          (ToolType     tool_type);
  150.  
  151. #endif  /*  __TOOLS_H__  */
  152.