uedit.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uedit.hpp
00004 *  Ubit Project
00005 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006 *  (C) 1999-2006 Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007 *
00008 * ***********************************************************************
00009 * COPYRIGHT NOTICE :
00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016 * ***********************************************************************
00017 * ==================================================== [(c)Elc] ======= *
00018 * ==================================================== ======== ======= */
00019 
00020 #ifndef _uedit_hpp_
00021 #define _uedit_hpp_
00022 //pragma ident  "@(#)uedit.hpp  ubit:05.05.00"
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(); // NOTE: removingFrom() requires a destructor.
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   // - - - impl - - - - -- - - - - - - - - - - - - - - - - - - - - - - -
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   // NOTE: removingFrom() requires a destructor.
00139   
00140   void setCaretStr(UStr*, int pos_in_str, bool update, UView* view);
00141 
00142   // prototypes for non-warped text (UView)
00143   virtual int getXpos(UContext&, const URegion& r) const;
00144   virtual void paint(UGraph&, UContext&, const URegion &r) const;
00145 
00146   // prototypes for warped text (UFlowview)
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;        // callback object
00153   uptr<UCall>  calls2;        // callback object
00154   uptr<UColor> caret_color;  // specific color for displaying the caret (if any)
00155   uptr<UStr>   caret_str;    // the string that contains the caret (if any)
00156   long caret_pos;             // the position of the caret in 'caret_str'
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 /* ==================================================== [TheEnd] ======= */

Generated on Mon Jan 29 00:20:38 2007 for Ubit by  doxygen 1.4.7