ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.14 by root, Tue Apr 11 13:05:11 2006 UTC vs.
Revision 1.15 by root, Tue Apr 11 13:14:36 2006 UTC

20static PangoFontMap *fontmap; 20static PangoFontMap *fontmap;
21 21
22typedef struct cf_layout { 22typedef 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
27static void 27static void
28layout_get_pixel_size (Crossfire__Client__Layout self, int *w, int *h) 28layout_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
37MODULE = Crossfire::Client PACKAGE = Crossfire::Client 37MODULE = CFClient PACKAGE = CFClient
38 38
39PROTOTYPES: ENABLE 39PROTOTYPES: ENABLE
40 40
41BOOT: 41BOOT:
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
82MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Layout 82MODULE = CFClient PACKAGE = CFClient::Layout
83 83
84Crossfire::Client::Layout 84CFClient::Layout
85new (SV *class, int base_height = 10) 85new (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
94void 94void
95DESTROY (Crossfire::Client::Layout self) 95DESTROY (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
100void 100void
101set_markup (Crossfire::Client::Layout self, SV *text_) 101set_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
110void 110void
111set_width (Crossfire::Client::Layout self, int max_width = -1) 111set_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
115void 115void
116size (Crossfire::Client::Layout self) 116size (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
131void 131void
132render (Crossfire::Client::Layout self) 132render (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
162MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture 162MODULE = CFClient PACKAGE = CFClient::Texture
163 163
164void 164void
165draw_quad (SV *self, double x, double y, double w = 0, double h = 0) 165draw_quad (SV *self, double x, double y, double w = 0, double h = 0)
166 PROTOTYPE: $$$;$$ 166 PROTOTYPE: $$$;$$
167 CODE: 167 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines