gimpprojection.h 9.75 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17 18 19 20
 */
#ifndef __GDISPLAY_H__
#define __GDISPLAY_H__

Manish Singh's avatar
Manish Singh committed
21 22
#include <glib.h>

Elliot Lee's avatar
Elliot Lee committed
23 24 25 26
#include "gimage.h"
#include "info_dialog.h"
#include "selection.h"

27 28
#include "gdisplayF.h"

Elliot Lee's avatar
Elliot Lee committed
29 30 31 32 33 34 35
/*
 *  Global variables
 *
 */

/*  some useful macros  */

36
/* unpacking the user scale level (char) */
Elliot Lee's avatar
Elliot Lee committed
37 38
#define  SCALESRC(g)    (g->scale & 0x00ff)
#define  SCALEDEST(g)   (g->scale >> 8)
39

40
/* finding the effective screen resolution (double) */
41 42 43
#define  SCREEN_XRES(g) (g->dot_for_dot? g->gimage->xresolution : monitor_xres)
#define  SCREEN_YRES(g) (g->dot_for_dot? g->gimage->yresolution : monitor_yres)

44
/* calculate scale factors (double) */
45 46 47 48 49 50
#define  SCALEFACTOR_X(g)  ((SCALEDEST(g) * SCREEN_XRES(g)) /          \
			    (SCALESRC(g) * g->gimage->xresolution))
#define  SCALEFACTOR_Y(g)  ((SCALEDEST(g) * SCREEN_YRES(g)) /          \
			    (SCALESRC(g) * g->gimage->yresolution))

/* scale values */
51 52
#define  SCALEX(g,x)    ((int)(x * SCALEFACTOR_X(g)))
#define  SCALEY(g,y)    ((int)(y * SCALEFACTOR_Y(g)))
53 54

/* unscale values */
55 56
#define  UNSCALEX(g,x)  ((int)(x / SCALEFACTOR_X(g)))
#define  UNSCALEY(g,y)  ((int)(y / SCALEFACTOR_Y(g)))
57 58 59 60
/* (and float-returning versions) */
#define  FUNSCALEX(g,x)  ((x / SCALEFACTOR_X(g)))
#define  FUNSCALEY(g,y)  ((y / SCALEFACTOR_Y(g)))

61 62


Elliot Lee's avatar
Elliot Lee committed
63 64

#define LOWPASS(x) ((x>0) ? x : 0)
65
/* #define HIGHPASS(x,y) ((x>y) ? y : x) */ /* unused - == MIN */
Elliot Lee's avatar
Elliot Lee committed
66 67


68
/* maximal width of the string holding the cursor-coordinates for
69 70 71
   the status line */
#define CURSOR_STR_LENGTH 256

72
/* maximal length of the format string for the cursor-coordinates */
73
#define CURSOR_FORMAT_LENGTH 32
74

75 76 77 78 79 80 81 82 83
typedef struct _IdleRenderStruct
{
  int width;
  int height;
  int x;
  int y;
  int basex;
  int basey;
  guint idleid;
84
  /*guint handlerid;*/
85
  gboolean active;
86
  GSList *update_areas;           /*  flushed update areas */
87 88 89 90

} IdleRenderStruct;


Elliot Lee's avatar
Elliot Lee committed
91 92 93 94 95 96 97
struct _GDisplay
{
  int ID;                         /*  unique identifier for this gdisplay     */

  GtkWidget *shell;               /*  shell widget for this gdisplay          */
  GtkWidget *canvas;              /*  canvas widget for this gdisplay         */
  GtkWidget *hsb, *vsb;           /*  widgets for scroll bars                 */
98
  GtkWidget *qmaskoff, *qmaskon;  /*  widgets for qmask buttons               */
Elliot Lee's avatar
Elliot Lee committed
99 100 101
  GtkWidget *hrule, *vrule;       /*  widgets for rulers                      */
  GtkWidget *origin;              /*  widgets for rulers                      */
  GtkWidget *popup;               /*  widget for popup menu                   */
102
  GtkWidget *statusarea;          /*  hbox holding the statusbar and stuff    */
103 104
  GtkWidget *statusbar;           /*  widget for statusbar                    */
  GtkWidget *progressbar;         /*  widget for progressbar                  */
105
  GtkWidget *cursor_label;        /*  widget for cursor position              */
106 107 108 109
  char cursor_format_str [CURSOR_FORMAT_LENGTH]; /* we need a variable format
						  * string because different
						  * units have different number
						  * of decimals               */
110
  GtkWidget *cancelbutton;        /*  widget for cancel button                */
111
  guint progressid;               /*  id of statusbar message for progress    */
Elliot Lee's avatar
Elliot Lee committed
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  */
Elliot Lee's avatar
Elliot Lee committed
116 117 118 119 120 121

  int color_type;                 /*  is this an RGB or GRAY colormap         */

  GtkAdjustment *hsbdata;         /*  horizontal data information             */
  GtkAdjustment *vsbdata;         /*  vertical data information               */

122
  GimpImage *gimage;	          /*  pointer to the associated gimage struct */
Elliot Lee's avatar
Elliot Lee committed
123 124 125 126 127 128 129 130 131 132 133
  int instance;                   /*  the instance # of this gdisplay as      */
                                  /*  taken from the gimage at creation       */

  int depth;   		          /*  depth of our drawables                  */
  int disp_width;                 /*  width of drawing area in the window     */
  int disp_height;                /*  height of drawing area in the window    */
  int disp_xoffset;
  int disp_yoffset;

  int offset_x, offset_y;         /*  offset of display image into raw image  */
  int scale;        	          /*  scale factor from original raw image    */
134
  int dot_for_dot;		  /*  is monitor resolution being ignored?    */
Elliot Lee's avatar
Elliot Lee committed
135 136 137 138 139
  short draw_guides;              /*  should the guides be drawn?             */
  short snap_to_guides;           /*  should the guides be snapped to?        */

  Selection *select;              /*  Selection object                        */

140
  GdkGC *scroll_gc;               /*  GC for scrolling                        */
141

142 143
  GSList *update_areas;           /*  Update areas list                       */
  GSList *display_areas;          /*  Display areas list                      */
Elliot Lee's avatar
Elliot Lee committed
144

145
  int           current_cursor;   /*  Currently installed cursor              */
146

147
  GdkCursorType override_cursor;  /*  Overriding cursor (ie. hourglass)       */
148

149 150
  short draw_cursor;	          /* should we draw software cursor ?         */
  short using_override_cursor;    /* is the cursor overridden? (ie. hourglass)*/
151 152
  int cursor_x;			  /* software cursor X value                  */
  int cursor_y;			  /* software cursor Y value                  */
153
  short proximity;                /* is a device in proximity of gdisplay ?   */
154
  short have_cursor;		  /* is cursor currently drawn ?              */
155
  
156
  IdleRenderStruct idle_render;   /* state of this gdisplay's render thread   */
157
  
158
  GList *cd_list;                 /* color display conversion stuff           */
Elliot Lee's avatar
Elliot Lee committed
159 160 161 162 163 164
};



/* member function declarations */

165
GDisplay * gdisplay_new                    (GimpImage *, unsigned int);
Manish Singh's avatar
Manish Singh committed
166
void       gdisplay_reconnect              (GDisplay *, GimpImage *);
Elliot Lee's avatar
Elliot Lee committed
167 168 169 170 171 172 173 174 175 176 177
void       gdisplay_remove_and_delete      (GDisplay *);
int        gdisplay_mask_value             (GDisplay *, int, int);
int        gdisplay_mask_bounds            (GDisplay *, int *, int *, int *, int *);
void       gdisplay_transform_coords       (GDisplay *, int, int, int *, int *, int);
void       gdisplay_untransform_coords     (GDisplay *, int, int, int *,
					    int *, int, int);
void       gdisplay_transform_coords_f     (GDisplay *, double, double, double *,
					    double *, int);
void       gdisplay_untransform_coords_f   (GDisplay *, double, double, double *,
					    double *, int);
void       gdisplay_install_tool_cursor    (GDisplay *, GdkCursorType);
178
void       gdisplay_install_gimp_tool_cursor (GDisplay *, int);
Elliot Lee's avatar
Elliot Lee committed
179
void       gdisplay_remove_tool_cursor     (GDisplay *);
180 181
void       gdisplay_install_override_cursor(GDisplay *, GdkCursorType);
void       gdisplay_remove_override_cursor (GDisplay *);
Elliot Lee's avatar
Elliot Lee committed
182 183 184 185 186
void       gdisplay_set_menu_sensitivity   (GDisplay *);
void       gdisplay_expose_area            (GDisplay *, int, int, int, int);
void       gdisplay_expose_guide           (GDisplay *, Guide *);
void       gdisplay_expose_full            (GDisplay *);
void       gdisplay_flush                  (GDisplay *);
187
void       gdisplay_flush_now              (GDisplay *);
188
void       gdisplays_finish_draw           (void);
Elliot Lee's avatar
Elliot Lee committed
189 190 191
void       gdisplay_draw_guides            (GDisplay *);
void       gdisplay_draw_guide             (GDisplay *, Guide *, int);
Guide*     gdisplay_find_guide             (GDisplay *, int, int);
192
void       gdisplay_snap_point             (GDisplay *, double , double, double *, double *);
Elliot Lee's avatar
Elliot Lee committed
193
void       gdisplay_snap_rectangle         (GDisplay *, int, int, int, int, int *, int *);
194
void	   gdisplay_update_cursor	   (GDisplay *, int, int);
195
void	   gdisplay_set_dot_for_dot	   (GDisplay *, int);
196
void       gdisplay_resize_cursor_label    (GDisplay *);
197
GDisplay * gdisplays_check_valid           (GDisplay *, GimpImage *);
Elliot Lee's avatar
Elliot Lee committed
198 199 200 201 202

/*  function declarations  */

GDisplay * gdisplay_active                 (void);
GDisplay * gdisplay_get_ID                 (int);
203
void       gdisplay_update_title           (GDisplay*);
204
void       gdisplays_update_title          (GimpImage*);
205
void       gdisplays_resize_cursor_label   (GimpImage*);
206 207 208 209 210
void       gdisplays_update_area           (GimpImage*, int, int, int, int);
void       gdisplays_expose_guides         (GimpImage*);
void       gdisplays_expose_guide          (GimpImage*, Guide *);
void       gdisplays_update_full           (GimpImage*);
void       gdisplays_shrink_wrap           (GimpImage*);
Elliot Lee's avatar
Elliot Lee committed
211
void       gdisplays_expose_full           (void);
212
void       gdisplays_selection_visibility  (GimpImage*, SelectionControl);
Elliot Lee's avatar
Elliot Lee committed
213 214 215
int        gdisplays_dirty                 (void);
void       gdisplays_delete                (void);
void       gdisplays_flush                 (void);
216
void       gdisplays_flush_now             (void);
Manish Singh's avatar
Manish Singh committed
217
void       gdisplay_flush_displays_only    (GDisplay *gdisp); /* no rerender! */
218
void       gdisplays_nav_preview_resized   (void);
Manish Singh's avatar
Manish Singh committed
219 220 221
void       gdisplays_foreach               (GFunc func, gpointer user_data);
void       gdisplays_notify_add            (GFunc func, gpointer user_data);
void       gdisplays_notify_remove         (GFunc func, gpointer user_data);
222

Elliot Lee's avatar
Elliot Lee committed
223
#endif /*  __GDISPLAY_H__  */