32#include <textlayout.hxx>
53 ImplInit( pParent, nStyle,
nullptr );
74 Window::EnableRTL(bEnable);
89 SAL_WARN_IF(
mxLayoutData,
"vcl",
"Control::CreateLayoutData: should be called with non-existent layout data only!" );
101 Window::SetText( rStr );
104ControlLayoutData::ControlLayoutData() : m_pParent( nullptr )
115 if( !HasLayoutData() )
127 if (rPoint.X() >= aTopLeft.X() && rPoint.Y() >= aTopLeft.Y() &&
128 rPoint.X() <= aBottomRight.X() && rPoint.Y() <= aBottomRight.Y())
139 if( ! HasLayoutData() )
141 return mxLayoutData ? mxLayoutData->GetIndexForPoint( rPoint ) : -1;
154 Pair aPair( -1, -1 );
157 if( nLine >= 0 && nLine < nDisplayLines )
160 if( nLine+1 < nDisplayLines )
165 else if( nLine == 0 && nDisplayLines == 0 && !
m_aDisplayText.isEmpty() )
177 if( !HasLayoutData() )
179 return mxLayoutData ? mxLayoutData->GetLineStartEnd( nLine ) :
Pair( -1, -1 );
190 if( nDisplayLines > 1 )
193 for( nLine = nDisplayLines-1; nLine >= 0; nLine-- )
203 SAL_WARN_IF( nLine < 0,
"vcl",
"ToRelativeLineIndex failed" );
216 if( !HasLayoutData() )
218 return mxLayoutData ? mxLayoutData->ToRelativeLineIndex(
nIndex ) : -1;
223 if( !HasLayoutData() )
225 return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText();
230 return ImplIsWindowOrChild(pFocusWin);
237 if ( !mbHasControlFocus )
239 mbHasControlFocus =
true;
251 if ( !pFocusWin || !FocusWindowBelongsToControl(pFocusWin) )
253 mbHasControlFocus =
false;
272 ImplClearLayoutData();
284 tools::Long nCurrentIndex = mxLayoutData->m_aDisplayText.getLength();
285 mxLayoutData->m_aDisplayText += rSubControl.
mxLayoutData->m_aDisplayText;
286 int nLines = rSubControl.
mxLayoutData->m_aLineIndices.size();
288 mxLayoutData->m_aLineIndices.push_back( nCurrentIndex );
289 for(
n = 1;
n < nLines;
n++ )
290 mxLayoutData->m_aLineIndices.push_back( rSubControl.
mxLayoutData->m_aLineIndices[
n] + nCurrentIndex );
291 int nRectangles = rSubControl.
mxLayoutData->m_aUnicodeBoundRects.size();
293 for(
n = 0;
n < nRectangles;
n++ )
297 mxLayoutData->m_aUnicodeBoundRects.push_back( aRect );
330 if( HasLayoutData() )
331 mxLayoutData->m_pParent = pParent;
336 mxLayoutData.reset();
353 aStyle.
SetMonoColor( GetSettings().GetStyleSettings().GetMonoColor() );
358 pDev->OutputDevice::SetSettings( aNewSettings );
363 pDev->OutputDevice::SetSettings( aOriginalSettings );
368 mbShowAccelerator = bVal;
379 return Size( GetTextWidth( GetText() ) + 2 * 12,
380 GetTextHeight() + 2 * 6 );
385 if ( mpReferenceDevice == _referenceDevice )
388 mpReferenceDevice = _referenceDevice;
403 if(
nullptr != mpReferenceDevice && mpReferenceDevice->isDisposed())
405 const_cast<Control*
>(
this)->SetReferenceDevice(
nullptr);
408 return mpReferenceDevice;
425 ApplyControlFont(rRenderContext, GetCanonicalFont(rStyleSettings));
427 ApplyControlForeground(rRenderContext, GetCanonicalTextColor(rStyleSettings));
433 ApplySettings(*GetOutDev());
437 DrawTextFlags _nStyle, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
const
439 OUString rPStr = _rStr;
444 if (autoacc && !mbShowAccelerator)
450 if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
453 _rTargetDevice.
DrawText(aRet, rPStr, nPStyle, _pVector, _pDisplayText);
458 return aRenderer.
DrawText(rRect, rPStr, nPStyle, _pVector, _pDisplayText, i_pDeviceSize);
464 OUString rPStr = _rStr;
469 if (autoacc && !mbShowAccelerator)
475 if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
480 *o_pDeviceSize = aRet.
GetSize();
486 return aRenderer.
GetTextRect(rRect, rPStr, nPStyle, o_pDeviceSize);
492 Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings()));
494 aFont.
Merge(GetControlFont());
521 aResultRectangle = *pRectangle;
524 aResultRectangle = PixelToLogic(aResultRectangle,
MapMode(MapUnit::MapTwip));
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 LogicInvalidate(const tools::Rectangle *pRectangle) override
Notify the LOK client about an invalidated area.
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.
virtual bool FocusWindowBelongsToControl(const vcl::Window *pFocusWin) const
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 notifyInvalidation(tools::Rectangle const *) const =0
Emits a LOK_CALLBACK_INVALIDATE_TILES.
virtual void StateChanged(StateChangedType nStateChange)
::OutputDevice const * GetOutDev() const
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
virtual void LogicInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.Used for the main document win...
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)