1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PaneDockingWindow.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "PaneDockingWindow.hxx"
36 #include "ViewShellBase.hxx"
37 #include "sdresid.hxx"
38 #include "res_bmp.hrc"
39 #include <sfx2/dispatch.hxx>
40 #include <vcl/toolbox.hxx>
41 #include <vcl/taskpanelist.hxx>
42 #include "framework/FrameworkHelper.hxx"
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::drawing::framework
;
50 PaneDockingWindow::PaneDockingWindow (
51 SfxBindings
*_pBindings
,
52 SfxChildWindow
*pChildWindow
,
55 const ::rtl::OUString
& rsPaneURL
,
56 const ::rtl::OUString
& rsTitle
)
67 mnChildWindowId(pChildWindow
->GetType()),
68 mpContentWindow(new ::Window(this)),
69 mbIsLayoutPending(false)
71 SetBackground (Wallpaper());
73 InitializeTitleToolBox();
75 // Tell the system window about the new docking window so that it can be
76 // reached via the keyboard.
77 SystemWindow
* pSystemWindow
= GetSystemWindow();
78 if (pSystemWindow
!= NULL
)
79 pSystemWindow
->GetTaskPaneList()->AddWindow(this);
81 mpContentWindow
->Show();
87 PaneDockingWindow::~PaneDockingWindow (void)
89 // Tell the next system window that the docking window is no longer
91 SystemWindow
* pSystemWindow
= GetSystemWindow();
92 if (pSystemWindow
!= NULL
)
93 pSystemWindow
->GetTaskPaneList()->RemoveWindow(this);
94 mpTitleToolBox
.reset();
100 void PaneDockingWindow::SetTitle (const String
& rsTitle
)
109 void PaneDockingWindow::Resize (void)
111 SfxDockingWindow::Resize();
112 mbIsLayoutPending
= true;
118 void PaneDockingWindow::Layout (void)
120 mbIsLayoutPending
= false;
122 Size
aWindowSize (GetOutputSizePixel());
123 Size
aToolBoxSize (0,0);
124 int nTitleBarHeight (GetSettings().GetStyleSettings().GetTitleHeight());
126 // Place the title tool box.
127 if (mpTitleToolBox
.get() != NULL
)
129 if (IsFloatingMode())
130 mpTitleToolBox
->HideItem (1);
132 mpTitleToolBox
->ShowItem (1);
134 aToolBoxSize
= mpTitleToolBox
->CalcWindowSizePixel();
135 if (aToolBoxSize
.Height() > nTitleBarHeight
)
136 nTitleBarHeight
= aToolBoxSize
.Height();
137 mpTitleToolBox
->SetPosSizePixel (
138 Point(aWindowSize
.Width()-aToolBoxSize
.Width(),
139 (nTitleBarHeight
-aToolBoxSize
.Height())/2),
143 // Place the content window.
144 if (nTitleBarHeight
< aToolBoxSize
.Height())
145 nTitleBarHeight
= aToolBoxSize
.Height();
146 aWindowSize
.Height() -= nTitleBarHeight
;
147 mpContentWindow
->SetPosSizePixel(
148 Point(maBorder
.Left(),nTitleBarHeight
+maBorder
.Top()),
149 Size (aWindowSize
.Width()-maBorder
.Left()-maBorder
.Right(),
150 aWindowSize
.Height()-maBorder
.Top()-maBorder
.Bottom()));
156 void PaneDockingWindow::Paint (const Rectangle
& rRectangle
)
158 if (mbIsLayoutPending
)
161 SfxDockingWindow::Paint (rRectangle
);
162 int nTitleBarHeight (GetSettings().GetStyleSettings().GetTitleHeight());
163 Size aToolBoxSize
= mpTitleToolBox
->CalcWindowSizePixel();
164 if (aToolBoxSize
.Height() > nTitleBarHeight
)
165 nTitleBarHeight
= aToolBoxSize
.Height();
166 Color
aOriginalLineColor (GetLineColor());
167 Color
aOriginalFillColor (GetFillColor());
168 SetFillColor (GetSettings().GetStyleSettings().GetDialogColor());
172 const Font
& rOriginalFont (GetFont());
173 Font
aFont (rOriginalFont
);
174 aFont
.SetWeight (WEIGHT_BOLD
);
177 // Set border values.
178 Size
aWindowSize (GetOutputSizePixel());
180 int nInnerLeft
= nOuterLeft
+ maBorder
.Left() - 1;
181 int nOuterRight
= aWindowSize
.Width() - 1;
182 int nInnerRight
= nOuterRight
- maBorder
.Right() + 1;
183 int nInnerTop
= nTitleBarHeight
+ maBorder
.Top() - 1;
184 int nOuterBottom
= aWindowSize
.Height() - 1;
185 int nInnerBottom
= nOuterBottom
- maBorder
.Bottom() + 1;
187 // Paint title bar background.
188 Rectangle
aTitleBarBox (Rectangle(
193 DrawRect (aTitleBarBox
);
195 if (nInnerLeft
> nOuterLeft
)
197 Rectangle (nOuterLeft
, nInnerTop
, nInnerLeft
, nInnerBottom
));
198 if (nOuterRight
> nInnerRight
)
200 Rectangle (nInnerRight
, nInnerTop
, nOuterRight
, nInnerBottom
));
201 if (nInnerBottom
< nOuterBottom
)
203 Rectangle (nOuterLeft
, nInnerBottom
, nOuterRight
, nOuterBottom
));
205 // Paint bevel border.
207 SetLineColor (GetSettings().GetStyleSettings().GetShadowColor());
208 if (maBorder
.Top() > 0)
210 Point(nInnerLeft
,nInnerTop
),
211 Point(nInnerLeft
,nInnerBottom
));
212 if (maBorder
.Left() > 0)
214 Point(nInnerLeft
,nInnerTop
),
215 Point(nInnerRight
,nInnerTop
));
216 SetLineColor (GetSettings().GetStyleSettings().GetLightColor());
217 if (maBorder
.Bottom() > 0)
219 Point(nInnerRight
,nInnerBottom
),
220 Point(nInnerLeft
,nInnerBottom
));
221 if (maBorder
.Right() > 0)
223 Point(nInnerRight
,nInnerBottom
),
224 Point(nInnerRight
,nInnerTop
));
226 // Paint title bar text.
227 SetLineColor (GetSettings().GetStyleSettings().GetActiveTextColor());
229 aTitleBarBox
.Left() += 3;
230 DrawText (aTitleBarBox
, msTitle
,
233 | TEXT_DRAW_MULTILINE
234 | TEXT_DRAW_WORDBREAK
);
236 // Restore original values of the output device.
237 SetFont (rOriginalFont
);
238 SetFillColor (aOriginalFillColor
);
244 void PaneDockingWindow::InitializeTitleToolBox (void)
246 if (mpTitleToolBox
.get() == NULL
)
248 // Initialize the title tool box.
249 mpTitleToolBox
.reset (new ToolBox(this));
250 mpTitleToolBox
->SetSelectHdl (
251 LINK(this, PaneDockingWindow
, ToolboxSelectHandler
));
252 mpTitleToolBox
->SetOutStyle (TOOLBOX_STYLE_FLAT
);
253 mpTitleToolBox
->SetBackground (Wallpaper (
254 GetSettings().GetStyleSettings().GetDialogColor()));
255 mpTitleToolBox
->Show();
258 mpTitleToolBox
->Clear();
260 // Get the closer bitmap and set it as right most button.
261 Bitmap
aBitmap (SdResId (BMP_CLOSE_DOC
));
262 Bitmap
aBitmapHC (SdResId (BMP_CLOSE_DOC_H
));
263 Image aImage
= Image (aBitmap
, Color (COL_LIGHTMAGENTA
));
264 Image aImageHC
= Image (aBitmapHC
, Color (BMP_COLOR_HIGHCONTRAST
));
265 mpTitleToolBox
->InsertItem (1,
266 GetSettings().GetStyleSettings().GetMenuBarColor().IsDark()
269 mpTitleToolBox
->ShowItem (1);
275 USHORT
PaneDockingWindow::AddMenu (
276 const String
& rsMenuName
,
278 const Link
& rCallback
)
280 // Add the menu before the closer button.
281 USHORT
nItemCount (mpTitleToolBox
->GetItemCount());
282 USHORT
nItemId (nItemCount
+1);
283 mpTitleToolBox
->InsertItem (
287 nItemCount
>0 ? nItemCount
-1 : (USHORT
)-1);
288 mpTitleToolBox
->SetHelpId( nItemId
, nHelpId
);
289 mpTitleToolBox
->SetClickHdl (rCallback
);
290 mpTitleToolBox
->SetDropdownClickHdl (rCallback
);
292 // The tool box has likely changed its size. The title bar has to be
303 IMPL_LINK(PaneDockingWindow
, ToolboxSelectHandler
, ToolBox
*, pToolBox
)
305 USHORT nId
= pToolBox
->GetCurItemId();
310 SfxBoolItem
aVisibility (mnChildWindowId
, FALSE
);
311 GetBindings().GetDispatcher()->Execute (
313 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
324 long PaneDockingWindow::Notify( NotifyEvent
& rNEvt
)
326 return SfxDockingWindow::Notify (rNEvt
);
332 void PaneDockingWindow::StateChanged( StateChangedType nType
)
336 case STATE_CHANGE_INITSHOW
:
340 case STATE_CHANGE_VISIBLE
:
341 // The visibility of the docking window has changed. Tell the
342 // ConfigurationController so that it can activate or deactivate
343 // a/the view for the pane.
344 // Without this the side panes remain empty after closing an
345 // in-place slide show.
346 ViewShellBase
* pBase
= ViewShellBase::GetViewShellBase(
347 GetBindings().GetDispatcher()->GetFrame());
350 framework::FrameworkHelper::Instance(*pBase
)->UpdateConfiguration();
354 SfxDockingWindow::StateChanged (nType
);
360 void PaneDockingWindow::DataChanged (const DataChangedEvent
& rEvent
)
362 SfxDockingWindow::DataChanged (rEvent
);
364 switch (rEvent
.GetType())
366 case DATACHANGED_SETTINGS
:
367 if ((rEvent
.GetFlags() & SETTINGS_STYLE
) == 0)
369 // else fall through.
370 case DATACHANGED_FONTS
:
371 case DATACHANGED_FONTSUBSTITUTION
:
373 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
376 Font aFont
= rStyleSettings
.GetAppFont();
378 aFont
.Merge(GetControlFont());
379 SetZoomedPointFont(aFont
);
383 if (IsControlForeground())
384 aColor
= GetControlForeground();
386 aColor
= rStyleSettings
.GetButtonTextColor();
387 SetTextColor(aColor
);
400 ::Window
* PaneDockingWindow::GetContentWindow (void)
402 return mpContentWindow
.get();
408 ::boost::shared_ptr
<ToolBox
> PaneDockingWindow::GetTitleToolBox (void) const
410 return mpTitleToolBox
;
414 } // end of namespace ::sd