Branch data 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 : :
20 : :
21 : : #include <vcl/dockingarea.hxx>
22 : : #include <vcl/syswin.hxx>
23 : : #include <vcl/menu.hxx>
24 : :
25 : : #include <svdata.hxx>
26 : :
27 : : #include <map>
28 : :
29 : : // =======================================================================
30 : :
31 : : class DockingAreaWindow::ImplData
32 : : {
33 : : public:
34 : : ImplData();
35 : : ~ImplData();
36 : :
37 : : WindowAlign meAlign;
38 : : };
39 : :
40 : 14080 : DockingAreaWindow::ImplData::ImplData()
41 : : {
42 : 14080 : meAlign = WINDOWALIGN_TOP;
43 : 14080 : }
44 : :
45 : 13352 : DockingAreaWindow::ImplData::~ImplData()
46 : : {
47 : 13352 : }
48 : :
49 : : // =======================================================================
50 : :
51 : 14080 : static void ImplInitBackground( DockingAreaWindow* pThis )
52 : : {
53 [ + - ]: 14080 : if( !pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
54 : : {
55 [ + - ]: 14080 : Wallpaper aWallpaper;
56 [ + - ]: 14080 : aWallpaper.SetStyle( WALLPAPER_APPLICATIONGRADIENT );
57 [ + - ][ + - ]: 14080 : pThis->SetBackground( aWallpaper );
58 : : }
59 : : else
60 [ # # ]: 0 : pThis->SetBackground( Wallpaper( pThis->GetSettings().GetStyleSettings().GetFaceColor() ) );
61 : 14080 : }
62 : :
63 : 14080 : DockingAreaWindow::DockingAreaWindow( Window* pParent ) :
64 : 14080 : Window( WINDOW_DOCKINGAREA )
65 : : {
66 [ + - ]: 14080 : ImplInit( pParent, WB_CLIPCHILDREN|WB_3DLOOK, NULL );
67 : :
68 [ + - ][ + - ]: 14080 : mpImplData = new ImplData;
69 [ + - ]: 14080 : ImplInitBackground( this );
70 : 14080 : }
71 : :
72 : 13352 : DockingAreaWindow::~DockingAreaWindow()
73 : : {
74 [ + - ][ + - ]: 13352 : delete mpImplData;
75 [ - + ]: 26704 : }
76 : :
77 : : // -----------------------------------------------------------------------
78 : :
79 : 48 : void DockingAreaWindow::DataChanged( const DataChangedEvent& rDCEvt )
80 : : {
81 : 48 : Window::DataChanged( rDCEvt );
82 : :
83 [ - + ][ - + ]: 48 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
[ + - ]
84 : : {
85 : 0 : ImplInitBackground( this );
86 : : }
87 : 48 : }
88 : :
89 : : // -----------------------------------------------------------------------
90 : :
91 : 23314 : static void ImplInvalidateMenubar( DockingAreaWindow* pThis )
92 : : {
93 : : // due to a possible comon gradient covering menubar and top dockingarea
94 : : // the menubar must be repainted if the top dockingarea changes size or visibility
95 [ - + # # : 23314 : if( ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG &&
# # # # ]
[ - + ]
96 : 0 : (pThis->GetAlign() == WINDOWALIGN_TOP)
97 : 0 : && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL )
98 : 0 : && pThis->IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
99 : : {
100 : 0 : SystemWindow *pSysWin = pThis->GetSystemWindow();
101 [ # # ][ # # ]: 0 : if( pSysWin && pSysWin->GetMenuBar() )
[ # # ]
102 : : {
103 : 0 : Window *pMenubarWin = pSysWin->GetMenuBar()->GetWindow();
104 [ # # ]: 0 : if( pMenubarWin )
105 : 0 : pMenubarWin->Invalidate();
106 : : }
107 : : }
108 : 23314 : }
109 : :
110 : 16632 : void DockingAreaWindow::StateChanged( StateChangedType nType )
111 : : {
112 : 16632 : Window::StateChanged( nType );
113 : :
114 [ + + ]: 16632 : if ( nType == STATE_CHANGE_VISIBLE )
115 : 6964 : ImplInvalidateMenubar( this );
116 : 16632 : }
117 : :
118 : : // -----------------------------------------------------------------------
119 : :
120 : 0 : sal_Bool DockingAreaWindow::IsHorizontal() const
121 : : {
122 [ # # ][ # # ]: 0 : return ( mpImplData->meAlign == WINDOWALIGN_TOP || mpImplData->meAlign == WINDOWALIGN_BOTTOM );
123 : : }
124 : :
125 : 14080 : void DockingAreaWindow::SetAlign( WindowAlign eNewAlign )
126 : : {
127 [ + + ]: 14080 : if( eNewAlign != mpImplData->meAlign )
128 : : {
129 : 10560 : mpImplData->meAlign = eNewAlign;
130 : 10560 : Invalidate();
131 : : }
132 : 14080 : }
133 : :
134 : 0 : WindowAlign DockingAreaWindow::GetAlign() const
135 : : {
136 : 0 : return mpImplData->meAlign;
137 : : }
138 : :
139 : : // -----------------------------------------------------------------------
140 : :
141 : 2834 : void DockingAreaWindow::Paint( const Rectangle& )
142 : : {
143 : 2834 : EnableNativeWidget( sal_True ); // only required because the toolkit curently switches this flag off
144 [ - + ]: 2834 : if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
145 : : {
146 [ # # ]: 0 : ToolbarValue aControlValue;
147 : :
148 [ # # ][ # # ]: 0 : if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
[ # # ][ # # ]
[ # # ]
149 : : {
150 : : // give NWF a hint that this dockingarea is adjacent to the menubar
151 : : // useful for special gradient effects that should cover both windows
152 : 0 : aControlValue.mbIsTopDockingArea = sal_True;
153 : : }
154 : 0 : ControlState nState = CTRL_STATE_ENABLED;
155 : :
156 [ # # ][ # # ]: 0 : if( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
157 : : {
158 : : // draw a single toolbar background covering the whole docking area
159 : 0 : Point tmp;
160 [ # # ]: 0 : Rectangle aCtrlRegion( tmp, GetOutputSizePixel() );
161 : :
162 [ # # ]: 0 : DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
163 [ # # ][ # # ]: 0 : aCtrlRegion, nState, aControlValue, rtl::OUString() );
164 : :
165 [ # # ][ # # ]: 0 : if( !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
166 : : {
167 : : // each toolbar gets a thin border to better recognize its borders on the homogeneous docking area
168 [ # # ]: 0 : sal_uInt16 nChildren = GetChildCount();
169 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nChildren; n++ )
170 : : {
171 [ # # ]: 0 : Window* pChild = GetChild( n );
172 [ # # ][ # # ]: 0 : if ( pChild->IsVisible() )
173 : : {
174 [ # # ]: 0 : Point aPos = pChild->GetPosPixel();
175 [ # # ]: 0 : Size aSize = pChild->GetSizePixel();
176 [ # # ]: 0 : Rectangle aRect( aPos, aSize );
177 : :
178 [ # # ]: 0 : SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
179 [ # # ][ # # ]: 0 : DrawLine( aRect.TopLeft(), aRect.TopRight() );
180 [ # # ][ # # ]: 0 : DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
181 : :
182 [ # # ][ # # ]: 0 : SetLineColor( GetSettings().GetStyleSettings().GetSeparatorColor() );
183 [ # # ][ # # ]: 0 : DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
[ # # ]
184 [ # # ][ # # ]: 0 : DrawLine( aRect.TopRight(), aRect.BottomRight() );
[ # # ]
185 : : }
186 : : }
187 : : }
188 : : }
189 : : else
190 : : {
191 : : // create map to find toolbar lines
192 : 0 : Size aOutSz = GetOutputSizePixel();
193 [ # # ]: 0 : std::map< int, int > ranges;
194 [ # # ]: 0 : sal_uInt16 nChildren = GetChildCount();
195 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nChildren; n++ )
196 : : {
197 [ # # ]: 0 : Window* pChild = GetChild( n );
198 [ # # ]: 0 : Point aPos = pChild->GetPosPixel();
199 [ # # ]: 0 : Size aSize = pChild->GetSizePixel();
200 [ # # ][ # # ]: 0 : if( IsHorizontal() )
201 [ # # ]: 0 : ranges[ aPos.Y() ] = aSize.Height();
202 : : else
203 [ # # ]: 0 : ranges[ aPos.X() ] = aSize.Width();
204 : : }
205 : :
206 : :
207 : : // draw multiple toolbar backgrounds, i.e., one for each toolbar line
208 [ # # ][ # # ]: 0 : for( std::map<int,int>::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
[ # # ][ # # ]
[ # # ]
209 : : {
210 [ # # ]: 0 : Rectangle aTBRect;
211 [ # # ][ # # ]: 0 : if( IsHorizontal() )
212 : : {
213 : 0 : aTBRect.Left() = 0;
214 : 0 : aTBRect.Right() = aOutSz.Width() - 1;
215 [ # # ]: 0 : aTBRect.Top() = it->first;
216 [ # # ][ # # ]: 0 : aTBRect.Bottom() = it->first + it->second - 1;
217 : : }
218 : : else
219 : : {
220 [ # # ]: 0 : aTBRect.Left() = it->first;
221 [ # # ][ # # ]: 0 : aTBRect.Right() = it->first + it->second - 1;
222 : 0 : aTBRect.Top() = 0;
223 : 0 : aTBRect.Bottom() = aOutSz.Height() - 1;
224 : : }
225 [ # # ]: 0 : DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
226 [ # # ][ # # ]: 0 : aTBRect, nState, aControlValue, rtl::OUString() );
227 : 0 : }
228 [ # # ]: 0 : }
229 : : }
230 : 2834 : }
231 : :
232 : 16350 : void DockingAreaWindow::Resize()
233 : : {
234 : 16350 : ImplInvalidateMenubar( this );
235 [ - + ]: 16350 : if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
236 : 0 : Invalidate();
237 : 16350 : }
238 : :
239 : : // -----------------------------------------------------------------------
240 : :
241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|