• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2008, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef SELECT_TEXT_H
27 #define SELECT_TEXT_H
28 
29 #include "DrawExtra.h"
30 #include "IntRect.h"
31 #include "PlatformString.h"
32 #include "SkPath.h"
33 
34 class SkPicture;
35 struct SkIRect;
36 class SkRegion;
37 
38 namespace android {
39 
40 class CachedRoot;
41 
42 class SelectText : public DrawExtra {
43 public:
44     SelectText();
45     virtual void draw(SkCanvas* , LayerAndroid* );
46     void extendSelection(const SkPicture* , int x, int y);
47     const String getSelection();
48     bool hitSelection(int x, int y) const;
49     void moveSelection(const SkPicture* , int x, int y);
50     void reset();
51     void selectAll(const SkPicture* );
52     int selectionX() const;
53     int selectionY() const;
setDrawPointer(bool drawPointer)54     void setDrawPointer(bool drawPointer) { m_drawPointer = drawPointer; }
setExtendSelection(bool extend)55     void setExtendSelection(bool extend) { m_extendSelection = extend; }
setVisibleRect(const IntRect & rect)56     void setVisibleRect(const IntRect& rect) { m_visibleRect = rect; }
57     bool startSelection(int x, int y);
58     bool wordSelection(const SkPicture* picture);
59 public:
60     float m_inverseScale; // inverse scale, x, y used for drawing select path
61     int m_selectX;
62     int m_selectY;
63 private:
64     void drawSelectionPointer(SkCanvas* );
65     void drawSelectionRegion(SkCanvas* );
66     static void getSelectionArrow(SkPath* );
67     void getSelectionCaret(SkPath* );
68     bool hitCorner(int cx, int cy, int x, int y) const;
69     void swapAsNeeded();
70     SkIPoint m_original; // computed start of extend selection
71     SkIRect m_selStart;
72     SkIRect m_selEnd;
73     int m_startBase;
74     int m_endBase;
75     SkIRect m_visibleRect; // constrains picture computations to visible area
76     SkRegion m_selRegion; // computed from sel start, end
77     SkPicture m_startControl;
78     SkPicture m_endControl;
79     const SkPicture* m_picture;
80     bool m_drawPointer;
81     bool m_extendSelection; // false when trackball is moving pointer
82     bool m_flipped;
83     bool m_hitTopLeft;
84     bool m_startSelection;
85 };
86 
87 }
88 
89 namespace WebCore {
90 
91 void ReverseBidi(UChar* chars, int len);
92 
93 }
94 
95 #endif
96