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 SFX_SIDEBAR_TOOLBOX_HXX
20 : #define SFX_SIDEBAR_TOOLBOX_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 : namespace css = ::com::sun::star;
31 : namespace cssu = ::com::sun::star::uno;
32 :
33 : namespace sfx2 { namespace sidebar {
34 :
35 : /** The sidebar tool box has two responsibilities:
36 : 1. Coordinated location, size, and other states with its parent
37 : background window.
38 : 2. Create and handle tool bar controller for its items.
39 : */
40 : class SFX2_DLLPUBLIC SidebarToolBox
41 : : public ToolBox
42 : {
43 : public:
44 : /** Create a new tool box.
45 : When a valid XFrame is given then the tool box will handle its
46 : buttons and drop-downs. Otherwise the caller has to do that.
47 : */
48 : SidebarToolBox (
49 : Window* pParentWindow,
50 : const ResId& rResId,
51 : const cssu::Reference<css::frame::XFrame>& rxFrame);
52 : SidebarToolBox (
53 : Window* pParentWindow);
54 : virtual ~SidebarToolBox (void);
55 :
56 : using ToolBox::InsertItem;
57 : virtual void InsertItem(const OUString& rCommand,
58 : const com::sun::star::uno::Reference<com::sun::star::frame::XFrame>& rFrame,
59 : ToolBoxItemBits nBits = 0,
60 : const Size& rRequestedSize = Size(),
61 : sal_uInt16 nPos = TOOLBOX_APPEND);
62 :
63 : void SetBorderWindow (const Window* pBorderWindow);
64 : virtual void Paint (const Rectangle& rRect);
65 :
66 : virtual Point GetPosPixel (void) const;
67 : virtual void setPosSizePixel (
68 : long nX,
69 : long nY,
70 : long nWidth,
71 : long nHeight,
72 : sal_uInt16 nFlags);
73 : virtual long Notify (NotifyEvent& rEvent);
74 :
75 : cssu::Reference<css::frame::XToolbarController> GetControllerForItemId (
76 : const sal_uInt16 nItemId) const;
77 : sal_uInt16 GetItemIdForSubToolbarName (
78 : const ::rtl::OUString& rsCOmmandName) const;
79 :
80 : void SetController (
81 : const sal_uInt16 nItemId,
82 : const cssu::Reference<css::frame::XToolbarController>& rxController,
83 : const ::rtl::OUString& rsCommandName);
84 :
85 : private:
86 : bool mbParentIsBorder;
87 : Image maItemSeparator;
88 0 : class ItemDescriptor
89 : {
90 : public:
91 : cssu::Reference<css::frame::XToolbarController> mxController;
92 : css::util::URL maURL;
93 : rtl::OUString msCurrentCommand;
94 : };
95 : typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
96 : ControllerContainer maControllers;
97 : bool mbAreHandlersRegistered;
98 :
99 : DECL_LINK(DropDownClickHandler, ToolBox*);
100 : DECL_LINK(ClickHandler, ToolBox*);
101 : DECL_LINK(DoubleClickHandler, ToolBox*);
102 : DECL_LINK(SelectHandler, ToolBox*);
103 : DECL_LINK(ActivateToolBox, ToolBox*);
104 : DECL_LINK(DeactivateToolBox, ToolBox*);
105 :
106 : void CreateController (
107 : const sal_uInt16 nItemId,
108 : const cssu::Reference<css::frame::XFrame>& rxFrame,
109 : const sal_Int32 nItemWidth = 0);
110 : void UpdateIcons (
111 : const cssu::Reference<css::frame::XFrame>& rxFrame);
112 : void RegisterHandlers (void);
113 : };
114 :
115 :
116 : } } // end of namespace sfx2::sidebar
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|