1*8dcb2a10SAndre Fischer /************************************************************** 2*8dcb2a10SAndre Fischer * 3*8dcb2a10SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*8dcb2a10SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*8dcb2a10SAndre Fischer * distributed with this work for additional information 6*8dcb2a10SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*8dcb2a10SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*8dcb2a10SAndre Fischer * "License"); you may not use this file except in compliance 9*8dcb2a10SAndre Fischer * with the License. You may obtain a copy of the License at 10*8dcb2a10SAndre Fischer * 11*8dcb2a10SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*8dcb2a10SAndre Fischer * 13*8dcb2a10SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*8dcb2a10SAndre Fischer * software distributed under the License is distributed on an 15*8dcb2a10SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*8dcb2a10SAndre Fischer * KIND, either express or implied. See the License for the 17*8dcb2a10SAndre Fischer * specific language governing permissions and limitations 18*8dcb2a10SAndre Fischer * under the License. 19*8dcb2a10SAndre Fischer * 20*8dcb2a10SAndre Fischer *************************************************************/ 21*8dcb2a10SAndre Fischer 22*8dcb2a10SAndre Fischer #include "LineWidthValueSet.hxx" 23*8dcb2a10SAndre Fischer 24*8dcb2a10SAndre Fischer #include <i18npool/mslangid.hxx> 25*8dcb2a10SAndre Fischer 26*8dcb2a10SAndre Fischer namespace svx { namespace sidebar { 27*8dcb2a10SAndre Fischer 28*8dcb2a10SAndre Fischer 29*8dcb2a10SAndre Fischer LineWidthValueSet::LineWidthValueSet ( 30*8dcb2a10SAndre Fischer Window* pParent, const ResId& rResId) 31*8dcb2a10SAndre Fischer : ValueSet( pParent, rResId ), 32*8dcb2a10SAndre Fischer pVDev(NULL), 33*8dcb2a10SAndre Fischer nSelItem(0), 34*8dcb2a10SAndre Fischer bCusEnable(false) 35*8dcb2a10SAndre Fischer { 36*8dcb2a10SAndre Fischer strUnit = new XubString[9]; 37*8dcb2a10SAndre Fischer SetColCount( 1 ); 38*8dcb2a10SAndre Fischer SetLineCount( 9); 39*8dcb2a10SAndre Fischer } 40*8dcb2a10SAndre Fischer 41*8dcb2a10SAndre Fischer 42*8dcb2a10SAndre Fischer 43*8dcb2a10SAndre Fischer 44*8dcb2a10SAndre Fischer LineWidthValueSet::~LineWidthValueSet (void) 45*8dcb2a10SAndre Fischer { 46*8dcb2a10SAndre Fischer delete pVDev; 47*8dcb2a10SAndre Fischer delete[] strUnit; 48*8dcb2a10SAndre Fischer } 49*8dcb2a10SAndre Fischer 50*8dcb2a10SAndre Fischer 51*8dcb2a10SAndre Fischer 52*8dcb2a10SAndre Fischer 53*8dcb2a10SAndre Fischer void LineWidthValueSet::SetUnit(XubString* str) 54*8dcb2a10SAndre Fischer { 55*8dcb2a10SAndre Fischer for(int i = 0; i < 9; i++) 56*8dcb2a10SAndre Fischer { 57*8dcb2a10SAndre Fischer strUnit[i] = str[i]; 58*8dcb2a10SAndre Fischer } 59*8dcb2a10SAndre Fischer } 60*8dcb2a10SAndre Fischer 61*8dcb2a10SAndre Fischer 62*8dcb2a10SAndre Fischer 63*8dcb2a10SAndre Fischer void LineWidthValueSet::SetSelItem(sal_uInt16 nSel) 64*8dcb2a10SAndre Fischer { 65*8dcb2a10SAndre Fischer nSelItem = nSel; 66*8dcb2a10SAndre Fischer if(nSel == 0) 67*8dcb2a10SAndre Fischer { 68*8dcb2a10SAndre Fischer SelectItem(1); // ,false); // 'false' nut supported by AOO 69*8dcb2a10SAndre Fischer SetNoSelection(); 70*8dcb2a10SAndre Fischer } 71*8dcb2a10SAndre Fischer else 72*8dcb2a10SAndre Fischer { 73*8dcb2a10SAndre Fischer SelectItem(nSelItem); 74*8dcb2a10SAndre Fischer GrabFocus(); 75*8dcb2a10SAndre Fischer } 76*8dcb2a10SAndre Fischer } 77*8dcb2a10SAndre Fischer 78*8dcb2a10SAndre Fischer 79*8dcb2a10SAndre Fischer 80*8dcb2a10SAndre Fischer 81*8dcb2a10SAndre Fischer sal_uInt16 LineWidthValueSet::GetSelItem() 82*8dcb2a10SAndre Fischer { 83*8dcb2a10SAndre Fischer return nSelItem; 84*8dcb2a10SAndre Fischer } 85*8dcb2a10SAndre Fischer 86*8dcb2a10SAndre Fischer 87*8dcb2a10SAndre Fischer 88*8dcb2a10SAndre Fischer 89*8dcb2a10SAndre Fischer void LineWidthValueSet::SetImage(Image img) 90*8dcb2a10SAndre Fischer { 91*8dcb2a10SAndre Fischer imgCus = img; 92*8dcb2a10SAndre Fischer } 93*8dcb2a10SAndre Fischer 94*8dcb2a10SAndre Fischer 95*8dcb2a10SAndre Fischer 96*8dcb2a10SAndre Fischer 97*8dcb2a10SAndre Fischer void LineWidthValueSet::SetCusEnable(bool bEnable) 98*8dcb2a10SAndre Fischer { 99*8dcb2a10SAndre Fischer bCusEnable = bEnable; 100*8dcb2a10SAndre Fischer } 101*8dcb2a10SAndre Fischer 102*8dcb2a10SAndre Fischer 103*8dcb2a10SAndre Fischer 104*8dcb2a10SAndre Fischer 105*8dcb2a10SAndre Fischer void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt ) 106*8dcb2a10SAndre Fischer { 107*8dcb2a10SAndre Fischer Rectangle aRect = rUDEvt.GetRect(); 108*8dcb2a10SAndre Fischer OutputDevice* pDev = rUDEvt.GetDevice(); 109*8dcb2a10SAndre Fischer sal_uInt16 nItemId = rUDEvt.GetItemId(); 110*8dcb2a10SAndre Fischer 111*8dcb2a10SAndre Fischer long nRectHeight = aRect.GetHeight(); 112*8dcb2a10SAndre Fischer long nRectWidth = aRect.GetWidth(); 113*8dcb2a10SAndre Fischer Point aBLPos = aRect.TopLeft(); 114*8dcb2a10SAndre Fischer 115*8dcb2a10SAndre Fischer //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 116*8dcb2a10SAndre Fischer //Color aBackColor(0,0,200); 117*8dcb2a10SAndre Fischer //const Color aTextColor = rStyleSettings.GetFieldTextColor(); 118*8dcb2a10SAndre Fischer Font aOldFont = pDev->GetFont(); 119*8dcb2a10SAndre Fischer Color aOldColor = pDev->GetLineColor(); 120*8dcb2a10SAndre Fischer Color aOldFillColor = pDev->GetFillColor(); 121*8dcb2a10SAndre Fischer 122*8dcb2a10SAndre Fischer Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE)); 123*8dcb2a10SAndre Fischer Size aSize = aFont.GetSize(); 124*8dcb2a10SAndre Fischer aSize.Height() = nRectHeight*3/5; 125*8dcb2a10SAndre Fischer aFont.SetSize( aSize ); 126*8dcb2a10SAndre Fischer 127*8dcb2a10SAndre Fischer Point aLineStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - nItemId )/2); 128*8dcb2a10SAndre Fischer Point aLineEnd(aBLPos.X() + nRectWidth * 7 / 9 - 10, aBLPos.Y() + ( nRectHeight - nItemId )/2); 129*8dcb2a10SAndre Fischer if(nItemId == 9) 130*8dcb2a10SAndre Fischer { 131*8dcb2a10SAndre Fischer Point aImgStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - 23 ) / 2); 132*8dcb2a10SAndre Fischer pDev->DrawImage(aImgStart, imgCus); 133*8dcb2a10SAndre Fischer // Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6); 134*8dcb2a10SAndre Fischer Rectangle aStrRect = aRect; 135*8dcb2a10SAndre Fischer aStrRect.Top() += nRectHeight/6; 136*8dcb2a10SAndre Fischer aStrRect.Bottom() -= nRectHeight/6; 137*8dcb2a10SAndre Fischer aStrRect.Left() += imgCus.GetSizePixel().Width() + 20; 138*8dcb2a10SAndre Fischer if(bCusEnable) 139*8dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 140*8dcb2a10SAndre Fischer else 141*8dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor()); 142*8dcb2a10SAndre Fischer 143*8dcb2a10SAndre Fischer pDev->SetFont(aFont); 144*8dcb2a10SAndre Fischer pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS); 145*8dcb2a10SAndre Fischer } 146*8dcb2a10SAndre Fischer else 147*8dcb2a10SAndre Fischer { 148*8dcb2a10SAndre Fischer if( nSelItem == nItemId ) 149*8dcb2a10SAndre Fischer { 150*8dcb2a10SAndre Fischer Color aBackColor(50,107,197); 151*8dcb2a10SAndre Fischer Rectangle aBackRect = aRect; 152*8dcb2a10SAndre Fischer aBackRect.Top() += 3; 153*8dcb2a10SAndre Fischer aBackRect.Bottom() -= 2; 154*8dcb2a10SAndre Fischer pDev->SetFillColor(aBackColor); 155*8dcb2a10SAndre Fischer pDev->DrawRect(aBackRect); 156*8dcb2a10SAndre Fischer } 157*8dcb2a10SAndre Fischer else 158*8dcb2a10SAndre Fischer { 159*8dcb2a10SAndre Fischer pDev->SetFillColor( COL_TRANSPARENT ); 160*8dcb2a10SAndre Fischer pDev->DrawRect(aRect); 161*8dcb2a10SAndre Fischer } 162*8dcb2a10SAndre Fischer 163*8dcb2a10SAndre Fischer //draw text 164*8dcb2a10SAndre Fischer if(nSelItem == nItemId ) 165*8dcb2a10SAndre Fischer aFont.SetColor(COL_WHITE); 166*8dcb2a10SAndre Fischer else 167*8dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 168*8dcb2a10SAndre Fischer pDev->SetFont(aFont); 169*8dcb2a10SAndre Fischer Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6); 170*8dcb2a10SAndre Fischer pDev->DrawText(aStart, strUnit[ nItemId - 1 ]); //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear 171*8dcb2a10SAndre Fischer 172*8dcb2a10SAndre Fischer //draw line 173*8dcb2a10SAndre Fischer if( nSelItem == nItemId ) 174*8dcb2a10SAndre Fischer pDev->SetLineColor(COL_WHITE); 175*8dcb2a10SAndre Fischer else 176*8dcb2a10SAndre Fischer pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 177*8dcb2a10SAndre Fischer 178*8dcb2a10SAndre Fischer for(sal_uInt16 i = 1; i <= nItemId; i++) 179*8dcb2a10SAndre Fischer { 180*8dcb2a10SAndre Fischer pDev->DrawLine(aLineStart,aLineEnd ); 181*8dcb2a10SAndre Fischer aLineStart.setY(aLineStart.getY() + 1); 182*8dcb2a10SAndre Fischer aLineEnd.setY (aLineEnd.getY() + 1); 183*8dcb2a10SAndre Fischer } 184*8dcb2a10SAndre Fischer } 185*8dcb2a10SAndre Fischer 186*8dcb2a10SAndre Fischer Invalidate( aRect ); 187*8dcb2a10SAndre Fischer pDev->SetLineColor(aOldColor); 188*8dcb2a10SAndre Fischer pDev->SetFillColor(aOldFillColor); 189*8dcb2a10SAndre Fischer pDev->SetFont(aOldFont); 190*8dcb2a10SAndre Fischer } 191*8dcb2a10SAndre Fischer 192*8dcb2a10SAndre Fischer 193*8dcb2a10SAndre Fischer 194*8dcb2a10SAndre Fischer } } // end of namespace svx::sidebar 195