/* Copyright (C) 2000-2011 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 _GDRAW_H #define _GDRAW_H #include "gimage.h" #include "charset.h" enum font_style { fs_none, fs_italic=1, fs_smallcaps=2, fs_condensed=4, fs_extended=8 }; enum font_type { ft_unknown, ft_serif, ft_sans, ft_mono, ft_cursive, ft_max }; enum text_mods { tm_none, tm_upper=1, tm_lower=2, tm_initialcaps=4, tm_showsofthyphen=8 }; enum text_lines { tl_none, tl_under=1, tl_strike=2, tl_over=4, tl_dash=8 }; typedef struct { const unichar_t *family_name; /* may be more than one */ int16 point_size; /* negative values are in pixels */ int16 weight; enum font_style style; char *utf8_family_name; } FontRequest; typedef struct { int16 letter_spacing; /* in point tenths */ unsigned int starts_word: 1; unsigned int has_charset: 1; enum text_mods mods; enum text_lines lines; enum charset charset; } FontMods; typedef struct gbidata { unichar_t *text; uint8 *level; uint8 *override; uint16 *type; unichar_t **original; int32 len; unsigned int base_right_to_left: 1; unsigned int interpret_arabic: 1; } GBiText; 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; int32 xor_base; Color fg; Color bg; GRect clip; enum draw_func { df_copy, df_xor } func; unsigned int copy_through_sub_windows: 1; unsigned int bitmap_col: 1; /* window is mapped for bitmap */ int16 skip_len, dash_len; int16 line_width; int16 ts; int32 ts_xoff, ts_yoff; int dash_offset; GFont *fi; } GGC; typedef struct gtextbounds { int16 lbearing; /* of first character */ /* origin to left edge of first char's raster */ int32 rbearing; /* origin to right edge of last char's raster */ int16 as,ds; /* maximum ascent and maximum descent */ /* (both numbers will be positive for "g" */ /* so total height = as+ds */ int16 fas, fds; /* font ascent and descent */ /* total width = rbearing-lbearing */ int32 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 }; typedef struct gevent { enum event_type { et_noevent = -1, et_char, et_charup, et_mousemove, et_mousedown, et_mouseup, et_crossing, /* these four are assumed to be consecutive */ et_focus, 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 } type; #define _GD_EVT_CHRLEN 10 GWindow w; union { struct { char *device; /* for wacom devices */ uint32 time; uint16 state; int16 x,y; uint16 keysym; unichar_t chars[_GD_EVT_CHRLEN]; } chr; struct { char *device; /* for wacom devices */ uint32 time; int16 state; int16 x,y; int16 button; int16 clicks; int32 pressure, xtilt, ytilt, separation; } mouse; struct { GRect rect; } expose; struct { enum visibility_state { vs_unobscured, vs_partially, vs_obscured } state; } visibility; struct { GRect size; int16 dx, dy, dwidth, dheight; unsigned int moved: 1; unsigned int sized: 1; } resize; struct { char *device; /* for wacom devices */ uint32 time; int16 state; int16 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 x,y; } drag_drop; struct { GTimer *timer; void *userdata; } timer; struct { enum { et_buttonpress, et_buttonactivate, et_radiochanged, et_listselected, et_listdoubleclick, et_scrollbarchange, et_textchanged, et_textfocuschanged, et_lastsubtype } subtype; struct ggadget *g; union { struct sbevent { 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 } type; int32 pos; } sb; struct { int gained_focus; } tf_focus; struct { int from_pulldown; /* -1 normally, else index into pulldown list */ } tf_changed; struct { int clicks; int16 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; typedef struct gwindow_attrs { 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_cairo=0x200000, wam_verytransient=0x400000 } mask; uint32 event_masks; /* (1<