28 #include <textlayout.hxx>
36 mbHasControlFocus =
false;
37 mbShowAccelerator =
false;
51 ImplInit( pParent, nStyle,
nullptr );
86 SAL_WARN_IF(
mpControlData->mpLayoutData,
"vcl",
"Control::CreateLayoutData: should be called with non-existent layout data only!" );
98 Window::SetText( rStr );
101 ControlLayoutData::ControlLayoutData() : m_pParent( nullptr )
112 if( !HasLayoutData() )
114 return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetCharacterBounds( nIndex ) :
tools::Rectangle();
124 if (rPoint.X() >= aTopLeft.X() && rPoint.Y() >= aTopLeft.Y() &&
125 rPoint.X() <= aBottomRight.X() && rPoint.Y() <= aBottomRight.Y())
136 if( ! HasLayoutData() )
138 return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetIndexForPoint( rPoint ) : -1;
151 Pair aPair( -1, -1 );
154 if( nLine >= 0 && nLine < nDisplayLines )
157 if( nLine+1 < nDisplayLines )
162 else if( nLine == 0 && nDisplayLines == 0 && !
m_aDisplayText.isEmpty() )
174 if( !HasLayoutData() )
176 return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetLineStartEnd( nLine ) :
Pair( -1, -1 );
187 if( nDisplayLines > 1 )
190 for( nLine = nDisplayLines-1; nLine >= 0; nLine-- )
200 SAL_WARN_IF( nLine < 0,
"vcl",
"ToRelativeLineIndex failed" );
213 if( !HasLayoutData() )
215 return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->ToRelativeLineIndex( nIndex ) : -1;
220 if( !HasLayoutData() )
222 return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->m_aDisplayText : GetText();
232 if ( !mbHasControlFocus )
234 mbHasControlFocus =
true;
246 if ( !pFocusWin || !ImplIsWindowOrChild( pFocusWin ) )
248 mbHasControlFocus =
false;
268 ImplClearLayoutData();
280 tools::Long nCurrentIndex = mpControlData->mpLayoutData->m_aDisplayText.getLength();
281 mpControlData->mpLayoutData->m_aDisplayText += rSubControl.
mpControlData->mpLayoutData->m_aDisplayText;
282 int nLines = rSubControl.
mpControlData->mpLayoutData->m_aLineIndices.size();
284 mpControlData->mpLayoutData->m_aLineIndices.push_back( nCurrentIndex );
285 for( n = 1; n < nLines; n++ )
286 mpControlData->mpLayoutData->m_aLineIndices.push_back( rSubControl.
mpControlData->mpLayoutData->m_aLineIndices[n] + nCurrentIndex );
287 int nRectangles = rSubControl.
mpControlData->mpLayoutData->m_aUnicodeBoundRects.size();
289 for( n = 0; n < nRectangles; n++ )
293 mpControlData->mpLayoutData->m_aUnicodeBoundRects.push_back( aRect );
326 if( HasLayoutData() )
327 mpControlData->mpLayoutData->m_pParent = pParent;
333 mpControlData->mpLayoutData.reset();
350 aStyle.SetMonoColor( GetSettings().GetStyleSettings().GetMonoColor() );
352 aNewSettings.SetStyleSettings( aStyle );
355 pDev->OutputDevice::SetSettings( aNewSettings );
360 pDev->OutputDevice::SetSettings( aOriginalSettings );
365 mbShowAccelerator = bVal;
376 return Size( GetTextWidth( GetText() ) + 2 * 12,
377 GetTextHeight() + 2 * 6 );
382 if ( mpControlData->mpReferenceDevice == _referenceDevice )
385 mpControlData->mpReferenceDevice = _referenceDevice;
400 if(
nullptr != mpControlData->mpReferenceDevice && mpControlData->mpReferenceDevice->isDisposed())
402 const_cast<Control*
>(
this)->SetReferenceDevice(
nullptr);
405 return mpControlData->mpReferenceDevice;
422 ApplyControlFont(rRenderContext, GetCanonicalFont(rStyleSettings));
424 ApplyControlForeground(rRenderContext, GetCanonicalTextColor(rStyleSettings));
430 ApplySettings(*
this);
436 OUString rPStr = _rStr;
441 if (autoacc && !mbShowAccelerator)
443 rPStr = GetNonMnemonicString( _rStr );
447 if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
450 _rTargetDevice.
DrawText(aRet, rPStr, nPStyle, _pVector, _pDisplayText);
455 return aRenderer.
DrawText(rRect, rPStr, nPStyle, _pVector, _pDisplayText, i_pDeviceSize);
461 OUString rPStr = _rStr;
466 if (autoacc && !mbShowAccelerator)
468 rPStr = GetNonMnemonicString( _rStr );
472 if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
477 *o_pDeviceSize = aRet.
GetSize();
483 return aRenderer.
GetTextRect(rRect, rPStr, nPStyle, o_pDeviceSize);
489 Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings()));
491 aFont.
Merge(GetControlFont());
virtual OUString GetDisplayText() const override
void CreateLayoutData() const
creates the mpData->mpLayoutData structure
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
virtual void EnableRTL(bool bEnable=true) override
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
tools::Long GetLineCount() const
std::vector< tools::Rectangle > MetricVector
SAL_DLLPRIVATE void ImplInitControlData()
Pair GetLineStartEnd(tools::Long nLine) const
std::vector< tools::Long > m_aLineIndices
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
SAL_DLLPRIVATE void ImplClearLayoutData() const
const StyleSettings & GetStyleSettings() const
virtual void StateChanged(StateChangedType nStateChange) override
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
virtual void FillLayoutData() const
void CompatStateChanged(StateChangedType nStateChange)
void SetLayoutMode(ComplexTextLayoutFlags nTextLayoutMode)
const Color & GetLabelTextColor() const
void AppendLayoutData(const Control &rSubControl) const
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
void logAction(VclPtr< Control > const &xUIElement, VclEventId nEvent)
tools::Rectangle GetControlTextRect(OutputDevice &_rTargetDevice, const tools::Rectangle &rRect, const OUString &_rStr, DrawTextFlags _nStyle, Size *o_pDeviceSize=nullptr) const
std::vector< tools::Rectangle > m_aUnicodeBoundRects
static UITestLogger & getInstance()
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
tools::Long GetIndexForPoint(const Point &rPoint) const
const vcl::Font & GetLabelFont() const
virtual ~Control() override
void SetOptions(StyleSettingsOptions nOptions)
virtual void EnableRTL(bool bEnable=true)
a class which allows rendering text of a Control onto a device, by taking into account the metrics of...
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
tools::Rectangle DrawControlText(OutputDevice &_rTargetDevice, const tools::Rectangle &_rRect, const OUString &_rStr, DrawTextFlags _nStyle, MetricVector *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize=nullptr) const
draws the given text onto the given device
ImplSVData * ImplGetSVData()
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
OutputDevice * GetReferenceDevice() const
tools::Rectangle GetCharacterBounds(tools::Long nIndex) const
virtual bool EventNotify(NotifyEvent &rNEvt)
virtual void SetText(const OUString &rStr) override
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
vcl::Font GetUnzoomedControlPointFont() const
void Merge(const Font &rFont)
tools::Rectangle GetTextRect(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, Size *o_pDeviceSize)
MouseNotifyEvent GetType() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
const AllSettings & GetSettings() const
void SetShowAccelerator(bool val)
VclPtr< const Control > m_pParent
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
virtual Size GetOptimalSize() const override
static vcl::Window * GetFocusWindow()
Get the currently focused window.
virtual void Resize() override
tools::Long GetIndexForPoint(const Point &rPoint) const
Control(const Control &)=delete
#define SAL_WARN_IF(condition, area, stream)
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const
std::unique_ptr< vcl::ImplControlData > mpControlData
tools::Rectangle DrawText(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, MetricVector *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize)
tools::Rectangle GetCharacterBounds(tools::Long nIndex) const
::Pair GetLineStartEnd(tools::Long nLine) const
virtual void StateChanged(StateChangedType nStateChange)
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
void SetReferenceDevice(OutputDevice *_referenceDevice)
sets a reference device used for rendering control text
bool HasLayoutData() const
determines whether we currently have layout data
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
void SetLayoutDataParent(const Control *pParent) const
virtual bool EventNotify(NotifyEvent &rNEvt) override