1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
3  *
4  * gimppreview.h
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #if !defined (__GIMP_WIDGETS_H_INSIDE__) && !defined (GIMP_WIDGETS_COMPILATION)
22 #error "Only <libgimpwidgets/gimpwidgets.h> can be included directly."
23 #endif
24 
25 #ifndef __GIMP_PREVIEW_H__
26 #define __GIMP_PREVIEW_H__
27 
28 G_BEGIN_DECLS
29 
30 
31 /* For information look into the C source or the html documentation */
32 
33 
34 #define GIMP_TYPE_PREVIEW            (gimp_preview_get_type ())
35 #define GIMP_PREVIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PREVIEW, GimpPreview))
36 #define GIMP_PREVIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW, GimpPreviewClass))
37 #define GIMP_IS_PREVIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PREVIEW))
38 #define GIMP_IS_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW))
39 #define GIMP_PREVIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PREVIEW, GimpPreviewClass))
40 
41 
42 typedef struct _GimpPreviewClass  GimpPreviewClass;
43 
44 struct _GimpPreview
45 {
46   GtkBox        parent_instance;
47 
48   gboolean      update_preview;
49 
50   /*< protected >*/
51   GtkWidget    *area;
52   GtkWidget    *table;
53   GtkWidget    *frame;
54   GtkWidget    *toggle;
55   GdkCursor    *cursor_busy;
56   GdkCursor    *default_cursor;
57 
58   /*< private >*/
59   gint          xoff, yoff;
60   gint          xmin, xmax, ymin, ymax;
61   gint          width, height;
62 
63   guint         timeout_id;
64 };
65 
66 struct _GimpPreviewClass
67 {
68   GtkBoxClass  parent_class;
69 
70   /* virtual methods */
71   void   (* draw)        (GimpPreview     *preview);
72   void   (* draw_thumb)  (GimpPreview     *preview,
73                           GimpPreviewArea *area,
74                           gint             width,
75                           gint             height);
76   void   (* draw_buffer) (GimpPreview     *preview,
77                           const guchar    *buffer,
78                           gint             rowstride);
79   void   (* set_cursor)  (GimpPreview     *preview);
80 
81   /* signal */
82   void   (* invalidated) (GimpPreview     *preview);
83 
84   /* virtual methods */
85   void   (* transform)   (GimpPreview     *preview,
86                           gint             src_x,
87                           gint             src_y,
88                           gint            *dest_x,
89                           gint            *dest_y);
90   void   (* untransform) (GimpPreview     *preview,
91                           gint             src_x,
92                           gint             src_y,
93                           gint            *dest_x,
94                           gint            *dest_y);
95 
96   /* Padding for future expansion */
97   void (* _gimp_reserved3) (void);
98   void (* _gimp_reserved4) (void);
99 };
100 
101 
102 GType       gimp_preview_get_type           (void) G_GNUC_CONST;
103 
104 void        gimp_preview_set_update         (GimpPreview  *preview,
105                                              gboolean      update);
106 gboolean    gimp_preview_get_update         (GimpPreview  *preview);
107 
108 void        gimp_preview_set_bounds         (GimpPreview  *preview,
109                                              gint          xmin,
110                                              gint          ymin,
111                                              gint          xmax,
112                                              gint          ymax);
113 
114 void        gimp_preview_get_position       (GimpPreview  *preview,
115                                              gint         *x,
116                                              gint         *y);
117 void        gimp_preview_get_size           (GimpPreview  *preview,
118                                              gint         *width,
119                                              gint         *height);
120 
121 void        gimp_preview_transform          (GimpPreview *preview,
122                                              gint         src_x,
123                                              gint         src_y,
124                                              gint        *dest_x,
125                                              gint        *dest_y);
126 void        gimp_preview_untransform        (GimpPreview *preview,
127                                              gint         src_x,
128                                              gint         src_y,
129                                              gint        *dest_x,
130                                              gint        *dest_y);
131 
132 GtkWidget * gimp_preview_get_area           (GimpPreview  *preview);
133 
134 void        gimp_preview_draw               (GimpPreview  *preview);
135 void        gimp_preview_draw_buffer        (GimpPreview  *preview,
136                                              const guchar *buffer,
137                                              gint          rowstride);
138 
139 void        gimp_preview_invalidate         (GimpPreview  *preview);
140 
141 void        gimp_preview_set_default_cursor (GimpPreview  *preview,
142                                              GdkCursor    *cursor);
143 
144 GtkWidget * gimp_preview_get_controls       (GimpPreview  *preview);
145 
146 
147 G_END_DECLS
148 
149 #endif /* __GIMP_PREVIEW_H__ */
150