home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / gdisplay.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-25  |  11.1 KB  |  250 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. #ifndef __GDISPLAY_H__
  19. #define __GDISPLAY_H__
  20.  
  21.  
  22. #include "cursorutil.h"
  23. #include "gimage.h"
  24. #include "info_dialog.h"
  25. #include "selection.h"
  26.  
  27. #include "gdisplayF.h"
  28.  
  29. /*
  30.  *  Global variables
  31.  *
  32.  */
  33.  
  34. /*  some useful macros  */
  35.  
  36. /* unpacking the user scale level (char) */
  37. #define  SCALESRC(g)    (g->scale & 0x00ff)
  38. #define  SCALEDEST(g)   (g->scale >> 8)
  39.  
  40. /* finding the effective screen resolution (double) */
  41. #define  SCREEN_XRES(g) (g->dot_for_dot? g->gimage->xresolution : monitor_xres)
  42. #define  SCREEN_YRES(g) (g->dot_for_dot? g->gimage->yresolution : monitor_yres)
  43.  
  44. /* calculate scale factors (double) */
  45. #define  SCALEFACTOR_X(g)  ((SCALEDEST(g) * SCREEN_XRES(g)) /          \
  46.                 (SCALESRC(g) * g->gimage->xresolution))
  47. #define  SCALEFACTOR_Y(g)  ((SCALEDEST(g) * SCREEN_YRES(g)) /          \
  48.                 (SCALESRC(g) * g->gimage->yresolution))
  49.  
  50. /* scale values */
  51. #define  SCALEX(g,x)    ((int)(x * SCALEFACTOR_X(g)))
  52. #define  SCALEY(g,y)    ((int)(y * SCALEFACTOR_Y(g)))
  53.  
  54. /* unscale values */
  55. #define  UNSCALEX(g,x)  ((int)(x / SCALEFACTOR_X(g)))
  56. #define  UNSCALEY(g,y)  ((int)(y / SCALEFACTOR_Y(g)))
  57. /* (and float-returning versions) */
  58. #define  FUNSCALEX(g,x)  ((x / SCALEFACTOR_X(g)))
  59. #define  FUNSCALEY(g,y)  ((y / SCALEFACTOR_Y(g)))
  60.  
  61.  
  62.  
  63.  
  64. #define LOWPASS(x) ((x>0) ? x : 0)
  65. /* #define HIGHPASS(x,y) ((x>y) ? y : x) */ /* unused - == MIN */
  66.  
  67.  
  68. /* maximal width of the string holding the cursor-coordinates for
  69.    the status line */
  70. #define CURSOR_STR_LENGTH 256
  71.  
  72. /* maximal length of the format string for the cursor-coordinates */
  73. #define CURSOR_FORMAT_LENGTH 32
  74.  
  75. typedef struct _IdleRenderStruct
  76. {
  77.   gint width;
  78.   gint height;
  79.   gint x;
  80.   gint y;
  81.   gint basex;
  82.   gint basey;
  83.   guint idleid;
  84.   /*guint handlerid;*/
  85.   gboolean active;
  86.   GSList *update_areas;           /*  flushed update areas */
  87.  
  88. } IdleRenderStruct;
  89.  
  90.  
  91. struct _GDisplay
  92. {
  93.   gint ID;                        /*  unique identifier for this gdisplay     */
  94.  
  95.   GtkWidget *shell;               /*  shell widget for this gdisplay          */
  96.   GtkWidget *canvas;              /*  canvas widget for this gdisplay         */
  97.   GtkWidget *hsb, *vsb;           /*  widgets for scroll bars                 */
  98.   GtkWidget *qmaskoff, *qmaskon;  /*  widgets for qmask buttons               */
  99.   GtkWidget *hrule, *vrule;       /*  widgets for rulers                      */
  100.   GtkWidget *origin;              /*  widgets for rulers                      */
  101.   GtkWidget *popup;               /*  widget for popup menu                   */
  102.   GtkWidget *statusarea;          /*  hbox holding the statusbar and stuff    */
  103.   GtkWidget *statusbar;           /*  widget for statusbar                    */
  104.   GtkWidget *progressbar;         /*  widget for progressbar                  */
  105.   GtkWidget *cursor_label;        /*  widget for cursor position              */
  106.   gchar cursor_format_str [CURSOR_FORMAT_LENGTH]; /* we need a variable format
  107.                            * string because different
  108.                            * units have different number
  109.                            * of decimals              */
  110.   GtkWidget *cancelbutton;        /*  widget for cancel button                */
  111.   guint progressid;               /*  id of statusbar message for progress    */
  112.  
  113.   InfoDialog *window_info_dialog; /*  dialog box for image information        */
  114.   InfoDialog *window_nav_dialog;  /*  dialog box for image navigation         */
  115.   GtkWidget  *nav_popup;          /*  widget for the popup navigation window  */
  116.  
  117.   gint color_type;                /*  is this an RGB or GRAY colormap         */
  118.  
  119.   GtkAdjustment *hsbdata;         /*  horizontal data information             */
  120.   GtkAdjustment *vsbdata;         /*  vertical data information               */
  121.  
  122.   GimpImage *gimage;              /*  pointer to the associated gimage struct */
  123.   gint instance;                  /*  the instance # of this gdisplay as      */
  124.                                   /*  taken from the gimage at creation       */
  125.  
  126.   gint depth;                     /*  depth of our drawables                  */
  127.   gint disp_width;                /*  width of drawing area in the window     */
  128.   gint disp_height;               /*  height of drawing area in the window    */
  129.   gint disp_xoffset;
  130.   gint disp_yoffset;
  131.  
  132.   gint offset_x;                  /*  offset of display image into raw image  */
  133.   gint offset_y;        
  134.   gint scale;                      /*  scale factor from original raw image    */
  135.   gboolean dot_for_dot;          /*  is monitor resolution being ignored?    */
  136.   gboolean draw_guides;           /*  should the guides be drawn?             */
  137.   gboolean snap_to_guides;        /*  should the guides be snapped to?        */
  138.  
  139.   Selection *select;              /*  Selection object                        */
  140.  
  141.   GdkGC *scroll_gc;               /*  GC for scrolling                        */
  142.  
  143.   GSList *update_areas;           /*  Update areas list                       */
  144.   GSList *display_areas;          /*  Display areas list                      */
  145.  
  146.   GdkCursorType  current_cursor;  /*  Currently installed cursor              */
  147.   ToolType       cursor_tool;     /*  Cursor for which tool?                  */
  148.   CursorModifier cursor_modifier; /*  Cursor modifier (plus, minus, ...)      */
  149.   gboolean       toggle_cursor;   /*  Cursor toggled?                         */
  150.  
  151.   GdkCursorType override_cursor;  /*  Overriding cursor (ie. hourglass)       */
  152.   gboolean using_override_cursor; /* is the cursor overridden? (ie. hourglass)*/
  153.  
  154.   gboolean draw_cursor;              /* should we draw software cursor ?         */
  155.   gint cursor_x;                  /* software cursor X value                  */
  156.   gint cursor_y;                  /* software cursor Y value                  */
  157.   gboolean proximity;             /* is a device in proximity of gdisplay ?   */
  158.   gboolean have_cursor;          /* is cursor currently drawn ?              */
  159.   
  160.   IdleRenderStruct idle_render;   /* state of this gdisplay's render thread   */
  161.   
  162. #ifdef DISPLAY_FILTERS
  163.   GList     *cd_list;             /* color display conversion stuff           */
  164.   GtkWidget *cd_ui;          /* color display filter dialog              */
  165. #endif /* DISPLAY_FILTERS */
  166.  
  167.   GtkWidget *warning_dialog;      /* "Changes were made to %s. Close anyway?" */
  168. };
  169.  
  170.  
  171.  
  172. /* member function declarations */
  173.  
  174. GDisplay * gdisplay_new                    (GimpImage *, guint);
  175. void       gdisplay_reconnect              (GDisplay *, GimpImage *);
  176. void       gdisplay_remove_and_delete      (GDisplay *);
  177. gint       gdisplay_mask_value             (GDisplay *, gint, gint);
  178. gint       gdisplay_mask_bounds            (GDisplay *, gint *, gint *, gint *, gint *);
  179. void       gdisplay_transform_coords       (GDisplay *, gint, gint, gint *, gint *, gint);
  180. void       gdisplay_untransform_coords     (GDisplay *, gint, gint, gint *, gint *, 
  181.                                     gboolean, gboolean);
  182. void       gdisplay_transform_coords_f     (GDisplay *, gdouble, gdouble, 
  183.                                     gdouble *, gdouble *, gboolean);
  184. void       gdisplay_untransform_coords_f   (GDisplay *, gdouble, gdouble, 
  185.                                     gdouble *, gdouble *, gboolean);
  186.  
  187. void       gdisplay_real_install_tool_cursor (GDisplay       *gdisp,
  188.                           GdkCursorType   cursor_type,
  189.                           ToolType        tool_type,
  190.                           CursorModifier  modifier,
  191.                           gboolean        toggle_cursor,
  192.                           gboolean        always_install);
  193. void       gdisplay_install_tool_cursor      (GDisplay       *gdisp,
  194.                           GdkCursorType   cursor_type,
  195.                           ToolType        tool_type,
  196.                           CursorModifier  modifier,
  197.                           gboolean        toggle_cursor);
  198. void       gdisplay_remove_tool_cursor       (GDisplay       *gdisp);
  199. void       gdisplay_install_override_cursor  (GDisplay       *gdisp,
  200.                           GdkCursorType   cursor_type);
  201. void       gdisplay_remove_override_cursor   (GDisplay       *gdisp);
  202.  
  203. void       gdisplay_set_menu_sensitivity   (GDisplay *);
  204. void       gdisplay_expose_area            (GDisplay *, gint, gint, gint, gint);
  205. void       gdisplay_expose_guide           (GDisplay *, Guide *);
  206. void       gdisplay_expose_full            (GDisplay *);
  207. void       gdisplay_flush                  (GDisplay *);
  208. void       gdisplay_flush_now              (GDisplay *);
  209. void       gdisplay_draw_guides            (GDisplay *);
  210. void       gdisplay_draw_guide             (GDisplay *, Guide *, gboolean);
  211. Guide*     gdisplay_find_guide             (GDisplay *, gdouble, double);
  212. gboolean   gdisplay_snap_point             (GDisplay *, gdouble, gdouble, 
  213.                                     gdouble *, gdouble *);
  214. void       gdisplay_snap_rectangle         (GDisplay *, gdouble, gdouble, gdouble, gdouble,
  215.                                     gdouble *, gdouble *);
  216. void       gdisplay_update_cursor       (GDisplay *, gint, gint);
  217. void       gdisplay_set_dot_for_dot       (GDisplay *, gboolean);
  218. void       gdisplay_resize_cursor_label    (GDisplay *);
  219. void       gdisplay_update_title           (GDisplay *);
  220. void       gdisplay_flush_displays_only    (GDisplay *gdisp); /* no rerender! */
  221.  
  222.  
  223. GDisplay * gdisplay_active                 (void);
  224. GDisplay * gdisplay_get_ID                 (gint);
  225.  
  226.  
  227. /*  function declarations  */
  228.  
  229. GDisplay * gdisplays_check_valid           (GDisplay *, GimpImage *);
  230. void       gdisplays_reconnect             (GimpImage *old, GimpImage *new);
  231. void       gdisplays_update_title          (GimpImage *);
  232. void       gdisplays_resize_cursor_label   (GimpImage *);
  233. void       gdisplays_setup_scale           (GimpImage *);
  234. void       gdisplays_update_area           (GimpImage *, gint, gint, gint, gint);
  235. void       gdisplays_expose_guides         (GimpImage *);
  236. void       gdisplays_expose_guide          (GimpImage *, Guide *);
  237. void       gdisplays_update_full           (GimpImage *);
  238. void       gdisplays_shrink_wrap           (GimpImage *);
  239. void       gdisplays_expose_full           (void);
  240. void       gdisplays_selection_visibility  (GimpImage *, SelectionControl);
  241. gboolean   gdisplays_dirty                 (void);
  242. void       gdisplays_delete                (void);
  243. void       gdisplays_flush                 (void);
  244. void       gdisplays_flush_now             (void);
  245. void       gdisplays_finish_draw           (void);
  246. void       gdisplays_nav_preview_resized   (void);
  247. void       gdisplays_foreach               (GFunc func, gpointer user_data);
  248.  
  249. #endif /*  __GDISPLAY_H__  */
  250.