xref: /aoo41x/main/sfx2/source/sidebar/TabBar.hxx (revision be6d8c25)
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 #ifndef SFX_SIDEBAR_TAB_BAR_HXX
23 #define SFX_SIDEBAR_TAB_BAR_HXX
24 
25 #include "DeckDescriptor.hxx"
26 #include "ResourceManager.hxx"
27 
28 #include <vcl/menu.hxx>
29 #include <vcl/window.hxx>
30 
31 #include <com/sun/star/frame/XFrame.hpp>
32 #include <boost/function.hpp>
33 #include <boost/tuple/tuple.hpp>
34 #include <boost/scoped_ptr.hpp>
35 
36 class Button;
37 class RadioButton;
38 
39 namespace css = ::com::sun::star;
40 namespace cssu = ::com::sun::star::uno;
41 
42 
43 namespace sfx2 { namespace sidebar {
44 
45 class FocusManager;
46 class TabBarConfiguration;
47 class TabItem;
48 
49 /** The tab bar is the container for the individual tabs.
50 */
51 class TabBar
52     : public Window
53 {
54 public:
55     /** DeckMenuData has entries for display name, deck id, and a flag:
56          - isCurrentDeck for the deck selection data
57          - isEnabled     for the show/hide menu
58     */
59     class DeckMenuData
60     {
61     public:
62         ::rtl::OUString msDisplayName;
63         ::rtl::OUString msDeckId;
64         bool mbIsCurrentDeck;
65         bool mbIsActive;
66         bool mbIsEnabled;
67     };
68     typedef ::boost::function<void(
69             const Rectangle&,
70             const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
71     TabBar (
72         Window* pParentWindow,
73         const cssu::Reference<css::frame::XFrame>& rxFrame,
74         const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor,
75         const PopupMenuProvider& rPopupMenuProvider);
76     virtual ~TabBar (void);
77 
78     virtual void Paint (const Rectangle& rUpdateArea);
79     virtual void DataChanged (const DataChangedEvent& rDataChangedEvent);
80     virtual long Notify (NotifyEvent& rEvent);
81 
82     static sal_Int32 GetDefaultWidth (void);
83 
84     void SetDecks (
85         const ResourceManager::DeckContextDescriptorContainer& rDecks);
86     void HighlightDeck (const ::rtl::OUString& rsDeckId);
87     void AddPopupMenuEntries (
88         PopupMenu& rMenu,
89         const sal_Int32 nFirstIndex);
90     void AddCustomizationMenuEntries (
91         PopupMenu& rMenu,
92         const sal_Int32 nFirstIndex);
93     const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const;
94     void ToggleHideFlag (const sal_Int32 nIndex);
95     void RestoreHideFlags (void);
96 
97     void UpdateFocusManager (FocusManager& rFocusManager);
98 
99 private:
100     cssu::Reference<css::frame::XFrame> mxFrame;
101     ::boost::scoped_ptr<Button> mpMenuButton;
102     class Item
103     {
104     public:
105         DECL_LINK(HandleClick, Button*);
106         ::boost::shared_ptr<RadioButton> mpButton;
107         ::rtl::OUString msDeckId;
108         ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
109         bool mbIsHidden;
110         bool mbIsHiddenByDefault;
111     };
112     typedef ::std::vector<Item> ItemContainer;
113     ItemContainer maItems;
114     const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
115     sal_Int32 mnMenuSeparatorY;
116     PopupMenuProvider maPopupMenuProvider;
117 
118     RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
119     Item* GetItemForId (const ::rtl::OUString& rsId);
120     Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
121     void Layout (void);
122     void UpdateButtonIcons (void);
123 
124     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
125     void ShowPopupMenu (void) const;
126     DECL_LINK(OnToolboxClicked, void*);
127 
128 };
129 
130 
131 } } // end of namespace sfx2::sidebar
132 
133 #endif
134