chiark / gitweb /
Imported Debian patch 1.0.0-6
[e16] / src / tclass.h
1 /*
2  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3  * Copyright (C) 2004-2007 Kim Woelders
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to
7  * deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9  * sell copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies of the Software, its documentation and marketing & publicity
14  * materials, and acknowledgment shall be given in the documentation, materials
15  * and software packages that this Software was used.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _TCLASS_H
25 #define _TCLASS_H
26
27 #include "eimage.h"
28 #include "etypes.h"
29 #include "xwin.h"
30
31 #define MODE_VERBATIM     0
32 #define MODE_WRAP_CHAR    1
33 #define MODE_WRAP_WORD    2
34
35 #define FONT_TO_RIGHT     0
36 #define FONT_TO_DOWN      1
37 #define FONT_TO_UP        2
38 #define FONT_TO_LEFT      3
39
40 #define FONT_TYPE_UNKNOWN       0
41 #define FONT_TYPE_XFONT         0       /* XFontStruct     */
42 #define FONT_TYPE_XFS           2       /* XFontSet        */
43 #define FONT_TYPE_IFT           3       /* Imlib2/FreeType */
44 #if USE_XFT
45 #define FONT_TYPE_XFT           4       /* Xft             */
46 #endif
47 #if USE_PANGO
48 #define FONT_TYPE_PANGO_XFT     5       /* Pango-Xft       */
49 #endif
50
51 typedef struct {
52    int                 (*Load) (TextState * ts, const char *name);
53    void                (*Destroy) (TextState * ts);
54    void                (*TextSize) (TextState * ts, const char *text, int len,
55                                     int *width, int *height, int *ascent);
56    void                (*TextFit) (TextState * ts, char **ptext,
57                                    int *pwidth, int textwidth_limit);
58    void                (*TextDraw) (TextState * ts, int x, int y,
59                                     const char *text, int len);
60    int                 (*FdcInit) (TextState * ts, Win win, Drawable draw);
61    void                (*FdcFini) (TextState * ts);
62    void                (*FdcSetDrawable) (TextState * ts, unsigned long draw);
63    void                (*FdcSetColor) (TextState * ts, EColor * xc);
64 } FontOps;
65
66 struct _textstate {
67    char               *fontname;
68    char                type;
69    char                need_utf8;
70    struct {
71       char                mode;
72       char                orientation;
73       char                effect;
74    } style;
75    EColor              fg_col;
76    EColor              bg_col;
77    void               *fdc;
78    const FontOps      *ops;
79 };
80
81 struct _textclass {
82    char               *name;
83    struct {
84       TextState          *normal;
85       TextState          *hilited;
86       TextState          *clicked;
87       TextState          *disabled;
88    } norm             , active, sticky, sticky_active;
89    int                 justification;
90    unsigned int        ref_count;
91 };
92
93 /* tclass.c */
94 int                 TextclassConfigLoad(FILE * fs);
95 TextClass          *TextclassFind(const char *name, int fallback);
96 TextClass          *TextclassAlloc(const char *name, int fallback);
97 void                TextclassFree(TextClass * tc);
98 int                 TextclassGetJustification(TextClass * tc);
99 void                TextclassSetJustification(TextClass * tc, int just);
100
101 /* text.c */
102 TextState          *TextclassGetTextState(TextClass * tclass, int state,
103                                           int active, int sticky);
104 __EXPORT__ void     TextstateTextFit(TextState * ts, char **ptext, int *pw,
105                                      int textwidth_limit);
106 void                TextstateTextDraw(TextState * ts, Win win, Drawable draw,
107                                       const char *text, int x, int y, int w,
108                                       int h, const EImageBorder * pad,
109                                       int fsize, int justh, int justv);
110 void                TextSize(TextClass * tclass, int active, int sticky,
111                              int state, const char *text, int *width,
112                              int *height, int fsize);
113 void                TextDraw(TextClass * tclass, Win win, Drawable draw,
114                              int active, int sticky, int state,
115                              const char *text, int x, int y, int w, int h,
116                              int fsize, int justification);
117
118 __EXPORT__ int      _xft_FdcInit(TextState * ts, Win win, Drawable draw);
119 __EXPORT__ void     _xft_FdcFini(TextState * ts);
120 __EXPORT__ void     _xft_FdcSetDrawable(TextState * ts, unsigned long draw);
121 __EXPORT__ void     _xft_FdcSetColor(TextState * ts, EColor * xc);
122
123 #endif /* _TCLASS_H */