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

File Contents

# User Rev Content
1 sf-pippijn 1.1 /* button.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++/application.hh>
10     #include <ndk++/button.hh>
11     #include <ndk++/palette.hh>
12    
13     using namespace ndk;
14    
15     namespace
16     {
17     struct run_callback
18     {
19     /**< functor to run callback functions */
20     template<typename CallbackT>
21     void
22     operator () (CallbackT &callback)
23     {
24     callback ();
25     }
26     };
27     }
28    
29    
30     mini_button::mini_button (const std::string &str, ndk::panel *parent, bool accept)
31     : label (str, parent)
32     {
33     }
34    
35     button::button (const std::string &str, panel *parent, bool accept)
36     : label (str, parent)
37     , state_ (engine::leave_focus)
38     {
39     events ()->on_system (slot (&button::at_system, this));
40     }
41    
42     void
43     button::set_color (ncurses::pen &p)
44     {
45     p.set_color (palette::instance ()[colors::button_focused]);
46     }
47    
48     /*
49     * Note:
50     * There are following reason to move widget's panel to the top:
51     * ncurses has strange algorithm of moving cursor
52     * if widget on the top, it's cursor is active and visible on the screen
53     * I need this feature for the Line Edit
54     */
55     event::result
56     button::at_system (const event &ev) /**< system event processor */
57     {
58     event::result res = event::ignored;
59    
60     if (!ev.sender_)
61     {
62     state_ = ev.type_;
63     res = event::accepted;
64     draw ();
65     }
66    
67     return res;
68     }