29 #include <textlayout.hxx>
36 mbHasControlFocus =
false;
37 mbShowAccelerator =
false;
50 ImplInit( pParent, nStyle,
nullptr );
71 Window::EnableRTL(bEnable);
86 SAL_WARN_IF(
mxLayoutData,
"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 mxLayoutData ? mxLayoutData->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 mxLayoutData ? mxLayoutData->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 mxLayoutData ? mxLayoutData->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 mxLayoutData ? mxLayoutData->ToRelativeLineIndex( nIndex ) : -1;
220 if( !HasLayoutData() )
222 return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText();
229 if ( !mbHasControlFocus )
231 mbHasControlFocus =
true;
243 if ( !pFocusWin || !ImplIsWindowOrChild( 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() );
347 aNewSettings.SetStyleSettings( aStyle );
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)
438 rPStr = GetNonMnemonicString( _rStr );
442 if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
445 _rTargetDevice.
DrawText(aRet, rPStr, nPStyle, _pVector, _pDisplayText);
450 return aRenderer.
DrawText(rRect, rPStr, nPStyle, _pVector, _pDisplayText, i_pDeviceSize);
456 OUString rPStr = _rStr;
461 if (autoacc && !mbShowAccelerator)
463 rPStr = GetNonMnemonicString( _rStr );
467 if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) )
472 *o_pDeviceSize = aRet.
GetSize();
478 return aRenderer.
GetTextRect(rRect, rPStr, nPStyle, o_pDeviceSize);
484 Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings()));
486 aFont.
Merge(GetControlFont());
virtual OUString GetDisplayText() const override
void CreateLayoutData() const
creates the mpData->mpLayoutData structure
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
void LogicMouseMove(const MouseEvent &rMouseEvent) override
Same as MouseMove(), but coordinates are in logic unit. used for LOK.
SAL_DLLPRIVATE void ImplInitControlData()
Pair GetLineStartEnd(tools::Long nLine) const
std::vector< tools::Long > m_aLineIndices
std::optional< vcl::ControlLayoutData > mxLayoutData
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
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
const Color & GetLabelTextColor() const
void AppendLayoutData(const Control &rSubControl) 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 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
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
virtual ~Control() override
void SetOptions(StyleSettingsOptions nOptions)
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
void LogicMouseButtonUp(const MouseEvent &rMouseEvent) override
Same as MouseButtonUp(), but coordinates are in logic unit. used for LOK.
VclPtr< OutputDevice > mpReferenceDevice
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...
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
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
tools::Rectangle DrawText(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize)
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)
void LogicMouseButtonDown(const MouseEvent &rMouseEvent) override
Same as MouseButtonDown(), but coordinates are in logic unit. used for LOK.
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const
::OutputDevice const * GetOutDev() const
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
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)
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