Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / sidebar / TabBar.hxx
blob37089f873d56def6f97aaf6b98abc70c95faccf3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX
20 #define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX
22 #include "DeckDescriptor.hxx"
23 #include "ResourceManager.hxx"
25 #include <vcl/menu.hxx>
26 #include <vcl/window.hxx>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <boost/function.hpp>
30 #include <boost/tuple/tuple.hpp>
31 #include <boost/scoped_ptr.hpp>
33 class Button;
34 class CheckBox;
35 class RadioButton;
37 namespace sfx2 { namespace sidebar {
39 class FocusManager;
40 class TabBarConfiguration;
41 class TabItem;
43 /** The tab bar is the container for the individual tabs.
45 class TabBar
46 : public vcl::Window
48 public:
49 /** DeckMenuData has entries for display name, deck id, and a flag:
50 - isCurrentDeck for the deck selection data
51 - isEnabled for the show/hide menu
53 class DeckMenuData
55 public:
56 ::rtl::OUString msDisplayName;
57 ::rtl::OUString msDeckId;
58 bool mbIsCurrentDeck;
59 bool mbIsActive;
60 bool mbIsEnabled;
62 typedef ::boost::function<void(
63 const Rectangle&,
64 const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
65 TabBar (
66 vcl::Window* pParentWindow,
67 const css::uno::Reference<css::frame::XFrame>& rxFrame,
68 const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor,
69 const PopupMenuProvider& rPopupMenuProvider);
70 virtual ~TabBar();
71 virtual void dispose() SAL_OVERRIDE;
73 virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const Rectangle& rUpdateArea) SAL_OVERRIDE;
74 virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) SAL_OVERRIDE;
75 virtual bool Notify (NotifyEvent& rEvent) SAL_OVERRIDE;
77 static sal_Int32 GetDefaultWidth();
79 void SetDecks (
80 const ResourceManager::DeckContextDescriptorContainer& rDecks);
81 void HighlightDeck (const ::rtl::OUString& rsDeckId);
82 void RemoveDeckHighlight ();
83 void AddPopupMenuEntries (
84 PopupMenu& rMenu,
85 const sal_Int32 nFirstIndex);
86 void AddCustomizationMenuEntries (
87 PopupMenu& rMenu,
88 const sal_Int32 nFirstIndex);
89 const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const;
90 void ToggleHideFlag (const sal_Int32 nIndex);
91 void RestoreHideFlags();
93 void UpdateFocusManager (FocusManager& rFocusManager);
95 private:
96 css::uno::Reference<css::frame::XFrame> mxFrame;
97 VclPtr<CheckBox> mpMenuButton;
98 class Item
100 public:
101 DECL_LINK(HandleClick, Button*);
102 VclPtr<RadioButton> mpButton;
103 ::rtl::OUString msDeckId;
104 ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
105 bool mbIsHidden;
106 bool mbIsHiddenByDefault;
108 typedef ::std::vector<Item> ItemContainer;
109 ItemContainer maItems;
110 const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor;
111 sal_Int32 mnMenuSeparatorY;
112 PopupMenuProvider maPopupMenuProvider;
114 VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor);
115 Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
116 void Layout();
117 void UpdateButtonIcons();
119 ::boost::shared_ptr<PopupMenu> CreatePopupMenu() const;
120 void ShowPopupMenu() const;
121 DECL_LINK(OnToolboxClicked, void*);
126 } } // end of namespace sfx2::sidebar
128 #endif
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */