| 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 |
#ifndef FONTFORGE_GDRAWP_H |
| 29 |
#define FONTFORGE_GDRAWP_H |
| 30 |
|
| 31 |
#include "basics.h" |
| 32 |
|
| 33 |
#include "gdraw.h" |
| 34 |
|
| 35 |
typedef struct gcol { |
| 36 |
int16_t red, green, blue; |
| 37 |
uint32_t pixel; |
| 38 |
} GCol; |
| 39 |
|
| 40 |
struct revcol { |
| 41 |
int16_t red, green, blue; |
| 42 |
uint32_t index; |
| 43 |
uint8_t dist; |
| 44 |
struct revcol *next; |
| 45 |
}; |
| 46 |
|
| 47 |
struct revitem { |
| 48 |
struct revcol *cols[2]; |
| 49 |
int16_t cnt; |
| 50 |
struct revcmap *sub; |
| 51 |
}; |
| 52 |
|
| 53 |
struct revcmap { |
| 54 |
int16_t range; |
| 55 |
|
| 56 |
int16_t side_cnt; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
int16_t side_shift; |
| 61 |
int16_t div_mul, div_shift, div_add; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
unsigned int is_grey: 1; |
| 67 |
Color mask; |
| 68 |
struct revitem *cube; |
| 69 |
GCol *greys; |
| 70 |
}; |
| 71 |
|
| 72 |
typedef struct { |
| 73 |
unsigned char byte1; |
| 74 |
unsigned char byte2; |
| 75 |
} GChar2b; |
| 76 |
|
| 77 |
struct gchr_transform { |
| 78 |
uint32_t oldstate; |
| 79 |
uint32_t newstate; |
| 80 |
unichar_t resch; |
| 81 |
}; |
| 82 |
|
| 83 |
struct gchr_lookup { |
| 84 |
int cnt; |
| 85 |
struct gchr_transform *transtab; |
| 86 |
}; |
| 87 |
|
| 88 |
struct gchr_accents { |
| 89 |
unichar_t accent; |
| 90 |
uint32_t mask; |
| 91 |
}; |
| 92 |
|
| 93 |
enum text_funcs { tf_width, tf_drawit, tf_rect, tf_stopat, tf_stopbefore, tf_stopafter }; |
| 94 |
struct tf_arg { GTextBounds size; int width, maxwidth; unichar_t *last; char *utf8_last; int first; int dont_replace; }; |
| 95 |
|
| 96 |
struct gwindow { |
| 97 |
GGC *ggc; |
| 98 |
GDisplay *display; |
| 99 |
int (*eh)(GWindow,GEvent *); |
| 100 |
GRect pos; |
| 101 |
GWindow parent; |
| 102 |
void *user_data; |
| 103 |
struct gwidgetdata *widget_data; |
| 104 |
void *native_window; |
| 105 |
unsigned int is_visible: 1; |
| 106 |
unsigned int is_pixmap: 1; |
| 107 |
unsigned int is_toplevel: 1; |
| 108 |
unsigned int visible_request: 1; |
| 109 |
unsigned int is_dying: 1; |
| 110 |
unsigned int is_popup: 1; |
| 111 |
unsigned int disable_expose_requests: 1; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
char* window_type_name; |
| 118 |
}; |
| 119 |
|
| 120 |
struct ginput_context { |
| 121 |
GWindow w; |
| 122 |
enum gic_style style; |
| 123 |
void *ic; |
| 124 |
struct ginput_context *next; |
| 125 |
}; |
| 126 |
|
| 127 |
struct gtimer { |
| 128 |
long time_sec; |
| 129 |
long time_usec; |
| 130 |
int32_t repeat_time; |
| 131 |
GWindow owner; |
| 132 |
void *userdata; |
| 133 |
struct gtimer *next; |
| 134 |
unsigned int active: 1; |
| 135 |
}; |
| 136 |
|
| 137 |
struct gdisplay { |
| 138 |
struct displayfuncs *funcs; |
| 139 |
struct font_state *fontstate; |
| 140 |
int16_t res; |
| 141 |
GWindow groot; |
| 142 |
unsigned int default_visual: 1; |
| 143 |
unsigned int do_dithering: 1; |
| 144 |
unsigned int focusfollowsmouse: 1; |
| 145 |
unsigned int top_offsets_set: 1; |
| 146 |
unsigned int endian_mismatch: 1; |
| 147 |
unsigned int macosx_cmd: 1; |
| 148 |
unsigned int twobmouse_win: 1; |
| 149 |
unsigned int devicesinit: 1; |
| 150 |
unsigned int expecting_core_event: 1; |
| 151 |
unsigned int has_xkb: 1; |
| 152 |
unsigned int supports_alpha_images: 1; |
| 153 |
unsigned int supports_alpha_windows: 1; |
| 154 |
int err_flag; |
| 155 |
char * err_report; |
| 156 |
|
| 157 |
}; |
| 158 |
#define PointToPixel(points,res) (((points)*(res)+36)/72) |
| 159 |
#define PointTenthsToPixel(pointtenths,res) ((((pointtenths)*(res)+36)/72)/10) |
| 160 |
#define PixelToPoint(pixels,res) (((pixels)*72+(res)/2)/(res)) |
| 161 |
#define PixelToPointTenths(pixels,res) (((pixels)*720+(res)/2)/(res)) |
| 162 |
|
| 163 |
struct font_data; |
| 164 |
|
| 165 |
struct displayfuncs { |
| 166 |
void (*init)(GDisplay *); |
| 167 |
|
| 168 |
void (*setDefaultIcon)(GWindow); |
| 169 |
|
| 170 |
GWindow (*createTopWindow)(GDisplay *, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *); |
| 171 |
GWindow (*createSubWindow)(GWindow, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *); |
| 172 |
GWindow (*createPixmap)(GDisplay *, GWindow similar, uint16_t width, uint16_t height); |
| 173 |
GWindow (*createBitmap)(GDisplay *, uint16_t width, uint16_t height, uint8_t *data); |
| 174 |
GCursor (*createCursor)(GWindow src, GWindow mask, Color fg, Color bg, int16_t x, int16_t y); |
| 175 |
void (*destroyWindow)(GWindow); |
| 176 |
void (*destroyCursor)(GDisplay *,GCursor); |
| 177 |
int (*nativeWindowExists)(GDisplay *,void *native_window); |
| 178 |
void (*setZoom)(GWindow,GRect *size,enum gzoom_flags flags); |
| 179 |
void (*setWindowBackground)(GWindow,Color); |
| 180 |
int (*setDither)(GDisplay *,int); |
| 181 |
|
| 182 |
void (*setVisible)(GWindow,int); |
| 183 |
void (*move)(GWindow,int32_t,int32_t); |
| 184 |
void (*trueMove)(GWindow,int32_t,int32_t); |
| 185 |
void (*resize)(GWindow,int32_t,int32_t); |
| 186 |
void (*moveResize)(GWindow,int32_t,int32_t,int32_t,int32_t); |
| 187 |
void (*raise)(GWindow); |
| 188 |
void (*setWindowTitles8)(GWindow, const char *title, const char *icontitle); |
| 189 |
char *(*getWindowTitle8)(GWindow); |
| 190 |
void (*setTransientFor)(GWindow, GWindow); |
| 191 |
void (*getPointerPos)(GWindow,GEvent *); |
| 192 |
GWindow (*getPointerWindow)(GWindow); |
| 193 |
void (*setCursor)(GWindow, GCursor); |
| 194 |
GCursor (*getCursor)(GWindow); |
| 195 |
void (*translateCoordinates)(GWindow from, GWindow to, GPoint *pt); |
| 196 |
|
| 197 |
void (*beep)(GDisplay *); |
| 198 |
|
| 199 |
void (*pushClip)(GWindow, GRect *rct, GRect *old); |
| 200 |
void (*popClip)(GWindow, GRect *old); |
| 201 |
|
| 202 |
void (*drawLine)(GWindow, int32_t x,int32_t y, int32_t xend,int32_t yend, Color col); |
| 203 |
void (*drawArrow)(GWindow, int32_t x,int32_t y, int32_t xend,int32_t yend, int16_t arrows, Color col); |
| 204 |
void (*drawRect)(GWindow, GRect *rect, Color col); |
| 205 |
void (*fillRect)(GWindow, GRect *rect, Color col); |
| 206 |
void (*fillRoundRect)(GWindow, GRect *rect, int radius, Color col); |
| 207 |
void (*drawElipse)(GWindow, GRect *rect, Color col); |
| 208 |
void (*fillElipse)(GWindow, GRect *rect, Color col); |
| 209 |
void (*drawArc)(GWindow, GRect *rect, int32_t sangle, int32_t eangle, Color col); |
| 210 |
void (*drawPoly)(GWindow, GPoint *pts, int16_t cnt, Color col); |
| 211 |
void (*fillPoly)(GWindow, GPoint *pts, int16_t cnt, Color col); |
| 212 |
void (*scroll)(GWindow, GRect *rect, int32_t hor, int32_t vert); |
| 213 |
|
| 214 |
void (*drawImage)(GWindow, GImage *, GRect *src, int32_t x, int32_t y); |
| 215 |
void (*drawGlyph)(GWindow, GImage *, GRect *src, int32_t x, int32_t y); |
| 216 |
void (*drawImageMag)(GWindow, GImage *, GRect *src, int32_t x, int32_t y, int32_t width, int32_t height); |
| 217 |
void (*drawPixmap)(GWindow, GWindow, GRect *src, int32_t x, int32_t y); |
| 218 |
|
| 219 |
GIC *(*createInputContext)(GWindow, enum gic_style); |
| 220 |
void (*setGIC)(GWindow, GIC *, int x, int y); |
| 221 |
int (*keyState)(GWindow w, int keysym); |
| 222 |
|
| 223 |
void (*grabSelection)(GWindow w,enum selnames sel); |
| 224 |
void (*addSelectionType)(GWindow w,enum selnames sel,char *type, |
| 225 |
void *data,int32_t cnt,int32_t unitsize,void *(*gendata)(void *,int32_t *len), |
| 226 |
void (*freedata)(void *)); |
| 227 |
void *(*requestSelection)(GWindow w,enum selnames sn, char *typename, int32_t *len); |
| 228 |
int (*selectionHasType)(GWindow w,enum selnames sn, char *typename); |
| 229 |
void (*bindSelection)(GDisplay *disp,enum selnames sn, char *atomname); |
| 230 |
int (*selectionHasOwner)(GDisplay *disp,enum selnames sn); |
| 231 |
|
| 232 |
void (*pointerUngrab)(GDisplay *); |
| 233 |
void (*pointerGrab)(GWindow); |
| 234 |
void (*requestExpose)(GWindow,GRect *,int); |
| 235 |
void (*forceUpdate)(GWindow); |
| 236 |
void (*sync)(GDisplay *); |
| 237 |
void (*skipMouseMoveEvents)(GWindow, GEvent *); |
| 238 |
void (*processPendingEvents)(GDisplay *); |
| 239 |
void (*processOneEvent)(GDisplay *); |
| 240 |
void (*eventLoop)(GDisplay *); |
| 241 |
void (*postEvent)(GEvent *e); |
| 242 |
void (*postDragEvent)(GWindow w,GEvent *mouse,enum event_type et); |
| 243 |
int (*requestDeviceEvents)(GWindow w,int devcnt,struct gdeveventmask *de); |
| 244 |
int (*shortcutKeyMatches)(const GEvent *e, unichar_t ch); |
| 245 |
|
| 246 |
GTimer *(*requestTimer)(GWindow w,int32_t time_from_now,int32_t frequency, void *userdata); |
| 247 |
void (*cancelTimer)(GTimer *timer); |
| 248 |
|
| 249 |
void (*getFontMetrics)(GWindow,GFont *,int *,int *,int *); |
| 250 |
|
| 251 |
void (*startNewPath)(GWindow w); |
| 252 |
void (*closePath)(GWindow w); |
| 253 |
void (*moveto)(GWindow w,double x, double y); |
| 254 |
void (*lineto)(GWindow w,double x, double y); |
| 255 |
void (*curveto)(GWindow w, double cx1,double cy1, double cx2,double cy2, double x, double y); |
| 256 |
void (*stroke)(GWindow w, Color col); |
| 257 |
void (*fill)(GWindow w, Color col); |
| 258 |
void (*fillAndStroke)(GWindow w, Color fillcol,Color strokecol); |
| 259 |
|
| 260 |
void (*layoutInit)(GWindow w, char *text, int cnt, GFont *fi); |
| 261 |
void (*layoutDraw)(GWindow w, int32_t x, int32_t y, Color fg); |
| 262 |
void (*layoutIndexToPos)(GWindow w, int index, GRect *pos); |
| 263 |
int (*layoutXYToIndex)(GWindow w, int x, int y); |
| 264 |
void (*layoutExtents)(GWindow w, GRect *size); |
| 265 |
void (*layoutSetWidth)(GWindow w, int width); |
| 266 |
int (*layoutLineCount)(GWindow w); |
| 267 |
int (*layoutLineStart)(GWindow w,int line); |
| 268 |
void (*startNewSubPath)(GWindow w); |
| 269 |
int (*fillRuleSetWinding)(GWindow w); |
| 270 |
|
| 271 |
int (*doText8)(GWindow w, int32_t x, int32_t y, const char *text, int32_t cnt, Color col, enum text_funcs drawit, struct tf_arg *arg); |
| 272 |
|
| 273 |
void (*PushClipOnly)(GWindow w); |
| 274 |
void (*ClipPreserve)(GWindow w); |
| 275 |
}; |
| 276 |
|
| 277 |
extern int16_t div_tables[257][2]; |
| 278 |
|
| 279 |
extern void GDrawIErrorRun(const char *fmt,...); |
| 280 |
extern void GDrawIError(const char *fmt,...); |
| 281 |
|
| 282 |
extern void _GXDraw_DestroyDisplay(GDisplay * gdisp); |
| 283 |
extern GDisplay *_GXDraw_CreateDisplay(char *displayname,char *programname); |
| 284 |
extern void _GGDKDraw_DestroyDisplay(GDisplay *disp); |
| 285 |
extern GDisplay *_GGDKDraw_CreateDisplay(char *displayname, char *programname); |
| 286 |
extern void _GDraw_InitError(GDisplay *); |
| 287 |
extern void _GDraw_ComposeChars(GDisplay *gdisp,GEvent *gevent); |
| 288 |
|
| 289 |
extern void _GDraw_getimageclut(struct _GImage *base, struct gcol *clut); |
| 290 |
extern const GCol *_GImage_GetIndexedPixel(Color col,RevCMap *rev); |
| 291 |
extern const GCol *_GImage_GetIndexedPixelPrecise(Color col,RevCMap *rev); |
| 292 |
|
| 293 |
#endif |