ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ndk/label.cpp
Revision: 1.4
Committed: Mon Oct 18 16:38:03 2010 UTC (15 years, 11 months ago) by sf-pippijn
Branch: MAIN
Changes since 1.3: +0 -2 lines
Log Message:
support msg colours

File Contents

# User Rev Content
1 sf-pippijn 1.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 sf-pippijn 1.3 using ndk::label;
12 sf-pippijn 1.1
13 sf-pippijn 1.3 label::label (std::string const &str, ndk::panel *parent)
14 sf-pippijn 1.1 : ndk::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 sf-pippijn 1.3 label::set_text (std::string const &str)
24 sf-pippijn 1.1 {
25     text_ = str;
26     }
27    
28 sf-pippijn 1.3 std::string const &
29 sf-pippijn 1.1 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 sf-pippijn 1.3 label::draw (std::string const &str, std::string::size_type begin)
42 sf-pippijn 1.1 {
43     ncurses::pen p (*this);
44    
45     set_color (p);
46 sf-pippijn 1.2 return_unless (p.move (0, 0));
47 sf-pippijn 1.1 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 (ncurses::pen &p)
55     {
56     p.set_color (palette::instance ()[colors::label]);
57     }