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

File Contents

# Content
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 #include <ncurses/pen.hh>
11
12 #include <ndk++/application.hh>
13 #include <ndk++/edit.hh>
14 #include <ndk++/packer.hh>
15
16 using ndk::input;
17
18 input::input (std::string const &label, panel *parent)
19 : 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 input::set_label (std::string const &str)
47 {
48 label_.set_text (str);
49 }
50
51 void
52 input::set_text (std::string const &str)
53 {
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 std::string const &
64 input::text () const
65 {
66 return edit_.text ();
67 }
68
69 ndk::event::result
70 input::at_system (event const &ev)
71 {
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 }