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> 2965908a7eSAndre 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. 7365908a7eSAndre 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); 8265908a7eSAndre Fischer const Rectangle aTitleBox (GetTitleArea(aTitleBarBox)); 8365908a7eSAndre Fischer PaintTitle(aTitleBox); 8465908a7eSAndre Fischer if (HasFocus()) 8565908a7eSAndre Fischer PaintFocus(aTitleBox); 86ff12d537SAndre Fischer } 87ff12d537SAndre Fischer 88ff12d537SAndre Fischer 89ff12d537SAndre Fischer 90b9e67834SAndre Fischer 917a32b0c8SAndre Fischer void TitleBar::DataChanged (const DataChangedEvent& rEvent) 927a32b0c8SAndre Fischer { 937a32b0c8SAndre Fischer (void)rEvent; 947a32b0c8SAndre Fischer 957a32b0c8SAndre Fischer SetBackground(GetBackgroundPaint().GetWallpaper()); 967a32b0c8SAndre 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) 107ff12d537SAndre 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 11965908a7eSAndre Fischer ToolBox& TitleBar::GetToolBox (void) 12065908a7eSAndre Fischer { 12165908a7eSAndre Fischer return maToolBox; 12265908a7eSAndre Fischer } 12365908a7eSAndre Fischer 12465908a7eSAndre Fischer 12565908a7eSAndre Fischer 12665908a7eSAndre 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()); 141*ba606a71SAndre Fischer aFont.SetWeight(WEIGHT_BOLD); 14222de8995SAndre Fischer SetFont(aFont); 14322de8995SAndre Fischer 14422de8995SAndre Fischer // Paint title bar text. 145ff12d537SAndre Fischer SetTextColor(GetTextColor()); 14622de8995SAndre Fischer DrawText( 147ff12d537SAndre Fischer rTitleBox, 14822de8995SAndre Fischer msTitle, 14922de8995SAndre Fischer TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER); 15065908a7eSAndre Fischer 15165908a7eSAndre Fischer Pop(); 15265908a7eSAndre Fischer } 15365908a7eSAndre Fischer 15465908a7eSAndre Fischer 15565908a7eSAndre Fischer 15665908a7eSAndre Fischer 15765908a7eSAndre Fischer void TitleBar::PaintFocus (const Rectangle& rFocusBox) 15865908a7eSAndre Fischer { 15965908a7eSAndre Fischer Push(PUSH_FONT | PUSH_TEXTCOLOR | PUSH_LINECOLOR | PUSH_FILLCOLOR); 16065908a7eSAndre Fischer 16165908a7eSAndre Fischer const Rectangle aTextBox ( 16265908a7eSAndre Fischer GetTextRect( 16365908a7eSAndre Fischer rFocusBox, 16465908a7eSAndre Fischer msTitle, 16565908a7eSAndre Fischer TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER)); 16665908a7eSAndre Fischer const Rectangle aLargerTextBox ( 16765908a7eSAndre Fischer aTextBox.Left() - 2, 16865908a7eSAndre Fischer aTextBox.Top() - 2, 16965908a7eSAndre Fischer aTextBox.Right() + 2, 17065908a7eSAndre Fischer aTextBox.Bottom() + 2); 17165908a7eSAndre Fischer 17265908a7eSAndre Fischer LineInfo aDottedStyle (LINE_DASH); 17365908a7eSAndre Fischer aDottedStyle.SetDashCount(0); 17465908a7eSAndre Fischer aDottedStyle.SetDotCount(1); 17565908a7eSAndre Fischer aDottedStyle.SetDotLen(1); 17665908a7eSAndre Fischer aDottedStyle.SetDistance(1); 177ff12d537SAndre Fischer 17865908a7eSAndre Fischer SetFillColor(); 17965908a7eSAndre Fischer SetLineColor(COL_BLACK); 18065908a7eSAndre Fischer DrawPolyLine(Polygon(aLargerTextBox), aDottedStyle); 18165908a7eSAndre Fischer 18222de8995SAndre Fischer Pop(); 18322de8995SAndre Fischer } 18422de8995SAndre Fischer 18522de8995SAndre Fischer 1867a32b0c8SAndre Fischer 1877a32b0c8SAndre Fischer 1887a32b0c8SAndre Fischer IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox) 1897a32b0c8SAndre Fischer { 1907a32b0c8SAndre Fischer (void)pToolBox; 1917a32b0c8SAndre Fischer OSL_ASSERT(&maToolBox==pToolBox); 1927a32b0c8SAndre Fischer const sal_uInt16 nItemId (maToolBox.GetHighlightItemId()); 1937a32b0c8SAndre Fischer 1947a32b0c8SAndre Fischer HandleToolBoxItemClick(nItemId); 1957a32b0c8SAndre Fischer 1967a32b0c8SAndre Fischer return sal_True; 1977a32b0c8SAndre Fischer } 1987a32b0c8SAndre Fischer 199ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 200