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

Last change on this file since 47 was 40, checked in by Eugene Romanenko, 16 years ago

implemented 'select all', fixes for crash in libc memanager

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