00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef Fl_Input__H
00032 #define Fl_Input__H
00033
00034 #ifndef Fl_Widget_H
00035 #include "Fl_Widget.H"
00036 #endif
00037
00038 #define FL_NORMAL_INPUT 0
00039 #define FL_FLOAT_INPUT 1
00040 #define FL_INT_INPUT 2
00041 #define FL_HIDDEN_INPUT 3
00042 #define FL_MULTILINE_INPUT 4
00043 #define FL_SECRET_INPUT 5
00044 #define FL_INPUT_TYPE 7
00045 #define FL_INPUT_READONLY 8
00046 #define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY)
00047 #define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
00048 #define FL_INPUT_WRAP 16
00049 #define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
00050 #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
00051
00102 class FL_EXPORT Fl_Input_ : public Fl_Widget {
00103
00105 const char* value_;
00106
00108 char* buffer;
00109
00111 int size_;
00112
00114 int bufsize;
00115
00117 int position_;
00118
00121 int mark_;
00122
00126 int tab_nav_;
00127
00129 int xscroll_, yscroll_;
00130
00133 int mu_p;
00134
00136 int maximum_size_;
00137
00139 int shortcut_;
00140
00142 uchar erase_cursor_only;
00143
00145 Fl_Font textfont_;
00146
00148 Fl_Fontsize textsize_;
00149
00151 Fl_Color textcolor_;
00152
00154 Fl_Color cursor_color_;
00155
00157 static double up_down_pos;
00158
00160 static int was_up_down;
00161
00162
00163 const char* expand(const char*, char*) const;
00164
00165
00166 double expandpos(const char*, const char*, const char*, int*) const;
00167
00168
00169 void minimal_update(int, int);
00170
00171
00172 void minimal_update(int p);
00173
00174
00175 void put_in_buffer(int newsize);
00176
00177
00178 void setfont() const;
00179
00180 protected:
00181
00182
00183 int word_start(int i) const;
00184
00185
00186 int word_end(int i) const;
00187
00188
00189 int line_start(int i) const;
00190
00191
00192 int line_end(int i) const;
00193
00194
00195 void drawtext(int, int, int, int);
00196
00197
00198 int up_down_position(int, int keepmark=0);
00199
00200
00201 void handle_mouse(int, int, int, int, int keepmark=0);
00202
00203
00204 int handletext(int e, int, int, int, int);
00205
00206
00207 void maybe_do_callback();
00208
00210 int xscroll() const {return xscroll_;}
00211
00213 int yscroll() const {return yscroll_;}
00214 void yscroll(int y) { yscroll_ = y; damage(FL_DAMAGE_EXPOSE);}
00215
00216
00217 int linesPerPage();
00218
00219 public:
00220
00221
00222 void resize(int, int, int, int);
00223
00224
00225 Fl_Input_(int, int, int, int, const char* = 0);
00226
00227
00228 ~Fl_Input_();
00229
00230
00231 int value(const char*);
00232
00233
00234 int value(const char*, int);
00235
00236
00237 int static_value(const char*);
00238
00239
00240 int static_value(const char*, int);
00241
00252 const char* value() const {return value_;}
00253
00254
00255 Fl_Char index(int i) const;
00256
00265 int size() const {return size_;}
00266
00270 void size(int W, int H) { Fl_Widget::size(W, H); }
00271
00274 int maximum_size() const {return maximum_size_;}
00275
00278 void maximum_size(int m) {maximum_size_ = m;}
00279
00284 int position() const {return position_;}
00285
00288 int mark() const {return mark_;}
00289
00290
00291 int position(int p, int m);
00292
00299 int position(int p) {return position(p, p);}
00300
00306 int mark(int m) {return position(position(), m);}
00307
00308
00309 int replace(int, int, const char*, int=0);
00310
00321 int cut() {return replace(position(), mark(), 0);}
00322
00335 int cut(int n) {return replace(position(), position()+n, 0);}
00336
00348 int cut(int a, int b) {return replace(a, b, 0);}
00349
00361 int insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
00362
00363
00364 int copy(int clipboard);
00365
00366
00367 int undo();
00368
00369
00370 int copy_cuts();
00371
00375 int shortcut() const {return shortcut_;}
00376
00383 void shortcut(int s) {shortcut_ = s;}
00384
00387 Fl_Font textfont() const {return textfont_;}
00388
00392 void textfont(Fl_Font s) {textfont_ = s;}
00393
00396 Fl_Fontsize textsize() const {return textsize_;}
00397
00401 void textsize(Fl_Fontsize s) {textsize_ = s;}
00402
00406 Fl_Color textcolor() const {return textcolor_;}
00407
00412 void textcolor(Fl_Color n) {textcolor_ = n;}
00413
00416 Fl_Color cursor_color() const {return cursor_color_;}
00417
00421 void cursor_color(Fl_Color n) {cursor_color_ = n;}
00422
00425 int input_type() const {return type() & FL_INPUT_TYPE; }
00426
00430 void input_type(int t) { type((uchar)(t | readonly())); }
00431
00434 int readonly() const { return type() & FL_INPUT_READONLY; }
00435
00438 void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY));
00439 else type((uchar)(type() & ~FL_INPUT_READONLY)); }
00440
00445 int wrap() const { return type() & FL_INPUT_WRAP; }
00446
00451 void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
00452 else type((uchar)(type() & ~FL_INPUT_WRAP)); }
00453
00475 void tab_nav(int val) {
00476 tab_nav_ = val;
00477 }
00478
00488 int tab_nav() const {
00489 return tab_nav_;
00490 }
00491 };
00492
00493 #endif
00494
00495
00496
00497