1 /*
2  *  This file is part of the XForms library package.
3  *
4  *  XForms is free software; you can redistribute it and/or modify it
5  *  under the terms of the GNU Lesser General Public License as
6  *  published by the Free Software Foundation; either version 2.1, or
7  *  (at your option) any later version.
8  *
9  *  XForms is distributed in the hope that it will be useful, but
10  *  WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public License
15  *  along with XForms.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /********************** crop here for forms.h **********************/
19 
20 /**
21  * \file input.h
22  */
23 
24 #ifndef FL_INPUT_H
25 #define FL_INPUT_H
26 
27 
28 /***** Types    *****/
29 
30 typedef enum {
31     FL_NORMAL_INPUT,
32     FL_FLOAT_INPUT,
33     FL_INT_INPUT,
34     FL_DATE_INPUT,
35     FL_MULTILINE_INPUT,
36     FL_HIDDEN_INPUT,
37     FL_SECRET_INPUT
38 } FL_INPUT_TYPE;
39 
40 /* for date input */
41 
42 enum {
43     FL_INPUT_MMDD,
44     FL_INPUT_DDMM
45 };
46 
47 enum {
48     FL_NORMAL_INPUT_MODE,
49     FL_DOS_INPUT_MODE
50 };
51 
52 /***** Defaults *****/
53 
54 #define FL_INPUT_BOXTYPE    FL_DOWN_BOX
55 #define FL_INPUT_COL1       FL_COL1
56 #define FL_INPUT_COL2       FL_MCOL
57 #define FL_INPUT_LCOL       FL_LCOL
58 #define FL_INPUT_ALIGN      FL_ALIGN_LEFT
59 
60 /***** Others   *****/
61 
62 #define FL_INPUT_TCOL       FL_LCOL
63 #define FL_INPUT_CCOL       FL_BLUE
64 
65 #define FL_RINGBELL         ( 1 << 4 )
66 
67 /***** Routines *****/
68 
69 FL_EXPORT FL_OBJECT * fl_create_input( int          type,
70                                        FL_Coord     x,
71                                        FL_Coord     y,
72                                        FL_Coord     w,
73                                        FL_Coord     h,
74                                        const char * label );
75 
76 FL_EXPORT FL_OBJECT * fl_add_input( int          type,
77                                     FL_Coord     x,
78                                     FL_Coord     y,
79                                     FL_Coord     w,
80                                     FL_Coord     h,
81                                     const char * label );
82 
83 FL_EXPORT void fl_set_input( FL_OBJECT  * ob,
84                              const char * str );
85 
86 FL_EXPORT void fl_set_input_f( FL_OBJECT  * obj,
87 							   const char * fmt,
88 							   ... );
89 
90 FL_EXPORT void fl_set_input_return( FL_OBJECT    * ob,
91                                     unsigned int   when );
92 
93 FL_EXPORT void fl_set_input_color( FL_OBJECT * ob,
94                                    FL_COLOR    textcol,
95                                    FL_COLOR    curscol );
96 
97 FL_EXPORT void fl_get_input_color( FL_OBJECT * ob,
98                                    FL_COLOR  * textcol,
99                                    FL_COLOR  * curscol );
100 
101 FL_EXPORT void fl_set_input_scroll( FL_OBJECT * ob,
102                                     int         yes );
103 
104 FL_EXPORT void fl_set_input_cursorpos( FL_OBJECT * ob,
105                                        int         xpos,
106                                        int         ypos );
107 
108 FL_EXPORT void fl_set_input_selected( FL_OBJECT * ob,
109                                       int         yes );
110 
111 FL_EXPORT void fl_set_input_selected_range( FL_OBJECT * ob,
112                                             int         begin,
113                                             int         end );
114 
115 FL_EXPORT const char *fl_get_input_selected_range( FL_OBJECT * ob,
116                                                    int       * begin,
117                                                    int       * end );
118 
119 FL_EXPORT void fl_set_input_maxchars( FL_OBJECT * ob,
120                                       int         maxchars );
121 
122 FL_EXPORT void fl_set_input_format( FL_OBJECT * ob,
123                                     int         fmt,
124                                     int         sep );
125 
126 FL_EXPORT void fl_set_input_hscrollbar( FL_OBJECT * ob,
127                                         int         pref );
128 
129 FL_EXPORT void fl_set_input_vscrollbar( FL_OBJECT * ob,
130                                         int         pref );
131 
132 FL_EXPORT void fl_set_input_topline( FL_OBJECT * ob,
133                                      int         top );
134 
135 FL_EXPORT void fl_set_input_scrollbarsize( FL_OBJECT * ob,
136                                            int         hh,
137                                            int         vw );
138 
139 FL_EXPORT void fl_get_input_scrollbarsize( FL_OBJECT * ob,
140                                            int       * hh,
141                                            int       * vw );
142 
143 FL_EXPORT void fl_set_input_xoffset( FL_OBJECT * ob,
144                                      int         xoff );
145 
146 FL_EXPORT int fl_get_input_xoffset( FL_OBJECT * ob );
147 
148 FL_EXPORT int fl_set_input_fieldchar( FL_OBJECT * ob,
149                                       int         fchar );
150 
151 FL_EXPORT int fl_get_input_topline( FL_OBJECT * ob );
152 
153 FL_EXPORT int fl_get_input_screenlines( FL_OBJECT * ob );
154 
155 FL_EXPORT int fl_get_input_cursorpos( FL_OBJECT * ob,
156                                       int       * x,
157                                       int       * y );
158 
159 FL_EXPORT void fl_set_input_cursor_visible( FL_OBJECT * ob,
160                                             int         visible );
161 
162 FL_EXPORT int fl_get_input_numberoflines( FL_OBJECT * ob );
163 
164 FL_EXPORT void fl_get_input_format( FL_OBJECT * ob,
165                                     int       * fmt,
166                                     int       * sep );
167 
168 FL_EXPORT const char * fl_get_input( FL_OBJECT * ob );
169 
170 typedef int ( * FL_INPUT_VALIDATOR )(FL_OBJECT  *,
171 									 const char *,
172 									 const char *,
173 									 int );
174 
175 #define FL_INPUTVALIDATOR FL_INPUT_VALIDATOR
176 
177 FL_EXPORT FL_INPUT_VALIDATOR
178 fl_set_input_filter( FL_OBJECT          * ob,
179 					 FL_INPUT_VALIDATOR   validate );
180 
181 FL_EXPORT int fl_validate_input( FL_OBJECT *obj );
182 
183 #define fl_set_input_shortcut   fl_set_object_shortcut
184 
185 /* edit keys. */
186 
187 typedef struct {
188     /* basic editing */
189 
190     long del_prev_char;     /* delete previous char    */
191     long del_next_char;     /* delete next char        */
192     long del_prev_word;     /* delete previous word    */
193     long del_next_word;     /* delete next word        */
194 
195     /* movement */
196 
197     long moveto_prev_line;  /* one line  up             */
198     long moveto_next_line;  /* one line down            */
199     long moveto_prev_char;  /* one char left            */
200     long moveto_next_char;  /* one char right           */
201     long moveto_prev_word;  /* one word left            */
202     long moveto_next_word;  /* one word right           */
203     long moveto_prev_page;  /* one page up              */
204     long moveto_next_page;  /* one page down            */
205     long moveto_bol;        /* move to begining of line */
206     long moveto_eol;        /* move to end of line      */
207     long moveto_bof;        /* move to begin of file    */
208     long moveto_eof;        /* move to end of file      */
209 
210     /* misc. stuff */
211 
212     long transpose;         /* switch two char positions */
213     long paste;             /* paste the edit buffer    */
214     long backspace;         /* another  del_prev_char   */
215     long del_to_bol;        /* cut to begining of line  */
216     long del_to_eol;        /* cut to end of line       */
217     long clear_field;       /* delete everything        */
218     long del_to_eos;        /* not implemented          */
219 } FL_EditKeymap;
220 
221 FL_EXPORT void fl_set_input_editkeymap( const FL_EditKeymap * keymap );
222 
223 FL_EXPORT void fl_get_input_editkeymap( FL_EditKeymap * keymap );
224 
225 FL_EXPORT void fl_set_default_editkeymap( void );
226 
227 FL_EXPORT int fl_set_input_mode( int mode );
228 
229 #endif /* ! defined FL_INPUT_H */
230