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

Last change on this file since 37 was 35, checked in by Eugene Romanenko, 16 years ago

added licence block to source files

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