source: trunk/Lucide/SOURCE/gui/docViewer.h @ 150

Last change on this file since 150 was 126, checked in by Eugene Romanenko, 15 years ago

Prevent getLinkMapping() call on every redraw if no links on page.

File size: 7.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35#ifndef __DOCVIEWER_H
36#define __DOCVIEWER_H
37
38#include <vector>
39
40#include <ludoc.xh>
41#include "lucide.h"
42
43class ProgressDlg;
44
45struct LuSize  { double x, y; };
46
47struct PageDrawArea
48{
49    long   pagenum;
50    LuSize startpos;
51    RECTL  drawrect;
52};
53
54typedef std::vector<PageDrawArea> DrawAreas;
55
56class DocumentViewer
57{
58    public:
59        DocumentViewer( HWND hWndFrame );
60        virtual ~DocumentViewer();
61
62        void setPageLayout( PgLayout layout );
63        PgLayout getPageLayout() { return ( continuous ? Continuous : SinglePage ); }
64
65        HWND getFrameHWND() { return hWndDocFrame; }
66        HWND getViewHWND() { return hWndDoc; }
67
68        void setDocument( LuDocument *_doc );
69        void close();
70        void goToPage( long page );
71        long getCurrentPage() { return currentpage; }  // Zero based
72        void setZoom( double _zoom );
73        double getZoom() { return zoom; }
74        double getRealZoom() { return realzoom; }
75        void setZoomMode( bool _zoomMode ) { zoomMode = _zoomMode; }
76        bool isZoomMode() { return zoomMode; }
77        void setRotation( long _rotation );
78        long getRotation() { return rotation; }
79        void selectAll();
80        void copyToClipbrd();
81        void searchDocument( const char *_searchString, bool _caseSensitive,
82                             bool _continueSearch );
83        void setFullscreen( bool _fullscreen );
84
85        static void registerClass();
86
87        // Internal stuffs
88    private:
89
90        void drawPage();
91        void adjustSize();
92                void countPagesizes();
93
94        MRESULT vertScroll( HWND hwnd, MPARAM mp2, HRGN hrgn );
95        MRESULT horizScroll( HWND hwnd, MPARAM mp2, HRGN hrgn );
96        MRESULT wmDragOver( PDRAGINFO dragInfo );
97                void wmDrop( PDRAGINFO dragInfo );
98                void wmSize( HWND hwnd, MPARAM mp2 );
99        void wmPaint( HWND hwnd );
100        void wmPaintCont( HWND hwnd );
101        void wmPaintAsynch( HWND hwnd );
102        void wmPaintContAsynch( HWND hwnd );
103        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
104        void wmButton1Up();
105        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
106        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
107        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
108        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
109        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
110        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
111        void rotateRectangle( long pagenum, LuRectangle *r );
112        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
113        void drawSelection( long pagenum, HPS hps, PRECTL r );
114        void scrollToPos( HWND hwnd, HRGN hrgn, LONG xpos, LONG ypos, bool withSelection );
115        void freeRects( LuDocument_LuRectSequence **rects );
116        void freeLinks();
117        void drawFound( long pagenum, HPS hps, PRECTL r );
118        DrawAreas *findDrawAreas( PRECTL r );
119        void determineCurrentPage();
120        long posToPagenum( LONG yPosWin, double *pageRest );
121        double pagenumToPos( long pagenum );
122        bool isRotated() { return ( (rotation==90) || (rotation==270) ); }
123
124        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
125        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
126        static void searchthread( void *p );
127        static void searchabort( void *p );
128        static void drawthread( void *p );
129        static long _System asynchCallbackFnDraw( void *data );
130        static long _System asynchCallbackFnAbort( void *data );
131
132        LuDocument *doc;
133        HWND hMainFrame;
134        HWND hWndDocFrame;
135        HWND hWndDoc;
136        PFNWP oldFrameProc;
137        HWND hWndHscroll;
138        HWND hWndVscroll;
139        SHORT sHscrollMax;
140        SHORT sVscrollMax;
141        SHORT sHscrollPos;
142        SHORT sVscrollPos;
143        LONG  sVscrollInc;
144        LONG  sHscrollInc;
145        ULONG realVscrollMax;
146        LONG  cxClient;
147        LONG  cyClient;
148        LONG  spos_x;
149        LONG  spos_y;
150        HPS hpsBuffer;
151        HDC hdcBuffer;
152        LuPixbuf *pixbuf;
153        short bpp;
154        double width, height, zoom, realzoom, fullwidth, fullheight;
155        boolean zoomMode;
156        long rotation;
157        long totalpages, currentpage;
158        ProgressDlg *progressDlg;
159        DrawAreas *drawareas;
160        int drawareaIndex;
161        bool closed;
162        bool drawPS;
163       
164        // fullscreen
165        bool fullscreen;
166        PgLayout pglSave;
167        double zoomSave;
168
169        // continuous view
170        bool continuous;
171        LuSize *pagesizes;
172        SHORT VScrollStep;
173        RECTL savedRcl;
174
175        // asynch draw
176        bool enableAsynchDraw;
177        HMTX todrawAccess;
178        HEV  haveDraw;
179        bool abortAsynch;
180        bool termdraw;
181        TID  drawThreadId;
182
183        // selection
184        bool mousePressed;
185        POINTL selectionStart;
186        POINTL selectionEnd;
187        LuRectangle *selection;
188        LuDocument_LuRectSequence **selrects;
189
190        // links
191        bool haveLinks;
192        LuDocument_LuLinkMapSequence **links;
193
194        // search
195        LuDocument_LuRectSequence **foundrects;
196        char *searchString;
197        bool caseSensitive;
198        bool continueSearch;
199        bool abortSearch;
200       
201        // pointers
202        HPOINTER handPtr;
203        HPOINTER zoomInPtr;
204        HPOINTER zoomOutPtr;
205};
206
207#endif // __DOCVIEWER_H
208
Note: See TracBrowser for help on using the repository browser.