source: branches/kmk/Lucide/gui/docViewer.h @ 355

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

branches/kmk: Reset the modified state if saved to the same file.

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 copyToClipbrd();
99        void searchDocument( const char *_searchString, bool _caseSensitive,
100                             bool _continueSearch );
101        void setFullscreen( bool _fullscreen );
102        void zoomInOut( bool zoomIn );
103        void resetModifiedState();
104
105        static void registerClass();
106
107        // Internal stuffs
108    private:
109
110        void drawPage();
111        void adjustSize();
112        void countPagesizes();
113
114        MRESULT vertScroll( HWND hwnd, MPARAM mp2 );
115        MRESULT horizScroll( HWND hwnd, MPARAM mp2 );
116        MRESULT wmDragOver( PDRAGINFO dragInfo );
117        void wmDrop( PDRAGINFO dragInfo );
118        void wmSize( HWND hwnd, MPARAM mp2 );
119        void wmPaint( HWND hwnd );
120        void wmPaintCont( HWND hwnd );
121        void wmPaintAsynch( HWND hwnd );
122        void wmPaintContAsynch( HWND hwnd );
123        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
124        void wmButton1Up();
125        void wmButton2Down( HWND hwnd, SHORT xpos, SHORT ypos );
126        void wmButton2Up();
127        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
128        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
129        BOOL wmRightClick( HWND hwnd, SHORT xpos, SHORT ypos );
130        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
131        void wmTimer( USHORT idTimer );
132        void wmControl( USHORT idControl, USHORT notifyCode, HWND hwndControl );
133        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
134        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
135        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
136        void rotateRectangle( long pagenum, LuRectangle *r );
137        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
138        void drawSelection( long pagenum, HPS hps, PRECTL r );
139        void scrollToPos( HWND hwnd, LONG xpos, LONG ypos, bool withSelection );
140        void freeRects( LuDocument_LuRectSequence **rects );
141        void freeLinks();
142        void freeInputFields();
143        void drawFound( long pagenum, HPS hps, PRECTL r );
144        DrawAreas *findDrawAreas( PRECTL r );
145        void determineCurrentPage();
146        long posToPagenum( LONG yPosWin, double *pageRest );
147        double pagenumToPos( long pagenum );
148        bool isRotated() { return ( (rotation==90) || (rotation==270) ); }
149        bool isContinuous() { return ( layout == Continuous ); };
150        void showTextField( long page, long index, PRECTL r = NULL );
151        void positionTextField( PRECTL r = NULL );
152        void hideTextField( bool apply = true, PPOINTL ptl = NULL );
153
154        static MRESULT EXPENTRY docViewProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
155        static MRESULT EXPENTRY docFrameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
156        static void searchthread( void *p );
157        static void searchabort( void *p );
158        static void drawthread( void *p );
159        static long _System asynchCallbackFnDraw( void *data );
160        static long _System asynchCallbackFnAbort( void *data );
161
162        LuDocument *doc;
163        HWND hMainFrame;
164        HWND hWndDocFrame;
165        HWND hWndDoc;
166        HWND hWndEntry;
167        HWND hWndMLE;
168        LuInputText *textField;
169        long textFieldPage;
170        long textFieldIndex;
171        PFNWP oldFrameProc;
172        HWND hWndHscroll;
173        HWND hWndVscroll;
174        SHORT sHscrollMax;
175        SHORT sVscrollMax;
176        SHORT sHscrollPos;
177        SHORT sVscrollPos;
178        LONG  sVscrollInc;
179        LONG  sHscrollInc;
180        ULONG realVscrollMax;
181        LONG  cxClient;
182        LONG  cyClient;
183        LONG  spos_x;
184        LONG  spos_y;
185        HPS hpsBuffer;
186        HDC hdcBuffer;
187        LuPixbuf *pixbuf;
188        short bpp;
189        double width, height, zoom, realzoom, fullwidth, fullheight;
190        boolean zoomMode;
191        long rotation;
192        long totalpages, currentpage;
193        ProgressDlg *progressDlg;
194        DrawAreas *drawareas;
195        int drawareaIndex;
196        bool closed;
197        bool drawPS;
198        PgLayout layout;
199
200        // mouse drag using right button
201        bool docDraggingStarted;
202        POINTL docDraggingStart;
203        POINTL docDraggingEnd;
204
205        // fullscreen
206        bool fullscreen;
207        long secondsNoMouse;
208        bool mouseHidden;
209        SHORT xLastPos;
210        SHORT yLastPos;
211        PgLayout pglSave;
212        double zoomSave;
213
214        // continuous view
215        LuSize *pagesizes;
216        SHORT VScrollStep;
217        RECTL savedRcl;
218
219        // asynch draw
220        bool enableAsynchDraw;
221        HMTX todrawAccess;
222        HEV  haveDraw;
223        bool abortAsynch;
224        bool termdraw;
225        TID  drawThreadId;
226
227        // selection
228        bool mousePressed;
229        POINTL selectionStart;
230        POINTL selectionEnd;
231        LuRectangle *selection;
232        LuDocument_LuRectSequence **selrects;
233
234        // links
235        LuDocument_LuLinkMapSequence **links;
236
237        // input fields
238        PageInputFields *inputFields;
239
240        // search
241        LuDocument_LuRectSequence **foundrects;
242        char *searchString;
243        bool caseSensitive;
244        bool continueSearch;
245        bool abortSearch;
246
247        // pointers
248        HPOINTER handPtr;
249        HPOINTER handClosedPtr;
250        HPOINTER zoomInPtr;
251        HPOINTER zoomOutPtr;
252        HPOINTER textPtr;
253};
254
255#endif // __DOCVIEWER_H
256
Note: See TracBrowser for help on using the repository browser.