xref: /trunk/main/svx/source/dialog/dlgctrl.cxx (revision 633aadc51c3c356307be76612d13fe02feb48058)
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 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_svx.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // include ---------------------------------------------------------------
26cdf0e10cSrcweir #include <tools/shl.hxx>
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <svx/xtable.hxx>
29cdf0e10cSrcweir #include <svx/xpool.hxx>
30cdf0e10cSrcweir #include <svx/dialogs.hrc>
3170d3707aSArmin Le Grand #include <accessibility.hrc>
32cdf0e10cSrcweir #include <svx/dlgctrl.hxx>
33cdf0e10cSrcweir #include <svx/dialmgr.hxx>
34cdf0e10cSrcweir #include <tools/poly.hxx>
35cdf0e10cSrcweir #include <vcl/region.hxx>
36cdf0e10cSrcweir #include <vcl/gradient.hxx>
37cdf0e10cSrcweir #include <vcl/hatch.hxx>
389b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_
399b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
409b8096d0SSteve Yin #endif
419b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
429b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleEventId.hpp>
439b8096d0SSteve Yin #endif
449b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
459b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
469b8096d0SSteve Yin #endif
479b8096d0SSteve Yin #include "svxpixelctlaccessiblecontext.hxx"
48cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
4970d3707aSArmin Le Grand #include <svxrectctaccessiblecontext.hxx>
50cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
51cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
52cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
53cdf0e10cSrcweir #include <svx/svdorect.hxx>
54cdf0e10cSrcweir #include <svx/svdmodel.hxx>
55cdf0e10cSrcweir #include <svx/svdopath.hxx>
56cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
57cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
5870d3707aSArmin Le Grand #include <vcl/bmpacc.hxx>
5970d3707aSArmin Le Grand #include <svx/xbtmpit.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #define OUTPUT_DRAWMODE_COLOR       (DRAWMODE_DEFAULT)
62cdf0e10cSrcweir #define OUTPUT_DRAWMODE_CONTRAST    (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
63cdf0e10cSrcweir 
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::lang;
66cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir /*************************************************************************
70a787b805SMechtilde |*  Control to display select the corner points (and center point)
71a787b805SMechtilde |*  of an object
72cdf0e10cSrcweir \************************************************************************/
73cdf0e10cSrcweir 
GetRectBitmap(void)74cdf0e10cSrcweir Bitmap& SvxRectCtl::GetRectBitmap( void )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     if( !pBitmap )
77cdf0e10cSrcweir         InitRectBitmap();
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     return *pBitmap;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
SvxRectCtl(Window * pParent,const ResId & rResId,RECT_POINT eRpt,sal_uInt16 nBorder,sal_uInt16 nCircle,CTL_STYLE eStyle)82cdf0e10cSrcweir SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
83cdf0e10cSrcweir                         sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     Control( pParent, rResId ),
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     pAccContext ( NULL ),
88cdf0e10cSrcweir     nBorderWidth( nBorder ),
89cdf0e10cSrcweir     nRadius     ( nCircle),
90cdf0e10cSrcweir     eDefRP      ( eRpt ),
91cdf0e10cSrcweir     eCS         ( eStyle ),
92cdf0e10cSrcweir     pBitmap     ( NULL ),
93cdf0e10cSrcweir     m_nState    ( 0 ),
94cdf0e10cSrcweir     mbCompleteDisable(sal_False)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     SetMapMode( MAP_100TH_MM );
97cdf0e10cSrcweir     Resize_Impl();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // -----------------------------------------------------------------------
101cdf0e10cSrcweir 
~SvxRectCtl()102cdf0e10cSrcweir SvxRectCtl::~SvxRectCtl()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     delete pBitmap;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     if( pAccContext )
107cdf0e10cSrcweir         pAccContext->release();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir // -----------------------------------------------------------------------
Resize()111cdf0e10cSrcweir void SvxRectCtl::Resize()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     Resize_Impl();
114cdf0e10cSrcweir     Control::Resize();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir // -----------------------------------------------------------------------
118cdf0e10cSrcweir 
Resize_Impl()119cdf0e10cSrcweir void SvxRectCtl::Resize_Impl()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     aSize = GetOutputSize();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     switch( eCS )
124cdf0e10cSrcweir     {
125cdf0e10cSrcweir         case CS_RECT:
126cdf0e10cSrcweir         case CS_ANGLE:
127cdf0e10cSrcweir         case CS_SHADOW:
128cdf0e10cSrcweir             aPtLT = Point( 0 + nBorderWidth,  0 + nBorderWidth );
129cdf0e10cSrcweir             aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
130cdf0e10cSrcweir             aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir             aPtLM = Point( 0 + nBorderWidth,  aSize.Height() / 2 );
133cdf0e10cSrcweir             aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
134cdf0e10cSrcweir             aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir             aPtLB = Point( 0 + nBorderWidth,    aSize.Height() - nBorderWidth );
137cdf0e10cSrcweir             aPtMB = Point( aSize.Width() / 2,   aSize.Height() - nBorderWidth );
138cdf0e10cSrcweir             aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
139cdf0e10cSrcweir         break;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         case CS_LINE:
142cdf0e10cSrcweir             aPtLT = Point( 0 + 3 * nBorderWidth,  0 + nBorderWidth );
143cdf0e10cSrcweir             aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
144cdf0e10cSrcweir             aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir             aPtLM = Point( 0 + 3 * nBorderWidth,  aSize.Height() / 2 );
147cdf0e10cSrcweir             aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
148cdf0e10cSrcweir             aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir             aPtLB = Point( 0 + 3 * nBorderWidth,    aSize.Height() - nBorderWidth );
151cdf0e10cSrcweir             aPtMB = Point( aSize.Width() / 2,   aSize.Height() - nBorderWidth );
152cdf0e10cSrcweir             aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
153cdf0e10cSrcweir         break;
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir     Reset();
156cdf0e10cSrcweir     InitSettings( sal_True, sal_True );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir // -----------------------------------------------------------------------
159cdf0e10cSrcweir 
InitRectBitmap(void)160cdf0e10cSrcweir void SvxRectCtl::InitRectBitmap( void )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     if( pBitmap )
163cdf0e10cSrcweir         delete pBitmap;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     const StyleSettings&    rStyles = Application::GetSettings().GetStyleSettings();
166cdf0e10cSrcweir     svtools::ColorConfig aColorConfig;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     // set bitmap-colors
171cdf0e10cSrcweir     Color   aColorAry1[7];
172cdf0e10cSrcweir     Color   aColorAry2[7];
173cdf0e10cSrcweir     aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );  // light-gray
174cdf0e10cSrcweir     aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );  // yellow
175cdf0e10cSrcweir     aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );  // white
176cdf0e10cSrcweir     aColorAry1[3] = Color( 0x80, 0x80, 0x80 );  // dark-gray
177cdf0e10cSrcweir     aColorAry1[4] = Color( 0x00, 0x00, 0x00 );  // black
178cdf0e10cSrcweir     aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );  // green
179cdf0e10cSrcweir     aColorAry1[6] = Color( 0x00, 0x00, 0xFF );  // blue
180cdf0e10cSrcweir     aColorAry2[0] = rStyles.GetDialogColor();       // background
181cdf0e10cSrcweir     aColorAry2[1] = rStyles.GetWindowColor();
182cdf0e10cSrcweir     aColorAry2[2] = rStyles.GetLightColor();
183cdf0e10cSrcweir     aColorAry2[3] = rStyles.GetShadowColor();
184cdf0e10cSrcweir     aColorAry2[4] = rStyles.GetDarkShadowColor();
185cdf0e10cSrcweir     aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
186cdf0e10cSrcweir     aColorAry2[6] = rStyles.GetDialogColor();
187cdf0e10cSrcweir 
188cdf0e10cSrcweir #ifdef DBG_UTIL
189cdf0e10cSrcweir     static sal_Bool     bModify = sal_False;
190cdf0e10cSrcweir     sal_Bool&           rModify = bModify;
191cdf0e10cSrcweir     if( rModify )
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         static int      n = 0;
194cdf0e10cSrcweir         static sal_uInt8    r = 0xFF;
195cdf0e10cSrcweir         static sal_uInt8    g = 0x00;
196cdf0e10cSrcweir         static sal_uInt8    b = 0xFF;
197cdf0e10cSrcweir         int&            rn = n;
198cdf0e10cSrcweir         sal_uInt8&          rr = r;
199cdf0e10cSrcweir         sal_uInt8&          rg = g;
200cdf0e10cSrcweir         sal_uInt8&          rb = b;
201cdf0e10cSrcweir         aColorAry2[ rn ] = Color( rr, rg, rb );
202cdf0e10cSrcweir     }
203cdf0e10cSrcweir #endif
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // -----------------------------------------------------------------------
209cdf0e10cSrcweir 
InitSettings(sal_Bool bForeground,sal_Bool bBackground)210cdf0e10cSrcweir void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     if( bForeground )
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         svtools::ColorConfig aColorConfig;
217cdf0e10cSrcweir         Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         if ( IsControlForeground() )
220cdf0e10cSrcweir             aTextColor = GetControlForeground();
221cdf0e10cSrcweir         SetTextColor( aTextColor );
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     if( bBackground )
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         if ( IsControlBackground() )
227cdf0e10cSrcweir             SetBackground( GetControlBackground() );
228cdf0e10cSrcweir         else
229cdf0e10cSrcweir             SetBackground( rStyleSettings.GetWindowColor() );
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     delete pBitmap;
233cdf0e10cSrcweir     pBitmap = NULL;     // forces new creating of bitmap
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     Invalidate();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir /*************************************************************************
239a787b805SMechtilde |*  The selected rectangle (3 x 3) is identified and the parent (dialog)
240a787b805SMechtilde |*  is notified that the point has been changed
241cdf0e10cSrcweir \************************************************************************/
242cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)243cdf0e10cSrcweir void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
246cdf0e10cSrcweir     if(!IsCompletelyDisabled())
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         Point aPtLast = aPtNew;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
253cdf0e10cSrcweir         {
254cdf0e10cSrcweir             aPtNew = aPtLast;
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir         else
257cdf0e10cSrcweir         {
258cdf0e10cSrcweir             Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
259cdf0e10cSrcweir                                    aPtLast + Point( nRadius, nRadius ) ) );
260cdf0e10cSrcweir             Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
261cdf0e10cSrcweir                                    aPtNew + Point( nRadius, nRadius ) ) );
262cdf0e10cSrcweir             eRP = GetRPFromPoint( aPtNew );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir             SetActualRP( eRP );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir             if( WINDOW_TABPAGE == GetParent()->GetType() )
267cdf0e10cSrcweir                 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
268cdf0e10cSrcweir         }
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir // -----------------------------------------------------------------------
273cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKeyEvt)274cdf0e10cSrcweir void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
277cdf0e10cSrcweir     if(!IsCompletelyDisabled())
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         RECT_POINT eNewRP = eRP;
280cdf0e10cSrcweir         sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
281cdf0e10cSrcweir 
282cdf0e10cSrcweir         switch( rKeyEvt.GetKeyCode().GetCode() )
283cdf0e10cSrcweir         {
284cdf0e10cSrcweir             case KEY_DOWN:
285cdf0e10cSrcweir             {
286cdf0e10cSrcweir                 if( !(m_nState & CS_NOVERT) )
287cdf0e10cSrcweir                     switch( eNewRP )
288cdf0e10cSrcweir                     {
289cdf0e10cSrcweir                         case RP_LT: eNewRP = RP_LM; break;
290cdf0e10cSrcweir                         case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
291cdf0e10cSrcweir                         case RP_RT: eNewRP = RP_RM; break;
292cdf0e10cSrcweir                         case RP_LM: eNewRP = RP_LB; break;
293cdf0e10cSrcweir                         case RP_MM: eNewRP = RP_MB; break;
294cdf0e10cSrcweir                         case RP_RM: eNewRP = RP_RB; break;
295cdf0e10cSrcweir                         default: ; //prevent warning
296cdf0e10cSrcweir                     }
297cdf0e10cSrcweir             }
298cdf0e10cSrcweir             break;
299cdf0e10cSrcweir             case KEY_UP:
300cdf0e10cSrcweir             {
301cdf0e10cSrcweir                 if( !(m_nState & CS_NOVERT) )
302cdf0e10cSrcweir                     switch( eNewRP )
303cdf0e10cSrcweir                     {
304cdf0e10cSrcweir                         case RP_LM: eNewRP = RP_LT; break;
305cdf0e10cSrcweir                         case RP_MM: eNewRP = RP_MT; break;
306cdf0e10cSrcweir                         case RP_RM: eNewRP = RP_RT; break;
307cdf0e10cSrcweir                         case RP_LB: eNewRP = RP_LM; break;
308cdf0e10cSrcweir                         case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
309cdf0e10cSrcweir                         case RP_RB: eNewRP = RP_RM; break;
310cdf0e10cSrcweir                         default: ; //prevent warning
311cdf0e10cSrcweir                     }
312cdf0e10cSrcweir             }
313cdf0e10cSrcweir             break;
314cdf0e10cSrcweir             case KEY_LEFT:
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 if( !(m_nState & CS_NOHORZ) )
317cdf0e10cSrcweir                     switch( eNewRP )
318cdf0e10cSrcweir                     {
319cdf0e10cSrcweir                         case RP_MT: eNewRP = RP_LT; break;
320cdf0e10cSrcweir                         case RP_RT: eNewRP = RP_MT; break;
321cdf0e10cSrcweir                         case RP_MM: eNewRP = RP_LM; break;
322cdf0e10cSrcweir                         case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
323cdf0e10cSrcweir                         case RP_MB: eNewRP = RP_LB; break;
324cdf0e10cSrcweir                         case RP_RB: eNewRP = RP_MB; break;
325cdf0e10cSrcweir                         default: ; //prevent warning
326cdf0e10cSrcweir                     }
327cdf0e10cSrcweir             }
328cdf0e10cSrcweir             break;
329cdf0e10cSrcweir             case KEY_RIGHT:
330cdf0e10cSrcweir             {
331cdf0e10cSrcweir                 if( !(m_nState & CS_NOHORZ) )
332cdf0e10cSrcweir                     switch( eNewRP )
333cdf0e10cSrcweir                     {
334cdf0e10cSrcweir                         case RP_LT: eNewRP = RP_MT; break;
335cdf0e10cSrcweir                         case RP_MT: eNewRP = RP_RT; break;
336cdf0e10cSrcweir                         case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
337cdf0e10cSrcweir                         case RP_MM: eNewRP = RP_RM; break;
338cdf0e10cSrcweir                         case RP_LB: eNewRP = RP_MB; break;
339cdf0e10cSrcweir                         case RP_MB: eNewRP = RP_RB; break;
340cdf0e10cSrcweir                         default: ; //prevent warning
341cdf0e10cSrcweir                     }
342cdf0e10cSrcweir             }
343cdf0e10cSrcweir             break;
344cdf0e10cSrcweir             default:
345cdf0e10cSrcweir                 Control::KeyInput( rKeyEvt );
346cdf0e10cSrcweir                 return;
347cdf0e10cSrcweir         }
348cdf0e10cSrcweir         if( eNewRP != eRP )
349cdf0e10cSrcweir         {
350cdf0e10cSrcweir             SetActualRP( eNewRP );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir             if( WINDOW_TABPAGE == GetParent()->GetType() )
353cdf0e10cSrcweir                 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir             SetFocusRect();
356cdf0e10cSrcweir         }
357cdf0e10cSrcweir     }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir // -----------------------------------------------------------------------
361cdf0e10cSrcweir 
StateChanged(StateChangedType nType)362cdf0e10cSrcweir void SvxRectCtl::StateChanged( StateChangedType nType )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
365cdf0e10cSrcweir         InitSettings( sal_True, sal_False );
366cdf0e10cSrcweir     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
367cdf0e10cSrcweir         InitSettings( sal_False, sal_True );
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     Window::StateChanged( nType );
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir // -----------------------------------------------------------------------
373cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)374cdf0e10cSrcweir void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
377cdf0e10cSrcweir         InitSettings( sal_True, sal_True );
378cdf0e10cSrcweir     else
379cdf0e10cSrcweir         Window::DataChanged( rDCEvt );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir /*************************************************************************
383a787b805SMechtilde |*  Draw the control (rectangle with 9 circles)
384cdf0e10cSrcweir \************************************************************************/
385cdf0e10cSrcweir 
Paint(const Rectangle &)386cdf0e10cSrcweir void SvxRectCtl::Paint( const Rectangle& )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     Point   aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     SetLineColor( rStyles.GetDialogColor() );
393cdf0e10cSrcweir     SetFillColor( rStyles.GetDialogColor() );
394cdf0e10cSrcweir     DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     if( IsEnabled() )
397cdf0e10cSrcweir         SetLineColor( rStyles.GetLabelTextColor() );
398cdf0e10cSrcweir     else
399cdf0e10cSrcweir         SetLineColor( rStyles.GetShadowColor() );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     SetFillColor();
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     switch( eCS )
404cdf0e10cSrcweir     {
405cdf0e10cSrcweir 
406cdf0e10cSrcweir         case CS_RECT:
407cdf0e10cSrcweir         case CS_SHADOW:
408cdf0e10cSrcweir             if( !IsEnabled() )
409cdf0e10cSrcweir             {
410cdf0e10cSrcweir                 Color aOldCol = GetLineColor();
411cdf0e10cSrcweir                 SetLineColor( rStyles.GetLightColor() );
412cdf0e10cSrcweir                 DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
413cdf0e10cSrcweir                 SetLineColor( aOldCol );
414cdf0e10cSrcweir             }
415cdf0e10cSrcweir             DrawRect( Rectangle( aPtLT, aPtRB ) );
416cdf0e10cSrcweir         break;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir         case CS_LINE:
419cdf0e10cSrcweir             if( !IsEnabled() )
420cdf0e10cSrcweir             {
421cdf0e10cSrcweir                 Color aOldCol = GetLineColor();
422cdf0e10cSrcweir                 SetLineColor( rStyles.GetLightColor() );
423cdf0e10cSrcweir                 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
424cdf0e10cSrcweir                           aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
425cdf0e10cSrcweir                 SetLineColor( aOldCol );
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir             DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
428cdf0e10cSrcweir                       aPtRM + Point( 2 * nBorderWidth, 0 ) );
429cdf0e10cSrcweir         break;
430cdf0e10cSrcweir 
431cdf0e10cSrcweir         case CS_ANGLE:
432cdf0e10cSrcweir             if( !IsEnabled() )
433cdf0e10cSrcweir             {
434cdf0e10cSrcweir                 Color aOldCol = GetLineColor();
435cdf0e10cSrcweir                 SetLineColor( rStyles.GetLightColor() );
436cdf0e10cSrcweir                 DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
437cdf0e10cSrcweir                 DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
438cdf0e10cSrcweir                 DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
439cdf0e10cSrcweir                 DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
440cdf0e10cSrcweir                 SetLineColor( aOldCol );
441cdf0e10cSrcweir             }
442cdf0e10cSrcweir             DrawLine( aPtLT, aPtRB );
443cdf0e10cSrcweir             DrawLine( aPtLB, aPtRT );
444cdf0e10cSrcweir             DrawLine( aPtLM, aPtRM );
445cdf0e10cSrcweir             DrawLine( aPtMT, aPtMB );
446cdf0e10cSrcweir         break;
447cdf0e10cSrcweir 
448cdf0e10cSrcweir         default:
449cdf0e10cSrcweir             break;
450cdf0e10cSrcweir     }
451cdf0e10cSrcweir     SetFillColor( GetBackground().GetColor() );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     Size aBtnSize( 11, 11 );
454cdf0e10cSrcweir     Size aDstBtnSize(  PixelToLogic( aBtnSize ) );
455cdf0e10cSrcweir     Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
456cdf0e10cSrcweir     Point aBtnPnt1( IsEnabled()?0:22,0 );
457cdf0e10cSrcweir     Point aBtnPnt2( 11,0 );
458cdf0e10cSrcweir     Point aBtnPnt3( 22,0 );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir     sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
461cdf0e10cSrcweir     sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0;
462cdf0e10cSrcweir 
463cdf0e10cSrcweir     Bitmap&         rBitmap = GetRectBitmap();
464cdf0e10cSrcweir 
465cdf0e10cSrcweir     // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
466cdf0e10cSrcweir     if(IsCompletelyDisabled())
467cdf0e10cSrcweir     {
468cdf0e10cSrcweir         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
469cdf0e10cSrcweir         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
470cdf0e10cSrcweir         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
471cdf0e10cSrcweir         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
472cdf0e10cSrcweir         if( eCS == CS_RECT || eCS == CS_LINE )
473cdf0e10cSrcweir             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
474cdf0e10cSrcweir         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
475cdf0e10cSrcweir         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
476cdf0e10cSrcweir         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
477cdf0e10cSrcweir         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
478cdf0e10cSrcweir     }
479cdf0e10cSrcweir     else
480cdf0e10cSrcweir     {
481cdf0e10cSrcweir         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
482cdf0e10cSrcweir         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
483cdf0e10cSrcweir         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
486cdf0e10cSrcweir 
487a787b805SMechtilde         // Center point for rectangle and line
488cdf0e10cSrcweir         if( eCS == CS_RECT || eCS == CS_LINE )
489cdf0e10cSrcweir             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
490cdf0e10cSrcweir 
491cdf0e10cSrcweir         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
494cdf0e10cSrcweir         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
495cdf0e10cSrcweir         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
496cdf0e10cSrcweir     }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir     // draw active button, avoid center pos for angle
499cdf0e10cSrcweir     // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
500cdf0e10cSrcweir     if(!IsCompletelyDisabled())
501cdf0e10cSrcweir     {
502cdf0e10cSrcweir         if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             Point       aCenterPt( aPtNew );
505cdf0e10cSrcweir             aCenterPt -= aToCenter;
506cdf0e10cSrcweir 
507cdf0e10cSrcweir             DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
508cdf0e10cSrcweir         }
509cdf0e10cSrcweir     }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir /*************************************************************************
513a787b805SMechtilde |*  Converted RECT_POINT in Point
514cdf0e10cSrcweir \************************************************************************/
515cdf0e10cSrcweir 
GetPointFromRP(RECT_POINT _eRP) const516cdf0e10cSrcweir Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
517cdf0e10cSrcweir {
518cdf0e10cSrcweir     switch( _eRP )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         case RP_LT: return aPtLT;
521cdf0e10cSrcweir         case RP_MT: return aPtMT;
522cdf0e10cSrcweir         case RP_RT: return aPtRT;
523cdf0e10cSrcweir         case RP_LM: return aPtLM;
524cdf0e10cSrcweir         case RP_MM: return aPtMM;
525cdf0e10cSrcweir         case RP_RM: return aPtRM;
526cdf0e10cSrcweir         case RP_LB: return aPtLB;
527cdf0e10cSrcweir         case RP_MB: return aPtMB;
528cdf0e10cSrcweir         case RP_RB: return aPtRB;
529cdf0e10cSrcweir     }
530cdf0e10cSrcweir     return( aPtMM ); // default
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
SetFocusRect(const Rectangle * pRect)534cdf0e10cSrcweir void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir     HideFocus();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir     if( pRect )
539cdf0e10cSrcweir         ShowFocus( *pRect );
540cdf0e10cSrcweir     else
541cdf0e10cSrcweir         ShowFocus( CalculateFocusRectangle() );
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
SetActualRPWithoutInvalidate(RECT_POINT eNewRP)544cdf0e10cSrcweir Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir     Point aPtLast = aPtNew;
547cdf0e10cSrcweir     aPtNew = GetPointFromRP( eNewRP );
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     if( (m_nState & CS_NOHORZ) != 0 )
550cdf0e10cSrcweir         aPtNew.X() = aPtMM.X();
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     if( (m_nState & CS_NOVERT) != 0 )
553cdf0e10cSrcweir         aPtNew.Y() = aPtMM.Y();
554cdf0e10cSrcweir 
555cdf0e10cSrcweir     eNewRP = GetRPFromPoint( aPtNew );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir     eDefRP = eNewRP;
558cdf0e10cSrcweir     eRP = eNewRP;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     return aPtLast;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
GetFocus()563cdf0e10cSrcweir void SvxRectCtl::GetFocus()
564cdf0e10cSrcweir {
565cdf0e10cSrcweir     SetFocusRect();
5669b8096d0SSteve Yin     // Solution: Send the accessible focused event
5679b8096d0SSteve Yin     Control::GetFocus();
5689b8096d0SSteve Yin     // Send accessibility event.
5699b8096d0SSteve Yin     if(pAccContext)
5709b8096d0SSteve Yin     {
5719b8096d0SSteve Yin         pAccContext->FireChildFocus(GetActualRP());
5729b8096d0SSteve Yin     }
573cdf0e10cSrcweir }
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 
LoseFocus()576cdf0e10cSrcweir void SvxRectCtl::LoseFocus()
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     HideFocus();
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 
GetApproxLogPtFromPixPt(const Point & rPt) const582cdf0e10cSrcweir Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
583cdf0e10cSrcweir {
584cdf0e10cSrcweir     Point   aPt = PixelToLogic( rPt );
585cdf0e10cSrcweir     long    x;
586cdf0e10cSrcweir     long    y;
587cdf0e10cSrcweir 
588cdf0e10cSrcweir     if( ( m_nState & CS_NOHORZ ) == 0 )
589cdf0e10cSrcweir     {
590cdf0e10cSrcweir         if( aPt.X() < aSize.Width() / 3 )
591cdf0e10cSrcweir             x = aPtLT.X();
592cdf0e10cSrcweir         else if( aPt.X() < aSize.Width() * 2 / 3 )
593cdf0e10cSrcweir             x = aPtMM.X();
594cdf0e10cSrcweir         else
595cdf0e10cSrcweir             x = aPtRB.X();
596cdf0e10cSrcweir     }
597cdf0e10cSrcweir     else
598cdf0e10cSrcweir         x = aPtMM.X();
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     if( ( m_nState & CS_NOVERT ) == 0 )
601cdf0e10cSrcweir     {
602cdf0e10cSrcweir         if( aPt.Y() < aSize.Height() / 3 )
603cdf0e10cSrcweir             y = aPtLT.Y();
604cdf0e10cSrcweir         else if( aPt.Y() < aSize.Height() * 2 / 3 )
605cdf0e10cSrcweir             y = aPtMM.Y();
606cdf0e10cSrcweir         else
607cdf0e10cSrcweir             y = aPtRB.Y();
608cdf0e10cSrcweir     }
609cdf0e10cSrcweir     else
610cdf0e10cSrcweir             y = aPtMM.Y();
611cdf0e10cSrcweir 
612cdf0e10cSrcweir     return Point( x, y );
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 
616cdf0e10cSrcweir /*************************************************************************
617a787b805SMechtilde |*  Converted Point in RECT_POINT
618cdf0e10cSrcweir \************************************************************************/
619cdf0e10cSrcweir 
GetRPFromPoint(Point aPt) const620cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
621cdf0e10cSrcweir {
622cdf0e10cSrcweir     if     ( aPt == aPtLT) return RP_LT;
623cdf0e10cSrcweir     else if( aPt == aPtMT) return RP_MT;
624cdf0e10cSrcweir     else if( aPt == aPtRT) return RP_RT;
625cdf0e10cSrcweir     else if( aPt == aPtLM) return RP_LM;
626cdf0e10cSrcweir     else if( aPt == aPtRM) return RP_RM;
627cdf0e10cSrcweir     else if( aPt == aPtLB) return RP_LB;
628cdf0e10cSrcweir     else if( aPt == aPtMB) return RP_MB;
629cdf0e10cSrcweir     else if( aPt == aPtRB) return RP_RB;
630cdf0e10cSrcweir 
631cdf0e10cSrcweir     else
632cdf0e10cSrcweir         return RP_MM; // default
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir /*************************************************************************
636a787b805SMechtilde |*  Reset the original state of the controls
637cdf0e10cSrcweir \************************************************************************/
638cdf0e10cSrcweir 
Reset()639cdf0e10cSrcweir void SvxRectCtl::Reset()
640cdf0e10cSrcweir {
641cdf0e10cSrcweir     aPtNew = GetPointFromRP( eDefRP );
642cdf0e10cSrcweir     eRP = eDefRP;
643cdf0e10cSrcweir     Invalidate();
644cdf0e10cSrcweir }
645cdf0e10cSrcweir 
646cdf0e10cSrcweir /*************************************************************************
647a787b805SMechtilde |*  Returns the currently selected RECT_POINT
648cdf0e10cSrcweir \************************************************************************/
649cdf0e10cSrcweir 
GetActualRP() const650cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetActualRP() const
651cdf0e10cSrcweir {
652cdf0e10cSrcweir     return( eRP );
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir /*************************************************************************
656a787b805SMechtilde |*  Returns the currently selected RECT_POINT
657cdf0e10cSrcweir \************************************************************************/
SetActualRP(RECT_POINT eNewRP)6589b8096d0SSteve Yin void SvxRectCtl::SetActualRP( RECT_POINT eNewRP /* MT: , sal_Bool bFireFocus */ )
659cdf0e10cSrcweir {
6609b8096d0SSteve Yin     // MT: bFireFox as API parameter is ugly...
661cdf0e10cSrcweir     Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
662cdf0e10cSrcweir 
663cdf0e10cSrcweir     Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
664cdf0e10cSrcweir     Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
665cdf0e10cSrcweir 
666cdf0e10cSrcweir     // notify accessibility object about change
667cdf0e10cSrcweir     if( pAccContext )
6689b8096d0SSteve Yin         pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
669cdf0e10cSrcweir }
SetState(CTL_STATE nState)670cdf0e10cSrcweir void SvxRectCtl::SetState( CTL_STATE nState )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     m_nState = nState;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     Point aPtLast( GetPointFromRP( eRP ) );
675cdf0e10cSrcweir     Point _aPtNew( aPtLast );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     if( (m_nState & CS_NOHORZ) != 0 )
678cdf0e10cSrcweir         _aPtNew.X() = aPtMM.X();
679cdf0e10cSrcweir 
680cdf0e10cSrcweir     if( (m_nState & CS_NOVERT) != 0 )
681cdf0e10cSrcweir         _aPtNew.Y() = aPtMM.Y();
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     eRP = GetRPFromPoint( _aPtNew );
684cdf0e10cSrcweir     Invalidate();
685cdf0e10cSrcweir 
686cdf0e10cSrcweir     if( WINDOW_TABPAGE == GetParent()->GetType() )
687cdf0e10cSrcweir         ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
688cdf0e10cSrcweir }
689cdf0e10cSrcweir 
GetNumOfChilds(void) const690cdf0e10cSrcweir sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const
691cdf0e10cSrcweir {
692cdf0e10cSrcweir     return ( eCS == CS_ANGLE )? 8 : 9;
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
CalculateFocusRectangle(void) const695cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
696cdf0e10cSrcweir {
697cdf0e10cSrcweir     Size        aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
698cdf0e10cSrcweir     return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
CalculateFocusRectangle(RECT_POINT eRectPoint) const701cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
702cdf0e10cSrcweir {
703cdf0e10cSrcweir     Rectangle   aRet;
704cdf0e10cSrcweir     RECT_POINT  eOldRectPoint = GetActualRP();
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     if( eOldRectPoint == eRectPoint )
707cdf0e10cSrcweir         aRet = CalculateFocusRectangle();
708cdf0e10cSrcweir     else
709cdf0e10cSrcweir     {
710cdf0e10cSrcweir         SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
711cdf0e10cSrcweir 
712cdf0e10cSrcweir         pThis->SetActualRPWithoutInvalidate( eRectPoint );      // no invalidation because it's only temporary!
713cdf0e10cSrcweir         aRet = CalculateFocusRectangle();
714cdf0e10cSrcweir 
715cdf0e10cSrcweir         pThis->SetActualRPWithoutInvalidate( eOldRectPoint );   // no invalidation because nothing has changed!
716cdf0e10cSrcweir     }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     return aRet;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
CreateAccessible()721cdf0e10cSrcweir Reference< XAccessible > SvxRectCtl::CreateAccessible()
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     Window*                     pParent = GetAccessibleParentWindow();
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     Reference< XAccessible >    xAccParent = pParent->GetAccessible();
728cdf0e10cSrcweir     if( xAccParent.is() )
729cdf0e10cSrcweir     {
730cdf0e10cSrcweir         pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
731cdf0e10cSrcweir         pAccContext->acquire();
732cdf0e10cSrcweir 
733cdf0e10cSrcweir         SetActualRP( GetActualRP() );
734cdf0e10cSrcweir 
735cdf0e10cSrcweir         return pAccContext;
736cdf0e10cSrcweir     }
737cdf0e10cSrcweir     else
738cdf0e10cSrcweir         return Reference< XAccessible >();
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
GetApproxRPFromPixPt(const::com::sun::star::awt::Point & r) const741cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
DoCompletelyDisable(sal_Bool bNew)747cdf0e10cSrcweir void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     mbCompleteDisable = bNew;
750cdf0e10cSrcweir     Invalidate();
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir /*************************************************************************
754a787b805SMechtilde |* Constructor without size parameter
755cdf0e10cSrcweir \************************************************************************/
756cdf0e10cSrcweir 
SvxAngleCtl(Window * pParent,const ResId & rResId)757cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
758cdf0e10cSrcweir 
759cdf0e10cSrcweir     SvxRectCtl( pParent, rResId ),
760cdf0e10cSrcweir 
761cdf0e10cSrcweir     aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
762cdf0e10cSrcweir {
763cdf0e10cSrcweir     aFontSize = Size( 250, 400 );
764cdf0e10cSrcweir     Initialize();
765cdf0e10cSrcweir }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir /*************************************************************************
768a787b805SMechtilde |* Constructor with size parameter
769cdf0e10cSrcweir \************************************************************************/
770cdf0e10cSrcweir 
SvxAngleCtl(Window * pParent,const ResId & rResId,Size _aSize)771cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
772cdf0e10cSrcweir 
773cdf0e10cSrcweir     SvxRectCtl( pParent, rResId ),
774cdf0e10cSrcweir 
775cdf0e10cSrcweir     aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
776cdf0e10cSrcweir {
777cdf0e10cSrcweir     aFontSize = _aSize;
778cdf0e10cSrcweir     Initialize();
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir /*************************************************************************
782*633aadc5Smseidel |* Initialization
783cdf0e10cSrcweir \************************************************************************/
784cdf0e10cSrcweir 
Initialize()785cdf0e10cSrcweir void SvxAngleCtl::Initialize()
786cdf0e10cSrcweir {
787cdf0e10cSrcweir     bPositive = sal_True;
788cdf0e10cSrcweir 
789cdf0e10cSrcweir     // aFont.SetName( "Helvetica" );
790cdf0e10cSrcweir     aFont.SetSize( aFontSize );
791cdf0e10cSrcweir     aFont.SetWeight( WEIGHT_NORMAL );
792cdf0e10cSrcweir     aFont.SetTransparent( sal_False );
793cdf0e10cSrcweir 
794cdf0e10cSrcweir     SetFont( aFont );
795cdf0e10cSrcweir }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir /*************************************************************************
798a787b805SMechtilde |*  Draw the (mini) coordinate system
799cdf0e10cSrcweir \************************************************************************/
800cdf0e10cSrcweir 
Paint(const Rectangle &)801cdf0e10cSrcweir void SvxAngleCtl::Paint( const Rectangle& )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     SetLineColor( Color( COL_BLACK ) );     // PEN_DOT ???
804cdf0e10cSrcweir     DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
805cdf0e10cSrcweir     DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
806cdf0e10cSrcweir 
807cdf0e10cSrcweir     SetLineColor( Color( COL_BLACK ) );
808cdf0e10cSrcweir     DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
809cdf0e10cSrcweir     DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
812cdf0e10cSrcweir 
813cdf0e10cSrcweir     DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
814cdf0e10cSrcweir                              RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
815cdf0e10cSrcweir     DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
816cdf0e10cSrcweir                              RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     if ( bPositive )
819cdf0e10cSrcweir         DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
820cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
821cdf0e10cSrcweir     else
822cdf0e10cSrcweir         DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
823cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     aDiff.X() = aFontSize.Width();
826cdf0e10cSrcweir     DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
827cdf0e10cSrcweir                              RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
828cdf0e10cSrcweir     DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
829cdf0e10cSrcweir                              RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
830cdf0e10cSrcweir     aDiff.X() = aDiff .X() * 3 / 2;
831cdf0e10cSrcweir 
832cdf0e10cSrcweir     if ( bPositive )
833cdf0e10cSrcweir         DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
834cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
835cdf0e10cSrcweir     else
836cdf0e10cSrcweir         DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
837cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
838cdf0e10cSrcweir 
839cdf0e10cSrcweir     DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
840cdf0e10cSrcweir                                              RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
841cdf0e10cSrcweir     aDiff.X() = aFontSize.Width() * 2;
842cdf0e10cSrcweir 
843cdf0e10cSrcweir     if ( bPositive )
844cdf0e10cSrcweir         DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
845cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
846cdf0e10cSrcweir     else
847cdf0e10cSrcweir         DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
848cdf0e10cSrcweir                                  RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir /*************************************************************************
852a787b805SMechtilde |*  Control to edit bitmaps
853cdf0e10cSrcweir \************************************************************************/
854cdf0e10cSrcweir 
CreateAccessible()8559b8096d0SSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
8569b8096d0SSteve Yin {
8579b8096d0SSteve Yin     if(!m_xAccess.is())
8589b8096d0SSteve Yin     {
8599b8096d0SSteve Yin         m_xAccess = m_pAccess = new SvxPixelCtlAccessible(*this);
8609b8096d0SSteve Yin     }
8619b8096d0SSteve Yin     return m_xAccess;
8629b8096d0SSteve Yin }
8639b8096d0SSteve Yin 
8649b8096d0SSteve Yin // Logic Pixel
PointToIndex(const Point & aPt) const8659b8096d0SSteve Yin long SvxPixelCtl::PointToIndex(const Point &aPt) const
8669b8096d0SSteve Yin {
8679b8096d0SSteve Yin     sal_uInt16  nX, nY;
8689b8096d0SSteve Yin 
8699b8096d0SSteve Yin     nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
8709b8096d0SSteve Yin     nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
8719b8096d0SSteve Yin 
8729b8096d0SSteve Yin     return nX + nY * nLines ;
8739b8096d0SSteve Yin }
IndexToPoint(long nIndex) const8749b8096d0SSteve Yin Point SvxPixelCtl::IndexToPoint(long nIndex) const
8759b8096d0SSteve Yin {
8769b8096d0SSteve Yin     DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
8779b8096d0SSteve Yin 
8789b8096d0SSteve Yin     sal_uInt16 nXIndex = nIndex % nLines ;
8799b8096d0SSteve Yin     sal_uInt16 nYIndex = sal_uInt16(nIndex / nLines) ;
8809b8096d0SSteve Yin 
8819b8096d0SSteve Yin     Point aPtTl;
8829b8096d0SSteve Yin     aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1;
8839b8096d0SSteve Yin     aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1;
8849b8096d0SSteve Yin 
8859b8096d0SSteve Yin     return aPtTl;
8869b8096d0SSteve Yin }
GetFoucsPosIndex() const8879b8096d0SSteve Yin long SvxPixelCtl::GetFoucsPosIndex() const
8889b8096d0SSteve Yin {
8899b8096d0SSteve Yin     return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
8909b8096d0SSteve Yin }
ShowPosition(const Point & pt)8919b8096d0SSteve Yin long SvxPixelCtl::ShowPosition( const Point &pt)
8929b8096d0SSteve Yin {
8939b8096d0SSteve Yin     Point aPt = PixelToLogic( pt );
8949b8096d0SSteve Yin 
8959b8096d0SSteve Yin     sal_uInt16  nX, nY;
8969b8096d0SSteve Yin     nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
8979b8096d0SSteve Yin     nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
8989b8096d0SSteve Yin 
8999b8096d0SSteve Yin     ChangePixel( nX + nY * nLines );
9009b8096d0SSteve Yin 
9019b8096d0SSteve Yin     // Solution:Set new focus position and repaint
9029b8096d0SSteve Yin     // Invalidate( Rectangle( aPtTl, aPtBr ) );
9039b8096d0SSteve Yin     aFocusPosition.setX(nX);
9049b8096d0SSteve Yin     aFocusPosition.setY(nY);
9059b8096d0SSteve Yin     Invalidate(Rectangle(Point(0,0),aRectSize));
9069b8096d0SSteve Yin 
9079b8096d0SSteve Yin     if( WINDOW_TABPAGE == GetParent()->GetType() )
908*633aadc5Smseidel         ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint is dummy
9099b8096d0SSteve Yin 
9109b8096d0SSteve Yin     return GetFoucsPosIndex();
9119b8096d0SSteve Yin 
9129b8096d0SSteve Yin }
SvxPixelCtl(Window * pParent,const ResId & rResId,sal_uInt16 nNumber)913cdf0e10cSrcweir SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
914cdf0e10cSrcweir                         Control     ( pParent, rResId ),
915cdf0e10cSrcweir                         nLines      ( nNumber ),
916cdf0e10cSrcweir                         bPaintable  ( sal_True )
917*633aadc5Smseidel                         // Solution:Initialize its value to Point(0,0)
9189b8096d0SSteve Yin                         ,aFocusPosition(0,0)
919cdf0e10cSrcweir {
920cdf0e10cSrcweir     // SetMapMode( MAP_100TH_MM );
921cdf0e10cSrcweir     aRectSize = GetOutputSize();
922cdf0e10cSrcweir 
923cdf0e10cSrcweir     SetPixelColor( Color( COL_BLACK ) );
924cdf0e10cSrcweir     SetBackgroundColor( Color( COL_WHITE ) );
925cdf0e10cSrcweir     SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
926cdf0e10cSrcweir 
927cdf0e10cSrcweir     nSquares = nLines * nLines;
928cdf0e10cSrcweir     pPixel = new sal_uInt16[ nSquares ];
929cdf0e10cSrcweir     rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
9309b8096d0SSteve Yin     m_pAccess=NULL;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir /*************************************************************************
934cdf0e10cSrcweir |*  Destruktor dealociert dyn. Array
935cdf0e10cSrcweir \************************************************************************/
936cdf0e10cSrcweir 
~SvxPixelCtl()937cdf0e10cSrcweir SvxPixelCtl::~SvxPixelCtl( )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir     delete []pPixel;
940cdf0e10cSrcweir }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir /*************************************************************************
943a787b805SMechtilde |*  Change the foreground or background color
944cdf0e10cSrcweir \************************************************************************/
945cdf0e10cSrcweir 
ChangePixel(sal_uInt16 nPixel)946cdf0e10cSrcweir void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir     if( *( pPixel + nPixel) == 0 )
949a787b805SMechtilde         *( pPixel + nPixel) = 1; // could be expand for more colors
950cdf0e10cSrcweir     else
951cdf0e10cSrcweir         *( pPixel + nPixel) = 0;
952cdf0e10cSrcweir }
953cdf0e10cSrcweir 
954cdf0e10cSrcweir /*************************************************************************
955a787b805SMechtilde |*  The selected rectangle is identified to change the color
956cdf0e10cSrcweir \************************************************************************/
957cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)958cdf0e10cSrcweir void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
959cdf0e10cSrcweir {
9609b8096d0SSteve Yin     //Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
9619b8096d0SSteve Yin     //Point aPtTl, aPtBr;
9629b8096d0SSteve Yin     //sal_uInt16    nX, nY;
963cdf0e10cSrcweir 
9649b8096d0SSteve Yin     //nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
9659b8096d0SSteve Yin     //nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
966cdf0e10cSrcweir 
9679b8096d0SSteve Yin     //ChangePixel( nX + nY * nLines );
968cdf0e10cSrcweir 
9699b8096d0SSteve Yin     //aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
9709b8096d0SSteve Yin     //aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
9719b8096d0SSteve Yin     //aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
9729b8096d0SSteve Yin     //aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
973cdf0e10cSrcweir 
9749b8096d0SSteve Yin     //Invalidate( Rectangle( aPtTl, aPtBr ) );
975cdf0e10cSrcweir 
9769b8096d0SSteve Yin     //if( WINDOW_TABPAGE == GetParent()->GetType() )
9779b8096d0SSteve Yin     //  ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
9789b8096d0SSteve Yin     //Solution:Grab focus when click in window
9799b8096d0SSteve Yin     if( !HasFocus() )
9809b8096d0SSteve Yin     {
9819b8096d0SSteve Yin         GrabFocus();
9829b8096d0SSteve Yin     }
9839b8096d0SSteve Yin     long nIndex = ShowPosition(rMEvt.GetPosPixel());
9849b8096d0SSteve Yin 
9859b8096d0SSteve Yin     if(m_pAccess)
9869b8096d0SSteve Yin     {
9879b8096d0SSteve Yin         m_pAccess->NotifyChild(nIndex,sal_True,sal_True);
9889b8096d0SSteve Yin     }
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir /*************************************************************************
992a787b805SMechtilde |*  Draw the control (rectangle with 9 circles)
993cdf0e10cSrcweir \************************************************************************/
994cdf0e10cSrcweir 
Paint(const Rectangle &)995cdf0e10cSrcweir void SvxPixelCtl::Paint( const Rectangle& )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir     sal_uInt16  i, j, nTmp;
998cdf0e10cSrcweir     Point   aPtTl, aPtBr;
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     if( bPaintable )
1001cdf0e10cSrcweir     {
1002a787b805SMechtilde         // Draw lines
1003cdf0e10cSrcweir         Control::SetLineColor( aLineColor );
1004cdf0e10cSrcweir         for( i = 1; i < nLines; i++)
1005cdf0e10cSrcweir         {
1006cdf0e10cSrcweir             // horizontal
1007cdf0e10cSrcweir             nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
1008cdf0e10cSrcweir             DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
1009a787b805SMechtilde             // vertical
1010cdf0e10cSrcweir             nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
1011cdf0e10cSrcweir             DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
1012cdf0e10cSrcweir         }
1013cdf0e10cSrcweir 
1014a787b805SMechtilde         // Draw rectangles (squares)
1015cdf0e10cSrcweir         Control::SetLineColor();
1016cdf0e10cSrcweir         sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir         for( i = 0; i < nLines; i++)
1019cdf0e10cSrcweir         {
1020cdf0e10cSrcweir             aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
1021cdf0e10cSrcweir             aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir             for( j = 0; j < nLines; j++)
1024cdf0e10cSrcweir             {
1025cdf0e10cSrcweir                 aPtTl.X() = aRectSize.Width() * j / nLines + 1;
1026cdf0e10cSrcweir                 aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir                 if ( *( pPixel + i * nLines + j ) != nLastPixel )
1029cdf0e10cSrcweir                 {
1030cdf0e10cSrcweir                     nLastPixel = *( pPixel + i * nLines + j );
1031a787b805SMechtilde                     // Change color: 0 -> background color
1032cdf0e10cSrcweir                     SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
1033cdf0e10cSrcweir                 }
1034cdf0e10cSrcweir                 DrawRect( Rectangle( aPtTl, aPtBr ) );
1035cdf0e10cSrcweir             }
1036cdf0e10cSrcweir         }
10379b8096d0SSteve Yin         // Solution:Draw visual focus when has focus
10389b8096d0SSteve Yin         if( HasFocus() )
10399b8096d0SSteve Yin         {
10409b8096d0SSteve Yin             ShowFocus(implCalFocusRect(aFocusPosition));
10419b8096d0SSteve Yin         }
1042cdf0e10cSrcweir     } // bPaintable
1043cdf0e10cSrcweir     else
1044cdf0e10cSrcweir     {
1045cdf0e10cSrcweir         SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
1046cdf0e10cSrcweir         Control::SetLineColor( Color( COL_LIGHTRED ) );
1047cdf0e10cSrcweir         DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
1048cdf0e10cSrcweir         DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
1049cdf0e10cSrcweir     }
1050cdf0e10cSrcweir }
1051*633aadc5Smseidel // Solution:Calculate visual focus rectangle via focus position
implCalFocusRect(const Point & aPosition)10529b8096d0SSteve Yin Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition )
10539b8096d0SSteve Yin {
10549b8096d0SSteve Yin     long nLeft,nTop,nRight,nBottom;
10559b8096d0SSteve Yin     long i,j;
10569b8096d0SSteve Yin     i = aPosition.Y();
10579b8096d0SSteve Yin     j = aPosition.X();
10589b8096d0SSteve Yin     nLeft = aRectSize.Width() * j / nLines + 1;
10599b8096d0SSteve Yin     nRight = aRectSize.Width() * (j + 1) / nLines - 1;
10609b8096d0SSteve Yin     nTop = aRectSize.Height() * i / nLines + 1;
10619b8096d0SSteve Yin     nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
10629b8096d0SSteve Yin     return Rectangle(nLeft,nTop,nRight,nBottom);
10639b8096d0SSteve Yin }
10649b8096d0SSteve Yin 
106586e1cf34SPedro Giffuni // Solution:Keyboard function
KeyInput(const KeyEvent & rKEvt)10669b8096d0SSteve Yin void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
10679b8096d0SSteve Yin {
10689b8096d0SSteve Yin     KeyCode aKeyCode = rKEvt.GetKeyCode();
10699b8096d0SSteve Yin     sal_uInt16 nCode = aKeyCode.GetCode();
10709b8096d0SSteve Yin     sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
10719b8096d0SSteve Yin 
10729b8096d0SSteve Yin     if( !bIsMod )
10739b8096d0SSteve Yin     {
10749b8096d0SSteve Yin         Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
10759b8096d0SSteve Yin                              aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
10769b8096d0SSteve Yin                             );
10779b8096d0SSteve Yin         Size  mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
10789b8096d0SSteve Yin         Rectangle mRepaintRect( pRepaintPoint, mRepaintSize );
10799b8096d0SSteve Yin         sal_Bool bFocusPosChanged=sal_False;
10809b8096d0SSteve Yin         switch(nCode)
10819b8096d0SSteve Yin         {
10829b8096d0SSteve Yin             case KEY_LEFT:
10839b8096d0SSteve Yin                 if((aFocusPosition.getX() >= 1))
10849b8096d0SSteve Yin                 {
10859b8096d0SSteve Yin                     aFocusPosition.setX( aFocusPosition.getX() - 1 );
10869b8096d0SSteve Yin                     Invalidate(mRepaintRect);
10879b8096d0SSteve Yin                     bFocusPosChanged=sal_True;
10889b8096d0SSteve Yin                 }
10899b8096d0SSteve Yin                 break;
10909b8096d0SSteve Yin             case KEY_RIGHT:
10919b8096d0SSteve Yin                 if( aFocusPosition.getX() < (nLines - 1) )
10929b8096d0SSteve Yin                 {
10939b8096d0SSteve Yin                     aFocusPosition.setX( aFocusPosition.getX() + 1 );
10949b8096d0SSteve Yin                     Invalidate(mRepaintRect);
10959b8096d0SSteve Yin                     bFocusPosChanged=sal_True;
10969b8096d0SSteve Yin                 }
10979b8096d0SSteve Yin                 break;
10989b8096d0SSteve Yin             case KEY_UP:
10999b8096d0SSteve Yin                 if((aFocusPosition.getY() >= 1))
11009b8096d0SSteve Yin                 {
11019b8096d0SSteve Yin                     aFocusPosition.setY( aFocusPosition.getY() - 1 );
11029b8096d0SSteve Yin                     Invalidate(mRepaintRect);
11039b8096d0SSteve Yin                     bFocusPosChanged=sal_True;
11049b8096d0SSteve Yin                 }
11059b8096d0SSteve Yin                 break;
11069b8096d0SSteve Yin             case KEY_DOWN:
11079b8096d0SSteve Yin                 if( aFocusPosition.getY() < ( nLines - 1 ) )
11089b8096d0SSteve Yin                 {
11099b8096d0SSteve Yin                     aFocusPosition.setY( aFocusPosition.getY() + 1 );
11109b8096d0SSteve Yin                     Invalidate(mRepaintRect);
11119b8096d0SSteve Yin                     bFocusPosChanged=sal_True;
11129b8096d0SSteve Yin                 }
11139b8096d0SSteve Yin                 break;
11149b8096d0SSteve Yin             case KEY_SPACE:
11159b8096d0SSteve Yin                 ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
11169b8096d0SSteve Yin                 Invalidate( implCalFocusRect(aFocusPosition) );
11179b8096d0SSteve Yin                 break;
11189b8096d0SSteve Yin             default:
11199b8096d0SSteve Yin                 Control::KeyInput( rKEvt );
11209b8096d0SSteve Yin                 return;
11219b8096d0SSteve Yin         }
11229b8096d0SSteve Yin         if(m_xAccess.is())
11239b8096d0SSteve Yin         {
11249b8096d0SSteve Yin             long nIndex = GetFoucsPosIndex();
11259b8096d0SSteve Yin             switch(nCode)
11269b8096d0SSteve Yin             {
11279b8096d0SSteve Yin             case KEY_LEFT:
11289b8096d0SSteve Yin             case KEY_RIGHT:
11299b8096d0SSteve Yin             case KEY_UP:
11309b8096d0SSteve Yin             case KEY_DOWN:
11319b8096d0SSteve Yin                 if (bFocusPosChanged)
11329b8096d0SSteve Yin                 {
11339b8096d0SSteve Yin                     m_pAccess->NotifyChild(nIndex,sal_False,sal_False);
11349b8096d0SSteve Yin                 }
11359b8096d0SSteve Yin                 break;
11369b8096d0SSteve Yin             case KEY_SPACE:
11379b8096d0SSteve Yin                 m_pAccess->NotifyChild(nIndex,sal_False,sal_True);
11389b8096d0SSteve Yin                 break;
11399b8096d0SSteve Yin             default:
11409b8096d0SSteve Yin                 break;
11419b8096d0SSteve Yin             }
11429b8096d0SSteve Yin         }
11439b8096d0SSteve Yin     }
11449b8096d0SSteve Yin     else
11459b8096d0SSteve Yin     {
11469b8096d0SSteve Yin         Control::KeyInput( rKEvt );
11479b8096d0SSteve Yin     }
11489b8096d0SSteve Yin }
11499b8096d0SSteve Yin 
11509b8096d0SSteve Yin // Draw focus when get focus
GetFocus()11519b8096d0SSteve Yin void SvxPixelCtl::GetFocus()
11529b8096d0SSteve Yin {
11539b8096d0SSteve Yin     Invalidate(implCalFocusRect(aFocusPosition));
11549b8096d0SSteve Yin 
11559b8096d0SSteve Yin     if(m_pAccess)
11569b8096d0SSteve Yin     {
11579b8096d0SSteve Yin         m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False);
11589b8096d0SSteve Yin     }
11599b8096d0SSteve Yin 
11609b8096d0SSteve Yin     Control::GetFocus();
11619b8096d0SSteve Yin }
11629b8096d0SSteve Yin 
11639b8096d0SSteve Yin // Hide focus when lose focus
LoseFocus()11649b8096d0SSteve Yin void SvxPixelCtl::LoseFocus()
11659b8096d0SSteve Yin {
11669b8096d0SSteve Yin     HideFocus();
11679b8096d0SSteve Yin     if (m_pAccess)
11689b8096d0SSteve Yin     {
11699b8096d0SSteve Yin         m_pAccess->LoseFocus();
11709b8096d0SSteve Yin     }
11719b8096d0SSteve Yin     Control::LoseFocus();
11729b8096d0SSteve Yin }
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir /*************************************************************************
1175cdf0e10cSrcweir |*
1176cdf0e10cSrcweir \************************************************************************/
1177cdf0e10cSrcweir 
SetXBitmap(const BitmapEx & rBitmapEx)117870d3707aSArmin Le Grand void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
1179cdf0e10cSrcweir {
118070d3707aSArmin Le Grand     BitmapColor aBack;
118170d3707aSArmin Le Grand     BitmapColor aFront;
118270d3707aSArmin Le Grand 
118370d3707aSArmin Le Grand     if(isHistorical8x8(rBitmapEx, aBack, aFront))
1184cdf0e10cSrcweir     {
118570d3707aSArmin Le Grand         Bitmap aBitmap(rBitmapEx.GetBitmap());
118670d3707aSArmin Le Grand         BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
1187cdf0e10cSrcweir 
118870d3707aSArmin Le Grand         aBackgroundColor = aBack;
118970d3707aSArmin Le Grand         aPixelColor = aFront;
1190cdf0e10cSrcweir 
119170d3707aSArmin Le Grand         for(sal_uInt16 i(0); i < nSquares; i++)
119270d3707aSArmin Le Grand         {
119370d3707aSArmin Le Grand             const BitmapColor aColor(pRead->GetColor(i/8, i%8));
119470d3707aSArmin Le Grand 
119570d3707aSArmin Le Grand             if(aColor == aBack)
119670d3707aSArmin Le Grand             {
119770d3707aSArmin Le Grand                 *( pPixel + i ) = 0;
119870d3707aSArmin Le Grand             }
119970d3707aSArmin Le Grand             else
120070d3707aSArmin Le Grand             {
120170d3707aSArmin Le Grand                 *( pPixel + i ) = 1;
120270d3707aSArmin Le Grand             }
120370d3707aSArmin Le Grand         }
120470d3707aSArmin Le Grand 
120570d3707aSArmin Le Grand         aBitmap.ReleaseAccess(pRead);
1206cdf0e10cSrcweir     }
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir /*************************************************************************
1210a787b805SMechtilde |*  Return a selected pixel
1211cdf0e10cSrcweir \************************************************************************/
1212cdf0e10cSrcweir 
GetBitmapPixel(const sal_uInt16 nPixel)1213cdf0e10cSrcweir sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir     return( *( pPixel + nPixel ) );
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir /*************************************************************************
1219a787b805SMechtilde |*  Reset the original state of the control
1220cdf0e10cSrcweir \************************************************************************/
1221cdf0e10cSrcweir 
Reset()1222cdf0e10cSrcweir void SvxPixelCtl::Reset()
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir     // clear pixel area
1225cdf0e10cSrcweir     rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
1226cdf0e10cSrcweir     Invalidate();
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir /*************************************************************************
1230a787b805SMechtilde |*  Ctor: BitmapCtl for SvxPixelCtl
1231cdf0e10cSrcweir \************************************************************************/
1232cdf0e10cSrcweir 
SvxBitmapCtl(Window *,const Size & rSize)1233cdf0e10cSrcweir SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir     aSize = rSize;
1236cdf0e10cSrcweir     // aVD.SetOutputSizePixel( aSize );
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir /*************************************************************************
1240cdf0e10cSrcweir |*  Dtor
1241cdf0e10cSrcweir \************************************************************************/
1242cdf0e10cSrcweir 
~SvxBitmapCtl()1243cdf0e10cSrcweir SvxBitmapCtl::~SvxBitmapCtl()
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir /*************************************************************************
1248a787b805SMechtilde |*  BitmapCtl:  Return the bitmap
1249cdf0e10cSrcweir \************************************************************************/
1250cdf0e10cSrcweir 
GetBitmapEx()125170d3707aSArmin Le Grand BitmapEx SvxBitmapCtl::GetBitmapEx()
1252cdf0e10cSrcweir {
125370d3707aSArmin Le Grand     const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
1254cdf0e10cSrcweir 
125570d3707aSArmin Le Grand     return BitmapEx(aRetval);
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir /*************************************************************************
1259a787b805SMechtilde |*  Fill the list box with colors and strings
1260cdf0e10cSrcweir \************************************************************************/
1261cdf0e10cSrcweir 
Fill(const XColorListSharedPtr aColorTab)1262c7be74b1SArmin Le Grand void ColorLB::Fill( const XColorListSharedPtr aColorTab )
1263cdf0e10cSrcweir {
1264c7be74b1SArmin Le Grand     long nCount = aColorTab->Count();
1265cdf0e10cSrcweir     XColorEntry* pEntry;
1266cdf0e10cSrcweir     SetUpdateMode( sal_False );
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1269cdf0e10cSrcweir     {
1270c7be74b1SArmin Le Grand         pEntry = aColorTab->GetColor( i );
1271cdf0e10cSrcweir         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1272cdf0e10cSrcweir     }
1273a68b38dfSArmin Le Grand 
1274a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1275cdf0e10cSrcweir     SetUpdateMode( sal_True );
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir /************************************************************************/
1279cdf0e10cSrcweir 
Append(const XColorEntry & rEntry)12803e407bd8SArmin Le Grand void ColorLB::Append( const XColorEntry& rEntry )
1281cdf0e10cSrcweir {
12823e407bd8SArmin Le Grand     InsertEntry( rEntry.GetColor(), rEntry.GetName() );
1283a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1284cdf0e10cSrcweir }
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir /************************************************************************/
1287cdf0e10cSrcweir 
Modify(const XColorEntry & rEntry,sal_uInt16 nPos)12883e407bd8SArmin Le Grand void ColorLB::Modify( const XColorEntry& rEntry, sal_uInt16 nPos )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir     RemoveEntry( nPos );
12913e407bd8SArmin Le Grand     InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos );
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir /*************************************************************************
1295a787b805SMechtilde |*  Fill the list box with colors and strings
1296cdf0e10cSrcweir \************************************************************************/
1297cdf0e10cSrcweir 
Fill(const XColorListSharedPtr aColorTab)1298c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XColorListSharedPtr aColorTab )
1299cdf0e10cSrcweir {
1300c7be74b1SArmin Le Grand     long nCount = aColorTab->Count();
1301cdf0e10cSrcweir     XColorEntry* pEntry;
1302cdf0e10cSrcweir     SetUpdateMode( sal_False );
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1305cdf0e10cSrcweir     {
1306c7be74b1SArmin Le Grand         pEntry = aColorTab->GetColor( i );
1307cdf0e10cSrcweir         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1308cdf0e10cSrcweir     }
1309a68b38dfSArmin Le Grand 
1310a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1311cdf0e10cSrcweir     SetUpdateMode( sal_True );
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir /*************************************************************************
1315a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1316cdf0e10cSrcweir \************************************************************************/
1317cdf0e10cSrcweir 
HatchingLB(Window * pParent,ResId Id)1318a68b38dfSArmin Le Grand HatchingLB::HatchingLB( Window* pParent, ResId Id)
1319c7be74b1SArmin Le Grand : ListBox( pParent, Id )
1320cdf0e10cSrcweir {
1321a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir 
HatchingLB(Window * pParent,WinBits aWB)1324a68b38dfSArmin Le Grand HatchingLB::HatchingLB( Window* pParent, WinBits aWB)
1325c7be74b1SArmin Le Grand : ListBox( pParent, aWB )
1326cdf0e10cSrcweir {
1327a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir 
Fill(const XHatchListSharedPtr aList)1330c7be74b1SArmin Le Grand void HatchingLB::Fill( const XHatchListSharedPtr aList )
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir     XHatchEntry* pEntry;
1333c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir     SetUpdateMode( sal_False );
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1338cdf0e10cSrcweir     {
1339c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1340c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
134197e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
134297e8a929SArmin Le Grand             InsertEntry( pEntry->GetName(), aBitmap );
1343cdf0e10cSrcweir         else
1344cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1345cdf0e10cSrcweir     }
1346cdf0e10cSrcweir 
1347a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1348cdf0e10cSrcweir     SetUpdateMode( sal_True );
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir /************************************************************************/
1352cdf0e10cSrcweir 
Append(const XHatchEntry & rEntry,const Bitmap & rBitmap)13533e407bd8SArmin Le Grand void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap )
1354cdf0e10cSrcweir {
13553e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
13563e407bd8SArmin Le Grand     {
13573e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
13583e407bd8SArmin Le Grand     }
1359cdf0e10cSrcweir     else
13603e407bd8SArmin Le Grand     {
13613e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
13623e407bd8SArmin Le Grand     }
13633e407bd8SArmin Le Grand 
1364a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir /************************************************************************/
1368cdf0e10cSrcweir 
Modify(const XHatchEntry & rEntry,sal_uInt16 nPos,const Bitmap & rBitmap)13693e407bd8SArmin Le Grand void HatchingLB::Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir     RemoveEntry( nPos );
1372cdf0e10cSrcweir 
13733e407bd8SArmin Le Grand     if( !rBitmap.IsEmpty() )
13743e407bd8SArmin Le Grand     {
13753e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
13763e407bd8SArmin Le Grand     }
1377cdf0e10cSrcweir     else
13783e407bd8SArmin Le Grand     {
13793e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
13803e407bd8SArmin Le Grand     }
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir /************************************************************************/
1384cdf0e10cSrcweir 
SelectEntryByList(const XHatchListSharedPtr aList,const String & rStr,const XHatch & rHatch,sal_uInt16 nDist)1385c7be74b1SArmin Le Grand void HatchingLB::SelectEntryByList( const XHatchListSharedPtr aList, const String& rStr, const XHatch& rHatch, sal_uInt16 nDist )
1386cdf0e10cSrcweir {
1387c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1388cdf0e10cSrcweir     XHatchEntry* pEntry;
1389cdf0e10cSrcweir     sal_Bool bFound = sal_False;
1390cdf0e10cSrcweir     String aStr;
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir     long i;
1393cdf0e10cSrcweir     for( i = 0; i < nCount && !bFound; i++ )
1394cdf0e10cSrcweir     {
1395c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir         aStr = pEntry->GetName();
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir         if( rStr == aStr && rHatch == pEntry->GetHatch() )
1400cdf0e10cSrcweir             bFound = sal_True;
1401cdf0e10cSrcweir     }
1402cdf0e10cSrcweir     if( bFound )
1403cdf0e10cSrcweir         SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir /*************************************************************************
1407a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1408cdf0e10cSrcweir \************************************************************************/
1409cdf0e10cSrcweir 
Fill(const XHatchListSharedPtr aList)1410c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XHatchListSharedPtr aList )
1411cdf0e10cSrcweir {
1412c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1413cdf0e10cSrcweir     XHatchEntry* pEntry;
1414cdf0e10cSrcweir     ListBox::SetUpdateMode( sal_False );
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1417cdf0e10cSrcweir     {
1418c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1419c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
142097e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
142197e8a929SArmin Le Grand             ListBox::InsertEntry( pEntry->GetName(), aBitmap );
1422cdf0e10cSrcweir         else
1423cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1424cdf0e10cSrcweir     }
1425a68b38dfSArmin Le Grand 
1426a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1427cdf0e10cSrcweir     ListBox::SetUpdateMode( sal_True );
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir /*************************************************************************
1431a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1432cdf0e10cSrcweir \************************************************************************/
1433cdf0e10cSrcweir 
GradientLB(Window * pParent,ResId Id)1434a68b38dfSArmin Le Grand GradientLB::GradientLB( Window* pParent, ResId Id)
1435c7be74b1SArmin Le Grand : ListBox( pParent, Id )
1436cdf0e10cSrcweir {
1437a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir 
GradientLB(Window * pParent,WinBits aWB)1440a68b38dfSArmin Le Grand GradientLB::GradientLB( Window* pParent, WinBits aWB)
1441c7be74b1SArmin Le Grand : ListBox( pParent, aWB )
1442cdf0e10cSrcweir {
1443a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir 
Fill(const XGradientListSharedPtr aList)1446c7be74b1SArmin Le Grand void GradientLB::Fill( const XGradientListSharedPtr aList )
1447cdf0e10cSrcweir {
1448cdf0e10cSrcweir     XGradientEntry* pEntry;
1449c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir     SetUpdateMode( sal_False );
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1454cdf0e10cSrcweir     {
1455c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1456c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
145797e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
145897e8a929SArmin Le Grand             InsertEntry( pEntry->GetName(), aBitmap );
1459cdf0e10cSrcweir         else
1460cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1461cdf0e10cSrcweir     }
1462cdf0e10cSrcweir 
1463a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1464cdf0e10cSrcweir     SetUpdateMode( sal_True );
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir /************************************************************************/
1468cdf0e10cSrcweir 
Append(const XGradientEntry & rEntry,const Bitmap & rBitmap)14693e407bd8SArmin Le Grand void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap )
1470cdf0e10cSrcweir {
14713e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
14723e407bd8SArmin Le Grand     {
14733e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
14743e407bd8SArmin Le Grand     }
1475cdf0e10cSrcweir     else
14763e407bd8SArmin Le Grand     {
14773e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
14783e407bd8SArmin Le Grand     }
14793e407bd8SArmin Le Grand 
1480a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir /************************************************************************/
1484cdf0e10cSrcweir 
Modify(const XGradientEntry & rEntry,sal_uInt16 nPos,const Bitmap & rBitmap)14853e407bd8SArmin Le Grand void GradientLB::Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir     RemoveEntry( nPos );
1488cdf0e10cSrcweir 
14893e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
14903e407bd8SArmin Le Grand     {
14913e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
14923e407bd8SArmin Le Grand     }
1493cdf0e10cSrcweir     else
14943e407bd8SArmin Le Grand     {
14953e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
14963e407bd8SArmin Le Grand     }
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir /************************************************************************/
1500cdf0e10cSrcweir 
SelectEntryByList(const XGradientListSharedPtr aList,const String & rStr,const XGradient & rGradient,sal_uInt16 nDist)1501c7be74b1SArmin Le Grand void GradientLB::SelectEntryByList( const XGradientListSharedPtr aList, const String& rStr, const XGradient& rGradient, sal_uInt16 nDist )
1502cdf0e10cSrcweir {
1503c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1504cdf0e10cSrcweir     XGradientEntry* pEntry;
1505cdf0e10cSrcweir     sal_Bool bFound = sal_False;
1506cdf0e10cSrcweir     String aStr;
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir     long i;
1509cdf0e10cSrcweir     for( i = 0; i < nCount && !bFound; i++ )
1510cdf0e10cSrcweir     {
1511c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir         aStr = pEntry->GetName();
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir         if( rStr == aStr && rGradient == pEntry->GetGradient() )
1516cdf0e10cSrcweir             bFound = sal_True;
1517cdf0e10cSrcweir     }
1518cdf0e10cSrcweir     if( bFound )
1519cdf0e10cSrcweir         SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir /*************************************************************************
1523a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1524cdf0e10cSrcweir \************************************************************************/
1525cdf0e10cSrcweir 
Fill(const XGradientListSharedPtr aList)1526c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XGradientListSharedPtr aList )
1527cdf0e10cSrcweir {
1528c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1529cdf0e10cSrcweir     XGradientEntry* pEntry;
1530cdf0e10cSrcweir     ListBox::SetUpdateMode( sal_False );
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1533cdf0e10cSrcweir     {
1534c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1535c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
153697e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
153797e8a929SArmin Le Grand             ListBox::InsertEntry( pEntry->GetName(), aBitmap );
1538cdf0e10cSrcweir         else
1539cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1540cdf0e10cSrcweir     }
1541a68b38dfSArmin Le Grand 
1542a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1543cdf0e10cSrcweir     ListBox::SetUpdateMode( sal_True );
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir /*************************************************************************
1547a787b805SMechtilde |*  Constructor of BitmapLB
1548cdf0e10cSrcweir \************************************************************************/
1549cdf0e10cSrcweir 
BitmapLB(Window * pParent,ResId Id)1550a68b38dfSArmin Le Grand BitmapLB::BitmapLB(Window* pParent, ResId Id)
1551cdf0e10cSrcweir :   ListBox(pParent, Id),
1552c7be74b1SArmin Le Grand     maBitmapEx()
1553cdf0e10cSrcweir {
1554a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1555cdf0e10cSrcweir }
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir /************************************************************************/
1558cdf0e10cSrcweir 
1559a68b38dfSArmin Le Grand namespace
1560cdf0e10cSrcweir {
formatBitmapExToSize(BitmapEx & rBitmapEx,const Size & rSize)1561a68b38dfSArmin Le Grand     void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
1562a68b38dfSArmin Le Grand     {
1563a68b38dfSArmin Le Grand         if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
1564a68b38dfSArmin Le Grand         {
1565a68b38dfSArmin Le Grand             VirtualDevice aVirtualDevice;
1566a68b38dfSArmin Le Grand             aVirtualDevice.SetOutputSizePixel(rSize);
156797e8a929SArmin Le Grand 
1568a68b38dfSArmin Le Grand             if(rBitmapEx.IsTransparent())
1569cdf0e10cSrcweir             {
157035726d9dSArmin Le Grand                 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
157135726d9dSArmin Le Grand 
157233b19716SArmin Le Grand                 if(rStyleSettings.GetPreviewUsesCheckeredBackground())
157335726d9dSArmin Le Grand                 {
1574a68b38dfSArmin Le Grand                     const Point aNull(0, 0);
1575a68b38dfSArmin Le Grand                     static const sal_uInt32 nLen(8);
1576a68b38dfSArmin Le Grand                     static const Color aW(COL_WHITE);
1577a68b38dfSArmin Le Grand                     static const Color aG(0xef, 0xef, 0xef);
1578a68b38dfSArmin Le Grand 
1579a68b38dfSArmin Le Grand                     aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
1580a68b38dfSArmin Le Grand                 }
158135726d9dSArmin Le Grand                 else
158235726d9dSArmin Le Grand                 {
158335726d9dSArmin Le Grand                     aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
158435726d9dSArmin Le Grand                     aVirtualDevice.Erase();
158535726d9dSArmin Le Grand                 }
158635726d9dSArmin Le Grand             }
1587a68b38dfSArmin Le Grand 
1588a68b38dfSArmin Le Grand             if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
1589a68b38dfSArmin Le Grand             {
1590a68b38dfSArmin Le Grand                 static sal_uInt32 nScaleFlag(BMP_SCALE_FASTESTINTERPOLATE);
1591a68b38dfSArmin Le Grand 
1592a68b38dfSArmin Le Grand                 rBitmapEx.Scale(rSize, nScaleFlag);
1593a68b38dfSArmin Le Grand                 aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
1594cdf0e10cSrcweir             }
1595cdf0e10cSrcweir             else
1596cdf0e10cSrcweir             {
1597a68b38dfSArmin Le Grand                 const Size aBitmapSize(rBitmapEx.GetSizePixel());
159897e8a929SArmin Le Grand 
15992a96d551SPavel Janík                 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height())
160097e8a929SArmin Le Grand                 {
16012a96d551SPavel Janík                     for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
160297e8a929SArmin Le Grand                     {
1603a68b38dfSArmin Le Grand                         aVirtualDevice.DrawBitmapEx(
160497e8a929SArmin Le Grand                             Point(x, y),
1605a68b38dfSArmin Le Grand                             rBitmapEx);
160697e8a929SArmin Le Grand                     }
160797e8a929SArmin Le Grand                 }
1608cdf0e10cSrcweir             }
1609a68b38dfSArmin Le Grand 
1610a68b38dfSArmin Le Grand             rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
1611cdf0e10cSrcweir         }
1612a68b38dfSArmin Le Grand     }
1613a68b38dfSArmin Le Grand } // end of anonymous namespace
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir /************************************************************************/
1616cdf0e10cSrcweir 
Fill(const XBitmapListSharedPtr aList)1617c7be74b1SArmin Le Grand void BitmapLB::Fill(const XBitmapListSharedPtr aList)
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir     XBitmapEntry* pEntry;
1620c7be74b1SArmin Le Grand     const long nCount(aList.get() ? aList->Count() : 0);
1621a68b38dfSArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1622a68b38dfSArmin Le Grand     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
1623cdf0e10cSrcweir 
162470d3707aSArmin Le Grand     SetUpdateMode(false);
1625cdf0e10cSrcweir 
162670d3707aSArmin Le Grand     for(long i(0); i < nCount; i++)
1627cdf0e10cSrcweir     {
1628c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
162970d3707aSArmin Le Grand         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1630a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, aSize);
1631a68b38dfSArmin Le Grand         InsertEntry(pEntry->GetName(), maBitmapEx);
1632cdf0e10cSrcweir     }
1633cdf0e10cSrcweir 
1634a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
163570d3707aSArmin Le Grand     SetUpdateMode(true);
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir /************************************************************************/
1639cdf0e10cSrcweir 
Append(const Size & rSize,const XBitmapEntry & rEntry)16403e407bd8SArmin Le Grand void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry)
1641cdf0e10cSrcweir {
164297e8a929SArmin Le Grand     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
16433e407bd8SArmin Le Grand 
16443e407bd8SArmin Le Grand     if(!maBitmapEx.IsEmpty())
16453e407bd8SArmin Le Grand     {
1646a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, rSize);
1647a68b38dfSArmin Le Grand         InsertEntry(rEntry.GetName(), maBitmapEx);
1648cdf0e10cSrcweir     }
1649cdf0e10cSrcweir     else
165070d3707aSArmin Le Grand     {
165197e8a929SArmin Le Grand         InsertEntry(rEntry.GetName());
1652cdf0e10cSrcweir     }
1653a68b38dfSArmin Le Grand 
1654a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
165570d3707aSArmin Le Grand }
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir /************************************************************************/
1658cdf0e10cSrcweir 
Modify(const Size & rSize,const XBitmapEntry & rEntry,sal_uInt16 nPos)16593e407bd8SArmin Le Grand void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos)
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir     RemoveEntry(nPos);
166297e8a929SArmin Le Grand     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
16633e407bd8SArmin Le Grand 
16643e407bd8SArmin Le Grand     if(!maBitmapEx.IsEmpty())
16653e407bd8SArmin Le Grand     {
1666a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, rSize);
1667a68b38dfSArmin Le Grand         InsertEntry(rEntry.GetName(), maBitmapEx, nPos);
1668cdf0e10cSrcweir     }
1669cdf0e10cSrcweir     else
167070d3707aSArmin Le Grand     {
167197e8a929SArmin Le Grand         InsertEntry(rEntry.GetName());
1672cdf0e10cSrcweir     }
167370d3707aSArmin Le Grand }
1674cdf0e10cSrcweir 
1675cdf0e10cSrcweir /************************************************************************/
1676cdf0e10cSrcweir 
SelectEntryByList(const XBitmapListSharedPtr aList,const String & rStr)1677c7be74b1SArmin Le Grand void BitmapLB::SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr)
1678cdf0e10cSrcweir {
1679c7be74b1SArmin Le Grand     const long nCount(aList.get() ? aList->Count() : 0);
1680cdf0e10cSrcweir     XBitmapEntry* pEntry;
168170d3707aSArmin Le Grand     bool bFound(false);
168270d3707aSArmin Le Grand     long i(0);
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir     for(i = 0; i < nCount && !bFound; i++)
1685cdf0e10cSrcweir     {
1686c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
168770d3707aSArmin Le Grand         const String aStr(pEntry->GetName());
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir         if(rStr == aStr)
1690cdf0e10cSrcweir         {
169170d3707aSArmin Le Grand             bFound = true;
1692cdf0e10cSrcweir         }
1693cdf0e10cSrcweir     }
169470d3707aSArmin Le Grand 
1695cdf0e10cSrcweir     if(bFound)
169670d3707aSArmin Le Grand     {
1697cdf0e10cSrcweir         SelectEntryPos((sal_uInt16)(i - 1));
1698cdf0e10cSrcweir     }
169970d3707aSArmin Le Grand }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir /*************************************************************************
1702a787b805SMechtilde |*  Constructor of FillAttrLB
1703cdf0e10cSrcweir \************************************************************************/
1704cdf0e10cSrcweir 
FillAttrLB(Window * pParent,ResId Id)170570d3707aSArmin Le Grand FillAttrLB::FillAttrLB( Window* pParent, ResId Id )
170670d3707aSArmin Le Grand :   ColorListBox(pParent, Id),
170770d3707aSArmin Le Grand     maBitmapEx()
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir }
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir /************************************************************************/
1712cdf0e10cSrcweir 
FillAttrLB(Window * pParent,WinBits aWB)171370d3707aSArmin Le Grand FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
171470d3707aSArmin Le Grand :   ColorListBox(pParent, aWB)
1715cdf0e10cSrcweir {
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir /************************************************************************/
1719cdf0e10cSrcweir 
Fill(const XBitmapListSharedPtr aList)1720c7be74b1SArmin Le Grand void FillAttrLB::Fill(const XBitmapListSharedPtr aList)
1721cdf0e10cSrcweir {
1722c7be74b1SArmin Le Grand     const long nCount(aList.get() ? aList->Count() : 0);
1723cdf0e10cSrcweir     XBitmapEntry* pEntry;
1724a68b38dfSArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1725a68b38dfSArmin Le Grand     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
1726cdf0e10cSrcweir 
172770d3707aSArmin Le Grand     ListBox::SetUpdateMode(false);
172870d3707aSArmin Le Grand 
172970d3707aSArmin Le Grand     for(long i(0); i < nCount; i++)
1730cdf0e10cSrcweir     {
1731c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap( i );
173270d3707aSArmin Le Grand         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1733a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, aSize);
1734a68b38dfSArmin Le Grand         ListBox::InsertEntry(pEntry->GetName(), maBitmapEx);
1735cdf0e10cSrcweir     }
173670d3707aSArmin Le Grand 
1737a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
173870d3707aSArmin Le Grand     ListBox::SetUpdateMode(true);
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir /************************************************************************/
1742cdf0e10cSrcweir 
SelectEntryByList(const XBitmapListSharedPtr aList,const String & rStr)1743c7be74b1SArmin Le Grand void FillAttrLB::SelectEntryByList( const XBitmapListSharedPtr aList, const String& rStr)
1744cdf0e10cSrcweir {
1745c7be74b1SArmin Le Grand     const long nCount(aList.get() ? aList->Count() : 0);
1746cdf0e10cSrcweir     XBitmapEntry* pEntry;
174770d3707aSArmin Le Grand     bool bFound(false);
174870d3707aSArmin Le Grand     long i(0);
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir     for(i = 0; i < nCount && !bFound; i++)
1751cdf0e10cSrcweir     {
1752c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
175370d3707aSArmin Le Grand         const String aStr(pEntry->GetName());
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir         if(rStr == aStr)
1756cdf0e10cSrcweir         {
175770d3707aSArmin Le Grand             bFound = true;
1758cdf0e10cSrcweir         }
1759cdf0e10cSrcweir     }
176070d3707aSArmin Le Grand 
1761cdf0e10cSrcweir     if(bFound)
176270d3707aSArmin Le Grand     {
1763cdf0e10cSrcweir         SelectEntryPos((sal_uInt16)(i - 1));
1764cdf0e10cSrcweir     }
176570d3707aSArmin Le Grand }
1766cdf0e10cSrcweir 
1767cdf0e10cSrcweir /*************************************************************************
1768a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1769cdf0e10cSrcweir \************************************************************************/
1770cdf0e10cSrcweir 
Fill()1771cdf0e10cSrcweir void FillTypeLB::Fill()
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir     SetUpdateMode( sal_False );
1774a68b38dfSArmin Le Grand 
1775cdf0e10cSrcweir     InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
1776cdf0e10cSrcweir     InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
1777cdf0e10cSrcweir     InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
1778cdf0e10cSrcweir     InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
1779cdf0e10cSrcweir     InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
1780a68b38dfSArmin Le Grand 
1781a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1782cdf0e10cSrcweir     SetUpdateMode( sal_True );
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir /*************************************************************************
1786a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1787cdf0e10cSrcweir \************************************************************************/
LineLB(Window * pParent,ResId Id)1788ed6b2054SArmin Le Grand LineLB::LineLB(Window* pParent, ResId Id)
1789ed6b2054SArmin Le Grand :   ListBox(pParent, Id),
1790ed6b2054SArmin Le Grand     mbAddStandardFields(true)
1791ed6b2054SArmin Le Grand {
1792a68b38dfSArmin Le Grand     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1793ed6b2054SArmin Le Grand }
1794ed6b2054SArmin Le Grand 
LineLB(Window * pParent,WinBits aWB)1795ed6b2054SArmin Le Grand LineLB::LineLB(Window* pParent, WinBits aWB)
1796ed6b2054SArmin Le Grand :   ListBox(pParent, aWB),
1797ed6b2054SArmin Le Grand     mbAddStandardFields(true)
1798ed6b2054SArmin Le Grand {
1799a68b38dfSArmin Le Grand     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1800ed6b2054SArmin Le Grand }
1801ed6b2054SArmin Le Grand 
~LineLB()1802ed6b2054SArmin Le Grand LineLB::~LineLB()
1803ed6b2054SArmin Le Grand {
1804ed6b2054SArmin Le Grand }
1805ed6b2054SArmin Le Grand 
setAddStandardFields(bool bNew)1806ed6b2054SArmin Le Grand void LineLB::setAddStandardFields(bool bNew)
1807ed6b2054SArmin Le Grand {
1808ed6b2054SArmin Le Grand     if(getAddStandardFields() != bNew)
1809ed6b2054SArmin Le Grand     {
1810ed6b2054SArmin Le Grand         mbAddStandardFields = bNew;
1811ed6b2054SArmin Le Grand     }
1812ed6b2054SArmin Le Grand }
1813cdf0e10cSrcweir 
Fill(const XDashListSharedPtr aList)1814c7be74b1SArmin Le Grand void LineLB::Fill( const XDashListSharedPtr aList )
1815cdf0e10cSrcweir {
181697e8a929SArmin Le Grand     Clear();
181797e8a929SArmin Le Grand 
1818c7be74b1SArmin Le Grand     if(getAddStandardFields() && aList.get())
1819ed6b2054SArmin Le Grand     {
182097e8a929SArmin Le Grand         // entry for 'none'
1821c7be74b1SArmin Le Grand         InsertEntry(aList->GetStringForUiNoLine());
182297e8a929SArmin Le Grand 
182397e8a929SArmin Le Grand         // entry for solid line
1824c7be74b1SArmin Le Grand         InsertEntry(aList->GetStringForUiSolidLine(), aList->GetBitmapForUISolidLine());
1825ed6b2054SArmin Le Grand     }
182697e8a929SArmin Le Grand 
182797e8a929SArmin Le Grand     // entries for dashed lines
1828c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1829cdf0e10cSrcweir     XDashEntry* pEntry;
1830cdf0e10cSrcweir     SetUpdateMode( sal_False );
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1833cdf0e10cSrcweir     {
1834c7be74b1SArmin Le Grand         pEntry = aList->GetDash( i );
1835c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
183697e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
1837cdf0e10cSrcweir         {
183897e8a929SArmin Le Grand             InsertEntry( pEntry->GetName(), aBitmap );
183997e8a929SArmin Le Grand             //delete pBitmap;
1840cdf0e10cSrcweir         }
1841cdf0e10cSrcweir         else
1842cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1843cdf0e10cSrcweir     }
1844a68b38dfSArmin Le Grand 
1845a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1846cdf0e10cSrcweir     SetUpdateMode( sal_True );
1847cdf0e10cSrcweir }
1848cdf0e10cSrcweir 
1849cdf0e10cSrcweir /************************************************************************/
1850cdf0e10cSrcweir 
Append(const XDashEntry & rEntry,const Bitmap & rBitmap)18513e407bd8SArmin Le Grand void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap )
1852cdf0e10cSrcweir {
18533e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
18543e407bd8SArmin Le Grand     {
18553e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
18563e407bd8SArmin Le Grand     }
1857cdf0e10cSrcweir     else
18583e407bd8SArmin Le Grand     {
18593e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
18603e407bd8SArmin Le Grand     }
18613e407bd8SArmin Le Grand 
1862a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1863cdf0e10cSrcweir }
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir /************************************************************************/
1866cdf0e10cSrcweir 
Modify(const XDashEntry & rEntry,sal_uInt16 nPos,const Bitmap & rBitmap)18673e407bd8SArmin Le Grand void LineLB::Modify( const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1868cdf0e10cSrcweir {
1869cdf0e10cSrcweir     RemoveEntry( nPos );
1870cdf0e10cSrcweir 
18713e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
18723e407bd8SArmin Le Grand     {
18733e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
18743e407bd8SArmin Le Grand     }
1875cdf0e10cSrcweir     else
18763e407bd8SArmin Le Grand     {
18773e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
18783e407bd8SArmin Le Grand     }
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir /************************************************************************/
1882cdf0e10cSrcweir 
SelectEntryByList(const XDashListSharedPtr aList,const String & rStr,const XDash & rDash,sal_uInt16 nDist)1883c7be74b1SArmin Le Grand void LineLB::SelectEntryByList( const XDashListSharedPtr aList, const String& rStr, const XDash& rDash, sal_uInt16 nDist )
1884cdf0e10cSrcweir {
1885c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1886cdf0e10cSrcweir     XDashEntry* pEntry;
1887cdf0e10cSrcweir     sal_Bool bFound = sal_False;
1888cdf0e10cSrcweir     String aStr;
1889cdf0e10cSrcweir     XDash aDash;
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir     long i;
1892cdf0e10cSrcweir     for( i = 0; i < nCount && !bFound; i++ )
1893cdf0e10cSrcweir     {
1894c7be74b1SArmin Le Grand         pEntry = aList->GetDash( i );
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir         aStr = pEntry->GetName();
1897cdf0e10cSrcweir         aDash = pEntry->GetDash();
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir         if( rStr == aStr && rDash == aDash )
1900cdf0e10cSrcweir             bFound = sal_True;
1901cdf0e10cSrcweir     }
1902cdf0e10cSrcweir     if( bFound )
1903cdf0e10cSrcweir         SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1904cdf0e10cSrcweir }
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir /*************************************************************************
1907a787b805SMechtilde |*  Fill the list box (temporarily) with strings
1908cdf0e10cSrcweir \************************************************************************/
LineEndLB(Window * pParent,ResId Id)1909fb2c9d94SAndre Fischer LineEndLB::LineEndLB( Window* pParent, ResId Id )
1910fb2c9d94SAndre Fischer     : ListBox( pParent, Id )
1911fb2c9d94SAndre Fischer {
1912a68b38dfSArmin Le Grand     // No EdgeBlending for LineEnds SetEdgeBlending(true);
1913fb2c9d94SAndre Fischer }
1914fb2c9d94SAndre Fischer 
LineEndLB(Window * pParent,WinBits aWB)1915fb2c9d94SAndre Fischer LineEndLB::LineEndLB( Window* pParent, WinBits aWB )
1916fb2c9d94SAndre Fischer     : ListBox( pParent, aWB )
1917fb2c9d94SAndre Fischer {
1918a68b38dfSArmin Le Grand     // No EdgeBlending for LineEnds SetEdgeBlending(true);
1919fb2c9d94SAndre Fischer }
1920fb2c9d94SAndre Fischer 
~LineEndLB(void)1921fb2c9d94SAndre Fischer LineEndLB::~LineEndLB(void)
1922fb2c9d94SAndre Fischer {
1923fb2c9d94SAndre Fischer }
1924fb2c9d94SAndre Fischer 
1925cdf0e10cSrcweir 
Fill(const XLineEndListSharedPtr aList,bool bStart)19263e407bd8SArmin Le Grand void LineEndLB::Fill( const XLineEndListSharedPtr aList, bool bStart )
1927cdf0e10cSrcweir {
1928c7be74b1SArmin Le Grand     long nCount = aList.get() ? aList->Count() : 0;
1929cdf0e10cSrcweir     XLineEndEntry* pEntry;
1930cdf0e10cSrcweir     VirtualDevice aVD;
1931cdf0e10cSrcweir     SetUpdateMode( sal_False );
1932cdf0e10cSrcweir 
1933cdf0e10cSrcweir     for( long i = 0; i < nCount; i++ )
1934cdf0e10cSrcweir     {
1935c7be74b1SArmin Le Grand         pEntry = aList->GetLineEnd( i );
1936c7be74b1SArmin Le Grand         const Bitmap aBitmap = aList->GetUiBitmap( i );
193797e8a929SArmin Le Grand         if( !aBitmap.IsEmpty() )
1938cdf0e10cSrcweir         {
193997e8a929SArmin Le Grand             Size aBmpSize( aBitmap.GetSizePixel() );
1940cdf0e10cSrcweir             aVD.SetOutputSizePixel( aBmpSize, sal_False );
194197e8a929SArmin Le Grand             aVD.DrawBitmap( Point(), aBitmap );
1942cdf0e10cSrcweir             InsertEntry( pEntry->GetName(),
1943cdf0e10cSrcweir                 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1944cdf0e10cSrcweir                     Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
194597e8a929SArmin Le Grand             //delete pBitmap;
1946cdf0e10cSrcweir         }
1947cdf0e10cSrcweir         else
1948cdf0e10cSrcweir             InsertEntry( pEntry->GetName() );
1949cdf0e10cSrcweir     }
1950a68b38dfSArmin Le Grand 
1951a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1952cdf0e10cSrcweir     SetUpdateMode( sal_True );
1953cdf0e10cSrcweir }
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir /************************************************************************/
1956cdf0e10cSrcweir 
Append(const XLineEndEntry & rEntry,const Bitmap & rBitmap,bool bStart)19573e407bd8SArmin Le Grand void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart )
1958cdf0e10cSrcweir {
19593e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
1960cdf0e10cSrcweir     {
1961cdf0e10cSrcweir         VirtualDevice aVD;
19623e407bd8SArmin Le Grand         const Size aBmpSize(rBitmap.GetSizePixel());
1963cdf0e10cSrcweir 
19643e407bd8SArmin Le Grand         aVD.SetOutputSizePixel(aBmpSize, false);
19653e407bd8SArmin Le Grand         aVD.DrawBitmap(Point(), rBitmap);
19663e407bd8SArmin Le Grand         InsertEntry(
19673e407bd8SArmin Le Grand             rEntry.GetName(),
19683e407bd8SArmin Le Grand             aVD.GetBitmap(bStart ? Point() : Point(aBmpSize.Width() / 2, 0 ), Size(aBmpSize.Width() / 2, aBmpSize.Height())));
1969cdf0e10cSrcweir     }
1970cdf0e10cSrcweir     else
19713e407bd8SArmin Le Grand     {
19723e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName());
19733e407bd8SArmin Le Grand     }
19743e407bd8SArmin Le Grand 
1975a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir /************************************************************************/
1979cdf0e10cSrcweir 
Modify(const XLineEndEntry & rEntry,sal_uInt16 nPos,const Bitmap & rBitmap,bool bStart)19803e407bd8SArmin Le Grand void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart )
1981cdf0e10cSrcweir {
1982cdf0e10cSrcweir     RemoveEntry( nPos );
1983cdf0e10cSrcweir 
19843e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
1985cdf0e10cSrcweir     {
1986cdf0e10cSrcweir         VirtualDevice aVD;
19873e407bd8SArmin Le Grand         const Size aBmpSize(rBitmap.GetSizePixel());
1988cdf0e10cSrcweir 
19893e407bd8SArmin Le Grand         aVD.SetOutputSizePixel(aBmpSize, false);
19903e407bd8SArmin Le Grand         aVD.DrawBitmap(Point(), rBitmap);
19913e407bd8SArmin Le Grand         InsertEntry(
19923e407bd8SArmin Le Grand             rEntry.GetName(),
19933e407bd8SArmin Le Grand             aVD.GetBitmap(bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), Size( aBmpSize.Width() / 2, aBmpSize.Height())),
19943e407bd8SArmin Le Grand             nPos);
1995cdf0e10cSrcweir     }
1996cdf0e10cSrcweir     else
19973e407bd8SArmin Le Grand     {
19983e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName(), nPos);
19993e407bd8SArmin Le Grand     }
2000cdf0e10cSrcweir }
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2003cdf0e10cSrcweir 
InitSettings(bool bForeground,bool bBackground)2004cdf0e10cSrcweir void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
2005cdf0e10cSrcweir {
2006cdf0e10cSrcweir     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2007cdf0e10cSrcweir 
2008cdf0e10cSrcweir     if(bForeground)
2009cdf0e10cSrcweir     {
2010cdf0e10cSrcweir         svtools::ColorConfig aColorConfig;
2011cdf0e10cSrcweir         Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir         if(IsControlForeground())
2014cdf0e10cSrcweir         {
2015cdf0e10cSrcweir             aTextColor = GetControlForeground();
2016cdf0e10cSrcweir         }
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir         getBufferDevice().SetTextColor(aTextColor);
2019cdf0e10cSrcweir     }
2020cdf0e10cSrcweir 
2021cdf0e10cSrcweir     if(bBackground)
2022cdf0e10cSrcweir     {
2023cdf0e10cSrcweir         if(IsControlBackground())
2024cdf0e10cSrcweir         {
2025cdf0e10cSrcweir             getBufferDevice().SetBackground(GetControlBackground());
2026cdf0e10cSrcweir         }
2027cdf0e10cSrcweir         else
2028cdf0e10cSrcweir         {
2029cdf0e10cSrcweir             getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
2030cdf0e10cSrcweir         }
2031cdf0e10cSrcweir     }
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir     // do not paint background self, it gets painted buffered
2034cdf0e10cSrcweir     SetControlBackground();
2035cdf0e10cSrcweir     SetBackground();
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir     Invalidate();
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir 
SvxPreviewBase(Window * pParent,const ResId & rResId)2040cdf0e10cSrcweir SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
2041cdf0e10cSrcweir :   Control( pParent, rResId ),
2042cdf0e10cSrcweir     mpModel( new SdrModel() ),
2043cdf0e10cSrcweir     mpBufferDevice( new VirtualDevice(*this) )
2044cdf0e10cSrcweir {
2045cdf0e10cSrcweir     // Draw the control's border as a flat thin black line.
2046cdf0e10cSrcweir     SetBorderStyle(WINDOW_BORDER_MONO);
2047cdf0e10cSrcweir     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
2048cdf0e10cSrcweir     SetMapMode(MAP_100TH_MM);
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir     // init model
2051cdf0e10cSrcweir     mpModel->GetItemPool().FreezeIdRanges();
2052cdf0e10cSrcweir }
2053cdf0e10cSrcweir 
~SvxPreviewBase()2054cdf0e10cSrcweir SvxPreviewBase::~SvxPreviewBase()
2055cdf0e10cSrcweir {
2056cdf0e10cSrcweir     delete mpModel;
2057cdf0e10cSrcweir     delete mpBufferDevice;
2058cdf0e10cSrcweir }
2059cdf0e10cSrcweir 
LocalPrePaint()2060cdf0e10cSrcweir void SvxPreviewBase::LocalPrePaint()
2061cdf0e10cSrcweir {
2062cdf0e10cSrcweir     // init BufferDevice
2063cdf0e10cSrcweir     if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
2064cdf0e10cSrcweir     {
2065cdf0e10cSrcweir         mpBufferDevice->SetDrawMode(GetDrawMode());
2066cdf0e10cSrcweir         mpBufferDevice->SetSettings(GetSettings());
2067cdf0e10cSrcweir         mpBufferDevice->SetAntialiasing(GetAntialiasing());
2068cdf0e10cSrcweir         mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
2069cdf0e10cSrcweir         mpBufferDevice->SetMapMode(GetMapMode());
2070cdf0e10cSrcweir     }
2071cdf0e10cSrcweir 
207233b19716SArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
207333b19716SArmin Le Grand 
207433b19716SArmin Le Grand     if(rStyleSettings.GetPreviewUsesCheckeredBackground())
207533b19716SArmin Le Grand     {
207633b19716SArmin Le Grand         const Point aNull(0, 0);
207733b19716SArmin Le Grand         static const sal_uInt32 nLen(8);
207833b19716SArmin Le Grand         static const Color aW(COL_WHITE);
207933b19716SArmin Le Grand         static const Color aG(0xef, 0xef, 0xef);
208033b19716SArmin Le Grand         const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
208133b19716SArmin Le Grand 
208233b19716SArmin Le Grand         mpBufferDevice->EnableMapMode(false);
208333b19716SArmin Le Grand         mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG);
208433b19716SArmin Le Grand         mpBufferDevice->EnableMapMode(bWasEnabled);
208533b19716SArmin Le Grand     }
208633b19716SArmin Le Grand     else
208733b19716SArmin Le Grand     {
2088cdf0e10cSrcweir         mpBufferDevice->Erase();
2089cdf0e10cSrcweir     }
209033b19716SArmin Le Grand }
2091cdf0e10cSrcweir 
LocalPostPaint()2092cdf0e10cSrcweir void SvxPreviewBase::LocalPostPaint()
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir     // copy to front (in pixel mode)
2095cdf0e10cSrcweir     const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
2096cdf0e10cSrcweir     const bool bWasEnabledDst(IsMapModeEnabled());
2097cdf0e10cSrcweir     const Point aEmptyPoint;
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir     mpBufferDevice->EnableMapMode(false);
2100cdf0e10cSrcweir     EnableMapMode(false);
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir     DrawOutDev(
2103cdf0e10cSrcweir         aEmptyPoint, GetOutputSizePixel(),
2104cdf0e10cSrcweir         aEmptyPoint, GetOutputSizePixel(),
2105cdf0e10cSrcweir         *mpBufferDevice);
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir     mpBufferDevice->EnableMapMode(bWasEnabledSrc);
2108cdf0e10cSrcweir     EnableMapMode(bWasEnabledDst);
2109cdf0e10cSrcweir }
2110cdf0e10cSrcweir 
StateChanged(StateChangedType nType)2111cdf0e10cSrcweir void SvxPreviewBase::StateChanged(StateChangedType nType)
2112cdf0e10cSrcweir {
2113cdf0e10cSrcweir     Control::StateChanged(nType);
2114cdf0e10cSrcweir 
2115cdf0e10cSrcweir     if(STATE_CHANGE_CONTROLFOREGROUND == nType)
2116cdf0e10cSrcweir     {
2117cdf0e10cSrcweir         InitSettings(true, false);
2118cdf0e10cSrcweir     }
2119cdf0e10cSrcweir     else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
2120cdf0e10cSrcweir     {
2121cdf0e10cSrcweir         InitSettings(false, true);
2122cdf0e10cSrcweir     }
2123cdf0e10cSrcweir }
2124cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)2125cdf0e10cSrcweir void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir     SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir     if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
2130cdf0e10cSrcweir     {
2131cdf0e10cSrcweir         InitSettings(true, true);
2132cdf0e10cSrcweir     }
2133cdf0e10cSrcweir     else
2134cdf0e10cSrcweir     {
2135cdf0e10cSrcweir         Control::DataChanged(rDCEvt);
2136cdf0e10cSrcweir     }
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir /*************************************************************************
2140cdf0e10cSrcweir |* SvxXLinePreview::SvxXLinePreview()
2141cdf0e10cSrcweir *************************************************************************/
2142cdf0e10cSrcweir 
SvxXLinePreview(Window * pParent,const ResId & rResId)2143cdf0e10cSrcweir SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
2144cdf0e10cSrcweir :   SvxPreviewBase( pParent, rResId ),
2145cdf0e10cSrcweir     mpLineObjA( 0L ),
2146cdf0e10cSrcweir     mpLineObjB( 0L ),
2147cdf0e10cSrcweir     mpLineObjC( 0L ),
2148cdf0e10cSrcweir     mpGraphic( 0L ),
2149cdf0e10cSrcweir     mbWithSymbol( sal_False )
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir     const Size aOutputSize(GetOutputSize());
2152cdf0e10cSrcweir     InitSettings( sal_True, sal_True );
2153cdf0e10cSrcweir 
2154cdf0e10cSrcweir     const sal_Int32 nDistance(500L);
2155cdf0e10cSrcweir     const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir     // create DrawObectA
2158cdf0e10cSrcweir     const sal_Int32 aYPosA(aOutputSize.Height() / 2);
2159cdf0e10cSrcweir     const basegfx::B2DPoint aPointA1( nDistance,  aYPosA);
2160cdf0e10cSrcweir     const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
2161cdf0e10cSrcweir     basegfx::B2DPolygon aPolygonA;
2162cdf0e10cSrcweir     aPolygonA.append(aPointA1);
2163cdf0e10cSrcweir     aPolygonA.append(aPointA2);
2164cdf0e10cSrcweir     mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
2165cdf0e10cSrcweir     mpLineObjA->SetModel(&getModel());
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir     // create DrawObectB
2168cdf0e10cSrcweir     const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
2169cdf0e10cSrcweir     const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
2170cdf0e10cSrcweir     const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance,  aYPosB1);
2171cdf0e10cSrcweir     const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
2172cdf0e10cSrcweir     const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
2173cdf0e10cSrcweir     basegfx::B2DPolygon aPolygonB;
2174cdf0e10cSrcweir     aPolygonB.append(aPointB1);
2175cdf0e10cSrcweir     aPolygonB.append(aPointB2);
2176cdf0e10cSrcweir     aPolygonB.append(aPointB3);
2177cdf0e10cSrcweir     mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
2178cdf0e10cSrcweir     mpLineObjB->SetModel(&getModel());
2179cdf0e10cSrcweir 
2180cdf0e10cSrcweir     // create DrawObectC
2181cdf0e10cSrcweir     const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance,  aYPosB1);
2182cdf0e10cSrcweir     const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
2183cdf0e10cSrcweir     const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
2184cdf0e10cSrcweir     basegfx::B2DPolygon aPolygonC;
2185cdf0e10cSrcweir     aPolygonC.append(aPointC1);
2186cdf0e10cSrcweir     aPolygonC.append(aPointC2);
2187cdf0e10cSrcweir     aPolygonC.append(aPointC3);
2188cdf0e10cSrcweir     mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
2189cdf0e10cSrcweir     mpLineObjC->SetModel(&getModel());
2190cdf0e10cSrcweir }
2191cdf0e10cSrcweir 
~SvxXLinePreview()2192cdf0e10cSrcweir SvxXLinePreview::~SvxXLinePreview()
2193cdf0e10cSrcweir {
2194cdf0e10cSrcweir     SdrObject::Free( mpLineObjA );
2195cdf0e10cSrcweir     SdrObject::Free( mpLineObjB );
2196cdf0e10cSrcweir     SdrObject::Free( mpLineObjC );
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir // -----------------------------------------------------------------------
2200cdf0e10cSrcweir 
SetSymbol(Graphic * p,const Size & s)2201cdf0e10cSrcweir void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
2202cdf0e10cSrcweir {
2203cdf0e10cSrcweir     mpGraphic = p;
2204cdf0e10cSrcweir     maSymbolSize = s;
2205cdf0e10cSrcweir }
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir // -----------------------------------------------------------------------
2208cdf0e10cSrcweir 
ResizeSymbol(const Size & s)2209cdf0e10cSrcweir void SvxXLinePreview::ResizeSymbol(const Size& s)
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir     if ( s != maSymbolSize )
2212cdf0e10cSrcweir     {
2213cdf0e10cSrcweir         maSymbolSize = s;
2214cdf0e10cSrcweir         Invalidate();
2215cdf0e10cSrcweir     }
2216cdf0e10cSrcweir }
2217cdf0e10cSrcweir 
2218cdf0e10cSrcweir // -----------------------------------------------------------------------
2219cdf0e10cSrcweir 
SetLineAttributes(const SfxItemSet & rItemSet)2220cdf0e10cSrcweir void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
2221cdf0e10cSrcweir {
2222cdf0e10cSrcweir     // Set ItemSet at objects
2223cdf0e10cSrcweir     mpLineObjA->SetMergedItemSet(rItemSet);
2224cdf0e10cSrcweir 
2225cdf0e10cSrcweir     // At line joints, do not use arrows
2226cdf0e10cSrcweir     SfxItemSet aTempSet(rItemSet);
2227cdf0e10cSrcweir     aTempSet.ClearItem(XATTR_LINESTART);
2228cdf0e10cSrcweir     aTempSet.ClearItem(XATTR_LINEEND);
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir     mpLineObjB->SetMergedItemSet(aTempSet);
2231cdf0e10cSrcweir     mpLineObjC->SetMergedItemSet(aTempSet);
2232cdf0e10cSrcweir }
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir // -----------------------------------------------------------------------
2235cdf0e10cSrcweir 
Paint(const Rectangle &)2236cdf0e10cSrcweir void SvxXLinePreview::Paint( const Rectangle& )
2237cdf0e10cSrcweir {
2238cdf0e10cSrcweir     LocalPrePaint();
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir     // paint objects to buffer device
2241cdf0e10cSrcweir     sdr::contact::SdrObjectVector aObjectVector;
2242cdf0e10cSrcweir     aObjectVector.push_back(mpLineObjA);
2243cdf0e10cSrcweir     aObjectVector.push_back(mpLineObjB);
2244cdf0e10cSrcweir     aObjectVector.push_back(mpLineObjC);
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2247cdf0e10cSrcweir     sdr::contact::DisplayInfo aDisplayInfo;
2248cdf0e10cSrcweir 
2249cdf0e10cSrcweir     // do processing
2250cdf0e10cSrcweir     aPainter.ProcessDisplay(aDisplayInfo);
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir     if ( mbWithSymbol && mpGraphic )
2253cdf0e10cSrcweir     {
2254cdf0e10cSrcweir         const Size aOutputSize(GetOutputSize());
2255cdf0e10cSrcweir         Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
2256cdf0e10cSrcweir         aPos.X() -= maSymbolSize.Width() / 2;
2257cdf0e10cSrcweir         aPos.Y() -= maSymbolSize.Height() / 2;
2258cdf0e10cSrcweir         mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
2259cdf0e10cSrcweir     }
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir     LocalPostPaint();
2262cdf0e10cSrcweir }
2263cdf0e10cSrcweir 
2264cdf0e10cSrcweir /*************************************************************************
2265cdf0e10cSrcweir |* SvxXRectPreview::SvxXRectPreview()
2266cdf0e10cSrcweir *************************************************************************/
2267cdf0e10cSrcweir 
SvxXRectPreview(Window * pParent,const ResId & rResId)2268cdf0e10cSrcweir SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
2269cdf0e10cSrcweir :   SvxPreviewBase( pParent, rResId ),
2270cdf0e10cSrcweir     mpRectangleObject(0)
2271cdf0e10cSrcweir {
2272cdf0e10cSrcweir     InitSettings(true, true);
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir     // create RectangleObject
2275cdf0e10cSrcweir     const Rectangle aObjectSize(Point(), GetOutputSize());
2276cdf0e10cSrcweir     mpRectangleObject = new SdrRectObj(aObjectSize);
2277cdf0e10cSrcweir     mpRectangleObject->SetModel(&getModel());
2278cdf0e10cSrcweir }
2279cdf0e10cSrcweir 
~SvxXRectPreview()2280cdf0e10cSrcweir SvxXRectPreview::~SvxXRectPreview()
2281cdf0e10cSrcweir {
2282cdf0e10cSrcweir     SdrObject::Free(mpRectangleObject);
2283cdf0e10cSrcweir }
2284cdf0e10cSrcweir 
SetAttributes(const SfxItemSet & rItemSet)2285cdf0e10cSrcweir void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
2286cdf0e10cSrcweir {
2287cdf0e10cSrcweir     mpRectangleObject->SetMergedItemSet(rItemSet, true);
2288cdf0e10cSrcweir     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2289cdf0e10cSrcweir }
2290cdf0e10cSrcweir 
Paint(const Rectangle &)2291cdf0e10cSrcweir void SvxXRectPreview::Paint( const Rectangle& )
2292cdf0e10cSrcweir {
2293cdf0e10cSrcweir     LocalPrePaint();
2294cdf0e10cSrcweir 
2295cdf0e10cSrcweir     sdr::contact::SdrObjectVector aObjectVector;
2296cdf0e10cSrcweir 
2297cdf0e10cSrcweir     aObjectVector.push_back(mpRectangleObject);
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2300cdf0e10cSrcweir     sdr::contact::DisplayInfo aDisplayInfo;
2301cdf0e10cSrcweir 
2302cdf0e10cSrcweir     aPainter.ProcessDisplay(aDisplayInfo);
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir     LocalPostPaint();
2305cdf0e10cSrcweir }
2306cdf0e10cSrcweir 
2307cdf0e10cSrcweir /*************************************************************************
2308cdf0e10cSrcweir |* SvxXShadowPreview::SvxXShadowPreview()
2309cdf0e10cSrcweir *************************************************************************/
2310cdf0e10cSrcweir 
SvxXShadowPreview(Window * pParent,const ResId & rResId)2311cdf0e10cSrcweir SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
2312cdf0e10cSrcweir :   SvxPreviewBase( pParent, rResId ),
2313cdf0e10cSrcweir     mpRectangleObject(0),
2314cdf0e10cSrcweir     mpRectangleShadow(0)
2315cdf0e10cSrcweir {
2316cdf0e10cSrcweir     InitSettings(true, true);
2317cdf0e10cSrcweir 
2318cdf0e10cSrcweir     // prepare size
2319cdf0e10cSrcweir     Size aSize = GetOutputSize();
2320cdf0e10cSrcweir     aSize.Width() = aSize.Width() / 3;
2321cdf0e10cSrcweir     aSize.Height() = aSize.Height() / 3;
2322cdf0e10cSrcweir 
2323cdf0e10cSrcweir     // create RectangleObject
2324cdf0e10cSrcweir     const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
2325cdf0e10cSrcweir     mpRectangleObject = new SdrRectObj(aObjectSize);
2326cdf0e10cSrcweir     mpRectangleObject->SetModel(&getModel());
2327cdf0e10cSrcweir 
2328cdf0e10cSrcweir     // create ShadowObject
2329cdf0e10cSrcweir     const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
2330cdf0e10cSrcweir     mpRectangleShadow = new SdrRectObj(aShadowSize);
2331cdf0e10cSrcweir     mpRectangleShadow->SetModel(&getModel());
2332cdf0e10cSrcweir }
2333cdf0e10cSrcweir 
~SvxXShadowPreview()2334cdf0e10cSrcweir SvxXShadowPreview::~SvxXShadowPreview()
2335cdf0e10cSrcweir {
2336cdf0e10cSrcweir     SdrObject::Free(mpRectangleObject);
2337cdf0e10cSrcweir     SdrObject::Free(mpRectangleShadow);
2338cdf0e10cSrcweir }
2339cdf0e10cSrcweir 
SetRectangleAttributes(const SfxItemSet & rItemSet)2340cdf0e10cSrcweir void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
2341cdf0e10cSrcweir {
2342cdf0e10cSrcweir     mpRectangleObject->SetMergedItemSet(rItemSet, true);
2343cdf0e10cSrcweir     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2344cdf0e10cSrcweir }
2345cdf0e10cSrcweir 
SetShadowAttributes(const SfxItemSet & rItemSet)2346cdf0e10cSrcweir void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
2347cdf0e10cSrcweir {
2348cdf0e10cSrcweir     mpRectangleShadow->SetMergedItemSet(rItemSet, true);
2349cdf0e10cSrcweir     mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
2350cdf0e10cSrcweir }
2351cdf0e10cSrcweir 
SetShadowPosition(const Point & rPos)2352cdf0e10cSrcweir void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
2353cdf0e10cSrcweir {
2354cdf0e10cSrcweir     Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
2355cdf0e10cSrcweir     aObjectPosition.Move(rPos.X(), rPos.Y());
2356cdf0e10cSrcweir     mpRectangleShadow->SetSnapRect(aObjectPosition);
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir 
Paint(const Rectangle &)2359cdf0e10cSrcweir void SvxXShadowPreview::Paint( const Rectangle& )
2360cdf0e10cSrcweir {
2361cdf0e10cSrcweir     LocalPrePaint();
2362cdf0e10cSrcweir 
2363cdf0e10cSrcweir     sdr::contact::SdrObjectVector aObjectVector;
2364cdf0e10cSrcweir 
2365cdf0e10cSrcweir     aObjectVector.push_back(mpRectangleShadow);
2366cdf0e10cSrcweir     aObjectVector.push_back(mpRectangleObject);
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2369cdf0e10cSrcweir     sdr::contact::DisplayInfo aDisplayInfo;
2370cdf0e10cSrcweir 
2371cdf0e10cSrcweir     aPainter.ProcessDisplay(aDisplayInfo);
2372cdf0e10cSrcweir 
2373cdf0e10cSrcweir     LocalPostPaint();
2374cdf0e10cSrcweir }
2375cdf0e10cSrcweir 
2376*633aadc5Smseidel /* vim: set noet sw=4 ts=4: */
2377