Adonthell  0.4
text_bubble.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2001/2002/2016 Kai Sterker <kai.sterker@gmail.com>
3  Copyright (C) 2001 Alexandre Courbot <alexandrecourbot@linuxgames.com>
4  Part of the Adonthell Project <http://adonthell.nongnu.org>
5 
6  Adonthell 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.
10 
11  Adonthell 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  You should have received a copy of the GNU General Public License
17  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 /**
22  * @file text_bubble.cc
23  * @author Kai Sterker <kai.sterker@gmail.com>
24  * @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
25  *
26  * @brief Defines the text_bubble class.
27  *
28  *
29  */
30 
31 #include "nls.h"
32 #include "text_bubble.h"
33 #include "win_manager.h"
34 
35 text_bubble::text_bubble (const string & text, const string & textcolor,
36  const string & themename, u_int16 len) : win_label ()
37 {
38  remain = 75 + text.length () * 4;
39 
40  win_font * font = win_manager::get_font (textcolor);
41  win_theme * theme = win_manager::get_theme (themename);
42 
43  set_font (*font);
44  set_background (*theme);
45  set_border (*theme, win_border::MINI);
46 
47  label::resize (len, 0);
48  set_form (label::AUTO_HEIGHT);
49  set_text (nls::translate (text));
50  fit_text_width();
51  set_visible_border (true);
52  set_visible_background (true);
53  set_trans_background (true);
54  set_visible (true);
55  pack ();
56 }
57 
59 {
60 }
61 
63 {
64  if (win_label::update ())
65  {
66  remain--;
67  if (!remain) return false;
68  }
69  return true;
70 }
text_bubble::~text_bubble
~text_bubble()
Destructor.
Definition: text_bubble.cc:58
text_bubble::update
bool update()
Update function.
Definition: text_bubble.cc:62
nls.h
National Language Support.
win_base::set_visible
void set_visible(const bool b)
Set the visible parameter.
Definition: win_base.h:140
win_object::update
bool update()
Update process.
Definition: win_object.h:113
win_manager::get_theme
static win_theme * get_theme(string name)
Returns a pointer to a theme.
Definition: win_manager.cc:221
label::resize
void resize(u_int16 l, u_int16 h)
Resize the label.
Definition: label.cc:116
win_manager.h
Declares the win_manager class.
text_bubble.h
Declares the text_bubble class.
win_font
Definition: win_font.h:32
u_int16
#define u_int16
16 bits long unsigned integer
Definition: types.h:38
nls::translate
static const string translate(const string &text)
Translate the given string if it's found in the message catalogue.
Definition: nls.cc:76
win_theme
Definition: win_theme.h:24
win_object
Definition: win_object.h:26
text_bubble::text_bubble
text_bubble(const string &text, const string &textcolor, const string &themename, u_int16 len=110)
Constructor.
Definition: text_bubble.cc:35
win_manager::get_font
static win_font * get_font(string name)
Returns a pointer to a font.
Definition: win_manager.cc:252