libyui-ncurses
Loading...
Searching...
No Matches
NCComboBox.h
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) version 3.0 of the License. This library
7 is distributed in the hope that it will be useful, but WITHOUT ANY
8 WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 License for more details. You should have received a copy of the GNU
11 Lesser General Public License along with this library; if not, write
12 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13 Floor, Boston, MA 02110-1301 USA
14*/
15
16
17/*-/
18
19 File: NCComboBox.h
20
21 Author: Michael Andres <ma@suse.de>
22
23/-*/
24
25#ifndef NCComboBox_h
26#define NCComboBox_h
27
28#include <iosfwd>
29#include <list>
30
31#include <yui/YComboBox.h>
32#include "NCWidget.h"
33#include "NCApplication.h"
34#include <yui/YItem.h>
35
36
37class NCComboBox : public YComboBox, public NCWidget
38{
39private:
40
41 friend std::ostream & operator<<( std::ostream & str, const NCComboBox & obj );
42
43 NCComboBox & operator=( const NCComboBox & );
44 NCComboBox( const NCComboBox & );
45
46
47 bool mayedit;
48 NClabel label;
49 NCstring privText;
50 std::wstring buffer;
51 bool modified;
52 NCursesWindow * lwin;
53 NCursesWindow * twin;
54
55 std::string::size_type fldstart;
56 std::string::size_type fldlength;
57 std::string::size_type curpos;
58 std::string::size_type longest_line;
59
60 NCstring validChars;
61
62 std::list<std::string> deflist;
63 int index;
64
65 void setDefsze();
66 void tUpdate();
67
68 bool haveUtf8() { return YUI::app()->hasFullUtf8Support(); }
69
70protected:
71
72 virtual const char * location() const { return "NCComboBox"; }
73
74 virtual void wCreate( const wrect & newrect );
75 virtual void wDelete();
76
77 virtual void wRedraw();
78 virtual void wRecoded();
79
80 int listPopup();
81
82 bool validKey( wint_t key ) const;
83
84 // specifies how much characters can be inserted. -1 for unlimited input
85 int InputMaxLength;
86
87public:
88
89 NCComboBox( YWidget * parent,
90 const std::string & label,
91 bool editable );
92 virtual ~NCComboBox();
93
94 virtual void addItem( YItem * item );
95 virtual void selectItem( YItem * item, bool selected = true );
96
97 void addItem( const std::string & label, bool selected );
98
99 virtual int preferredWidth();
100 virtual int preferredHeight();
101
102 virtual void setSize( int newWidth, int newHeight );
103
104 virtual void setLabel( const std::string & nlabel );
105
106 virtual void setText( const std::string & ntext );
107 virtual std::string text();
108
109 virtual void setValidChars( const std::string & validchars );
110
111 virtual int getCurrentItem() const;
112 virtual void setCurrentItem( int index );
113
114 virtual NCursesEvent wHandleInput( wint_t key );
115
116 virtual void setEnabled( bool do_bv );
117
118 virtual bool setKeyboardFocus()
119 {
120 if ( !grabFocus() )
121 return YWidget::setKeyboardFocus();
122
123 return true;
124 }
125
126 unsigned getListSize() { return deflist.size(); }
127
128 void deleteAllItems();
129
130 // limits the input to numberOfChars characters and truncates the text
131 // if appropriate
132 void setInputMaxLength( int nr );
133
134};
135
136
137#endif // NCComboBox_h
Definition NCComboBox.h:38
virtual void setEnabled(bool do_bv)
Definition NCComboBox.cc:76
Definition NCWidget.h:46
Multi-line string, with optional hotkey, drawable.
Definition NCtext.h:82
Definition NCstring.h:36
Definition NCurses.h:73
C++ class for windows.
Definition ncursesw.h:907
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
Definition position.h:194