34 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
35 #include <boost/property_tree/ptree.hpp>
87 css::uno::Reference< css::datatransfer::dnd::XDropTargetListener> xDrop =
new DNDEventDispatcher(
this);
89 if( nStyle & WB_DROPDOWN )
91 sal_Int32 nLeft, nTop, nRight, nBottom;
92 GetBorder( nLeft, nTop, nRight, nBottom );
104 aBoundingRgn, aContentRgn ) )
106 sal_Int32 nHeight = aBoundingRgn.
GetHeight();
108 mnDDHeight =
static_cast<sal_uInt16
>(nHeight);
170 bool bPopup = IsInDropDown();
171 if( IsDropDownBox() )
173 if( !mpImplLB->IsTravelSelect() )
175 mpFloatWin->EndPopupMode();
176 mpImplWin->GrabFocus();
179 mpImplWin->SetItemPos( GetSelectedEntryPos() );
180 mpImplWin->SetString( GetSelectedEntry() );
181 if( mpImplLB->GetEntryList()->HasImages() )
183 Image aImage = mpImplLB->GetEntryList()->GetEntryImage( GetSelectedEntryPos() );
184 mpImplWin->SetImage( aImage );
186 mpImplWin->Invalidate();
189 if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || ( bPopup && !IsMultiSelectionEnabled() ) )
211 mpFloatWin->EndPopupMode();
216 if ( mpImplLB->IsTrackingSelect() )
223 if ( nChanged < pEntryList->GetMRUCount() )
225 mpImplWin->SetItemPos( nChanged );
226 mpImplWin->SetString( mpImplLB->GetEntryList()->GetEntryText( nChanged ) );
227 if( mpImplLB->GetEntryList()->HasImages() )
229 Image aImage = mpImplLB->GetEntryList()->GetEntryImage( nChanged );
230 mpImplWin->SetImage( aImage );
236 mpImplWin->SetString( OUString() );
238 mpImplWin->SetImage( aImage );
240 mpImplWin->Invalidate();
250 if( mpFloatWin->IsInPopupMode() )
254 mpImplWin->GrabFocus();
255 mpBtn->SetPressed(
true );
256 mpFloatWin->StartFloat(
true );
259 ImplClearLayoutData();
261 mpImplLB->GetMainWindow()->ImplClearLayoutData();
263 mpImplWin->ImplClearLayoutData();
268 if( mpFloatWin->IsPopupModeCanceled() )
271 && !IsEntryPosSelected( mpFloatWin->GetPopupModeStartSaveSelection() ) )
273 mpImplLB->SelectEntry( mpFloatWin->GetPopupModeStartSaveSelection(), true );
274 bool bTravelSelect = mpImplLB->IsTravelSelect();
275 mpImplLB->SetTravelSelect(
true );
282 mpImplLB->SetTravelSelect( bTravelSelect );
286 ImplClearLayoutData();
288 mpImplLB->GetMainWindow()->ImplClearLayoutData();
290 mpImplWin->ImplClearLayoutData();
292 mpBtn->SetPressed(
false );
336 if ( bBorder || bBackground )
392 ((nOffY+nTextHeight) > aSize.
Height()) ||
393 ((nOffX+nTextWidth) > aSize.
Width()) )
396 if ( nTextHeight > aSize.
Height() )
401 pDev->
DrawText( aTextRect, aText, nTextStyle );
406 sal_uInt16 nLines = ( nTextHeight > 0 ) ? static_cast<sal_uInt16>(aSize.
Height() / nTextHeight) : 1;
414 for ( sal_uInt16
n = 0;
n < nLines;
n++ )
422 Point( aPos.X() + aSize.
Width(), aPos.Y() + (
n+1)*nTextHeight + 2*nOnePixel ) ) );
427 aTextRect.
SetTop( aPos.Y() +
n*nTextHeight );
579 aContent.
Move( -aPoint.X(), -aPoint.Y() );
590 aContent.
Move( -aPoint.X(), -aPoint.Y() );
683 if( aConvPoint.X() >= 0 && aConvPoint.Y() >= 0 && aConvPoint.X() < aImplWinSize.
Width() && aConvPoint.Y() < aImplWinSize.
Height() )
697 SAL_WARN_IF( nIndex == -1,
"vcl",
"found index for point, but relative index failed" );
1010 if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() )
1032 if ( 0 <= nPos && nPos < mpImplLB->GetEntryList()->
GetEntryCount() )
1037 if (nCurrentPos != nPos && bSelect)
1051 bool bCallListeners =
false;
1057 for (
auto nPos : rPositions)
1059 if (0 <=
nPos &&
nPos < nEntryCount)
1062 if (nCurrentPos !=
nPos && bSelect)
1063 bCallListeners =
true;
1099 if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() )
1153 bool bAddScrollWidth =
false;
1159 bAddScrollWidth =
true;
1164 if (bAddScrollWidth)
1170 Size aTestSize( 100, 20 );
1173 aControlValue, aBound, aContent) )
1190 aControlValue, aBound, aContent) )
1236 Size aSz = rPrefSize;
1237 sal_Int32 nLeft, nTop, nRight, nBottom;
1304 rnCols =
static_cast<sal_uInt16
>(aOutSz.
Width()/nCharWidth);
1310 rnCols =
static_cast<sal_uInt16
>(aOutSz.
Width()/nCharWidth);
1372 if (rKey ==
"active")
1374 else if (rKey ==
"max-width-chars")
1376 else if (rKey ==
"can-focus")
1403 auto entriesNode = rJsonWriter.
startArray(
"entries");
1413 auto entriesNode = rJsonWriter.
startArray(
"selectedEntries");
static bool toBool(std::string_view rValue)
sal_Int32 m_nMaxWidthChars
#define LINK(Instance, Class, Member)
const Color & GetTextColor() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
bool IsControlBackground() const
virtual void EnableRTL(bool bEnable=true) override
bool IsInPopupMode() const
virtual Size GetOptimalSize() const override
SAL_DLLPRIVATE float approximate_char_width() const
Image GetEntryImage(sal_Int32 nPos) const
bool IsDropDownBox() const
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
void SetSelectHdl(const Link< LinkParamNone *, void > &rLink)
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const
void RemoveEntry(sal_Int32 nPos)
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
void SetMBDownHdl(const Link< void *, void > &rLink)
bool HasEntryImage(sal_Int32 nPos) const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
const ImplEntryList * GetEntryList() const
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
void setWidth(tools::Long nWidth)
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)
sal_Int32 GetSelectedEntryPos(sal_Int32 nIndex) const
const CommandEvent * GetCommandEvent() const
bool IsTravelSelect() const
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
A widget used to choose from a list of items and which has no entry.
IMPL_LINK_NOARG(ListBox, ImplSelectHdl, LinkParamNone *, void)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
void AllowGrabFocus(bool b)
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
const StyleSettings & GetStyleSettings() const
bool IsMultiSelectionEnabled() const
const Size & GetPrefSize() const
virtual void StateChanged(StateChangedType nStateChange) override
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
sal_Int32 GetTopEntry() const
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
sal_Int32 GetEntryPosForPoint(const Point &rPoint) const
void CompatStateChanged(StateChangedType nStateChange)
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual FactoryFunction GetUITestFactory() const override
sal_uInt16 GetCode() const
sal_Int32 FindEntry(std::u16string_view rStr, bool bSearchMRUArea=false) const
sal_Int32 GetSelectedEntryCount() const
DataChangedEventType GetType() const
const KeyEvent * GetKeyEvent() const
void IntersectClipRegion(const tools::Rectangle &rRect)
void AppendLayoutData(const Control &rSubControl) const
void SetDropDownLineCount(sal_uInt16 nLines)
virtual void SetSettings(const AllSettings &rSettings) override
const Color & GetControlBackground() const
VclPtr< ImplListBox > mpImplLB
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator. ...
void SetDropDownLineCount(sal_uInt16 n)
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
bool HasChildPathFocus(bool bSystemWindow=false) const
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
constexpr sal_uInt16 KEY_UP
#define LISTBOX_ENTRY_NOTFOUND
The invalidated area is painted with the background color/pattern.
const Fraction & GetZoom() const
void * GetEntryData(sal_Int32 nPos) const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
tools::Long GetMaxEntryWidth() const
vcl::Window * GetWindow() const
sal_Int32 GetCurrentPos() const
void Enable(bool bEnable=true, bool bChild=true)
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
void EnableAutoSize(bool bAuto)
sal_Int32 GetEntryCount() const
Size CalcAdjustedSize(const Size &rPrefSize) const
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
const vcl::Font & GetFont() const
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
void SetEntryData(sal_Int32 nPos, void *pNewData)
AllSettingsFlags GetFlags() const
virtual const Wallpaper & GetDisplayBackground() const override
void EnableMultiSelection(bool bMulti)
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
void * GetEntryData(sal_Int32 nPos) const
void SetCompoundControl(bool bCompound)
OUString GetEntry(sal_Int32 nPos) const
void SetDoubleClickHdl(const Link< ImplListBoxWindow *, void > &rLink)
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
Image GetEntryImage(sal_Int32 nPos) const
ImplListBoxWindow * GetMainWindow()
void DrawRect(const tools::Rectangle &rRect)
const Color & GetControlForeground() const
void SetMultiSelectionSimpleMode(bool bSimple)
void SelectEntry(std::u16string_view rStr, bool bSelect=true)
void SetTopEntry(sal_Int32 nTop)
constexpr sal_uInt16 KEY_DOWN
void RemoveEntry(sal_Int32 nPos)
WinBits const WB_NOLIGHTBORDER
sal_Int32 GetMRUCount() const
sal_uInt16 GetDisplayLineCount() const
ImplSVData * ImplGetSVData()
Size CalcWindowSize(const Size &rOutSz) const
bool IsAutoSizeEnabled() const
void SetScrollHdl(const Link< ImplListBox *, void > &rLink)
const Color & GetDisableColor() const
bool IsRTLEnabled() const
virtual bool PreNotify(NotifyEvent &rNEvt)
virtual bool set_property(const OString &rKey, const OUString &rValue) override
virtual void Resize() override
void setMaxWidthChars(sal_Int32 nWidth)
bool IsEntryPosSelected(sal_Int32 nIndex) const
tools::Long GetEntryHeight() const
bool IsNativeWidgetEnabled() const
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
void SetControlBackground()
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
WinBits const WB_SIMPLEMODE
void SetReadOnly(bool bReadOnly=true)
sal_uInt16 GetDropDownLineCount() const
void SetImage(const Image &rImg)
void SelectEntriesPos(const std::vector< sal_Int32 > &rPositions, bool bSelect=true)
void SetControlForeground()
tools::Rectangle GetDropDownPosSizePixel() const
bool IsTravelSelect() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
void SetUpdateMode(bool bUpdate)
sal_uInt16 GetDropDownLineCount() const
virtual ~ListBox() override
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
bool IsUpdateMode() const
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
CommandEventId GetCommand() const
sal_Int32 GetSelectedEntryCount() const
void SetZoom(const Fraction &rZoom)
void SetTextColor(const Color &rColor)
void SetItemPos(sal_Int32 n)
WinBits const WB_RECTSTYLE
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
bool IsEntryPosSelected(sal_Int32 nPos) const
MouseNotifyEvent GetType() const
sal_Int32 GetEntryPos(std::u16string_view rStr) const
void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const
sal_uInt16 GetDisplayLineCount() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
WinBits const WB_DROPDOWN
virtual void Resize() override
const AllSettings & GetSettings() const
Size GetOutputSizePixel() const
tools::Long GetScrollBarSize() const
bool HandleWheelAsCursorTravel(const CommandEvent &rCEvt, Control &rControl)
virtual bool set_property(const OString &rKey, const OUString &rValue)
void RequestDoubleBuffering(bool bRequest)
Enable/disable double-buffering of the frame window and all its children.
Point ScreenToOutputPixel(const Point &rPos) const
Size CalcSubEditSize() const
virtual const Wallpaper & GetDisplayBackground() const override
SAL_DLLPRIVATE void ImplInitListBoxData()
void SetStyle(WinBits nStyle)
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
this methods stores a combination of flags from the ListBoxEntryFlags::* defines at the given entry...
Size CalcSize(sal_Int32 nMaxLines) const
constexpr sal_uInt16 KEY_RETURN
WinBits const WB_NOBORDER
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Size CalcMinimumSize() const
virtual bool PreNotify(NotifyEvent &rNEvt) override
vcl::Window * GetWindow(GetWindowType nType) const
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
tools::Long GetIndexForPoint(const Point &rPoint, sal_Int32 &rPos) const
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
virtual void GetFocus() override
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
const vcl::KeyCode & GetKeyCode() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Size CalcBlockSize(sal_uInt16 nColumns, sal_uInt16 nLines) const
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
void EnableMultiSelection(bool bMulti)
virtual void Resize() override
tools::Long GetIndexForPoint(const Point &rPoint) const
void SetPrefSize(const Size &rSz)
bool ProcessKeyInput(const KeyEvent &rKEvt)
VclPtr< ImplListBoxFloatingWindow > mpFloatWin
#define SAL_WARN_IF(condition, area, stream)
void SetFont(const vcl::Font &rNewFont)
std::unique_ptr< vcl::ImplControlData > mpControlData
sal_Int32 GetTopEntry() const
tools::Long GetEntryHeightWithMargin() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
void SetAutoWidth(bool b)
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator. ...
virtual void FillLayoutData() const override
void SetEdgeBlending(bool bNew)
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
void SetSelectionChangedHdl(const Link< sal_Int32, void > &rLnk)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
tools::Long Height() const
tools::Long CalcZoom(tools::Long n) const
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
void SetCancelHdl(const Link< LinkParamNone *, void > &rLink)
tools::Long AdjustHeight(tools::Long n)
VclPtr< ImplWin > mpImplWin
bool IsMultiSelectionEnabled() const
void setHeight(tools::Long nHeight)
sal_Int32 InsertEntry(sal_Int32 nPos, const OUString &rStr)
void AdaptDropDownLineCountToMaximum()
void SetFocusHdl(const Link< sal_Int32, void > &rLink)
virtual void LoseFocus() override
void SelectEntry(sal_Int32 nPos, bool bSelect)
OUString GetEntryText(sal_Int32 nPos) const
Point OutputToScreenPixel(const Point &rPos) const
void StartFloat(bool bStartTracking)
void ImplInitDropDownButton(PushButton *pButton)
void SetTopEntry(sal_Int32 nPos)
void SetString(const OUString &rStr)
void SetEntryData(sal_Int32 nPos, void *pNewData)
bool IsReallyVisible() const
vcl::Font GetControlFont() const
sal_Int32 GetItemPos() const
void SetImplListBox(ImplListBox *pLB)
Link< ListBox &, void > maSelectHdl
bool IsInDropDown() const
void Push(PushFlags nFlags=PushFlags::ALL)
void SetEdgeBlending(bool bNew)
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
WinBits const WB_NOTABSTOP
virtual void SetPosPixel(const Point &rNewPos)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
sal_Int32 GetEntryCount() const
virtual void StateChanged(StateChangedType nType) override
bool HasLayoutData() const
determines whether we currently have layout data
void SetMBDownHdl(const Link< void *, void > &rLink)
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
ListBox(WindowType nType)
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
void SetLayoutDataParent(const Control *pParent) const
void SetListItemSelectHdl(const Link< LinkParamNone *, void > &rLink)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
IMPL_LINK(ListBox, ImplFocusHdl, sal_Int32, nPos, void)