xref: /aoo41x/main/sfx2/source/sidebar/TabBar.hxx (revision a2f41a4a)
122de8995SAndre Fischer /**************************************************************
222de8995SAndre Fischer  *
322de8995SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
422de8995SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
522de8995SAndre Fischer  * distributed with this work for additional information
622de8995SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
722de8995SAndre Fischer  * to you under the Apache License, Version 2.0 (the
822de8995SAndre Fischer  * "License"); you may not use this file except in compliance
922de8995SAndre Fischer  * with the License.  You may obtain a copy of the License at
1022de8995SAndre Fischer  *
1122de8995SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
1222de8995SAndre Fischer  *
1322de8995SAndre Fischer  * Unless required by applicable law or agreed to in writing,
1422de8995SAndre Fischer  * software distributed under the License is distributed on an
1522de8995SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1622de8995SAndre Fischer  * KIND, either express or implied.  See the License for the
1722de8995SAndre Fischer  * specific language governing permissions and limitations
1822de8995SAndre Fischer  * under the License.
1922de8995SAndre Fischer  *
2022de8995SAndre Fischer  *************************************************************/
2122de8995SAndre Fischer 
2222de8995SAndre Fischer #ifndef SFX_SIDEBAR_TAB_BAR_HXX
2322de8995SAndre Fischer #define SFX_SIDEBAR_TAB_BAR_HXX
2422de8995SAndre Fischer 
25ff12d537SAndre Fischer #include "DeckDescriptor.hxx"
26ff12d537SAndre Fischer #include "ResourceManager.hxx"
27ff12d537SAndre Fischer 
2895a18594SAndre Fischer #include <vcl/menu.hxx>
2995a18594SAndre Fischer #include <vcl/window.hxx>
3095a18594SAndre Fischer 
317a32b0c8SAndre Fischer #include <com/sun/star/frame/XFrame.hpp>
3295a18594SAndre Fischer #include <boost/function.hpp>
3395a18594SAndre Fischer #include <boost/tuple/tuple.hpp>
347a32b0c8SAndre Fischer #include <boost/scoped_ptr.hpp>
3522de8995SAndre Fischer 
36ff12d537SAndre Fischer class Button;
37*a2f41a4aSAndre Fischer class CheckBox;
3895a18594SAndre Fischer class RadioButton;
39ff12d537SAndre Fischer 
407a32b0c8SAndre Fischer namespace css = ::com::sun::star;
417a32b0c8SAndre Fischer namespace cssu = ::com::sun::star::uno;
427a32b0c8SAndre Fischer 
437a32b0c8SAndre Fischer 
44ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
4522de8995SAndre Fischer 
4665908a7eSAndre Fischer class FocusManager;
47ff12d537SAndre Fischer class TabBarConfiguration;
48ff12d537SAndre Fischer class TabItem;
4922de8995SAndre Fischer 
5022de8995SAndre Fischer /** The tab bar is the container for the individual tabs.
5122de8995SAndre Fischer */
5222de8995SAndre Fischer class TabBar
5322de8995SAndre Fischer     : public Window
5422de8995SAndre Fischer {
5522de8995SAndre Fischer public:
5695a18594SAndre Fischer     /** DeckMenuData has entries for display name, deck id, and a flag:
5795a18594SAndre Fischer          - isCurrentDeck for the deck selection data
5895a18594SAndre Fischer          - isEnabled     for the show/hide menu
5995a18594SAndre Fischer     */
60be6d8c25SAndre Fischer     class DeckMenuData
61be6d8c25SAndre Fischer     {
62be6d8c25SAndre Fischer     public:
63be6d8c25SAndre Fischer         ::rtl::OUString msDisplayName;
64be6d8c25SAndre Fischer         ::rtl::OUString msDeckId;
65be6d8c25SAndre Fischer         bool mbIsCurrentDeck;
66be6d8c25SAndre Fischer         bool mbIsActive;
67be6d8c25SAndre Fischer         bool mbIsEnabled;
68be6d8c25SAndre Fischer     };
6995a18594SAndre Fischer     typedef ::boost::function<void(
7095a18594SAndre Fischer             const Rectangle&,
71be6d8c25SAndre Fischer             const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
72ff12d537SAndre Fischer     TabBar (
73ff12d537SAndre Fischer         Window* pParentWindow,
74ff12d537SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame,
7595a18594SAndre Fischer         const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor,
7695a18594SAndre Fischer         const PopupMenuProvider& rPopupMenuProvider);
7722de8995SAndre Fischer     virtual ~TabBar (void);
7822de8995SAndre Fischer 
7922de8995SAndre Fischer     virtual void Paint (const Rectangle& rUpdateArea);
80ff12d537SAndre Fischer     virtual void DataChanged (const DataChangedEvent& rDataChangedEvent);
81101538fcSAndre Fischer     virtual long Notify (NotifyEvent& rEvent);
8222de8995SAndre Fischer 
8322de8995SAndre Fischer     static sal_Int32 GetDefaultWidth (void);
84ff12d537SAndre Fischer 
85ff12d537SAndre Fischer     void SetDecks (
8613e1c3b4SAndre Fischer         const ResourceManager::DeckContextDescriptorContainer& rDecks);
87ff12d537SAndre Fischer     void HighlightDeck (const ::rtl::OUString& rsDeckId);
88ff12d537SAndre Fischer     void AddPopupMenuEntries (
89ff12d537SAndre Fischer         PopupMenu& rMenu,
90ff12d537SAndre Fischer         const sal_Int32 nFirstIndex);
91ff12d537SAndre Fischer     void AddCustomizationMenuEntries (
92ff12d537SAndre Fischer         PopupMenu& rMenu,
93ff12d537SAndre Fischer         const sal_Int32 nFirstIndex);
9495a18594SAndre Fischer     const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const;
95ff12d537SAndre Fischer     void ToggleHideFlag (const sal_Int32 nIndex);
96ff12d537SAndre Fischer     void RestoreHideFlags (void);
9765908a7eSAndre Fischer 
9865908a7eSAndre Fischer     void UpdateFocusManager (FocusManager& rFocusManager);
9965908a7eSAndre Fischer 
100ff12d537SAndre Fischer private:
101ff12d537SAndre Fischer     cssu::Reference<css::frame::XFrame> mxFrame;
102*a2f41a4aSAndre Fischer     ::boost::scoped_ptr<CheckBox> mpMenuButton;
103ff12d537SAndre Fischer     class Item
104ff12d537SAndre Fischer     {
105ff12d537SAndre Fischer     public:
106ff12d537SAndre Fischer         DECL_LINK(HandleClick, Button*);
1077a32b0c8SAndre Fischer         ::boost::shared_ptr<RadioButton> mpButton;
10895a18594SAndre Fischer         ::rtl::OUString msDeckId;
10995a18594SAndre Fischer         ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
110ff12d537SAndre Fischer         bool mbIsHidden;
111ff12d537SAndre Fischer         bool mbIsHiddenByDefault;
112ff12d537SAndre Fischer     };
113ff12d537SAndre Fischer     typedef ::std::vector<Item> ItemContainer;
114ff12d537SAndre Fischer     ItemContainer maItems;
11595a18594SAndre Fischer     const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
116ff12d537SAndre Fischer     sal_Int32 mnMenuSeparatorY;
11795a18594SAndre Fischer     PopupMenuProvider maPopupMenuProvider;
118ff12d537SAndre Fischer 
119ff12d537SAndre Fischer     RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
12013e1c3b4SAndre Fischer     Item* GetItemForId (const ::rtl::OUString& rsId);
121ff12d537SAndre Fischer     Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
122ff12d537SAndre Fischer     void Layout (void);
123ff12d537SAndre Fischer     void UpdateButtonIcons (void);
124ff12d537SAndre Fischer 
125ff12d537SAndre Fischer     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
126ff12d537SAndre Fischer     void ShowPopupMenu (void) const;
127ff12d537SAndre Fischer     DECL_LINK(OnToolboxClicked, void*);
128ff12d537SAndre Fischer 
12922de8995SAndre Fischer };
13022de8995SAndre Fischer 
13122de8995SAndre Fischer 
132ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
13322de8995SAndre Fischer 
13422de8995SAndre Fischer #endif
135