source: trunk/Lucide/gui/docViewer.h

Last change on this file was 678, checked in by Gregg Young, 3 years ago

Fix memory leak in "Save" code. Reduce "Save screen noise. Add Last link origin for navigating back from taking a hyper link. Ticket 309 Additional Spanish translation from Alfredo. Make help instance code tolerate a "\" on the end of the install path.

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