33#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
34#include <boost/property_tree/ptree.hpp>
86 css::uno::Reference< css::datatransfer::dnd::XDropTargetListener> xDrop =
new DNDEventDispatcher(
this);
90 sal_Int32 nLeft, nTop, nRight, nBottom;
91 GetBorder( nLeft, nTop, nRight, nBottom );
103 aBoundingRgn, aContentRgn ) )
105 sal_Int32 nHeight = aBoundingRgn.
GetHeight();
107 mnDDHeight =
static_cast<sal_uInt16
>(nHeight);
169 bool bPopup = IsInDropDown();
170 if( IsDropDownBox() )
172 if( !mpImplLB->IsTravelSelect() )
174 mpFloatWin->EndPopupMode();
175 mpImplWin->GrabFocus();
178 mpImplWin->SetItemPos( GetSelectedEntryPos() );
179 mpImplWin->SetString( GetSelectedEntry() );
180 if( mpImplLB->GetEntryList().HasImages() )
182 Image aImage = mpImplLB->GetEntryList().GetEntryImage( GetSelectedEntryPos() );
183 mpImplWin->SetImage( aImage );
185 mpImplWin->Invalidate();
188 if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || (
bPopup && !IsMultiSelectionEnabled() ) )
210 mpFloatWin->EndPopupMode();
215 if ( mpImplLB->IsTrackingSelect() )
224 mpImplWin->SetItemPos( nChanged );
225 mpImplWin->SetString( rEntryList.
GetEntryText( nChanged ) );
229 mpImplWin->SetImage( aImage );
235 mpImplWin->SetString( OUString() );
237 mpImplWin->SetImage( aImage );
239 mpImplWin->Invalidate();
249 if( mpFloatWin->IsInPopupMode() )
253 mpImplWin->GrabFocus();
254 mpBtn->SetPressed(
true );
255 mpFloatWin->StartFloat(
true );
258 ImplClearLayoutData();
260 mpImplLB->GetMainWindow()->ImplClearLayoutData();
262 mpImplWin->ImplClearLayoutData();
267 if( mpFloatWin->IsPopupModeCanceled() )
270 && !IsEntryPosSelected( mpFloatWin->GetPopupModeStartSaveSelection() ) )
272 mpImplLB->SelectEntry( mpFloatWin->GetPopupModeStartSaveSelection(),
true );
273 bool bTravelSelect = mpImplLB->IsTravelSelect();
274 mpImplLB->SetTravelSelect(
true );
281 mpImplLB->SetTravelSelect( bTravelSelect );
285 ImplClearLayoutData();
287 mpImplLB->GetMainWindow()->ImplClearLayoutData();
289 mpImplWin->ImplClearLayoutData();
291 mpBtn->SetPressed(
false );
335 if ( bBorder || bBackground )
391 ((nOffY+nTextHeight) > aSize.
Height()) ||
392 ((nOffX+nTextWidth) > aSize.
Width()) )
395 if ( nTextHeight > aSize.
Height() )
400 pDev->
DrawText( aTextRect, aText, nTextStyle );
405 sal_uInt16 nLines = ( nTextHeight > 0 ) ?
static_cast<sal_uInt16
>(aSize.
Height() / nTextHeight) : 1;
413 for ( sal_uInt16
n = 0;
n < nLines;
n++ )
421 Point( aPos.
X() + aSize.
Width(), aPos.
Y() + (
n+1)*nTextHeight + 2*nOnePixel ) ) );
426 aTextRect.
SetTop( aPos.
Y() +
n*nTextHeight );
578 aContent.
Move( -aPoint.
X(), -aPoint.
Y() );
589 aContent.
Move( -aPoint.
X(), -aPoint.
Y() );
682 if( aConvPoint.
X() >= 0 && aConvPoint.
Y() >= 0 && aConvPoint.
X() < aImplWinSize.
Width() && aConvPoint.
Y() < aImplWinSize.
Height() )
696 SAL_WARN_IF(
nIndex == -1,
"vcl",
"found index for point, but relative index failed" );
1015 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1042 if (nCurrentPos !=
nPos && bSelect)
1056 bool bCallListeners =
false;
1062 for (
auto nPos : rPositions)
1064 if (0 <=
nPos &&
nPos < nEntryCount)
1067 if (nCurrentPos !=
nPos && bSelect)
1068 bCallListeners =
true;
1104 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1180 bool bAddScrollWidth =
false;
1186 bAddScrollWidth =
true;
1191 if (bAddScrollWidth)
1197 Size aTestSize( 100, 20 );
1200 aControlValue, aBound, aContent) )
1217 aControlValue, aBound, aContent) )
1263 Size aSz = rPrefSize;
1264 sal_Int32 nLeft, nTop, nRight, nBottom;
1331 rnCols =
static_cast<sal_uInt16
>(aOutSz.
Width()/nCharWidth);
1337 rnCols =
static_cast<sal_uInt16
>(aOutSz.
Width()/nCharWidth);
1399 if (rKey ==
"active")
1401 else if (rKey ==
"max-width-chars")
1403 else if (rKey ==
"can-focus")
1430 auto entriesNode = rJsonWriter.
startArray(
"entries");
1440 auto entriesNode = rJsonWriter.
startArray(
"selectedEntries");
static bool toBool(std::string_view rValue)
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
CommandEventId GetCommand() const
std::optional< vcl::ControlLayoutData > mxLayoutData
tools::Long GetIndexForPoint(const Point &rPoint) const
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
void SetLayoutDataParent(const Control *pParent) const
virtual void StateChanged(StateChangedType nStateChange) override
virtual void Resize() override
virtual void EnableRTL(bool bEnable=true) override
bool HasLayoutData() const
determines whether we currently have layout data
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)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
bool IsInPopupMode() const
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const
void SetMBDownHdl(const Link< void *, void > &rLink)
bool HasEntryImage(sal_Int32 nPos) const
sal_Int32 GetSelectedEntryPos(sal_Int32 nIndex) const
Image GetEntryImage(sal_Int32 nPos) const
sal_Int32 GetSelectedEntryCount() const
sal_Int32 FindEntry(std::u16string_view rStr, bool bSearchMRUArea=false) const
OUString GetEntryText(sal_Int32 nPos) const
void * GetEntryData(sal_Int32 nPos) const
sal_Int32 GetEntryCount() const
sal_Int32 GetMRUCount() const
bool IsEntryPosSelected(sal_Int32 nIndex) const
sal_uInt16 GetDropDownLineCount() const
void SetDropDownLineCount(sal_uInt16 n)
void SetAutoWidth(bool b)
void SetImplListBox(ImplListBox *pLB)
const Size & GetPrefSize() const
Size CalcFloatSize() const
void SetPrefSize(const Size &rSz)
void StartFloat(bool bStartTracking)
void AllowGrabFocus(bool b)
sal_Int32 GetEntryPosForPoint(const Point &rPoint) const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
sal_uInt16 GetDisplayLineCount() const
ImplListBoxWindow * GetMainWindow()
tools::Long GetMaxEntryWidth() const
Size CalcSize(sal_Int32 nMaxLines) const
bool IsMultiSelectionEnabled() const
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator.
void SelectEntry(sal_Int32 nPos, bool bSelect)
void RemoveEntry(sal_Int32 nPos)
void SetDoubleClickHdl(const Link< ImplListBoxWindow *, void > &rLink)
void SetSelectHdl(const Link< LinkParamNone *, void > &rLink)
void SetHighlightColor(const Color &rColor)
void SetHighlightTextColor(const Color &rColor)
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
virtual const Wallpaper & GetDisplayBackground() const override
bool ProcessKeyInput(const KeyEvent &rKEvt)
void SetListItemSelectHdl(const Link< LinkParamNone *, void > &rLink)
virtual void Resize() override
sal_Int32 GetTopEntry() const
void SetTopEntry(sal_Int32 nTop)
const ImplEntryList & GetEntryList() const
bool IsTravelSelect() const
bool HandleWheelAsCursorTravel(const CommandEvent &rCEvt, Control &rControl)
void SetScrollHdl(const Link< ImplListBox *, void > &rLink)
void SetCancelHdl(const Link< LinkParamNone *, void > &rLink)
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
tools::Long GetEntryHeightWithMargin() const
void SetFocusHdl(const Link< sal_Int32, void > &rLink)
sal_Int32 InsertEntry(sal_Int32 nPos, const OUString &rStr)
void SetMultiSelectionSimpleMode(bool bSimple)
void EnableMultiSelection(bool bMulti)
void SetEdgeBlending(bool bNew)
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
void SetSelectionChangedHdl(const Link< sal_Int32, void > &rLnk)
void SetEntryData(sal_Int32 nPos, void *pNewData)
tools::Long GetEntryHeight() const
sal_Int32 GetCurrentPos() const
void SetImage(const Image &rImg)
sal_Int32 GetItemPos() const
void SetString(const OUString &rStr)
void SetEdgeBlending(bool bNew)
void SetMBDownHdl(const Link< void *, void > &rLink)
void SetItemPos(sal_Int32 n)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
const vcl::KeyCode & GetKeyCode() const
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
A widget used to choose from a list of items and which has no entry.
void EnableMultiSelection(bool bMulti)
Size CalcSubEditSize() const
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
sal_Int32 GetEntryPos(std::u16string_view rStr) const
void SetHighlightTextColor(const Color &rColor)
Size CalcAdjustedSize(const Size &rPrefSize) const
virtual ~ListBox() override
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
bool IsMultiSelectionEnabled() const
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
sal_Int32 GetTopEntry() const
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator.
sal_uInt16 GetDisplayLineCount() const
bool IsEntryPosSelected(sal_Int32 nPos) const
sal_Int32 GetSelectedEntryCount() const
ListBox(WindowType nType)
void EnableAutoSize(bool bAuto)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
VclPtr< ImplListBox > mpImplLB
bool IsInDropDown() const
sal_Int32 GetEntryCount() const
bool IsDropDownBox() const
virtual void LoseFocus() override
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Link< ListBox &, void > maSelectHdl
Size CalcBlockSize(sal_uInt16 nColumns, sal_uInt16 nLines) const
VclPtr< ImplListBoxFloatingWindow > mpFloatWin
virtual FactoryFunction GetUITestFactory() const override
virtual void GetFocus() override
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
sal_Int32 m_nMaxWidthChars
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
this methods stores a combination of flags from the ListBoxEntryFlags::* defines at the given entry.
virtual const Wallpaper & GetDisplayBackground() const override
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
void SetReadOnly(bool bReadOnly=true)
sal_uInt16 GetDropDownLineCount() const
void setMaxWidthChars(sal_Int32 nWidth)
tools::Long GetIndexForPoint(const Point &rPoint, sal_Int32 &rPos) const
OUString GetEntry(sal_Int32 nPos) const
void RemoveEntry(sal_Int32 nPos)
VclPtr< ImplWin > mpImplWin
void SetHighlightColor(const Color &rColor)
void AdaptDropDownLineCountToMaximum()
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
Image GetEntryImage(sal_Int32 nPos) const
Size CalcMinimumSize() const
virtual void Resize() override
void SetDropDownLineCount(sal_uInt16 nLines)
virtual Size GetOptimalSize() const override
bool IsAutoSizeEnabled() const
bool IsTravelSelect() const
SAL_DLLPRIVATE void ImplInitListBoxData()
void SetEntryData(sal_Int32 nPos, void *pNewData)
void SelectEntriesPos(const std::vector< sal_Int32 > &rPositions, bool bSelect=true)
void * GetEntryData(sal_Int32 nPos) const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
virtual void StateChanged(StateChangedType nType) override
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
void SelectEntry(std::u16string_view rStr, bool bSelect=true)
void SetTopEntry(sal_Int32 nPos)
virtual void FillLayoutData() const override
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
tools::Rectangle GetDropDownPosSizePixel() const
virtual bool PreNotify(NotifyEvent &rNEvt) override
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
bool IsEnterWindow() const
bool IsLeaveWindow() const
const KeyEvent * GetKeyEvent() const
vcl::Window * GetWindow() const
const CommandEvent * GetCommandEvent() const
const MouseEvent * GetMouseEvent() const
NotifyEventType GetType() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
virtual void SetSettings(const AllSettings &rSettings)
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
void SetTextColor(const Color &rColor)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
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 IntersectClipRegion(const tools::Rectangle &rRect)
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
void SetHighlightTextColor(const Color &rColor)
void SetHighlightColor(const Color &rColor)
const Color & GetDisableColor() const
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
sal_uInt16 GetCode() const
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Point OutputToScreenPixel(const Point &rPos) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
void SetStyle(WinBits nStyle)
void SetFont(const vcl::Font &rNewFont)
void SetUpdateMode(bool bUpdate)
bool IsNativeWidgetEnabled() const
bool IsReallyVisible() const
void SetControlForeground()
bool HasChildPathFocus(bool bSystemWindow=false) const
Point LogicToPixel(const Point &rLogicPt) const
virtual void SetSizePixel(const Size &rNewSize)
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
tools::Long CalcZoom(tools::Long n) const
vcl::Window * GetWindow(GetWindowType nType) const
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
const Color & GetControlForeground() const
void SetControlBackground()
bool IsUpdateMode() const
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
void Enable(bool bEnable=true, bool bChild=true)
const Fraction & GetZoom() const
const AllSettings & GetSettings() const
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Size CalcWindowSize(const Size &rOutSz) const
virtual bool PreNotify(NotifyEvent &rNEvt)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
vcl::Font GetControlFont() const
::OutputDevice const * GetOutDev() const
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
const vcl::Font & GetFont() const
SAL_DLLPRIVATE float approximate_char_width() const
void RequestDoubleBuffering(bool bRequest)
Enable/disable double-buffering of the frame window and all its children.
void SetSettings(const AllSettings &rSettings)
void SetZoom(const Fraction &rZoom)
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
const Color & GetTextColor() const
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
bool IsRTLEnabled() const
Point PixelToLogic(const Point &rDevicePt) const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
bool IsControlBackground() const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
const Color & GetControlBackground() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
virtual void SetPosPixel(const Point &rNewPos)
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
virtual bool set_property(const OUString &rKey, const OUString &rValue)
Point ScreenToOutputPixel(const Point &rPos) const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
void SetCompoundControl(bool bCompound)
void SetTextColor(const Color &rColor)
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
void ImplInitDropDownButton(PushButton *pButton)
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_DOWN
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(ListBox, ImplSelectHdl, LinkParamNone *, void)
IMPL_LINK(ListBox, ImplFocusHdl, sal_Int32, nPos, void)
#define SAL_WARN_IF(condition, area, stream)
#define LISTBOX_ENTRY_NOTFOUND
ImplSVData * ImplGetSVData()
@ NoErase
The invalidated area is painted with the background color/pattern.
WinBits const WB_DROPDOWN
WinBits const WB_NOTABSTOP
WinBits const WB_SIMPLEMODE
WinBits const WB_NOLIGHTBORDER
WinBits const WB_NOBORDER
WinBits const WB_RECTSTYLE