ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/dclient/src/backend/ndk/frame.cpp
Revision: 1.1
Committed: Sun Oct 17 08:15:08 2010 UTC (13 years, 8 months ago) by sf-pippijn
Branch: MAIN
Log Message:
initial import

File Contents

# User Rev Content
1 sf-pippijn 1.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 <ncurses/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     ncurses::pen p (*this);
28     p.clear ();
29    
30     p.set_color (palette::instance ()[active_ ? colors::frame1 : colors::frame2]);
31     p.frame ();
32     if (!title_.empty ())
33     p.title (title_.substr (0, width () - 2));
34     p.set_color (palette::instance ()[colors::frame2]);
35     }
36    
37     int
38     ndk::frame::padding () const
39     {
40     return 1;
41     }
42    
43     void
44     ndk::frame::set_title (std::string const &title)
45     {
46     title_ = title;
47     }
48    
49     ndk::event::result
50     ndk::frame::at_system (ndk::event const &ev)
51     {
52     event::result res = event::ignored;
53    
54     if (!ev.sender_)
55     {
56     active_ = engine::enter_focus == ev.type_;
57     prepare ();
58     res = event::accepted;
59     }
60    
61     return res;
62     }