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

Last change on this file since 212 was 212, checked in by Eugene Romanenko, 14 years ago

Zoom in/Zoom out menuitems and corresponding Ctrl++/Ctrl+- hotkeys. Ctrl+Shift++/Ctrl+Shift+- hotkeys for rotate CW/CCW, Ctrl+P for Print (closes #108)

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