ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ndk/panel.cpp
Revision: 1.1
Committed: Sun Oct 17 08:15:09 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Log Message:
initial import

File Contents

# User Rev Content
1 sf-pippijn 1.1 /* panel.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     #include <ncurses/pen.hh>
9     #include <ndk++/palette.hh>
10    
11     #include <ndk++/panel.hh>
12     #include <ndk++/application.hh>
13    
14    
15     ndk::panel::panel (panel *parent)
16     : ncurses::panel (parent)
17     , events_ (parent ? parent->events () : 0, this)
18     {
19     events ()->on_system (ndk::slot (&panel::at_system, this));
20     }
21    
22     /**
23     * @todo add support for palette
24     */
25     void
26     ndk::panel::draw ()
27     {
28     ncurses::pen (*this).fill (palette::instance ()[colors::panel]);
29     }
30    
31     int
32     ndk::panel::padding () const
33     {
34     return 0;
35     }
36    
37     void
38     ndk::panel::emit (int type)
39     {
40     events_.emit (type);
41     }
42    
43     ndk::engine *
44     ndk::panel::events ()
45     {
46     return &events_;
47     }
48    
49     void
50     ndk::panel::in_focus (panel &other)
51     {
52     events_.in_focus (other.events ());
53     }
54    
55     void
56     ndk::panel::focus ()
57     {
58     if (parent ())
59     {
60     dynamic_cast<panel &> (*parent ()).focus ();
61     dynamic_cast<panel &> (*parent ()).in_focus (*this);
62     }
63     else
64     ndk::app ().in_focus (*this);
65     }
66    
67     ndk::event::result
68     ndk::panel::at_system (const event &ev)
69     {
70     if (!ev.sender_ && engine::enter_focus == ev.type_)
71     {
72     top ();
73     return event::accepted;
74     }
75     return event::ignored;
76     }