xynth.h
来自「CS架构的多平台的GUI系统」· C头文件 代码 · 共 882 行 · 第 1/2 页
H
882 行
int blen; char *buf;} s_stream_t;typedef struct s_desktop_client_s { int id; int pri; int title_l; char *title;} s_desktop_client_t;typedef struct s_dekstop_s { s_list_t *clients;} s_desktop_t;typedef struct s_timer_s { long long timeval; long long interval; void (*cb) (s_window_t *, struct s_timer_s *); void *user_data;} s_timer_t;typedef struct s_timers_s { s_list_t *timers; s_thread_mutex_t *mut;} s_timers_t;typedef struct s_event_s { S_EVENT type; s_mouse_t *mouse; s_keybd_t *keybd; s_expose_t *expose; s_desktop_t *desktop; s_timer_t *timer;} s_event_t;typedef struct s_eventq { s_thread_t *tid; s_list_t *queue; s_thread_cond_t *cond; s_thread_mutex_t *mut;} s_eventq_t;typedef struct s_handler_keybd_s { int flag; int button; void (*p) (s_window_t *, s_event_t *, s_handler_t *); void (*r) (s_window_t *, s_event_t *, s_handler_t *);} s_handler_keybd_t;typedef struct s_handler_mouse_s { int x; int y; int w; int h; int button; void (*p) (s_window_t *, s_event_t *, s_handler_t *); /* button pressed */ void (*r) (s_window_t *, s_event_t *, s_handler_t *); /* button released, */ void (*c) (s_window_t *, s_event_t *, s_handler_t *); /* button clicked, */ void (*o) (s_window_t *, s_event_t *, s_handler_t *); /* on over */ void (*ho) (s_window_t *, s_event_t *, s_handler_t *); /* on over && hint, */ /* on over, but mouse button is still pressed */ void (*hr) (s_window_t *, s_event_t *, s_handler_t *); /* button realesed && hint */ /* mouse button released, but the prev. press was not on us */ void (*oh) (s_window_t *, s_event_t *, s_handler_t *); /* button over && hint2 */ /* not on over, but was on over */ void (*hoh) (s_window_t *, s_event_t *, s_handler_t *); /* button over && hint && hint2 */ /* not on over, but was on over. and button is still pressed */ void (*rh) (s_window_t *, s_event_t *, s_handler_t *); /* button realesed && hint2 */ /* mouse button released outside, but the prev. press was on us */ /* wheel buttons has no realesed event */ S_EVENT hstate;} s_handler_mouse_t; struct s_handler_s { S_HANDLER type; s_handler_mouse_t mouse; s_handler_keybd_t keybd; void *user_data;};typedef struct s_handlers_s { s_list_t *list; s_thread_mutex_t *mut;} s_handlers_t;typedef struct s_childs_s { s_list_t *list; s_thread_mutex_t *mut;} s_childs_t;typedef struct s_surface_s { S_SURFACE_MODE mode; int bytesperpixel; /* We need to get them from server, to be able to draw right */ int bitsperpixel; /* thing on linear buffer. */ int colors; /* These are for future compability */ int blueoffset; int greenoffset; int redoffset; int bluelength; int greenlength; int redlength; int width; /* These are the real sizes of our buffer */ int height; char *vbuf; /* The buffer that holds clients window. */ s_rect_t buf; /* This is our bufs virtual part */ s_rect_t win; char *linear_buf; /* mapped shared buffer */ int linear_buf_width; /* See s_client_surface_linear() */ int linear_buf_pitch; int linear_buf_height; unsigned int linear_mem_base; /* We have to get the properties and the address of linear */ unsigned int linear_mem_size; /* buffer to be able to draw on it. */ int *id; /* ugly hack, window->surface->id = &(window->client->id); */ int shm_mid; /* shared screen matrix */ unsigned char *matrix; int shm_sid; /* shared linear buffer */ int need_expose; s_window_t *window; /* ugly hack, window->surface->window = window; */} s_surface_t;typedef struct s_object_s { s_list_t *childs; /* object`s childs */ s_thread_mutex_t *mut; /* object`s root mutex */ s_surface_t *surface; /* object`s surface */ struct s_object_s *parent; /* object`s parent */} s_object_t;typedef struct s_client_s { int id; int pri; char *title; char *driver; char *device; int resizeable; int alwaysontop; void (*atevent) (s_window_t *, s_event_t *); void (*atexit) (s_window_t *); void *user_data;} s_client_t;struct s_window_s { int running; int soc; int wsoc; S_WINDOW type; s_client_t *client; s_surface_t *surface; s_eventq_t *eventq; s_timers_t *timers; s_childs_t *childs; s_pollfds_t *pollfds; s_handlers_t *handlers; s_thread_t *tid; s_window_t *parent; s_event_t *event; s_thread_mutex_t *socket_mutex;};typedef struct s_single_app_s { int (*fonk) (int argc, char *argv[]); int argc; char *argv[10];} s_single_app_t;/* alloc.c */void * s_malloc (unsigned int size);void * s_calloc (unsigned int nmemb, unsigned int size);void * s_realloc (void *ptr, unsigned int size);void s_free (void *ptr);/* child.c */int s_child_add (s_window_t *window, s_window_t *child);int s_child_del (s_window_t *window, s_window_t *child);int s_childs_init (s_window_t *window);int s_childs_uninit (s_window_t *window);/* client.c */int s_client_init (s_window_t **window);void s_client_uninit (s_window_t *window);void s_client_exit (s_window_t *window);void s_client_quit (s_window_t *window);int s_client_wakeup (s_window_t *window);int s_client_child_find (s_window_t *parent, s_window_t *window, s_event_t *event);void * s_client_loop_event (void *arg);void * s_client_loop (void *arg);void * s_client_main (void *arg);void s_client_atevent (s_window_t *window, void (*f) (s_window_t *, s_event_t *));void s_client_atexit (s_window_t *window, void (*f) (s_window_t *));/* config.c */char * s_config_strip (char *buf);int s_config_parse (s_config_t *cfg, char *name);int s_config_init (s_config_t **cfg);int s_config_category_init (s_config_cat_t **cat, char *name);int s_config_variable_init (s_config_var_t **var, char *name, char *value);int s_config_variable_uninit (s_config_var_t *var);int s_config_category_uninit (s_config_cat_t *cat);int s_config_uninit (s_config_t *cfg);/* debugf.c */void s_debug_debugf (unsigned short flags, char *file, int line, char *func, char *fmt, ...);/* driver.c */void bpp_setpixel (s_surface_t *surface, int x, int y, int c);void bpp_setpixel_o (s_surface_t *surface, int id, int x, int y, int c);int bpp_getpixel (s_surface_t *surface, int x, int y);int bpp_getpixel_o (s_surface_t *surface, int id, int x, int y);void bpp_hline (s_surface_t *surface, int x1, int y, int x2, int c);void bpp_hline_o (s_surface_t *surface, int id, int x1, int y, int x2, int c);void bpp_vline (s_surface_t *surface, int x, int y1, int y2, int c);void bpp_vline_o (s_surface_t *surface, int id, int x, int y1, int y2, int c);void bpp_fillbox (s_surface_t *surface, int x, int y, int w, int h, int c);void bpp_fillbox_o (s_surface_t *surface, int id, int x, int y, int w, int h, int c);void bpp_putbox (s_surface_t *surface, int x, int y, int w, int h, char *sp, int bw);void bpp_putbox_mask (s_surface_t *surface, int x, int y, int w, int h, char *sp, unsigned char *sm, int bw);void bpp_getbox (s_surface_t *surface, int x, int y, int w, int h, char *dp);void bpp_putbox_o (s_surface_t *surface, int id, int x, int y, int w, int h, char *sp, int bw);void bpp_putbox_mask_o (s_surface_t *surface, int id, int x, int y, int w, int h, char *sp, unsigned char *sm, int bw);void bpp_getbox_o (s_surface_t *surface, int id, int x, int y, int w, int h, char *dp);/* event.c */int s_event_mouse_state (s_window_t *window, s_event_t *event, s_handler_mouse_t *mouse, int over);void s_event_parse_mouse (s_window_t *window, s_event_t *event);int s_event_parse_keybd (s_window_t *window, s_event_t *event);int s_event_parse_expos (s_window_t *window, s_event_t *event);int s_event_parse_timer (s_window_t *window, s_event_t *event);int s_event_changed (s_window_t *window);int s_event_init (s_event_t **event);int s_event_uninit (s_event_t *event);/* eventq.c */int s_eventq_init (s_window_t *window);int s_eventq_uninit (s_window_t *window);int s_eventq_add (s_window_t *window, s_event_t *event);int s_eventq_get (s_window_t *window, s_event_t **event);int s_eventq_wait (s_window_t *window, s_event_t **event);/* font.c */int s_font_init (s_font_t **font, char *name);int s_font_uninit (s_font_t *font);int s_font_set_size (s_font_t *font, int size);int s_font_set_str (s_font_t *font, char *str);int s_font_set_rgb (s_font_t *font, int r, int g, int b);int s_font_get_glyph (s_font_t *font);/* gettime.c */long long s_gettimeofday (void);/* grlib.c */int s_grlib_stream (s_surface_t *surface, s_rect_t *coor);int s_rgbcolor (s_surface_t *surface, int r, int g, int b);void s_colorrgb (s_surface_t *surface, int c, int *r, int *g, int *b);void s_setpixel (s_surface_t *surface, int x, int y, int c);void s_setpixelrgb (s_surface_t *surface, int x, int y, int r, int g, int b);void s_setpixelrgba (s_surface_t *surface, int x, int y, int r, int g, int b, int a);int s_getpixel (s_surface_t *surface, int x, int y);void s_getpixelrgb (s_surface_t *surface, int x, int y, int *r, int *g, int *b);void s_hline (s_surface_t *surface, int x1, int y, int x2, int c);void s_vline (s_surface_t *surface, int x, int y1, int y2, int c);void s_fillbox (s_surface_t *surface, int x, int y, int w, int h, int c);void s_putbox (s_surface_t *surface, int x, int y, int w, int h, char *sp);void s_putboxmask (s_surface_t *surface, int x, int y, int w, int h, char *sp, unsigned char *sm);void s_putboxalpha (s_surface_t *surface, int x, int y, int w, int h, char *sp, unsigned char *sm);void s_putboxrgba (s_surface_t *surfacem, int x, int y, int w, int h, unsigned int *rgba);void s_getbox (s_surface_t *surface, int x, int y, int w, int h, char *dp);void s_putboxpart (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, char *sp, int xo, int yo);void s_putboxpartmask (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, char *sp, unsigned char *sm, int xo, int yo);void s_putboxpartrgba (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, unsigned int *rgba, int xo, int yo);void s_putboxpartalpha (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, char *sp, unsigned char *sm, int xo, int yo);void s_copybox (s_surface_t *surface, int x1, int y1, int w, int h, int x2, int y2);void s_getsurfacevirtual (s_surface_t *s, int w, int h, int bitspp, char *vbuf);int s_copybuffer (char *sb, int sbitspp, char **db, int dbitspp, int w, int h);void s_scalebox (s_surface_t *surface, int w1, int h1, void *_dp1, int w2, int h2, void *_dp2);/* handler.c */int s_handler_init (s_handler_t **handler);int s_handler_uninit (s_handler_t *handler);int s_handler_add (s_window_t *window, s_handler_t *handler);int s_handler_del (s_window_t *window, s_handler_t *handler);int s_handlers_init (s_window_t *window);int s_handlers_uninit (s_window_t *window);/* image.c */int s_image_hex2int (char *str);int s_image_get_mat (s_image_t *img);int s_image_get_buf (s_surface_t *surface, s_image_t *img);void s_image_get_handler (s_image_t *img);int s_image_init (s_image_t **img);void s_image_free_buf (s_image_t *img);void s_image_free_mat (s_image_t *img);void s_image_free_rgba (s_image_t *img);int s_image_uninit (s_image_t *img);int s_image_layer_init (s_image_t **lyr);int s_image_layer_uninit (s_image_t *lyr);int s_image_layers_init (s_image_t *img);int s_image_layers_uninit (s_image_t *img);int s_image_img (char *file, s_image_t *img);/* image_gif.c */int s_image_gif_is (char *file);int s_image_gif (char *file, s_image_t *img);/* image_png.c */int s_image_png_is (char *file);int s_image_png (char *file, s_image_t *img);/* image_xpm.c */int s_image_xpm_is (char *file);int s_image_xpm (char *file, s_image_t *img);/* list.c */int s_list_init (s_list_t *li);int s_list_eol (s_list_t *li, int i);void * s_list_get (s_list_t *li, int pos);int s_list_remove (s_list_t *li, int pos);int s_list_add (s_list_t *li, void *el, int pos);void * s_list_find (s_list_t *list, void *node, int (*cmp_func) (void *, void *));int s_list_get_pos (s_list_t *list, void *node);/* object.c */int s_object_update_to_surface (s_object_t *object, s_surface_t *surface, s_rect_t *coor);int s_object_update (s_object_t *object, s_rect_t *coor);int s_object_move (s_object_t *object, int x, int y, int w, int h);int s_object_hide (s_object_t *object);int s_object_show (s_object_t *object);int s_object_init (s_window_t *window, s_object_t **object, int w, int h, s_object_t *parent);int s_object_uninit (s_object_t *object);/* pollfd.c */int s_pollfd_init (s_pollfd_t **pfd);int s_pollfd_uninit (s_pollfd_t *pfd);int s_pollfd_find_cmp_f (void *p1, void *p2);s_pollfd_t * s_pollfd_find (s_window_t *window, int fd);int s_pollfd_add (s_window_t *window, s_pollfd_t *pfd);int s_pollfd_del (s_window_t *window, s_pollfd_t *pfd);int s_pollfds_init (s_window_t *window);int s_pollfds_uninit (s_window_t *window);/* rect.c */int s_rect_intersect (s_rect_t *r1, s_rect_t *r2, s_rect_t *r);int s_rect_clip_virtual (s_surface_t *surface, int x, int y, int w, int h, s_rect_t *coor);int s_rect_clip_real (s_surface_t *surface, int x, int y, int w, int h, s_rect_t *coor);int s_rect_difference_add (s_list_t *list, int x, int y, int w, int h);int s_rect_difference (s_rect_t *r1, s_rect_t *r0, s_list_t *list);/* socket.c */int s_socket_request_new (s_window_t *window, int soc);int s_socket_request_title (s_window_t *window, int soc);int s_socket_request_display (s_window_t *window, int soc);int s_socket_request_configure (s_window_t *window, int soc, S_WINDOW form);int s_socket_request_desktop (s_window_t *window, int soc, int id);int s_socket_request (s_window_t *window, S_SOC_DATA req, ...);int s_socket_listen_event (s_window_t *window, int soc);int s_socket_listen_expose (s_window_t *window, int soc);int s_socket_listen_desktop (s_window_t *window, int soc);int s_socket_listen_parse (s_window_t *window, int soc);int s_socket_listen_wait (s_window_t *window, int timeout);int s_socket_uninit (s_window_t *window, int s);int s_socket_in_f (s_window_t *window, int s);int s_socket_ierr_f (s_window_t *window, int s);int s_socket_inw_f (s_window_t *window, int s);int s_socket_ierrw_f (s_window_t *window, int s);int s_socket_closew_f (s_window_t *window, int s); int s_socket_init_uds (s_window_t *window);int s_socket_init_tcp (s_window_t *window);int s_socket_init_wakeup (s_window_t *window);int s_socket_init (s_window_t *window);/* surface.c */int s_surface_init (s_window_t *window);void s_surface_create (s_window_t *window);void s_surface_shm_attach (s_window_t *window);void s_surface_linear (s_window_t *window);void s_surface_uninit (s_window_t *window);void s_surface_changed (s_window_t *window, s_rect_t *changed);/* thread.c */int s_thread_sem_create (s_thread_sem_t *sem, int initial);int s_thread_sem_destroy (s_thread_sem_t *sem);int s_thread_sem_wait (s_thread_sem_t *sem);int s_thread_sem_wait_timeout (s_thread_sem_t *sem, int msec);int s_thread_sem_post (s_thread_sem_t *sem);int s_thread_mutex_init (s_thread_mutex_t **mut);int s_thread_mutex_destroy (s_thread_mutex_t *mut);int s_thread_mutex_lock (s_thread_mutex_t *mut);int s_thread_mutex_trylock (s_thread_mutex_t *mut);int s_thread_mutex_unlock (s_thread_mutex_t *mut);int s_thread_cond_init (s_thread_cond_t **cond);int s_thread_cond_destroy (s_thread_cond_t *cond);int s_thread_cond_signal (s_thread_cond_t *cond);int s_thread_cond_broadcast (s_thread_cond_t *cond);int s_thread_cond_wait (s_thread_cond_t *cond, s_thread_mutex_t *mut);int s_thread_cond_timedwait (s_thread_cond_t *cond, s_thread_mutex_t *mut, int msec);void * s_thread_run (void *farg);s_thread_t * s_thread_create (void * (*f) (void *), void *farg);int s_thread_cancel (s_thread_t *tid);int s_thread_join (s_thread_t *tid, void **ret);int s_thread_self (void);void s_thread_exit (void *ret);/* timer.c */int s_timer_init (s_timer_t **timer);int s_timer_timeval (s_window_t *window, s_timer_t *timer, int timeval);int s_timer_uninit (s_timer_t *timer);int s_timer_del (s_window_t *window, s_timer_t *timer);int s_timer_add (s_window_t *window, s_timer_t *timer);int s_timers_init (s_window_t *window);int s_timers_uninit (s_window_t *window);/* window.c */void s_window_set_title (s_window_t *window, char *fmt, ...);void s_window_form_draw (s_window_t *window);void s_window_hide (s_window_t *window);void s_window_show (s_window_t *window);void s_window_set_coor (s_window_t *window, int form, int x, int y, int w, int h);void s_window_set_resizeable (s_window_t *window, int resizeable);void s_window_set_alwaysontop (s_window_t *window, int alwaysontop);int s_window_new (s_window_t *window, S_WINDOW type, s_window_t *parent);#ifdef __cplusplus }#endif#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?