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_SD_SOURCE_UI_INC_TABCONTROL_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_TABCONTROL_HXX
22 
23 #include <svtools/tabbar.hxx>
24 #include <vcl/transfer.hxx>
25 
26 namespace sd {
27 
28 /**
29  * TabControl-Class for page switch
30  */
31 
32 class DrawViewShell;
33 
34 class TabControl final
35     : public TabBar,
36       public DragSourceHelper,
37       public DropTargetHelper
38 {
39 public:
40     TabControl (DrawViewShell* pDrViewSh, vcl::Window* pParent);
41     virtual void dispose() override;
42     virtual ~TabControl() override;
43 
44     /** Inform all listeners of this control that the current page has been
45         activated.  Call this method after switching the current page and is
46         not done elsewhere (like when using page up/down keys).
47     */
48     void SendActivatePageEvent();
49 
50     /** Inform all listeners of this control that the current page has been
51         deactivated.  Call this method before switching the current page and
52         is not done elsewhere (like when using page up/down keys).
53     */
54     void SendDeactivatePageEvent();
55 
56 private:
57     sal_uInt16          RrePageID;
58     DrawViewShell*      pDrViewSh;
59     bool                bInternalMove;
60 
61     // TabBar
62     virtual void        Select() override;
63     virtual void        DoubleClick() override;
64     virtual void        MouseButtonDown(const MouseEvent& rMEvt) override;
65 
66     virtual void        Command(const CommandEvent& rCEvt) override;
67 
68     virtual bool        StartRenaming() override;
69     virtual TabBarAllowRenamingReturnCode  AllowRenaming() override;
70     virtual void        EndRenaming() override;
71 
72     virtual void        ActivatePage() override;
73     virtual bool        DeactivatePage() override;
74 
75     // DragSourceHelper
76     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
77 
78     // DropTargetHelper
79     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) override;
80     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
81 
82     // nested class to implement the TransferableHelper
83     class TabControlTransferable : public TransferableHelper
84     {
85     public:
TabControlTransferable(TabControl & rParent)86         explicit TabControlTransferable( TabControl& rParent ) :
87             mrParent( rParent ) {}
88     private:
89 
90         TabControl&     mrParent;
91 
92         virtual             ~TabControlTransferable() override;
93 
94         virtual void        AddSupportedFormats() override;
95         virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
96         virtual void        DragFinished( sal_Int8 nDropAction ) override;
97 
98     };
99 
100     friend class TabControl::TabControlTransferable;
101 
102     void                DragFinished();
103 
104     using TabBar::StartDrag;
105 };
106 
107 } // end of namespace sd
108 
109 #endif
110 
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
112