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

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

drawing fixes and improvements, djvu plugin fixes

File size: 6.9 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( HAB _hab, 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; }
72        void setZoom( double _zoom );
73        double getZoom() { return zoom; }
74        double getRealZoom() { return realzoom; }
75        void setRotation( long _rotation );
76        long getRotation() { return rotation; }
77        void selectAll();
78        void copyToClipbrd();
79        void searchDocument( const char *_searchString, bool _caseSensitive,
80                             bool _continueSearch );
81        void setFullscreen( bool _fullscreen );
82
83        static void registerClass( HAB hab );
84
85        // Internal stuffs
86    private:
87
88        void drawPage();
89        void adjustSize();
90                void countPagesizes();
91
92        MRESULT vertScroll( HWND hwnd, MPARAM mp2, HRGN hrgn );
93        MRESULT horizScroll( HWND hwnd, MPARAM mp2, HRGN hrgn );
94        MRESULT wmDragOver( PDRAGINFO dragInfo );
95                void wmDrop( PDRAGINFO dragInfo );
96                void wmSize( HWND hwnd, MPARAM mp2 );
97        void wmPaint( HWND hwnd );
98        void wmPaintCont( HWND hwnd );
99        void wmPaintAsynch( HWND hwnd );
100        void wmPaintContAsynch( HWND hwnd );
101        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
102        void wmButton1Up();
103        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
104        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
105        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
106        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
107        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
108        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
109        void rotateRectangle( long pagenum, LuRectangle *r );
110        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
111        void drawSelection( long pagenum, HPS hps, PRECTL r );
112        void scrollToPos( HWND hwnd, HRGN hrgn, LONG xpos, LONG ypos, bool withSelection );
113        void freeRects( LuDocument_LuRectSequence **rects );
114        void freeLinks();
115        void drawFound( long pagenum, HPS hps, PRECTL r );
116        DrawAreas *findDrawAreas( PRECTL r );
117        void determineCurrentPage();
118        long posToPagenum( LONG yPosWin, double *pageRest );
119        double pagenumToPos( long pagenum );
120        bool isRotated() { return ( (rotation==90) || (rotation==270) ); }
121
122        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
123        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
124        static void searchthread( void *p );
125        static void searchabort( void *p );
126        static void drawthread( void *p );
127        static long _System asynchCallbackFnDraw( void *data );
128        static long _System asynchCallbackFnAbort( void *data );
129
130        LuDocument *doc;
131        HAB hab;
132        HWND hMainFrame;
133        HWND hWndDocFrame;
134        HWND hWndDoc;
135        PFNWP oldFrameProc;
136        HWND hWndHscroll;
137        HWND hWndVscroll;
138        SHORT sHscrollMax;
139        SHORT sVscrollMax;
140        SHORT sHscrollPos;
141        SHORT sVscrollPos;
142        LONG  sVscrollInc;
143        LONG  sHscrollInc;
144        ULONG realVscrollMax;
145        LONG  cxClient;
146        LONG  cyClient;
147        LONG  spos_x;
148        LONG  spos_y;
149        HPS hpsBuffer;
150        HDC hdcBuffer;
151        Environment *ev;
152        LuPixbuf *pixbuf;
153        short bpp;
154        double width, height, zoom, realzoom, fullwidth, fullheight;
155        long rotation;
156        long totalpages, currentpage;
157        ProgressDlg *progressDlg;
158        DrawAreas *drawareas;
159        int drawareaIndex;
160        bool closed;
161        bool drawPS;
162       
163        // fullscreen
164        bool fullscreen;
165        PgLayout pglSave;
166        double zoomSave;
167
168        // continuous view
169        bool continuous;
170        LuSize *pagesizes;
171        SHORT VScrollStep;
172        RECTL savedRcl;
173
174        // asynch draw
175        bool enableAsynchDraw;
176        HMTX todrawAccess;
177        HEV  haveDraw;
178        bool abortAsynch;
179        bool termdraw;
180        TID  drawThreadId;
181
182        // selection
183        bool mousePressed;
184        POINTL selectionStart;
185        POINTL selectionEnd;
186        LuRectangle *selection;
187        LuDocument_LuRectSequence **selrects;
188
189        // links
190        LuDocument_LuLinkMapSequence **links;
191        HPOINTER handptr;
192
193        // search
194        LuDocument_LuRectSequence **foundrects;
195        char *searchString;
196        bool caseSensitive;
197        bool continueSearch;
198        bool abortSearch;
199};
200
201#endif // __DOCVIEWER_H
202
Note: See TracBrowser for help on using the repository browser.