uselection.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uselection.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
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 _uselection_hpp_
00021 #define _uselection_hpp_
00022 //pragma ident  "@(#)uselection.hpp     ubit:05.05.00"
00023 namespace ubit {
00024 
00025 /* ==================================================== ====== ======= */
00028 class USelection {
00029 public:
00030   USelection(const UColor* color, const UColor* bgcolor, const UFont*);
00031   ~USelection();
00032   
00033   void copyText(UStr&);
00034   void cutText(UStr&);
00035   void deleteText();
00036   void clear();
00037 
00038   UColor& color()   {return *pcolor;}
00039   UColor& bgcolor() {return *pbgcolor;}
00040   UFont&  font()    {return *pfont;}
00041 
00042   const UGroup* getObj() {return in_obj;}
00043 
00044 protected:
00045   void setObj(UGroup* obj);
00046   void start(UMouseEvent&);
00047   void extend(UMouseEvent&);
00048   bool complete(UMouseEvent&);
00049   void keyPress(UKeyEvent&);
00050   bool beingSelected() {return being_selected;}
00051   void perform(UStr* copy, bool del);
00052 
00053 private:
00054   friend class UEdit;
00055   friend class UStr;
00056   friend class UEventFlow;
00057   
00058   bool being_selected;  
00059   bool rec_sel;  //< recursive selection (the default).
00060   UGroup* in_obj;
00061   
00062   static const UChildIter null_link;
00063   // reordered in the left to right order
00064   UChildIter fromLink, toLink, pressLink, endPressLink, oldLink;
00065   long  fromPos, toPos, pressPos, oldPos;
00066   uptr <UColor> pcolor;
00067   uptr <UColor> pbgcolor;
00068   uptr <UFont>  pfont;
00069 
00070   void update(UDataProps*);
00071   void paint(long refreshFromPos, long refreshToPos);
00072   void paintImpl(UGroup* obj, bool state, long refreshFromPos, long refreshToPos);
00073 };
00074 }
00075 #endif
00076 /* ==================================================== [TheEnd] ======= */
00077 /* ==================================================== [(c)Elc] ======= */

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