Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_SCRWIN_HXX
21 : #define INCLUDED_SVTOOLS_SCRWIN_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <vcl/scrbar.hxx>
25 : #include <o3tl/typed_flags_set.hxx>
26 : #include <vcl/vclptr.hxx>
27 :
28 : class DataChangedEvent;
29 :
30 :
31 : // - ScrollableWindow-Type -
32 :
33 :
34 : enum class ScrollableWindowFlags
35 : {
36 : THUMBDRAGGING = 1,
37 : VCENTER = 2,
38 : HCENTER = 4,
39 : DEFAULT = THUMBDRAGGING | VCENTER | HCENTER,
40 : };
41 : namespace o3tl
42 : {
43 : template<> struct typed_flags<ScrollableWindowFlags> : is_typed_flags<ScrollableWindowFlags, 0x07> {};
44 : }
45 :
46 :
47 : // - ScrollableWindow -
48 :
49 :
50 : class SVT_DLLPUBLIC ScrollableWindow: public vcl::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 : VclPtr<ScrollBar> aVScroll; // the scrollbars
59 : VclPtr<ScrollBar> aHScroll;
60 : VclPtr<ScrollBarBox> aCornerWin; // window in the bottom right corner
61 : bool bScrolling:1, // user controlled scrolling
62 : bHandleDragging:1, // scroll window while dragging
63 : bHCenter:1,
64 : bVCenter:1;
65 :
66 : SVT_DLLPRIVATE void ImpInitialize( ScrollableWindowFlags nFlags );
67 : DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar * );
68 : DECL_DLLPRIVATE_LINK( EndScrollHdl, ScrollBar * );
69 :
70 : public:
71 : ScrollableWindow( vcl::Window* pParent, WinBits nBits = 0,
72 : ScrollableWindowFlags = ScrollableWindowFlags::DEFAULT );
73 : virtual ~ScrollableWindow();
74 : virtual void dispose() SAL_OVERRIDE;
75 :
76 : virtual void Resize() SAL_OVERRIDE;
77 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
78 : virtual void DataChanged( const DataChangedEvent& rDEvt ) SAL_OVERRIDE;
79 :
80 : using OutputDevice::SetMapMode;
81 : virtual void SetMapMode( const MapMode& rNewMapMode ) SAL_OVERRIDE;
82 : MapMode GetMapMode() const;
83 :
84 : void SetTotalSize( const Size& rNewSize );
85 31 : Size GetTotalSize() { return PixelToLogic( aTotPixSz ); }
86 :
87 : using Window::Scroll;
88 : virtual void Scroll( long nDeltaX, long nDeltaY, ScrollFlags nFlags = ScrollFlags::NONE ) SAL_OVERRIDE;
89 :
90 : private:
91 : SVT_DLLPRIVATE Size GetOutputSizePixel() const;
92 : };
93 :
94 : #endif
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|