ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ndk/input.cpp
Revision: 1.3
Committed: Tue Oct 19 09:45:08 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.2: +1 -1 lines
Log Message:
- use wchar_t for single characters (glyphs and line drawing)
- merge ncurses and ndk wrappers
- simplify colour caching

File Contents

# User Rev Content
1 sf-pippijn 1.1 /* edit.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 <cctype>
9    
10 sf-pippijn 1.3 #include <ndk++/pen.hh>
11 sf-pippijn 1.1
12     #include <ndk++/application.hh>
13     #include <ndk++/edit.hh>
14     #include <ndk++/packer.hh>
15    
16     using ndk::input;
17    
18 sf-pippijn 1.2 input::input (std::string const &label, panel *parent)
19 sf-pippijn 1.1 : panel (parent)
20     , label_ (label, this)
21     , edit_ ("", this)
22     {
23     events ()->on_system (slot (&input::at_system, this));
24     }
25    
26     void
27     input::resize (int size)
28     {
29     panel::resize (size, 1);
30     size -= label_.width () + 1;
31     if (size > 0)
32     edit_.resize (size);
33     }
34    
35     void
36     input::draw ()
37     {
38     packer<pack::horizontal, pack::no_resizer> pack (this, align::center, 1);
39     pack.add (&label_);
40     pack.add (&edit_);
41     pack.pack ();
42     panel::draw ();
43     }
44    
45     void
46 sf-pippijn 1.2 input::set_label (std::string const &str)
47 sf-pippijn 1.1 {
48     label_.set_text (str);
49     }
50    
51     void
52 sf-pippijn 1.2 input::set_text (std::string const &str)
53 sf-pippijn 1.1 {
54     edit_.set_text (str);
55     }
56    
57     void
58     input::set_mode (edit::echo_mode mode)
59     {
60     edit_.set_mode (mode);
61     }
62    
63 sf-pippijn 1.2 std::string const &
64 sf-pippijn 1.1 input::text () const
65     {
66     return edit_.text ();
67     }
68    
69     ndk::event::result
70 sf-pippijn 1.2 input::at_system (event const &ev)
71 sf-pippijn 1.1 {
72     event::result res = event::ignored;
73    
74     if (!ev.sender_ && engine::enter_focus == ev.type_)
75     edit_.events ()->system (ev);
76     return res;
77     }