Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Input.h

00001 /*
00002  * $Id: Fl_Input.h,v 1.18 2003/06/23 11:35:29 space2 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 #ifndef _FL_INPUT_H_
00023 #define _FL_INPUT_H_
00024 
00025 #include "Fl_Widget.h"
00026 #include "Enumerations.h"
00027 
00029 class FL_API Fl_Input : public Fl_Widget {
00030 public:
00031     enum { // values for type()
00032         NORMAL = 0,
00033     // this hole was used by float & int types
00034         SECRET = 3,
00035         MULTILINE = 4,
00036     // 5 and 6 not used now...
00037         INPUT_TYPE = 7,
00038         READ_ONLY = 8,
00039         WORDWRAP = 16,
00040     };
00041 
00043     Fl_Input(int, int, int, int, const char* = 0);
00044 
00046     Fl_Input(const char* l = 0,int layout_size=30,Fl_Align layout_al=FL_ALIGN_TOP,int label_w=100);
00047 
00049     virtual ~Fl_Input();
00050 
00051     static Fl_Named_Style* default_style;
00052 
00053     int input_type() const {return type() & INPUT_TYPE; }
00054     void input_type(int t) { type(t | readonly()); }
00055 
00056     int text_align() const {return text_align_; }
00057     void text_align(int v){ text_align_ = v; }
00058 
00059     int readonly() const { return (type() & READ_ONLY); }
00060     void readonly(int b) { if (b) type(type() | READ_ONLY); else type(type() & ~READ_ONLY); }
00061 
00062     int wordwrap() const { return (type() & WORDWRAP); }
00063     void wordwrap(int b) { if (b) type(type() | WORDWRAP); else type(type() & ~WORDWRAP); }
00064 
00065     virtual void preferred_size(int& w, int& h) const;
00066 
00067     virtual void reset() { value(""); }
00068 
00069     virtual void draw();
00070     virtual void draw(int x, int y, int w, int h);
00071     virtual int handle(int);
00072     virtual int handle(int event, int x, int y, int w, int h);
00073 
00074     bool value(const char*);
00075     bool value(const char*, int);
00076 
00077     bool static_value(const char*);
00078     bool static_value(const char*, int);
00079 
00080     const char* value() const {return value_;}
00081 
00082     char index(int i) const {return value_[i];}
00083     int size() const {return size_;}
00084     int maximum_size() const { return maximum_size_; }
00085     void maximum_size(int m) { maximum_size_ = m; }
00086 
00087     // Data source support
00088     virtual bool load_data(Fl_Data_Source *ds);
00089     virtual bool save_data(Fl_Data_Source *ds);
00090 
00091     int position() const {return position_;}
00092     int mark() const {return mark_;}
00093     void position(int p, int m);
00094     void position(int p) {position(p, p);}
00095     void up_down_position(int position, bool extend);
00096     void mark(int m) { position(position(), m);}
00097 
00098     virtual bool replace(int, int, const char*, int);
00099     bool cut() {return replace(position(), mark(), 0, 0);}
00100     bool cut(int n) {return replace(position(), position()+n, 0, 0);}
00101     bool cut(int a, int b) {return replace(a, b, 0, 0);}
00102     bool insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
00103     bool replace(int a, int b, char c) {return replace(a,b,&c,1);}
00104     bool copy(bool clipboard = true);
00105     bool undo();
00106     void maybe_do_callback();
00107 
00108     int word_start(int i) const;
00109     int word_end(int i) const;
00110     int line_start(int i) const;
00111     int line_end(int i) const;
00112     int mouse_position(int, int, int, int) const;
00113     int xscroll() const {return xscroll_;}
00114     int yscroll() const {return yscroll_;}
00115 
00116 private:
00117 
00118     const char* value_;
00119     char* buffer;
00120 
00121     int size_;
00122     int maximum_size_;
00123     int bufsize;
00124     int position_;
00125     int mark_;
00126     int xscroll_, yscroll_;
00127     int mu_p;
00128     int inside_label_width;
00129     uchar text_align_;
00130 
00132     void ctor_init();
00133 
00134     const char* expand(const char*, char*, int) const;
00135     float expandpos(const char*, const char*, const char*, int*) const;
00136     void minimal_update(int, int);
00137     void minimal_update(int p);
00138     void erase_cursor_at(int p);
00139     void put_in_buffer(int newsize);
00140 
00141     void setfont() const;
00142 
00143     bool handle_key();
00144     bool key_is_shortcut();
00145     void shift_position(int p);
00146     void shift_up_down_position(int p);
00147 
00148 public:
00149     // default slots
00150     DEFSLOT_O(Fl_Widget, Fl_Input, slot_value, char *);
00151     
00152     void slot_value(char * s) { value(s); }
00153 };
00154 
00155 #endif

Generated on Thu Jul 31 15:33:44 2003 for eFLTK by doxygen1.2.15