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 "TabItem.hxx" 25*ff12d537SAndre Fischer 26*ff12d537SAndre Fischer #include "DrawHelper.hxx" 27*ff12d537SAndre Fischer #include "Paint.hxx" 28*ff12d537SAndre Fischer #include "Theme.hxx" 29*ff12d537SAndre Fischer 30*ff12d537SAndre Fischer using namespace ::com::sun::star; 31*ff12d537SAndre Fischer using namespace ::com::sun::star::uno; 32*ff12d537SAndre Fischer 33*ff12d537SAndre Fischer 34*ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 35*ff12d537SAndre Fischer 36*ff12d537SAndre Fischer 37*ff12d537SAndre Fischer TabItem::TabItem (Window* pParentWindow) 38*ff12d537SAndre Fischer : ImageRadioButton(pParentWindow), 39*ff12d537SAndre Fischer mbIsLeftButtonDown(false), 40*ff12d537SAndre Fischer mePaintType(PT_Theme) 41*ff12d537SAndre Fischer { 42*ff12d537SAndre Fischer SetBackground(Theme::GetTabBarBackground().GetWallpaper()); 43*ff12d537SAndre Fischer } 44*ff12d537SAndre Fischer 45*ff12d537SAndre Fischer 46*ff12d537SAndre Fischer 47*ff12d537SAndre Fischer 48*ff12d537SAndre Fischer TabItem::~TabItem (void) 49*ff12d537SAndre Fischer { 50*ff12d537SAndre Fischer } 51*ff12d537SAndre Fischer 52*ff12d537SAndre Fischer 53*ff12d537SAndre Fischer 54*ff12d537SAndre Fischer 55*ff12d537SAndre Fischer void TabItem::Paint (const Rectangle& rUpdateArea) 56*ff12d537SAndre Fischer { 57*ff12d537SAndre Fischer switch(mePaintType) 58*ff12d537SAndre Fischer { 59*ff12d537SAndre Fischer case PT_Theme: 60*ff12d537SAndre Fischer default: 61*ff12d537SAndre Fischer { 62*ff12d537SAndre Fischer const bool bIsSelected (IsChecked()); 63*ff12d537SAndre Fischer const bool bIsMouseOver (IsMouseOver()); 64*ff12d537SAndre Fischer DrawHelper::DrawRoundedRectangle( 65*ff12d537SAndre Fischer *this, 66*ff12d537SAndre Fischer Rectangle(Point(0,0), GetSizePixel()), 67*ff12d537SAndre Fischer 2, 68*ff12d537SAndre Fischer bIsMouseOver||bIsSelected ? Theme::GetTabItemBorderColor() : Color(0xffffffff), 69*ff12d537SAndre Fischer bIsMouseOver ? Theme::GetTabItemBackgroundPaint() : sidebar::Paint()); 70*ff12d537SAndre Fischer 71*ff12d537SAndre Fischer const Image aIcon (Button::GetModeImage(Theme::IsHighContrastMode() 72*ff12d537SAndre Fischer ? BMP_COLOR_HIGHCONTRAST 73*ff12d537SAndre Fischer : BMP_COLOR_NORMAL)); 74*ff12d537SAndre Fischer const Size aIconSize (aIcon.GetSizePixel()); 75*ff12d537SAndre Fischer const Point aIconLocation( 76*ff12d537SAndre Fischer (GetSizePixel().Width() - aIconSize.Width())/2, 77*ff12d537SAndre Fischer (GetSizePixel().Height() - aIconSize.Height())/2); 78*ff12d537SAndre Fischer DrawImage( 79*ff12d537SAndre Fischer aIconLocation, 80*ff12d537SAndre Fischer aIcon); 81*ff12d537SAndre Fischer break; 82*ff12d537SAndre Fischer } 83*ff12d537SAndre Fischer case PT_Native: 84*ff12d537SAndre Fischer Button::Paint(rUpdateArea); 85*ff12d537SAndre Fischer // DrawImage(maIconPosition, maIcon); 86*ff12d537SAndre Fischer break; 87*ff12d537SAndre Fischer } 88*ff12d537SAndre Fischer } 89*ff12d537SAndre Fischer 90*ff12d537SAndre Fischer 91*ff12d537SAndre Fischer 92*ff12d537SAndre Fischer 93*ff12d537SAndre Fischer void TabItem::MouseMove (const MouseEvent& rEvent) 94*ff12d537SAndre Fischer { 95*ff12d537SAndre Fischer if (rEvent.IsEnterWindow() || rEvent.IsLeaveWindow()) 96*ff12d537SAndre Fischer Invalidate(); 97*ff12d537SAndre Fischer ImageRadioButton::MouseMove(rEvent); 98*ff12d537SAndre Fischer } 99*ff12d537SAndre Fischer 100*ff12d537SAndre Fischer 101*ff12d537SAndre Fischer 102*ff12d537SAndre Fischer 103*ff12d537SAndre Fischer void TabItem::MouseButtonDown (const MouseEvent& rMouseEvent) 104*ff12d537SAndre Fischer { 105*ff12d537SAndre Fischer #if 0 106*ff12d537SAndre Fischer Hide(); 107*ff12d537SAndre Fischer ImageRadioButton::MouseButtonDown(rMouseEvent); 108*ff12d537SAndre Fischer Show(); 109*ff12d537SAndre Fischer #else 110*ff12d537SAndre Fischer if (rMouseEvent.IsLeft()) 111*ff12d537SAndre Fischer { 112*ff12d537SAndre Fischer mbIsLeftButtonDown = true; 113*ff12d537SAndre Fischer CaptureMouse(); 114*ff12d537SAndre Fischer Invalidate(); 115*ff12d537SAndre Fischer } 116*ff12d537SAndre Fischer #endif 117*ff12d537SAndre Fischer } 118*ff12d537SAndre Fischer 119*ff12d537SAndre Fischer 120*ff12d537SAndre Fischer 121*ff12d537SAndre Fischer 122*ff12d537SAndre Fischer void TabItem::MouseButtonUp (const MouseEvent& rMouseEvent) 123*ff12d537SAndre Fischer { 124*ff12d537SAndre Fischer #if 0 125*ff12d537SAndre Fischer Hide(); 126*ff12d537SAndre Fischer ImageRadioButton::MouseButtonUp(rMouseEvent); 127*ff12d537SAndre Fischer Show(); 128*ff12d537SAndre Fischer #else 129*ff12d537SAndre Fischer if (IsMouseCaptured()) 130*ff12d537SAndre Fischer ReleaseMouse(); 131*ff12d537SAndre Fischer 132*ff12d537SAndre Fischer if (rMouseEvent.IsLeft()) 133*ff12d537SAndre Fischer { 134*ff12d537SAndre Fischer if (mbIsLeftButtonDown) 135*ff12d537SAndre Fischer { 136*ff12d537SAndre Fischer Check(); 137*ff12d537SAndre Fischer Click(); 138*ff12d537SAndre Fischer GetParent()->Invalidate(); 139*ff12d537SAndre Fischer } 140*ff12d537SAndre Fischer } 141*ff12d537SAndre Fischer if (mbIsLeftButtonDown) 142*ff12d537SAndre Fischer { 143*ff12d537SAndre Fischer mbIsLeftButtonDown = false; 144*ff12d537SAndre Fischer Invalidate(); 145*ff12d537SAndre Fischer } 146*ff12d537SAndre Fischer #endif 147*ff12d537SAndre Fischer } 148*ff12d537SAndre Fischer 149*ff12d537SAndre Fischer 150*ff12d537SAndre Fischer 151*ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 152