iceWing
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
gui
Gpreview.h
Go to the documentation of this file.
1
/* -*- mode: C; tab-width: 4; c-basic-offset: 4; -*- */
2
3
/*
4
* Author: Frank Loemker
5
*
6
* Copyright (C) 1999-2009
7
* Frank Loemker, Applied Computer Science, Faculty of Technology,
8
* Bielefeld University, Germany
9
*
10
* This file is part of iceWing, a graphical plugin shell.
11
*
12
* iceWing is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
16
*
17
* iceWing is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
*/
26
27
#ifndef iw_Gpreview_H
28
#define iw_Gpreview_H
29
30
#include <stdio.h>
31
#include <gtk/gtk.h>
32
#include "
Gcolor.h
"
33
#include "
Gimage.h
"
34
#include "
Gdata.h
"
35
36
/* Identifies data for rendering, e.g.
37
in prev_render_data(), prev_render_list(), and prev_render_set() */
38
typedef
enum
{
/* Types containing the data: */
39
PREV_IMAGE
,
/* prevDataImage */
40
PREV_TEXT
,
/* prevDataText */
41
PREV_LINE
,
/* prevDataLine */
42
PREV_RECT
,
/* prevDataRect */
43
PREV_FRECT
,
/* prevDataRect (filled rectangle) */
44
PREV_REGION
,
/* iwRegion */
45
PREV_POLYGON
,
/* prevDataPoly */
46
PREV_FPOLYGON
,
/* prevDataPoly (filled polygon) */
47
PREV_CIRCLE
,
/* prevDataCircle */
48
PREV_FCIRCLE
,
/* prevDataCircle (filled circle) */
49
PREV_ELLIPSE
,
/* prevDataEllipse */
50
PREV_COMINFO
,
/* iwRegCOMinfo */
51
PREV_LINE_F
,
/* prevDataLineF */
52
PREV_RECT_F
,
/* prevDataRectF */
53
PREV_FRECT_F
,
/* prevDataRectF (filled rectangle) */
54
PREV_POLYGON_F
,
/* prevDataPolyF */
55
PREV_FPOLYGON_F
,
/* prevDataPolyF (filled polygon) */
56
PREV_CIRCLE_F
,
/* prevDataCircleF */
57
PREV_FCIRCLE_F
,
/* prevDataCircleF (filled circle) */
58
PREV_ELLIPSE_F
,
/* prevDataEllipseF */
59
PREV_NEW
= 100
/* For prev_renderdb_register() to add a new type,
60
(100 to have some free values before to add new PREV_...) */
61
}
prevType
;
62
63
/* User event in a preview window,
64
see prev_signal_connect() and prev_signal_connect2() */
65
typedef
enum
{
66
PREV_BUTTON_PRESS
= 1 << 0,
67
PREV_BUTTON_RELEASE
= 1 << 1,
68
PREV_BUTTON_MOTION
= 1 << 2,
69
PREV_KEY_PRESS
= 1 << 3,
70
PREV_KEY_RELEASE
= 1 << 4
71
}
prevEvent
;
72
73
typedef
enum
{
74
SAVE_NONE
,
75
SAVE_RENDER
,
76
SAVE_ORIG
,
77
SAVE_SEQ
,
78
SAVE_ORIGSEQ
79
}
prevSave
;
80
81
typedef
struct
_prevSettings
prevSettings
;
82
typedef
struct
_prevBuffer
prevBuffer
;
83
84
typedef
struct
prevEventAny
{
85
prevEvent
type
;
86
}
prevEventAny
;
87
typedef
struct
prevEventButton
{
88
prevEvent
type
;
89
guint32
time
;
/* Time this event happend */
90
guint
state
;
/* State of modifier keys (GDK_SHIFT_MASK, ...) */
91
int
x
,
y
;
/* Coordinates without zooming and panning */
92
int
x_orig
,
y_orig
;
/* Original screen coordinates */
93
guint
button
;
/* Number of pressed button */
94
}
prevEventButton
;
95
typedef
struct
prevEventMotion
{
96
prevEvent
type
;
97
guint32
time
;
/* Time this event happend */
98
guint
state
;
/* State of modifier keys (GDK_SHIFT_MASK, ...) */
99
int
x
,
y
;
/* Coordinates without zooming and panning */
100
int
x_orig
,
y_orig
;
/* Original screen coordinates */
101
guint
button
;
/* Number of pressed button */
102
}
prevEventMotion
;
103
typedef
struct
prevEventKey
{
104
prevEvent
type
;
105
guint32
time
;
/* Time this event happend */
106
guint
state
;
/* State of modifier keys (GDK_SHIFT_MASK, ...) */
107
guint
keyval
;
/* Pressed key (GDK_A, ..., GDK_Shift_L, ...) */
108
int
length
;
/* Length of string */
109
char
*
string
;
/* Text result from keyval */
110
}
prevEventKey
;
111
typedef
union
prevEventData
{
112
prevEventAny
any
;
113
prevEventButton
button
;
114
prevEventMotion
motion
;
115
prevEventKey
key
;
116
}
prevEventData
;
117
118
typedef
void (*
prevButtonFunc
) (
prevBuffer
*b,
prevEvent
signal,
int
x,
int
y,
void
*data);
119
typedef
void (*
prevSignalFunc
) (
prevBuffer
*b,
prevEventData
*event,
void
*data);
120
121
/* PRIVATE */
122
typedef
struct
{
123
int
width
, height;
/* Size of largest rendering since last window clear */
124
guchar
bg_r
, bg_g, bg_b;
/* Color for background clearing */
125
int
thickness
;
126
}
prevGC
;
127
128
/* A window which can be used to render/visualize any results.
129
Created by prev_new_window(). */
130
struct
_prevBuffer
{
131
guchar *
buffer
;
/* Buffer for the to be displayed image */
132
int
width
,
height
;
/* Size of buffer */
133
gboolean
gray
;
/* Color or Grayscale */
134
char
*
title
;
/* Title of the window */
135
136
int
x
,
y
;
/* Left upper edge of part displayed in the window */
137
float
zoom
;
/* Zoom factor, if 0 fit to window is used */
138
139
GtkWidget *
window
;
/* Window for the to be displayed buffer,
140
if !=NULL the preview window is open */
141
/* PRIVATE */
142
gboolean
save_rdata
;
/* Save original render data? */
143
GArray *
rdata
;
/* Saved render data */
144
145
GtkWidget *
drawing
;
/* Destination for gdk_draw_rgb_image() */
146
int
draw_width
,
draw_height
;
/* Size of drawable */
147
GdkGC *
g_gc
;
/* gc for gdk_draw_rgb_image() */
148
149
GHashTable *
opts
;
/* Options data for this window, see prev_opts_xxx() */
150
151
GtkWidget *
menu
;
/* Context menu */
152
GtkItemFactory *
factory
;
/* The item factory for the context menu */
153
GtkAccelGroup *
accel
;
/* The window accelerator group */
154
prevSettings
*
settings
;
/* Data for the settings window */
155
156
GSList *
cback
;
/* List of callbacks for this window */
157
158
prevGC
gc
;
/* Render options */
159
160
guint
expose_id
;
/* ID of the expose idle-handler */
161
prevSave
save
;
/* !=SAVE_NONE -> prev_render() saves the image */
162
GtkWidget *
save_widget
;
/* Pointer to the active menu entry (for SAVE SEQ) */
163
iwMovie
*
save_avifile
;
164
gboolean
save_done
;
/* Set in prev_render() if save!=SAVE_NONE, */
165
/* reseted in prev_draw_buffer() */
166
int
save_cnt
;
/* How many times the buffer was saved? */
167
168
prevBuffer
*
next
;
169
};
170
171
typedef
struct
{
172
char
*
fname
;
/* Destination file name */
173
FILE *
file
;
/* Destination file */
174
float
zoom
;
175
guiData
rdata
;
/* Entry for the renderer to store persistent data */
176
iwImgFormat
format
;
177
}
prevVectorSave
;
178
179
typedef
void (*
renderDbOptsFunc
) (
prevBuffer
*b);
180
typedef
void (*
renderDbFreeFunc
) (
void
*data);
181
typedef
void
* (*renderDbCopyFunc) (
const
void
*data);
182
typedef
void (*
renderDbRenderFunc
) (
prevBuffer
*b,
const
void
*data,
int
disp_mode);
183
typedef
char
* (*renderDbInfoFunc) (
prevBuffer
*b,
const
void
*data,
int
disp_mode,
int
x,
int
y,
int
radius);
184
typedef
iwImgStatus
(*
renderDbVectorFunc
) (
prevBuffer
*b,
prevVectorSave
*save,
185
const
void
*data,
int
disp_mode);
186
187
/* prev_set_render_size(prevBuffer *b, int width, int height)
188
Update render_{width|height} in buffer b. */
189
#define prev_set_render_size(b,width,height) G_STMT_START { \
190
if ((width) >= 0) (b)->gc.width = (width); \
191
if ((height) >= 0) (b)->gc.height = (height); \
192
} G_STMT_END
193
194
#ifdef __cplusplus
195
extern
"C"
{
196
#endif
197
198
/*********************************************************************
199
Must be called on access of a prevBuffer->buffer.
200
Attention: gdk-/X11-mutex must not be locked before locking this
201
mutex.
202
*********************************************************************/
203
void
prev_buffer_lock
(
void
);
204
void
prev_buffer_unlock
(
void
);
205
206
/*********************************************************************
207
Register a new render type 'type'.
208
If 'type' == PREV_NEW use the first unused value and return it.
209
*********************************************************************/
210
prevType
prev_renderdb_register
(
prevType
type,
renderDbOptsFunc
o_fkt,
211
renderDbFreeFunc
f_fkt,
renderDbCopyFunc
c_fkt,
212
renderDbRenderFunc
r_fkt);
213
214
/*********************************************************************
215
Register a function which is called for the "Info Window".
216
*********************************************************************/
217
void
prev_renderdb_register_info
(
prevType
type,
renderDbInfoFunc
i_fkt);
218
219
/*********************************************************************
220
Register a function for saving in a vector format.
221
*********************************************************************/
222
void
prev_renderdb_register_vector
(
prevType
type,
renderDbVectorFunc
v_fkt);
223
224
/*********************************************************************
225
Store a value associated to type and return its address.
226
free_data==TRUE: If the window b is freed, data is freed by calling
227
free().
228
Used in renderDbOptsFunc() to store the value of the menu entry.
229
*********************************************************************/
230
void
**
prev_opts_store
(
prevBuffer
*b,
prevType
type,
231
void
*data, gboolean free_data);
232
/*********************************************************************
233
Get the value associated to type stored with prev_opts_store().
234
*********************************************************************/
235
void
**
prev_opts_get
(
prevBuffer
*b,
prevType
type);
236
/*********************************************************************
237
Append option widgets to the window specific menu according to
238
the given types. Last argument must be '-1'.
239
*********************************************************************/
240
void
prev_opts_append
(
prevBuffer
*b,
prevType
type, ...);
241
242
/*********************************************************************
243
Return zoom factor to get something of size
244
b->gc.width x b->gc.height into buffer b.
245
*********************************************************************/
246
float
prev_get_zoom
(
prevBuffer
*b);
247
248
/*********************************************************************
249
If b->save!=SAVE_NONE:
250
img!=NULL: Save image img.
251
img==NULL: Save image b->buffer (size: b->width x b->height).
252
Attention: prev_buffer_(un)lock is called.
253
*********************************************************************/
254
void
prev_chk_save
(
prevBuffer
*b,
const
iwImage
*img);
255
256
/*********************************************************************
257
If b->window is open, display b->buffer.
258
*********************************************************************/
259
void
prev_draw_buffer
(
prevBuffer
*b);
260
261
/*********************************************************************
262
If zoom >= 0, change zoom level of the preview.
263
If x >= 0 or y >= 0 pan the preview to that position.
264
*********************************************************************/
265
void
prev_pan_zoom
(
prevBuffer
*b,
int
x,
int
y,
float
zoom);
266
267
/*********************************************************************
268
Call cback with data as last argument if one of the signals
269
specified with sigset occured.
270
*********************************************************************/
271
void
prev_signal_connect
(
prevBuffer
*b,
prevEvent
sigset,
272
prevButtonFunc
cback,
void
*data);
273
void
prev_signal_connect2
(
prevBuffer
*b,
prevEvent
sigset,
274
prevSignalFunc
cback,
void
*data);
275
276
/*********************************************************************
277
Return the page number for the preview settings window. Allows to
278
create any widgets with the help of the opts_() functions.
279
*********************************************************************/
280
int
prev_get_page
(
prevBuffer
*b);
281
282
/*********************************************************************
283
Close preview window b (if necessary), remove it from the CList and
284
free its memory.
285
*********************************************************************/
286
void
prev_free_window
(
prevBuffer
*b);
287
288
/*********************************************************************
289
Initialise a new preview window (Title: title, size: width x height,
290
depth: 24bit (gray==FALSE) or 8 Bit (gray==TRUE)).
291
show == TRUE: The window is shown immediately.
292
width, heigth < 0 : Default width, height is used.
293
title contains '.' (a'.'b): Window is shown in the list of windows
294
under node a with entry b.
295
*********************************************************************/
296
prevBuffer
*
prev_new_window
(
const
char
*title,
int
width,
int
height,
297
gboolean gray, gboolean show);
298
299
/*********************************************************************
300
Copy the content of a preview window into an iceWing image. The
301
preview window needs to be open (buffer->window != NULL), otherwise
302
NULL is returned. If save_full the full visible preview window size
303
is used, otherwise the size of the displayed data is used.
304
*********************************************************************/
305
iwImage
*
prev_copy_to_image
(
prevBuffer
*b, gboolean save_full);
306
307
#ifdef __cplusplus
308
}
309
#endif
310
311
#endif
/* iw_Gpreview_H */
Generated by
1.8.1