diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c new file mode 100644 index 0000000..10b807b --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c | |||
@@ -0,0 +1,171 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif /* ifdef HAVE_CONFIG_H */ | ||
4 | |||
5 | #include <string.h> | ||
6 | |||
7 | #include "Ecore.h" | ||
8 | #include "ecore_x_private.h" | ||
9 | #include "Ecore_X.h" | ||
10 | |||
11 | /** | ||
12 | * Creates a new default graphics context associated with the given | ||
13 | * drawable. | ||
14 | * @param draw Drawable to create graphics context with. If @c 0 is | ||
15 | * given instead, the default root window is used. | ||
16 | * @param value_mask Bitmask values. | ||
17 | * @param value_list List of values. The order of values must be the | ||
18 | * same than the corresponding bitmaks. | ||
19 | * @return The new default graphics context. | ||
20 | */ | ||
21 | EAPI Ecore_X_GC | ||
22 | ecore_x_gc_new(Ecore_X_Drawable draw, | ||
23 | Ecore_X_GC_Value_Mask value_mask, | ||
24 | const unsigned int *value_list) | ||
25 | { | ||
26 | XGCValues gcv; | ||
27 | int mask; | ||
28 | int idx; | ||
29 | int i; | ||
30 | |||
31 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
32 | if (!draw) | ||
33 | draw = DefaultRootWindow(_ecore_x_disp); | ||
34 | |||
35 | memset(&gcv, 0, sizeof (gcv)); | ||
36 | |||
37 | for (i = 0, idx = 0, mask = 1; i <= 22; i++, mask <<= 1) | ||
38 | { | ||
39 | switch (mask & value_mask) | ||
40 | { | ||
41 | case ECORE_X_GC_VALUE_MASK_FUNCTION: | ||
42 | gcv.function = value_list[idx]; | ||
43 | idx++; | ||
44 | break; | ||
45 | |||
46 | case ECORE_X_GC_VALUE_MASK_PLANE_MASK: | ||
47 | gcv.plane_mask = value_list[idx]; | ||
48 | idx++; | ||
49 | break; | ||
50 | |||
51 | case ECORE_X_GC_VALUE_MASK_FOREGROUND: | ||
52 | gcv.foreground = value_list[idx]; | ||
53 | idx++; | ||
54 | break; | ||
55 | |||
56 | case ECORE_X_GC_VALUE_MASK_BACKGROUND: | ||
57 | gcv.background = value_list[idx]; | ||
58 | idx++; | ||
59 | break; | ||
60 | |||
61 | case ECORE_X_GC_VALUE_MASK_LINE_WIDTH: | ||
62 | gcv.line_width = value_list[idx]; | ||
63 | idx++; | ||
64 | break; | ||
65 | |||
66 | case ECORE_X_GC_VALUE_MASK_LINE_STYLE: | ||
67 | gcv.line_style = value_list[idx]; | ||
68 | idx++; | ||
69 | break; | ||
70 | |||
71 | case ECORE_X_GC_VALUE_MASK_CAP_STYLE: | ||
72 | gcv.cap_style = value_list[idx]; | ||
73 | idx++; | ||
74 | break; | ||
75 | |||
76 | case ECORE_X_GC_VALUE_MASK_JOIN_STYLE: | ||
77 | gcv.join_style = value_list[idx]; | ||
78 | idx++; | ||
79 | break; | ||
80 | |||
81 | case ECORE_X_GC_VALUE_MASK_FILL_STYLE: | ||
82 | gcv.fill_style = value_list[idx]; | ||
83 | idx++; | ||
84 | break; | ||
85 | |||
86 | case ECORE_X_GC_VALUE_MASK_FILL_RULE: | ||
87 | gcv.fill_rule = value_list[idx]; | ||
88 | idx++; | ||
89 | break; | ||
90 | |||
91 | case ECORE_X_GC_VALUE_MASK_TILE: | ||
92 | gcv.tile = value_list[idx]; | ||
93 | idx++; | ||
94 | break; | ||
95 | |||
96 | case ECORE_X_GC_VALUE_MASK_STIPPLE: | ||
97 | gcv.stipple = value_list[idx]; | ||
98 | idx++; | ||
99 | break; | ||
100 | |||
101 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_X: | ||
102 | gcv.ts_x_origin = value_list[idx]; | ||
103 | idx++; | ||
104 | break; | ||
105 | |||
106 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_Y: | ||
107 | gcv.ts_y_origin = value_list[idx]; | ||
108 | idx++; | ||
109 | break; | ||
110 | |||
111 | case ECORE_X_GC_VALUE_MASK_FONT: | ||
112 | gcv.font = value_list[idx]; | ||
113 | idx++; | ||
114 | break; | ||
115 | |||
116 | case ECORE_X_GC_VALUE_MASK_SUBWINDOW_MODE: | ||
117 | gcv.subwindow_mode = value_list[idx]; | ||
118 | idx++; | ||
119 | break; | ||
120 | |||
121 | case ECORE_X_GC_VALUE_MASK_GRAPHICS_EXPOSURES: | ||
122 | gcv.graphics_exposures = value_list[idx]; | ||
123 | idx++; | ||
124 | break; | ||
125 | |||
126 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_X: | ||
127 | gcv.clip_x_origin = value_list[idx]; | ||
128 | idx++; | ||
129 | break; | ||
130 | |||
131 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_Y: | ||
132 | gcv.clip_y_origin = value_list[idx]; | ||
133 | idx++; | ||
134 | break; | ||
135 | |||
136 | case ECORE_X_GC_VALUE_MASK_CLIP_MASK: | ||
137 | gcv.clip_mask = value_list[idx]; | ||
138 | idx++; | ||
139 | break; | ||
140 | |||
141 | case ECORE_X_GC_VALUE_MASK_DASH_OFFSET: | ||
142 | gcv.dash_offset = value_list[idx]; | ||
143 | idx++; | ||
144 | break; | ||
145 | |||
146 | case ECORE_X_GC_VALUE_MASK_DASH_LIST: | ||
147 | gcv.dashes = value_list[idx]; | ||
148 | idx++; | ||
149 | break; | ||
150 | |||
151 | case ECORE_X_GC_VALUE_MASK_ARC_MODE: | ||
152 | gcv.arc_mode = value_list[idx]; | ||
153 | idx++; | ||
154 | break; | ||
155 | } /* switch */ | ||
156 | } | ||
157 | |||
158 | return XCreateGC(_ecore_x_disp, draw, value_mask, &gcv); | ||
159 | } /* ecore_x_gc_new */ | ||
160 | |||
161 | /** | ||
162 | * Deletes and frees the given graphics context. | ||
163 | * @param gc The given graphics context. | ||
164 | */ | ||
165 | EAPI void | ||
166 | ecore_x_gc_free(Ecore_X_GC gc) | ||
167 | { | ||
168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
169 | XFreeGC(_ecore_x_disp, gc); | ||
170 | } /* ecore_x_gc_free */ | ||
171 | |||