… | |
… | |
20 | static PangoFontMap *fontmap; |
20 | static PangoFontMap *fontmap; |
21 | |
21 | |
22 | typedef struct cf_layout { |
22 | typedef struct cf_layout { |
23 | PangoLayout *pl; |
23 | PangoLayout *pl; |
24 | int base_height; |
24 | int base_height; |
25 | } *Crossfire__Client__Layout; |
25 | } *CFClient__Layout; |
26 | |
26 | |
27 | static void |
27 | static void |
28 | layout_get_pixel_size (Crossfire__Client__Layout self, int *w, int *h) |
28 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
29 | { |
29 | { |
30 | pango_layout_get_pixel_size (self->pl, w, h); |
30 | pango_layout_get_pixel_size (self->pl, w, h); |
31 | |
31 | |
32 | *w = (*w + 3) & ~3; |
32 | *w = (*w + 3) & ~3; |
33 | if (!*w) *w = 1; |
33 | if (!*w) *w = 1; |
34 | if (!*h) *h = 1; |
34 | if (!*h) *h = 1; |
35 | } |
35 | } |
36 | |
36 | |
37 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
37 | MODULE = CFClient PACKAGE = CFClient |
38 | |
38 | |
39 | PROTOTYPES: ENABLE |
39 | PROTOTYPES: ENABLE |
40 | |
40 | |
41 | BOOT: |
41 | BOOT: |
42 | { |
42 | { |
… | |
… | |
77 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
77 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
78 | FcPatternDestroy (pattern); |
78 | FcPatternDestroy (pattern); |
79 | pango_context_set_font_description (context, font); |
79 | pango_context_set_font_description (context, font); |
80 | } |
80 | } |
81 | |
81 | |
82 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Layout |
82 | MODULE = CFClient PACKAGE = CFClient::Layout |
83 | |
83 | |
84 | Crossfire::Client::Layout |
84 | CFClient::Layout |
85 | new (SV *class, int base_height = 10) |
85 | new (SV *class, int base_height = 10) |
86 | CODE: |
86 | CODE: |
87 | New (0, RETVAL, 1, struct cf_layout); |
87 | New (0, RETVAL, 1, struct cf_layout); |
88 | RETVAL->base_height = base_height; |
88 | RETVAL->base_height = base_height; |
89 | RETVAL->pl = pango_layout_new (context); |
89 | RETVAL->pl = pango_layout_new (context); |
90 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
90 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
91 | OUTPUT: |
91 | OUTPUT: |
92 | RETVAL |
92 | RETVAL |
93 | |
93 | |
94 | void |
94 | void |
95 | DESTROY (Crossfire::Client::Layout self) |
95 | DESTROY (CFClient::Layout self) |
96 | CODE: |
96 | CODE: |
97 | g_object_unref (self->pl); |
97 | g_object_unref (self->pl); |
98 | Safefree (self); |
98 | Safefree (self); |
99 | |
99 | |
100 | void |
100 | void |
101 | set_markup (Crossfire::Client::Layout self, SV *text_) |
101 | set_markup (CFClient::Layout self, SV *text_) |
102 | CODE: |
102 | CODE: |
103 | { |
103 | { |
104 | STRLEN textlen; |
104 | STRLEN textlen; |
105 | char *text = SvPVutf8 (text_, textlen); |
105 | char *text = SvPVutf8 (text_, textlen); |
106 | |
106 | |
107 | pango_layout_set_markup (self->pl, text, textlen); |
107 | pango_layout_set_markup (self->pl, text, textlen); |
108 | } |
108 | } |
109 | |
109 | |
110 | void |
110 | void |
111 | set_width (Crossfire::Client::Layout self, int max_width = -1) |
111 | set_width (CFClient::Layout self, int max_width = -1) |
112 | CODE: |
112 | CODE: |
113 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
113 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
114 | |
114 | |
115 | void |
115 | void |
116 | size (Crossfire::Client::Layout self) |
116 | size (CFClient::Layout self) |
117 | PPCODE: |
117 | PPCODE: |
118 | { |
118 | { |
119 | int w, h; |
119 | int w, h; |
120 | |
120 | |
121 | PangoFontDescription *font = pango_context_get_font_description (context); |
121 | PangoFontDescription *font = pango_context_get_font_description (context); |
… | |
… | |
127 | PUSHs (sv_2mortal (newSViv (w))); |
127 | PUSHs (sv_2mortal (newSViv (w))); |
128 | PUSHs (sv_2mortal (newSViv (h))); |
128 | PUSHs (sv_2mortal (newSViv (h))); |
129 | } |
129 | } |
130 | |
130 | |
131 | void |
131 | void |
132 | render (Crossfire::Client::Layout self) |
132 | render (CFClient::Layout self) |
133 | PPCODE: |
133 | PPCODE: |
134 | { |
134 | { |
135 | SV *retval; |
135 | SV *retval; |
136 | int w, h; |
136 | int w, h; |
137 | FT_Bitmap bitmap; |
137 | FT_Bitmap bitmap; |
… | |
… | |
157 | PUSHs (sv_2mortal (newSViv (w))); |
157 | PUSHs (sv_2mortal (newSViv (w))); |
158 | PUSHs (sv_2mortal (newSViv (h))); |
158 | PUSHs (sv_2mortal (newSViv (h))); |
159 | PUSHs (sv_2mortal (retval)); |
159 | PUSHs (sv_2mortal (retval)); |
160 | } |
160 | } |
161 | |
161 | |
162 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture |
162 | MODULE = CFClient PACKAGE = CFClient::Texture |
163 | |
163 | |
164 | void |
164 | void |
165 | draw_quad (SV *self, double x, double y, double w = 0, double h = 0) |
165 | draw_quad (SV *self, double x, double y, double w = 0, double h = 0) |
166 | PROTOTYPE: $$$;$$ |
166 | PROTOTYPE: $$$;$$ |
167 | CODE: |
167 | CODE: |