18dcb2a10SAndre Fischer /************************************************************** 28dcb2a10SAndre Fischer * 38dcb2a10SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 48dcb2a10SAndre Fischer * or more contributor license agreements. See the NOTICE file 58dcb2a10SAndre Fischer * distributed with this work for additional information 68dcb2a10SAndre Fischer * regarding copyright ownership. The ASF licenses this file 78dcb2a10SAndre Fischer * to you under the Apache License, Version 2.0 (the 88dcb2a10SAndre Fischer * "License"); you may not use this file except in compliance 98dcb2a10SAndre Fischer * with the License. You may obtain a copy of the License at 108dcb2a10SAndre Fischer * 118dcb2a10SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 128dcb2a10SAndre Fischer * 138dcb2a10SAndre Fischer * Unless required by applicable law or agreed to in writing, 148dcb2a10SAndre Fischer * software distributed under the License is distributed on an 158dcb2a10SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 168dcb2a10SAndre Fischer * KIND, either express or implied. See the License for the 178dcb2a10SAndre Fischer * specific language governing permissions and limitations 188dcb2a10SAndre Fischer * under the License. 198dcb2a10SAndre Fischer * 208dcb2a10SAndre Fischer *************************************************************/ 218dcb2a10SAndre Fischer 228dcb2a10SAndre Fischer #include "LineWidthValueSet.hxx" 238dcb2a10SAndre Fischer 248dcb2a10SAndre Fischer #include <i18npool/mslangid.hxx> 258dcb2a10SAndre Fischer 268dcb2a10SAndre Fischer namespace svx { namespace sidebar { 278dcb2a10SAndre Fischer 288dcb2a10SAndre Fischer 298dcb2a10SAndre Fischer LineWidthValueSet::LineWidthValueSet ( 308dcb2a10SAndre Fischer Window* pParent, const ResId& rResId) 318dcb2a10SAndre Fischer : ValueSet( pParent, rResId ), 328dcb2a10SAndre Fischer pVDev(NULL), 338dcb2a10SAndre Fischer nSelItem(0), 348dcb2a10SAndre Fischer bCusEnable(false) 358dcb2a10SAndre Fischer { 368dcb2a10SAndre Fischer strUnit = new XubString[9]; 378dcb2a10SAndre Fischer SetColCount( 1 ); 388dcb2a10SAndre Fischer SetLineCount( 9); 398dcb2a10SAndre Fischer } 408dcb2a10SAndre Fischer 418dcb2a10SAndre Fischer 428dcb2a10SAndre Fischer 438dcb2a10SAndre Fischer 448dcb2a10SAndre Fischer LineWidthValueSet::~LineWidthValueSet (void) 458dcb2a10SAndre Fischer { 468dcb2a10SAndre Fischer delete pVDev; 478dcb2a10SAndre Fischer delete[] strUnit; 488dcb2a10SAndre Fischer } 498dcb2a10SAndre Fischer 508dcb2a10SAndre Fischer 518dcb2a10SAndre Fischer 528dcb2a10SAndre Fischer 538dcb2a10SAndre Fischer void LineWidthValueSet::SetUnit(XubString* str) 548dcb2a10SAndre Fischer { 558dcb2a10SAndre Fischer for(int i = 0; i < 9; i++) 568dcb2a10SAndre Fischer { 578dcb2a10SAndre Fischer strUnit[i] = str[i]; 588dcb2a10SAndre Fischer } 598dcb2a10SAndre Fischer } 608dcb2a10SAndre Fischer 618dcb2a10SAndre Fischer 628dcb2a10SAndre Fischer 638dcb2a10SAndre Fischer void LineWidthValueSet::SetSelItem(sal_uInt16 nSel) 648dcb2a10SAndre Fischer { 658dcb2a10SAndre Fischer nSelItem = nSel; 668dcb2a10SAndre Fischer if(nSel == 0) 678dcb2a10SAndre Fischer { 688dcb2a10SAndre Fischer SelectItem(1); // ,false); // 'false' nut supported by AOO 698dcb2a10SAndre Fischer SetNoSelection(); 708dcb2a10SAndre Fischer } 718dcb2a10SAndre Fischer else 728dcb2a10SAndre Fischer { 738dcb2a10SAndre Fischer SelectItem(nSelItem); 748dcb2a10SAndre Fischer GrabFocus(); 758dcb2a10SAndre Fischer } 768dcb2a10SAndre Fischer } 778dcb2a10SAndre Fischer 788dcb2a10SAndre Fischer 798dcb2a10SAndre Fischer 808dcb2a10SAndre Fischer 818dcb2a10SAndre Fischer sal_uInt16 LineWidthValueSet::GetSelItem() 828dcb2a10SAndre Fischer { 838dcb2a10SAndre Fischer return nSelItem; 848dcb2a10SAndre Fischer } 858dcb2a10SAndre Fischer 868dcb2a10SAndre Fischer 878dcb2a10SAndre Fischer 888dcb2a10SAndre Fischer 898dcb2a10SAndre Fischer void LineWidthValueSet::SetImage(Image img) 908dcb2a10SAndre Fischer { 918dcb2a10SAndre Fischer imgCus = img; 928dcb2a10SAndre Fischer } 938dcb2a10SAndre Fischer 948dcb2a10SAndre Fischer 958dcb2a10SAndre Fischer 968dcb2a10SAndre Fischer 978dcb2a10SAndre Fischer void LineWidthValueSet::SetCusEnable(bool bEnable) 988dcb2a10SAndre Fischer { 998dcb2a10SAndre Fischer bCusEnable = bEnable; 1008dcb2a10SAndre Fischer } 1018dcb2a10SAndre Fischer 1028dcb2a10SAndre Fischer 1038dcb2a10SAndre Fischer 1048dcb2a10SAndre Fischer 1058dcb2a10SAndre Fischer void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt ) 1068dcb2a10SAndre Fischer { 1078dcb2a10SAndre Fischer Rectangle aRect = rUDEvt.GetRect(); 1088dcb2a10SAndre Fischer OutputDevice* pDev = rUDEvt.GetDevice(); 1098dcb2a10SAndre Fischer sal_uInt16 nItemId = rUDEvt.GetItemId(); 1108dcb2a10SAndre Fischer 1118dcb2a10SAndre Fischer long nRectHeight = aRect.GetHeight(); 1128dcb2a10SAndre Fischer long nRectWidth = aRect.GetWidth(); 1138dcb2a10SAndre Fischer Point aBLPos = aRect.TopLeft(); 1148dcb2a10SAndre Fischer 1158dcb2a10SAndre Fischer //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 1168dcb2a10SAndre Fischer //Color aBackColor(0,0,200); 1178dcb2a10SAndre Fischer //const Color aTextColor = rStyleSettings.GetFieldTextColor(); 1188dcb2a10SAndre Fischer Font aOldFont = pDev->GetFont(); 1198dcb2a10SAndre Fischer Color aOldColor = pDev->GetLineColor(); 1208dcb2a10SAndre Fischer Color aOldFillColor = pDev->GetFillColor(); 1218dcb2a10SAndre Fischer 1228dcb2a10SAndre Fischer Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE)); 1238dcb2a10SAndre Fischer Size aSize = aFont.GetSize(); 1248dcb2a10SAndre Fischer aSize.Height() = nRectHeight*3/5; 1258dcb2a10SAndre Fischer aFont.SetSize( aSize ); 1268dcb2a10SAndre Fischer 1278dcb2a10SAndre Fischer Point aLineStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - nItemId )/2); 1288dcb2a10SAndre Fischer Point aLineEnd(aBLPos.X() + nRectWidth * 7 / 9 - 10, aBLPos.Y() + ( nRectHeight - nItemId )/2); 1298dcb2a10SAndre Fischer if(nItemId == 9) 1308dcb2a10SAndre Fischer { 1318dcb2a10SAndre Fischer Point aImgStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - 23 ) / 2); 1328dcb2a10SAndre Fischer pDev->DrawImage(aImgStart, imgCus); 1338dcb2a10SAndre Fischer // Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6); 1348dcb2a10SAndre Fischer Rectangle aStrRect = aRect; 1358dcb2a10SAndre Fischer aStrRect.Top() += nRectHeight/6; 1368dcb2a10SAndre Fischer aStrRect.Bottom() -= nRectHeight/6; 1378dcb2a10SAndre Fischer aStrRect.Left() += imgCus.GetSizePixel().Width() + 20; 1388dcb2a10SAndre Fischer if(bCusEnable) 1398dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 1408dcb2a10SAndre Fischer else 1418dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor()); 1428dcb2a10SAndre Fischer 1438dcb2a10SAndre Fischer pDev->SetFont(aFont); 1448dcb2a10SAndre Fischer pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS); 1458dcb2a10SAndre Fischer } 1468dcb2a10SAndre Fischer else 1478dcb2a10SAndre Fischer { 1488dcb2a10SAndre Fischer if( nSelItem == nItemId ) 1498dcb2a10SAndre Fischer { 1508dcb2a10SAndre Fischer Color aBackColor(50,107,197); 1518dcb2a10SAndre Fischer Rectangle aBackRect = aRect; 1528dcb2a10SAndre Fischer aBackRect.Top() += 3; 1538dcb2a10SAndre Fischer aBackRect.Bottom() -= 2; 1548dcb2a10SAndre Fischer pDev->SetFillColor(aBackColor); 1558dcb2a10SAndre Fischer pDev->DrawRect(aBackRect); 1568dcb2a10SAndre Fischer } 1578dcb2a10SAndre Fischer else 1588dcb2a10SAndre Fischer { 1598dcb2a10SAndre Fischer pDev->SetFillColor( COL_TRANSPARENT ); 1608dcb2a10SAndre Fischer pDev->DrawRect(aRect); 1618dcb2a10SAndre Fischer } 1628dcb2a10SAndre Fischer 1638dcb2a10SAndre Fischer //draw text 1648dcb2a10SAndre Fischer if(nSelItem == nItemId ) 1658dcb2a10SAndre Fischer aFont.SetColor(COL_WHITE); 1668dcb2a10SAndre Fischer else 1678dcb2a10SAndre Fischer aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 1688dcb2a10SAndre Fischer pDev->SetFont(aFont); 1698dcb2a10SAndre Fischer Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6); 1708dcb2a10SAndre Fischer pDev->DrawText(aStart, strUnit[ nItemId - 1 ]); //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear 1718dcb2a10SAndre Fischer 1728dcb2a10SAndre Fischer //draw line 1738dcb2a10SAndre Fischer if( nSelItem == nItemId ) 1748dcb2a10SAndre Fischer pDev->SetLineColor(COL_WHITE); 1758dcb2a10SAndre Fischer else 1768dcb2a10SAndre Fischer pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 1778dcb2a10SAndre Fischer 1788dcb2a10SAndre Fischer for(sal_uInt16 i = 1; i <= nItemId; i++) 1798dcb2a10SAndre Fischer { 1808dcb2a10SAndre Fischer pDev->DrawLine(aLineStart,aLineEnd ); 1818dcb2a10SAndre Fischer aLineStart.setY(aLineStart.getY() + 1); 1828dcb2a10SAndre Fischer aLineEnd.setY (aLineEnd.getY() + 1); 1838dcb2a10SAndre Fischer } 1848dcb2a10SAndre Fischer } 1858dcb2a10SAndre Fischer 1868dcb2a10SAndre Fischer Invalidate( aRect ); 1878dcb2a10SAndre Fischer pDev->SetLineColor(aOldColor); 1888dcb2a10SAndre Fischer pDev->SetFillColor(aOldFillColor); 1898dcb2a10SAndre Fischer pDev->SetFont(aOldFont); 1908dcb2a10SAndre Fischer } 1918dcb2a10SAndre Fischer 1928dcb2a10SAndre Fischer 1938dcb2a10SAndre Fischer 1948dcb2a10SAndre Fischer } } // end of namespace svx::sidebar 195*4e8031e0SArmin Le Grand 196*4e8031e0SArmin Le Grand // eof 197