1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // include --------------------------------------------------------------- 28cdf0e10cSrcweir #include <tools/shl.hxx> 29cdf0e10cSrcweir #include <vcl/svapp.hxx> 30cdf0e10cSrcweir #include <svx/xtable.hxx> 31cdf0e10cSrcweir #include <svx/xpool.hxx> 32cdf0e10cSrcweir #include <svx/dialogs.hrc> 3370d3707aSArmin Le Grand #include <accessibility.hrc> 34cdf0e10cSrcweir #include <svx/dlgctrl.hxx> 35cdf0e10cSrcweir #include <svx/dialmgr.hxx> 36cdf0e10cSrcweir #include <tools/poly.hxx> 37cdf0e10cSrcweir #include <vcl/region.hxx> 38cdf0e10cSrcweir #include <vcl/gradient.hxx> 39cdf0e10cSrcweir #include <vcl/hatch.hxx> 40*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 41*9b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_ 42*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleEventObject.hpp> 43*9b8096d0SSteve Yin #endif 44*9b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 45*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleEventId.hpp> 46*9b8096d0SSteve Yin #endif 47*9b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 48*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp> 49*9b8096d0SSteve Yin #endif 50*9b8096d0SSteve Yin #include "svxpixelctlaccessiblecontext.hxx" 51*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 52cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 5370d3707aSArmin Le Grand #include <svxrectctaccessiblecontext.hxx> 54cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 55cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 56cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 57cdf0e10cSrcweir #include <svx/svdorect.hxx> 58cdf0e10cSrcweir #include <svx/svdmodel.hxx> 59cdf0e10cSrcweir #include <svx/svdopath.hxx> 60cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> 61cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 6270d3707aSArmin Le Grand #include <linectrl.hrc> 6370d3707aSArmin Le Grand #include <vcl/bmpacc.hxx> 6470d3707aSArmin Le Grand #include <svx/xbtmpit.hxx> 65cdf0e10cSrcweir 66cdf0e10cSrcweir #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT) 67cdf0e10cSrcweir #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT) 68cdf0e10cSrcweir 69cdf0e10cSrcweir using namespace ::com::sun::star::uno; 70cdf0e10cSrcweir using namespace ::com::sun::star::lang; 71cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir /************************************************************************* 75cdf0e10cSrcweir |* 76cdf0e10cSrcweir |* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt) 77cdf0e10cSrcweir |* eines Objekts 78cdf0e10cSrcweir |* 79cdf0e10cSrcweir \************************************************************************/ 80cdf0e10cSrcweir 81cdf0e10cSrcweir Bitmap& SvxRectCtl::GetRectBitmap( void ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir if( !pBitmap ) 84cdf0e10cSrcweir InitRectBitmap(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir return *pBitmap; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt, 90cdf0e10cSrcweir sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) : 91cdf0e10cSrcweir 92cdf0e10cSrcweir Control( pParent, rResId ), 93cdf0e10cSrcweir 94cdf0e10cSrcweir pAccContext ( NULL ), 95cdf0e10cSrcweir nBorderWidth( nBorder ), 96cdf0e10cSrcweir nRadius ( nCircle), 97cdf0e10cSrcweir eDefRP ( eRpt ), 98cdf0e10cSrcweir eCS ( eStyle ), 99cdf0e10cSrcweir pBitmap ( NULL ), 100cdf0e10cSrcweir m_nState ( 0 ), 101cdf0e10cSrcweir mbCompleteDisable(sal_False) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir SetMapMode( MAP_100TH_MM ); 104cdf0e10cSrcweir Resize_Impl(); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir // ----------------------------------------------------------------------- 108cdf0e10cSrcweir 109cdf0e10cSrcweir SvxRectCtl::~SvxRectCtl() 110cdf0e10cSrcweir { 111cdf0e10cSrcweir delete pBitmap; 112cdf0e10cSrcweir 113cdf0e10cSrcweir if( pAccContext ) 114cdf0e10cSrcweir pAccContext->release(); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir // ----------------------------------------------------------------------- 118cdf0e10cSrcweir void SvxRectCtl::Resize() 119cdf0e10cSrcweir { 120cdf0e10cSrcweir Resize_Impl(); 121cdf0e10cSrcweir Control::Resize(); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir // ----------------------------------------------------------------------- 125cdf0e10cSrcweir 126cdf0e10cSrcweir void SvxRectCtl::Resize_Impl() 127cdf0e10cSrcweir { 128cdf0e10cSrcweir aSize = GetOutputSize(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir switch( eCS ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir case CS_RECT: 133cdf0e10cSrcweir case CS_ANGLE: 134cdf0e10cSrcweir case CS_SHADOW: 135cdf0e10cSrcweir aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth ); 136cdf0e10cSrcweir aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); 137cdf0e10cSrcweir aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 ); 140cdf0e10cSrcweir aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); 141cdf0e10cSrcweir aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth ); 144cdf0e10cSrcweir aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); 145cdf0e10cSrcweir aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth ); 146cdf0e10cSrcweir break; 147cdf0e10cSrcweir 148cdf0e10cSrcweir case CS_LINE: 149cdf0e10cSrcweir aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth ); 150cdf0e10cSrcweir aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); 151cdf0e10cSrcweir aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 ); 154cdf0e10cSrcweir aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); 155cdf0e10cSrcweir aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth ); 158cdf0e10cSrcweir aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); 159cdf0e10cSrcweir aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth ); 160cdf0e10cSrcweir break; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir Reset(); 163cdf0e10cSrcweir InitSettings( sal_True, sal_True ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir // ----------------------------------------------------------------------- 166cdf0e10cSrcweir 167cdf0e10cSrcweir void SvxRectCtl::InitRectBitmap( void ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir if( pBitmap ) 170cdf0e10cSrcweir delete pBitmap; 171cdf0e10cSrcweir 172cdf0e10cSrcweir const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 173cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 174cdf0e10cSrcweir 175cdf0e10cSrcweir pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir // set bitmap-colors 178cdf0e10cSrcweir Color aColorAry1[7]; 179cdf0e10cSrcweir Color aColorAry2[7]; 180cdf0e10cSrcweir aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray 181cdf0e10cSrcweir aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow 182cdf0e10cSrcweir aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white 183cdf0e10cSrcweir aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray 184cdf0e10cSrcweir aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black 185cdf0e10cSrcweir aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green 186cdf0e10cSrcweir aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue 187cdf0e10cSrcweir aColorAry2[0] = rStyles.GetDialogColor(); // background 188cdf0e10cSrcweir aColorAry2[1] = rStyles.GetWindowColor(); 189cdf0e10cSrcweir aColorAry2[2] = rStyles.GetLightColor(); 190cdf0e10cSrcweir aColorAry2[3] = rStyles.GetShadowColor(); 191cdf0e10cSrcweir aColorAry2[4] = rStyles.GetDarkShadowColor(); 192cdf0e10cSrcweir aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 193cdf0e10cSrcweir aColorAry2[6] = rStyles.GetDialogColor(); 194cdf0e10cSrcweir 195cdf0e10cSrcweir #ifdef DBG_UTIL 196cdf0e10cSrcweir static sal_Bool bModify = sal_False; 197cdf0e10cSrcweir sal_Bool& rModify = bModify; 198cdf0e10cSrcweir if( rModify ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir static int n = 0; 201cdf0e10cSrcweir static sal_uInt8 r = 0xFF; 202cdf0e10cSrcweir static sal_uInt8 g = 0x00; 203cdf0e10cSrcweir static sal_uInt8 b = 0xFF; 204cdf0e10cSrcweir int& rn = n; 205cdf0e10cSrcweir sal_uInt8& rr = r; 206cdf0e10cSrcweir sal_uInt8& rg = g; 207cdf0e10cSrcweir sal_uInt8& rb = b; 208cdf0e10cSrcweir aColorAry2[ rn ] = Color( rr, rg, rb ); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir #endif 211cdf0e10cSrcweir 212cdf0e10cSrcweir pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL ); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir // ----------------------------------------------------------------------- 216cdf0e10cSrcweir 217cdf0e10cSrcweir void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 220cdf0e10cSrcweir 221cdf0e10cSrcweir if( bForeground ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 224cdf0e10cSrcweir Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir if ( IsControlForeground() ) 227cdf0e10cSrcweir aTextColor = GetControlForeground(); 228cdf0e10cSrcweir SetTextColor( aTextColor ); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir if( bBackground ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir if ( IsControlBackground() ) 234cdf0e10cSrcweir SetBackground( GetControlBackground() ); 235cdf0e10cSrcweir else 236cdf0e10cSrcweir SetBackground( rStyleSettings.GetWindowColor() ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir delete pBitmap; 240cdf0e10cSrcweir pBitmap = NULL; // forces new creating of bitmap 241cdf0e10cSrcweir 242cdf0e10cSrcweir Invalidate(); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir /************************************************************************* 246cdf0e10cSrcweir |* 247cdf0e10cSrcweir |* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog) 248cdf0e10cSrcweir |* wird benachrichtigt, dass der Punkt geaendert wurde 249cdf0e10cSrcweir |* 250cdf0e10cSrcweir \************************************************************************/ 251cdf0e10cSrcweir 252cdf0e10cSrcweir void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 255cdf0e10cSrcweir if(!IsCompletelyDisabled()) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir Point aPtLast = aPtNew; 258cdf0e10cSrcweir 259cdf0e10cSrcweir aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) ) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir aPtNew = aPtLast; 264cdf0e10cSrcweir } 265cdf0e10cSrcweir else 266cdf0e10cSrcweir { 267cdf0e10cSrcweir Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), 268cdf0e10cSrcweir aPtLast + Point( nRadius, nRadius ) ) ); 269cdf0e10cSrcweir Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), 270cdf0e10cSrcweir aPtNew + Point( nRadius, nRadius ) ) ); 271cdf0e10cSrcweir eRP = GetRPFromPoint( aPtNew ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir SetActualRP( eRP ); 274cdf0e10cSrcweir 275cdf0e10cSrcweir if( WINDOW_TABPAGE == GetParent()->GetType() ) 276cdf0e10cSrcweir ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir // ----------------------------------------------------------------------- 282cdf0e10cSrcweir 283cdf0e10cSrcweir void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 286cdf0e10cSrcweir if(!IsCompletelyDisabled()) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir RECT_POINT eNewRP = eRP; 289cdf0e10cSrcweir sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE); 290cdf0e10cSrcweir 291cdf0e10cSrcweir switch( rKeyEvt.GetKeyCode().GetCode() ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir case KEY_DOWN: 294cdf0e10cSrcweir { 295cdf0e10cSrcweir if( !(m_nState & CS_NOVERT) ) 296cdf0e10cSrcweir switch( eNewRP ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir case RP_LT: eNewRP = RP_LM; break; 299cdf0e10cSrcweir case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break; 300cdf0e10cSrcweir case RP_RT: eNewRP = RP_RM; break; 301cdf0e10cSrcweir case RP_LM: eNewRP = RP_LB; break; 302cdf0e10cSrcweir case RP_MM: eNewRP = RP_MB; break; 303cdf0e10cSrcweir case RP_RM: eNewRP = RP_RB; break; 304cdf0e10cSrcweir default: ; //prevent warning 305cdf0e10cSrcweir } 306cdf0e10cSrcweir } 307cdf0e10cSrcweir break; 308cdf0e10cSrcweir case KEY_UP: 309cdf0e10cSrcweir { 310cdf0e10cSrcweir if( !(m_nState & CS_NOVERT) ) 311cdf0e10cSrcweir switch( eNewRP ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir case RP_LM: eNewRP = RP_LT; break; 314cdf0e10cSrcweir case RP_MM: eNewRP = RP_MT; break; 315cdf0e10cSrcweir case RP_RM: eNewRP = RP_RT; break; 316cdf0e10cSrcweir case RP_LB: eNewRP = RP_LM; break; 317cdf0e10cSrcweir case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break; 318cdf0e10cSrcweir case RP_RB: eNewRP = RP_RM; break; 319cdf0e10cSrcweir default: ; //prevent warning 320cdf0e10cSrcweir } 321cdf0e10cSrcweir } 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir case KEY_LEFT: 324cdf0e10cSrcweir { 325cdf0e10cSrcweir if( !(m_nState & CS_NOHORZ) ) 326cdf0e10cSrcweir switch( eNewRP ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir case RP_MT: eNewRP = RP_LT; break; 329cdf0e10cSrcweir case RP_RT: eNewRP = RP_MT; break; 330cdf0e10cSrcweir case RP_MM: eNewRP = RP_LM; break; 331cdf0e10cSrcweir case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break; 332cdf0e10cSrcweir case RP_MB: eNewRP = RP_LB; break; 333cdf0e10cSrcweir case RP_RB: eNewRP = RP_MB; break; 334cdf0e10cSrcweir default: ; //prevent warning 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir break; 338cdf0e10cSrcweir case KEY_RIGHT: 339cdf0e10cSrcweir { 340cdf0e10cSrcweir if( !(m_nState & CS_NOHORZ) ) 341cdf0e10cSrcweir switch( eNewRP ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir case RP_LT: eNewRP = RP_MT; break; 344cdf0e10cSrcweir case RP_MT: eNewRP = RP_RT; break; 345cdf0e10cSrcweir case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break; 346cdf0e10cSrcweir case RP_MM: eNewRP = RP_RM; break; 347cdf0e10cSrcweir case RP_LB: eNewRP = RP_MB; break; 348cdf0e10cSrcweir case RP_MB: eNewRP = RP_RB; break; 349cdf0e10cSrcweir default: ; //prevent warning 350cdf0e10cSrcweir } 351cdf0e10cSrcweir } 352cdf0e10cSrcweir break; 353cdf0e10cSrcweir default: 354cdf0e10cSrcweir Control::KeyInput( rKeyEvt ); 355cdf0e10cSrcweir return; 356cdf0e10cSrcweir } 357cdf0e10cSrcweir if( eNewRP != eRP ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir SetActualRP( eNewRP ); 360cdf0e10cSrcweir 361cdf0e10cSrcweir if( WINDOW_TABPAGE == GetParent()->GetType() ) 362cdf0e10cSrcweir ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 363cdf0e10cSrcweir 364cdf0e10cSrcweir SetFocusRect(); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir // ----------------------------------------------------------------------- 370cdf0e10cSrcweir 371cdf0e10cSrcweir void SvxRectCtl::StateChanged( StateChangedType nType ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 374cdf0e10cSrcweir InitSettings( sal_True, sal_False ); 375cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 376cdf0e10cSrcweir InitSettings( sal_False, sal_True ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir Window::StateChanged( nType ); 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir // ----------------------------------------------------------------------- 382cdf0e10cSrcweir 383cdf0e10cSrcweir void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 386cdf0e10cSrcweir InitSettings( sal_True, sal_True ); 387cdf0e10cSrcweir else 388cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir /************************************************************************* 392cdf0e10cSrcweir |* 393cdf0e10cSrcweir |* Zeichnet das Control (Rechteck mit 9 Kreisen) 394cdf0e10cSrcweir |* 395cdf0e10cSrcweir \************************************************************************/ 396cdf0e10cSrcweir 397cdf0e10cSrcweir void SvxRectCtl::Paint( const Rectangle& ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) ); 400cdf0e10cSrcweir 401cdf0e10cSrcweir const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 402cdf0e10cSrcweir 403cdf0e10cSrcweir SetLineColor( rStyles.GetDialogColor() ); 404cdf0e10cSrcweir SetFillColor( rStyles.GetDialogColor() ); 405cdf0e10cSrcweir DrawRect( Rectangle( Point(0,0), GetOutputSize() ) ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir if( IsEnabled() ) 408cdf0e10cSrcweir SetLineColor( rStyles.GetLabelTextColor() ); 409cdf0e10cSrcweir else 410cdf0e10cSrcweir SetLineColor( rStyles.GetShadowColor() ); 411cdf0e10cSrcweir 412cdf0e10cSrcweir SetFillColor(); 413cdf0e10cSrcweir 414cdf0e10cSrcweir switch( eCS ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir 417cdf0e10cSrcweir case CS_RECT: 418cdf0e10cSrcweir case CS_SHADOW: 419cdf0e10cSrcweir if( !IsEnabled() ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir Color aOldCol = GetLineColor(); 422cdf0e10cSrcweir SetLineColor( rStyles.GetLightColor() ); 423cdf0e10cSrcweir DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) ); 424cdf0e10cSrcweir SetLineColor( aOldCol ); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir DrawRect( Rectangle( aPtLT, aPtRB ) ); 427cdf0e10cSrcweir break; 428cdf0e10cSrcweir 429cdf0e10cSrcweir case CS_LINE: 430cdf0e10cSrcweir if( !IsEnabled() ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir Color aOldCol = GetLineColor(); 433cdf0e10cSrcweir SetLineColor( rStyles.GetLightColor() ); 434cdf0e10cSrcweir DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff, 435cdf0e10cSrcweir aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff ); 436cdf0e10cSrcweir SetLineColor( aOldCol ); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir DrawLine( aPtLM - Point( 2 * nBorderWidth, 0), 439cdf0e10cSrcweir aPtRM + Point( 2 * nBorderWidth, 0 ) ); 440cdf0e10cSrcweir break; 441cdf0e10cSrcweir 442cdf0e10cSrcweir case CS_ANGLE: 443cdf0e10cSrcweir if( !IsEnabled() ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir Color aOldCol = GetLineColor(); 446cdf0e10cSrcweir SetLineColor( rStyles.GetLightColor() ); 447cdf0e10cSrcweir DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff ); 448cdf0e10cSrcweir DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff ); 449cdf0e10cSrcweir DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff ); 450cdf0e10cSrcweir DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff ); 451cdf0e10cSrcweir SetLineColor( aOldCol ); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir DrawLine( aPtLT, aPtRB ); 454cdf0e10cSrcweir DrawLine( aPtLB, aPtRT ); 455cdf0e10cSrcweir DrawLine( aPtLM, aPtRM ); 456cdf0e10cSrcweir DrawLine( aPtMT, aPtMB ); 457cdf0e10cSrcweir break; 458cdf0e10cSrcweir 459cdf0e10cSrcweir default: 460cdf0e10cSrcweir break; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir SetFillColor( GetBackground().GetColor() ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir Size aBtnSize( 11, 11 ); 465cdf0e10cSrcweir Size aDstBtnSize( PixelToLogic( aBtnSize ) ); 466cdf0e10cSrcweir Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1); 467cdf0e10cSrcweir Point aBtnPnt1( IsEnabled()?0:22,0 ); 468cdf0e10cSrcweir Point aBtnPnt2( 11,0 ); 469cdf0e10cSrcweir Point aBtnPnt3( 22,0 ); 470cdf0e10cSrcweir 471cdf0e10cSrcweir sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0; 472cdf0e10cSrcweir sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0; 473cdf0e10cSrcweir 474cdf0e10cSrcweir Bitmap& rBitmap = GetRectBitmap(); 475cdf0e10cSrcweir 476cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 477cdf0e10cSrcweir if(IsCompletelyDisabled()) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 480cdf0e10cSrcweir DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 481cdf0e10cSrcweir DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 482cdf0e10cSrcweir DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 483cdf0e10cSrcweir if( eCS == CS_RECT || eCS == CS_LINE ) 484cdf0e10cSrcweir DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 485cdf0e10cSrcweir DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 486cdf0e10cSrcweir DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 487cdf0e10cSrcweir DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 488cdf0e10cSrcweir DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir else 491cdf0e10cSrcweir { 492cdf0e10cSrcweir DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 493cdf0e10cSrcweir DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 494cdf0e10cSrcweir DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 495cdf0e10cSrcweir 496cdf0e10cSrcweir DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir // Mittelpunkt bei Rechteck und Linie 499cdf0e10cSrcweir if( eCS == CS_RECT || eCS == CS_LINE ) 500cdf0e10cSrcweir DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap ); 501cdf0e10cSrcweir 502cdf0e10cSrcweir DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 503cdf0e10cSrcweir 504cdf0e10cSrcweir DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 505cdf0e10cSrcweir DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 506cdf0e10cSrcweir DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir // draw active button, avoid center pos for angle 510cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 511cdf0e10cSrcweir if(!IsCompletelyDisabled()) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir Point aCenterPt( aPtNew ); 516cdf0e10cSrcweir aCenterPt -= aToCenter; 517cdf0e10cSrcweir 518cdf0e10cSrcweir DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap ); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir } 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir /************************************************************************* 524cdf0e10cSrcweir |* 525cdf0e10cSrcweir |* Konvertiert RECT_POINT in Point 526cdf0e10cSrcweir |* 527cdf0e10cSrcweir \************************************************************************/ 528cdf0e10cSrcweir 529cdf0e10cSrcweir Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const 530cdf0e10cSrcweir { 531cdf0e10cSrcweir switch( _eRP ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir case RP_LT: return aPtLT; 534cdf0e10cSrcweir case RP_MT: return aPtMT; 535cdf0e10cSrcweir case RP_RT: return aPtRT; 536cdf0e10cSrcweir case RP_LM: return aPtLM; 537cdf0e10cSrcweir case RP_MM: return aPtMM; 538cdf0e10cSrcweir case RP_RM: return aPtRM; 539cdf0e10cSrcweir case RP_LB: return aPtLB; 540cdf0e10cSrcweir case RP_MB: return aPtMB; 541cdf0e10cSrcweir case RP_RB: return aPtRB; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir return( aPtMM ); // default 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir 547cdf0e10cSrcweir void SvxRectCtl::SetFocusRect( const Rectangle* pRect ) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir HideFocus(); 550cdf0e10cSrcweir 551cdf0e10cSrcweir if( pRect ) 552cdf0e10cSrcweir ShowFocus( *pRect ); 553cdf0e10cSrcweir else 554cdf0e10cSrcweir ShowFocus( CalculateFocusRectangle() ); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557cdf0e10cSrcweir Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir Point aPtLast = aPtNew; 560cdf0e10cSrcweir aPtNew = GetPointFromRP( eNewRP ); 561cdf0e10cSrcweir 562cdf0e10cSrcweir if( (m_nState & CS_NOHORZ) != 0 ) 563cdf0e10cSrcweir aPtNew.X() = aPtMM.X(); 564cdf0e10cSrcweir 565cdf0e10cSrcweir if( (m_nState & CS_NOVERT) != 0 ) 566cdf0e10cSrcweir aPtNew.Y() = aPtMM.Y(); 567cdf0e10cSrcweir 568cdf0e10cSrcweir eNewRP = GetRPFromPoint( aPtNew ); 569cdf0e10cSrcweir 570cdf0e10cSrcweir eDefRP = eNewRP; 571cdf0e10cSrcweir eRP = eNewRP; 572cdf0e10cSrcweir 573cdf0e10cSrcweir return aPtLast; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir 576cdf0e10cSrcweir void SvxRectCtl::GetFocus() 577cdf0e10cSrcweir { 578cdf0e10cSrcweir SetFocusRect(); 579*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 580*9b8096d0SSteve Yin //Solution: Send the accessible focused event 581*9b8096d0SSteve Yin Control::GetFocus(); 582*9b8096d0SSteve Yin // Send accessibility event. 583*9b8096d0SSteve Yin if(pAccContext) 584*9b8096d0SSteve Yin { 585*9b8096d0SSteve Yin pAccContext->FireChildFocus(GetActualRP()); 586*9b8096d0SSteve Yin } 587*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir 591cdf0e10cSrcweir void SvxRectCtl::LoseFocus() 592cdf0e10cSrcweir { 593cdf0e10cSrcweir HideFocus(); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir 596cdf0e10cSrcweir 597cdf0e10cSrcweir Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const 598cdf0e10cSrcweir { 599cdf0e10cSrcweir Point aPt = PixelToLogic( rPt ); 600cdf0e10cSrcweir long x; 601cdf0e10cSrcweir long y; 602cdf0e10cSrcweir 603cdf0e10cSrcweir if( ( m_nState & CS_NOHORZ ) == 0 ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir if( aPt.X() < aSize.Width() / 3 ) 606cdf0e10cSrcweir x = aPtLT.X(); 607cdf0e10cSrcweir else if( aPt.X() < aSize.Width() * 2 / 3 ) 608cdf0e10cSrcweir x = aPtMM.X(); 609cdf0e10cSrcweir else 610cdf0e10cSrcweir x = aPtRB.X(); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir else 613cdf0e10cSrcweir x = aPtMM.X(); 614cdf0e10cSrcweir 615cdf0e10cSrcweir if( ( m_nState & CS_NOVERT ) == 0 ) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir if( aPt.Y() < aSize.Height() / 3 ) 618cdf0e10cSrcweir y = aPtLT.Y(); 619cdf0e10cSrcweir else if( aPt.Y() < aSize.Height() * 2 / 3 ) 620cdf0e10cSrcweir y = aPtMM.Y(); 621cdf0e10cSrcweir else 622cdf0e10cSrcweir y = aPtRB.Y(); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir else 625cdf0e10cSrcweir y = aPtMM.Y(); 626cdf0e10cSrcweir 627cdf0e10cSrcweir return Point( x, y ); 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir 631cdf0e10cSrcweir /************************************************************************* 632cdf0e10cSrcweir |* 633cdf0e10cSrcweir |* Konvertiert Point in RECT_POINT 634cdf0e10cSrcweir |* 635cdf0e10cSrcweir \************************************************************************/ 636cdf0e10cSrcweir 637cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const 638cdf0e10cSrcweir { 639cdf0e10cSrcweir if ( aPt == aPtLT) return RP_LT; 640cdf0e10cSrcweir else if( aPt == aPtMT) return RP_MT; 641cdf0e10cSrcweir else if( aPt == aPtRT) return RP_RT; 642cdf0e10cSrcweir else if( aPt == aPtLM) return RP_LM; 643cdf0e10cSrcweir else if( aPt == aPtRM) return RP_RM; 644cdf0e10cSrcweir else if( aPt == aPtLB) return RP_LB; 645cdf0e10cSrcweir else if( aPt == aPtMB) return RP_MB; 646cdf0e10cSrcweir else if( aPt == aPtRB) return RP_RB; 647cdf0e10cSrcweir 648cdf0e10cSrcweir else 649cdf0e10cSrcweir return RP_MM; // default 650cdf0e10cSrcweir } 651cdf0e10cSrcweir 652cdf0e10cSrcweir /************************************************************************* 653cdf0e10cSrcweir |* 654cdf0e10cSrcweir |* Bewirkt den Ursprungszustand des Controls 655cdf0e10cSrcweir |* 656cdf0e10cSrcweir \************************************************************************/ 657cdf0e10cSrcweir 658cdf0e10cSrcweir void SvxRectCtl::Reset() 659cdf0e10cSrcweir { 660cdf0e10cSrcweir aPtNew = GetPointFromRP( eDefRP ); 661cdf0e10cSrcweir eRP = eDefRP; 662cdf0e10cSrcweir Invalidate(); 663cdf0e10cSrcweir } 664cdf0e10cSrcweir 665cdf0e10cSrcweir /************************************************************************* 666cdf0e10cSrcweir |* 667cdf0e10cSrcweir |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck 668cdf0e10cSrcweir |* 669cdf0e10cSrcweir \************************************************************************/ 670cdf0e10cSrcweir 671cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetActualRP() const 672cdf0e10cSrcweir { 673cdf0e10cSrcweir return( eRP ); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir 676cdf0e10cSrcweir /************************************************************************* 677cdf0e10cSrcweir |* 678cdf0e10cSrcweir |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck 679cdf0e10cSrcweir |* 680cdf0e10cSrcweir \************************************************************************/ 681*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 682*9b8096d0SSteve Yin void SvxRectCtl::SetActualRP( RECT_POINT eNewRP /* MT: , sal_Bool bFireFocus */ ) 683cdf0e10cSrcweir { 684*9b8096d0SSteve Yin // MT: bFireFox as API parameter is ugly... 685cdf0e10cSrcweir Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) ); 686cdf0e10cSrcweir 687cdf0e10cSrcweir Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) ); 688cdf0e10cSrcweir Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) ); 689cdf0e10cSrcweir 690cdf0e10cSrcweir // notify accessibility object about change 691cdf0e10cSrcweir if( pAccContext ) 692*9b8096d0SSteve Yin pAccContext->selectChild( eNewRP /* MT, bFireFocus */ ); 693cdf0e10cSrcweir } 694*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 695cdf0e10cSrcweir void SvxRectCtl::SetState( CTL_STATE nState ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir m_nState = nState; 698cdf0e10cSrcweir 699cdf0e10cSrcweir Point aPtLast( GetPointFromRP( eRP ) ); 700cdf0e10cSrcweir Point _aPtNew( aPtLast ); 701cdf0e10cSrcweir 702cdf0e10cSrcweir if( (m_nState & CS_NOHORZ) != 0 ) 703cdf0e10cSrcweir _aPtNew.X() = aPtMM.X(); 704cdf0e10cSrcweir 705cdf0e10cSrcweir if( (m_nState & CS_NOVERT) != 0 ) 706cdf0e10cSrcweir _aPtNew.Y() = aPtMM.Y(); 707cdf0e10cSrcweir 708cdf0e10cSrcweir eRP = GetRPFromPoint( _aPtNew ); 709cdf0e10cSrcweir Invalidate(); 710cdf0e10cSrcweir 711cdf0e10cSrcweir if( WINDOW_TABPAGE == GetParent()->GetType() ) 712cdf0e10cSrcweir ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const 716cdf0e10cSrcweir { 717cdf0e10cSrcweir return ( eCS == CS_ANGLE )? 8 : 9; 718cdf0e10cSrcweir } 719cdf0e10cSrcweir 720cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const 721cdf0e10cSrcweir { 722cdf0e10cSrcweir Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) ); 723cdf0e10cSrcweir return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize ); 724cdf0e10cSrcweir } 725cdf0e10cSrcweir 726cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const 727cdf0e10cSrcweir { 728cdf0e10cSrcweir Rectangle aRet; 729cdf0e10cSrcweir RECT_POINT eOldRectPoint = GetActualRP(); 730cdf0e10cSrcweir 731cdf0e10cSrcweir if( eOldRectPoint == eRectPoint ) 732cdf0e10cSrcweir aRet = CalculateFocusRectangle(); 733cdf0e10cSrcweir else 734cdf0e10cSrcweir { 735cdf0e10cSrcweir SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this ); 736cdf0e10cSrcweir 737cdf0e10cSrcweir pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary! 738cdf0e10cSrcweir aRet = CalculateFocusRectangle(); 739cdf0e10cSrcweir 740cdf0e10cSrcweir pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed! 741cdf0e10cSrcweir } 742cdf0e10cSrcweir 743cdf0e10cSrcweir return aRet; 744cdf0e10cSrcweir } 745cdf0e10cSrcweir 746cdf0e10cSrcweir Reference< XAccessible > SvxRectCtl::CreateAccessible() 747cdf0e10cSrcweir { 748cdf0e10cSrcweir Window* pParent = GetAccessibleParentWindow(); 749cdf0e10cSrcweir 750cdf0e10cSrcweir DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" ); 751cdf0e10cSrcweir 752cdf0e10cSrcweir Reference< XAccessible > xAccParent = pParent->GetAccessible(); 753cdf0e10cSrcweir if( xAccParent.is() ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this ); 756cdf0e10cSrcweir pAccContext->acquire(); 757cdf0e10cSrcweir 758cdf0e10cSrcweir SetActualRP( GetActualRP() ); 759cdf0e10cSrcweir 760cdf0e10cSrcweir return pAccContext; 761cdf0e10cSrcweir } 762cdf0e10cSrcweir else 763cdf0e10cSrcweir return Reference< XAccessible >(); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir 766cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const 767cdf0e10cSrcweir { 768cdf0e10cSrcweir return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) ); 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 772cdf0e10cSrcweir void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir mbCompleteDisable = bNew; 775cdf0e10cSrcweir Invalidate(); 776cdf0e10cSrcweir } 777cdf0e10cSrcweir 778cdf0e10cSrcweir /************************************************************************* 779cdf0e10cSrcweir |* 780cdf0e10cSrcweir |* Konstruktor ohne Size-Parameter 781cdf0e10cSrcweir |* 782cdf0e10cSrcweir \************************************************************************/ 783cdf0e10cSrcweir 784cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) : 785cdf0e10cSrcweir 786cdf0e10cSrcweir SvxRectCtl( pParent, rResId ), 787cdf0e10cSrcweir 788cdf0e10cSrcweir aFont( Application::GetSettings().GetStyleSettings().GetAppFont() ) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir aFontSize = Size( 250, 400 ); 791cdf0e10cSrcweir Initialize(); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir 794cdf0e10cSrcweir /************************************************************************* 795cdf0e10cSrcweir |* 796cdf0e10cSrcweir |* Konstruktor mit Size-Parameter 797cdf0e10cSrcweir |* 798cdf0e10cSrcweir \************************************************************************/ 799cdf0e10cSrcweir 800cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) : 801cdf0e10cSrcweir 802cdf0e10cSrcweir SvxRectCtl( pParent, rResId ), 803cdf0e10cSrcweir 804cdf0e10cSrcweir aFont( Application::GetSettings().GetStyleSettings().GetAppFont() ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir aFontSize = _aSize; 807cdf0e10cSrcweir Initialize(); 808cdf0e10cSrcweir } 809cdf0e10cSrcweir 810cdf0e10cSrcweir /************************************************************************* 811cdf0e10cSrcweir |* 812cdf0e10cSrcweir |* Initialisierung 813cdf0e10cSrcweir |* 814cdf0e10cSrcweir \************************************************************************/ 815cdf0e10cSrcweir 816cdf0e10cSrcweir void SvxAngleCtl::Initialize() 817cdf0e10cSrcweir { 818cdf0e10cSrcweir bPositive = sal_True; 819cdf0e10cSrcweir 820cdf0e10cSrcweir // aFont.SetName( "Helvetica" ); 821cdf0e10cSrcweir aFont.SetSize( aFontSize ); 822cdf0e10cSrcweir aFont.SetWeight( WEIGHT_NORMAL ); 823cdf0e10cSrcweir aFont.SetTransparent( sal_False ); 824cdf0e10cSrcweir 825cdf0e10cSrcweir SetFont( aFont ); 826cdf0e10cSrcweir } 827cdf0e10cSrcweir 828cdf0e10cSrcweir /************************************************************************* 829cdf0e10cSrcweir |* 830cdf0e10cSrcweir |* Zeichnet das (Mini-)Koordinatensystem 831cdf0e10cSrcweir |* 832cdf0e10cSrcweir \************************************************************************/ 833cdf0e10cSrcweir 834cdf0e10cSrcweir void SvxAngleCtl::Paint( const Rectangle& ) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ??? 837cdf0e10cSrcweir DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) ); 838cdf0e10cSrcweir DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) ); 839cdf0e10cSrcweir 840cdf0e10cSrcweir SetLineColor( Color( COL_BLACK ) ); 841cdf0e10cSrcweir DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) ); 842cdf0e10cSrcweir DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) ); 843cdf0e10cSrcweir 844cdf0e10cSrcweir Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2); 845cdf0e10cSrcweir 846cdf0e10cSrcweir DrawText( aPtLT - aDiff, UniString::CreateFromAscii( 847cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "135" ) ) ); 848cdf0e10cSrcweir DrawText( aPtLM - aDiff, UniString::CreateFromAscii( 849cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "180" ) ) ); 850cdf0e10cSrcweir 851cdf0e10cSrcweir if ( bPositive ) 852cdf0e10cSrcweir DrawText( aPtLB - aDiff, UniString::CreateFromAscii( 853cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "225" ) ) ); 854cdf0e10cSrcweir else 855cdf0e10cSrcweir DrawText( aPtLB - aDiff, UniString::CreateFromAscii( 856cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "-135" ) ) ); 857cdf0e10cSrcweir 858cdf0e10cSrcweir aDiff.X() = aFontSize.Width(); 859cdf0e10cSrcweir DrawText( aPtMT - aDiff, UniString::CreateFromAscii( 860cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "90" ) ) ); 861cdf0e10cSrcweir DrawText( aPtRT - aDiff, UniString::CreateFromAscii( 862cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "45" ) ) ); 863cdf0e10cSrcweir aDiff.X() = aDiff .X() * 3 / 2; 864cdf0e10cSrcweir 865cdf0e10cSrcweir if ( bPositive ) 866cdf0e10cSrcweir DrawText( aPtMB - aDiff, UniString::CreateFromAscii( 867cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "270" ) ) ); 868cdf0e10cSrcweir else 869cdf0e10cSrcweir DrawText( aPtMB - aDiff, UniString::CreateFromAscii( 870cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "-90" ) ) ); 871cdf0e10cSrcweir 872cdf0e10cSrcweir DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii( 873cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "0" ) ) ); 874cdf0e10cSrcweir aDiff.X() = aFontSize.Width() * 2; 875cdf0e10cSrcweir 876cdf0e10cSrcweir if ( bPositive ) 877cdf0e10cSrcweir DrawText( aPtRB - aDiff, UniString::CreateFromAscii( 878cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "315" ) ) ); 879cdf0e10cSrcweir else 880cdf0e10cSrcweir DrawText( aPtRB - aDiff, UniString::CreateFromAscii( 881cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "-45" ) ) ); 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir /************************************************************************* 885cdf0e10cSrcweir |* 886cdf0e10cSrcweir |* Control zum Editieren von Bitmaps 887cdf0e10cSrcweir |* 888cdf0e10cSrcweir \************************************************************************/ 889*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 890cdf0e10cSrcweir 891*9b8096d0SSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible() 892*9b8096d0SSteve Yin { 893*9b8096d0SSteve Yin if(!m_xAccess.is()) 894*9b8096d0SSteve Yin { 895*9b8096d0SSteve Yin m_xAccess = m_pAccess = new SvxPixelCtlAccessible(*this); 896*9b8096d0SSteve Yin } 897*9b8096d0SSteve Yin return m_xAccess; 898*9b8096d0SSteve Yin } 899*9b8096d0SSteve Yin 900*9b8096d0SSteve Yin //Logic Pixel 901*9b8096d0SSteve Yin long SvxPixelCtl::PointToIndex(const Point &aPt) const 902*9b8096d0SSteve Yin { 903*9b8096d0SSteve Yin sal_uInt16 nX, nY; 904*9b8096d0SSteve Yin 905*9b8096d0SSteve Yin nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 906*9b8096d0SSteve Yin nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 907*9b8096d0SSteve Yin 908*9b8096d0SSteve Yin return nX + nY * nLines ; 909*9b8096d0SSteve Yin } 910*9b8096d0SSteve Yin Point SvxPixelCtl::IndexToPoint(long nIndex) const 911*9b8096d0SSteve Yin { 912*9b8096d0SSteve Yin DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index"); 913*9b8096d0SSteve Yin 914*9b8096d0SSteve Yin sal_uInt16 nXIndex = nIndex % nLines ; 915*9b8096d0SSteve Yin sal_uInt16 nYIndex = sal_uInt16(nIndex / nLines) ; 916*9b8096d0SSteve Yin 917*9b8096d0SSteve Yin Point aPtTl; 918*9b8096d0SSteve Yin aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1; 919*9b8096d0SSteve Yin aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1; 920*9b8096d0SSteve Yin 921*9b8096d0SSteve Yin return aPtTl; 922*9b8096d0SSteve Yin } 923*9b8096d0SSteve Yin long SvxPixelCtl::GetFoucsPosIndex() const 924*9b8096d0SSteve Yin { 925*9b8096d0SSteve Yin return aFocusPosition.getX() + aFocusPosition.getY() * nLines ; 926*9b8096d0SSteve Yin } 927*9b8096d0SSteve Yin long SvxPixelCtl::ShowPosition( const Point &pt) 928*9b8096d0SSteve Yin { 929*9b8096d0SSteve Yin Point aPt = PixelToLogic( pt ); 930*9b8096d0SSteve Yin 931*9b8096d0SSteve Yin sal_uInt16 nX, nY; 932*9b8096d0SSteve Yin nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 933*9b8096d0SSteve Yin nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 934*9b8096d0SSteve Yin 935*9b8096d0SSteve Yin ChangePixel( nX + nY * nLines ); 936*9b8096d0SSteve Yin 937*9b8096d0SSteve Yin //Solution:Set new focus position and repaint 938*9b8096d0SSteve Yin //Invalidate( Rectangle( aPtTl, aPtBr ) ); 939*9b8096d0SSteve Yin aFocusPosition.setX(nX); 940*9b8096d0SSteve Yin aFocusPosition.setY(nY); 941*9b8096d0SSteve Yin Invalidate(Rectangle(Point(0,0),aRectSize)); 942*9b8096d0SSteve Yin 943*9b8096d0SSteve Yin if( WINDOW_TABPAGE == GetParent()->GetType() ) 944*9b8096d0SSteve Yin ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy 945*9b8096d0SSteve Yin 946*9b8096d0SSteve Yin return GetFoucsPosIndex(); 947*9b8096d0SSteve Yin 948*9b8096d0SSteve Yin } 949*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 950cdf0e10cSrcweir SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) : 951cdf0e10cSrcweir Control ( pParent, rResId ), 952cdf0e10cSrcweir nLines ( nNumber ), 953cdf0e10cSrcweir bPaintable ( sal_True ) 954*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 955*9b8096d0SSteve Yin //Solution:Initialize it's value to Point(0,0) 956*9b8096d0SSteve Yin ,aFocusPosition(0,0) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir // SetMapMode( MAP_100TH_MM ); 959cdf0e10cSrcweir aRectSize = GetOutputSize(); 960cdf0e10cSrcweir 961cdf0e10cSrcweir SetPixelColor( Color( COL_BLACK ) ); 962cdf0e10cSrcweir SetBackgroundColor( Color( COL_WHITE ) ); 963cdf0e10cSrcweir SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() ); 964cdf0e10cSrcweir 965cdf0e10cSrcweir nSquares = nLines * nLines; 966cdf0e10cSrcweir pPixel = new sal_uInt16[ nSquares ]; 967cdf0e10cSrcweir rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16)); 968*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 969*9b8096d0SSteve Yin m_pAccess=NULL; 970cdf0e10cSrcweir } 971cdf0e10cSrcweir 972cdf0e10cSrcweir /************************************************************************* 973cdf0e10cSrcweir |* 974cdf0e10cSrcweir |* Destruktor dealociert dyn. Array 975cdf0e10cSrcweir |* 976cdf0e10cSrcweir \************************************************************************/ 977cdf0e10cSrcweir 978cdf0e10cSrcweir SvxPixelCtl::~SvxPixelCtl( ) 979cdf0e10cSrcweir { 980cdf0e10cSrcweir delete []pPixel; 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir /************************************************************************* 984cdf0e10cSrcweir |* 985cdf0e10cSrcweir |* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe 986cdf0e10cSrcweir |* 987cdf0e10cSrcweir \************************************************************************/ 988cdf0e10cSrcweir 989cdf0e10cSrcweir void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir if( *( pPixel + nPixel) == 0 ) 992cdf0e10cSrcweir *( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben 993cdf0e10cSrcweir else 994cdf0e10cSrcweir *( pPixel + nPixel) = 0; 995cdf0e10cSrcweir } 996cdf0e10cSrcweir 997cdf0e10cSrcweir /************************************************************************* 998cdf0e10cSrcweir |* 999cdf0e10cSrcweir |* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln 1000cdf0e10cSrcweir |* 1001cdf0e10cSrcweir \************************************************************************/ 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt ) 1004cdf0e10cSrcweir { 1005*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 1006*9b8096d0SSteve Yin //Point aPt = PixelToLogic( rMEvt.GetPosPixel() ); 1007*9b8096d0SSteve Yin //Point aPtTl, aPtBr; 1008*9b8096d0SSteve Yin //sal_uInt16 nX, nY; 1009cdf0e10cSrcweir 1010*9b8096d0SSteve Yin //nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 1011*9b8096d0SSteve Yin //nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 1012cdf0e10cSrcweir 1013*9b8096d0SSteve Yin //ChangePixel( nX + nY * nLines ); 1014cdf0e10cSrcweir 1015*9b8096d0SSteve Yin //aPtTl.X() = aRectSize.Width() * nX / nLines + 1; 1016*9b8096d0SSteve Yin //aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1; 1017*9b8096d0SSteve Yin //aPtTl.Y() = aRectSize.Height() * nY / nLines + 1; 1018*9b8096d0SSteve Yin //aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1; 1019cdf0e10cSrcweir 1020*9b8096d0SSteve Yin //Invalidate( Rectangle( aPtTl, aPtBr ) ); 1021cdf0e10cSrcweir 1022*9b8096d0SSteve Yin //if( WINDOW_TABPAGE == GetParent()->GetType() ) 1023*9b8096d0SSteve Yin // ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy 1024*9b8096d0SSteve Yin //Solution:Grab focus when click in window 1025*9b8096d0SSteve Yin if( !HasFocus() ) 1026*9b8096d0SSteve Yin { 1027*9b8096d0SSteve Yin GrabFocus(); 1028*9b8096d0SSteve Yin } 1029*9b8096d0SSteve Yin long nIndex = ShowPosition(rMEvt.GetPosPixel()); 1030*9b8096d0SSteve Yin 1031*9b8096d0SSteve Yin if(m_pAccess) 1032*9b8096d0SSteve Yin { 1033*9b8096d0SSteve Yin m_pAccess->NotifyChild(nIndex,sal_True,sal_True); 1034*9b8096d0SSteve Yin } 1035*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 1036cdf0e10cSrcweir } 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir /************************************************************************* 1039cdf0e10cSrcweir |* 1040cdf0e10cSrcweir |* Zeichnet das Control (Rechteck mit 9 Kreisen) 1041cdf0e10cSrcweir |* 1042cdf0e10cSrcweir \************************************************************************/ 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir void SvxPixelCtl::Paint( const Rectangle& ) 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir sal_uInt16 i, j, nTmp; 1047cdf0e10cSrcweir Point aPtTl, aPtBr; 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir if( bPaintable ) 1050cdf0e10cSrcweir { 1051cdf0e10cSrcweir // Linien Zeichnen 1052cdf0e10cSrcweir Control::SetLineColor( aLineColor ); 1053cdf0e10cSrcweir for( i = 1; i < nLines; i++) 1054cdf0e10cSrcweir { 1055cdf0e10cSrcweir // horizontal 1056cdf0e10cSrcweir nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines ); 1057cdf0e10cSrcweir DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) ); 1058cdf0e10cSrcweir // vertikal 1059cdf0e10cSrcweir nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines ); 1060cdf0e10cSrcweir DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) ); 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir // Rechtecke (Quadrate) zeichnen 1064cdf0e10cSrcweir Control::SetLineColor(); 1065cdf0e10cSrcweir sal_uInt16 nLastPixel = *pPixel ? 0 : 1; 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir for( i = 0; i < nLines; i++) 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir aPtTl.Y() = aRectSize.Height() * i / nLines + 1; 1070cdf0e10cSrcweir aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1; 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir for( j = 0; j < nLines; j++) 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir aPtTl.X() = aRectSize.Width() * j / nLines + 1; 1075cdf0e10cSrcweir aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1; 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir if ( *( pPixel + i * nLines + j ) != nLastPixel ) 1078cdf0e10cSrcweir { 1079cdf0e10cSrcweir nLastPixel = *( pPixel + i * nLines + j ); 1080cdf0e10cSrcweir // Farbe wechseln: 0 -> Hintergrundfarbe 1081cdf0e10cSrcweir SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor ); 1082cdf0e10cSrcweir } 1083cdf0e10cSrcweir DrawRect( Rectangle( aPtTl, aPtBr ) ); 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir } 1086*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 1087*9b8096d0SSteve Yin //Solution:Draw visual focus when has focus 1088*9b8096d0SSteve Yin if( HasFocus() ) 1089*9b8096d0SSteve Yin { 1090*9b8096d0SSteve Yin ShowFocus(implCalFocusRect(aFocusPosition)); 1091*9b8096d0SSteve Yin } 1092*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 1093cdf0e10cSrcweir } // bPaintable 1094cdf0e10cSrcweir else 1095cdf0e10cSrcweir { 1096cdf0e10cSrcweir SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) ); 1097cdf0e10cSrcweir Control::SetLineColor( Color( COL_LIGHTRED ) ); 1098cdf0e10cSrcweir DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) ); 1099cdf0e10cSrcweir DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) ); 1100cdf0e10cSrcweir } 1101cdf0e10cSrcweir } 1102*9b8096d0SSteve Yin // IAccessibility2 implementation 2009. ------ 1103*9b8096d0SSteve Yin //Solution:Caculate visual focus rectangle via focus position 1104*9b8096d0SSteve Yin Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition ) 1105*9b8096d0SSteve Yin { 1106*9b8096d0SSteve Yin long nLeft,nTop,nRight,nBottom; 1107*9b8096d0SSteve Yin long i,j; 1108*9b8096d0SSteve Yin i = aPosition.Y(); 1109*9b8096d0SSteve Yin j = aPosition.X(); 1110*9b8096d0SSteve Yin nLeft = aRectSize.Width() * j / nLines + 1; 1111*9b8096d0SSteve Yin nRight = aRectSize.Width() * (j + 1) / nLines - 1; 1112*9b8096d0SSteve Yin nTop = aRectSize.Height() * i / nLines + 1; 1113*9b8096d0SSteve Yin nBottom = aRectSize.Height() * (i + 1) / nLines - 1; 1114*9b8096d0SSteve Yin return Rectangle(nLeft,nTop,nRight,nBottom); 1115*9b8096d0SSteve Yin } 1116*9b8096d0SSteve Yin 1117*9b8096d0SSteve Yin //Solution:Keyboard fucntion 1118*9b8096d0SSteve Yin void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) 1119*9b8096d0SSteve Yin { 1120*9b8096d0SSteve Yin KeyCode aKeyCode = rKEvt.GetKeyCode(); 1121*9b8096d0SSteve Yin sal_uInt16 nCode = aKeyCode.GetCode(); 1122*9b8096d0SSteve Yin sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2(); 1123*9b8096d0SSteve Yin 1124*9b8096d0SSteve Yin if( !bIsMod ) 1125*9b8096d0SSteve Yin { 1126*9b8096d0SSteve Yin Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1, 1127*9b8096d0SSteve Yin aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1 1128*9b8096d0SSteve Yin ); 1129*9b8096d0SSteve Yin Size mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2); 1130*9b8096d0SSteve Yin Rectangle mRepaintRect( pRepaintPoint, mRepaintSize ); 1131*9b8096d0SSteve Yin sal_Bool bFocusPosChanged=sal_False; 1132*9b8096d0SSteve Yin switch(nCode) 1133*9b8096d0SSteve Yin { 1134*9b8096d0SSteve Yin case KEY_LEFT: 1135*9b8096d0SSteve Yin if((aFocusPosition.getX() >= 1)) 1136*9b8096d0SSteve Yin { 1137*9b8096d0SSteve Yin aFocusPosition.setX( aFocusPosition.getX() - 1 ); 1138*9b8096d0SSteve Yin Invalidate(mRepaintRect); 1139*9b8096d0SSteve Yin bFocusPosChanged=sal_True; 1140*9b8096d0SSteve Yin } 1141*9b8096d0SSteve Yin break; 1142*9b8096d0SSteve Yin case KEY_RIGHT: 1143*9b8096d0SSteve Yin if( aFocusPosition.getX() < (nLines - 1) ) 1144*9b8096d0SSteve Yin { 1145*9b8096d0SSteve Yin aFocusPosition.setX( aFocusPosition.getX() + 1 ); 1146*9b8096d0SSteve Yin Invalidate(mRepaintRect); 1147*9b8096d0SSteve Yin bFocusPosChanged=sal_True; 1148*9b8096d0SSteve Yin } 1149*9b8096d0SSteve Yin break; 1150*9b8096d0SSteve Yin case KEY_UP: 1151*9b8096d0SSteve Yin if((aFocusPosition.getY() >= 1)) 1152*9b8096d0SSteve Yin { 1153*9b8096d0SSteve Yin aFocusPosition.setY( aFocusPosition.getY() - 1 ); 1154*9b8096d0SSteve Yin Invalidate(mRepaintRect); 1155*9b8096d0SSteve Yin bFocusPosChanged=sal_True; 1156*9b8096d0SSteve Yin } 1157*9b8096d0SSteve Yin break; 1158*9b8096d0SSteve Yin case KEY_DOWN: 1159*9b8096d0SSteve Yin if( aFocusPosition.getY() < ( nLines - 1 ) ) 1160*9b8096d0SSteve Yin { 1161*9b8096d0SSteve Yin aFocusPosition.setY( aFocusPosition.getY() + 1 ); 1162*9b8096d0SSteve Yin Invalidate(mRepaintRect); 1163*9b8096d0SSteve Yin bFocusPosChanged=sal_True; 1164*9b8096d0SSteve Yin } 1165*9b8096d0SSteve Yin break; 1166*9b8096d0SSteve Yin case KEY_SPACE: 1167*9b8096d0SSteve Yin ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) ); 1168*9b8096d0SSteve Yin Invalidate( implCalFocusRect(aFocusPosition) ); 1169*9b8096d0SSteve Yin break; 1170*9b8096d0SSteve Yin default: 1171*9b8096d0SSteve Yin Control::KeyInput( rKEvt ); 1172*9b8096d0SSteve Yin return; 1173*9b8096d0SSteve Yin } 1174*9b8096d0SSteve Yin if(m_xAccess.is()) 1175*9b8096d0SSteve Yin { 1176*9b8096d0SSteve Yin long nIndex = GetFoucsPosIndex(); 1177*9b8096d0SSteve Yin switch(nCode) 1178*9b8096d0SSteve Yin { 1179*9b8096d0SSteve Yin case KEY_LEFT: 1180*9b8096d0SSteve Yin case KEY_RIGHT: 1181*9b8096d0SSteve Yin case KEY_UP: 1182*9b8096d0SSteve Yin case KEY_DOWN: 1183*9b8096d0SSteve Yin if (bFocusPosChanged) 1184*9b8096d0SSteve Yin { 1185*9b8096d0SSteve Yin m_pAccess->NotifyChild(nIndex,sal_False,sal_False); 1186*9b8096d0SSteve Yin } 1187*9b8096d0SSteve Yin break; 1188*9b8096d0SSteve Yin case KEY_SPACE: 1189*9b8096d0SSteve Yin m_pAccess->NotifyChild(nIndex,sal_False,sal_True); 1190*9b8096d0SSteve Yin break; 1191*9b8096d0SSteve Yin default: 1192*9b8096d0SSteve Yin break; 1193*9b8096d0SSteve Yin } 1194*9b8096d0SSteve Yin } 1195*9b8096d0SSteve Yin } 1196*9b8096d0SSteve Yin else 1197*9b8096d0SSteve Yin { 1198*9b8096d0SSteve Yin Control::KeyInput( rKEvt ); 1199*9b8096d0SSteve Yin } 1200*9b8096d0SSteve Yin } 1201*9b8096d0SSteve Yin 1202*9b8096d0SSteve Yin //Draw focus when get focus 1203*9b8096d0SSteve Yin void SvxPixelCtl::GetFocus() 1204*9b8096d0SSteve Yin { 1205*9b8096d0SSteve Yin Invalidate(implCalFocusRect(aFocusPosition)); 1206*9b8096d0SSteve Yin 1207*9b8096d0SSteve Yin if(m_pAccess) 1208*9b8096d0SSteve Yin { 1209*9b8096d0SSteve Yin m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False); 1210*9b8096d0SSteve Yin } 1211*9b8096d0SSteve Yin 1212*9b8096d0SSteve Yin Control::GetFocus(); 1213*9b8096d0SSteve Yin } 1214*9b8096d0SSteve Yin 1215*9b8096d0SSteve Yin //Hide focus when lose focus 1216*9b8096d0SSteve Yin void SvxPixelCtl::LoseFocus() 1217*9b8096d0SSteve Yin { 1218*9b8096d0SSteve Yin HideFocus(); 1219*9b8096d0SSteve Yin if (m_pAccess) 1220*9b8096d0SSteve Yin { 1221*9b8096d0SSteve Yin m_pAccess->LoseFocus(); 1222*9b8096d0SSteve Yin } 1223*9b8096d0SSteve Yin Control::LoseFocus(); 1224*9b8096d0SSteve Yin } 1225*9b8096d0SSteve Yin // ------ IAccessibility2 implementation 2009. 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir /************************************************************************* 1228cdf0e10cSrcweir |* 1229cdf0e10cSrcweir |* 1230cdf0e10cSrcweir |* 1231cdf0e10cSrcweir \************************************************************************/ 1232cdf0e10cSrcweir 123370d3707aSArmin Le Grand void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx ) 1234cdf0e10cSrcweir { 123570d3707aSArmin Le Grand BitmapColor aBack; 123670d3707aSArmin Le Grand BitmapColor aFront; 123770d3707aSArmin Le Grand 123870d3707aSArmin Le Grand if(isHistorical8x8(rBitmapEx, aBack, aFront)) 1239cdf0e10cSrcweir { 124070d3707aSArmin Le Grand Bitmap aBitmap(rBitmapEx.GetBitmap()); 124170d3707aSArmin Le Grand BitmapReadAccess* pRead = aBitmap.AcquireReadAccess(); 1242cdf0e10cSrcweir 124370d3707aSArmin Le Grand aBackgroundColor = aBack; 124470d3707aSArmin Le Grand aPixelColor = aFront; 1245cdf0e10cSrcweir 124670d3707aSArmin Le Grand for(sal_uInt16 i(0); i < nSquares; i++) 124770d3707aSArmin Le Grand { 124870d3707aSArmin Le Grand const BitmapColor aColor(pRead->GetColor(i/8, i%8)); 124970d3707aSArmin Le Grand 125070d3707aSArmin Le Grand if(aColor == aBack) 125170d3707aSArmin Le Grand { 125270d3707aSArmin Le Grand *( pPixel + i ) = 0; 125370d3707aSArmin Le Grand } 125470d3707aSArmin Le Grand else 125570d3707aSArmin Le Grand { 125670d3707aSArmin Le Grand *( pPixel + i ) = 1; 125770d3707aSArmin Le Grand } 125870d3707aSArmin Le Grand } 125970d3707aSArmin Le Grand 126070d3707aSArmin Le Grand aBitmap.ReleaseAccess(pRead); 1261cdf0e10cSrcweir } 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir /************************************************************************* 1265cdf0e10cSrcweir |* 1266cdf0e10cSrcweir |* Gibt ein bestimmtes Pixel zurueck 1267cdf0e10cSrcweir |* 1268cdf0e10cSrcweir \************************************************************************/ 1269cdf0e10cSrcweir 1270cdf0e10cSrcweir sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) 1271cdf0e10cSrcweir { 1272cdf0e10cSrcweir return( *( pPixel + nPixel ) ); 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir /************************************************************************* 1276cdf0e10cSrcweir |* 1277cdf0e10cSrcweir |* Bewirkt den Ursprungszustand des Controls 1278cdf0e10cSrcweir |* 1279cdf0e10cSrcweir \************************************************************************/ 1280cdf0e10cSrcweir 1281cdf0e10cSrcweir void SvxPixelCtl::Reset() 1282cdf0e10cSrcweir { 1283cdf0e10cSrcweir // clear pixel area 1284cdf0e10cSrcweir rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16)); 1285cdf0e10cSrcweir Invalidate(); 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir /************************************************************************* 1289cdf0e10cSrcweir |* 1290cdf0e10cSrcweir |* Ctor: BitmapCtl fuer SvxPixelCtl 1291cdf0e10cSrcweir |* 1292cdf0e10cSrcweir \************************************************************************/ 1293cdf0e10cSrcweir 1294cdf0e10cSrcweir SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize ) 1295cdf0e10cSrcweir { 1296cdf0e10cSrcweir aSize = rSize; 1297cdf0e10cSrcweir // aVD.SetOutputSizePixel( aSize ); 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir /************************************************************************* 1301cdf0e10cSrcweir |* 1302cdf0e10cSrcweir |* Dtor 1303cdf0e10cSrcweir |* 1304cdf0e10cSrcweir \************************************************************************/ 1305cdf0e10cSrcweir 1306cdf0e10cSrcweir SvxBitmapCtl::~SvxBitmapCtl() 1307cdf0e10cSrcweir { 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir 1310cdf0e10cSrcweir /************************************************************************* 1311cdf0e10cSrcweir |* 1312cdf0e10cSrcweir |* BitmapCtl: Gibt die Bitmap zurueck 1313cdf0e10cSrcweir |* 1314cdf0e10cSrcweir \************************************************************************/ 1315cdf0e10cSrcweir 131670d3707aSArmin Le Grand BitmapEx SvxBitmapCtl::GetBitmapEx() 1317cdf0e10cSrcweir { 131870d3707aSArmin Le Grand const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor)); 1319cdf0e10cSrcweir 132070d3707aSArmin Le Grand return BitmapEx(aRetval); 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir /************************************************************************* 1324cdf0e10cSrcweir |* 1325cdf0e10cSrcweir |* Fuellt die Listbox mit Farben und Strings 1326cdf0e10cSrcweir |* 1327cdf0e10cSrcweir \************************************************************************/ 1328cdf0e10cSrcweir 1329cdf0e10cSrcweir void ColorLB::Fill( const XColorTable* pColorTab ) 1330cdf0e10cSrcweir { 1331cdf0e10cSrcweir long nCount = pColorTab->Count(); 1332cdf0e10cSrcweir XColorEntry* pEntry; 1333cdf0e10cSrcweir SetUpdateMode( sal_False ); 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1336cdf0e10cSrcweir { 1337cdf0e10cSrcweir pEntry = pColorTab->GetColor( i ); 1338cdf0e10cSrcweir InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1339cdf0e10cSrcweir } 1340cdf0e10cSrcweir SetUpdateMode( sal_True ); 1341cdf0e10cSrcweir } 1342cdf0e10cSrcweir 1343cdf0e10cSrcweir /************************************************************************/ 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir void ColorLB::Append( XColorEntry* pEntry, Bitmap* ) 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1348cdf0e10cSrcweir } 1349cdf0e10cSrcweir 1350cdf0e10cSrcweir /************************************************************************/ 1351cdf0e10cSrcweir 1352cdf0e10cSrcweir void ColorLB::Modify( XColorEntry* pEntry, sal_uInt16 nPos, Bitmap* ) 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir RemoveEntry( nPos ); 1355cdf0e10cSrcweir InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos ); 1356cdf0e10cSrcweir } 1357cdf0e10cSrcweir 1358cdf0e10cSrcweir /************************************************************************* 1359cdf0e10cSrcweir |* 1360cdf0e10cSrcweir |* Fuellt die Listbox mit Farben und Strings 1361cdf0e10cSrcweir |* 1362cdf0e10cSrcweir \************************************************************************/ 1363cdf0e10cSrcweir 1364cdf0e10cSrcweir void FillAttrLB::Fill( const XColorTable* pColorTab ) 1365cdf0e10cSrcweir { 1366cdf0e10cSrcweir long nCount = pColorTab->Count(); 1367cdf0e10cSrcweir XColorEntry* pEntry; 1368cdf0e10cSrcweir SetUpdateMode( sal_False ); 1369cdf0e10cSrcweir 1370cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir pEntry = pColorTab->GetColor( i ); 1373cdf0e10cSrcweir InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir SetUpdateMode( sal_True ); 1376cdf0e10cSrcweir } 1377cdf0e10cSrcweir 1378cdf0e10cSrcweir /************************************************************************* 1379cdf0e10cSrcweir |* 1380cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1381cdf0e10cSrcweir |* 1382cdf0e10cSrcweir \************************************************************************/ 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir HatchingLB::HatchingLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ ) 1385cdf0e10cSrcweir : ListBox( pParent, Id ), 1386cdf0e10cSrcweir mpList ( NULL ), 1387cdf0e10cSrcweir mbUserDraw( bUserDraw ) 1388cdf0e10cSrcweir { 1389cdf0e10cSrcweir EnableUserDraw( mbUserDraw ); 1390cdf0e10cSrcweir } 1391cdf0e10cSrcweir 1392cdf0e10cSrcweir HatchingLB::HatchingLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ ) 1393cdf0e10cSrcweir : ListBox( pParent, aWB ), 1394cdf0e10cSrcweir mpList ( NULL ), 1395cdf0e10cSrcweir mbUserDraw( bUserDraw ) 1396cdf0e10cSrcweir { 1397cdf0e10cSrcweir EnableUserDraw( mbUserDraw ); 1398cdf0e10cSrcweir } 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir void HatchingLB::Fill( const XHatchList* pList ) 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir mpList = (XHatchList*)pList; 1403cdf0e10cSrcweir XHatchEntry* pEntry; 1404cdf0e10cSrcweir long nCount = pList->Count(); 1405cdf0e10cSrcweir 1406cdf0e10cSrcweir SetUpdateMode( sal_False ); 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir if( mbUserDraw ) 1409cdf0e10cSrcweir { 1410cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1411cdf0e10cSrcweir InsertEntry( pList->GetHatch( i )->GetName() ); 1412cdf0e10cSrcweir } 1413cdf0e10cSrcweir else 1414cdf0e10cSrcweir { 1415cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1416cdf0e10cSrcweir { 1417cdf0e10cSrcweir pEntry = pList->GetHatch( i ); 1418cdf0e10cSrcweir Bitmap* pBitmap = pList->GetBitmap( i ); 1419cdf0e10cSrcweir if( pBitmap ) 1420cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBitmap ); 1421cdf0e10cSrcweir else 1422cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1423cdf0e10cSrcweir } 1424cdf0e10cSrcweir } 1425cdf0e10cSrcweir 1426cdf0e10cSrcweir SetUpdateMode( sal_True ); 1427cdf0e10cSrcweir } 1428cdf0e10cSrcweir 1429cdf0e10cSrcweir void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir if( mpList != NULL ) 1432cdf0e10cSrcweir { 1433cdf0e10cSrcweir // Draw gradient with borderrectangle 1434cdf0e10cSrcweir const Rectangle& rDrawRect = rUDEvt.GetRect(); 1435cdf0e10cSrcweir Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 ); 1436cdf0e10cSrcweir 1437cdf0e10cSrcweir sal_Int32 nId = rUDEvt.GetItemId(); 1438cdf0e10cSrcweir if( nId >= 0 && nId <= mpList->Count() ) 1439cdf0e10cSrcweir { 1440cdf0e10cSrcweir OutputDevice* pDevice = rUDEvt.GetDevice(); 1441cdf0e10cSrcweir 1442cdf0e10cSrcweir sal_uIntPtr nOldDrawMode = pDevice->GetDrawMode(); 1443cdf0e10cSrcweir pDevice->SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR ); 1444cdf0e10cSrcweir 1445cdf0e10cSrcweir XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch(); 1446cdf0e10cSrcweir MapMode aMode( MAP_100TH_MM ); 1447cdf0e10cSrcweir Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(), 1448cdf0e10cSrcweir rXHatch.GetColor(), 1449cdf0e10cSrcweir rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(), 1450cdf0e10cSrcweir (sal_uInt16)rXHatch.GetAngle() ); 1451cdf0e10cSrcweir const Polygon aPolygon( aRect ); 1452cdf0e10cSrcweir const PolyPolygon aPolypoly( aPolygon ); 1453cdf0e10cSrcweir pDevice->DrawHatch( aPolypoly, aHatch ); 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir pDevice->SetLineColor( COL_BLACK ); 1456cdf0e10cSrcweir pDevice->SetFillColor(); 1457cdf0e10cSrcweir pDevice->DrawRect( aRect ); 1458cdf0e10cSrcweir 1459cdf0e10cSrcweir pDevice->SetDrawMode( nOldDrawMode ); 1460cdf0e10cSrcweir 1461cdf0e10cSrcweir // Draw name 1462cdf0e10cSrcweir pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() ); 1463cdf0e10cSrcweir } 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir } 1466cdf0e10cSrcweir 1467cdf0e10cSrcweir /************************************************************************/ 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp ) 1470cdf0e10cSrcweir { 1471cdf0e10cSrcweir if( pBmp ) 1472cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp ); 1473cdf0e10cSrcweir else 1474cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1475cdf0e10cSrcweir } 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir /************************************************************************/ 1478cdf0e10cSrcweir 1479cdf0e10cSrcweir void HatchingLB::Modify( XHatchEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp ) 1480cdf0e10cSrcweir { 1481cdf0e10cSrcweir RemoveEntry( nPos ); 1482cdf0e10cSrcweir 1483cdf0e10cSrcweir if( pBmp ) 1484cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp, nPos ); 1485cdf0e10cSrcweir else 1486cdf0e10cSrcweir InsertEntry( pEntry->GetName(), nPos ); 1487cdf0e10cSrcweir } 1488cdf0e10cSrcweir 1489cdf0e10cSrcweir /************************************************************************/ 1490cdf0e10cSrcweir 1491cdf0e10cSrcweir void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr, 1492cdf0e10cSrcweir const XHatch& rHatch, sal_uInt16 nDist ) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir long nCount = pList->Count(); 1495cdf0e10cSrcweir XHatchEntry* pEntry; 1496cdf0e10cSrcweir sal_Bool bFound = sal_False; 1497cdf0e10cSrcweir String aStr; 1498cdf0e10cSrcweir 1499cdf0e10cSrcweir long i; 1500cdf0e10cSrcweir for( i = 0; i < nCount && !bFound; i++ ) 1501cdf0e10cSrcweir { 1502cdf0e10cSrcweir pEntry = pList->GetHatch( i ); 1503cdf0e10cSrcweir 1504cdf0e10cSrcweir aStr = pEntry->GetName(); 1505cdf0e10cSrcweir 1506cdf0e10cSrcweir if( rStr == aStr && rHatch == pEntry->GetHatch() ) 1507cdf0e10cSrcweir bFound = sal_True; 1508cdf0e10cSrcweir } 1509cdf0e10cSrcweir if( bFound ) 1510cdf0e10cSrcweir SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1511cdf0e10cSrcweir } 1512cdf0e10cSrcweir 1513cdf0e10cSrcweir /************************************************************************* 1514cdf0e10cSrcweir |* 1515cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1516cdf0e10cSrcweir |* 1517cdf0e10cSrcweir \************************************************************************/ 1518cdf0e10cSrcweir 1519cdf0e10cSrcweir void FillAttrLB::Fill( const XHatchList* pList ) 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir long nCount = pList->Count(); 1522cdf0e10cSrcweir XHatchEntry* pEntry; 1523cdf0e10cSrcweir ListBox::SetUpdateMode( sal_False ); 1524cdf0e10cSrcweir 1525cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir pEntry = pList->GetHatch( i ); 1528cdf0e10cSrcweir Bitmap* pBitmap = pList->GetBitmap( i ); 1529cdf0e10cSrcweir if( pBitmap ) 1530cdf0e10cSrcweir ListBox::InsertEntry( pEntry->GetName(), *pBitmap ); 1531cdf0e10cSrcweir else 1532cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir ListBox::SetUpdateMode( sal_True ); 1535cdf0e10cSrcweir } 1536cdf0e10cSrcweir 1537cdf0e10cSrcweir /************************************************************************* 1538cdf0e10cSrcweir |* 1539cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1540cdf0e10cSrcweir |* 1541cdf0e10cSrcweir \************************************************************************/ 1542cdf0e10cSrcweir 1543cdf0e10cSrcweir GradientLB::GradientLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ ) 1544cdf0e10cSrcweir : ListBox( pParent, Id ), 1545cdf0e10cSrcweir mpList(NULL), 1546cdf0e10cSrcweir mbUserDraw( bUserDraw ) 1547cdf0e10cSrcweir { 1548cdf0e10cSrcweir EnableUserDraw( mbUserDraw); 1549cdf0e10cSrcweir } 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir GradientLB::GradientLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ ) 1552cdf0e10cSrcweir : ListBox( pParent, aWB ), 1553cdf0e10cSrcweir mpList(NULL), 1554cdf0e10cSrcweir mbUserDraw( bUserDraw ) 1555cdf0e10cSrcweir { 1556cdf0e10cSrcweir EnableUserDraw( mbUserDraw ); 1557cdf0e10cSrcweir } 1558cdf0e10cSrcweir 1559cdf0e10cSrcweir void GradientLB::Fill( const XGradientList* pList ) 1560cdf0e10cSrcweir { 1561cdf0e10cSrcweir mpList = (XGradientList*)pList; 1562cdf0e10cSrcweir XGradientEntry* pEntry; 1563cdf0e10cSrcweir long nCount = pList->Count(); 1564cdf0e10cSrcweir 1565cdf0e10cSrcweir SetUpdateMode( sal_False ); 1566cdf0e10cSrcweir 1567cdf0e10cSrcweir if( mbUserDraw ) 1568cdf0e10cSrcweir { 1569cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1570cdf0e10cSrcweir InsertEntry( pList->GetGradient( i )->GetName() ); 1571cdf0e10cSrcweir } 1572cdf0e10cSrcweir else 1573cdf0e10cSrcweir { 1574cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1575cdf0e10cSrcweir { 1576cdf0e10cSrcweir pEntry = pList->GetGradient( i ); 1577cdf0e10cSrcweir Bitmap* pBitmap = pList->GetBitmap( i ); 1578cdf0e10cSrcweir if( pBitmap ) 1579cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBitmap ); 1580cdf0e10cSrcweir else 1581cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1582cdf0e10cSrcweir } 1583cdf0e10cSrcweir } 1584cdf0e10cSrcweir 1585cdf0e10cSrcweir SetUpdateMode( sal_True ); 1586cdf0e10cSrcweir } 1587cdf0e10cSrcweir 1588cdf0e10cSrcweir void GradientLB::UserDraw( const UserDrawEvent& rUDEvt ) 1589cdf0e10cSrcweir { 1590cdf0e10cSrcweir if( mpList != NULL ) 1591cdf0e10cSrcweir { 1592cdf0e10cSrcweir // Draw gradient with borderrectangle 1593cdf0e10cSrcweir const Rectangle& rDrawRect = rUDEvt.GetRect(); 1594cdf0e10cSrcweir Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 ); 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir sal_Int32 nId = rUDEvt.GetItemId(); 1597cdf0e10cSrcweir if( nId >= 0 && nId <= mpList->Count() ) 1598cdf0e10cSrcweir { 1599cdf0e10cSrcweir OutputDevice* pDevice = rUDEvt.GetDevice(); 1600cdf0e10cSrcweir 1601cdf0e10cSrcweir XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient(); 1602cdf0e10cSrcweir Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() ); 1603cdf0e10cSrcweir aGradient.SetAngle( (sal_uInt16)rXGrad.GetAngle() ); 1604cdf0e10cSrcweir aGradient.SetBorder( rXGrad.GetBorder() ); 1605cdf0e10cSrcweir aGradient.SetOfsX( rXGrad.GetXOffset() ); 1606cdf0e10cSrcweir aGradient.SetOfsY( rXGrad.GetYOffset() ); 1607cdf0e10cSrcweir aGradient.SetStartIntensity( rXGrad.GetStartIntens() ); 1608cdf0e10cSrcweir aGradient.SetEndIntensity( rXGrad.GetEndIntens() ); 1609cdf0e10cSrcweir aGradient.SetSteps( 255 ); 1610cdf0e10cSrcweir 1611cdf0e10cSrcweir // #i76307# always paint the preview in LTR, because this is what the document does 1612cdf0e10cSrcweir Window* pWin = dynamic_cast<Window*>(pDevice); 1613cdf0e10cSrcweir if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL()) 1614cdf0e10cSrcweir { 1615cdf0e10cSrcweir long nWidth = pDevice->GetOutputSize().Width(); 1616cdf0e10cSrcweir 1617cdf0e10cSrcweir pWin->EnableRTL( sal_False ); 1618cdf0e10cSrcweir 1619cdf0e10cSrcweir Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ), 1620cdf0e10cSrcweir aRect.GetSize() ); 1621cdf0e10cSrcweir 1622cdf0e10cSrcweir pDevice->DrawGradient( aMirrorRect, aGradient ); 1623cdf0e10cSrcweir 1624cdf0e10cSrcweir pWin->EnableRTL( sal_True ); 1625cdf0e10cSrcweir } 1626cdf0e10cSrcweir else 1627cdf0e10cSrcweir pDevice->DrawGradient( aRect, aGradient ); 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir pDevice->SetLineColor( COL_BLACK ); 1630cdf0e10cSrcweir pDevice->SetFillColor(); 1631cdf0e10cSrcweir pDevice->DrawRect( aRect ); 1632cdf0e10cSrcweir 1633cdf0e10cSrcweir // Draw name 1634cdf0e10cSrcweir pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() ); 1635cdf0e10cSrcweir } 1636cdf0e10cSrcweir } 1637cdf0e10cSrcweir } 1638cdf0e10cSrcweir 1639cdf0e10cSrcweir /************************************************************************/ 1640cdf0e10cSrcweir 1641cdf0e10cSrcweir void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp ) 1642cdf0e10cSrcweir { 1643cdf0e10cSrcweir if( pBmp ) 1644cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp ); 1645cdf0e10cSrcweir else 1646cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1647cdf0e10cSrcweir } 1648cdf0e10cSrcweir 1649cdf0e10cSrcweir /************************************************************************/ 1650cdf0e10cSrcweir 1651cdf0e10cSrcweir void GradientLB::Modify( XGradientEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp ) 1652cdf0e10cSrcweir { 1653cdf0e10cSrcweir RemoveEntry( nPos ); 1654cdf0e10cSrcweir 1655cdf0e10cSrcweir if( pBmp ) 1656cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp, nPos ); 1657cdf0e10cSrcweir else 1658cdf0e10cSrcweir InsertEntry( pEntry->GetName(), nPos ); 1659cdf0e10cSrcweir } 1660cdf0e10cSrcweir 1661cdf0e10cSrcweir /************************************************************************/ 1662cdf0e10cSrcweir 1663cdf0e10cSrcweir void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr, 1664cdf0e10cSrcweir const XGradient& rGradient, sal_uInt16 nDist ) 1665cdf0e10cSrcweir { 1666cdf0e10cSrcweir long nCount = pList->Count(); 1667cdf0e10cSrcweir XGradientEntry* pEntry; 1668cdf0e10cSrcweir sal_Bool bFound = sal_False; 1669cdf0e10cSrcweir String aStr; 1670cdf0e10cSrcweir 1671cdf0e10cSrcweir long i; 1672cdf0e10cSrcweir for( i = 0; i < nCount && !bFound; i++ ) 1673cdf0e10cSrcweir { 1674cdf0e10cSrcweir pEntry = pList->GetGradient( i ); 1675cdf0e10cSrcweir 1676cdf0e10cSrcweir aStr = pEntry->GetName(); 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir if( rStr == aStr && rGradient == pEntry->GetGradient() ) 1679cdf0e10cSrcweir bFound = sal_True; 1680cdf0e10cSrcweir } 1681cdf0e10cSrcweir if( bFound ) 1682cdf0e10cSrcweir SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1683cdf0e10cSrcweir } 1684cdf0e10cSrcweir 1685cdf0e10cSrcweir /************************************************************************* 1686cdf0e10cSrcweir |* 1687cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1688cdf0e10cSrcweir |* 1689cdf0e10cSrcweir \************************************************************************/ 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir void FillAttrLB::Fill( const XGradientList* pList ) 1692cdf0e10cSrcweir { 1693cdf0e10cSrcweir long nCount = pList->Count(); 1694cdf0e10cSrcweir XGradientEntry* pEntry; 1695cdf0e10cSrcweir ListBox::SetUpdateMode( sal_False ); 1696cdf0e10cSrcweir 1697cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 1698cdf0e10cSrcweir { 1699cdf0e10cSrcweir pEntry = pList->GetGradient( i ); 1700cdf0e10cSrcweir Bitmap* pBitmap = pList->GetBitmap( i ); 1701cdf0e10cSrcweir if( pBitmap ) 1702cdf0e10cSrcweir ListBox::InsertEntry( pEntry->GetName(), *pBitmap ); 1703cdf0e10cSrcweir else 1704cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 1705cdf0e10cSrcweir } 1706cdf0e10cSrcweir ListBox::SetUpdateMode( sal_True ); 1707cdf0e10cSrcweir } 1708cdf0e10cSrcweir 1709cdf0e10cSrcweir /************************************************************************* 1710cdf0e10cSrcweir |* 1711cdf0e10cSrcweir |* Konstruktor von BitmapLB 1712cdf0e10cSrcweir |* 1713cdf0e10cSrcweir \************************************************************************/ 1714cdf0e10cSrcweir 171570d3707aSArmin Le Grand BitmapLB::BitmapLB(Window* pParent, ResId Id, bool bUserDraw /*= false*/ ) 1716cdf0e10cSrcweir : ListBox(pParent, Id), 171770d3707aSArmin Le Grand maVD(), 171870d3707aSArmin Le Grand maBitmapEx(), 1719cdf0e10cSrcweir mpList(NULL), 1720cdf0e10cSrcweir mbUserDraw(bUserDraw) 1721cdf0e10cSrcweir { 172270d3707aSArmin Le Grand maVD.SetOutputSizePixel(Size(32, 16)); 1723cdf0e10cSrcweir EnableUserDraw(mbUserDraw); 1724cdf0e10cSrcweir } 1725cdf0e10cSrcweir 1726cdf0e10cSrcweir /************************************************************************/ 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir void BitmapLB::SetVirtualDevice() 1729cdf0e10cSrcweir { 173070d3707aSArmin Le Grand if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1731cdf0e10cSrcweir { 173270d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 0), Size(32, 16), maBitmapEx); 1733cdf0e10cSrcweir } 1734cdf0e10cSrcweir else 1735cdf0e10cSrcweir { 173670d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 0), maBitmapEx); 173770d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(8, 0), maBitmapEx); 173870d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(16, 0), maBitmapEx); 173970d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(24, 0), maBitmapEx); 174070d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 8), maBitmapEx); 174170d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(8, 8), maBitmapEx); 174270d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(16, 8), maBitmapEx); 174370d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(24, 8), maBitmapEx); 1744cdf0e10cSrcweir } 1745cdf0e10cSrcweir } 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir /************************************************************************/ 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir void BitmapLB::Fill(const XBitmapList* pList) 1750cdf0e10cSrcweir { 1751cdf0e10cSrcweir mpList = (XBitmapList*)pList; 1752cdf0e10cSrcweir XBitmapEntry* pEntry; 175370d3707aSArmin Le Grand const long nCount(pList->Count()); 1754cdf0e10cSrcweir 175570d3707aSArmin Le Grand SetUpdateMode(false); 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir if(mbUserDraw) 1758cdf0e10cSrcweir { 175970d3707aSArmin Le Grand for(long i(0); i < nCount; i++) 176070d3707aSArmin Le Grand { 1761cdf0e10cSrcweir InsertEntry(pList->GetBitmap(i)->GetName()); 1762cdf0e10cSrcweir } 176370d3707aSArmin Le Grand } 1764cdf0e10cSrcweir else 1765cdf0e10cSrcweir { 176670d3707aSArmin Le Grand for(long i(0); i < nCount; i++) 1767cdf0e10cSrcweir { 1768cdf0e10cSrcweir pEntry = pList->GetBitmap(i); 176970d3707aSArmin Le Grand maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1770cdf0e10cSrcweir SetVirtualDevice(); 177170d3707aSArmin Le Grand InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12))); 1772cdf0e10cSrcweir } 1773cdf0e10cSrcweir } 1774cdf0e10cSrcweir 177570d3707aSArmin Le Grand SetUpdateMode(true); 1776cdf0e10cSrcweir } 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir void BitmapLB::UserDraw(const UserDrawEvent& rUDEvt) 1779cdf0e10cSrcweir { 178070d3707aSArmin Le Grand if(mpList) 1781cdf0e10cSrcweir { 1782cdf0e10cSrcweir // Draw bitmap 1783cdf0e10cSrcweir const Rectangle& rDrawRect = rUDEvt.GetRect(); 178470d3707aSArmin Le Grand const Rectangle aRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nLeft + 33, rDrawRect.nBottom - 1); 178570d3707aSArmin Le Grand const sal_Int32 nId(rUDEvt.GetItemId()); 1786cdf0e10cSrcweir 1787cdf0e10cSrcweir if(nId >= 0 && nId <= mpList->Count()) 1788cdf0e10cSrcweir { 178970d3707aSArmin Le Grand const Rectangle aClipRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nRight - 1, rDrawRect.nBottom - 1); 1790cdf0e10cSrcweir OutputDevice* pDevice = rUDEvt.GetDevice(); 1791cdf0e10cSrcweir pDevice->SetClipRegion(Region(aClipRect)); 179270d3707aSArmin Le Grand maBitmapEx = mpList->GetBitmap(nId)->GetGraphicObject().GetGraphic().GetBitmapEx(); 1793cdf0e10cSrcweir long nPosBaseX = aRect.nLeft; 1794cdf0e10cSrcweir long nPosBaseY = aRect.nTop; 1795cdf0e10cSrcweir 179670d3707aSArmin Le Grand if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1797cdf0e10cSrcweir { 179870d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX, nPosBaseY), Size(32, 16), maBitmapEx); 1799cdf0e10cSrcweir } 1800cdf0e10cSrcweir else 1801cdf0e10cSrcweir { 180270d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+0 ), maBitmapEx); 180370d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+0 ), maBitmapEx); 180470d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+0 ), maBitmapEx); 180570d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+0 ), maBitmapEx); 180670d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+8 ), maBitmapEx); 180770d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+8 ), maBitmapEx); 180870d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+8 ), maBitmapEx); 180970d3707aSArmin Le Grand pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+8 ), maBitmapEx); 1810cdf0e10cSrcweir } 1811cdf0e10cSrcweir 1812cdf0e10cSrcweir pDevice->SetClipRegion(); 1813cdf0e10cSrcweir 1814cdf0e10cSrcweir // Draw name 1815cdf0e10cSrcweir pDevice->DrawText(Point(aRect.nRight + 7, aRect.nTop - 1), mpList->GetBitmap(nId)->GetName()); 1816cdf0e10cSrcweir } 1817cdf0e10cSrcweir } 1818cdf0e10cSrcweir } 1819cdf0e10cSrcweir 1820cdf0e10cSrcweir /************************************************************************/ 1821cdf0e10cSrcweir 182270d3707aSArmin Le Grand void BitmapLB::Append(XBitmapEntry* pEntry, BitmapEx* pBmpEx) 1823cdf0e10cSrcweir { 182470d3707aSArmin Le Grand if(pBmpEx) 1825cdf0e10cSrcweir { 182670d3707aSArmin Le Grand maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1827cdf0e10cSrcweir SetVirtualDevice(); 182870d3707aSArmin Le Grand InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12))); 1829cdf0e10cSrcweir } 1830cdf0e10cSrcweir else 183170d3707aSArmin Le Grand { 1832cdf0e10cSrcweir InsertEntry(pEntry->GetName()); 1833cdf0e10cSrcweir } 183470d3707aSArmin Le Grand } 1835cdf0e10cSrcweir 1836cdf0e10cSrcweir /************************************************************************/ 1837cdf0e10cSrcweir 183870d3707aSArmin Le Grand void BitmapLB::Modify(XBitmapEntry* pEntry, sal_uInt16 nPos, BitmapEx* pBmpEx) 1839cdf0e10cSrcweir { 1840cdf0e10cSrcweir RemoveEntry(nPos); 1841cdf0e10cSrcweir 184270d3707aSArmin Le Grand if(pBmpEx) 1843cdf0e10cSrcweir { 184470d3707aSArmin Le Grand maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1845cdf0e10cSrcweir SetVirtualDevice(); 184670d3707aSArmin Le Grand InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12)), nPos); 1847cdf0e10cSrcweir } 1848cdf0e10cSrcweir else 184970d3707aSArmin Le Grand { 1850cdf0e10cSrcweir InsertEntry(pEntry->GetName()); 1851cdf0e10cSrcweir } 185270d3707aSArmin Le Grand } 1853cdf0e10cSrcweir 1854cdf0e10cSrcweir /************************************************************************/ 1855cdf0e10cSrcweir 185670d3707aSArmin Le Grand void BitmapLB::SelectEntryByList(const XBitmapList* pList, const String& rStr) 1857cdf0e10cSrcweir { 185870d3707aSArmin Le Grand const long nCount(pList->Count()); 1859cdf0e10cSrcweir XBitmapEntry* pEntry; 186070d3707aSArmin Le Grand bool bFound(false); 186170d3707aSArmin Le Grand long i(0); 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir for(i = 0; i < nCount && !bFound; i++) 1864cdf0e10cSrcweir { 1865cdf0e10cSrcweir pEntry = pList->GetBitmap(i); 186670d3707aSArmin Le Grand const String aStr(pEntry->GetName()); 1867cdf0e10cSrcweir 1868cdf0e10cSrcweir if(rStr == aStr) 1869cdf0e10cSrcweir { 187070d3707aSArmin Le Grand bFound = true; 1871cdf0e10cSrcweir } 1872cdf0e10cSrcweir } 187370d3707aSArmin Le Grand 1874cdf0e10cSrcweir if(bFound) 187570d3707aSArmin Le Grand { 1876cdf0e10cSrcweir SelectEntryPos((sal_uInt16)(i - 1)); 1877cdf0e10cSrcweir } 187870d3707aSArmin Le Grand } 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir /************************************************************************* 1881cdf0e10cSrcweir |* 1882cdf0e10cSrcweir |* Konstruktor von FillAttrLB 1883cdf0e10cSrcweir |* 1884cdf0e10cSrcweir \************************************************************************/ 1885cdf0e10cSrcweir 188670d3707aSArmin Le Grand FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) 188770d3707aSArmin Le Grand : ColorListBox(pParent, Id), 188870d3707aSArmin Le Grand maVD(), 188970d3707aSArmin Le Grand maBitmapEx() 1890cdf0e10cSrcweir { 189170d3707aSArmin Le Grand maVD.SetOutputSizePixel(Size(32, 16)); 1892cdf0e10cSrcweir } 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir /************************************************************************/ 1895cdf0e10cSrcweir 189670d3707aSArmin Le Grand FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB) 189770d3707aSArmin Le Grand : ColorListBox(pParent, aWB) 1898cdf0e10cSrcweir { 189970d3707aSArmin Le Grand maVD.SetOutputSizePixel(Size(32, 16)); 1900cdf0e10cSrcweir } 1901cdf0e10cSrcweir 1902cdf0e10cSrcweir /************************************************************************/ 1903cdf0e10cSrcweir 1904cdf0e10cSrcweir void FillAttrLB::SetVirtualDevice() 1905cdf0e10cSrcweir { 190670d3707aSArmin Le Grand maVD.Erase(); 190770d3707aSArmin Le Grand 190870d3707aSArmin Le Grand if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1909cdf0e10cSrcweir { 191070d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 0), Size(32, 16), maBitmapEx); 1911cdf0e10cSrcweir } 1912cdf0e10cSrcweir else 1913cdf0e10cSrcweir { 191470d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 0), maBitmapEx); 191570d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(8, 0), maBitmapEx); 191670d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(16, 0), maBitmapEx); 191770d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(24, 0), maBitmapEx); 191870d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(0, 8), maBitmapEx); 191970d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(8, 8), maBitmapEx); 192070d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(16, 8), maBitmapEx); 192170d3707aSArmin Le Grand maVD.DrawBitmapEx(Point(24, 8), maBitmapEx); 1922cdf0e10cSrcweir } 1923cdf0e10cSrcweir } 1924cdf0e10cSrcweir 1925cdf0e10cSrcweir /************************************************************************/ 1926cdf0e10cSrcweir 1927cdf0e10cSrcweir void FillAttrLB::Fill(const XBitmapList* pList) 1928cdf0e10cSrcweir { 192970d3707aSArmin Le Grand const long nCount(pList->Count()); 1930cdf0e10cSrcweir XBitmapEntry* pEntry; 1931cdf0e10cSrcweir 193270d3707aSArmin Le Grand ListBox::SetUpdateMode(false); 193370d3707aSArmin Le Grand 193470d3707aSArmin Le Grand for(long i(0); i < nCount; i++) 1935cdf0e10cSrcweir { 1936cdf0e10cSrcweir pEntry = pList->GetBitmap( i ); 193770d3707aSArmin Le Grand maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1938cdf0e10cSrcweir SetVirtualDevice(); 193970d3707aSArmin Le Grand ListBox::InsertEntry(pEntry->GetName(), maVD.GetBitmap(Point(0, 2), Size(32, 12))); 1940cdf0e10cSrcweir } 194170d3707aSArmin Le Grand 194270d3707aSArmin Le Grand ListBox::SetUpdateMode(true); 1943cdf0e10cSrcweir } 1944cdf0e10cSrcweir 1945cdf0e10cSrcweir /************************************************************************/ 1946cdf0e10cSrcweir 194770d3707aSArmin Le Grand void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr) 1948cdf0e10cSrcweir { 194970d3707aSArmin Le Grand const long nCount(pList->Count()); 1950cdf0e10cSrcweir XBitmapEntry* pEntry; 195170d3707aSArmin Le Grand bool bFound(false); 195270d3707aSArmin Le Grand long i(0); 1953cdf0e10cSrcweir 1954cdf0e10cSrcweir for(i = 0; i < nCount && !bFound; i++) 1955cdf0e10cSrcweir { 1956cdf0e10cSrcweir pEntry = pList->GetBitmap(i); 195770d3707aSArmin Le Grand const String aStr(pEntry->GetName()); 1958cdf0e10cSrcweir 1959cdf0e10cSrcweir if(rStr == aStr) 1960cdf0e10cSrcweir { 196170d3707aSArmin Le Grand bFound = true; 1962cdf0e10cSrcweir } 1963cdf0e10cSrcweir } 196470d3707aSArmin Le Grand 1965cdf0e10cSrcweir if(bFound) 196670d3707aSArmin Le Grand { 1967cdf0e10cSrcweir SelectEntryPos((sal_uInt16)(i - 1)); 1968cdf0e10cSrcweir } 196970d3707aSArmin Le Grand } 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir /************************************************************************* 1972cdf0e10cSrcweir |* 1973cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1974cdf0e10cSrcweir |* 1975cdf0e10cSrcweir \************************************************************************/ 1976cdf0e10cSrcweir 1977cdf0e10cSrcweir void FillTypeLB::Fill() 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir SetUpdateMode( sal_False ); 1980cdf0e10cSrcweir InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) ); 1981cdf0e10cSrcweir InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) ); 1982cdf0e10cSrcweir InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) ); 1983cdf0e10cSrcweir InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) ); 1984cdf0e10cSrcweir InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) ); 1985cdf0e10cSrcweir SetUpdateMode( sal_True ); 1986cdf0e10cSrcweir } 1987cdf0e10cSrcweir 1988cdf0e10cSrcweir /************************************************************************* 1989cdf0e10cSrcweir |* 1990cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 1991cdf0e10cSrcweir |* 1992cdf0e10cSrcweir \************************************************************************/ 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir void LineLB::Fill( const XDashList* pList ) 1995cdf0e10cSrcweir { 1996cdf0e10cSrcweir long nCount = pList->Count(); 1997cdf0e10cSrcweir XDashEntry* pEntry; 1998cdf0e10cSrcweir SetUpdateMode( sal_False ); 1999cdf0e10cSrcweir 2000cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 2001cdf0e10cSrcweir { 2002cdf0e10cSrcweir pEntry = pList->GetDash( i ); 2003cdf0e10cSrcweir Bitmap* pBitmap = const_cast<XDashList*>(pList)->CreateBitmapForUI( i ); 2004cdf0e10cSrcweir if( pBitmap ) 2005cdf0e10cSrcweir { 2006cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBitmap ); 2007cdf0e10cSrcweir delete pBitmap; 2008cdf0e10cSrcweir } 2009cdf0e10cSrcweir else 2010cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 2011cdf0e10cSrcweir } 2012cdf0e10cSrcweir SetUpdateMode( sal_True ); 2013cdf0e10cSrcweir } 2014cdf0e10cSrcweir 2015cdf0e10cSrcweir void LineLB::FillStyles() 2016cdf0e10cSrcweir { 2017cdf0e10cSrcweir ResMgr& rMgr = DIALOG_MGR(); 2018cdf0e10cSrcweir 2019cdf0e10cSrcweir // Linienstile 2020cdf0e10cSrcweir Clear(); 2021cdf0e10cSrcweir InsertEntry( String( ResId( RID_SVXSTR_INVISIBLE, rMgr ) ) ); 2022cdf0e10cSrcweir 2023cdf0e10cSrcweir const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 2024cdf0e10cSrcweir Bitmap aBitmap ( SVX_RES ( RID_SVXCTRL_LINECTRL ) ); 2025cdf0e10cSrcweir Color aSourceColors[2]; 2026cdf0e10cSrcweir Color aDestColors[2]; 2027cdf0e10cSrcweir 2028cdf0e10cSrcweir aSourceColors[0] = Color( COL_WHITE ); 2029cdf0e10cSrcweir aSourceColors[1] = Color( COL_BLACK ); 2030cdf0e10cSrcweir 2031cdf0e10cSrcweir aDestColors[0] = rStyles.GetFieldColor(); 2032cdf0e10cSrcweir aDestColors[1] = rStyles.GetFieldTextColor(); 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir aBitmap.Replace ( aSourceColors, aDestColors, 2 ); 2035cdf0e10cSrcweir Image aSolidLine ( aBitmap ); 2036cdf0e10cSrcweir InsertEntry( String( ResId( RID_SVXSTR_SOLID, rMgr ) ), aSolidLine ); 2037cdf0e10cSrcweir } 2038cdf0e10cSrcweir 2039cdf0e10cSrcweir /************************************************************************/ 2040cdf0e10cSrcweir 2041cdf0e10cSrcweir void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp ) 2042cdf0e10cSrcweir { 2043cdf0e10cSrcweir if( pBmp ) 2044cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp ); 2045cdf0e10cSrcweir else 2046cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 2047cdf0e10cSrcweir } 2048cdf0e10cSrcweir 2049cdf0e10cSrcweir /************************************************************************/ 2050cdf0e10cSrcweir 2051cdf0e10cSrcweir void LineLB::Modify( XDashEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp ) 2052cdf0e10cSrcweir { 2053cdf0e10cSrcweir RemoveEntry( nPos ); 2054cdf0e10cSrcweir 2055cdf0e10cSrcweir if( pBmp ) 2056cdf0e10cSrcweir InsertEntry( pEntry->GetName(), *pBmp, nPos ); 2057cdf0e10cSrcweir else 2058cdf0e10cSrcweir InsertEntry( pEntry->GetName(), nPos ); 2059cdf0e10cSrcweir } 2060cdf0e10cSrcweir 2061cdf0e10cSrcweir /************************************************************************/ 2062cdf0e10cSrcweir 2063cdf0e10cSrcweir void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr, 2064cdf0e10cSrcweir const XDash& rDash, sal_uInt16 nDist ) 2065cdf0e10cSrcweir { 2066cdf0e10cSrcweir long nCount = pList->Count(); 2067cdf0e10cSrcweir XDashEntry* pEntry; 2068cdf0e10cSrcweir sal_Bool bFound = sal_False; 2069cdf0e10cSrcweir String aStr; 2070cdf0e10cSrcweir XDash aDash; 2071cdf0e10cSrcweir 2072cdf0e10cSrcweir long i; 2073cdf0e10cSrcweir for( i = 0; i < nCount && !bFound; i++ ) 2074cdf0e10cSrcweir { 2075cdf0e10cSrcweir pEntry = pList->GetDash( i ); 2076cdf0e10cSrcweir 2077cdf0e10cSrcweir aStr = pEntry->GetName(); 2078cdf0e10cSrcweir aDash = pEntry->GetDash(); 2079cdf0e10cSrcweir 2080cdf0e10cSrcweir if( rStr == aStr && rDash == aDash ) 2081cdf0e10cSrcweir bFound = sal_True; 2082cdf0e10cSrcweir } 2083cdf0e10cSrcweir if( bFound ) 2084cdf0e10cSrcweir SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 2085cdf0e10cSrcweir } 2086cdf0e10cSrcweir 2087cdf0e10cSrcweir /************************************************************************* 2088cdf0e10cSrcweir |* 2089cdf0e10cSrcweir |* Fuellt die Listbox (vorlaeufig) mit Strings 2090cdf0e10cSrcweir |* 2091cdf0e10cSrcweir \************************************************************************/ 2092cdf0e10cSrcweir 2093cdf0e10cSrcweir void LineEndLB::Fill( const XLineEndList* pList, sal_Bool bStart ) 2094cdf0e10cSrcweir { 2095cdf0e10cSrcweir long nCount = pList->Count(); 2096cdf0e10cSrcweir XLineEndEntry* pEntry; 2097cdf0e10cSrcweir VirtualDevice aVD; 2098cdf0e10cSrcweir SetUpdateMode( sal_False ); 2099cdf0e10cSrcweir 2100cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 2101cdf0e10cSrcweir { 2102cdf0e10cSrcweir pEntry = pList->GetLineEnd( i ); 2103cdf0e10cSrcweir Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i ); 2104cdf0e10cSrcweir if( pBitmap ) 2105cdf0e10cSrcweir { 2106cdf0e10cSrcweir Size aBmpSize( pBitmap->GetSizePixel() ); 2107cdf0e10cSrcweir aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2108cdf0e10cSrcweir aVD.DrawBitmap( Point(), *pBitmap ); 2109cdf0e10cSrcweir InsertEntry( pEntry->GetName(), 2110cdf0e10cSrcweir aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2111cdf0e10cSrcweir Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) ); 2112cdf0e10cSrcweir 2113cdf0e10cSrcweir delete pBitmap; 2114cdf0e10cSrcweir } 2115cdf0e10cSrcweir else 2116cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 2117cdf0e10cSrcweir } 2118cdf0e10cSrcweir SetUpdateMode( sal_True ); 2119cdf0e10cSrcweir } 2120cdf0e10cSrcweir 2121cdf0e10cSrcweir /************************************************************************/ 2122cdf0e10cSrcweir 2123cdf0e10cSrcweir void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp, 2124cdf0e10cSrcweir sal_Bool bStart ) 2125cdf0e10cSrcweir { 2126cdf0e10cSrcweir if( pBmp ) 2127cdf0e10cSrcweir { 2128cdf0e10cSrcweir VirtualDevice aVD; 2129cdf0e10cSrcweir Size aBmpSize( pBmp->GetSizePixel() ); 2130cdf0e10cSrcweir 2131cdf0e10cSrcweir aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2132cdf0e10cSrcweir aVD.DrawBitmap( Point(), *pBmp ); 2133cdf0e10cSrcweir InsertEntry( pEntry->GetName(), 2134cdf0e10cSrcweir aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2135cdf0e10cSrcweir Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) ); 2136cdf0e10cSrcweir } 2137cdf0e10cSrcweir else 2138cdf0e10cSrcweir InsertEntry( pEntry->GetName() ); 2139cdf0e10cSrcweir } 2140cdf0e10cSrcweir 2141cdf0e10cSrcweir /************************************************************************/ 2142cdf0e10cSrcweir 2143cdf0e10cSrcweir void LineEndLB::Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp, 2144cdf0e10cSrcweir sal_Bool bStart ) 2145cdf0e10cSrcweir { 2146cdf0e10cSrcweir RemoveEntry( nPos ); 2147cdf0e10cSrcweir 2148cdf0e10cSrcweir if( pBmp ) 2149cdf0e10cSrcweir { 2150cdf0e10cSrcweir VirtualDevice aVD; 2151cdf0e10cSrcweir Size aBmpSize( pBmp->GetSizePixel() ); 2152cdf0e10cSrcweir 2153cdf0e10cSrcweir aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2154cdf0e10cSrcweir aVD.DrawBitmap( Point(), *pBmp ); 2155cdf0e10cSrcweir InsertEntry( pEntry->GetName(), 2156cdf0e10cSrcweir aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2157cdf0e10cSrcweir Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos ); 2158cdf0e10cSrcweir } 2159cdf0e10cSrcweir else 2160cdf0e10cSrcweir InsertEntry( pEntry->GetName(), nPos ); 2161cdf0e10cSrcweir } 2162cdf0e10cSrcweir 2163cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 2164cdf0e10cSrcweir 2165cdf0e10cSrcweir void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground) 2166cdf0e10cSrcweir { 2167cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 2168cdf0e10cSrcweir 2169cdf0e10cSrcweir if(bForeground) 2170cdf0e10cSrcweir { 2171cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 2172cdf0e10cSrcweir Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); 2173cdf0e10cSrcweir 2174cdf0e10cSrcweir if(IsControlForeground()) 2175cdf0e10cSrcweir { 2176cdf0e10cSrcweir aTextColor = GetControlForeground(); 2177cdf0e10cSrcweir } 2178cdf0e10cSrcweir 2179cdf0e10cSrcweir getBufferDevice().SetTextColor(aTextColor); 2180cdf0e10cSrcweir } 2181cdf0e10cSrcweir 2182cdf0e10cSrcweir if(bBackground) 2183cdf0e10cSrcweir { 2184cdf0e10cSrcweir if(IsControlBackground()) 2185cdf0e10cSrcweir { 2186cdf0e10cSrcweir getBufferDevice().SetBackground(GetControlBackground()); 2187cdf0e10cSrcweir } 2188cdf0e10cSrcweir else 2189cdf0e10cSrcweir { 2190cdf0e10cSrcweir getBufferDevice().SetBackground(rStyleSettings.GetWindowColor()); 2191cdf0e10cSrcweir } 2192cdf0e10cSrcweir } 2193cdf0e10cSrcweir 2194cdf0e10cSrcweir // do not paint background self, it gets painted buffered 2195cdf0e10cSrcweir SetControlBackground(); 2196cdf0e10cSrcweir SetBackground(); 2197cdf0e10cSrcweir 2198cdf0e10cSrcweir Invalidate(); 2199cdf0e10cSrcweir } 2200cdf0e10cSrcweir 2201cdf0e10cSrcweir SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId ) 2202cdf0e10cSrcweir : Control( pParent, rResId ), 2203cdf0e10cSrcweir mpModel( new SdrModel() ), 2204cdf0e10cSrcweir mpBufferDevice( new VirtualDevice(*this) ) 2205cdf0e10cSrcweir { 2206cdf0e10cSrcweir // Draw the control's border as a flat thin black line. 2207cdf0e10cSrcweir SetBorderStyle(WINDOW_BORDER_MONO); 2208cdf0e10cSrcweir SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR ); 2209cdf0e10cSrcweir SetMapMode(MAP_100TH_MM); 2210cdf0e10cSrcweir 2211cdf0e10cSrcweir // init model 2212cdf0e10cSrcweir mpModel->GetItemPool().FreezeIdRanges(); 2213cdf0e10cSrcweir } 2214cdf0e10cSrcweir 2215cdf0e10cSrcweir SvxPreviewBase::~SvxPreviewBase() 2216cdf0e10cSrcweir { 2217cdf0e10cSrcweir delete mpModel; 2218cdf0e10cSrcweir delete mpBufferDevice; 2219cdf0e10cSrcweir } 2220cdf0e10cSrcweir 2221cdf0e10cSrcweir void SvxPreviewBase::LocalPrePaint() 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir // init BufferDevice 2224cdf0e10cSrcweir if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel()) 2225cdf0e10cSrcweir { 2226cdf0e10cSrcweir mpBufferDevice->SetDrawMode(GetDrawMode()); 2227cdf0e10cSrcweir mpBufferDevice->SetSettings(GetSettings()); 2228cdf0e10cSrcweir mpBufferDevice->SetAntialiasing(GetAntialiasing()); 2229cdf0e10cSrcweir mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel()); 2230cdf0e10cSrcweir mpBufferDevice->SetMapMode(GetMapMode()); 2231cdf0e10cSrcweir } 2232cdf0e10cSrcweir 2233cdf0e10cSrcweir mpBufferDevice->Erase(); 2234cdf0e10cSrcweir } 2235cdf0e10cSrcweir 2236cdf0e10cSrcweir void SvxPreviewBase::LocalPostPaint() 2237cdf0e10cSrcweir { 2238cdf0e10cSrcweir // copy to front (in pixel mode) 2239cdf0e10cSrcweir const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled()); 2240cdf0e10cSrcweir const bool bWasEnabledDst(IsMapModeEnabled()); 2241cdf0e10cSrcweir const Point aEmptyPoint; 2242cdf0e10cSrcweir 2243cdf0e10cSrcweir mpBufferDevice->EnableMapMode(false); 2244cdf0e10cSrcweir EnableMapMode(false); 2245cdf0e10cSrcweir 2246cdf0e10cSrcweir DrawOutDev( 2247cdf0e10cSrcweir aEmptyPoint, GetOutputSizePixel(), 2248cdf0e10cSrcweir aEmptyPoint, GetOutputSizePixel(), 2249cdf0e10cSrcweir *mpBufferDevice); 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir mpBufferDevice->EnableMapMode(bWasEnabledSrc); 2252cdf0e10cSrcweir EnableMapMode(bWasEnabledDst); 2253cdf0e10cSrcweir } 2254cdf0e10cSrcweir 2255cdf0e10cSrcweir void SvxPreviewBase::StateChanged(StateChangedType nType) 2256cdf0e10cSrcweir { 2257cdf0e10cSrcweir Control::StateChanged(nType); 2258cdf0e10cSrcweir 2259cdf0e10cSrcweir if(STATE_CHANGE_CONTROLFOREGROUND == nType) 2260cdf0e10cSrcweir { 2261cdf0e10cSrcweir InitSettings(true, false); 2262cdf0e10cSrcweir } 2263cdf0e10cSrcweir else if(STATE_CHANGE_CONTROLBACKGROUND == nType) 2264cdf0e10cSrcweir { 2265cdf0e10cSrcweir InitSettings(false, true); 2266cdf0e10cSrcweir } 2267cdf0e10cSrcweir } 2268cdf0e10cSrcweir 2269cdf0e10cSrcweir void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt) 2270cdf0e10cSrcweir { 2271cdf0e10cSrcweir SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR); 2272cdf0e10cSrcweir 2273cdf0e10cSrcweir if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) 2274cdf0e10cSrcweir { 2275cdf0e10cSrcweir InitSettings(true, true); 2276cdf0e10cSrcweir } 2277cdf0e10cSrcweir else 2278cdf0e10cSrcweir { 2279cdf0e10cSrcweir Control::DataChanged(rDCEvt); 2280cdf0e10cSrcweir } 2281cdf0e10cSrcweir } 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir /************************************************************************* 2284cdf0e10cSrcweir |* 2285cdf0e10cSrcweir |* SvxXLinePreview::SvxXLinePreview() 2286cdf0e10cSrcweir |* 2287cdf0e10cSrcweir *************************************************************************/ 2288cdf0e10cSrcweir 2289cdf0e10cSrcweir SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId ) 2290cdf0e10cSrcweir : SvxPreviewBase( pParent, rResId ), 2291cdf0e10cSrcweir mpLineObjA( 0L ), 2292cdf0e10cSrcweir mpLineObjB( 0L ), 2293cdf0e10cSrcweir mpLineObjC( 0L ), 2294cdf0e10cSrcweir mpGraphic( 0L ), 2295cdf0e10cSrcweir mbWithSymbol( sal_False ) 2296cdf0e10cSrcweir { 2297cdf0e10cSrcweir const Size aOutputSize(GetOutputSize()); 2298cdf0e10cSrcweir InitSettings( sal_True, sal_True ); 2299cdf0e10cSrcweir 2300cdf0e10cSrcweir const sal_Int32 nDistance(500L); 2301cdf0e10cSrcweir const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance)); 2302cdf0e10cSrcweir 2303cdf0e10cSrcweir // create DrawObectA 2304cdf0e10cSrcweir const sal_Int32 aYPosA(aOutputSize.Height() / 2); 2305cdf0e10cSrcweir const basegfx::B2DPoint aPointA1( nDistance, aYPosA); 2306cdf0e10cSrcweir const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA ); 2307cdf0e10cSrcweir basegfx::B2DPolygon aPolygonA; 2308cdf0e10cSrcweir aPolygonA.append(aPointA1); 2309cdf0e10cSrcweir aPolygonA.append(aPointA2); 2310cdf0e10cSrcweir mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA)); 2311cdf0e10cSrcweir mpLineObjA->SetModel(&getModel()); 2312cdf0e10cSrcweir 2313cdf0e10cSrcweir // create DrawObectB 2314cdf0e10cSrcweir const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4); 2315cdf0e10cSrcweir const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4); 2316cdf0e10cSrcweir const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1); 2317cdf0e10cSrcweir const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 ); 2318cdf0e10cSrcweir const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 ); 2319cdf0e10cSrcweir basegfx::B2DPolygon aPolygonB; 2320cdf0e10cSrcweir aPolygonB.append(aPointB1); 2321cdf0e10cSrcweir aPolygonB.append(aPointB2); 2322cdf0e10cSrcweir aPolygonB.append(aPointB3); 2323cdf0e10cSrcweir mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB)); 2324cdf0e10cSrcweir mpLineObjB->SetModel(&getModel()); 2325cdf0e10cSrcweir 2326cdf0e10cSrcweir // create DrawObectC 2327cdf0e10cSrcweir const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1); 2328cdf0e10cSrcweir const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 ); 2329cdf0e10cSrcweir const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 ); 2330cdf0e10cSrcweir basegfx::B2DPolygon aPolygonC; 2331cdf0e10cSrcweir aPolygonC.append(aPointC1); 2332cdf0e10cSrcweir aPolygonC.append(aPointC2); 2333cdf0e10cSrcweir aPolygonC.append(aPointC3); 2334cdf0e10cSrcweir mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC)); 2335cdf0e10cSrcweir mpLineObjC->SetModel(&getModel()); 2336cdf0e10cSrcweir } 2337cdf0e10cSrcweir 2338cdf0e10cSrcweir SvxXLinePreview::~SvxXLinePreview() 2339cdf0e10cSrcweir { 2340cdf0e10cSrcweir SdrObject::Free( mpLineObjA ); 2341cdf0e10cSrcweir SdrObject::Free( mpLineObjB ); 2342cdf0e10cSrcweir SdrObject::Free( mpLineObjC ); 2343cdf0e10cSrcweir } 2344cdf0e10cSrcweir 2345cdf0e10cSrcweir // ----------------------------------------------------------------------- 2346cdf0e10cSrcweir 2347cdf0e10cSrcweir void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s) 2348cdf0e10cSrcweir { 2349cdf0e10cSrcweir mpGraphic = p; 2350cdf0e10cSrcweir maSymbolSize = s; 2351cdf0e10cSrcweir } 2352cdf0e10cSrcweir 2353cdf0e10cSrcweir // ----------------------------------------------------------------------- 2354cdf0e10cSrcweir 2355cdf0e10cSrcweir void SvxXLinePreview::ResizeSymbol(const Size& s) 2356cdf0e10cSrcweir { 2357cdf0e10cSrcweir if ( s != maSymbolSize ) 2358cdf0e10cSrcweir { 2359cdf0e10cSrcweir maSymbolSize = s; 2360cdf0e10cSrcweir Invalidate(); 2361cdf0e10cSrcweir } 2362cdf0e10cSrcweir } 2363cdf0e10cSrcweir 2364cdf0e10cSrcweir // ----------------------------------------------------------------------- 2365cdf0e10cSrcweir 2366cdf0e10cSrcweir void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet) 2367cdf0e10cSrcweir { 2368cdf0e10cSrcweir // Set ItemSet at objects 2369cdf0e10cSrcweir mpLineObjA->SetMergedItemSet(rItemSet); 2370cdf0e10cSrcweir 2371cdf0e10cSrcweir // At line joints, do not use arrows 2372cdf0e10cSrcweir SfxItemSet aTempSet(rItemSet); 2373cdf0e10cSrcweir aTempSet.ClearItem(XATTR_LINESTART); 2374cdf0e10cSrcweir aTempSet.ClearItem(XATTR_LINEEND); 2375cdf0e10cSrcweir 2376cdf0e10cSrcweir mpLineObjB->SetMergedItemSet(aTempSet); 2377cdf0e10cSrcweir mpLineObjC->SetMergedItemSet(aTempSet); 2378cdf0e10cSrcweir } 2379cdf0e10cSrcweir 2380cdf0e10cSrcweir // ----------------------------------------------------------------------- 2381cdf0e10cSrcweir 2382cdf0e10cSrcweir void SvxXLinePreview::Paint( const Rectangle& ) 2383cdf0e10cSrcweir { 2384cdf0e10cSrcweir LocalPrePaint(); 2385cdf0e10cSrcweir 2386cdf0e10cSrcweir // paint objects to buffer device 2387cdf0e10cSrcweir sdr::contact::SdrObjectVector aObjectVector; 2388cdf0e10cSrcweir aObjectVector.push_back(mpLineObjA); 2389cdf0e10cSrcweir aObjectVector.push_back(mpLineObjB); 2390cdf0e10cSrcweir aObjectVector.push_back(mpLineObjC); 2391cdf0e10cSrcweir 2392cdf0e10cSrcweir sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2393cdf0e10cSrcweir sdr::contact::DisplayInfo aDisplayInfo; 2394cdf0e10cSrcweir 2395cdf0e10cSrcweir // do processing 2396cdf0e10cSrcweir aPainter.ProcessDisplay(aDisplayInfo); 2397cdf0e10cSrcweir 2398cdf0e10cSrcweir if ( mbWithSymbol && mpGraphic ) 2399cdf0e10cSrcweir { 2400cdf0e10cSrcweir const Size aOutputSize(GetOutputSize()); 2401cdf0e10cSrcweir Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 ); 2402cdf0e10cSrcweir aPos.X() -= maSymbolSize.Width() / 2; 2403cdf0e10cSrcweir aPos.Y() -= maSymbolSize.Height() / 2; 2404cdf0e10cSrcweir mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize ); 2405cdf0e10cSrcweir } 2406cdf0e10cSrcweir 2407cdf0e10cSrcweir LocalPostPaint(); 2408cdf0e10cSrcweir } 2409cdf0e10cSrcweir 2410cdf0e10cSrcweir /************************************************************************* 2411cdf0e10cSrcweir |* 2412cdf0e10cSrcweir |* SvxXRectPreview::SvxXRectPreview() 2413cdf0e10cSrcweir |* 2414cdf0e10cSrcweir *************************************************************************/ 2415cdf0e10cSrcweir 2416cdf0e10cSrcweir SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId ) 2417cdf0e10cSrcweir : SvxPreviewBase( pParent, rResId ), 2418cdf0e10cSrcweir mpRectangleObject(0) 2419cdf0e10cSrcweir { 2420cdf0e10cSrcweir InitSettings(true, true); 2421cdf0e10cSrcweir 2422cdf0e10cSrcweir // create RectangleObject 2423cdf0e10cSrcweir const Rectangle aObjectSize(Point(), GetOutputSize()); 2424cdf0e10cSrcweir mpRectangleObject = new SdrRectObj(aObjectSize); 2425cdf0e10cSrcweir mpRectangleObject->SetModel(&getModel()); 2426cdf0e10cSrcweir } 2427cdf0e10cSrcweir 2428cdf0e10cSrcweir SvxXRectPreview::~SvxXRectPreview() 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir SdrObject::Free(mpRectangleObject); 2431cdf0e10cSrcweir } 2432cdf0e10cSrcweir 2433cdf0e10cSrcweir void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet) 2434cdf0e10cSrcweir { 2435cdf0e10cSrcweir mpRectangleObject->SetMergedItemSet(rItemSet, true); 2436cdf0e10cSrcweir mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2437cdf0e10cSrcweir } 2438cdf0e10cSrcweir 2439cdf0e10cSrcweir void SvxXRectPreview::Paint( const Rectangle& ) 2440cdf0e10cSrcweir { 2441cdf0e10cSrcweir LocalPrePaint(); 2442cdf0e10cSrcweir 2443cdf0e10cSrcweir sdr::contact::SdrObjectVector aObjectVector; 2444cdf0e10cSrcweir 2445cdf0e10cSrcweir aObjectVector.push_back(mpRectangleObject); 2446cdf0e10cSrcweir 2447cdf0e10cSrcweir sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2448cdf0e10cSrcweir sdr::contact::DisplayInfo aDisplayInfo; 2449cdf0e10cSrcweir 2450cdf0e10cSrcweir aPainter.ProcessDisplay(aDisplayInfo); 2451cdf0e10cSrcweir 2452cdf0e10cSrcweir LocalPostPaint(); 2453cdf0e10cSrcweir } 2454cdf0e10cSrcweir 2455cdf0e10cSrcweir /************************************************************************* 2456cdf0e10cSrcweir |* 2457cdf0e10cSrcweir |* SvxXShadowPreview::SvxXShadowPreview() 2458cdf0e10cSrcweir |* 2459cdf0e10cSrcweir *************************************************************************/ 2460cdf0e10cSrcweir 2461cdf0e10cSrcweir SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId ) 2462cdf0e10cSrcweir : SvxPreviewBase( pParent, rResId ), 2463cdf0e10cSrcweir mpRectangleObject(0), 2464cdf0e10cSrcweir mpRectangleShadow(0) 2465cdf0e10cSrcweir { 2466cdf0e10cSrcweir InitSettings(true, true); 2467cdf0e10cSrcweir 2468cdf0e10cSrcweir // prepare size 2469cdf0e10cSrcweir Size aSize = GetOutputSize(); 2470cdf0e10cSrcweir aSize.Width() = aSize.Width() / 3; 2471cdf0e10cSrcweir aSize.Height() = aSize.Height() / 3; 2472cdf0e10cSrcweir 2473cdf0e10cSrcweir // create RectangleObject 2474cdf0e10cSrcweir const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2475cdf0e10cSrcweir mpRectangleObject = new SdrRectObj(aObjectSize); 2476cdf0e10cSrcweir mpRectangleObject->SetModel(&getModel()); 2477cdf0e10cSrcweir 2478cdf0e10cSrcweir // create ShadowObject 2479cdf0e10cSrcweir const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2480cdf0e10cSrcweir mpRectangleShadow = new SdrRectObj(aShadowSize); 2481cdf0e10cSrcweir mpRectangleShadow->SetModel(&getModel()); 2482cdf0e10cSrcweir } 2483cdf0e10cSrcweir 2484cdf0e10cSrcweir SvxXShadowPreview::~SvxXShadowPreview() 2485cdf0e10cSrcweir { 2486cdf0e10cSrcweir SdrObject::Free(mpRectangleObject); 2487cdf0e10cSrcweir SdrObject::Free(mpRectangleShadow); 2488cdf0e10cSrcweir } 2489cdf0e10cSrcweir 2490cdf0e10cSrcweir void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet) 2491cdf0e10cSrcweir { 2492cdf0e10cSrcweir mpRectangleObject->SetMergedItemSet(rItemSet, true); 2493cdf0e10cSrcweir mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2494cdf0e10cSrcweir } 2495cdf0e10cSrcweir 2496cdf0e10cSrcweir void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet) 2497cdf0e10cSrcweir { 2498cdf0e10cSrcweir mpRectangleShadow->SetMergedItemSet(rItemSet, true); 2499cdf0e10cSrcweir mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2500cdf0e10cSrcweir } 2501cdf0e10cSrcweir 2502cdf0e10cSrcweir void SvxXShadowPreview::SetShadowPosition(const Point& rPos) 2503cdf0e10cSrcweir { 2504cdf0e10cSrcweir Rectangle aObjectPosition(mpRectangleObject->GetSnapRect()); 2505cdf0e10cSrcweir aObjectPosition.Move(rPos.X(), rPos.Y()); 2506cdf0e10cSrcweir mpRectangleShadow->SetSnapRect(aObjectPosition); 2507cdf0e10cSrcweir } 2508cdf0e10cSrcweir 2509cdf0e10cSrcweir void SvxXShadowPreview::Paint( const Rectangle& ) 2510cdf0e10cSrcweir { 2511cdf0e10cSrcweir LocalPrePaint(); 2512cdf0e10cSrcweir 2513cdf0e10cSrcweir sdr::contact::SdrObjectVector aObjectVector; 2514cdf0e10cSrcweir 2515cdf0e10cSrcweir aObjectVector.push_back(mpRectangleShadow); 2516cdf0e10cSrcweir aObjectVector.push_back(mpRectangleObject); 2517cdf0e10cSrcweir 2518cdf0e10cSrcweir sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2519cdf0e10cSrcweir sdr::contact::DisplayInfo aDisplayInfo; 2520cdf0e10cSrcweir 2521cdf0e10cSrcweir aPainter.ProcessDisplay(aDisplayInfo); 2522cdf0e10cSrcweir 2523cdf0e10cSrcweir LocalPostPaint(); 2524cdf0e10cSrcweir } 2525cdf0e10cSrcweir 2526cdf0e10cSrcweir // ----------------------------------------------------------------------- 2527cdf0e10cSrcweir // eof 2528