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

File Contents

# Content
1 /* frame.cc
2 * This file is part of NDK++ library
3 * Copyright (c) 2003,2004 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
9 #include <ndk/pen.hh>
10 #include <ndk/frame.hh>
11 #include <ndk/palette.hh>
12
13
14 ndk::frame::frame (std::string const &title, panel *parent)
15 : panel (parent)
16 , title_ (title)
17 , active_ (false)
18 {
19 events ()->on_system (slot (&frame::at_system, this));
20 }
21
22 void
23 ndk::frame::draw ()
24 {
25 panel::draw ();
26
27 pen p (*this);
28 p.clear ();
29
30 p.set_color (palette::instance ().find (active_ ? colors::frame1 : colors::frame2)->second);
31 p.frame ();
32 if (!title_.empty ())
33 p.title (title_.substr (0, width () - 2));
34 p.set_color (palette::instance ().find (colors::frame2)->second);
35 }
36
37 int
38 ndk::frame::padding () const
39 {
40 return 1;
41 }
42
43 std::string const &
44 ndk::frame::title () const
45 {
46 return title_;
47 }
48
49 void
50 ndk::frame::set_title (std::string const &title)
51 {
52 title_ = title;
53 }
54
55 ndk::event::result
56 ndk::frame::at_system (ndk::event const &ev)
57 {
58 event::result res = event::ignored;
59
60 if (!ev.sender_)
61 {
62 active_ = engine::enter_focus == ev.type_;
63 prepare ();
64 res = event::accepted;
65 }
66
67 return res;
68 }