1 /****************************************************************************
2     Copyright (C) 1987-2015 by Jeffery P. Hansen
3     Copyright (C) 2015-2018 by Andrey V. Skvortsov
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ****************************************************************************/
19 
20 #ifndef GATE_PAINTER_H
21 #define	GATE_PAINTER_H
22 
23 #include "fonts.h"
24 #include "misc.h"
25 
26 #include <X11/Xft/Xft.h>
27 
28 struct _GateColor {
29 	XColor		xColor;
30 	XftColor	xftColor;
31 };
32 typedef struct _GateColor GateColor;
33 
34 extern GateColor notAColor;
35 
36 Boolean GateColor_equals(GateColor*, GateColor*);
37 
38 /**
39  * @class GatePainter
40  * @brief Abstract painter
41  * @stereotype control
42  *
43  * Incapsulates the painting device references and provides interface
44  * of drawing the primitives and text
45  */
46 struct _GatePainter;
47 typedef struct _GatePainter GatePainter;
48 
49 /**
50  * @class GatePainterContext
51  * @brief the painter state parameters set
52  * @stereotype entity
53  */
54 struct _GatePainterContext;
55 typedef struct _GatePainterContext GatePainterContext;
56 
57 /**
58  * @brief initialize painter object
59  *
60  * @param display X display to use
61  * @param draw drawable object to paint on
62  */
63 void GatePainter_init(GatePainter*, Display *display, Drawable draw);
64 
65 /**
66  * @brief destroy painter object and free resources
67  * @param
68  */
69 void GatePainter_destroy(GatePainter*);
70 
71 /**
72  * @brief paint string at given coordinates
73  *
74  * @param gc painter parameters to use
75  * @param x X coordinate
76  * @param y Y coordinate
77  * @param str string characters
78  * @param len length of the string
79  */
80 void GatePainter_drawString_new(GatePainter*, GatePainterContext*, int, int, const char*, int);
81 void GatePainter_drawString(GatePainter*, GC, int, int, const char*, int);
82 
83 GatePainterContext * GatePainter_createContext(GatePainter*);
84 
85 GateColor GatePainter_getColor(GatePainter*, const char*);
86 
87 Drawable GatePainter_drawable(GatePainter *self);
88 void GatePainter_setDrawable(GatePainter *self, Drawable newVal);
89 
90 /**
91  * @class GatePainterXlib
92  * @brief Pure Xlib concrete painter
93  */
94 struct _GatePainterXlib;
95 typedef struct _GatePainterXlib GatePainterXlib;
96 GatePainterXlib *new_GatePainterXlib();
97 
98 struct _GatePainterXlibContext;
99 typedef struct _GatePainterXlibContext GatePainterXlibContext;
100 
101 /**
102  * @class GatePainterPangoXft
103  * @brief Pango/Xft concrete painter
104  */
105 struct _GatePainterPangoXft;
106 typedef struct _GatePainterPangoXft GatePainterPangoXft;
107 GatePainterPangoXft *new_GatePainterPangoXft();
108 
109 struct _GatePainterPangoXftContext;
110 typedef struct _GatePainterPangoXftContext GatePainterPangoXftContext;
111 
112 /**
113  * @brief GC property get
114  */
115 GC GatePainterContext_gc(GatePainterContext*);
116 GC *GatePainterContext_gcRef(GatePainterContext*);
117 
118 /**
119  * @brief set active font
120  * @param TkGate font object
121  */
122 void GatePainterContext_setFont(GatePainterContext*, GateFont);
123 
124 void GatePainterContext_setColor(GatePainterContext*, GateColor);
125 
126 void GatePainterContext_print(GatePainterContext*, FILE*);
127 
128 int GatePainterContext_textWidth(GatePainterContext*, GateFont, const char*, int);
129 
130 GateFontMetrics GatePainterContext_fontMetrics(GatePainterContext*, GateFont*);
131 
132 #endif	/* GATE_PAINTER_H */
133