sent/drw.h

66 lines
1.6 KiB
C
Raw Normal View History

2015-04-05 13:48:47 +00:00
/* See LICENSE file for copyright and license details. */
#define DRW_FONT_CACHE_SIZE 32
typedef struct {
Cursor cursor;
} Cur;
2015-04-21 20:57:52 +00:00
typedef struct Fnt Fnt;
struct Fnt {
2015-04-05 13:48:47 +00:00
Display *dpy;
int ascent;
int descent;
unsigned int h;
XftFont *xfont;
FcPattern *pattern;
2015-04-21 20:57:52 +00:00
Fnt *next;
};
2015-04-05 13:48:47 +00:00
typedef struct {
2015-04-10 21:12:50 +00:00
struct {
unsigned long pix;
XftColor rgb;
} fg, bg;
} Scm;
2015-04-05 13:48:47 +00:00
typedef struct {
unsigned int w, h;
Display *dpy;
int screen;
Window root;
Drawable drawable;
GC gc;
2015-04-10 21:12:50 +00:00
Scm *scheme;
2015-04-21 20:57:52 +00:00
Fnt *fonts;
2015-04-05 13:48:47 +00:00
} Drw;
/* Drawable abstraction */
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
void drw_free(Drw *drw);
/* Fnt abstraction */
2015-04-21 20:57:52 +00:00
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
void drw_fontset_free(Fnt* set);
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
2015-04-08 19:13:45 +00:00
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
2015-04-05 13:48:47 +00:00
2015-04-10 21:12:50 +00:00
/* Colorscheme abstraction */
Scm *drw_scm_create(Drw *drw, const char *fgname, const char *bgname);
void drw_scm_free(Scm *scm);
2015-04-05 13:48:47 +00:00
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
void drw_cur_free(Drw *drw, Cur *cursor);
/* Drawing context manipulation */
2015-04-21 20:57:52 +00:00
void drw_setfontset(Drw *drw, Fnt *set);
2015-04-10 21:12:50 +00:00
void drw_setscheme(Drw *drw, Scm *scm);
2015-04-05 13:48:47 +00:00
/* Drawing functions */
2015-04-12 20:56:56 +00:00
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
2015-04-05 13:48:47 +00:00
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
/* Map functions */
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);