xref: /AOO41X/main/svtools/inc/svtools/scrwin.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SCRWIN_HXX
25 #define _SCRWIN_HXX
26 
27 #include "svtools/svtdllapi.h"
28 
29 #ifndef _SCRBAR_HXX //autogen
30 #include <vcl/scrbar.hxx>
31 #endif
32 
33 class DataChangedEvent;
34 
35 // -------------------------
36 // - ScrollableWindow-Type -
37 // -------------------------
38 
39 typedef sal_uInt16 ScrollableWindowFlags;
40 
41 #define SCRWIN_THUMBDRAGGING 1
42 #define SCRWIN_VCENTER       2
43 #define SCRWIN_HCENTER       4
44 #define SCRWIN_DEFAULT       (SCRWIN_THUMBDRAGGING | SCRWIN_VCENTER | SCRWIN_HCENTER)
45 
46 // --------------------
47 // - ScrollableWindow -
48 // --------------------
49 
50 class SVT_DLLPUBLIC ScrollableWindow: public Window
51 {
52 private:
53     Point           aPixOffset;         // offset to virtual window (pixel)
54     Size            aTotPixSz;          // total size of virtual window (pixel)
55     long            nLinePixH;          // size of a line/column (pixel)
56     long            nColumnPixW;
57 
58     ScrollBar       aVScroll;           // the scrollbars
59     ScrollBar       aHScroll;
60     ScrollBarBox    aCornerWin;         // window in the bottom right corner
61     sal_Bool            bScrolling:1,       // user controlled scrolling
62                     bHandleDragging:1,  // scroll window while dragging
63                     bHCenter:1,
64                     bVCenter:1;
65 
66 #ifdef _SVT_SCRWIN_CXX
67     SVT_DLLPRIVATE void         ImpInitialize( ScrollableWindowFlags nFlags );
68     DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar * );
69     DECL_DLLPRIVATE_LINK( EndScrollHdl, ScrollBar * );
70 #endif
71 
72 public:
73                     ScrollableWindow( Window* pParent, WinBits nBits = 0,
74                                       ScrollableWindowFlags = SCRWIN_DEFAULT );
75                     ScrollableWindow( Window* pParent, const ResId& rId,
76                                       ScrollableWindowFlags = SCRWIN_DEFAULT );
77 
78     virtual void    Resize();
79     virtual void    Command( const CommandEvent& rCEvt );
80     virtual void    DataChanged( const DataChangedEvent& rDEvt );
81 
82     virtual void    StartScroll();
83     virtual void    EndScroll( long nDeltaX, long nDeltaY );
84 
85     using OutputDevice::SetMapMode;
86     virtual void    SetMapMode( const MapMode& rNewMapMode );
87     virtual MapMode GetMapMode() const;
88 
89     void            SetTotalSize( const Size& rNewSize );
GetTotalSize()90     Size            GetTotalSize() { return PixelToLogic( aTotPixSz ); }
91 
92     void            SetVisibleSize( const Size& rNewSize );
93     sal_Bool            MakeVisible( const Rectangle& rTarget, sal_Bool bSloppy = sal_False );
94     Rectangle       GetVisibleArea() const;
95 
96     void            SetLineSize( sal_uLong nHorz, sal_uLong nVert );
97     using Window::Scroll;
98     virtual void    Scroll( long nDeltaX, long nDeltaY, sal_uInt16 nFlags = 0 );
99     void            ScrollLines( long nLinesX, long nLinesY );
100     void            ScrollPages( long nPagesX, sal_uLong nOverlapX,
101                                  long nPagesY, sal_uLong nOverlapY );
102 
103 private:
104     SVT_DLLPRIVATE Size         GetOutputSizePixel() const;
105     SVT_DLLPRIVATE Size         GetOutputSize() const;
106 };
107 
108 #endif
109