30#include <textlayout.hxx>
51 ImplInit( pParent, nStyle,
nullptr );
72 Window::EnableRTL(bEnable);
87 SAL_WARN_IF(
mxLayoutData,
"vcl",
"Control::CreateLayoutData: should be called with non-existent layout data only!" );
99 Window::SetText( rStr );
102ControlLayoutData::ControlLayoutData() : m_pParent( nullptr )
113 if( !HasLayoutData() )
125 if (rPoint.X() >= aTopLeft.X() && rPoint.Y() >= aTopLeft.Y() &&
126 rPoint.X() <= aBottomRight.X() && rPoint.Y() <= aBottomRight.Y())
137 if( ! HasLayoutData() )
139 return mxLayoutData ? mxLayoutData->GetIndexForPoint( rPoint ) : -1;
152 Pair aPair( -1, -1 );
155 if( nLine >= 0 && nLine < nDisplayLines )
158 if( nLine+1 < nDisplayLines )
163 else if( nLine == 0 && nDisplayLines == 0 && !
m_aDisplayText.isEmpty() )
175 if( !HasLayoutData() )
177 return mxLayoutData ? mxLayoutData->GetLineStartEnd( nLine ) :
Pair( -1, -1 );
188 if( nDisplayLines > 1 )
191 for( nLine = nDisplayLines-1; nLine >= 0; nLine-- )
201 SAL_WARN_IF( nLine < 0,
"vcl",
"ToRelativeLineIndex failed" );
214 if( !HasLayoutData() )
216 return mxLayoutData ? mxLayoutData->ToRelativeLineIndex(
nIndex ) : -1;
221 if( !HasLayoutData() )
223 return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText();
230 if ( !mbHasControlFocus )
232 mbHasControlFocus =
true;
244 if ( !pFocusWin || !ImplIsWindowOrChild( pFocusWin ) )
246 mbHasControlFocus =
false;
265 ImplClearLayoutData();
277 tools::Long nCurrentIndex = mxLayoutData->m_aDisplayText.getLength();
278 mxLayoutData->m_aDisplayText += rSubControl.
mxLayoutData->m_aDisplayText;
279 int nLines = rSubControl.
mxLayoutData->m_aLineIndices.size();
281 mxLayoutData->m_aLineIndices.push_back( nCurrentIndex );
282 for(
n = 1;
n < nLines;
n++ )
283 mxLayoutData->m_aLineIndices.push_back( rSubControl.
mxLayoutData->m_aLineIndices[
n] + nCurrentIndex );
284 int nRectangles = rSubControl.
mxLayoutData->m_aUnicodeBoundRects.size();
286 for(
n = 0;
n < nRectangles;
n++ )
290 mxLayoutData->m_aUnicodeBoundRects.push_back( aRect );
323 if( HasLayoutData() )
324 mxLayoutData->m_pParent = pParent;
329 mxLayoutData.reset();
346 aStyle.
SetMonoColor( GetSettings().GetStyleSettings().GetMonoColor() );
351 pDev->OutputDevice::SetSettings( aNewSettings );
356 pDev->OutputDevice::SetSettings( aOriginalSettings );
361 mbShowAccelerator = bVal;
372 return Size( GetTextWidth( GetText() ) + 2 * 12,
373 GetTextHeight() + 2 * 6 );
378 if ( mpReferenceDevice == _referenceDevice )
381 mpReferenceDevice = _referenceDevice;
396 if(
nullptr != mpReferenceDevice && mpReferenceDevice->isDisposed())
398 const_cast<Control*
>(
this)->SetReferenceDevice(
nullptr);
401 return mpReferenceDevice;
418 ApplyControlFont(rRenderContext, GetCanonicalFont(rStyleSettings));
420 ApplyControlForeground(rRenderContext, GetCanonicalTextColor(rStyleSettings));
426 ApplySettings(*GetOutDev());
430 DrawTextFlags _nStyle, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
const
432 OUString rPStr = _rStr;
437 if (autoacc && !mbShowAccelerator)
443 if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
446 _rTargetDevice.
DrawText(aRet, rPStr, nPStyle, _pVector, _pDisplayText);
451 return aRenderer.
DrawText(rRect, rPStr, nPStyle, _pVector, _pDisplayText, i_pDeviceSize);
457 OUString rPStr = _rStr;
462 if (autoacc && !mbShowAccelerator)
468 if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
473 *o_pDeviceSize = aRet.
GetSize();
479 return aRenderer.
GetTextRect(rRect, rPStr, nPStyle, o_pDeviceSize);
485 Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings()));
487 aFont.
Merge(GetControlFont());
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
static vcl::Window * GetFocusWindow()
Get the currently focused window.
OutputDevice * GetReferenceDevice() const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
std::optional< vcl::ControlLayoutData > mxLayoutData
void CreateLayoutData() const
creates the mpData->mpLayoutData structure
vcl::Font GetUnzoomedControlPointFont() const
tools::Long GetIndexForPoint(const Point &rPoint) const
VclPtr< OutputDevice > mpReferenceDevice
SAL_DLLPRIVATE void ImplClearLayoutData() const
tools::Rectangle DrawControlText(OutputDevice &_rTargetDevice, const tools::Rectangle &_rRect, const OUString &_rStr, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize=nullptr) const
draws the given text onto the given device
virtual void FillLayoutData() const
Control(const Control &)=delete
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Pair GetLineStartEnd(tools::Long nLine) const
void SetLayoutDataParent(const Control *pParent) const
virtual bool EventNotify(NotifyEvent &rNEvt) override
tools::Rectangle GetControlTextRect(OutputDevice &_rTargetDevice, const tools::Rectangle &rRect, const OUString &_rStr, DrawTextFlags _nStyle, Size *o_pDeviceSize=nullptr) const
virtual void StateChanged(StateChangedType nStateChange) override
SAL_DLLPRIVATE void ImplInitControlData()
virtual void Resize() override
virtual ~Control() override
virtual void EnableRTL(bool bEnable=true) override
bool HasLayoutData() const
determines whether we currently have layout data
void SetReferenceDevice(OutputDevice *_referenceDevice)
sets a reference device used for rendering control text
virtual void SetText(const OUString &rStr) override
virtual OUString GetDisplayText() const override
virtual Size GetOptimalSize() const override
void AppendLayoutData(const Control &rSubControl) const
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
tools::Rectangle GetCharacterBounds(tools::Long nIndex) const
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const
void SetShowAccelerator(bool val)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
NotifyEventType GetType() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
const AllSettings & GetSettings() const
StyleSettingsOptions GetOptions() const
const Color & GetLabelTextColor() const
const vcl::Font & GetLabelFont() const
void SetMonoColor(const Color &rColor)
void SetOptions(StyleSettingsOptions nOptions)
void logAction(VclPtr< Control > const &xUIElement, VclEventId nEvent)
static UITestLogger & getInstance()
a class which allows rendering text of a Control onto a device, by taking into account the metrics of...
tools::Rectangle DrawText(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize)
tools::Rectangle GetTextRect(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, Size *o_pDeviceSize)
void Merge(const Font &rFont)
virtual void StateChanged(StateChangedType nStateChange)
::OutputDevice const * GetOutDev() const
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
virtual bool EventNotify(NotifyEvent &rNEvt)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::Pair GetLineStartEnd(tools::Long nLine) const
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
tools::Long GetIndexForPoint(const Point &rPoint) const
tools::Rectangle GetCharacterBounds(tools::Long nIndex) const
std::vector< tools::Rectangle > m_aUnicodeBoundRects
std::vector< tools::Long > m_aLineIndices
VclPtr< const Control > m_pParent
tools::Long GetLineCount() const
ImplSVData * ImplGetSVData()
OUString removeMnemonicFromString(OUString const &rStr)