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 
23 
24 #ifndef SVT_TOOLPANEL_HXX
25 #define SVT_TOOLPANEL_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include "svtools/toolpanel/refbase.hxx"
29 
30 #include <rtl/ustring.hxx>
31 #include <vcl/image.hxx>
32 
33 #include <boost/noncopyable.hpp>
34 
35 class Rectangle;
36 class Window;
37 namespace com { namespace sun { namespace star { namespace accessibility {
38     class XAccessible;
39 } } } }
40 
41 //........................................................................
42 namespace svt
43 {
44 //........................................................................
45 
46 	//====================================================================
47 	//= IToolPanel
48 	//====================================================================
49     /** abstract interface for a single tool panel
50     */
51 	class SVT_DLLPUBLIC IToolPanel : public ::rtl::IReference
52 	{
53     public:
54         /// retrieves the display name of the panel
55         virtual ::rtl::OUString GetDisplayName() const = 0;
56 
57         /// retrieves the image associated with the panel, if any
58         virtual Image GetImage() const = 0;
59 
60         /// retrieves the help ID associated with the panel, if any.
61         virtual rtl::OString GetHelpID() const = 0;
62 
63         /** activates the panel
64 
65             Usually, this means the panel's Window is created (if not previosly done so) and shown.
66 
67             @param i_rParentWindow
68                 the parent window to anchor the panel window at. Subsequent calls to the Activate
69                 method will always get the same parent window. The complete area of this window is
70                 available, and should be used, for the panel window.
71         */
72         virtual void Activate( Window& i_rParentWindow ) = 0;
73 
74         /** deactivates the panel
75 
76             There are different ways how an implementation could deactivate a panel. The easiest way
77             would be to simply hide the associated Window. Alternatively, you could completely destroy it,
78             or decide to cache it by re-parenting it to another (temporary, invisible) window.
79         */
80         virtual void Deactivate() = 0;
81 
82         /** sets a new size for the panel's Window
83 
84             The panel window is always expected to be positioned at (0,0), relative to the parent window
85             which was passed to the Activate member. Resizing the panel window is necessary when the size of
86             this parent window changes. Effectively, this method is a means of convenience, to relief panel
87             implementations from reacting on size changes of their parent window themselves.
88         */
89         virtual void SetSizePixel( const Size& i_rPanelWindowSize ) = 0;
90 
91         /// sets the focus to the panel window
92         virtual void GrabFocus() = 0;
93 
94         /** release any resources associated with the panel.
95 
96             In particular, implementations should ultimately destroy the VCL window which implements the panel
97             window. No subsequent calls to any other method will happen after Destroy has been called.
98         */
99         virtual void Dispose() = 0;
100 
101         /** creates an XAccessible for the tool panel
102 
103             Implementations are allowed to create a new instance each time this method is called, the caller
104             is responsible for caching the XAccessible implementation, if this is desired.
105         */
106         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
107                     CreatePanelAccessible(
108                         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible
109                     ) = 0;
110 
~IToolPanel()111         virtual ~IToolPanel()
112         {
113         }
114 	};
115 
116     typedef ::rtl::Reference< IToolPanel >  PToolPanel;
117 
118 	//====================================================================
119 	//= ToolPanelBase
120 	//====================================================================
121     /** base class for tool panel implementations, adding ref count implementation to the IToolPanel interface,
122         but still being abstract
123     */
124     class SVT_DLLPUBLIC ToolPanelBase   :public IToolPanel
125                                         ,public RefBase
126                                         ,public ::boost::noncopyable
127     {
128     protected:
129         ToolPanelBase();
130         ~ToolPanelBase();
131 
132     public:
133         DECLARE_IREFERENCE()
134 
135     private:
136         oslInterlockedCount m_refCount;
137     };
138 
139 //........................................................................
140 } // namespace svt
141 //........................................................................
142 
143 #endif // SVT_TOOLPANEL_HXX
144