xref: /aoo41x/main/sfx2/source/sidebar/TabBar.hxx (revision 95a18594)
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 <boost/function.hpp>
32 #include <boost/tuple/tuple.hpp>
33 
34 class Button;
35 class RadioButton;
36 
37 namespace sfx2 { namespace sidebar {
38 
39 class TabBarConfiguration;
40 class TabItem;
41 
42 /** The tab bar is the container for the individual tabs.
43 */
44 class TabBar
45     : public Window
46 {
47 public:
48     /** DeckMenuData has entries for display name, deck id, and a flag:
49          - isCurrentDeck for the deck selection data
50          - isEnabled     for the show/hide menu
51     */
52     typedef ::boost::tuple<rtl::OUString,rtl::OUString,bool> DeckMenuData;
53     typedef ::boost::function<void(
54             const Rectangle&,
55             const ::std::vector<DeckMenuData>& rDeckSelectionData,
56             const ::std::vector<DeckMenuData>& rDeckShowData)> PopupMenuProvider;
57     TabBar (
58         Window* pParentWindow,
59         const cssu::Reference<css::frame::XFrame>& rxFrame,
60         const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor,
61         const PopupMenuProvider& rPopupMenuProvider);
62     virtual ~TabBar (void);
63 
64     virtual void Paint (const Rectangle& rUpdateArea);
65     virtual void DataChanged (const DataChangedEvent& rDataChangedEvent);
66 
67     static sal_Int32 GetDefaultWidth (void);
68 
69     void SetDecks (
70         const ResourceManager::IdContainer& rDeckIds);
71     void HighlightDeck (const ::rtl::OUString& rsDeckId);
72     void AddPopupMenuEntries (
73         PopupMenu& rMenu,
74         const sal_Int32 nFirstIndex);
75     void AddCustomizationMenuEntries (
76         PopupMenu& rMenu,
77         const sal_Int32 nFirstIndex);
78     const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const;
79     void ToggleHideFlag (const sal_Int32 nIndex);
80     void RestoreHideFlags (void);
81 
82 private:
83     cssu::Reference<css::frame::XFrame> mxFrame;
84     Button* mpMenuButton;
85     class Item
86     {
87     public:
88         DECL_LINK(HandleClick, Button*);
89         RadioButton* mpButton;
90         ::rtl::OUString msDeckId;
91         ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
92         bool mbIsHidden;
93         bool mbIsHiddenByDefault;
94     };
95     typedef ::std::vector<Item> ItemContainer;
96     ItemContainer maItems;
97     const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
98     sal_Int32 mnMenuSeparatorY;
99     PopupMenuProvider maPopupMenuProvider;
100 
101     RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
102     Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
103     void Layout (void);
104     void UpdateButtonIcons (void);
105 
106     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
107     void ShowPopupMenu (void) const;
108     DECL_LINK(OnToolboxClicked, void*);
109 
110 };
111 
112 
113 } } // end of namespace sfx2::sidebar
114 
115 #endif
116