00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _uedit_hpp_
00021 #define _uedit_hpp_
00022
00023 #include <ubit/uprop.hpp>
00024 namespace ubit {
00025
00026
00035 class UEdit : public UProp {
00036 public:
00037 UBIT_ATTR_CLASS(UEdit, UProp)
00038
00039 UEdit();
00041
00042 friend UEdit& uedit() {return *new UEdit();}
00044
00045 virtual ~UEdit();
00046
00047
00048
00049 bool isEditable() const;
00050 UEdit& setEditable(bool = true);
00052
00053 bool isCaretVisible() const;
00054 UEdit& setCaretVisible(bool = true);
00056
00057 UColor* getCaretColor() const;
00058 UEdit& setCaretColor(UColor*);
00063 long getCaretPos() const;
00064 UEdit& setCaretPos(long pos);
00069 long getCaretPos(UGroup* container) const;
00070 UEdit& setCaretPos(long pos, UGroup* container);
00077
00078
00079 UStr* getCaretStr() const;
00080 UStr* getCaretStr(int& pos_in_str) const;
00089 UEdit& setCaretStr(UStr* str);
00090 UEdit& setCaretStr(UStr* str, int pos_in_str);
00101 static UStr* getPreviousStr(UStr* from, UGroup* container);
00102 static UStr* getNextStr(UStr* from, UGroup* container);
00108 static UStr* getParagraphFirstStr(UStr* from, int& pos, UGroup* container);
00109 static UStr* getParagraphLastStr(UStr* from, int& pos, UGroup* container);
00117
00118
00119 USelection* getSelection(UEvent& e, UStr& sel_text);
00120 void deleteSelection(USelection* sel, UStr& sel_text, UGroup* container);
00121 void deletePreviousChar(UGroup* container, UView* view);
00122 void deleteChar(UGroup* container, UView* view);
00123 bool nextChar(UGroup* container, UView* view);
00124 bool previousChar(UGroup* container, UView* view);
00125
00126 void beginningOfLine(UGroup* container, UView* view);
00127 void endOfLine(UGroup* container, UView* view);
00128 void previousLine(UGroup* container, UView* view);
00129 void nextLine(UGroup* container, UView* view);
00131
00132 virtual void update();
00133
00134 #ifndef NO_DOC
00135 virtual void putProp(UContext*, UControl*);
00136 virtual void addingTo(UChild*, UGroup* parent);
00137 virtual void removingFrom(UChild*, UGroup* parent);
00138
00139
00140 void setCaretStr(UStr*, int pos_in_str, bool update, UView* view);
00141
00142
00143 virtual int getXpos(UContext&, const URegion& r) const;
00144 virtual void paint(UGraph&, UContext&, const URegion &r) const;
00145
00146
00147 virtual int getXpos(UContext&, const URegion&, int offset, int cellen) const;
00148 virtual void paint(UGraph&, UContext&, const URegion&,
00149 int offset, int cellen) const;
00150
00151 private:
00152 uptr<UCall> calls;
00153 uptr<UCall> calls2;
00154 uptr<UColor> caret_color;
00155 uptr<UStr> caret_str;
00156 long caret_pos;
00157 bool is_editable, is_visible;
00158 mutable bool repainted;
00159 virtual void callbacks(UEvent&);
00160 virtual void kpressed(UKeyEvent&);
00161 virtual void mpressed(UMouseEvent&);
00162 virtual void mreleased(UMouseEvent&);
00163 virtual void callbacks2(UMouseEvent&);
00164 #endif
00165 };
00166
00167 }
00168 #endif
00169