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

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

Fullscreen implemented (closes #6). Hotkey is Ctrl+L, like in Acrobat. Mozilla-like fullscreen (F11) renamed to 'Maximized view'. Currently page draws at upper-left corner, centered draw should be implemented.

File size: 6.8 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
121        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
122        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
123        static void searchthread( void *p );
124        static void searchabort( void *p );
125        static void drawthread( void *p );
126        static long _System asynchCallbackFnDraw( void *data );
127        static long _System asynchCallbackFnAbort( void *data );
128
129        LuDocument *doc;
130        HAB hab;
131        HWND hMainFrame;
132        HWND hWndDocFrame;
133        HWND hWndDoc;
134        PFNWP oldFrameProc;
135        HWND hWndHscroll;
136        HWND hWndVscroll;
137        SHORT sHscrollMax;
138        SHORT sVscrollMax;
139        SHORT sHscrollPos;
140        SHORT sVscrollPos;
141        LONG  sVscrollInc;
142        LONG  sHscrollInc;
143        ULONG realVscrollMax;
144        LONG  cxClient;
145        LONG  cyClient;
146        LONG  spos_x;
147        LONG  spos_y;
148        HPS hpsBuffer;
149        HDC hdcBuffer;
150        Environment *ev;
151        LuPixbuf *pixbuf;
152        short bpp;
153        double width, height, zoom, realzoom, fullwidth, fullheight;
154        long rotation;
155        long totalpages, currentpage;
156        ProgressDlg *progressDlg;
157        DrawAreas *drawareas;
158        int drawareaIndex;
159        bool closed;
160        bool drawPS;
161       
162        // fullscreen
163        bool fullscreen;
164        PgLayout pglSave;
165        double zoomSave;
166
167        // continuous view
168        bool continuous;
169        LuSize *pagesizes;
170        SHORT VScrollStep;
171        RECTL savedRcl;
172
173        // asynch draw
174        bool enableAsynchDraw;
175        HMTX todrawAccess;
176        HEV  haveDraw;
177        bool abortAsynch;
178        bool termdraw;
179        TID  drawThreadId;
180
181        // selection
182        bool mousePressed;
183        POINTL selectionStart;
184        POINTL selectionEnd;
185        LuRectangle *selection;
186        LuDocument_LuRectSequence **selrects;
187
188        // links
189        LuDocument_LuLinkMapSequence **links;
190        HPOINTER handptr;
191
192        // search
193        LuDocument_LuRectSequence **foundrects;
194        char *searchString;
195        bool caseSensitive;
196        bool continueSearch;
197        bool abortSearch;
198};
199
200#endif // __DOCVIEWER_H
201
Note: See TracBrowser for help on using the repository browser.