21 #include <rtl/ustrbuf.hxx>
33 #include <com/sun/star/accessibility/XAccessible.hpp>
48 #define HEAD_ARROWSIZE1 4
49 #define HEAD_ARROWSIZE2 7
51 #define HEADERBAR_TEXTOFF 2
52 #define HEADERBAR_ARROWOFF 5
53 #define HEADERBAR_SPLITOFF 3
55 #define HEADERBAR_DRAGOUTOFF 15
57 #define HEAD_HITTEST_ITEM (sal_uInt16(0x0001))
58 #define HEAD_HITTEST_DIVIDER (sal_uInt16(0x0002))
104 SetType(WindowType::HEADERBAR);
135 if (bForeground || bFont)
148 for (
size_t i = 0;
i < nPos;
i++ )
158 if ( aRect.
Right() > 16000 )
167 bool bLastFixed =
true;
170 for (
size_t i = 0;
i < nCount;
i++ )
174 if ( rPos.X() < (nX+pItem->mnSize) )
182 nMouseOff = rPos.X()-nX+1;
191 nMouseOff = rPos.X()-(nX+pItem->mnSize);
196 nMouseOff = rPos.X()-nX;
214 nMouseOff = rPos.X()-nX+1;
227 Point aEndPos = aStartPos;
229 aStartPos.X()+2, aStartPos.Y()+2 );
231 if ( nEndPos > nStartPos )
233 aStartPos.AdjustX(3 );
234 aEndPos.setX( aRect2.
Right()-6 );
238 aStartPos.AdjustX( -3 );
239 aEndPos.setX( aRect2.
Left()+6 );
245 if ( nEndPos > nStartPos )
248 Point( aEndPos.X()+1, aEndPos.Y()+3 ) );
250 Point( aEndPos.X()+2, aEndPos.Y()+2 ) );
252 Point( aEndPos.X()+3, aEndPos.Y()+1 ) );
258 Point( aEndPos.X()-1, aEndPos.Y()+3 ) );
260 Point( aEndPos.X()-2, aEndPos.Y()+2 ) );
262 Point( aEndPos.X()-3, aEndPos.Y()+1 ) );
291 if (aRect.
Right() < 0)
305 aCtrlRegion, nState, aControlValue, OUString());
331 aCtrlRegion, nState, aControlValue, OUString());
352 pItem->maOutText = pItem->maText;
353 Size aImageSize = pItem->maImage.GetSizePixel();
355 if (!pItem->maOutText.isEmpty())
364 nTestHeight += aTxtSize.Height();
372 bool bLeftText =
false;
375 nMaxTxtWidth -= aImageSize.
Width();
377 if (nTxtWidth > nMaxTxtWidth)
380 OUStringBuffer
aBuf(pItem->maOutText);
384 aBuf.remove(aBuf.getLength() - 3 - 1, 1);
385 nTxtWidth = rRenderContext.
GetTextWidth(aBuf.toString());
387 while ((nTxtWidth > nMaxTxtWidth) && (aBuf.getLength() > 3));
388 pItem->maOutText = aBuf.makeStringAndClear();
389 if (pItem->maOutText.getLength() == 3)
392 pItem->maOutText.clear();
402 nTxtPos -= aImageSize.
Width();
408 nTempWidth += aImageSize.
Width();
409 nTxtPos = aRect.
Left() + (aRect.
GetWidth() - nTempWidth) / 2;
411 nTxtPos += aImageSize.
Width();
414 if (nTxtPos + nTxtWidth + nArrowWidth >= aRect.
Right())
417 if (nBits & HeaderBarItemBits::LEFTIMAGE)
418 nTxtPos += aImageSize.
Width();
426 nTxtPos += aImageSize.
Width();
427 if (nBits & HeaderBarItemBits::RIGHT)
428 nTxtPos += nArrowWidth;
433 if (!pItem->maOutText.isEmpty() || (nArrowWidth && aTxtSize.Height()))
436 nTempHeight += aImageSize.
Height();
437 nTxtPosY = aRect.
Top()+((aRect.
GetHeight()-nTempHeight)/2);
439 nTxtPosY += aImageSize.
Height();
443 if (!pItem->maOutText.isEmpty())
451 rRenderContext.
DrawText(
Point(nTxtPos, nTxtPosY), pItem->maOutText);
455 rRenderContext.
Pop();
465 nImagePos -= aImageSize.
Width();
466 if (nBits & HeaderBarItemBits::RIGHT)
467 nImagePos -= nArrowWidth;
471 nImagePos += nTxtWidth;
472 if (!(nBits & HeaderBarItemBits::RIGHT))
473 nImagePos += nArrowWidth;
477 if (nBits & HeaderBarItemBits::RIGHT )
479 else if (nBits & HeaderBarItemBits::CENTER)
486 if (!(nBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)))
487 nTempHeight += aTxtSize.Height();
488 nImagePosY = aRect.
Top() + ((aRect.
GetHeight() - nTempHeight) / 2);
490 if (nImagePos + aImageSize.
Width() <= aRect.
Right())
495 rRenderContext.
DrawImage(
Point(nImagePos, nImagePosY), pItem->maImage, nStyle);
503 if (nBits & HeaderBarItemBits::RIGHT)
504 nArrowX -= nArrowWidth;
509 if (nBits & HeaderBarItemBits::RIGHT)
510 nArrowX -= aImageSize.
Width();
512 nArrowX += aImageSize.
Width();
534 nState, aControlValue, OUString());
539 if (aTxtSize.Height())
540 nArrowY = nTxtPosY + (aTxtSize.Height() / 2);
541 else if (aImageSize.
Width() && aImageSize.
Height())
542 nArrowY = nImagePosY + (aImageSize.
Height() / 2);
575 ImplDrawItem(rRenderContext, nPos, bHigh, aRect, pRect );
585 if (nPos < nItemCount)
671 bNewOutDrag = !aItemRect.
Contains( rMousePos );
676 if ( (rMousePos.Y() >= aItemRect.
Top()) && (rMousePos.Y() <= aItemRect.
Bottom()) )
697 if ( rMousePos.X() <= 0 )
705 (nOldItemDragPos != nPos) &&
786 pItem->mnSize += nDelta;
867 sal_uInt16 nCurItemPos;
872 sal_uInt16 nItemCount =
static_cast<sal_uInt16
>(
mvItemList.size());
873 for (sal_uInt16
i = 0;
i < nItemCount;
i++)
915 for (
size_t i = 0;
i < nItemCount;
i++ )
920 if ( aItemRect.
Right() > 16000 )
948 Window::Command( rCEvt );
961 aItemRect.
SetTop( aPt.Y() );
972 if ( pItem->maOutText != pItem->maText )
973 aStr = pItem->maText;
974 else if (!pItem->maText.isEmpty())
989 Window::RequestHelp( rHEvt );
994 Window::StateChanged( nType );
1018 Window::DataChanged( rDCEvt );
1047 DBG_ASSERT( nItemId,
"HeaderBar::InsertItem(): ItemId == 0" );
1049 "HeaderBar::InsertItem(): ItemId already exists" );
1053 pItem->mnId = nItemId;
1054 pItem->mnBits = nBits;
1055 pItem->mnSize = nSize;
1056 pItem->maText = rText;
1088 if ( nPos == nNewPos )
1093 std::unique_ptr<ImplHeadItem> pItem = std::move(*it);
1095 if ( nNewPos < nPos )
1124 Scroll( nDelta, 0, aRect );
1129 return static_cast<sal_uInt16
>(
mvItemList.size());
1136 if ( pItem->mnId == nItemId )
1137 return static_cast<sal_uInt16
>(
i);
1176 if ( pItem->mnSize != nNewSize )
1178 pItem->mnSize = nNewSize;
1199 if ( pItem->mnBits != nNewBits )
1201 pItem->mnBits = nNewBits;
1240 if ( pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty() )
1244 pItem->maHelpText = pHelp->
GetHelpText( OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ),
this );
1247 return pItem->maHelpText;
1261 tools::Long nImageHeight = pItem->maImage.GetSizePixel().Height();
1263 nImageHeight += aSize.
Height();
1264 if ( nImageHeight > nMaxImageSize )
1265 nMaxImageSize = nImageHeight;
1271 if ( nMaxImageSize > aSize.
Height() )
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
const Color & GetShadowColor() const
const Wallpaper & GetBackground() const
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setWidth(tools::Long nWidth)
#define HEAD_HITTEST_DIVIDER
static Help * GetHelp()
Gets the application's help.
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const StyleSettings & GetStyleSettings() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
const Color & GetFaceColor() const
const OUString & GetHelpText() const
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
void setTristateVal(ButtonValue nTristate)
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
DataChangedEventType GetType() const
void SetType(WindowType nType)
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
HelpEventMode GetMode() const
void DrawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWallpaper)
constexpr tools::Long Width() const
sal_uInt16 GetClicks() const
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
bool IsMouseEvent() const
AllSettingsFlags GetFlags() const
const Color & GetLightColor() const
#define HEADERBAR_TEXTOFF
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void DrawRect(const tools::Rectangle &rRect)
const Point & GetMousePosPixel() const
const Color & GetDarkShadowColor() const
#define DBG_ASSERT(sCon, aError)
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.
const vcl::Font & GetToolFont() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
bool IsUpdateMode() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
const AllSettings & GetSettings() const
#define HEADERBAR_ARROWOFF
CommandEventId GetCommand() const
void SetTextColor(const Color &rColor)
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
const AllSettings & GetSettings() const
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Point ScreenToOutputPixel(const Point &rPos) const
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
void DrawPixel(const Point &rPt)
bool IsTrackingEnded() const
const Point & GetMousePosPixel() const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void SetPointer(PointerStyle)
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
const Color & GetButtonTextColor() const
constexpr tools::Long Height() const
void SetFont(const vcl::Font &rNewFont)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
::OutputDevice const * GetOutDev() const
void SetRasterOp(RasterOp eRasterOp)
tools::Long AdjustWidth(tools::Long n)
const Color & GetTextColor() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Point & GetPosPixel() const
#define HEAD_HITTEST_ITEM
tools::Long AdjustHeight(tools::Long n)
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
void setNumericVal(tools::Long nNumeric)
Size GetOutputSizePixel() const
void setHeight(tools::Long nHeight)
bool IsTrackingCanceled() const
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Point OutputToScreenPixel(const Point &rPos) const
#define HEADERBAR_SPLITOFF
const MouseEvent & GetMouseEvent() const
const Wallpaper & GetBackground() 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)
#define HEADERBAR_ITEM_NOTFOUND
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
bool m_bDetectedRangeSegmentation false
#define HEADERBAR_DRAGOUTOFF