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