| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#ifndef FONTFORGE_GGDKDRAWP_H |
| 31 |
#define FONTFORGE_GGDKDRAWP_H |
| 32 |
|
| 33 |
#include <fontforge-config.h> |
| 34 |
|
| 35 |
|
| 36 |
#include "ffgdk.h" |
| 37 |
#include "fontP.h" |
| 38 |
#include "gdrawP.h" |
| 39 |
|
| 40 |
#if (((GDK_MAJOR_VERSION == 3) && (GDK_MINOR_VERSION >= 22)) || (GDK_MAJOR_VERSION > 3)) |
| 41 |
# define GGDKDRAW_GDK_3_22 |
| 42 |
#endif |
| 43 |
|
| 44 |
#if (((GDK_MAJOR_VERSION == 3) && (GDK_MINOR_VERSION >= 20)) || (GDK_MAJOR_VERSION > 3)) |
| 45 |
# define GGDKDRAW_GDK_3_20 |
| 46 |
#endif |
| 47 |
|
| 48 |
#define GGDKDRAW_ADDREF(x) do { \ |
| 49 |
assert((x)->reference_count >= 0); \ |
| 50 |
(x)->reference_count++; \ |
| 51 |
} while(0) |
| 52 |
|
| 53 |
#define GGDKDRAW_DECREF(x,y) do { \ |
| 54 |
assert((x)->reference_count > 0); \ |
| 55 |
(x)->reference_count--; \ |
| 56 |
if ((x)->reference_count == 0) { \ |
| 57 |
y(x); \ |
| 58 |
} \ |
| 59 |
} while(0) |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define Log(level, ...) LogEx(level, __func__, __FILE__, __LINE__, __VA_ARGS__) |
| 64 |
|
| 65 |
|
| 66 |
enum {LOGNONE = 0, LOGERR = 1, LOGWARN = 2, LOGINFO = 3, LOGDEBUG = 4}; |
| 67 |
|
| 68 |
extern void LogInit(void); |
| 69 |
extern void LogEx(int level, const char *funct, const char *file, int line, const char *fmt, ...) G_GNUC_PRINTF(5, 6); |
| 70 |
extern const char *GdkEventName(int code); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
typedef enum visibility_state VisibilityState; |
| 75 |
typedef struct ggdkwindow *GGDKWindow; |
| 76 |
|
| 77 |
|
| 78 |
typedef struct ggdktimer { |
| 79 |
long time_sec; |
| 80 |
long time_usec; |
| 81 |
int32_t repeat_time; |
| 82 |
GWindow owner; |
| 83 |
void *userdata; |
| 84 |
struct gtimer *next; |
| 85 |
unsigned int active: 1; |
| 86 |
|
| 87 |
unsigned int stopped: 1; |
| 88 |
unsigned int has_differing_repeat_time: 1; |
| 89 |
int reference_count; |
| 90 |
guint glib_timeout_id; |
| 91 |
|
| 92 |
} GGDKTimer; |
| 93 |
|
| 94 |
typedef struct ggdkbuttonstate { |
| 95 |
uint32_t last_press_time; |
| 96 |
GGDKWindow release_w; |
| 97 |
int16_t release_x, release_y; |
| 98 |
int16_t release_button; |
| 99 |
int16_t cur_click; |
| 100 |
int16_t double_time; |
| 101 |
int16_t double_wiggle; |
| 102 |
bool is_pressed; |
| 103 |
} GGDKButtonState; |
| 104 |
|
| 105 |
typedef struct ggdkkeystate { |
| 106 |
GdkEventType type; |
| 107 |
guint state; |
| 108 |
guint keyval; |
| 109 |
guint16 keycode; |
| 110 |
guint8 group; |
| 111 |
} GGDKKeyState; |
| 112 |
|
| 113 |
typedef struct ggdkdndcontext { |
| 114 |
GGDKWindow w; |
| 115 |
int x, y; |
| 116 |
int rx, ry; |
| 117 |
} GGDKDNDContext; |
| 118 |
|
| 119 |
struct seldata { |
| 120 |
int32_t typeatom; |
| 121 |
int32_t cnt; |
| 122 |
int32_t unitsize; |
| 123 |
void *data; |
| 124 |
void *(*gendata)(void *, int32_t *len); |
| 125 |
|
| 126 |
void (*freedata)(void *); |
| 127 |
struct seldata *next; |
| 128 |
}; |
| 129 |
|
| 130 |
typedef struct ggdkselectiondata { |
| 131 |
|
| 132 |
GdkAtom type_atom; |
| 133 |
|
| 134 |
int32_t cnt; |
| 135 |
|
| 136 |
int32_t unit_size; |
| 137 |
|
| 138 |
void *data; |
| 139 |
|
| 140 |
void *(*gendata)(void *, int32_t *len); |
| 141 |
|
| 142 |
void (*freedata)(void *); |
| 143 |
} GGDKSelectionData; |
| 144 |
|
| 145 |
typedef struct ggdkselectioninfo { |
| 146 |
|
| 147 |
GdkAtom sel_atom; |
| 148 |
|
| 149 |
GGDKWindow owner; |
| 150 |
|
| 151 |
guint32 timestamp; |
| 152 |
|
| 153 |
GList_Glib *datalist; |
| 154 |
} GGDKSelectionInfo; |
| 155 |
|
| 156 |
typedef struct ggdkselectiontypes { |
| 157 |
|
| 158 |
guint32 timestamp; |
| 159 |
|
| 160 |
GdkAtom *types; |
| 161 |
|
| 162 |
int32_t len; |
| 163 |
|
| 164 |
GdkAtom sel_atom; |
| 165 |
} GGDKSelectionTypes; |
| 166 |
|
| 167 |
typedef struct ggdkdisplay { |
| 168 |
|
| 169 |
struct displayfuncs *funcs; |
| 170 |
struct font_state *fontstate; |
| 171 |
int16_t res; |
| 172 |
GGDKWindow groot; |
| 173 |
unsigned int default_visual: 1; |
| 174 |
unsigned int do_dithering: 1; |
| 175 |
unsigned int focusfollowsmouse: 1; |
| 176 |
unsigned int top_offsets_set: 1; |
| 177 |
unsigned int endian_mismatch: 1; |
| 178 |
unsigned int macosx_cmd: 1; |
| 179 |
unsigned int twobmouse_win: 1; |
| 180 |
unsigned int devicesinit: 1; |
| 181 |
unsigned int expecting_core_event: 1; |
| 182 |
unsigned int has_xkb: 1; |
| 183 |
unsigned int supports_alpha_images: 1; |
| 184 |
unsigned int supports_alpha_windows: 1; |
| 185 |
int err_flag; |
| 186 |
char *err_report; |
| 187 |
|
| 188 |
|
| 189 |
unsigned int is_space_pressed: 1; |
| 190 |
unsigned int is_dying: 1; |
| 191 |
|
| 192 |
int top_window_count; |
| 193 |
guint32 last_event_time; |
| 194 |
|
| 195 |
GGDKSelectionInfo selinfo[sn_max]; |
| 196 |
GGDKSelectionTypes seltypes; |
| 197 |
int sel_notify_timeout; |
| 198 |
GGDKDNDContext last_dd; |
| 199 |
|
| 200 |
GPtrArray *cursors; |
| 201 |
GGDKWindow dirty_window; |
| 202 |
GList_Glib *timers; |
| 203 |
GHashTable *windows; |
| 204 |
GQueue *mru_windows; |
| 205 |
|
| 206 |
GGDKButtonState bs; |
| 207 |
GGDKKeyState ks; |
| 208 |
GGDKWindow default_icon; |
| 209 |
GPtrArray *transient_stack; |
| 210 |
int restrict_count; |
| 211 |
|
| 212 |
GMainLoop *main_loop; |
| 213 |
GdkDisplay *display; |
| 214 |
GdkScreen *screen; |
| 215 |
GdkWindow *root; |
| 216 |
|
| 217 |
PangoContext *pangoc_context; |
| 218 |
} GGDKDisplay; |
| 219 |
|
| 220 |
struct ggdkwindow { |
| 221 |
|
| 222 |
GGC *ggc; |
| 223 |
GGDKDisplay *display; |
| 224 |
int (*eh)(GWindow, GEvent *); |
| 225 |
GRect pos; |
| 226 |
struct ggdkwindow *parent; |
| 227 |
void *user_data; |
| 228 |
void *widget_data; |
| 229 |
GdkWindow *w; |
| 230 |
unsigned int is_visible: 1; |
| 231 |
unsigned int is_pixmap: 1; |
| 232 |
unsigned int is_toplevel: 1; |
| 233 |
unsigned int visible_request: 1; |
| 234 |
unsigned int is_dying: 1; |
| 235 |
unsigned int is_popup: 1; |
| 236 |
unsigned int disable_expose_requests: 1; |
| 237 |
char *window_type_name; |
| 238 |
|
| 239 |
|
| 240 |
unsigned int is_dlg: 1; |
| 241 |
unsigned int not_restricted: 1; |
| 242 |
unsigned int was_positioned: 1; |
| 243 |
unsigned int restrict_input_to_me: 1; |
| 244 |
unsigned int redirect_chars_to_me: 1; |
| 245 |
unsigned int istransient: 1; |
| 246 |
unsigned int isverytransient: 1; |
| 247 |
unsigned int is_cleaning_up: 1; |
| 248 |
unsigned int is_centered: 1; |
| 249 |
unsigned int is_waiting_for_selection: 1; |
| 250 |
unsigned int is_notified_of_selection: 1; |
| 251 |
unsigned int is_in_paint: 1; |
| 252 |
unsigned int has_had_faked_configure: 1; |
| 253 |
|
| 254 |
int reference_count; |
| 255 |
guint resize_timeout; |
| 256 |
|
| 257 |
GWindow redirect_from; |
| 258 |
struct ggdkwindow *transient_owner; |
| 259 |
GList_Glib *mru_link; |
| 260 |
|
| 261 |
char *window_title; |
| 262 |
GCursor current_cursor; |
| 263 |
|
| 264 |
#ifdef GGDKDRAW_GDK_3_22 |
| 265 |
GdkDrawingContext *drawing_ctx; |
| 266 |
#endif |
| 267 |
cairo_region_t *expose_region; |
| 268 |
cairo_surface_t *cs; |
| 269 |
cairo_t *cc; |
| 270 |
PangoLayout *pango_layout; |
| 271 |
}; |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
bool _GGDKDraw_InitPangoCairo(GGDKWindow gw); |
| 276 |
void _GGDKDraw_CleanupAutoPaint(GGDKDisplay *gdisp); |
| 277 |
|
| 278 |
#ifdef GGDKDRAW_GDK_2 |
| 279 |
GdkPixbuf *_GGDKDraw_Cairo2Pixbuf(cairo_surface_t *cs); |
| 280 |
#else |
| 281 |
cairo_region_t *_GGDKDraw_ExcludeChildRegions(GGDKWindow gw, cairo_region_t *r, bool force); |
| 282 |
#endif |
| 283 |
|
| 284 |
void GGDKDrawPushClip(GWindow w, GRect *rct, GRect *old); |
| 285 |
void GGDKDrawPopClip(GWindow gw, GRect *old); |
| 286 |
void GGDKDrawDrawLine(GWindow w, int32_t x, int32_t y, int32_t xend, int32_t yend, Color col); |
| 287 |
void GGDKDrawDrawArrow(GWindow gw, int32_t x, int32_t y, int32_t xend, int32_t yend, int16_t arrows, Color col); |
| 288 |
void GGDKDrawDrawRect(GWindow gw, GRect *rect, Color col); |
| 289 |
void GGDKDrawFillRect(GWindow gw, GRect *rect, Color col); |
| 290 |
void GGDKDrawFillRoundRect(GWindow gw, GRect *rect, int radius, Color col); |
| 291 |
void GGDKDrawDrawEllipse(GWindow gw, GRect *rect, Color col); |
| 292 |
void GGDKDrawFillEllipse(GWindow gw, GRect *rect, Color col); |
| 293 |
void GGDKDrawDrawArc(GWindow gw, GRect *rect, int32_t sangle, int32_t eangle, Color col); |
| 294 |
void GGDKDrawDrawPoly(GWindow gw, GPoint *pts, int16_t cnt, Color col); |
| 295 |
void GGDKDrawFillPoly(GWindow gw, GPoint *pts, int16_t cnt, Color col); |
| 296 |
void GGDKDrawDrawImage(GWindow gw, GImage *gimg, GRect *src, int32_t x, int32_t y); |
| 297 |
void GGDKDrawDrawGlyph(GWindow gw, GImage *gimg, GRect *src, int32_t x, int32_t y); |
| 298 |
void GGDKDrawDrawImageMagnified(GWindow gw, GImage *gimg, GRect *src, int32_t x, int32_t y, int32_t width, int32_t height); |
| 299 |
|
| 300 |
void GGDKDrawDrawPixmap(GWindow gw1, GWindow gw2, GRect *src, int32_t x, int32_t y); |
| 301 |
|
| 302 |
void GGDKDrawPathStartNew(GWindow w); |
| 303 |
void GGDKDrawPathClose(GWindow w); |
| 304 |
void GGDKDrawPathMoveTo(GWindow w, double x, double y); |
| 305 |
void GGDKDrawPathLineTo(GWindow w, double x, double y); |
| 306 |
void GGDKDrawPathCurveTo(GWindow w, double cx1, double cy1, double cx2, double cy2, double x, double y); |
| 307 |
void GGDKDrawPathStroke(GWindow w, Color col); |
| 308 |
void GGDKDrawPathFill(GWindow w, Color col); |
| 309 |
void GGDKDrawPathFillAndStroke(GWindow w, Color fillcol, Color strokecol); |
| 310 |
void GGDKDrawStartNewSubPath(GWindow w); |
| 311 |
int GGDKDrawFillRuleSetWinding(GWindow w); |
| 312 |
int GGDKDrawDoText8(GWindow w, int32_t x, int32_t y, const char *text, int32_t cnt, Color col, enum text_funcs drawit, struct tf_arg *arg); |
| 313 |
|
| 314 |
void GGDKDrawPushClipOnly(GWindow w); |
| 315 |
void GGDKDrawClipPreserve(GWindow w); |
| 316 |
|
| 317 |
void GGDKDrawGetFontMetrics(GWindow gw, GFont *fi, int *as, int *ds, int *ld); |
| 318 |
void GGDKDrawLayoutInit(GWindow w, char *text, int cnt, GFont *fi); |
| 319 |
void GGDKDrawLayoutDraw(GWindow w, int32_t x, int32_t y, Color fg); |
| 320 |
void GGDKDrawLayoutIndexToPos(GWindow w, int index, GRect *pos); |
| 321 |
int GGDKDrawLayoutXYToIndex(GWindow w, int x, int y); |
| 322 |
void GGDKDrawLayoutExtents(GWindow w, GRect *size); |
| 323 |
void GGDKDrawLayoutSetWidth(GWindow w, int width); |
| 324 |
int GGDKDrawLayoutLineCount(GWindow w); |
| 325 |
int GGDKDrawLayoutLineStart(GWindow w, int l); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
char *_GGDKDrawCocoa_GetClipboardText(void); |
| 332 |
void _GGDKDrawCocoa_SetClipboardText(const char *text); |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
#endif |