1*ff12d537SAndre Fischer /************************************************************** 2*ff12d537SAndre Fischer * 3*ff12d537SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*ff12d537SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*ff12d537SAndre Fischer * distributed with this work for additional information 6*ff12d537SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*ff12d537SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*ff12d537SAndre Fischer * "License"); you may not use this file except in compliance 9*ff12d537SAndre Fischer * with the License. You may obtain a copy of the License at 10*ff12d537SAndre Fischer * 11*ff12d537SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*ff12d537SAndre Fischer * 13*ff12d537SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*ff12d537SAndre Fischer * software distributed under the License is distributed on an 15*ff12d537SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ff12d537SAndre Fischer * KIND, either express or implied. See the License for the 17*ff12d537SAndre Fischer * specific language governing permissions and limitations 18*ff12d537SAndre Fischer * under the License. 19*ff12d537SAndre Fischer * 20*ff12d537SAndre Fischer *************************************************************/ 21*ff12d537SAndre Fischer 22*ff12d537SAndre Fischer #include "precompiled_sfx2.hxx" 23*ff12d537SAndre Fischer 24*ff12d537SAndre Fischer #include "PanelTitleBar.hxx" 25*ff12d537SAndre Fischer 26*ff12d537SAndre Fischer #include "Paint.hxx" 27*ff12d537SAndre Fischer #include "Panel.hxx" 28*ff12d537SAndre Fischer #include "Theme.hxx" 29*ff12d537SAndre Fischer 30*ff12d537SAndre Fischer #include <tools/svborder.hxx> 31*ff12d537SAndre Fischer #include <vcl/gradient.hxx> 32*ff12d537SAndre Fischer 33*ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 34*ff12d537SAndre Fischer 35*ff12d537SAndre Fischer 36*ff12d537SAndre Fischer static const sal_Int32 gaLeftIconPadding (5); 37*ff12d537SAndre Fischer static const sal_Int32 gaRightIconPadding (5); 38*ff12d537SAndre Fischer 39*ff12d537SAndre Fischer 40*ff12d537SAndre Fischer PanelTitleBar::PanelTitleBar ( 41*ff12d537SAndre Fischer const ::rtl::OUString& rsTitle, 42*ff12d537SAndre Fischer Window* pParentWindow, 43*ff12d537SAndre Fischer Panel* pPanel) 44*ff12d537SAndre Fischer : TitleBar(rsTitle, pParentWindow), 45*ff12d537SAndre Fischer mbIsLeftButtonDown(false), 46*ff12d537SAndre Fischer mpPanel(pPanel) 47*ff12d537SAndre Fischer { 48*ff12d537SAndre Fischer OSL_ASSERT(mpPanel != NULL); 49*ff12d537SAndre Fischer } 50*ff12d537SAndre Fischer 51*ff12d537SAndre Fischer 52*ff12d537SAndre Fischer 53*ff12d537SAndre Fischer 54*ff12d537SAndre Fischer PanelTitleBar::~PanelTitleBar (void) 55*ff12d537SAndre Fischer { 56*ff12d537SAndre Fischer } 57*ff12d537SAndre Fischer 58*ff12d537SAndre Fischer 59*ff12d537SAndre Fischer 60*ff12d537SAndre Fischer 61*ff12d537SAndre Fischer Rectangle PanelTitleBar::GetTitleArea (const Rectangle& rTitleBarBox) 62*ff12d537SAndre Fischer { 63*ff12d537SAndre Fischer if (mpPanel != NULL) 64*ff12d537SAndre Fischer { 65*ff12d537SAndre Fischer Image aImage (mpPanel->IsExpanded() 66*ff12d537SAndre Fischer ? Theme::GetExpandImage() 67*ff12d537SAndre Fischer : Theme::GetCollapseImage()); 68*ff12d537SAndre Fischer return Rectangle( 69*ff12d537SAndre Fischer aImage.GetSizePixel().Width() + gaLeftIconPadding + gaRightIconPadding, 70*ff12d537SAndre Fischer rTitleBarBox.Top(), 71*ff12d537SAndre Fischer rTitleBarBox.Right(), 72*ff12d537SAndre Fischer rTitleBarBox.Bottom()); 73*ff12d537SAndre Fischer } 74*ff12d537SAndre Fischer else 75*ff12d537SAndre Fischer return rTitleBarBox; 76*ff12d537SAndre Fischer } 77*ff12d537SAndre Fischer 78*ff12d537SAndre Fischer 79*ff12d537SAndre Fischer 80*ff12d537SAndre Fischer 81*ff12d537SAndre Fischer void PanelTitleBar::PaintDecoration (const Rectangle& rTitleBarBox) 82*ff12d537SAndre Fischer { 83*ff12d537SAndre Fischer if (mpPanel != NULL) 84*ff12d537SAndre Fischer { 85*ff12d537SAndre Fischer Image aImage (mpPanel->IsExpanded() 86*ff12d537SAndre Fischer ? Theme::GetExpandImage() 87*ff12d537SAndre Fischer : Theme::GetCollapseImage()); 88*ff12d537SAndre Fischer const Point aTopLeft ( 89*ff12d537SAndre Fischer gaLeftIconPadding, 90*ff12d537SAndre Fischer (GetSizePixel().Height()-aImage.GetSizePixel().Height())/2); 91*ff12d537SAndre Fischer DrawImage(aTopLeft, aImage); 92*ff12d537SAndre Fischer } 93*ff12d537SAndre Fischer } 94*ff12d537SAndre Fischer 95*ff12d537SAndre Fischer 96*ff12d537SAndre Fischer 97*ff12d537SAndre Fischer 98*ff12d537SAndre Fischer Paint PanelTitleBar::GetBackgroundPaint (void) 99*ff12d537SAndre Fischer { 100*ff12d537SAndre Fischer return Theme::GetPanelTitleBackground(); 101*ff12d537SAndre Fischer } 102*ff12d537SAndre Fischer 103*ff12d537SAndre Fischer 104*ff12d537SAndre Fischer 105*ff12d537SAndre Fischer 106*ff12d537SAndre Fischer Color PanelTitleBar::GetTextColor (void) 107*ff12d537SAndre Fischer { 108*ff12d537SAndre Fischer return Theme::GetPanelTitleFontColor(); 109*ff12d537SAndre Fischer } 110*ff12d537SAndre Fischer 111*ff12d537SAndre Fischer 112*ff12d537SAndre Fischer 113*ff12d537SAndre Fischer 114*ff12d537SAndre Fischer void PanelTitleBar::MouseButtonDown (const MouseEvent& rMouseEvent) 115*ff12d537SAndre Fischer { 116*ff12d537SAndre Fischer if (rMouseEvent.IsLeft()) 117*ff12d537SAndre Fischer { 118*ff12d537SAndre Fischer mbIsLeftButtonDown = true; 119*ff12d537SAndre Fischer CaptureMouse(); 120*ff12d537SAndre Fischer } 121*ff12d537SAndre Fischer } 122*ff12d537SAndre Fischer 123*ff12d537SAndre Fischer 124*ff12d537SAndre Fischer 125*ff12d537SAndre Fischer 126*ff12d537SAndre Fischer void PanelTitleBar::MouseButtonUp (const MouseEvent& rMouseEvent) 127*ff12d537SAndre Fischer { 128*ff12d537SAndre Fischer if (IsMouseCaptured()) 129*ff12d537SAndre Fischer ReleaseMouse(); 130*ff12d537SAndre Fischer 131*ff12d537SAndre Fischer if (rMouseEvent.IsLeft()) 132*ff12d537SAndre Fischer { 133*ff12d537SAndre Fischer if (mbIsLeftButtonDown) 134*ff12d537SAndre Fischer { 135*ff12d537SAndre Fischer if (mpPanel != NULL) 136*ff12d537SAndre Fischer { 137*ff12d537SAndre Fischer mpPanel->SetExpanded( ! mpPanel->IsExpanded()); 138*ff12d537SAndre Fischer Invalidate(); 139*ff12d537SAndre Fischer } 140*ff12d537SAndre Fischer } 141*ff12d537SAndre Fischer } 142*ff12d537SAndre Fischer if (mbIsLeftButtonDown) 143*ff12d537SAndre Fischer mbIsLeftButtonDown = false; 144*ff12d537SAndre Fischer } 145*ff12d537SAndre Fischer 146*ff12d537SAndre Fischer 147*ff12d537SAndre Fischer 148*ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 149