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

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