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;
146 Pair aPair( -1, -1 );
149 if( nLine >= 0 && nLine < nDisplayLines )
152 if( nLine+1 < nDisplayLines )
157 else if( nLine == 0 && nDisplayLines == 0 && !
m_aDisplayText.isEmpty() )
169 if( !HasLayoutData() )
171 return mxLayoutData ? mxLayoutData->GetLineStartEnd( nLine ) :
Pair( -1, -1 );
182 if( nDisplayLines > 1 )
185 for( nLine = nDisplayLines-1; nLine >= 0; nLine-- )
195 SAL_WARN_IF( nLine < 0,
"vcl",
"ToRelativeLineIndex failed" );
208 if( !HasLayoutData() )
210 return mxLayoutData ? mxLayoutData->ToRelativeLineIndex(
nIndex ) : -1;
215 if( !HasLayoutData() )
217 return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText();
222 return ImplIsWindowOrChild(pFocusWin);
229 if ( !mbHasControlFocus )
231 mbHasControlFocus =
true;
243 if ( !pFocusWin || !FocusWindowBelongsToControl(pFocusWin) )
245 mbHasControlFocus =
false;
264 ImplClearLayoutData();
276 tools::Long nCurrentIndex = mxLayoutData->m_aDisplayText.getLength();
277 mxLayoutData->m_aDisplayText += rSubControl.
mxLayoutData->m_aDisplayText;
278 int nLines = rSubControl.
mxLayoutData->m_aLineIndices.size();
280 mxLayoutData->m_aLineIndices.push_back( nCurrentIndex );
281 for(
n = 1;
n < nLines;
n++ )
282 mxLayoutData->m_aLineIndices.push_back( rSubControl.
mxLayoutData->m_aLineIndices[
n] + nCurrentIndex );
283 int nRectangles = rSubControl.
mxLayoutData->m_aUnicodeBoundRects.size();
285 for(
n = 0;
n < nRectangles;
n++ )
289 mxLayoutData->m_aUnicodeBoundRects.push_back( aRect );
322 if( HasLayoutData() )
323 mxLayoutData->m_pParent = pParent;
328 mxLayoutData.reset();
345 aStyle.
SetMonoColor( GetSettings().GetStyleSettings().GetMonoColor() );
350 pDev->OutputDevice::SetSettings( aNewSettings );
355 pDev->OutputDevice::SetSettings( aOriginalSettings );
360 mbShowAccelerator = bVal;
371 return Size( GetTextWidth( GetText() ) + 2 * 12,
372 GetTextHeight() + 2 * 6 );
377 if ( mpReferenceDevice == _referenceDevice )
380 mpReferenceDevice = _referenceDevice;
395 if(
nullptr != mpReferenceDevice && mpReferenceDevice->isDisposed())
397 const_cast<Control*
>(
this)->SetReferenceDevice(
nullptr);
400 return mpReferenceDevice;
417 ApplyControlFont(rRenderContext, GetCanonicalFont(rStyleSettings));
419 ApplyControlForeground(rRenderContext, GetCanonicalTextColor(rStyleSettings));
425 ApplySettings(*GetOutDev());
429 DrawTextFlags _nStyle, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
const
431 OUString rPStr = _rStr;
436 if (autoacc && !mbShowAccelerator)
439 if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
442 _rTargetDevice.
DrawText(aRet, rPStr, nPStyle, _pVector, _pDisplayText);
447 return aRenderer.
DrawText(rRect, rPStr, nPStyle, _pVector, _pDisplayText, i_pDeviceSize);
453 OUString rPStr = _rStr;
458 if (autoacc && !mbShowAccelerator)
461 if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
466 *o_pDeviceSize = aRet.
GetSize();
472 return aRenderer.
GetTextRect(rRect, rPStr, nPStyle, o_pDeviceSize);
478 Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings()));
480 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 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...
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
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
constexpr tools::Long Y() const
constexpr tools::Long X() 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...
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
virtual bool EventNotify(NotifyEvent &rNEvt)
tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const
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
ImplSVData * ImplGetSVData()
OUString removeMnemonicFromString(OUString const &rStr)