1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "richtextimplcontrol.hxx"
21 #include "textattributelistener.hxx"
22 #include "richtextengine.hxx"
23 #include <sal/log.hxx>
24 #include <osl/diagnose.h>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <editeng/editids.hrc>
27 #include <editeng/editview.hxx>
28 #include <editeng/editstat.hxx>
29 #include <editeng/scripttypeitem.hxx>
31 #include <svl/itempool.hxx>
32 #include <svl/itemset.hxx>
33 #include <tools/mapunit.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/settings.hxx>
36 #include <vcl/commandevent.hxx>
38 #define EMPTY_PAPER_SIZE 0x7FFFFFFF
44 RichTextControlImpl::RichTextControlImpl( Control
* _pAntiImpl
, RichTextEngine
* _pEngine
, ITextAttributeListener
* _pTextAttrListener
, ITextSelectionListener
* _pSelectionListener
)
45 :m_pAntiImpl ( _pAntiImpl
)
46 ,m_pViewport ( nullptr )
47 ,m_pHScroll ( nullptr )
48 ,m_pVScroll ( nullptr )
49 ,m_pEngine ( _pEngine
)
50 ,m_pTextAttrListener ( _pTextAttrListener
)
51 ,m_pSelectionListener ( _pSelectionListener
)
52 ,m_bHasEverBeenShown ( false )
54 OSL_ENSURE( m_pAntiImpl
, "RichTextControlImpl::RichTextControlImpl: invalid window!" );
55 assert(m_pEngine
&& "RichTextControlImpl::RichTextControlImpl: invalid edit engine! This will *definitely* crash!");
57 m_pViewport
= VclPtr
<RichTextViewPort
>::Create( m_pAntiImpl
);
58 m_pViewport
->setAttributeInvalidationHandler( LINK( this, RichTextControlImpl
, OnInvalidateAllAttributes
) );
61 // ensure that both the window and the reference device have the same map unit
62 MapMode
aRefDeviceMapMode( m_pEngine
->GetRefDevice()->GetMapMode() );
63 m_pAntiImpl
->SetMapMode( aRefDeviceMapMode
);
64 m_pViewport
->SetMapMode( aRefDeviceMapMode
);
66 m_pView
.reset(new EditView( m_pEngine
, m_pViewport
));
67 m_pEngine
->InsertView( m_pView
.get() );
68 m_pViewport
->setView( *m_pView
);
70 m_pEngine
->registerEngineStatusListener( this );
73 EVControlBits nViewControlWord
= m_pView
->GetControlWord();
74 nViewControlWord
|= EVControlBits::AUTOSCROLL
;
75 m_pView
->SetControlWord( nViewControlWord
);
78 // ensure that it's initially scrolled to the upper left
79 m_pView
->SetVisArea( tools::Rectangle( Point( ), m_pViewport
->GetOutDev()->GetOutputSize() ) );
83 m_pAntiImpl
->SetBackground( Wallpaper( m_pAntiImpl
->GetSettings().GetStyleSettings().GetFieldColor() ) );
86 RichTextControlImpl::~RichTextControlImpl( )
88 m_pEngine
->RemoveView( m_pView
.get() );
89 m_pEngine
->revokeEngineStatusListener( this );
91 m_pViewport
.disposeAndClear();
92 m_pHScroll
.disposeAndClear();
93 m_pVScroll
.disposeAndClear();
96 void RichTextControlImpl::implUpdateAttribute( const AttributeHandlerPool::const_iterator
& _pHandler
)
98 if ( ( _pHandler
->first
== sal_uInt16(SID_ATTR_CHAR_WEIGHT
) )
99 || ( _pHandler
->first
== sal_uInt16(SID_ATTR_CHAR_POSTURE
) )
100 || ( _pHandler
->first
== sal_uInt16(SID_ATTR_CHAR_FONT
) )
101 || ( _pHandler
->first
== sal_uInt16(SID_ATTR_CHAR_FONTHEIGHT
) )
104 // these are attributes whose value depends on the current script type.
105 // I.e., in real, there are *three* items in the ItemSet: One for each script
106 // type (Latin, Asian, Complex). However, if we have an observer who is interested
107 // in the state of this attribute, we have to kind of *merge* the three attributes
109 // This is useful in case the observer is for instance a toolbox which contains only
110 // an, e.g., "bold" slot, and thus not interested in the particular script type of the
111 // current selection.
112 SvxScriptSetItem
aNormalizedSet( static_cast<WhichId
>(_pHandler
->first
), *m_pView
->GetAttribs().GetPool() );
113 normalizeScriptDependentAttribute( aNormalizedSet
);
115 implCheckUpdateCache( _pHandler
->first
, _pHandler
->second
->getState( aNormalizedSet
.GetItemSet() ) );
118 implCheckUpdateCache( _pHandler
->first
, _pHandler
->second
->getState( m_pView
->GetAttribs() ) );
122 void RichTextControlImpl::updateAttribute( AttributeId _nAttribute
)
124 AttributeHandlerPool::const_iterator pHandler
= m_aAttributeHandlers
.find( _nAttribute
);
125 if ( pHandler
!= m_aAttributeHandlers
.end() )
126 implUpdateAttribute( pHandler
);
130 void RichTextControlImpl::updateAllAttributes( )
132 for ( AttributeHandlerPool::const_iterator pHandler
= m_aAttributeHandlers
.begin();
133 pHandler
!= m_aAttributeHandlers
.end();
137 implUpdateAttribute( pHandler
);
140 // notify changes of the selection, if necessary
141 if ( m_pSelectionListener
&& m_pView
)
143 ESelection aCurrentSelection
= m_pView
->GetSelection();
144 if ( aCurrentSelection
!= m_aLastKnownSelection
)
146 m_aLastKnownSelection
= aCurrentSelection
;
147 m_pSelectionListener
->onSelectionChanged();
153 AttributeState
RichTextControlImpl::getAttributeState( AttributeId _nAttributeId
) const
155 StateCache::const_iterator aCachedStatePos
= m_aLastKnownStates
.find( _nAttributeId
);
156 if ( aCachedStatePos
== m_aLastKnownStates
.end() )
158 OSL_FAIL( "RichTextControlImpl::getAttributeState: Don't ask for the state of an attribute which I never encountered!" );
159 return AttributeState( eIndetermined
);
161 return aCachedStatePos
->second
;
165 bool RichTextControlImpl::executeAttribute( const SfxItemSet
& _rCurrentAttribs
, SfxItemSet
& _rAttribs
, AttributeId _nAttribute
, const SfxPoolItem
* _pArgument
, SvtScriptType _nForScriptType
)
167 // let's see whether we have a handler for this attribute
168 AttributeHandlerPool::const_iterator aHandlerPos
= m_aAttributeHandlers
.find( _nAttribute
);
169 if ( aHandlerPos
!= m_aAttributeHandlers
.end() )
171 aHandlerPos
->second
->executeAttribute( _rCurrentAttribs
, _rAttribs
, _pArgument
, _nForScriptType
);
178 void RichTextControlImpl::enableAttributeNotification( AttributeId _nAttributeId
, ITextAttributeListener
* _pListener
)
180 AttributeHandlerPool::const_iterator aHandlerPos
= m_aAttributeHandlers
.find( _nAttributeId
);
181 if ( aHandlerPos
== m_aAttributeHandlers
.end() )
183 ::rtl::Reference
< AttributeHandler
> aHandler
= AttributeHandlerFactory::getHandlerFor( _nAttributeId
, *m_pEngine
->GetEmptyItemSet().GetPool() );
184 OSL_ENSURE( aHandler
.is(), "RichTextControlImpl::enableAttributeNotification: no handler available for this attribute!" );
185 if ( !aHandler
.is() )
187 SAL_WARN_IF( _nAttributeId
!= aHandler
->getAttributeId(), "forms.richtext", "RichTextControlImpl::enableAttributeNotification: suspicious handler!" );
189 aHandlerPos
= m_aAttributeHandlers
.emplace( _nAttributeId
, aHandler
).first
;
192 // remember the listener
194 m_aAttributeListeners
.emplace( _nAttributeId
, _pListener
);
196 // update (and broadcast) the state of this attribute
197 updateAttribute( _nAttributeId
);
201 void RichTextControlImpl::disableAttributeNotification( AttributeId _nAttributeId
)
203 // forget the handler for this attribute
204 AttributeHandlerPool::iterator aHandlerPos
= m_aAttributeHandlers
.find( _nAttributeId
);
205 if ( aHandlerPos
!= m_aAttributeHandlers
.end() )
206 m_aAttributeHandlers
.erase( aHandlerPos
);
208 // as well as the listener
209 AttributeListenerPool::iterator aListenerPos
= m_aAttributeListeners
.find( _nAttributeId
);
210 if ( aListenerPos
!= m_aAttributeListeners
.end() )
211 m_aAttributeListeners
.erase( aListenerPos
);
215 void RichTextControlImpl::normalizeScriptDependentAttribute( SvxScriptSetItem
& _rScriptSetItem
)
217 _rScriptSetItem
.GetItemSet().Put( m_pView
->GetAttribs(), false );
218 const SfxPoolItem
* pNormalizedItem
= _rScriptSetItem
.GetItemOfScript( getSelectedScriptType() );
220 WhichId nNormalizedWhichId
= _rScriptSetItem
.GetItemSet().GetPool()->GetWhichIDFromSlotID( _rScriptSetItem
.Which() );
221 if ( pNormalizedItem
)
223 _rScriptSetItem
.GetItemSet().Put( pNormalizedItem
->CloneSetWhich(nNormalizedWhichId
) );
226 _rScriptSetItem
.GetItemSet().InvalidateItem( nNormalizedWhichId
);
230 void RichTextControlImpl::implCheckUpdateCache( AttributeId _nAttribute
, const AttributeState
& _rState
)
232 StateCache::iterator aCachePos
= m_aLastKnownStates
.find( _nAttribute
);
233 if ( aCachePos
== m_aLastKnownStates
.end() )
234 { // nothing known about this attribute, yet
235 m_aLastKnownStates
.emplace( _nAttribute
, _rState
);
239 if ( aCachePos
->second
== _rState
)
244 aCachePos
->second
= _rState
;
247 // is there a dedicated listener for this particular attribute?
248 AttributeListenerPool::const_iterator aListenerPos
= m_aAttributeListeners
.find( _nAttribute
);
249 if ( aListenerPos
!= m_aAttributeListeners
.end( ) )
250 aListenerPos
->second
->onAttributeStateChanged( _nAttribute
);
252 // call our global listener, if there is one
253 if ( m_pTextAttrListener
)
254 m_pTextAttrListener
->onAttributeStateChanged( _nAttribute
);
258 SvtScriptType
RichTextControlImpl::getSelectedScriptType() const
260 SvtScriptType nScript
= m_pView
->GetSelectedScriptType();
261 if ( nScript
== SvtScriptType::NONE
)
262 nScript
= SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
267 void RichTextControlImpl::EditEngineStatusChanged( const EditStatus
& _rStatus
)
269 EditStatusFlags
nStatusWord( _rStatus
.GetStatusWord() );
270 if ( ( nStatusWord
& EditStatusFlags::TEXTWIDTHCHANGED
)
271 || ( nStatusWord
& EditStatusFlags::TextHeightChanged
)
274 if ( ( nStatusWord
& EditStatusFlags::TextHeightChanged
) && windowHasAutomaticLineBreak() )
275 m_pEngine
->SetPaperSize( Size( m_pEngine
->GetPaperSize().Width(), m_pEngine
->GetTextHeight() ) );
280 bool bHScroll
= bool( nStatusWord
& EditStatusFlags::HSCROLL
);
281 bool bVScroll
= bool( nStatusWord
& EditStatusFlags::VSCROLL
);
283 // In case of *no* automatic line breaks, we also need to check for the *range* here.
284 // Normally, we would do this only after an EditStatusFlags::TEXTWIDTHCHANGED. However, due to a bug
285 // in the EditEngine (I believe so) this is not fired when the engine does not have
286 // the AutoPaperSize bits set.
287 // So in order to be properly notified, we would need the AutoPaperSize. But, with
288 // AutoPaperSize, other things do not work anymore: Either, when we set a MaxAutoPaperSize,
289 // then the view does automatic soft line breaks at the paper end - which we definitely do
290 // want. Or, if we did not set a MaxAutoPaperSize, then the view does not automatically scroll
291 // anymore in horizontal direction.
292 // So this is some kind of lose-lose situation ... :(
293 if ( !windowHasAutomaticLineBreak() && bHScroll
)
299 if ( bHScroll
&& m_pHScroll
)
300 m_pHScroll
->SetThumbPos( m_pView
->GetVisArea().Left() );
301 if ( bVScroll
&& m_pVScroll
)
302 m_pVScroll
->SetThumbPos( m_pView
->GetVisArea().Top() );
305 IMPL_LINK_NOARG( RichTextControlImpl
, OnInvalidateAllAttributes
, LinkParamNone
*, void )
307 updateAllAttributes();
310 IMPL_LINK( RichTextControlImpl
, OnHScroll
, weld::Scrollbar
&, rScrollbar
, void )
312 auto nDiff
= m_pView
->GetVisArea().Left() - rScrollbar
.adjustment_get_value();
313 m_pView
->Scroll(nDiff
, 0, ScrollRangeCheck::PaperWidthTextSize
);
316 IMPL_LINK(RichTextControlImpl
, OnVScroll
, weld::Scrollbar
&, rScrollbar
, void)
318 auto nDiff
= m_pView
->GetVisArea().Top() - rScrollbar
.adjustment_get_value();
319 m_pView
->Scroll(0, nDiff
, ScrollRangeCheck::PaperWidthTextSize
);
322 void RichTextControlImpl::ensureScrollbars()
324 bool bNeedVScroll
= 0 != ( m_pAntiImpl
->GetStyle() & WB_VSCROLL
);
325 bool bNeedHScroll
= 0 != ( m_pAntiImpl
->GetStyle() & WB_HSCROLL
);
327 if ( ( bNeedVScroll
== hasVScrollBar() ) && ( bNeedHScroll
== hasHScrollBar( ) ) )
331 // create or delete the scrollbars, as necessary
334 m_pVScroll
.disposeAndClear();
338 m_pVScroll
= VclPtr
<ScrollAdaptor
>::Create( m_pAntiImpl
, false );
339 m_pVScroll
->SetScrollHdl ( LINK( this, RichTextControlImpl
, OnVScroll
) );
345 m_pHScroll
.disposeAndClear();
349 m_pHScroll
= VclPtr
<ScrollAdaptor
>::Create( m_pAntiImpl
, true );
350 m_pHScroll
->SetScrollHdl ( LINK( this, RichTextControlImpl
, OnHScroll
) );
357 void RichTextControlImpl::ensureLineBreakSetting()
359 if ( !windowHasAutomaticLineBreak() )
360 m_pEngine
->SetPaperSize( Size( EMPTY_PAPER_SIZE
, EMPTY_PAPER_SIZE
) );
365 void RichTextControlImpl::layoutWindow()
367 if ( !m_bHasEverBeenShown
)
368 // no need to do anything. Especially, no need to set the paper size on the
369 // EditEngine to anything...
372 const StyleSettings
& rStyleSettings
= m_pAntiImpl
->GetSettings().GetStyleSettings();
374 tools::Long nScrollBarWidth
= m_pVScroll
? rStyleSettings
.GetScrollBarSize() : 0;
375 tools::Long nScrollBarHeight
= m_pHScroll
? rStyleSettings
.GetScrollBarSize() : 0;
377 if ( m_pAntiImpl
->IsZoom() )
379 nScrollBarWidth
= m_pAntiImpl
->CalcZoom( nScrollBarWidth
);
380 nScrollBarHeight
= m_pAntiImpl
->CalcZoom( nScrollBarHeight
);
383 // the overall size we can use
384 Size
aPlaygroundSizePixel( m_pAntiImpl
->GetOutputSizePixel() );
386 // the size of the viewport - note that the viewport does *not* occupy all the place
387 // which is left when subtracting the scrollbar width/height
388 Size
aViewportPlaygroundPixel( aPlaygroundSizePixel
);
389 aViewportPlaygroundPixel
.setWidth( ::std::max( tools::Long( 10 ), tools::Long( aViewportPlaygroundPixel
.Width() - nScrollBarWidth
) ) );
390 aViewportPlaygroundPixel
.setHeight( ::std::max( tools::Long( 10 ), tools::Long( aViewportPlaygroundPixel
.Height() - nScrollBarHeight
) ) );
391 Size
aViewportPlaygroundLogic( m_pViewport
->PixelToLogic( aViewportPlaygroundPixel
) );
393 const tools::Long nOffset
= 2;
394 Size
aViewportSizePixel( aViewportPlaygroundPixel
.Width() - 2 * nOffset
, aViewportPlaygroundPixel
.Height() - 2 * nOffset
);
395 Size
aViewportSizeLogic( m_pViewport
->PixelToLogic( aViewportSizePixel
) );
397 // position the viewport
398 m_pViewport
->SetPosSizePixel( Point( nOffset
, nOffset
), aViewportSizePixel
);
399 // position the scrollbars
402 m_pVScroll
->SetThickness(nScrollBarWidth
);
403 m_pVScroll
->SetPosSizePixel( Point( aViewportPlaygroundPixel
.Width(), 0 ), Size( nScrollBarWidth
, aViewportPlaygroundPixel
.Height() ) );
407 m_pHScroll
->SetThickness(nScrollBarHeight
);
408 m_pHScroll
->SetPosSizePixel( Point( 0, aViewportPlaygroundPixel
.Height() ), Size( aViewportPlaygroundPixel
.Width(), nScrollBarHeight
) );
412 if ( windowHasAutomaticLineBreak() )
413 m_pEngine
->SetPaperSize( Size( aViewportSizeLogic
.Width(), m_pEngine
->GetTextHeight() ) );
415 // output area of the view
416 m_pView
->SetOutputArea( tools::Rectangle( Point( ), aViewportSizeLogic
) );
417 m_pView
->SetVisArea( tools::Rectangle( Point( ), aViewportSizeLogic
) );
421 m_pVScroll
->SetVisibleSize( aViewportPlaygroundLogic
.Height() );
423 // the default height of a text line...
424 tools::Long nFontHeight
= m_pEngine
->GetStandardFont(0).GetFontSize().Height();
425 // ... is the scroll size for the vertical scrollbar
426 m_pVScroll
->SetLineSize( nFontHeight
);
427 // the viewport width, minus one line, is the page scroll size
428 m_pVScroll
->SetPageSize( ::std::max( nFontHeight
, aViewportPlaygroundLogic
.Height() - nFontHeight
) );
434 m_pHScroll
->SetVisibleSize( aViewportPlaygroundLogic
.Width() );
436 tools::Long nFontWidth
= m_pEngine
->GetStandardFont(0).GetFontSize().Width();
439 m_pViewport
->GetOutDev()->Push( vcl::PushFlags::FONT
);
440 m_pViewport
->SetFont( m_pEngine
->GetStandardFont(0) );
441 nFontWidth
= m_pViewport
->GetTextWidth( u
"x"_ustr
);
442 m_pViewport
->GetOutDev()->Pop();
444 // ... is the scroll size for the horizontal scrollbar
445 m_pHScroll
->SetLineSize( 5 * nFontWidth
);
446 // the viewport height, minus one character, is the page scroll size
447 m_pHScroll
->SetPageSize( ::std::max( nFontWidth
, aViewportPlaygroundLogic
.Width() - nFontWidth
) );
450 // update range and position of the scrollbars
455 void RichTextControlImpl::updateScrollbars()
459 tools::Long nOverallTextHeight
= m_pEngine
->GetTextHeight();
460 m_pVScroll
->SetRange( Range( 0, nOverallTextHeight
) );
461 m_pVScroll
->SetThumbPos( m_pView
->GetVisArea().Top() );
466 Size
aPaperSize( m_pEngine
->GetPaperSize() );
467 tools::Long nOverallTextWidth
= ( aPaperSize
.Width() == EMPTY_PAPER_SIZE
) ? m_pEngine
->CalcTextWidth() : aPaperSize
.Width();
468 m_pHScroll
->SetRange( Range( 0, nOverallTextWidth
) );
469 m_pHScroll
->SetThumbPos( m_pView
->GetVisArea().Left() );
474 void RichTextControlImpl::notifyInitShow()
476 if ( !m_bHasEverBeenShown
)
478 m_bHasEverBeenShown
= true;
484 void RichTextControlImpl::notifyStyleChanged()
487 ensureLineBreakSetting();
491 void RichTextControlImpl::notifyZoomChanged()
493 const Fraction
& rZoom
= m_pAntiImpl
->GetZoom();
495 MapMode
aMapMode( m_pAntiImpl
->GetMapMode() );
496 aMapMode
.SetScaleX( rZoom
);
497 aMapMode
.SetScaleY( rZoom
);
498 m_pAntiImpl
->SetMapMode( aMapMode
);
500 m_pViewport
->SetZoom( rZoom
);
501 m_pViewport
->SetMapMode( aMapMode
);
507 bool RichTextControlImpl::windowHasAutomaticLineBreak()
509 return ( m_pAntiImpl
->GetStyle() & WB_WORDBREAK
) != 0;
513 void RichTextControlImpl::SetReadOnly( bool _bReadOnly
)
515 m_pView
->SetReadOnly( _bReadOnly
);
519 bool RichTextControlImpl::IsReadOnly() const
521 return m_pView
->IsReadOnly( );
527 void lcl_inflate( tools::Rectangle
& _rRect
, tools::Long _nInflateX
, tools::Long _nInflateY
)
529 _rRect
.AdjustLeft( -_nInflateX
);
530 _rRect
.AdjustRight(_nInflateX
);
531 _rRect
.AdjustTop( -_nInflateY
);
532 _rRect
.AdjustBottom(_nInflateY
);
536 bool RichTextControlImpl::HandleCommand( const CommandEvent
& _rEvent
)
538 if ( ( _rEvent
.GetCommand() == CommandEventId::Wheel
)
539 || ( _rEvent
.GetCommand() == CommandEventId::StartAutoScroll
)
540 || ( _rEvent
.GetCommand() == CommandEventId::AutoScroll
)
543 m_pAntiImpl
->HandleScrollCommand( _rEvent
, m_pHScroll
, m_pVScroll
);
550 void RichTextControlImpl::Draw( OutputDevice
* _pDev
, const Point
& _rPos
, const Size
& _rSize
)
552 // need to normalize the map mode of the device - every paint operation on any device needs
553 // to use the same map mode
554 _pDev
->Push( vcl::PushFlags::MAPMODE
| vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FILLCOLOR
);
556 // enforce our "normalize map mode" on the device
557 MapMode
aRefMapMode( m_pEngine
->GetRefDevice()->GetMapMode() );
558 MapMode
aOriginalMapMode( _pDev
->GetMapMode() );
559 MapMode
aNormalizedMapMode( aRefMapMode
.GetMapUnit(), aRefMapMode
.GetOrigin(), aOriginalMapMode
.GetScaleX(), aOriginalMapMode
.GetScaleY() );
560 _pDev
->SetMapMode( aNormalizedMapMode
);
562 // translate coordinates
564 Size
aSize( _rSize
);
565 if ( aOriginalMapMode
.GetMapUnit() == MapUnit::MapPixel
)
567 aPos
= _pDev
->PixelToLogic( _rPos
, aNormalizedMapMode
);
568 aSize
= _pDev
->PixelToLogic( _rSize
, aNormalizedMapMode
);
572 aPos
= OutputDevice::LogicToLogic( _rPos
, aOriginalMapMode
, aNormalizedMapMode
);
573 aSize
= OutputDevice::LogicToLogic( _rSize
, aOriginalMapMode
, aNormalizedMapMode
);
576 tools::Rectangle
aPlayground( aPos
, aSize
);
577 Size
aOnePixel( _pDev
->PixelToLogic( Size( 1, 1 ) ) );
578 aPlayground
.AdjustRight( -(aOnePixel
.Width()) );
579 aPlayground
.AdjustBottom( -(aOnePixel
.Height()) );
582 _pDev
->SetLineColor();
583 _pDev
->DrawRect( aPlayground
);
585 // do we need to draw a border?
586 bool bBorder
= ( m_pAntiImpl
->GetStyle() & WB_BORDER
);
588 _pDev
->SetLineColor( m_pAntiImpl
->GetSettings().GetStyleSettings().GetMonoColor() );
590 _pDev
->SetLineColor();
591 _pDev
->SetFillColor( m_pAntiImpl
->GetBackground().GetColor() );
592 _pDev
->DrawRect( aPlayground
);
595 // don't draw the text over the border
596 lcl_inflate( aPlayground
, -aOnePixel
.Width(), -aOnePixel
.Height() );
598 // leave a space of two pixels between the "surroundings" of the control
600 lcl_inflate( aPlayground
, -aOnePixel
.Width(), -aOnePixel
.Height() );
601 lcl_inflate( aPlayground
, -aOnePixel
.Width(), -aOnePixel
.Height() );
603 // actually draw the content
604 m_pEngine
->Draw(*_pDev
, aPlayground
, Point(), true);
610 void RichTextControlImpl::SetBackgroundColor( )
612 SetBackgroundColor( Application::GetSettings().GetStyleSettings().GetFieldColor() );
616 void RichTextControlImpl::SetBackgroundColor( const Color
& _rColor
)
618 Wallpaper
aWallpaper( _rColor
);
619 m_pAntiImpl
->SetBackground( aWallpaper
);
620 m_pViewport
->SetBackground( aWallpaper
);
624 void RichTextControlImpl::SetHideInactiveSelection( bool _bHide
)
626 m_pViewport
->SetHideInactiveSelection( _bHide
);
630 bool RichTextControlImpl::GetHideInactiveSelection() const
632 return m_pViewport
->GetHideInactiveSelection( );
639 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */