xref: /aoo41x/main/sfx2/source/sidebar/TabBar.hxx (revision 13e1c3b4)
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     typedef ::boost::tuple<rtl::OUString,rtl::OUString,bool> DeckMenuData;
60     typedef ::boost::function<void(
61             const Rectangle&,
62             const ::std::vector<DeckMenuData>& rDeckSelectionData,
63             const ::std::vector<DeckMenuData>& rDeckShowData)> PopupMenuProvider;
64     TabBar (
65         Window* pParentWindow,
66         const cssu::Reference<css::frame::XFrame>& rxFrame,
67         const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor,
68         const PopupMenuProvider& rPopupMenuProvider);
69     virtual ~TabBar (void);
70 
71     virtual void Paint (const Rectangle& rUpdateArea);
72     virtual void DataChanged (const DataChangedEvent& rDataChangedEvent);
73 
74     static sal_Int32 GetDefaultWidth (void);
75 
76     void SetDecks (
77         const ResourceManager::DeckContextDescriptorContainer& rDecks);
78     void HighlightDeck (const ::rtl::OUString& rsDeckId);
79     void AddPopupMenuEntries (
80         PopupMenu& rMenu,
81         const sal_Int32 nFirstIndex);
82     void AddCustomizationMenuEntries (
83         PopupMenu& rMenu,
84         const sal_Int32 nFirstIndex);
85     const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const;
86     void ToggleHideFlag (const sal_Int32 nIndex);
87     void RestoreHideFlags (void);
88 
89     void UpdateFocusManager (FocusManager& rFocusManager);
90 
91 private:
92     cssu::Reference<css::frame::XFrame> mxFrame;
93     ::boost::scoped_ptr<Button> mpMenuButton;
94     class Item
95     {
96     public:
97         DECL_LINK(HandleClick, Button*);
98         ::boost::shared_ptr<RadioButton> mpButton;
99         ::rtl::OUString msDeckId;
100         ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
101         bool mbIsHidden;
102         bool mbIsHiddenByDefault;
103     };
104     typedef ::std::vector<Item> ItemContainer;
105     ItemContainer maItems;
106     const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
107     sal_Int32 mnMenuSeparatorY;
108     PopupMenuProvider maPopupMenuProvider;
109 
110     RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
111     Item* GetItemForId (const ::rtl::OUString& rsId);
112     Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
113     void Layout (void);
114     void UpdateButtonIcons (void);
115 
116     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
117     void ShowPopupMenu (void) const;
118     DECL_LINK(OnToolboxClicked, void*);
119 
120 };
121 
122 
123 } } // end of namespace sfx2::sidebar
124 
125 #endif
126