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.16 by root, Tue Apr 11 13:27:48 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 PangoFontDescription *font = pango_context_get_font_description (context);
31 pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE);
32
30 pango_layout_get_pixel_size (self->pl, w, h); 33 pango_layout_get_pixel_size (self->pl, w, h);
31 34
32 *w = (*w + 3) & ~3; 35 *w = (*w + 3) & ~3;
33 if (!*w) *w = 1; 36 if (!*w) *w = 1;
34 if (!*h) *h = 1; 37 if (!*h) *h = 1;
35} 38}
36 39
37MODULE = Crossfire::Client PACKAGE = Crossfire::Client 40MODULE = CFClient PACKAGE = CFClient
38 41
39PROTOTYPES: ENABLE 42PROTOTYPES: ENABLE
40 43
41BOOT: 44BOOT:
42{ 45{
77 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); 80 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0);
78 FcPatternDestroy (pattern); 81 FcPatternDestroy (pattern);
79 pango_context_set_font_description (context, font); 82 pango_context_set_font_description (context, font);
80} 83}
81 84
82MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Layout 85MODULE = CFClient PACKAGE = CFClient::Layout
83 86
84Crossfire::Client::Layout 87CFClient::Layout
85new (SV *class, int base_height = 10) 88new (SV *class, int base_height = 10)
86 CODE: 89 CODE:
87 New (0, RETVAL, 1, struct cf_layout); 90 New (0, RETVAL, 1, struct cf_layout);
88 RETVAL->base_height = base_height; 91 RETVAL->base_height = base_height;
89 RETVAL->pl = pango_layout_new (context); 92 RETVAL->pl = pango_layout_new (context);
90 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 93 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
91 OUTPUT: 94 OUTPUT:
92 RETVAL 95 RETVAL
93 96
94void 97void
95DESTROY (Crossfire::Client::Layout self) 98DESTROY (CFClient::Layout self)
96 CODE: 99 CODE:
97 g_object_unref (self->pl); 100 g_object_unref (self->pl);
98 Safefree (self); 101 Safefree (self);
99 102
100void 103void
101set_markup (Crossfire::Client::Layout self, SV *text_) 104set_markup (CFClient::Layout self, SV *text_)
102 CODE: 105 CODE:
103{ 106{
104 STRLEN textlen; 107 STRLEN textlen;
105 char *text = SvPVutf8 (text_, textlen); 108 char *text = SvPVutf8 (text_, textlen);
106 109
107 pango_layout_set_markup (self->pl, text, textlen); 110 pango_layout_set_markup (self->pl, text, textlen);
108} 111}
109 112
110void 113void
114set_height (CFClient::Layout self, int base_height)
115 CODE:
116 self->base_height = base_height;
117
118void
111set_width (Crossfire::Client::Layout self, int max_width = -1) 119set_width (CFClient::Layout self, int max_width = -1)
112 CODE: 120 CODE:
113 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 121 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
114 122
115void 123void
116size (Crossfire::Client::Layout self) 124size (CFClient::Layout self)
117 PPCODE: 125 PPCODE:
118{ 126{
119 int w, h; 127 int w, h;
120
121 PangoFontDescription *font = pango_context_get_font_description (context);
122 pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE);
123 128
124 layout_get_pixel_size (self, &w, &h); 129 layout_get_pixel_size (self, &w, &h);
125 130
126 EXTEND (SP, 2); 131 EXTEND (SP, 2);
127 PUSHs (sv_2mortal (newSViv (w))); 132 PUSHs (sv_2mortal (newSViv (w)));
128 PUSHs (sv_2mortal (newSViv (h))); 133 PUSHs (sv_2mortal (newSViv (h)));
129} 134}
130 135
131void 136void
132render (Crossfire::Client::Layout self) 137render (CFClient::Layout self)
133 PPCODE: 138 PPCODE:
134{ 139{
135 SV *retval; 140 SV *retval;
136 int w, h; 141 int w, h;
137 FT_Bitmap bitmap; 142 FT_Bitmap bitmap;
157 PUSHs (sv_2mortal (newSViv (w))); 162 PUSHs (sv_2mortal (newSViv (w)));
158 PUSHs (sv_2mortal (newSViv (h))); 163 PUSHs (sv_2mortal (newSViv (h)));
159 PUSHs (sv_2mortal (retval)); 164 PUSHs (sv_2mortal (retval));
160} 165}
161 166
162MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture 167MODULE = CFClient PACKAGE = CFClient::Texture
163 168
164void 169void
165draw_quad (SV *self, double x, double y, double w = 0, double h = 0) 170draw_quad (SV *self, double x, double y, double w = 0, double h = 0)
166 PROTOTYPE: $$$;$$ 171 PROTOTYPE: $$$;$$
167 CODE: 172 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines