1ae13266dSAndre Fischer /**************************************************************
2ae13266dSAndre Fischer  *
3ae13266dSAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4ae13266dSAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5ae13266dSAndre Fischer  * distributed with this work for additional information
6ae13266dSAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7ae13266dSAndre Fischer  * to you under the Apache License, Version 2.0 (the
8ae13266dSAndre Fischer  * "License"); you may not use this file except in compliance
9ae13266dSAndre Fischer  * with the License.  You may obtain a copy of the License at
10ae13266dSAndre Fischer  *
11ae13266dSAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12ae13266dSAndre Fischer  *
13ae13266dSAndre Fischer  * Unless required by applicable law or agreed to in writing,
14ae13266dSAndre Fischer  * software distributed under the License is distributed on an
15ae13266dSAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ae13266dSAndre Fischer  * KIND, either express or implied.  See the License for the
17ae13266dSAndre Fischer  * specific language governing permissions and limitations
18ae13266dSAndre Fischer  * under the License.
19ae13266dSAndre Fischer  *
20ae13266dSAndre Fischer  *************************************************************/
21ae13266dSAndre Fischer 
22ae13266dSAndre Fischer #ifndef SFX_SIDEBAR_TOOLBOX_HXX
23ae13266dSAndre Fischer #define SFX_SIDEBAR_TOOLBOX_HXX
24ae13266dSAndre Fischer 
25ae13266dSAndre Fischer #include "sfx2/dllapi.h"
26ae13266dSAndre Fischer #include "vcl/toolbox.hxx"
27ae13266dSAndre Fischer #include <com/sun/star/frame/XDispatch.hpp>
28ae13266dSAndre Fischer #include <com/sun/star/frame/XFrame.hpp>
29ae13266dSAndre Fischer #include <com/sun/star/frame/XToolbarController.hpp>
30ae13266dSAndre Fischer #include <com/sun/star/util/URL.hpp>
31ae13266dSAndre Fischer #include <map>
32ae13266dSAndre Fischer 
33ae13266dSAndre Fischer namespace css = ::com::sun::star;
34ae13266dSAndre Fischer namespace cssu = ::com::sun::star::uno;
35ae13266dSAndre Fischer 
36ae13266dSAndre Fischer namespace sfx2 { namespace sidebar {
37ae13266dSAndre Fischer 
38ae13266dSAndre Fischer /** The sidebar tool box has two responsibilities:
39ae13266dSAndre Fischer     1. Coordinated location, size, and other states with its parent
40ae13266dSAndre Fischer        background window.
41ae13266dSAndre Fischer     2. Create and handle tool bar controller for its items.
42ae13266dSAndre Fischer */
43ae13266dSAndre Fischer class SFX2_DLLPUBLIC SidebarToolBox
44ae13266dSAndre Fischer     : public ToolBox
45ae13266dSAndre Fischer {
46ae13266dSAndre Fischer public:
47ae13266dSAndre Fischer     /** Create a new tool box.
48ae13266dSAndre Fischer         When a valid XFrame is given then the tool box will handle its
49ae13266dSAndre Fischer         buttons and drop-downs.  Otherwise the caller has to do that.
50ae13266dSAndre Fischer     */
51ae13266dSAndre Fischer     SidebarToolBox (
52ae13266dSAndre Fischer         Window* pParentWindow,
53ae13266dSAndre Fischer         const ResId& rResId,
54ae13266dSAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
558a1a651aSAndre Fischer     SidebarToolBox (
568a1a651aSAndre Fischer         Window* pParentWindow);
57ae13266dSAndre Fischer     virtual ~SidebarToolBox (void);
58ae13266dSAndre Fischer 
59ae13266dSAndre Fischer     void SetBorderWindow (const Window* pBorderWindow);
60ae13266dSAndre Fischer     virtual void Paint (const Rectangle& rRect);
61ae13266dSAndre Fischer 
62ae13266dSAndre Fischer     virtual Point GetPosPixel (void) const;
63ae13266dSAndre Fischer     virtual void SetPosSizePixel (
64ae13266dSAndre Fischer         long nX,
65ae13266dSAndre Fischer         long nY,
66ae13266dSAndre Fischer         long nWidth,
67ae13266dSAndre Fischer         long nHeight,
68ae13266dSAndre Fischer         sal_uInt16 nFlags);
69ae13266dSAndre Fischer     virtual long Notify (NotifyEvent& rEvent);
70ae13266dSAndre Fischer 
71ae13266dSAndre Fischer     cssu::Reference<css::frame::XToolbarController> GetControllerForItemId (
72ae13266dSAndre Fischer         const sal_uInt16 nItemId) const;
73ae13266dSAndre Fischer     sal_uInt16 GetItemIdForSubToolbarName (
74ae13266dSAndre Fischer         const ::rtl::OUString& rsCOmmandName) const;
75ae13266dSAndre Fischer 
768a1a651aSAndre Fischer     void SetController (
778a1a651aSAndre Fischer         const sal_uInt16 nItemId,
788a1a651aSAndre Fischer         const cssu::Reference<css::frame::XToolbarController>& rxController,
798a1a651aSAndre Fischer         const ::rtl::OUString& rsCommandName);
808a1a651aSAndre Fischer 
81ae13266dSAndre Fischer private:
82ae13266dSAndre Fischer     bool mbParentIsBorder;
83ae13266dSAndre Fischer     Image maItemSeparator;
84ae13266dSAndre Fischer     class ItemDescriptor
85ae13266dSAndre Fischer     {
86ae13266dSAndre Fischer     public:
87ae13266dSAndre Fischer         cssu::Reference<css::frame::XToolbarController> mxController;
88ae13266dSAndre Fischer         css::util::URL maURL;
89ae13266dSAndre Fischer         rtl::OUString msCurrentCommand;
90ae13266dSAndre Fischer     };
91ae13266dSAndre Fischer     typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
92ae13266dSAndre Fischer     ControllerContainer maControllers;
938a1a651aSAndre Fischer     bool mbAreHandlersRegistered;
94ae13266dSAndre Fischer 
95ae13266dSAndre Fischer     DECL_LINK(DropDownClickHandler, ToolBox*);
96ae13266dSAndre Fischer     DECL_LINK(ClickHandler, ToolBox*);
97ae13266dSAndre Fischer     DECL_LINK(DoubleClickHandler, ToolBox*);
98ae13266dSAndre Fischer     DECL_LINK(SelectHandler, ToolBox*);
99ae13266dSAndre Fischer     DECL_LINK(Activate, ToolBox*);
100ae13266dSAndre Fischer     DECL_LINK(Deactivate, ToolBox*);
101ae13266dSAndre Fischer 
102*6a606da0SAndre Fischer     using ToolBox::Activate;
103*6a606da0SAndre Fischer     using ToolBox::Deactivate;
104*6a606da0SAndre Fischer     using DockingWindow::SetPosSizePixel;
105*6a606da0SAndre Fischer 
106ae13266dSAndre Fischer     void CreateController (
107ae13266dSAndre Fischer         const sal_uInt16 nItemId,
108d46a1e42SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame,
109d46a1e42SAndre Fischer         const sal_Int32 nItemWidth = 0);
110ae13266dSAndre Fischer     void UpdateIcons (
111ae13266dSAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
1128a1a651aSAndre Fischer     void RegisterHandlers (void);
113ae13266dSAndre Fischer };
114ae13266dSAndre Fischer 
115ae13266dSAndre Fischer 
116ae13266dSAndre Fischer } } // end of namespace sfx2::sidebar
117ae13266dSAndre Fischer 
118ae13266dSAndre Fischer #endif
119