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

Last change on this file since 268 was 268, checked in by Eugene Romanenko, 12 years ago

RMB vertical drag, intermediate commit, works incorrectly on some files

File size: 7.5 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 layout; }
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        void zoomInOut( bool zoomIn );
85
86        static void registerClass();
87
88        // Internal stuffs
89    private:
90
91        void drawPage();
92        void adjustSize();
93                void countPagesizes();
94
95        MRESULT vertScroll( HWND hwnd, MPARAM mp2 );
96        MRESULT horizScroll( HWND hwnd, MPARAM mp2 );
97        MRESULT wmDragOver( PDRAGINFO dragInfo );
98                void wmDrop( PDRAGINFO dragInfo );
99                void wmSize( HWND hwnd, MPARAM mp2 );
100        void wmPaint( HWND hwnd );
101        void wmPaintCont( HWND hwnd );
102        void wmPaintAsynch( HWND hwnd );
103        void wmPaintContAsynch( HWND hwnd );
104        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
105        void wmButton1Up();
106        void wmButton2Down( HWND hwnd, SHORT xpos, SHORT ypos );
107        void wmButton2Up();
108        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
109        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
110        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
111                void wmTimer( USHORT idTimer );
112        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
113        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
114        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
115        void rotateRectangle( long pagenum, LuRectangle *r );
116        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
117        void drawSelection( long pagenum, HPS hps, PRECTL r );
118        void scrollToPos( HWND hwnd, LONG xpos, LONG ypos, bool withSelection );
119        void freeRects( LuDocument_LuRectSequence **rects );
120        void freeLinks();
121        void drawFound( long pagenum, HPS hps, PRECTL r );
122        DrawAreas *findDrawAreas( PRECTL r );
123        void determineCurrentPage();
124        long posToPagenum( LONG yPosWin, double *pageRest );
125        double pagenumToPos( long pagenum );
126        bool isRotated() { return ( (rotation==90) || (rotation==270) ); }
127        bool isContinuous() { return ( layout == Continuous ); };
128
129        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
130        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
131        static void searchthread( void *p );
132        static void searchabort( void *p );
133        static void drawthread( void *p );
134        static long _System asynchCallbackFnDraw( void *data );
135        static long _System asynchCallbackFnAbort( void *data );
136
137        LuDocument *doc;
138        HWND hMainFrame;
139        HWND hWndDocFrame;
140        HWND hWndDoc;
141        PFNWP oldFrameProc;
142        HWND hWndHscroll;
143        HWND hWndVscroll;
144        SHORT sHscrollMax;
145        SHORT sVscrollMax;
146        SHORT sHscrollPos;
147        SHORT sVscrollPos;
148        LONG  sVscrollInc;
149        LONG  sHscrollInc;
150        ULONG realVscrollMax;
151        LONG  cxClient;
152        LONG  cyClient;
153        LONG  spos_x;
154        LONG  spos_y;
155        HPS hpsBuffer;
156        HDC hdcBuffer;
157        LuPixbuf *pixbuf;
158        short bpp;
159        double width, height, zoom, realzoom, fullwidth, fullheight;
160        boolean zoomMode;
161        long rotation;
162        long totalpages, currentpage;
163        ProgressDlg *progressDlg;
164        DrawAreas *drawareas;
165        int drawareaIndex;
166        bool closed;
167        bool drawPS;
168        PgLayout layout;
169
170        // mouse drag using right button
171        bool docDraggingStarted;
172        POINTL docDraggingStart;
173        POINTL docDraggingEnd;
174       
175        // fullscreen
176        bool fullscreen;
177        long secondsNoMouse;
178        bool mouseHidden;
179        SHORT xLastPos;
180        SHORT yLastPos;
181        PgLayout pglSave;
182        double zoomSave;
183
184        // continuous view
185        LuSize *pagesizes;
186        SHORT VScrollStep;
187        RECTL savedRcl;
188
189        // asynch draw
190        bool enableAsynchDraw;
191        HMTX todrawAccess;
192        HEV  haveDraw;
193        bool abortAsynch;
194        bool termdraw;
195        TID  drawThreadId;
196
197        // selection
198        bool mousePressed;
199        POINTL selectionStart;
200        POINTL selectionEnd;
201        LuRectangle *selection;
202        LuDocument_LuRectSequence **selrects;
203
204        // links
205        bool haveLinks;
206        LuDocument_LuLinkMapSequence **links;
207
208        // search
209        LuDocument_LuRectSequence **foundrects;
210        char *searchString;
211        bool caseSensitive;
212        bool continueSearch;
213        bool abortSearch;
214       
215        // pointers
216        HPOINTER handPtr;
217        HPOINTER handClosedPtr;
218        HPOINTER zoomInPtr;
219        HPOINTER zoomOutPtr;
220};
221
222#endif // __DOCVIEWER_H
223
Note: See TracBrowser for help on using the repository browser.