00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef Fl_Input__H
00023 #define Fl_Input__H
00024
00025 #ifndef Fl_Widget_H
00026 #include "Fl_Widget.H"
00027 #endif
00028
00029 #define FL_NORMAL_INPUT 0
00030 #define FL_FLOAT_INPUT 1
00031 #define FL_INT_INPUT 2
00032 #define FL_HIDDEN_INPUT 3
00033 #define FL_MULTILINE_INPUT 4
00034 #define FL_SECRET_INPUT 5
00035 #define FL_INPUT_TYPE 7
00036 #define FL_INPUT_READONLY 8
00037 #define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY)
00038 #define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
00039 #define FL_INPUT_WRAP 16
00040 #define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
00041 #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
00042
00094 class FL_EXPORT Fl_Input_ : public Fl_Widget {
00095
00097 const char* value_;
00098
00100 char* buffer;
00101
00103 int size_;
00104
00106 int bufsize;
00107
00109 int position_;
00110
00113 int mark_;
00114
00118 int tab_nav_;
00119
00121 int xscroll_, yscroll_;
00122
00125 int mu_p;
00126
00128 int maximum_size_;
00129
00131 int shortcut_;
00132
00134 uchar erase_cursor_only;
00135
00137 Fl_Font textfont_;
00138
00140 Fl_Fontsize textsize_;
00141
00143 Fl_Color textcolor_;
00144
00146 Fl_Color cursor_color_;
00147
00149 static double up_down_pos;
00150
00152 static int was_up_down;
00153
00154
00155 const char* expand(const char*, char*) const;
00156
00157
00158 double expandpos(const char*, const char*, const char*, int*) const;
00159
00160
00161 void minimal_update(int, int);
00162
00163
00164 void minimal_update(int p);
00165
00166
00167 void put_in_buffer(int newsize);
00168
00169
00170 void setfont() const;
00171
00172 protected:
00173
00174
00175 int word_start(int i) const;
00176
00177
00178 int word_end(int i) const;
00179
00180
00181 int line_start(int i) const;
00182
00183
00184 int line_end(int i) const;
00185
00186
00187 void drawtext(int, int, int, int);
00188
00189
00190 int up_down_position(int, int keepmark=0);
00191
00192
00193 void handle_mouse(int, int, int, int, int keepmark=0);
00194
00195
00196 int handletext(int e, int, int, int, int);
00197
00198
00199 void maybe_do_callback();
00200
00202 int xscroll() const {return xscroll_;}
00203
00205 int yscroll() const {return yscroll_;}
00206 void yscroll(int yOffset) { yscroll_ = yOffset; damage(FL_DAMAGE_EXPOSE);}
00207
00208
00209 int linesPerPage();
00210
00211 public:
00212
00213
00214 void resize(int, int, int, int);
00215
00216
00217 Fl_Input_(int, int, int, int, const char* = 0);
00218
00219
00220 ~Fl_Input_();
00221
00222
00223 int value(const char*);
00224
00225
00226 int value(const char*, int);
00227
00228
00229 int static_value(const char*);
00230
00231
00232 int static_value(const char*, int);
00233
00244 const char* value() const {return value_;}
00245
00246
00247 Fl_Char index(int i) const;
00248
00257 int size() const {return size_;}
00258
00262 void size(int W, int H) { Fl_Widget::size(W, H); }
00263
00266 int maximum_size() const {return maximum_size_;}
00267
00277 void maximum_size(int m) {maximum_size_ = m;}
00278
00283 int position() const {return position_;}
00284
00287 int mark() const {return mark_;}
00288
00289
00290 int position(int p, int m);
00291
00298 int position(int p) {return position(p, p);}
00299
00305 int mark(int m) {return position(position(), m);}
00306
00307
00308 int replace(int b, int e, const char *text, int ilen=0);
00309
00320 int cut() {return replace(position(), mark(), 0);}
00321
00334 int cut(int n) {return replace(position(), position()+n, 0);}
00335
00347 int cut(int a, int b) {return replace(a, b, 0);}
00348
00360 int insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
00361
00362
00363 int copy(int clipboard);
00364
00365
00366 int undo();
00367
00368
00369 int copy_cuts();
00370
00374 int shortcut() const {return shortcut_;}
00375
00382 void shortcut(int s) {shortcut_ = s;}
00383
00386 Fl_Font textfont() const {return textfont_;}
00387
00391 void textfont(Fl_Font s) {textfont_ = s;}
00392
00395 Fl_Fontsize textsize() const {return textsize_;}
00396
00400 void textsize(Fl_Fontsize s) {textsize_ = s;}
00401
00405 Fl_Color textcolor() const {return textcolor_;}
00406
00411 void textcolor(Fl_Color n) {textcolor_ = n;}
00412
00415 Fl_Color cursor_color() const {return cursor_color_;}
00416
00420 void cursor_color(Fl_Color n) {cursor_color_ = n;}
00421
00424 int input_type() const {return type() & FL_INPUT_TYPE; }
00425
00429 void input_type(int t) { type((uchar)(t | readonly())); }
00430
00433 int readonly() const { return type() & FL_INPUT_READONLY; }
00434
00437 void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY));
00438 else type((uchar)(type() & ~FL_INPUT_READONLY)); }
00439
00444 int wrap() const { return type() & FL_INPUT_WRAP; }
00445
00450 void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
00451 else type((uchar)(type() & ~FL_INPUT_WRAP)); }
00452
00476 void tab_nav(int val) {
00477 tab_nav_ = val;
00478 }
00479
00490 int tab_nav() const {
00491 return tab_nav_;
00492 }
00493 };
00494
00495 #endif
00496
00497
00498
00499