ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ndk/label.cpp
Revision: 1.3
Committed: Mon Oct 18 15:34:23 2010 UTC (15 years, 11 months ago) by sf-pippijn
Branch: MAIN
Changes since 1.2: +5 -5 lines
Log Message:
first attempt to support maximising windows

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.2 #include <ncurses/assert.hh>
12    
13 sf-pippijn 1.3 using ndk::label;
14 sf-pippijn 1.1
15 sf-pippijn 1.3 label::label (std::string const &str, ndk::panel *parent)
16 sf-pippijn 1.1 : ndk::panel (parent)
17     , text_ (str)
18     {
19     if (!str.empty ())
20     panel::resize (str.length (), 1);
21     events ()->set_accept (false); /* this widget doesn't accept focus */
22     }
23    
24     void
25 sf-pippijn 1.3 label::set_text (std::string const &str)
26 sf-pippijn 1.1 {
27     text_ = str;
28     }
29    
30 sf-pippijn 1.3 std::string const &
31 sf-pippijn 1.1 label::text () const
32     {
33     return text_;
34     }
35    
36     void
37     label::draw ()
38     {
39     draw (this->text_, 0); /* simple drawing of the text */
40     }
41    
42     void
43 sf-pippijn 1.3 label::draw (std::string const &str, std::string::size_type begin)
44 sf-pippijn 1.1 {
45     ncurses::pen p (*this);
46    
47     set_color (p);
48 sf-pippijn 1.2 return_unless (p.move (0, 0));
49 sf-pippijn 1.1 std::string out (str.substr (begin, this->width ()));
50     if (int (out.length ()) < this->width ())
51     out.append (this->width () - out.length (), ' ');
52     p.write (out);
53     }
54    
55     void
56     label::set_color (ncurses::pen &p)
57     {
58     p.set_color (palette::instance ()[colors::label]);
59     }