Changeset View
Changeset View
Standalone View
Standalone View
ui/pageviewutils.h
Show All 27 Lines | |||||
28 | class VideoWidget; | 28 | class VideoWidget; | ||
29 | 29 | | |||
30 | namespace Okular { | 30 | namespace Okular { | ||
31 | class Movie; | 31 | class Movie; | ||
32 | class Page; | 32 | class Page; | ||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | /** | 35 | /** | ||
36 | * @short PageViewItem represents graphically a page into the PageView. | 36 | * @short PageViewItem represents a Page, to be used in a PageView. | ||
37 | * | 37 | * | ||
38 | * It has methods for settings Item's geometry and other visual properties such | 38 | * @par Geometry | ||
39 | * as the individual zoom factor. | 39 | * @parblock | ||
40 | * PageViewItem stores geometry information to position the page in | ||||
41 | * the content area of the PageView. | ||||
42 | * * The uncropped geometry describing the whole page, | ||||
43 | * * The cropped geometry describing the visible part of the page after e. g. Trim Margins, | ||||
44 | * * The used zoom factor, | ||||
45 | * * The used crop rectangle. | ||||
46 | * | ||||
47 | * The cropped geometry describes the part of the page, | ||||
48 | * which is be used for the layout of the PageView. | ||||
49 | * If Trim Margins or Trim to Selection is used, | ||||
50 | * the cropped geometry does not contain the trimmed-away margins. | ||||
51 | * | ||||
52 | * The uncropped geometry describes the whole page. | ||||
53 | * Various objects on the page (e. g. TextEntity) are positioned in normalized coordinates. | ||||
54 | * To convert normalized coordinates to content area coordinates for PageView, | ||||
55 | * the uncropped geometry is needed as reference area. | ||||
56 | * | ||||
57 | * @note | ||||
58 | * For the conversion from normalized coordinates to content area coordinates, | ||||
59 | * the rotation of the page is needed, but rotation is not covered by this class. | ||||
60 | * (Uncropped geometry, cropped geometry, and the crop rectange are only valid | ||||
61 | * for the current rotation of the page, which is sufficient for layouting.) | ||||
62 | * @endparblock | ||||
63 | * | ||||
64 | * @par Other Properties | ||||
65 | * * The visibility of the page, | ||||
66 | * * Lists of interactive widgets on the page, | ||||
67 | * * Which types of widgets are visible, | ||||
68 | * * A pointer to the Page itself. | ||||
40 | */ | 69 | */ | ||
41 | class PageViewItem | 70 | class PageViewItem | ||
42 | { | 71 | { | ||
43 | public: | 72 | public: | ||
44 | PageViewItem( const Okular::Page * page ); | 73 | PageViewItem( const Okular::Page * page ); | ||
45 | ~PageViewItem(); | 74 | ~PageViewItem(); | ||
46 | 75 | | |||
47 | PageViewItem(const PageViewItem &) = delete; | 76 | PageViewItem(const PageViewItem &) = delete; | ||
48 | PageViewItem &operator=(const PageViewItem &) = delete; | 77 | PageViewItem &operator=(const PageViewItem &) = delete; | ||
49 | 78 | | |||
79 | /** | ||||
80 | * Returns the represented Page. | ||||
81 | */ | ||||
50 | const Okular::Page * page() const; | 82 | const Okular::Page * page() const; | ||
83 | | ||||
84 | /** | ||||
85 | * Returns the number of the represented Page. | ||||
86 | * First page has number 0. | ||||
87 | * Provided for convenience. | ||||
88 | */ | ||||
51 | int pageNumber() const; | 89 | int pageNumber() const; | ||
90 | | ||||
52 | double zoomFactor() const; | 91 | double zoomFactor() const; | ||
53 | bool isVisible() const; | 92 | bool isVisible() const; | ||
54 | QSet<FormWidgetIface*>& formWidgets(); | 93 | QSet<FormWidgetIface*>& formWidgets(); | ||
55 | QHash< Okular::Movie *, VideoWidget * >& videoWidgets(); | 94 | QHash< Okular::Movie *, VideoWidget * >& videoWidgets(); | ||
56 | 95 | | |||
57 | /* The page is cropped as follows: */ | 96 | /** | ||
97 | * Describes the cropped geometry relative to the uncropped geometry. | ||||
98 | */ | ||||
58 | const Okular::NormalizedRect & crop() const; | 99 | const Okular::NormalizedRect & crop() const; | ||
59 | 100 | | |||
60 | /* Real geometry into which the cropped page is rendered: */ | | |||
61 | const QRect& croppedGeometry() const; | 101 | const QRect& croppedGeometry() const; | ||
62 | int croppedWidth() const; | 102 | int croppedWidth() const; | ||
63 | int croppedHeight() const; | 103 | int croppedHeight() const; | ||
64 | 104 | | |||
65 | /* "Uncropped" geometry: | | |||
66 | * If the whole page was rendered into the uncropped geometry then the | | |||
67 | * cropped page would be rendered into the real geometry. | | |||
68 | * (Hence, uncropped always contains cropped, and they are equal only if | | |||
69 | * the page is uncropped.) This is just for convenience in calculations. | | |||
70 | */ | | |||
71 | const QRect& uncroppedGeometry() const; | 105 | const QRect& uncroppedGeometry() const; | ||
72 | int uncroppedWidth() const; | 106 | int uncroppedWidth() const; | ||
73 | int uncroppedHeight() const; | 107 | int uncroppedHeight() const; | ||
74 | 108 | | |||
75 | /* Convert absolute geometry coordinates to normalized [0,1] page coordinates: */ | 109 | /** | ||
110 | * Converts x coordinate from PageView content area coordinates to | ||||
111 | * the normalized coordinate system of the page, not covering page rotation. | ||||
112 | */ | ||||
76 | double absToPageX(double absX) const; | 113 | double absToPageX(double absX) const; | ||
114 | | ||||
115 | /** | ||||
116 | * Converts y coordinate from PageView content area coordinates to | ||||
117 | * the normalized coordinate system of the page, not covering page rotation. | ||||
118 | */ | ||||
77 | double absToPageY(double absY) const; | 119 | double absToPageY(double absY) const; | ||
78 | 120 | | |||
121 | /** | ||||
122 | * Sets the size of the page. | ||||
123 | * | ||||
124 | * (Uncropped geometry will be calculated from @p width, @p height, and @p crop.) | ||||
125 | * | ||||
126 | * @param width Cropped width. | ||||
127 | * @param height Cropped height. | ||||
128 | * @param zoom The zoom factor which yields these dimensions. | ||||
129 | * @param crop Describes the cropped geometry relative to the uncropped geometry. | ||||
130 | */ | ||||
79 | void setWHZC( int w, int h, double zoom, const Okular::NormalizedRect & c ); | 131 | void setWHZC( int w, int h, double zoom, const Okular::NormalizedRect & c ); | ||
132 | | ||||
133 | /** | ||||
134 | * Sets the position of the page in the PageView layout. | ||||
135 | * | ||||
136 | * @p x and @p y describe the top left corner of the cropped geometry, | ||||
137 | * in the PageView coordinate system. | ||||
138 | * Uncropped geometry is updated automatically. | ||||
139 | */ | ||||
80 | void moveTo( int x, int y ); | 140 | void moveTo( int x, int y ); | ||
81 | void setVisible( bool visible ); | 141 | void setVisible( bool visible ); | ||
82 | void invalidate(); | 142 | void invalidate(); | ||
143 | | ||||
144 | /** | ||||
145 | * Sets all form widgets on this PageViewItem visible or invisible, | ||||
146 | * provided this PageViewItem is visible. | ||||
147 | * | ||||
148 | * @return True, if some form widgets had focus. | ||||
149 | */ | ||||
83 | bool setFormWidgetsVisible( bool visible ); | 150 | bool setFormWidgetsVisible( bool visible ); | ||
151 | | ||||
152 | /** | ||||
153 | * Updates the visibility state of all form widgets of this PageViewItem. | ||||
154 | */ | ||||
84 | void reloadFormWidgetsState(); | 155 | void reloadFormWidgetsState(); | ||
85 | 156 | | |||
86 | private: | 157 | private: | ||
87 | const Okular::Page * m_page; | 158 | const Okular::Page * m_page; | ||
88 | double m_zoomFactor; | 159 | double m_zoomFactor; | ||
89 | bool m_visible; | 160 | bool m_visible; | ||
90 | bool m_formsVisible; | 161 | bool m_formsVisible; | ||
91 | QRect m_croppedGeometry; | 162 | QRect m_croppedGeometry; | ||
92 | QRect m_uncroppedGeometry; | 163 | QRect m_uncroppedGeometry; | ||
93 | Okular::NormalizedRect m_crop; | 164 | Okular::NormalizedRect m_crop; | ||
94 | QSet<FormWidgetIface*> m_formWidgets; | 165 | QSet<FormWidgetIface*> m_formWidgets; | ||
95 | QHash< Okular::Movie *, VideoWidget * > m_videoWidgets; | 166 | QHash< Okular::Movie *, VideoWidget * > m_videoWidgets; | ||
96 | }; | 167 | }; | ||
97 | 168 | | |||
98 | 169 | | |||
99 | /** | 170 | /** | ||
100 | * @short A widget that displays messages in the top-left corner. | 171 | * @short A widget that displays messages in the top-left corner. | ||
101 | * | 172 | * | ||
102 | * This is a widget with thin border and rounded corners that displays a given | 173 | * This is a widget with thin border and rounded corners that displays a given | ||
103 | * text along as an icon. It's meant to be used for displaying messages to the | 174 | * text and icon. It's meant to be used for displaying messages to the | ||
104 | * user by placing this above other widgets. | 175 | * user by placing this above other widgets. | ||
105 | */ | 176 | */ | ||
106 | class PageViewMessage : public QWidget | 177 | class PageViewMessage : public QWidget | ||
107 | { | 178 | { | ||
108 | Q_OBJECT | 179 | Q_OBJECT | ||
109 | 180 | | |||
110 | public: | 181 | public: | ||
111 | explicit PageViewMessage( QWidget * parent ); | 182 | explicit PageViewMessage( QWidget * parent ); | ||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |