Debian Codegraph @

src/widget/WiStatusBar.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "WiStatusBar.h"
10
11 #include "Font.h"
12
13 //-----------------------------------------------------------------
14 WiStatusBar::WiStatusBar(Font *new_font, const SDL_Color &color, int width)
15 : m_color(color)
16 {
17 m_font = new_font;
18 m_w = width;
19 }
20 //-----------------------------------------------------------------
21 WiStatusBar::~WiStatusBar()
22 {
23 delete m_font;
24 }
25 //-----------------------------------------------------------------
26 int
27 WiStatusBar::getH() const
28 {
29 return m_font->getHeight();
30 }
31 //-----------------------------------------------------------------
32 void
33 WiStatusBar::drawOn(SDL_Surface *screen)
34 {
35 if (!m_label.empty()) {
36 SDL_Rect rect;
37 rect.x = m_shift.getX();
38 rect.y = m_shift.getY();
39
40 SDL_Surface *rendered = m_font->renderTextOutlined(m_label, m_color);
41 SDL_BlitSurface(rendered, NULL, screen, &rect);
42 SDL_FreeSurface(rendered);
43 }
44 }
45