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

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

fixed processing of syscommands when document area active (closes #41)

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