xref: /aoo42x/main/sfx2/source/sidebar/TitleBar.cxx (revision 54eaaa32)
122de8995SAndre Fischer /**************************************************************
222de8995SAndre Fischer  *
322de8995SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
422de8995SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
522de8995SAndre Fischer  * distributed with this work for additional information
622de8995SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
722de8995SAndre Fischer  * to you under the Apache License, Version 2.0 (the
822de8995SAndre Fischer  * "License"); you may not use this file except in compliance
922de8995SAndre Fischer  * with the License.  You may obtain a copy of the License at
1022de8995SAndre Fischer  *
1122de8995SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
1222de8995SAndre Fischer  *
1322de8995SAndre Fischer  * Unless required by applicable law or agreed to in writing,
1422de8995SAndre Fischer  * software distributed under the License is distributed on an
1522de8995SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1622de8995SAndre Fischer  * KIND, either express or implied.  See the License for the
1722de8995SAndre Fischer  * specific language governing permissions and limitations
1822de8995SAndre Fischer  * under the License.
1922de8995SAndre Fischer  *
2022de8995SAndre Fischer  *************************************************************/
2122de8995SAndre Fischer 
2222de8995SAndre Fischer #include "precompiled_sfx2.hxx"
2322de8995SAndre Fischer 
2422de8995SAndre Fischer #include "TitleBar.hxx"
25ff12d537SAndre Fischer #include "Paint.hxx"
2622de8995SAndre Fischer 
2722de8995SAndre Fischer #include <tools/svborder.hxx>
2822de8995SAndre Fischer #include <vcl/gradient.hxx>
2922de8995SAndre Fischer 
30ff12d537SAndre Fischer ToolbarValue::~ToolbarValue (void) {}
3122de8995SAndre Fischer 
32ff12d537SAndre Fischer 
33ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
3422de8995SAndre Fischer 
3522de8995SAndre Fischer TitleBar::TitleBar (
3622de8995SAndre Fischer     const ::rtl::OUString& rsTitle,
377a32b0c8SAndre Fischer     Window* pParentWindow,
387a32b0c8SAndre Fischer     const sidebar::Paint& rInitialBackgroundPaint)
3922de8995SAndre Fischer     : Window(pParentWindow),
407a32b0c8SAndre Fischer       maToolBox(this),
41ff12d537SAndre Fischer       msTitle(rsTitle)
4222de8995SAndre Fischer {
437a32b0c8SAndre Fischer     SetBackground(rInitialBackgroundPaint.GetWallpaper());
447a32b0c8SAndre Fischer 
457a32b0c8SAndre Fischer     maToolBox.SetSelectHdl(LINK(this, TitleBar, SelectionHandler));
4622de8995SAndre Fischer }
4722de8995SAndre Fischer 
4822de8995SAndre Fischer 
4922de8995SAndre Fischer 
5022de8995SAndre Fischer 
5122de8995SAndre Fischer TitleBar::~TitleBar (void)
5222de8995SAndre Fischer {
5322de8995SAndre Fischer }
5422de8995SAndre Fischer 
5522de8995SAndre Fischer 
5622de8995SAndre Fischer 
5722de8995SAndre Fischer 
58*54eaaa32SAndre Fischer void TitleBar::SetTitle (const ::rtl::OUString& rsTitle)
59*54eaaa32SAndre Fischer {
60*54eaaa32SAndre Fischer     msTitle = rsTitle;
61*54eaaa32SAndre Fischer     Invalidate();
62*54eaaa32SAndre Fischer }
63*54eaaa32SAndre Fischer 
64*54eaaa32SAndre Fischer 
65*54eaaa32SAndre Fischer 
66*54eaaa32SAndre Fischer 
6722de8995SAndre Fischer void TitleBar::Paint (const Rectangle& rUpdateArea)
6822de8995SAndre Fischer {
6995a18594SAndre Fischer     (void)rUpdateArea;
7095a18594SAndre Fischer 
7122de8995SAndre Fischer     // Paint title bar background.
7222de8995SAndre Fischer     Size aWindowSize( GetOutputSizePixel() );
73ff12d537SAndre Fischer     Rectangle aTitleBarBox(
74ff12d537SAndre Fischer         0,
75ff12d537SAndre Fischer         0,
76ff12d537SAndre Fischer         aWindowSize.Width(),
77ff12d537SAndre Fischer         aWindowSize.Height()
78ff12d537SAndre Fischer         );
79ff12d537SAndre Fischer 
80ff12d537SAndre Fischer     PaintDecoration(aTitleBarBox);
81ff12d537SAndre Fischer     PaintTitle(GetTitleArea(aTitleBarBox));
82ff12d537SAndre Fischer }
83ff12d537SAndre Fischer 
84ff12d537SAndre Fischer 
85ff12d537SAndre Fischer 
86b9e67834SAndre Fischer 
877a32b0c8SAndre Fischer void TitleBar::DataChanged (const DataChangedEvent& rEvent)
887a32b0c8SAndre Fischer {
897a32b0c8SAndre Fischer     (void)rEvent;
907a32b0c8SAndre Fischer 
917a32b0c8SAndre Fischer     SetBackground(GetBackgroundPaint().GetWallpaper());
927a32b0c8SAndre Fischer }
937a32b0c8SAndre Fischer 
947a32b0c8SAndre Fischer 
957a32b0c8SAndre Fischer 
967a32b0c8SAndre Fischer 
977a32b0c8SAndre Fischer void TitleBar::SetPosSizePixel (
987a32b0c8SAndre Fischer     long nX,
997a32b0c8SAndre Fischer     long nY,
1007a32b0c8SAndre Fischer     long nWidth,
1017a32b0c8SAndre Fischer     long nHeight,
1027a32b0c8SAndre Fischer     sal_uInt16 nFlags)
103ff12d537SAndre Fischer {
1047a32b0c8SAndre Fischer     Window::SetPosSizePixel(nX,nY,nWidth,nHeight,nFlags);
1057a32b0c8SAndre Fischer 
1067a32b0c8SAndre Fischer     // Place the toolbox.
1077a32b0c8SAndre Fischer     const sal_Int32 nToolBoxWidth (maToolBox.GetItemPosRect(0).GetWidth());
1087a32b0c8SAndre Fischer     maToolBox.SetPosSizePixel(nWidth-nToolBoxWidth,0,nToolBoxWidth,nHeight);
1097a32b0c8SAndre Fischer     maToolBox.Show();
1107a32b0c8SAndre Fischer }
1117a32b0c8SAndre Fischer 
1127a32b0c8SAndre Fischer 
1137a32b0c8SAndre Fischer 
1147a32b0c8SAndre Fischer 
1157a32b0c8SAndre Fischer void TitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
1167a32b0c8SAndre Fischer {
1177a32b0c8SAndre Fischer     (void)nItemIndex;
1187a32b0c8SAndre Fischer     // Any real processing has to be done in derived class.
119ff12d537SAndre Fischer }
120ff12d537SAndre Fischer 
121ff12d537SAndre Fischer 
122ff12d537SAndre Fischer 
123ff12d537SAndre Fischer 
124ff12d537SAndre Fischer void TitleBar::PaintTitle (const Rectangle& rTitleBox)
125ff12d537SAndre Fischer {
126ff12d537SAndre Fischer     Push(PUSH_FONT | PUSH_TEXTCOLOR);
12722de8995SAndre Fischer 
12822de8995SAndre Fischer     // Use a bold font for the deck title.
12922de8995SAndre Fischer     Font aFont(GetFont());
13022de8995SAndre Fischer     aFont.SetWeight(WEIGHT_BOLD);
13122de8995SAndre Fischer     SetFont(aFont);
13222de8995SAndre Fischer 
13322de8995SAndre Fischer     // Paint title bar text.
134ff12d537SAndre Fischer     SetTextColor(GetTextColor());
13522de8995SAndre Fischer     DrawText(
136ff12d537SAndre Fischer         rTitleBox,
13722de8995SAndre Fischer         msTitle,
13822de8995SAndre Fischer         TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER);
139ff12d537SAndre Fischer 
14022de8995SAndre Fischer     Pop();
14122de8995SAndre Fischer }
14222de8995SAndre Fischer 
14322de8995SAndre Fischer 
1447a32b0c8SAndre Fischer 
1457a32b0c8SAndre Fischer 
1467a32b0c8SAndre Fischer IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox)
1477a32b0c8SAndre Fischer {
1487a32b0c8SAndre Fischer     (void)pToolBox;
1497a32b0c8SAndre Fischer     OSL_ASSERT(&maToolBox==pToolBox);
1507a32b0c8SAndre Fischer     const sal_uInt16 nItemId (maToolBox.GetHighlightItemId());
1517a32b0c8SAndre Fischer 
1527a32b0c8SAndre Fischer     HandleToolBoxItemClick(nItemId);
1537a32b0c8SAndre Fischer 
1547a32b0c8SAndre Fischer     return sal_True;
1557a32b0c8SAndre Fischer }
1567a32b0c8SAndre Fischer 
157ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
158