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