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 #include "precompiled_svtools.hxx"
25 
26 #include <vcl/window.hxx>
27 #include <vcl/virdev.hxx>
28 
29 //......................................................................................................................
30 namespace svt
31 {
32 //......................................................................................................................
33 
34     class ToolPanelDrawer;
35 	//==================================================================================================================
36 	//= DrawerVisualization
37 	//==================================================================================================================
38     /** serves a single purpose - let ZoomText read the drawers ...
39 
40         Strange enough, ZoomText does not read the drawers when they get the focus (in none of the combinations
41         of AccessibleRoles I tried), except when it does have an AccessibleChild with the role LABEL. To "inject"
42         such a child into the A11Y hierarchy, we use this window here.
43 
44         (We could also inject the A11Y component on the A11Y level only, but this would mean additional code. With
45         this approach here, VCL/toolkit will take care of creating and maintaining the A11Y component for us.)
46     */
47     class DrawerVisualization : public Window
48     {
49     public:
50         DrawerVisualization( ToolPanelDrawer& i_rParent );
51         ~DrawerVisualization();
52 
53     protected:
54         // Window overridables
55         virtual void Paint( const Rectangle& i_rBoundingBox );
56 
57     private:
58         ToolPanelDrawer&    m_rDrawer;
59     };
60 
61 	//==================================================================================================================
62 	//= ToolPanelDrawer
63 	//==================================================================================================================
64 	//------------------------------------------------------------------------------------------------------------------
65     class ToolPanelDrawer : public Window
66     {
67     public:
68         ToolPanelDrawer( Window& i_rParent, const ::rtl::OUString& i_rTitle );
69         ~ToolPanelDrawer();
70 
71         long    GetPreferredHeightPixel() const;
72         void    SetExpanded( const bool i_bExpanded );
IsExpanded() const73         bool    IsExpanded() const { return m_bExpanded; }
74 
75         void    Paint();
76 
77     protected:
78         // Window overridables
79         virtual void GetFocus();
80         virtual void LoseFocus();
81         virtual void Resize();
82         virtual void DataChanged( const DataChangedEvent& i_rEvent );
83         virtual void MouseButtonDown( const MouseEvent& i_rMouseEvent );
84 
85         virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
86                      GetComponentInterface( sal_Bool i_bCreate );
87 
88     private:
89         Rectangle   impl_calcTextBoundingBox() const;
90         Rectangle   impl_calcTitleBarBox( const Rectangle& i_rTextBox ) const;
91         void        impl_paintBackground( const Rectangle& i_rTitleBarBox );
92         sal_uInt16      impl_getTextStyle() const;
93         void        impl_paintFocusIndicator( const Rectangle& i_rTextBox );
94         Rectangle   impl_paintExpansionIndicator( const Rectangle& i_rTextBox );
95         Image       impl_getExpansionIndicator() const;
96 
97         // don't expose SetText. Our text is used as AccessibleName/Desc, and those are not expected to change.
98         using Window::SetText;
99         using Window::Paint;
100 
101     private:
102         ::std::auto_ptr< VirtualDevice >    m_pPaintDevice;
103         DrawerVisualization                 m_aVisualization;
104         bool                                m_bFocused;
105         bool                                m_bExpanded;
106     };
107 
108 //......................................................................................................................
109 } // namespace svt
110 //......................................................................................................................
111