ubit
uselection.hpp
1 /* ==================================================== ======== ======= *
2  *
3  * uselection.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uselection_hpp_
18 #define _uselection_hpp_
19 #include <ubit/udefs.hpp>
20 namespace ubit {
21 
22 
25 class USelection {
26 public:
27  USelection(const UColor* color, const UColor* bgcolor, const UFont*);
28  ~USelection();
29 
30  void copyText(UStr&);
31  void cutText(UStr&);
32  void deleteText();
33  void clear();
34 
35  UColor& color() {return *pcolor;}
36  UColor& bgcolor() {return *pbgcolor;}
37  UFont& font() {return *pfont;}
38 
39  const UElem* getObj() {return in_obj;}
40 
41 protected:
42  void setObj(UElem* obj);
43  void start(UMouseEvent&);
44  void extend(UMouseEvent&);
45  bool complete(UMouseEvent&);
46  void keyPress(UKeyEvent&);
47  bool beingSelected() {return being_selected;}
48  void perform(UStr* copy, bool del);
49 
50 private:
51  friend class UEdit;
52  friend class UStr;
53  friend class UEventFlow;
54 
55  bool being_selected;
56  bool rec_sel; //< recursive selection (the default).
57  UElem* in_obj;
58 
59  static const UChildIter null_link;
60  // reordered in the left to right order
61  UChildIter fromLink, toLink, pressLink, endPressLink, oldLink;
62  long fromPos, toPos, pressPos, oldPos;
63  uptr <UColor> pcolor;
64  uptr <UColor> pbgcolor;
65  uptr <UFont> pfont;
66 
67  void update(UDataContext*);
68  void paint(long refreshFromPos, long refreshToPos);
69  void paintImpl(UElem* obj, bool state, long refreshFromPos, long refreshToPos);
70 };
71 }
72 #endif
73 
information on UData objects that are being retrieved by UEvent::getData() or UEvent::getStr().
Definition: uevent.hpp:524
keyboard events
Definition: uevent.hpp:316
text selection.
Definition: uselection.hpp:25
Text editing and caret controller.
Definition: uedit.hpp:30
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
lightweight general purpose container.
Definition: uelem.hpp:44
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
Event Flow.
Definition: ueventflow.hpp:34
Font of a UElem or UBox container.
Definition: ufont.hpp:30
Definition: uhardfont.hpp:31
void perform(UStr *copy, bool del)
Definition: uselection.cpp:234
Ubit String.
Definition: ustr.hpp:72
mouse events
Definition: uevent.hpp:172