00001 #ifndef __DW_SELECTION_H__
00002 #define __DW_SELECTION_H__
00003
00004 #ifndef __INCLUDED_FROM_DW_CORE_HH__
00005 # error Do not include this file directly, use "core.hh" instead.
00006 #endif
00007
00008 namespace dw {
00009 namespace core {
00010
00178 class SelectionState
00179 {
00180 public:
00181 enum { END_OF_WORD = 1 << 30 };
00182
00183 private:
00184 Layout *layout;
00185
00186
00187 enum {
00188 NONE,
00189 SELECTING,
00190 SELECTED
00191 } selectionState;
00192
00193 DeepIterator *from, *to;
00194 int fromChar, toChar;
00195
00196
00197 enum {
00198 LINK_NONE,
00199 LINK_PRESSED
00200 } linkState;
00201
00202 int linkButton;
00203 DeepIterator *link;
00204 int linkChar, linkNumber;
00205
00206 void resetSelection ();
00207 void resetLink ();
00208 void switchLinkToSelection (Iterator *it, int charPos);
00209 void adjustSelection (Iterator *it, int charPos);
00210 static int correctCharPos (DeepIterator *it, int charPos);
00211
00212 void highlight (bool fl, int dir)
00213 { highlight0 (fl, from, fromChar, to, toChar, dir); }
00214
00215 void highlight0 (bool fl, DeepIterator *from, int fromChar,
00216 DeepIterator *to, int toChar, int dir);
00217 void copy ();
00218
00219 public:
00220 enum EventType { BUTTON_PRESS, BUTTON_RELEASE, BUTTON_MOTION };
00221
00222 SelectionState ();
00223 ~SelectionState ();
00224
00225 inline void setLayout (Layout *layout) { this->layout = layout; }
00226 void reset ();
00227 bool buttonPress (Iterator *it, int charPos, int linkNo,
00228 EventButton *event);
00229 bool buttonRelease (Iterator *it, int charPos, int linkNo,
00230 EventButton *event);
00231 bool buttonMotion (Iterator *it, int charPos, int linkNo,
00232 EventMotion *event);
00233
00234 bool handleEvent (EventType eventType, Iterator *it, int charPos,
00235 int linkNo, MousePositionEvent *event);
00236 };
00237
00238 }
00239 }
00240
00241 #endif // __DW_SELECTION_H__