source: trunk/Lucide/gui/docViewer.h @ 398

Last change on this file since 398 was 398, checked in by dmik, 11 years ago

Fixed: The mouse pointer could be auto-hidden in fullscreen while the file open dialog is shown.

File size: 8.4 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;
44class LuInputText;
45
46struct LuSize  { double x, y; };
47
48struct PageDrawArea
49{
50    long   pagenum;
51    LuSize startpos;
52    RECTL  drawrect;
53};
54
55struct PageInputFields
56{
57    LuDocument_LuInputFieldSequence *fields;
58
59    struct Cache
60    {
61        LuRectangle *rect;
62        LuInputField_Type type;
63        bool supported;
64        bool modified;
65    };
66
67    Cache *cache;
68
69    void fillCache( int i );
70};
71
72typedef std::vector<PageDrawArea> DrawAreas;
73
74class DocumentViewer
75{
76    public:
77        DocumentViewer( HWND hWndFrame );
78        virtual ~DocumentViewer();
79
80        void setPageLayout( PgLayout layout );
81        PgLayout getPageLayout() { return layout; }
82
83        HWND getFrameHWND() { return hWndDocFrame; }
84        HWND getViewHWND() { return hWndDoc; }
85
86        void setDocument( LuDocument *_doc );
87        bool close( bool force = false );
88        void goToPage( long page );
89        long getCurrentPage() { return currentpage; }  // Zero based
90        void setZoom( double _zoom );
91        double getZoom() { return zoom; }
92        double getRealZoom() { return realzoom; }
93        void setZoomMode( bool _zoomMode ) { zoomMode = _zoomMode; }
94        bool isZoomMode() { return zoomMode; }
95        void setRotation( long _rotation );
96        long getRotation() { return rotation; }
97        void selectAll();
98        void unhideMouse();
99        void copyToClipbrd();
100        void searchDocument( const char *_searchString, bool _caseSensitive,
101                             bool _continueSearch );
102        void setFullscreen( bool _fullscreen );
103        void zoomInOut( bool zoomIn );
104        void resetModifiedState();
105
106        static void registerClass();
107
108        // Internal stuffs
109    private:
110
111        void drawPage();
112        void adjustSize();
113        void countPagesizes();
114
115        MRESULT vertScroll( HWND hwnd, MPARAM mp2 );
116        MRESULT horizScroll( HWND hwnd, MPARAM mp2 );
117        MRESULT wmDragOver( PDRAGINFO dragInfo );
118        void wmDrop( PDRAGINFO dragInfo );
119        void wmSize( HWND hwnd, MPARAM mp2 );
120        void wmPaint( HWND hwnd );
121        void wmPaintCont( HWND hwnd );
122        void wmPaintAsynch( HWND hwnd );
123        void wmPaintContAsynch( HWND hwnd );
124        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
125        void wmButton1Up();
126        void wmButton2Down( HWND hwnd, SHORT xpos, SHORT ypos );
127        void wmButton2Up();
128        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
129        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
130        BOOL wmRightClick( HWND hwnd, SHORT xpos, SHORT ypos );
131        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
132        void wmTimer( USHORT idTimer );
133        void wmControl( USHORT idControl, USHORT notifyCode, HWND hwndControl );
134        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
135        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
136        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
137        void rotateRectangle( long pagenum, LuRectangle *r );
138        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
139        void drawSelection( long pagenum, HPS hps, PRECTL r );
140        void scrollToPos( HWND hwnd, LONG xpos, LONG ypos, bool withSelection );
141        void freeRects( LuDocument_LuRectSequence **rects );
142        void freeLinks();
143        void freeInputFields();
144        void drawFound( long pagenum, HPS hps, PRECTL r );
145        DrawAreas *findDrawAreas( PRECTL r );
146        void determineCurrentPage();
147        long posToPagenum( LONG yPosWin, double *pageRest );
148        double pagenumToPos( long pagenum );
149        bool isRotated() { return ( (rotation==90) || (rotation==270) ); }
150        bool isContinuous() { return ( layout == Continuous ); };
151        void showTextField( long page, long index, PRECTL r = NULL );
152        void positionTextField( PRECTL r = NULL );
153        void hideTextField( bool apply = true, PPOINTL ptl = NULL );
154
155        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
156        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
157        static void searchthread( void *p );
158        static void searchabort( void *p );
159        static void drawthread( void *p );
160        static long _System asynchCallbackFnDraw( void *data );
161        static long _System asynchCallbackFnAbort( void *data );
162
163        LuDocument *doc;
164        HWND hMainFrame;
165        HWND hWndDocFrame;
166        HWND hWndDoc;
167        HWND hWndEntry;
168        HWND hWndMLE;
169        LuInputText *textField;
170        long textFieldPage;
171        long textFieldIndex;
172        PFNWP oldFrameProc;
173        HWND hWndHscroll;
174        HWND hWndVscroll;
175        SHORT sHscrollMax;
176        SHORT sVscrollMax;
177        SHORT sHscrollPos;
178        SHORT sVscrollPos;
179        LONG  sVscrollInc;
180        LONG  sHscrollInc;
181        ULONG realVscrollMax;
182        LONG  cxClient;
183        LONG  cyClient;
184        LONG  spos_x;
185        LONG  spos_y;
186        HPS hpsBuffer;
187        HDC hdcBuffer;
188        LuPixbuf *pixbuf;
189        short bpp;
190        double width, height, zoom, realzoom, fullwidth, fullheight;
191        boolean zoomMode;
192        long rotation;
193        long totalpages, currentpage;
194        ProgressDlg *progressDlg;
195        DrawAreas *drawareas;
196        int drawareaIndex;
197        bool closed;
198        bool drawPS;
199        PgLayout layout;
200
201        // mouse drag using right button
202        bool docDraggingStarted;
203        POINTL docDraggingStart;
204        POINTL docDraggingEnd;
205
206        // fullscreen
207        bool fullscreen;
208        bool mouseHidden;
209        bool inFocus;
210        SHORT xLastPos;
211        SHORT yLastPos;
212        PgLayout pglSave;
213        double zoomSave;
214
215        // continuous view
216        LuSize *pagesizes;
217        SHORT VScrollStep;
218        RECTL savedRcl;
219
220        // asynch draw
221        bool enableAsynchDraw;
222        HMTX todrawAccess;
223        HEV  haveDraw;
224        bool abortAsynch;
225        bool termdraw;
226        TID  drawThreadId;
227
228        // selection
229        bool mousePressed;
230        POINTL selectionStart;
231        POINTL selectionEnd;
232        LuRectangle *selection;
233        LuDocument_LuRectSequence **selrects;
234
235        // links
236        LuDocument_LuLinkMapSequence **links;
237
238        // input fields
239        PageInputFields *inputFields;
240
241        // search
242        LuDocument_LuRectSequence **foundrects;
243        char *searchString;
244        bool caseSensitive;
245        bool continueSearch;
246        bool abortSearch;
247
248        // pointers
249        HPOINTER handPtr;
250        HPOINTER handClosedPtr;
251        HPOINTER zoomInPtr;
252        HPOINTER zoomOutPtr;
253        HPOINTER textPtr;
254};
255
256#endif // __DOCVIEWER_H
257
Note: See TracBrowser for help on using the repository browser.