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 virtual long Notify (NotifyEvent& rEvent); 74 75 static sal_Int32 GetDefaultWidth (void); 76 77 void SetDecks ( 78 const ResourceManager::DeckContextDescriptorContainer& rDecks); 79 void HighlightDeck (const ::rtl::OUString& rsDeckId); 80 void AddPopupMenuEntries ( 81 PopupMenu& rMenu, 82 const sal_Int32 nFirstIndex); 83 void AddCustomizationMenuEntries ( 84 PopupMenu& rMenu, 85 const sal_Int32 nFirstIndex); 86 const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const; 87 void ToggleHideFlag (const sal_Int32 nIndex); 88 void RestoreHideFlags (void); 89 90 void UpdateFocusManager (FocusManager& rFocusManager); 91 92 private: 93 cssu::Reference<css::frame::XFrame> mxFrame; 94 ::boost::scoped_ptr<Button> mpMenuButton; 95 class Item 96 { 97 public: 98 DECL_LINK(HandleClick, Button*); 99 ::boost::shared_ptr<RadioButton> mpButton; 100 ::rtl::OUString msDeckId; 101 ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; 102 bool mbIsHidden; 103 bool mbIsHiddenByDefault; 104 }; 105 typedef ::std::vector<Item> ItemContainer; 106 ItemContainer maItems; 107 const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; 108 sal_Int32 mnMenuSeparatorY; 109 PopupMenuProvider maPopupMenuProvider; 110 111 RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor); 112 Item* GetItemForId (const ::rtl::OUString& rsId); 113 Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const; 114 void Layout (void); 115 void UpdateButtonIcons (void); 116 117 ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const; 118 void ShowPopupMenu (void) const; 119 DECL_LINK(OnToolboxClicked, void*); 120 121 }; 122 123 124 } } // end of namespace sfx2::sidebar 125 126 #endif 127