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