xref: /aoo42x/main/sfx2/source/sidebar/TabBar.hxx (revision ff12d537)
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/window.hxx"
29 
30 class Button;
31 
32 namespace sfx2 { namespace sidebar {
33 
34 class TabBarConfiguration;
35 class TabItem;
36 
37 /** The tab bar is the container for the individual tabs.
38 */
39 class TabBar
40     : public Window
41 {
42 public:
43     TabBar (
44         Window* pParentWindow,
45         const cssu::Reference<css::frame::XFrame>& rxFrame,
46         const ::boost::function<void(const DeckDescriptor&)>& rDeckActivationFunctor,
47         const ::boost::function<void(const Rectangle&)>& rPopupMenuProvider);
48     virtual ~TabBar (void);
49 
50     virtual void Paint (const Rectangle& rUpdateArea);
51     virtual void DataChanged (const DataChangedEvent& rDataChangedEvent);
52 
53     static sal_Int32 GetDefaultWidth (void);
54 
55     void SetDecks (
56         const ResourceManager::DeckContainer& rDeckDescriptors);
57     void HighlightDeck (const ::rtl::OUString& rsDeckId);
58     void AddPopupMenuEntries (
59         PopupMenu& rMenu,
60         const sal_Int32 nFirstIndex);
61     void AddCustomizationMenuEntries (
62         PopupMenu& rMenu,
63         const sal_Int32 nFirstIndex);
64     const DeckDescriptor& GetDeckDescriptorForIndex (const sal_Int32 nIndex) const;
65     void ToggleHideFlag (const sal_Int32 nIndex);
66     void RestoreHideFlags (void);
67 
68 private:
69     cssu::Reference<css::frame::XFrame> mxFrame;
70     Button* mpMenuButton;
71     class Item
72     {
73     public:
74         DECL_LINK(HandleClick, Button*);
75         RadioButton* mpButton;
76         DeckDescriptor maDeckDescriptor;
77         ::boost::function<void(const DeckDescriptor&)> maDeckActivationFunctor;
78         bool mbIsHidden;
79         bool mbIsHiddenByDefault;
80     };
81     typedef ::std::vector<Item> ItemContainer;
82     ItemContainer maItems;
83     const ::boost::function<void(const DeckDescriptor&)> maDeckActivationFunctor;
84     sal_Int32 mnMenuSeparatorY;
85     ::boost::function<void(const Rectangle&)> maPopupMenuProvider;
86 
87     RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
88     Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
89     void Layout (void);
90     void UpdateButtonIcons (void);
91 
92     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
93     void ShowPopupMenu (void) const;
94     DECL_LINK(OnToolboxClicked, void*);
95 
96 };
97 
98 
99 } } // end of namespace sfx2::sidebar
100 
101 #endif
102