Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX
20 : #define INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX
21 :
22 : #include <sfx2/dllapi.h>
23 : #include <vcl/toolbox.hxx>
24 : #include <com/sun/star/frame/XDispatch.hpp>
25 : #include <com/sun/star/frame/XFrame.hpp>
26 : #include <com/sun/star/frame/XToolbarController.hpp>
27 : #include <com/sun/star/util/URL.hpp>
28 : #include <map>
29 :
30 :
31 : namespace sfx2 { namespace sidebar {
32 :
33 : /** The sidebar tool box has two responsibilities:
34 : 1. Coordinated location, size, and other states with its parent
35 : background window.
36 : 2. Create and handle tool bar controller for its items.
37 : */
38 : class SFX2_DLLPUBLIC SidebarToolBox
39 : : public ToolBox
40 : {
41 : public:
42 : SidebarToolBox(vcl::Window* pParentWindow);
43 : virtual ~SidebarToolBox (void);
44 :
45 : using ToolBox::InsertItem;
46 : virtual void InsertItem(const OUString& rCommand,
47 : const com::sun::star::uno::Reference<com::sun::star::frame::XFrame>& rFrame,
48 : ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
49 : const Size& rRequestedSize = Size(),
50 : sal_uInt16 nPos = TOOLBOX_APPEND) SAL_OVERRIDE;
51 :
52 : virtual void Paint (const Rectangle& rRect) SAL_OVERRIDE;
53 :
54 : virtual bool Notify (NotifyEvent& rEvent) SAL_OVERRIDE;
55 :
56 : css::uno::Reference<css::frame::XToolbarController> GetControllerForItemId (
57 : const sal_uInt16 nItemId) const;
58 : sal_uInt16 GetItemIdForSubToolbarName (
59 : const ::rtl::OUString& rsCOmmandName) const;
60 :
61 : void SetController (
62 : const sal_uInt16 nItemId,
63 : const css::uno::Reference<css::frame::XToolbarController>& rxController,
64 : const ::rtl::OUString& rsCommandName);
65 :
66 : private:
67 : Image maItemSeparator;
68 121790 : class ItemDescriptor
69 : {
70 : public:
71 : css::uno::Reference<css::frame::XToolbarController> mxController;
72 : css::util::URL maURL;
73 : rtl::OUString msCurrentCommand;
74 : };
75 : typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
76 : ControllerContainer maControllers;
77 : bool mbAreHandlersRegistered;
78 :
79 : DECL_LINK(DropDownClickHandler, ToolBox*);
80 : DECL_LINK(ClickHandler, ToolBox*);
81 : DECL_LINK(DoubleClickHandler, ToolBox*);
82 : DECL_LINK(SelectHandler, ToolBox*);
83 : DECL_LINK(ActivateToolBox, ToolBox*);
84 : DECL_LINK(DeactivateToolBox, ToolBox*);
85 :
86 : void CreateController (
87 : const sal_uInt16 nItemId,
88 : const css::uno::Reference<css::frame::XFrame>& rxFrame,
89 : const sal_Int32 nItemWidth = 0);
90 : void RegisterHandlers (void);
91 : };
92 :
93 :
94 : } } // end of namespace sfx2::sidebar
95 :
96 : #endif
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|