19f62ea84SAndrew Rist /**************************************************************
2*a404096bSMechtilde Stehmann *
39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
59f62ea84SAndrew Rist * distributed with this work for additional information
69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10*a404096bSMechtilde Stehmann *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*a404096bSMechtilde Stehmann *
139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist * software distributed under the License is distributed on an
159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
179f62ea84SAndrew Rist * specific language governing permissions and limitations
189f62ea84SAndrew Rist * under the License.
19*a404096bSMechtilde Stehmann *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
229f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <vcl/dockingarea.hxx>
30cdf0e10cSrcweir #include <vcl/syswin.hxx>
31cdf0e10cSrcweir #include <vcl/menu.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <svdata.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <map>
36cdf0e10cSrcweir
37cdf0e10cSrcweir // =======================================================================
38cdf0e10cSrcweir
39cdf0e10cSrcweir class DockingAreaWindow::ImplData
40cdf0e10cSrcweir {
41cdf0e10cSrcweir public:
42cdf0e10cSrcweir ImplData();
43cdf0e10cSrcweir ~ImplData();
44cdf0e10cSrcweir
45cdf0e10cSrcweir WindowAlign meAlign;
46cdf0e10cSrcweir };
47cdf0e10cSrcweir
ImplData()48cdf0e10cSrcweir DockingAreaWindow::ImplData::ImplData()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir meAlign = WINDOWALIGN_TOP;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
~ImplData()53cdf0e10cSrcweir DockingAreaWindow::ImplData::~ImplData()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir // =======================================================================
58cdf0e10cSrcweir
ImplInitBackground(DockingAreaWindow * pThis)59cdf0e10cSrcweir static void ImplInitBackground( DockingAreaWindow* pThis )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir if( !pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir Wallpaper aWallpaper;
64cdf0e10cSrcweir aWallpaper.SetStyle( WALLPAPER_APPLICATIONGRADIENT );
65cdf0e10cSrcweir pThis->SetBackground( aWallpaper );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir else
68cdf0e10cSrcweir pThis->SetBackground( Wallpaper( pThis->GetSettings().GetStyleSettings().GetFaceColor() ) );
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
DockingAreaWindow(Window * pParent)71cdf0e10cSrcweir DockingAreaWindow::DockingAreaWindow( Window* pParent ) :
72cdf0e10cSrcweir Window( WINDOW_DOCKINGAREA )
73cdf0e10cSrcweir {
74*a404096bSMechtilde Stehmann ImplInit( pParent, WB_CLIPCHILDREN|WB_3DLOOK, NULL );
75cdf0e10cSrcweir
76cdf0e10cSrcweir mpImplData = new ImplData;
77cdf0e10cSrcweir ImplInitBackground( this );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
~DockingAreaWindow()80cdf0e10cSrcweir DockingAreaWindow::~DockingAreaWindow()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir delete mpImplData;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir // -----------------------------------------------------------------------
86cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)87cdf0e10cSrcweir void DockingAreaWindow::DataChanged( const DataChangedEvent& rDCEvt )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir Window::DataChanged( rDCEvt );
90cdf0e10cSrcweir
91cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir ImplInitBackground( this );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir // -----------------------------------------------------------------------
98cdf0e10cSrcweir
ImplInvalidateMenubar(DockingAreaWindow * pThis)99cdf0e10cSrcweir static void ImplInvalidateMenubar( DockingAreaWindow* pThis )
100cdf0e10cSrcweir {
101af27b5beSMechtilde Stehmann // due to a possible common gradient covering menubar and top dockingarea
102cdf0e10cSrcweir // the menubar must be repainted if the top dockingarea changes size or visibility
103cdf0e10cSrcweir if( ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG &&
104*a404096bSMechtilde Stehmann (pThis->GetAlign() == WINDOWALIGN_TOP)
105cdf0e10cSrcweir && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL )
106cdf0e10cSrcweir && pThis->IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir SystemWindow *pSysWin = pThis->GetSystemWindow();
109cdf0e10cSrcweir if( pSysWin && pSysWin->GetMenuBar() )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir Window *pMenubarWin = pSysWin->GetMenuBar()->GetWindow();
112cdf0e10cSrcweir if( pMenubarWin )
113cdf0e10cSrcweir pMenubarWin->Invalidate();
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
StateChanged(StateChangedType nType)118cdf0e10cSrcweir void DockingAreaWindow::StateChanged( StateChangedType nType )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir Window::StateChanged( nType );
121cdf0e10cSrcweir
122cdf0e10cSrcweir if ( nType == STATE_CHANGE_VISIBLE )
123cdf0e10cSrcweir ImplInvalidateMenubar( this );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // -----------------------------------------------------------------------
127cdf0e10cSrcweir
IsHorizontal() const128cdf0e10cSrcweir sal_Bool DockingAreaWindow::IsHorizontal() const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir return ( mpImplData->meAlign == WINDOWALIGN_TOP || mpImplData->meAlign == WINDOWALIGN_BOTTOM );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
SetAlign(WindowAlign eNewAlign)133cdf0e10cSrcweir void DockingAreaWindow::SetAlign( WindowAlign eNewAlign )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir if( eNewAlign != mpImplData->meAlign )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir mpImplData->meAlign = eNewAlign;
138cdf0e10cSrcweir Invalidate();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
GetAlign() const142cdf0e10cSrcweir WindowAlign DockingAreaWindow::GetAlign() const
143cdf0e10cSrcweir {
144cdf0e10cSrcweir return mpImplData->meAlign;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir // -----------------------------------------------------------------------
148cdf0e10cSrcweir
Paint(const Rectangle &)149cdf0e10cSrcweir void DockingAreaWindow::Paint( const Rectangle& )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir EnableNativeWidget( sal_True ); // only required because the toolkit curently switches this flag off
152cdf0e10cSrcweir if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir ToolbarValue aControlValue;
155cdf0e10cSrcweir
156cdf0e10cSrcweir if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir // give NWF a hint that this dockingarea is adjacent to the menubar
159cdf0e10cSrcweir // useful for special gradient effects that should cover both windows
160cdf0e10cSrcweir aControlValue.mbIsTopDockingArea = sal_True;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir ControlState nState = CTRL_STATE_ENABLED;
163cdf0e10cSrcweir
164cdf0e10cSrcweir if( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir // draw a single toolbar background covering the whole docking area
167cdf0e10cSrcweir Point tmp;
168cdf0e10cSrcweir Rectangle aCtrlRegion( tmp, GetOutputSizePixel() );
169*a404096bSMechtilde Stehmann
170*a404096bSMechtilde Stehmann DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
171cdf0e10cSrcweir aCtrlRegion, nState, aControlValue, rtl::OUString() );
172cdf0e10cSrcweir
173cdf0e10cSrcweir // each toolbar gets a thin border to better recognize its borders on the homogeneous docking area
174cdf0e10cSrcweir sal_uInt16 nChildren = GetChildCount();
175cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nChildren; n++ )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir Window* pChild = GetChild( n );
178cdf0e10cSrcweir if ( pChild->IsVisible() )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir Point aPos = pChild->GetPosPixel();
181cdf0e10cSrcweir Size aSize = pChild->GetSizePixel();
182cdf0e10cSrcweir Rectangle aRect( aPos, aSize );
183cdf0e10cSrcweir
184cdf0e10cSrcweir SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
185cdf0e10cSrcweir DrawLine( aRect.TopLeft(), aRect.TopRight() );
186cdf0e10cSrcweir DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
187cdf0e10cSrcweir
188cdf0e10cSrcweir SetLineColor( GetSettings().GetStyleSettings().GetSeparatorColor() );
189cdf0e10cSrcweir DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
190cdf0e10cSrcweir DrawLine( aRect.TopRight(), aRect.BottomRight() );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir else
195cdf0e10cSrcweir {
196*a404096bSMechtilde Stehmann // create map to find toolbar lines
197cdf0e10cSrcweir Size aOutSz = GetOutputSizePixel();
198cdf0e10cSrcweir std::map< int, int > ranges;
199cdf0e10cSrcweir sal_uInt16 nChildren = GetChildCount();
200cdf0e10cSrcweir for( sal_uInt16 n = 0; n < nChildren; n++ )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir Window* pChild = GetChild( n );
203cdf0e10cSrcweir Point aPos = pChild->GetPosPixel();
204cdf0e10cSrcweir Size aSize = pChild->GetSizePixel();
205cdf0e10cSrcweir if( IsHorizontal() )
206cdf0e10cSrcweir ranges[ aPos.Y() ] = aSize.Height();
207cdf0e10cSrcweir else
208cdf0e10cSrcweir ranges[ aPos.X() ] = aSize.Width();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir
212cdf0e10cSrcweir // draw multiple toolbar backgrounds, i.e., one for each toolbar line
213cdf0e10cSrcweir for( std::map<int,int>::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir Rectangle aTBRect;
216cdf0e10cSrcweir if( IsHorizontal() )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir aTBRect.Left() = 0;
219cdf0e10cSrcweir aTBRect.Right() = aOutSz.Width() - 1;
220cdf0e10cSrcweir aTBRect.Top() = it->first;
221cdf0e10cSrcweir aTBRect.Bottom() = it->first + it->second - 1;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir else
224cdf0e10cSrcweir {
225cdf0e10cSrcweir aTBRect.Left() = it->first;
226cdf0e10cSrcweir aTBRect.Right() = it->first + it->second - 1;
227cdf0e10cSrcweir aTBRect.Top() = 0;
228cdf0e10cSrcweir aTBRect.Bottom() = aOutSz.Height() - 1;
229cdf0e10cSrcweir }
230*a404096bSMechtilde Stehmann DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
231cdf0e10cSrcweir aTBRect, nState, aControlValue, rtl::OUString() );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
Resize()237cdf0e10cSrcweir void DockingAreaWindow::Resize()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir ImplInvalidateMenubar( this );
240cdf0e10cSrcweir if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
241cdf0e10cSrcweir Invalidate();
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244cdf0e10cSrcweir // -----------------------------------------------------------------------
245cdf0e10cSrcweir
246