PageRenderTime 37ms CodeModel.GetById 31ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Pango/Pango.xs

http://github.com/PerlGameDev/SDL
Unknown | 171 lines | 146 code | 25 blank | 0 comment | 0 complexity | fc6d5dfa467f2472be392d54c4ebc4a9 MD5 | raw file
  1#include "EXTERN.h"
  2#include "perl.h"
  3#include "XSUB.h"
  4
  5#include <SDL.h>
  6
  7#ifdef HAVE_SDL_PANGO
  8#include <SDL_Pango.h>
  9
 10SDLPango_Matrix _MATRIX_DEFAULT
 11    = {0, 255, 0, 0,
 12       0, 255, 0, 0,
 13       0, 255, 0, 0,
 14       0, 255, 0, 0,};
 15
 16SDLPango_Matrix *MATRIX_DEFAULT = &_MATRIX_DEFAULT;
 17
 18#endif
 19
 20MODULE = SDL::Pango	PACKAGE = SDL::Pango	PREFIX = pango_
 21
 22=for documentation
 23
 24See L<http:/*sdlpango.sourceforge.net/> */
 25
 26=cut
 27
 28#ifdef HAVE_SDL_PANGO
 29
 30int
 31pango_init()
 32	CODE:
 33		RETVAL = SDLPango_Init();
 34	OUTPUT:
 35		RETVAL
 36
 37int
 38pango_was_init()
 39	CODE:
 40		RETVAL = SDLPango_WasInit();
 41	OUTPUT:
 42		RETVAL
 43
 44void
 45pango_draw(context, surface, x, y)
 46	SDLPango_Context *context
 47	SDL_Surface *surface
 48	int x
 49	int y
 50	CODE:
 51		SDLPango_Draw(context, surface, x, y);
 52
 53int
 54pango_get_layout_width(context)
 55	SDLPango_Context *context
 56	CODE:
 57		RETVAL = SDLPango_GetLayoutWidth(context);
 58	OUTPUT:
 59		RETVAL
 60
 61int
 62pango_get_layout_height(context)
 63	SDLPango_Context *context
 64	CODE:
 65		RETVAL = SDLPango_GetLayoutHeight(context);
 66	OUTPUT:
 67		RETVAL
 68
 69void
 70pango_set_default_color(context, ...)
 71	SDLPango_Context *context
 72	CODE:
 73		if(items == 3) /* context, foreground, background */
 74		{
 75			Uint32 fg = SvIV(ST(1));
 76			Uint32 bg = SvIV(ST(2));
 77			MATRIX_DEFAULT->m[0][1] = (fg >> 24) & 0xFF; /* fg red */
 78			MATRIX_DEFAULT->m[1][1] = (fg >> 16) & 0xFF; /* fg green */
 79			MATRIX_DEFAULT->m[2][1] = (fg >>  8) & 0xFF; /* fg blue */
 80			MATRIX_DEFAULT->m[3][1] =  fg        & 0xFF; /* fg alpha */
 81			MATRIX_DEFAULT->m[0][0] = (bg >> 24) & 0xFF; /* bg red */
 82			MATRIX_DEFAULT->m[1][0] = (bg >> 16) & 0xFF; /* bg green */
 83			MATRIX_DEFAULT->m[2][0] = (bg >>  8) & 0xFF; /* bg blue */
 84			MATRIX_DEFAULT->m[3][0] =  bg        & 0xFF; /* bg alpha */
 85			SDLPango_SetDefaultColor(context, MATRIX_DEFAULT);
 86		}
 87		else if(items == 9) /* context, fr, fg, fb, fa, br, bg, bb, ba */
 88		{
 89			MATRIX_DEFAULT->m[0][1] = SvIV(ST(1)); /* fg red */
 90			MATRIX_DEFAULT->m[1][1] = SvIV(ST(2)); /* fg green */
 91			MATRIX_DEFAULT->m[2][1] = SvIV(ST(3)); /* fg blue */
 92			MATRIX_DEFAULT->m[3][1] = SvIV(ST(4)); /* fg alpha */
 93			MATRIX_DEFAULT->m[0][0] = SvIV(ST(5)); /* bg red */
 94			MATRIX_DEFAULT->m[1][0] = SvIV(ST(6)); /* bg green */
 95			MATRIX_DEFAULT->m[2][0] = SvIV(ST(7)); /* bg blue */
 96			MATRIX_DEFAULT->m[3][0] = SvIV(ST(8)); /* bg alpha */
 97			SDLPango_SetDefaultColor(context, MATRIX_DEFAULT);
 98		}
 99		else
100			croak("Usage: SDL::Pango::set_default_color(context, fg, bg) or (context, r, g, b, a, r, g, b, a)");
101
102void
103pango_set_markup(context, markup, length)
104	SDLPango_Context *context
105	const char *markup
106	int length
107	CODE:
108		SDLPango_SetMarkup(context, markup, length);
109
110void
111pango_set_minimum_size(context, width, height)
112	SDLPango_Context *context
113	int width
114	int height
115	CODE:
116		SDLPango_SetMinimumSize(context, width, height);
117
118void
119pango_set_surface_create_args(context, flags, depth, Rmask, Gmask, Bmask, Amask)
120	SDLPango_Context *context
121	Uint32 flags
122    int depth
123    Uint32 Rmask
124	Uint32 Gmask
125	Uint32 Bmask
126	Uint32 Amask
127	CODE:
128		SDLPango_SetSurfaceCreateArgs(context, flags, depth, Rmask, Gmask, Bmask, Amask);
129
130SDL_Surface *
131pango_create_surface_draw(context)
132	SDLPango_Context *context
133	PREINIT:
134		char* CLASS = "SDL::Surface";
135	CODE:
136		RETVAL = SDLPango_CreateSurfaceDraw(context);
137	OUTPUT:
138		RETVAL
139
140void
141pango_set_dpi(context, dpi_x, dpi_y)
142	SDLPango_Context *context
143	double dpi_x
144	double dpi_y
145	CODE:
146		SDLPango_SetDpi(context, dpi_x, dpi_y);
147
148void
149pango_set_text(context, markup, length, alignment = SDLPANGO_ALIGN_LEFT)
150	SDLPango_Context *context
151	const char *markup
152	int length
153	SDLPango_Alignment alignment
154	CODE:
155		SDLPango_SetText_GivenAlignment(context, markup, length, alignment);
156
157void
158pango_set_language(context, language_tag)
159	SDLPango_Context *context
160	const char *language_tag
161	CODE:
162		SDLPango_SetLanguage(context, language_tag);
163
164void
165pango_set_base_direction(context, direction)
166	SDLPango_Context *context
167	int direction
168	CODE:
169		SDLPango_SetBaseDirection(context, direction);
170
171#endif