/* Copyright (C) 2000-2012 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FONTFORGE_GDRAW_H #define FONTFORGE_GDRAW_H #include "gimage.h" #include "gresource.h" typedef struct font_instance FontInstance, GFont; enum gic_style { gic_overspot=2, gic_root=1, gic_hidden=0, gic_orlesser=4, gic_type=3 }; typedef struct ginput_context GIC; typedef struct ggc { struct gwindow *w; Color fg; Color bg; GRect clip; unsigned int bitmap_col: 1; /* window is mapped for bitmap */ int16_t skip_len, dash_len; int16_t line_width; int16_t ts; int32_t ts_xoff, ts_yoff; int dash_offset; GFont *fi; } GGC; typedef struct gtextbounds { int16_t lbearing; /* of first character */ /* origin to left edge of first char's raster */ int32_t rbearing; /* origin to right edge of last char's raster */ int16_t as,ds; /* maximum ascent and maximum descent */ /* (both numbers will be positive for "g" */ /* so total height = as+ds */ int16_t fas, fds; /* font ascent and descent */ /* total width = rbearing-lbearing */ int32_t width; /* above are for the bounding rect, not the text */ /* "width" which may be totally different */ } GTextBounds; enum selnames { sn_primary, sn_clipboard, sn_drag_and_drop, sn_user1, sn_user2, sn_max }; typedef struct gwindow *GWindow; typedef struct gdisplay GDisplay; typedef struct gtimer GTimer; enum keystate_mask { ksm_shift=1, ksm_capslock=2, ksm_control=4, ksm_meta=8, ksm_cmdsuse=0x8, /* Suse X on a Mac maps command to meta. As of Mac 10.2, the command key is 0x10 */ /* In 10.0 the command key was 0x20 */ ksm_cmdmacosx=0x10, /* But not the command key under suse ppc linux*/ ksm_numlock=0x10, /* It's numlock on my 386 system */ ksm_super=0x40, /* RedHat mask for the key with the windows flag on it */ ksm_hyper=0x80, /* Both Suse and Mac OS/X.2 now map option to 0x2000, but under 10.0 it was meta */ /* Under 10.4 it is the meta mask again */ /* Under 10.6 it is 0x2000 again. I wish they'd be consistent */ ksm_option=0x2000, /* sometimes */ ksm_menumask=(ksm_control|ksm_meta|ksm_cmdmacosx|0xf0), ksm_button1=(1<<8), ksm_button2=(1<<9), ksm_button3=(1<<10), ksm_button4=(1<<11), ksm_button5=(1<<12), ksm_buttons=(ksm_button1|ksm_button2|ksm_button3|ksm_button4|ksm_button5) }; enum mnemonic_focus { mf_normal, mf_tab, mf_mnemonic, mf_shortcut }; enum event_type { et_noevent = -1, et_char, et_charup, // is 1 et_mousemove, et_mousedown, et_mouseup, et_crossing, /* these four are assumed to be consecutive */ et_focus, // is 7 et_expose, et_visibility, et_resize, et_timer, et_close/*request by user*/, et_create, et_map, et_destroy/*window being freed*/, et_selclear, et_drag, et_dragout, et_drop, et_lastnativeevent=et_drop, et_controlevent, et_user }; enum visibility_state { vs_unobscured, vs_partially, vs_obscured }; enum et_subtype { et_buttonpress, et_buttonactivate, et_radiochanged, et_listselected, et_listdoubleclick, et_scrollbarchange, et_textchanged, et_textfocuschanged, et_save, et_lastsubtype }; enum sb { et_sb_top, et_sb_uppage, et_sb_up, et_sb_left=et_sb_up, et_sb_down, et_sb_right=et_sb_down, et_sb_downpage, et_sb_bottom, et_sb_thumb, et_sb_thumbrelease, et_sb_halfup, et_sb_halfdown }; struct sbevent { enum sb type; int32_t pos; }; typedef struct gevent { enum event_type type; #define _GD_EVT_CHRLEN 10 GWindow w; union { struct { char *device; /* for wacom devices */ uint32_t time; uint16_t state; int16_t x,y; uint16_t keysym; int16_t autorepeat; unichar_t chars[_GD_EVT_CHRLEN]; } chr; struct { char *device; /* for wacom devices */ uint32_t time; int16_t state; int16_t x,y; int16_t button; int16_t clicks; int32_t pressure, xtilt, ytilt, separation; } mouse; struct { GRect rect; } expose; struct { enum visibility_state state; } visibility; struct { GRect size; int16_t dx, dy, dwidth, dheight; unsigned int moved: 1; unsigned int sized: 1; } resize; struct { char *device; /* for wacom devices */ uint32_t time; int16_t state; int16_t x,y; unsigned int entered: 1; } crossing; struct { unsigned int gained_focus: 1; unsigned int mnemonic_focus: 2; } focus; struct { unsigned int is_visible: 1; } map; struct { enum selnames sel; } selclear; struct { int32_t x,y; } drag_drop; struct { GTimer *timer; void *userdata; } timer; struct { enum et_subtype subtype; struct ggadget *g; union { struct sbevent sb; struct { int gained_focus; } tf_focus; struct { int from_pulldown; /* -1 normally, else index into pulldown list */ } tf_changed; struct { int clicks; int16_t button, state; } button; struct { int from_mouse, changed_index; } list; } u; } control; struct { long subtype; void *userdata; } user; } u; void *native_window; } GEvent; typedef enum cursor_types { ct_default, ct_pointer, ct_backpointer, ct_hand, ct_question, ct_cross, ct_4way, ct_text, ct_watch, ct_draganddrop, ct_invisible, ct_user, ct_user2 /* and so on */ } GCursor; enum window_attr_mask { wam_events=0x2, wam_bordwidth=0x4, wam_bordcol=0x8, wam_backcol=0x10, wam_cursor=0x20, wam_wtitle=0x40, wam_ititle=0x80, wam_icon=0x100, wam_nodecor=0x200, wam_positioned=0x400, wam_centered=0x800, wam_undercursor=0x1000, wam_noresize=0x2000, wam_restrict=0x4000, wam_redirect=0x8000, wam_isdlg=0x10000, wam_notrestricted=0x20000, wam_transient=0x40000, wam_utf8_wtitle=0x80000, wam_utf8_ititle=0x100000, wam_nocairo=0x200000, wam_verytransient=0x400000, wam_palette=0x800000 }; #ifdef __cplusplus extern "C++" { inline enum window_attr_mask operator|(enum window_attr_mask lhs, enum window_attr_mask rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } } #endif typedef struct gwindow_attrs { enum window_attr_mask mask; uint32_t event_masks; /* (1<