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

Last change on this file since 285 was 285, checked in by rbri, 11 years ago

Zoom out by right mouse button
initial impl for vert scrolling via mouse drag

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