ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ndk/label.cpp
Revision: 1.6
Committed: Sun Oct 24 20:31:51 2010 UTC (15 years, 11 months ago) by sf-pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +3 -3 lines
Log Message:
use EV and plain sockets instead of asio

File Contents

# Content
1 /* label.cc
2 * This file is part of NDK++ library
3 * Copyright (c) 2003 by Stanislav Ievlev
4 *
5 * This file is covered by the GNU Library General Public License,
6 * which should be included with libndk as the file COPYING.
7 */
8 #include <ndk/label.hh>
9 #include <ndk/palette.hh>
10
11 using ndk::label;
12
13 label::label (std::string const &str, ndk::panel *parent)
14 : panel (parent)
15 , text_ (str)
16 {
17 if (!str.empty ())
18 panel::resize (str.length (), 1);
19 events ()->set_accept (false); /* this widget doesn't accept focus */
20 }
21
22 void
23 label::set_text (std::string const &str)
24 {
25 text_ = str;
26 }
27
28 std::string const &
29 label::text () const
30 {
31 return text_;
32 }
33
34 void
35 label::draw ()
36 {
37 draw (this->text_, 0); /* simple drawing of the text */
38 }
39
40 void
41 label::draw (std::string const &str, std::string::size_type begin)
42 {
43 pen p (*this);
44
45 set_color (p);
46 return_unless (p.move (0, 0));
47 std::string out (str.substr (begin, this->width ()));
48 if (int (out.length ()) < this->width ())
49 out.append (this->width () - out.length (), ' ');
50 p.write (out);
51 }
52
53 void
54 label::set_color (pen &p)
55 {
56 p.set_color (palette::instance ().find (colors::label)->second);
57 }