original 1.0.1 release
[xwelltris.git] / src / sdl / sdlwellimagefont.cxx
blob010c33407687f3564b883e04e9b0e38e1952567b
1 // docm_prefix(///)
2 /****************************************************************************
3 * Copyright (C) 2002-2003 by Leo Khramov
4 * email: leo@xnc.dubna.su
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 ****************************************************************************/
16 // $Id: sdlwellimagefont.cxx,v 1.2 2003/02/20 15:09:41 leo Exp $
18 /// module description
19 /// SDL version of imagefont - displays text with SDL calls, work with pixmaps
20 /// loaded thought XWellEngine class
22 #include "sdlwellimagefont.h"
24 //===========================================================================
25 /// global WellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy)
26 /// Constructor of base draw text class
27 /// tags WellImageFont
28 SDLWellImageFont::SDLWellImageFont(Images id, unsigned int ifl, unsigned int ifh,
29 int idx, int idy):
30 WellImageFont(id,ifl,ifh,idx,idy)
32 engine=(SDLWellEngine*) default_well_engine;
33 font_surf=engine->get_pixmap_of_image(id);
34 mainw=engine->get_main_window();
37 //===========================================================================
38 /// global clear_region()
39 /// clear region on screen for making output
40 /// tags SDLWellImageFont
41 void SDLWellImageFont::clear_region()
43 SDL_Rect dest;
44 dest.x = screen_x;
45 dest.y = screen_y;
46 dest.w = screen_l;
47 dest.h = screen_h;
48 SDL_FillRect(mainw, &dest, 0);
49 SDL_UpdateRects(mainw, 1, &dest);
52 //===========================================================================
53 /// global clear_region()
54 /// clear region on screen for making output
55 /// tags SDLWellImageFont
56 void SDLWellImageFont::clear_region(Colors idx)
58 SDL_Rect dest;
59 Uint32 *cols=engine->get_colors();
61 dest.x = screen_x;
62 dest.y = screen_y;
63 dest.w = screen_l;
64 dest.h = screen_h;
66 SDL_FillRect(mainw, &dest, cols[idx]);
67 SDL_UpdateRects(mainw, 1, &dest);
70 //===========================================================================
71 /// global draw_symbol(...)
72 /// draw one symbol from font image to screen
73 /// tags SDLWellImageFont
74 void SDLWellImageFont::draw_symbol(int ix, int iy,
75 unsigned int il,
76 unsigned int ih,
77 char symb)
79 SDL_Rect src,dest;
81 if(symb<=32 || symb>=127)
82 return;
83 symb-=33; //Translate to our indexation
85 dest.x = ix;
86 dest.y = iy;
87 dest.w = il;
88 dest.h = ih;
89 src.x = dx;
90 src.y = dy+(int)symb*font_h;
91 src.w = il;
92 src.h = ih;
93 SDL_BlitSurface(font_surf, &src, mainw, &dest);
94 /* Update the changed portion of the screen */
95 SDL_UpdateRects(mainw, 1, &dest);