root/trunk/src/IPageView.h

Revision 277, 7.9 kB (checked in by jordi, 16 months ago)

Added a patch by Igor Vagulin which adds text selection and copy to clipboard features. This fixes bug #14.

Line 
1// ePDFView - A lightweight PDF Viewer.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#if !defined (__IPAGE_VIEW_H__)
19#define __IPAGE_VIEW_H__
20
21namespace ePDFView
22{
23    // Forward declarations.
24    class PagePter;
25
26    ///
27    /// @brief The possible cursor for the page view.
28    ///
29    enum PageCursor
30    {
31        /// Normal cursor.
32        PAGE_VIEW_CURSOR_NORMAL,
33        /// Drag cursor.
34        PAGE_VIEW_CURSOR_DRAG,
35        /// Text selection cursor.
36        PAGE_VIEW_CURSOR_SELECT_TEXT,
37        /// Link cursor.
38        PAGE_VIEW_CURSOR_LINK
39    };
40   
41    ///
42    /// @brief How to show the new page.
43    ///
44    enum PageScroll
45    {
46        /// No scroll.
47        PAGE_SCROLL_NONE,
48        /// Scroll to the beginning of the page.
49        PAGE_SCROLL_START,
50        /// Scroll to the bottom of the page.
51        PAGE_SCROLL_END
52    };
53 
54    ///
55    /// @class IPageView.
56    /// @brief Interface for the page view.
57    ///
58    /// The page view is the responsible to show the page's image,
59    /// handle the scroll of it and the links. It will also tell
60    /// the available width and height space when doing a zoom to fit or
61    /// zoom to width.
62    ///
63    class IPageView
64    {
65        public:
66            ///
67            /// @brief Destroys all dynamically allocated memory.
68            ///
69            virtual ~IPageView (void) { }
70
71            ///
72            /// @brief Sets the view's presenter.
73            ///
74            /// @param pter The presenter that controls the view and the
75            ///             view sends notices to.
76            ///
77            virtual void setPresenter (PagePter *pter) { m_Pter = pter; }
78
79            ///
80            /// @brief Gets the view's presenter.
81            ///
82            /// @return The presenter that controls the view or NULL if
83            ///         it was not set.
84            ///
85            PagePter *getPresenter (void) { return m_Pter; }
86
87            /// @brief Gets the horizontal scroll position.
88            ///
89            /// @return The position of the horizontal scroll bar.
90            virtual gdouble getHorizontalScroll (void) = 0;
91
92            ///
93            /// @brief Gets the size of the document's view.
94            ///
95            /// The view must provide to the presenter the current size
96            /// the part destined to show the page has.
97            ///
98            /// This is used when the user requests "Zoom to Fit" or
99            /// "Zoom to Width", so don't user the current's page size. Give
100            /// the allocated space for viewing the page (for example the
101            /// Scrolled Window's size in a GTK application).
102            ///
103            /// @param width The location to save the page view's width.
104            /// @param height The location to save the page view's height.
105            virtual void getSize (gint *width, gint *height) = 0;
106
107            /// @brief Gets the vertical scroll position.
108            ///
109            /// @return The position of the vertical scroll bar.
110            virtual gdouble getVerticalScroll (void) = 0;
111
112            ///
113            /// @brief Makes a document rectangle visible.
114            ///
115            /// When the presenter calls this function, the view must make
116            /// sure that the rectangle is visible. If the rectangle is
117            /// already visible, then do nothing. Otherwise, scroll the
118            /// page to be able to view the rectangle.
119            ///
120            /// @param rect The rectangle to make visible to the user.
121            /// @param scale The scale that the page is currently shown,
122            ///              since the rectangle's coordinates are unscaled.
123            ///
124            virtual void makeRectangleVisible (DocumentRectangle &rect,
125                                               gdouble scale) = 0;
126
127            ///
128            /// @brief Resize the current page.
129            ///
130            /// When the document's scale is changed the view is instructed
131            /// to resize the current page when the cached page image is
132            /// not ready yet. The view should resize the current image using
133            /// a fast algorithm, without caring too much about the final
134            /// result.
135            ///
136            /// @param width The new width of the page.
137            /// @param height The new height of the page.
138            ///
139            virtual void resizePage (gint width, gint height) = 0;
140           
141            ///
142            /// @brief Sets the page scroll.
143            ///
144            /// The view should scroll the page when the presenter calls
145            /// this, because it's dragging the page with the mouse.
146            ///
147            /// @param scrollX The drag X start position of the scroll bar.
148            /// @param scrollY The drag Y start position of the scroll bar.
149            /// @param dx The difference in the x-axis between the drag
150            ///           start position and the current mouse position.
151            /// @param dy The difference in the y-axis between the drag
152            ///           start position and the current mouse position.
153            ///
154            virtual void scrollPage (gdouble scrollX, gdouble scrollY,
155                                     gint dx, gint dy) = 0;
156           
157            ///
158            /// @brief Sets the cursor for the page view.
159            ///
160            /// The view must change the cursor for the page image.
161            /// If the cursor to be set is the same as the current cursor,
162            /// the view can ignore the petition.
163            ///
164            /// @param cursorType The cursor to set.
165            ///
166            virtual void setCursor (PageCursor cursorType) = 0;
167           
168            ///
169            /// @brief Shows a document's page.
170            ///
171            /// The view must show the @a page the the presenter gives to it.
172            /// Of course the view can use scroll bars if the page doesn't fit
173            /// the current view's size, but MUST NOT change the page's size.
174            ///
175            /// The view must make a copy of the image, because the page
176            /// can be deleted after this call.
177            ///
178            /// @param page The document's page to show.
179            /// @param scroll Tells the main view how to scroll the
180            ///               new page.
181            ///
182            virtual void showPage (DocumentPage *page, PageScroll scroll) = 0;
183
184            ///
185            /// @brief Shows text on the page.
186            ///
187            /// This is only used when the page is still loading but the
188            /// presenter wants to show something on the user. The presenter
189            /// passes a text string to show during the rendering of the
190            /// current page. The view should put this string at the middle
191            /// of the currently shown page.
192            ///
193            /// @param text The text to show on the middle of the page.
194            ///
195            virtual void showText (const gchar *text) = 0;
196           
197           
198        protected:
199            ///
200            /// @brief Creates a new IPageView object.
201            ///
202            IPageView (void) { m_Pter = NULL; }
203           
204            /// @brief The view's presenter.
205            PagePter *m_Pter;
206    };
207}
208
209#endif // !__IPAGE_VIEW_H__
Note: See TracBrowser for help on using the browser.