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> 29*65908a7eSAndre Fischer #include <vcl/lineinfo.hxx> 3022de8995SAndre Fischer 31ff12d537SAndre Fischer ToolbarValue::~ToolbarValue (void) {} 3222de8995SAndre Fischer 33ff12d537SAndre Fischer 34ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 3522de8995SAndre Fischer 3622de8995SAndre Fischer TitleBar::TitleBar ( 3722de8995SAndre Fischer const ::rtl::OUString& rsTitle, 387a32b0c8SAndre Fischer Window* pParentWindow, 397a32b0c8SAndre Fischer const sidebar::Paint& rInitialBackgroundPaint) 4022de8995SAndre Fischer : Window(pParentWindow), 417a32b0c8SAndre Fischer maToolBox(this), 42ff12d537SAndre Fischer msTitle(rsTitle) 4322de8995SAndre Fischer { 447a32b0c8SAndre Fischer SetBackground(rInitialBackgroundPaint.GetWallpaper()); 457a32b0c8SAndre Fischer 467a32b0c8SAndre Fischer maToolBox.SetSelectHdl(LINK(this, TitleBar, SelectionHandler)); 4722de8995SAndre Fischer } 4822de8995SAndre Fischer 4922de8995SAndre Fischer 5022de8995SAndre Fischer 5122de8995SAndre Fischer 5222de8995SAndre Fischer TitleBar::~TitleBar (void) 5322de8995SAndre Fischer { 5422de8995SAndre Fischer } 5522de8995SAndre Fischer 5622de8995SAndre Fischer 5722de8995SAndre Fischer 5822de8995SAndre Fischer 5954eaaa32SAndre Fischer void TitleBar::SetTitle (const ::rtl::OUString& rsTitle) 6054eaaa32SAndre Fischer { 6154eaaa32SAndre Fischer msTitle = rsTitle; 6254eaaa32SAndre Fischer Invalidate(); 6354eaaa32SAndre Fischer } 6454eaaa32SAndre Fischer 6554eaaa32SAndre Fischer 6654eaaa32SAndre Fischer 6754eaaa32SAndre Fischer 6822de8995SAndre Fischer void TitleBar::Paint (const Rectangle& rUpdateArea) 6922de8995SAndre Fischer { 7095a18594SAndre Fischer (void)rUpdateArea; 7195a18594SAndre Fischer 7222de8995SAndre Fischer // Paint title bar background. 7322de8995SAndre Fischer Size aWindowSize (GetOutputSizePixel()); 74ff12d537SAndre Fischer Rectangle aTitleBarBox( 75ff12d537SAndre Fischer 0, 76ff12d537SAndre Fischer 0, 77ff12d537SAndre Fischer aWindowSize.Width(), 78ff12d537SAndre Fischer aWindowSize.Height() 79ff12d537SAndre Fischer ); 80ff12d537SAndre Fischer 81ff12d537SAndre Fischer PaintDecoration(aTitleBarBox); 82*65908a7eSAndre Fischer const Rectangle aTitleBox (GetTitleArea(aTitleBarBox)); 83*65908a7eSAndre Fischer PaintTitle(aTitleBox); 84*65908a7eSAndre Fischer if (HasFocus()) 85*65908a7eSAndre Fischer PaintFocus(aTitleBox); 86ff12d537SAndre Fischer } 87ff12d537SAndre Fischer 88ff12d537SAndre Fischer 89ff12d537SAndre Fischer 90b9e67834SAndre Fischer 917a32b0c8SAndre Fischer void TitleBar::DataChanged (const DataChangedEvent& rEvent) 92ff12d537SAndre Fischer { 937a32b0c8SAndre Fischer (void)rEvent; 94ff12d537SAndre Fischer 957a32b0c8SAndre Fischer SetBackground(GetBackgroundPaint().GetWallpaper()); 96ff12d537SAndre Fischer } 977a32b0c8SAndre Fischer 987a32b0c8SAndre Fischer 997a32b0c8SAndre Fischer 1007a32b0c8SAndre Fischer 1017a32b0c8SAndre Fischer void TitleBar::SetPosSizePixel ( 1027a32b0c8SAndre Fischer long nX, 1037a32b0c8SAndre Fischer long nY, 1047a32b0c8SAndre Fischer long nWidth, 1057a32b0c8SAndre Fischer long nHeight, 1067a32b0c8SAndre Fischer sal_uInt16 nFlags) 1077a32b0c8SAndre Fischer { 1087a32b0c8SAndre Fischer Window::SetPosSizePixel(nX,nY,nWidth,nHeight,nFlags); 1097a32b0c8SAndre Fischer 1107a32b0c8SAndre Fischer // Place the toolbox. 1117a32b0c8SAndre Fischer const sal_Int32 nToolBoxWidth (maToolBox.GetItemPosRect(0).GetWidth()); 1127a32b0c8SAndre Fischer maToolBox.SetPosSizePixel(nWidth-nToolBoxWidth,0,nToolBoxWidth,nHeight); 1137a32b0c8SAndre Fischer maToolBox.Show(); 1147a32b0c8SAndre Fischer } 1157a32b0c8SAndre Fischer 1167a32b0c8SAndre Fischer 1177a32b0c8SAndre Fischer 1187a32b0c8SAndre Fischer 119*65908a7eSAndre Fischer ToolBox& TitleBar::GetToolBox (void) 120*65908a7eSAndre Fischer { 121*65908a7eSAndre Fischer return maToolBox; 122*65908a7eSAndre Fischer } 123*65908a7eSAndre Fischer 124*65908a7eSAndre Fischer 125*65908a7eSAndre Fischer 126*65908a7eSAndre Fischer 1277a32b0c8SAndre Fischer void TitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) 1287a32b0c8SAndre Fischer { 1297a32b0c8SAndre Fischer (void)nItemIndex; 1307a32b0c8SAndre Fischer // Any real processing has to be done in derived class. 131ff12d537SAndre Fischer } 132ff12d537SAndre Fischer 133ff12d537SAndre Fischer 134ff12d537SAndre Fischer 135ff12d537SAndre Fischer 136ff12d537SAndre Fischer void TitleBar::PaintTitle (const Rectangle& rTitleBox) 137ff12d537SAndre Fischer { 138ff12d537SAndre Fischer Push(PUSH_FONT | PUSH_TEXTCOLOR); 13922de8995SAndre Fischer 14022de8995SAndre Fischer Font aFont(GetFont()); 14122de8995SAndre Fischer SetFont(aFont); 14222de8995SAndre Fischer 14322de8995SAndre Fischer // Paint title bar text. 144ff12d537SAndre Fischer SetTextColor(GetTextColor()); 14522de8995SAndre Fischer DrawText( 146ff12d537SAndre Fischer rTitleBox, 14722de8995SAndre Fischer msTitle, 14822de8995SAndre Fischer TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER); 14922de8995SAndre Fischer 15022de8995SAndre Fischer Pop(); 15122de8995SAndre Fischer } 15222de8995SAndre Fischer 15322de8995SAndre Fischer 1547a32b0c8SAndre Fischer 1557a32b0c8SAndre Fischer 156*65908a7eSAndre Fischer void TitleBar::PaintFocus (const Rectangle& rFocusBox) 157*65908a7eSAndre Fischer { 158*65908a7eSAndre Fischer Push(PUSH_FONT | PUSH_TEXTCOLOR | PUSH_LINECOLOR | PUSH_FILLCOLOR); 159*65908a7eSAndre Fischer 160*65908a7eSAndre Fischer const Rectangle aTextBox ( 161*65908a7eSAndre Fischer GetTextRect( 162*65908a7eSAndre Fischer rFocusBox, 163*65908a7eSAndre Fischer msTitle, 164*65908a7eSAndre Fischer TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER)); 165*65908a7eSAndre Fischer const Rectangle aLargerTextBox ( 166*65908a7eSAndre Fischer aTextBox.Left() - 2, 167*65908a7eSAndre Fischer aTextBox.Top() - 2, 168*65908a7eSAndre Fischer aTextBox.Right() + 2, 169*65908a7eSAndre Fischer aTextBox.Bottom() + 2); 170*65908a7eSAndre Fischer 171*65908a7eSAndre Fischer LineInfo aDottedStyle (LINE_DASH); 172*65908a7eSAndre Fischer aDottedStyle.SetDashCount(0); 173*65908a7eSAndre Fischer aDottedStyle.SetDotCount(1); 174*65908a7eSAndre Fischer aDottedStyle.SetDotLen(1); 175*65908a7eSAndre Fischer aDottedStyle.SetDistance(1); 176*65908a7eSAndre Fischer 177*65908a7eSAndre Fischer SetFillColor(); 178*65908a7eSAndre Fischer SetLineColor(COL_BLACK); 179*65908a7eSAndre Fischer DrawPolyLine(Polygon(aLargerTextBox), aDottedStyle); 180*65908a7eSAndre Fischer 181*65908a7eSAndre Fischer Pop(); 182*65908a7eSAndre Fischer } 183*65908a7eSAndre Fischer 184*65908a7eSAndre Fischer 185*65908a7eSAndre Fischer 186*65908a7eSAndre Fischer 1877a32b0c8SAndre Fischer IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox) 1887a32b0c8SAndre Fischer { 1897a32b0c8SAndre Fischer (void)pToolBox; 1907a32b0c8SAndre Fischer OSL_ASSERT(&maToolBox==pToolBox); 1917a32b0c8SAndre Fischer const sal_uInt16 nItemId (maToolBox.GetHighlightItemId()); 1927a32b0c8SAndre Fischer 1937a32b0c8SAndre Fischer HandleToolBoxItemClick(nItemId); 1947a32b0c8SAndre Fischer 1957a32b0c8SAndre Fischer return sal_True; 1967a32b0c8SAndre Fischer } 1977a32b0c8SAndre Fischer 198ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 199