LibreOffice Module vcl (master)  1
headbar.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <vcl/headbar.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <tools/debug.hxx>
23 
24 #include <vcl/svapp.hxx>
25 #include <vcl/help.hxx>
26 #include <vcl/image.hxx>
27 #include <vcl/salnativewidgets.hxx>
28 #include <vcl/settings.hxx>
29 #include <vcl/commandevent.hxx>
30 #include <vcl/event.hxx>
31 #include <vcl/ptrstyle.hxx>
32 
33 #include <com/sun/star/accessibility/XAccessible.hpp>
34 
36 {
37 public:
38  sal_uInt16 mnId;
41  OString maHelpId;
43  OUString maOutText;
44  OUString maText;
45  OUString maHelpText;
46 };
47 
48 #define HEAD_ARROWSIZE1 4
49 #define HEAD_ARROWSIZE2 7
50 
51 #define HEADERBAR_TEXTOFF 2
52 #define HEADERBAR_ARROWOFF 5
53 #define HEADERBAR_SPLITOFF 3
54 
55 #define HEADERBAR_DRAGOUTOFF 15
56 
57 #define HEAD_HITTEST_ITEM (sal_uInt16(0x0001))
58 #define HEAD_HITTEST_DIVIDER (sal_uInt16(0x0002))
59 
60 void HeaderBar::ImplInit( WinBits nWinStyle )
61 {
62  mnBorderOff1 = 0;
63  mnBorderOff2 = 0;
64  mnOffset = 0;
65  mnDX = 0;
66  mnDY = 0;
67  mnDragSize = 0;
68  mnStartPos = 0;
69  mnDragPos = 0;
70  mnMouseOff = 0;
71  mnCurItemId = 0;
73  mbDrag = false;
74  mbItemDrag = false;
75  mbOutDrag = false;
76  mbItemMode = false;
77 
78  // evaluate StyleBits
79  if ( nWinStyle & WB_DRAG )
80  mbDragable = true;
81  else
82  mbDragable = false;
83  if ( nWinStyle & WB_BUTTONSTYLE )
84  mbButtonStyle = true;
85  else
86  mbButtonStyle = false;
87  if ( nWinStyle & WB_BORDER )
88  {
89  mnBorderOff1 = 1;
90  mnBorderOff2 = 1;
91  }
92  else
93  {
94  if ( nWinStyle & WB_BOTTOMBORDER )
95  mnBorderOff2 = 1;
96  }
97 
98  ImplInitSettings( true, true, true );
99 }
100 
102  : Window(pParent, nWinStyle & WB_3DLOOK)
103 {
104  SetType(WindowType::HEADERBAR);
105  ImplInit(nWinStyle);
107 }
108 
110 {
111  return CalcWindowSizePixel();
112 }
113 
114 HeaderBar::~HeaderBar() = default;
115 
117 {
118  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
119 
120  ApplyControlFont(rRenderContext, rStyleSettings.GetToolFont());
121 
122  ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor());
124 
125  ApplyControlBackground(rRenderContext, rStyleSettings.GetFaceColor());
126 }
127 
128 void HeaderBar::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
129 {
130  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
131 
132  if (bFont)
133  ApplyControlFont(*this, rStyleSettings.GetToolFont());
134 
135  if (bForeground || bFont)
136  {
137  ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor());
139  }
140 
141  if (bBackground)
142  ApplyControlBackground(*this, rStyleSettings.GetFaceColor());
143 }
144 
145 tools::Long HeaderBar::ImplGetItemPos( sal_uInt16 nPos ) const
146 {
147  tools::Long nX = -mnOffset;
148  for ( size_t i = 0; i < nPos; i++ )
149  nX += mvItemList[ i ]->mnSize;
150  return nX;
151 }
152 
154 {
155  tools::Rectangle aRect( ImplGetItemPos( nPos ), 0, 0, mnDY-1 );
156  aRect.SetRight( aRect.Left() + mvItemList[ nPos ]->mnSize - 1 );
157  // check for overflow on various systems
158  if ( aRect.Right() > 16000 )
159  aRect.SetRight( 16000 );
160  return aRect;
161 }
162 
163 sal_uInt16 HeaderBar::ImplHitTest( const Point& rPos,
164  tools::Long& nMouseOff, sal_uInt16& nPos ) const
165 {
166  size_t nCount = static_cast<sal_uInt16>(mvItemList.size());
167  bool bLastFixed = true;
168  tools::Long nX = -mnOffset;
169 
170  for ( size_t i = 0; i < nCount; i++ )
171  {
172  auto& pItem = mvItemList[ i ];
173 
174  if ( rPos.X() < (nX+pItem->mnSize) )
175  {
176  sal_uInt16 nMode;
177 
178  if ( !bLastFixed && (rPos.X() < (nX+HEADERBAR_SPLITOFF)) )
179  {
180  nMode = HEAD_HITTEST_DIVIDER;
181  nPos = i-1;
182  nMouseOff = rPos.X()-nX+1;
183  }
184  else
185  {
186  nPos = i;
187 
188  if ( rPos.X() >= (nX+pItem->mnSize-HEADERBAR_SPLITOFF) )
189  {
190  nMode = HEAD_HITTEST_DIVIDER;
191  nMouseOff = rPos.X()-(nX+pItem->mnSize);
192  }
193  else
194  {
195  nMode = HEAD_HITTEST_ITEM;
196  nMouseOff = rPos.X()-nX;
197  }
198  }
199 
200  return nMode;
201  }
202 
203  bLastFixed = false;
204 
205  nX += pItem->mnSize;
206  }
207 
208  if ( !bLastFixed )
209  {
210  auto& pItem = mvItemList[ nCount-1 ];
211  if ( (pItem->mnSize < 4) && (rPos.X() < (nX+HEADERBAR_SPLITOFF)) )
212  {
213  nPos = nCount-1;
214  nMouseOff = rPos.X()-nX+1;
215  return HEAD_HITTEST_DIVIDER;
216  }
217  }
218 
219  return 0;
220 }
221 
222 void HeaderBar::ImplInvertDrag( sal_uInt16 nStartPos, sal_uInt16 nEndPos )
223 {
224  tools::Rectangle aRect1 = ImplGetItemRect( nStartPos );
225  tools::Rectangle aRect2 = ImplGetItemRect( nEndPos );
226  Point aStartPos = aRect1.Center();
227  Point aEndPos = aStartPos;
228  tools::Rectangle aStartRect( aStartPos.X()-2, aStartPos.Y()-2,
229  aStartPos.X()+2, aStartPos.Y()+2 );
230 
231  if ( nEndPos > nStartPos )
232  {
233  aStartPos.AdjustX(3 );
234  aEndPos.setX( aRect2.Right()-6 );
235  }
236  else
237  {
238  aStartPos.AdjustX( -3 );
239  aEndPos.setX( aRect2.Left()+6 );
240  }
241 
243  DrawRect( aStartRect );
244  DrawLine( aStartPos, aEndPos );
245  if ( nEndPos > nStartPos )
246  {
247  DrawLine( Point( aEndPos.X()+1, aEndPos.Y()-3 ),
248  Point( aEndPos.X()+1, aEndPos.Y()+3 ) );
249  DrawLine( Point( aEndPos.X()+2, aEndPos.Y()-2 ),
250  Point( aEndPos.X()+2, aEndPos.Y()+2 ) );
251  DrawLine( Point( aEndPos.X()+3, aEndPos.Y()-1 ),
252  Point( aEndPos.X()+3, aEndPos.Y()+1 ) );
253  DrawPixel( Point( aEndPos.X()+4, aEndPos.Y() ) );
254  }
255  else
256  {
257  DrawLine( Point( aEndPos.X()-1, aEndPos.Y()-3 ),
258  Point( aEndPos.X()-1, aEndPos.Y()+3 ) );
259  DrawLine( Point( aEndPos.X()-2, aEndPos.Y()-2 ),
260  Point( aEndPos.X()-2, aEndPos.Y()+2 ) );
261  DrawLine( Point( aEndPos.X()-3, aEndPos.Y()-1 ),
262  Point( aEndPos.X()-3, aEndPos.Y()+1 ) );
263  DrawPixel( Point( aEndPos.X()-4, aEndPos.Y() ) );
264  }
266 }
267 
268 void HeaderBar::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHigh,
269  const tools::Rectangle& rItemRect, const tools::Rectangle* pRect )
270 {
271  ImplControlValue aControlValue(0);
272  tools::Rectangle aCtrlRegion;
274 
275  tools::Rectangle aRect = rItemRect;
276 
277  // do not display if there is no space
278  if (aRect.GetWidth() <= 1)
279  return;
280 
281  // check of rectangle is visible
282  if (pRect)
283  {
284  if (aRect.Right() < pRect->Left())
285  return;
286  else if (aRect.Left() > pRect->Right())
287  return;
288  }
289  else
290  {
291  if (aRect.Right() < 0)
292  return;
293  else if (aRect.Left() > mnDX)
294  return;
295  }
296 
297  auto& pItem = mvItemList[nPos];
298  HeaderBarItemBits nBits = pItem->mnBits;
299  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
300 
302  {
303  aCtrlRegion = aRect;
305  aCtrlRegion, nState, aControlValue, OUString());
306 
307  }
308  else
309  {
310  // do not draw border
311  aRect.AdjustTop(mnBorderOff1 );
312  aRect.AdjustBottom( -mnBorderOff2 );
313 
314  // delete background
315  if ( !pRect )
316  {
317  rRenderContext.DrawWallpaper(aRect, rRenderContext.GetBackground());
318  }
319  }
320 
321  Color aSelectionTextColor(COL_TRANSPARENT);
322 
324  {
325  aCtrlRegion = aRect;
326  aControlValue.setTristateVal(ButtonValue::On);
327  nState |= ControlState::ENABLED;
328  if (bHigh)
329  nState |= ControlState::PRESSED;
331  aCtrlRegion, nState, aControlValue, OUString());
332  }
333  else
334  {
335  // draw separation line
336  rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
337  rRenderContext.DrawLine(Point(aRect.Right(), aRect.Top()), Point(aRect.Right(), aRect.Bottom()));
338 
339  // draw ButtonStyle
340  // avoid 3D borders
341  if (bHigh)
342  vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, aRect, 1, true, false, false, &aSelectionTextColor);
343  else if (!mbButtonStyle || (nBits & HeaderBarItemBits::FLAT))
344  vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, aRect, 0, true, false, false, &aSelectionTextColor);
345  }
346 
347  // do not draw if there is no space
348  if (aRect.GetWidth() < 1)
349  return;
350 
351  // calculate size and position and draw content
352  pItem->maOutText = pItem->maText;
353  Size aImageSize = pItem->maImage.GetSizePixel();
354  Size aTxtSize(rRenderContext.GetTextWidth(pItem->maOutText), 0);
355  if (!pItem->maOutText.isEmpty())
356  aTxtSize.setHeight( rRenderContext.GetTextHeight() );
357  tools::Long nArrowWidth = 0;
359  nArrowWidth = HEAD_ARROWSIZE2 + HEADERBAR_ARROWOFF;
360 
361  // do not draw if there is not enough space for the image
362  tools::Long nTestHeight = aImageSize.Height();
364  nTestHeight += aTxtSize.Height();
365  if ((aImageSize.Width() > aRect.GetWidth()) || (nTestHeight > aRect.GetHeight()))
366  {
367  aImageSize.setWidth( 0 );
368  aImageSize.setHeight( 0 );
369  }
370 
371  // cut text to correct length
372  bool bLeftText = false;
373  tools::Long nMaxTxtWidth = aRect.GetWidth() - (HEADERBAR_TEXTOFF * 2) - nArrowWidth;
375  nMaxTxtWidth -= aImageSize.Width();
376  tools::Long nTxtWidth = aTxtSize.Width();
377  if (nTxtWidth > nMaxTxtWidth)
378  {
379  bLeftText = true;
380  OUStringBuffer aBuf(pItem->maOutText);
381  aBuf.append("...");
382  do
383  {
384  aBuf.remove(aBuf.getLength() - 3 - 1, 1);
385  nTxtWidth = rRenderContext.GetTextWidth(aBuf.toString());
386  }
387  while ((nTxtWidth > nMaxTxtWidth) && (aBuf.getLength() > 3));
388  pItem->maOutText = aBuf.makeStringAndClear();
389  if (pItem->maOutText.getLength() == 3)
390  {
391  nTxtWidth = 0;
392  pItem->maOutText.clear();
393  }
394  }
395 
396  // calculate text/imageposition
397  tools::Long nTxtPos;
398  if (!bLeftText && (nBits & HeaderBarItemBits::RIGHT))
399  {
400  nTxtPos = aRect.Right() - nTxtWidth - HEADERBAR_TEXTOFF;
401  if (nBits & HeaderBarItemBits::RIGHTIMAGE)
402  nTxtPos -= aImageSize.Width();
403  }
404  else if (!bLeftText && (nBits & HeaderBarItemBits::CENTER))
405  {
406  tools::Long nTempWidth = nTxtWidth;
408  nTempWidth += aImageSize.Width();
409  nTxtPos = aRect.Left() + (aRect.GetWidth() - nTempWidth) / 2;
410  if (nBits & HeaderBarItemBits::LEFTIMAGE)
411  nTxtPos += aImageSize.Width();
412  if (nArrowWidth)
413  {
414  if (nTxtPos + nTxtWidth + nArrowWidth >= aRect.Right())
415  {
416  nTxtPos = aRect.Left() + HEADERBAR_TEXTOFF;
417  if (nBits & HeaderBarItemBits::LEFTIMAGE)
418  nTxtPos += aImageSize.Width();
419  }
420  }
421  }
422  else
423  {
424  nTxtPos = aRect.Left() + HEADERBAR_TEXTOFF;
425  if (nBits & HeaderBarItemBits::LEFTIMAGE)
426  nTxtPos += aImageSize.Width();
427  if (nBits & HeaderBarItemBits::RIGHT)
428  nTxtPos += nArrowWidth;
429  }
430 
431  // calculate text/imageposition
432  tools::Long nTxtPosY = 0;
433  if (!pItem->maOutText.isEmpty() || (nArrowWidth && aTxtSize.Height()))
434  {
435  tools::Long nTempHeight = aTxtSize.Height();
436  nTempHeight += aImageSize.Height();
437  nTxtPosY = aRect.Top()+((aRect.GetHeight()-nTempHeight)/2);
439  nTxtPosY += aImageSize.Height();
440  }
441 
442  // display text
443  if (!pItem->maOutText.isEmpty())
444  {
445  if (aSelectionTextColor != COL_TRANSPARENT)
446  {
447  rRenderContext.Push(PushFlags::TEXTCOLOR);
448  rRenderContext.SetTextColor(aSelectionTextColor);
449  }
450  if (IsEnabled())
451  rRenderContext.DrawText(Point(nTxtPos, nTxtPosY), pItem->maOutText);
452  else
453  rRenderContext.DrawCtrlText(Point(nTxtPos, nTxtPosY), pItem->maOutText, 0, pItem->maOutText.getLength(), DrawTextFlags::Disable);
454  if (aSelectionTextColor != COL_TRANSPARENT)
455  rRenderContext.Pop();
456  }
457 
458  // calculate the position and draw image if it is available
459  tools::Long nImagePosY = 0;
460  if (aImageSize.Width() && aImageSize.Height())
461  {
462  tools::Long nImagePos = nTxtPos;
463  if (nBits & HeaderBarItemBits::LEFTIMAGE)
464  {
465  nImagePos -= aImageSize.Width();
466  if (nBits & HeaderBarItemBits::RIGHT)
467  nImagePos -= nArrowWidth;
468  }
469  else if (nBits & HeaderBarItemBits::RIGHTIMAGE)
470  {
471  nImagePos += nTxtWidth;
472  if (!(nBits & HeaderBarItemBits::RIGHT))
473  nImagePos += nArrowWidth;
474  }
475  else
476  {
477  if (nBits & HeaderBarItemBits::RIGHT )
478  nImagePos = aRect.Right()-aImageSize.Width();
479  else if (nBits & HeaderBarItemBits::CENTER)
480  nImagePos = aRect.Left() + (aRect.GetWidth() - aImageSize.Width()) / 2;
481  else
482  nImagePos = aRect.Left() + HEADERBAR_TEXTOFF;
483  }
484 
485  tools::Long nTempHeight = aImageSize.Height();
486  if (!(nBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)))
487  nTempHeight += aTxtSize.Height();
488  nImagePosY = aRect.Top() + ((aRect.GetHeight() - nTempHeight) / 2);
489 
490  if (nImagePos + aImageSize.Width() <= aRect.Right())
491  {
493  if (!IsEnabled())
494  nStyle |= DrawImageFlags::Disable;
495  rRenderContext.DrawImage(Point(nImagePos, nImagePosY), pItem->maImage, nStyle);
496  }
497  }
498 
500  return;
501 
502  tools::Long nArrowX = nTxtPos;
503  if (nBits & HeaderBarItemBits::RIGHT)
504  nArrowX -= nArrowWidth;
505  else
506  nArrowX += nTxtWidth + HEADERBAR_ARROWOFF;
507  if (!(nBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)) && pItem->maText.isEmpty())
508  {
509  if (nBits & HeaderBarItemBits::RIGHT)
510  nArrowX -= aImageSize.Width();
511  else
512  nArrowX += aImageSize.Width();
513  }
514 
515  // is there enough space to draw the item?
516  bool bDraw = true;
517  if (nArrowX < aRect.Left() + HEADERBAR_TEXTOFF)
518  bDraw = false;
519  else if (nArrowX + HEAD_ARROWSIZE2 > aRect.Right())
520  bDraw = false;
521 
522  if (!bDraw)
523  return;
524 
526  {
527  aCtrlRegion = tools::Rectangle(Point(nArrowX, aRect.Top()), Size(nArrowWidth, aRect.GetHeight()));
528  // control value passes 1 if arrow points down, 0 otherwise
529  aControlValue.setNumericVal((nBits & HeaderBarItemBits::DOWNARROW) ? 1 : 0);
530  nState |= ControlState::ENABLED;
531  if (bHigh)
532  nState |= ControlState::PRESSED;
533  rRenderContext.DrawNativeControl(ControlType::ListHeader, ControlPart::Arrow, aCtrlRegion,
534  nState, aControlValue, OUString());
535  }
536  else
537  {
538  tools::Long nArrowY;
539  if (aTxtSize.Height())
540  nArrowY = nTxtPosY + (aTxtSize.Height() / 2);
541  else if (aImageSize.Width() && aImageSize.Height())
542  nArrowY = nImagePosY + (aImageSize.Height() / 2);
543  else
544  nArrowY = aRect.Top() + ((aRect.GetHeight() - HEAD_ARROWSIZE2) / 2);
545  nArrowY -= HEAD_ARROWSIZE1 - 1;
546  if (nBits & HeaderBarItemBits::DOWNARROW)
547  {
548  rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
549  rRenderContext.DrawLine(Point(nArrowX, nArrowY),
550  Point(nArrowX + HEAD_ARROWSIZE2, nArrowY));
551  rRenderContext.DrawLine(Point(nArrowX, nArrowY),
552  Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2));
553  rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
554  rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2),
555  Point(nArrowX + HEAD_ARROWSIZE2, nArrowY));
556  }
557  else
558  {
559  rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
560  rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2),
561  Point(nArrowX + HEAD_ARROWSIZE1, nArrowY));
562  rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
563  rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2),
564  Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2));
565  rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2),
566  Point(nArrowX + HEAD_ARROWSIZE1, nArrowY));
567  }
568  }
569 }
570 
571 void HeaderBar::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos,
572  bool bHigh, const tools::Rectangle* pRect )
573 {
574  tools::Rectangle aRect = ImplGetItemRect(nPos);
575  ImplDrawItem(rRenderContext, nPos, bHigh, aRect, pRect );
576 }
577 
578 void HeaderBar::ImplUpdate(sal_uInt16 nPos, bool bEnd)
579 {
580  if (!(IsVisible() && IsUpdateMode()))
581  return;
582 
583  tools::Rectangle aRect;
584  size_t nItemCount = mvItemList.size();
585  if (nPos < nItemCount)
586  aRect = ImplGetItemRect(nPos);
587  else
588  {
589  aRect.SetBottom( mnDY - 1 );
590  if (nItemCount)
591  aRect.SetLeft( ImplGetItemRect(nItemCount - 1).Right() );
592  }
593  if (bEnd)
594  aRect.SetRight( mnDX - 1 );
595  aRect.AdjustTop(mnBorderOff1 );
596  aRect.AdjustBottom( -mnBorderOff2 );
597  Invalidate(aRect);
598 }
599 
600 void HeaderBar::ImplStartDrag( const Point& rMousePos, bool bCommand )
601 {
602  sal_uInt16 nPos;
603  sal_uInt16 nHitTest = ImplHitTest( rMousePos, mnMouseOff, nPos );
604  if ( !nHitTest )
605  return;
606 
607  mbDrag = false;
608  auto& pItem = mvItemList[ nPos ];
609  if ( nHitTest & HEAD_HITTEST_DIVIDER )
610  mbDrag = true;
611  else
612  {
613  if ( ((pItem->mnBits & HeaderBarItemBits::CLICKABLE) && !(pItem->mnBits & HeaderBarItemBits::FLAT)) ||
614  mbDragable )
615  {
616  mbItemMode = true;
617  mbDrag = true;
618  if ( bCommand )
619  {
620  if ( mbDragable )
621  mbItemDrag = true;
622  else
623  {
624  mbItemMode = false;
625  mbDrag = false;
626  }
627  }
628  }
629  else
630  {
631  if ( !bCommand )
632  {
633  mnCurItemId = pItem->mnId;
634  Select();
635  mnCurItemId = 0;
636  }
637  }
638  }
639 
640  if ( mbDrag )
641  {
642  mbOutDrag = false;
643  mnCurItemId = pItem->mnId;
644  mnItemDragPos = nPos;
645  StartTracking();
646  mnStartPos = rMousePos.X()-mnMouseOff;
648  maStartDragHdl.Call( this );
649  if (mbItemMode)
650  Invalidate();
651  else
652  {
654  ShowTracking( aSizeRect, ShowTrackFlags::Split );
655  }
656  }
657  else
658  mnMouseOff = 0;
659 }
660 
661 void HeaderBar::ImplDrag( const Point& rMousePos )
662 {
663  sal_uInt16 nPos = GetItemPos( mnCurItemId );
664 
665  mnDragPos = rMousePos.X()-mnMouseOff;
666  if ( mbItemMode )
667  {
668  bool bNewOutDrag;
669 
670  tools::Rectangle aItemRect = ImplGetItemRect( nPos );
671  bNewOutDrag = !aItemRect.IsInside( rMousePos );
672 
673  // if needed switch on ItemDrag
674  if ( bNewOutDrag && mbDragable && !mbItemDrag )
675  {
676  if ( (rMousePos.Y() >= aItemRect.Top()) && (rMousePos.Y() <= aItemRect.Bottom()) )
677  {
678  mbItemDrag = true;
679  Invalidate();
680  }
681  }
682 
683  sal_uInt16 nOldItemDragPos = mnItemDragPos;
684  if ( mbItemDrag )
685  {
686  bNewOutDrag = (rMousePos.Y() < -HEADERBAR_DRAGOUTOFF) || (rMousePos.Y() > mnDY+HEADERBAR_DRAGOUTOFF);
687 
688  if ( bNewOutDrag )
690  else
691  {
692  sal_uInt16 nTempId = GetItemId( Point( rMousePos.X(), 2 ) );
693  if ( nTempId )
694  mnItemDragPos = GetItemPos( nTempId );
695  else
696  {
697  if ( rMousePos.X() <= 0 )
698  mnItemDragPos = 0;
699  else
701  }
702  }
703 
704  if ( (mnItemDragPos != nOldItemDragPos) &&
705  (nOldItemDragPos != nPos) &&
706  (nOldItemDragPos != HEADERBAR_ITEM_NOTFOUND) )
707  {
708  ImplInvertDrag( nPos, nOldItemDragPos );
709  Invalidate();
710  }
711  }
712 
713  if ( bNewOutDrag != mbOutDrag )
714  Invalidate();
715 
716  if ( mbItemDrag )
717  {
718  if ( (mnItemDragPos != nOldItemDragPos) &&
719  (mnItemDragPos != nPos) &&
721  {
722  Invalidate();
723  ImplInvertDrag( nPos, mnItemDragPos );
724  }
725  }
726 
727  mbOutDrag = bNewOutDrag;
728  }
729  else
730  {
731  tools::Rectangle aItemRect = ImplGetItemRect( nPos );
732  if ( mnDragPos < aItemRect.Left() )
733  mnDragPos = aItemRect.Left();
734  if ( (mnDragPos < 0) || (mnDragPos > mnDX-1) )
735  HideTracking();
736  else
737  {
739  ShowTracking( aSizeRect, ShowTrackFlags::Split );
740  }
741  }
742 }
743 
744 void HeaderBar::ImplEndDrag( bool bCancel )
745 {
746  HideTracking();
747 
748  if ( bCancel || mbOutDrag )
749  {
750  if ( mbItemMode && (!mbOutDrag || mbItemDrag) )
751  {
752  Invalidate();
753  }
754 
755  mnCurItemId = 0;
756  }
757  else
758  {
759  sal_uInt16 nPos = GetItemPos( mnCurItemId );
760  if ( mbItemMode )
761  {
762  if ( mbItemDrag )
763  {
765  if ( (mnItemDragPos != nPos) &&
767  {
768  ImplInvertDrag( nPos, mnItemDragPos );
770  }
771  else
772  Invalidate();
773  }
774  else
775  {
776  Select();
777  ImplUpdate( nPos );
778  }
779  }
780  else
781  {
782  tools::Long nDelta = mnDragPos - mnStartPos;
783  if ( nDelta )
784  {
785  auto& pItem = mvItemList[ nPos ];
786  pItem->mnSize += nDelta;
787  ImplUpdate( nPos, true );
788  }
789  }
790  }
791 
792  mbDrag = false;
793  EndDrag();
794  mnCurItemId = 0;
796  mbOutDrag = false;
797  mbItemMode = false;
798  mbItemDrag = false;
799 }
800 
802 {
803  if ( !rMEvt.IsLeft() )
804  return;
805 
806  if ( rMEvt.GetClicks() == 2 )
807  {
808  tools::Long nTemp;
809  sal_uInt16 nPos;
810  sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp, nPos );
811  if ( nHitTest )
812  {
813  auto& pItem = mvItemList[ nPos ];
814  if ( nHitTest & HEAD_HITTEST_DIVIDER )
815  mbItemMode = false;
816  else
817  mbItemMode = true;
818  mnCurItemId = pItem->mnId;
819  DoubleClick();
820  mbItemMode = false;
821  mnCurItemId = 0;
822  }
823  }
824  else
825  ImplStartDrag( rMEvt.GetPosPixel(), false );
826 }
827 
828 void HeaderBar::MouseMove( const MouseEvent& rMEvt )
829 {
830  tools::Long nTemp1;
831  sal_uInt16 nTemp2;
833  sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp1, nTemp2 );
834 
835  if ( nHitTest & HEAD_HITTEST_DIVIDER )
836  eStyle = PointerStyle::HSizeBar;
837  SetPointer( eStyle );
838 }
839 
840 void HeaderBar::Tracking( const TrackingEvent& rTEvt )
841 {
842  Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
843 
844  if ( rTEvt.IsTrackingEnded() )
845  ImplEndDrag( rTEvt.IsTrackingCanceled() );
846  else
847  ImplDrag( aMousePos );
848 }
849 
850 void HeaderBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
851 {
852  if (mnBorderOff1 || mnBorderOff2)
853  {
854  rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
855  if (mnBorderOff1)
856  rRenderContext.DrawLine(Point(0, 0), Point(mnDX - 1, 0));
857  if (mnBorderOff2)
858  rRenderContext.DrawLine(Point(0, mnDY - 1), Point(mnDX - 1, mnDY - 1));
859  // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
860  if (mnBorderOff1 && mnBorderOff2)
861  {
862  rRenderContext.DrawLine(Point(0, 0), Point(0, mnDY - 1));
863  rRenderContext.DrawLine(Point(mnDX - 1, 0), Point(mnDX - 1, mnDY - 1));
864  }
865  }
866 
867  sal_uInt16 nCurItemPos;
868  if (mbDrag)
869  nCurItemPos = GetItemPos(mnCurItemId);
870  else
871  nCurItemPos = HEADERBAR_ITEM_NOTFOUND;
872  sal_uInt16 nItemCount = static_cast<sal_uInt16>(mvItemList.size());
873  for (sal_uInt16 i = 0; i < nItemCount; i++)
874  ImplDrawItem(rRenderContext, i, (i == nCurItemPos), &rRect);
875 }
876 
877 void HeaderBar::Draw( OutputDevice* pDev, const Point& rPos,
878  DrawFlags nFlags )
879 {
880  Point aPos = pDev->LogicToPixel( rPos );
881  Size aSize = GetSizePixel();
882  tools::Rectangle aRect( aPos, aSize );
883  vcl::Font aFont = GetDrawPixelFont( pDev );
884 
885  pDev->Push();
886  pDev->SetMapMode();
887  pDev->SetFont( aFont );
888  if ( nFlags & DrawFlags::Mono )
889  pDev->SetTextColor( COL_BLACK );
890  else
891  pDev->SetTextColor( GetTextColor() );
892  pDev->SetTextFillColor();
893 
894  // draw background
895  {
896  pDev->DrawWallpaper( aRect, GetBackground() );
897  if ( mnBorderOff1 || mnBorderOff2 )
898  {
899  pDev->SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
900  if ( mnBorderOff1 )
901  pDev->DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
902  if ( mnBorderOff2 )
903  pDev->DrawLine( Point( aRect.Left(), aRect.Bottom() ), Point( aRect.Right(), aRect.Bottom() ) );
904  // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
905  if ( mnBorderOff1 && mnBorderOff2 )
906  {
907  pDev->DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() ) );
908  pDev->DrawLine( Point( aRect.Right(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) );
909  }
910  }
911  }
912 
913  tools::Rectangle aItemRect( aRect );
914  size_t nItemCount = mvItemList.size();
915  for ( size_t i = 0; i < nItemCount; i++ )
916  {
917  aItemRect.SetLeft( aRect.Left()+ImplGetItemPos( i ) );
918  aItemRect.SetRight( aItemRect.Left() + mvItemList[ i ]->mnSize - 1 );
919  // check for overflow on some systems
920  if ( aItemRect.Right() > 16000 )
921  aItemRect.SetRight( 16000 );
922  vcl::Region aRegion( aRect );
923  pDev->SetClipRegion( aRegion );
924  ImplDrawItem(*pDev, i, false, aItemRect, &aRect );
925  pDev->SetClipRegion();
926  }
927 
928  pDev->Pop();
929 }
930 
932 {
933  Size aSize = GetOutputSizePixel();
934  if ( IsVisible() && (mnDY != aSize.Height()) )
935  Invalidate();
936  mnDX = aSize.Width();
937  mnDY = aSize.Height();
938 }
939 
940 void HeaderBar::Command( const CommandEvent& rCEvt )
941 {
942  if ( rCEvt.IsMouseEvent() && (rCEvt.GetCommand() == CommandEventId::StartDrag) && !mbDrag )
943  {
944  ImplStartDrag( rCEvt.GetMousePosPixel(), true );
945  return;
946  }
947 
948  Window::Command( rCEvt );
949 }
950 
951 void HeaderBar::RequestHelp( const HelpEvent& rHEvt )
952 {
953  sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
954  if ( nItemId )
955  {
957  {
958  tools::Rectangle aItemRect = GetItemRect( nItemId );
959  Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
960  aItemRect.SetLeft( aPt.X() );
961  aItemRect.SetTop( aPt.Y() );
962  aPt = OutputToScreenPixel( aItemRect.BottomRight() );
963  aItemRect.SetRight( aPt.X() );
964  aItemRect.SetBottom( aPt.Y() );
965 
966  OUString aStr = GetHelpText( nItemId );
967  if ( aStr.isEmpty() || !(rHEvt.GetMode() & HelpEventMode::BALLOON) )
968  {
969  auto& pItem = mvItemList[ GetItemPos( nItemId ) ];
970  // Quick-help is only displayed if the text is not fully visible.
971  // Otherwise we display Helptext only if the items do not contain text
972  if ( pItem->maOutText != pItem->maText )
973  aStr = pItem->maText;
974  else if (!pItem->maText.isEmpty())
975  aStr.clear();
976  }
977 
978  if (!aStr.isEmpty())
979  {
980  if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
981  Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
982  else
983  Help::ShowQuickHelp( this, aItemRect, aStr );
984  return;
985  }
986  }
987  }
988 
989  Window::RequestHelp( rHEvt );
990 }
991 
993 {
994  Window::StateChanged( nType );
995 
996  if ( nType == StateChangedType::Enable )
997  Invalidate();
998  else if ( (nType == StateChangedType::Zoom) ||
999  (nType == StateChangedType::ControlFont) )
1000  {
1001  ImplInitSettings( true, false, false );
1002  Invalidate();
1003  }
1004  else if ( nType == StateChangedType::ControlForeground )
1005  {
1006  ImplInitSettings( false, true, false );
1007  Invalidate();
1008  }
1009  else if ( nType == StateChangedType::ControlBackground )
1010  {
1011  ImplInitSettings( false, false, true );
1012  Invalidate();
1013  }
1014 }
1015 
1017 {
1018  Window::DataChanged( rDCEvt );
1019 
1020  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1022  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1023  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1024  {
1025  ImplInitSettings( true, true, true );
1026  Invalidate();
1027  }
1028 }
1029 
1031 {
1032  maEndDragHdl.Call( this );
1033 }
1034 
1036 {
1037  maSelectHdl.Call( this );
1038 }
1039 
1041 {
1042 }
1043 
1044 void HeaderBar::InsertItem( sal_uInt16 nItemId, const OUString& rText,
1045  tools::Long nSize, HeaderBarItemBits nBits, sal_uInt16 nPos )
1046 {
1047  DBG_ASSERT( nItemId, "HeaderBar::InsertItem(): ItemId == 0" );
1049  "HeaderBar::InsertItem(): ItemId already exists" );
1050 
1051  // create item and insert in the list
1052  std::unique_ptr<ImplHeadItem> pItem(new ImplHeadItem);
1053  pItem->mnId = nItemId;
1054  pItem->mnBits = nBits;
1055  pItem->mnSize = nSize;
1056  pItem->maText = rText;
1057  if ( nPos < mvItemList.size() ) {
1058  auto it = mvItemList.begin();
1059  it += nPos;
1060  mvItemList.insert( it, std::move(pItem) );
1061  } else {
1062  mvItemList.push_back( std::move(pItem) );
1063  }
1064 
1065  // update display
1066  ImplUpdate( nPos, true );
1067 }
1068 
1069 void HeaderBar::RemoveItem( sal_uInt16 nItemId )
1070 {
1071  sal_uInt16 nPos = GetItemPos( nItemId );
1072  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1073  {
1074  if ( nPos < mvItemList.size() ) {
1075  auto it = mvItemList.begin();
1076  it += nPos;
1077  mvItemList.erase( it );
1078  }
1079  }
1080 }
1081 
1082 void HeaderBar::MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos )
1083 {
1084  sal_uInt16 nPos = GetItemPos( nItemId );
1085  if ( nPos == HEADERBAR_ITEM_NOTFOUND )
1086  return;
1087 
1088  if ( nPos == nNewPos )
1089  return;
1090 
1091  auto it = mvItemList.begin();
1092  it += nPos;
1093  std::unique_ptr<ImplHeadItem> pItem = std::move(*it);
1094  mvItemList.erase( it );
1095  if ( nNewPos < nPos )
1096  nPos = nNewPos;
1097  it = mvItemList.begin();
1098  it += nNewPos;
1099  mvItemList.insert( it, std::move(pItem) );
1100  ImplUpdate( nPos, true);
1101 }
1102 
1104 {
1105  // delete all items
1106  mvItemList.clear();
1107 
1108  ImplUpdate( 0, true );
1109 }
1110 
1112 {
1113  // tdf#129856 (see also #i40393#) invalidate old left and right border area if WB_BORDER was set in ImplInit()
1114  if (mnBorderOff1 && mnBorderOff2)
1115  {
1116  Invalidate(tools::Rectangle(0, 0, 1, mnDY));
1118  }
1119 
1120  // move area
1122  tools::Long nDelta = mnOffset-nNewOffset;
1123  mnOffset = nNewOffset;
1124  Scroll( nDelta, 0, aRect );
1125 }
1126 
1127 sal_uInt16 HeaderBar::GetItemCount() const
1128 {
1129  return static_cast<sal_uInt16>(mvItemList.size());
1130 }
1131 
1132 sal_uInt16 HeaderBar::GetItemPos( sal_uInt16 nItemId ) const
1133 {
1134  for ( size_t i = 0, n = mvItemList.size(); i < n; ++i ) {
1135  auto& pItem = mvItemList[ i ];
1136  if ( pItem->mnId == nItemId )
1137  return static_cast<sal_uInt16>(i);
1138  }
1139  return HEADERBAR_ITEM_NOTFOUND;
1140 }
1141 
1142 sal_uInt16 HeaderBar::GetItemId( sal_uInt16 nPos ) const
1143 {
1144  ImplHeadItem* pItem = (nPos < mvItemList.size() ) ? mvItemList[ nPos ].get() : nullptr;
1145  if ( pItem )
1146  return pItem->mnId;
1147  else
1148  return 0;
1149 }
1150 
1151 sal_uInt16 HeaderBar::GetItemId( const Point& rPos ) const
1152 {
1153  for ( size_t i = 0, n = mvItemList.size(); i < n; ++i ) {
1154  if ( ImplGetItemRect( i ).IsInside( rPos ) ) {
1155  return GetItemId( i );
1156  }
1157  }
1158  return 0;
1159 }
1160 
1161 tools::Rectangle HeaderBar::GetItemRect( sal_uInt16 nItemId ) const
1162 {
1163  tools::Rectangle aRect;
1164  sal_uInt16 nPos = GetItemPos( nItemId );
1165  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1166  aRect = ImplGetItemRect( nPos );
1167  return aRect;
1168 }
1169 
1170 void HeaderBar::SetItemSize( sal_uInt16 nItemId, tools::Long nNewSize )
1171 {
1172  sal_uInt16 nPos = GetItemPos( nItemId );
1173  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1174  {
1175  auto& pItem = mvItemList[ nPos ];
1176  if ( pItem->mnSize != nNewSize )
1177  {
1178  pItem->mnSize = nNewSize;
1179  ImplUpdate( nPos, true );
1180  }
1181  }
1182 }
1183 
1184 tools::Long HeaderBar::GetItemSize( sal_uInt16 nItemId ) const
1185 {
1186  sal_uInt16 nPos = GetItemPos( nItemId );
1187  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1188  return mvItemList[ nPos ]->mnSize;
1189  else
1190  return 0;
1191 }
1192 
1193 void HeaderBar::SetItemBits( sal_uInt16 nItemId, HeaderBarItemBits nNewBits )
1194 {
1195  sal_uInt16 nPos = GetItemPos( nItemId );
1196  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1197  {
1198  auto& pItem = mvItemList[ nPos ];
1199  if ( pItem->mnBits != nNewBits )
1200  {
1201  pItem->mnBits = nNewBits;
1202  ImplUpdate( nPos );
1203  }
1204  }
1205 }
1206 
1207 HeaderBarItemBits HeaderBar::GetItemBits( sal_uInt16 nItemId ) const
1208 {
1209  sal_uInt16 nPos = GetItemPos( nItemId );
1210  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1211  return mvItemList[ nPos ]->mnBits;
1212  else
1213  return HeaderBarItemBits::NONE;
1214 }
1215 
1216 void HeaderBar::SetItemText( sal_uInt16 nItemId, const OUString& rText )
1217 {
1218  sal_uInt16 nPos = GetItemPos( nItemId );
1219  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1220  {
1221  mvItemList[ nPos ]->maText = rText;
1222  ImplUpdate( nPos );
1223  }
1224 }
1225 
1226 OUString HeaderBar::GetItemText( sal_uInt16 nItemId ) const
1227 {
1228  sal_uInt16 nPos = GetItemPos( nItemId );
1229  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1230  return mvItemList[ nPos ]->maText;
1231  return OUString();
1232 }
1233 
1234 OUString HeaderBar::GetHelpText( sal_uInt16 nItemId ) const
1235 {
1236  sal_uInt16 nPos = GetItemPos( nItemId );
1237  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1238  {
1239  auto& pItem = mvItemList[ nPos ];
1240  if ( pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty() )
1241  {
1242  Help* pHelp = Application::GetHelp();
1243  if ( pHelp )
1244  pItem->maHelpText = pHelp->GetHelpText( OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this );
1245  }
1246 
1247  return pItem->maHelpText;
1248  }
1249 
1250  return OUString();
1251 }
1252 
1254 {
1255  tools::Long nMaxImageSize = 0;
1256  Size aSize( 0, GetTextHeight() );
1257 
1258  for (auto& pItem : mvItemList)
1259  {
1260  // take image size into account
1261  tools::Long nImageHeight = pItem->maImage.GetSizePixel().Height();
1262  if ( !(pItem->mnBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)) && !pItem->maText.isEmpty() )
1263  nImageHeight += aSize.Height();
1264  if ( nImageHeight > nMaxImageSize )
1265  nMaxImageSize = nImageHeight;
1266 
1267  // add width
1268  aSize.AdjustWidth(pItem->mnSize );
1269  }
1270 
1271  if ( nMaxImageSize > aSize.Height() )
1272  aSize.setHeight( nMaxImageSize );
1273 
1274  // add border
1275  if ( mbButtonStyle )
1276  aSize.AdjustHeight(4 );
1277  else
1278  aSize.AdjustHeight(2 );
1280 
1281  return aSize;
1282 }
1283 
1284 css::uno::Reference< css::accessibility::XAccessible > HeaderBar::CreateAccessible()
1285 {
1286  if ( !mxAccessible.is() )
1287  {
1288  maCreateAccessibleHdl.Call( this );
1289 
1290  if ( !mxAccessible.is() )
1291  mxAccessible = Window::CreateAccessible();
1292  }
1293 
1294  return mxAccessible;
1295 }
1296 
1297 void HeaderBar::SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& _xAccessible )
1298 {
1299  mxAccessible = _xAccessible;
1300 }
1301 
1302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maText
Definition: headbar.cxx:44
Point TopLeft() const
const Color & GetTextColor() const
Definition: outdev.hxx:1132
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)
Definition: text.cxx:795
const Color & GetShadowColor() const
VCL_DLLPRIVATE void ImplInit(WinBits nWinStyle)
Definition: headbar.cxx:60
virtual void Resize() override
Definition: headbar.cxx:931
VCL_DLLPRIVATE void ImplDrag(const Point &rPos)
Definition: headbar.cxx:661
const Wallpaper & GetBackground() const
Definition: outdev.hxx:642
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
Definition: headbar.cxx:1132
VCL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext &rRenderContext, sal_uInt16 nPos, bool bHigh, const tools::Rectangle &rItemRect, const tools::Rectangle *pRect)
Definition: headbar.cxx:268
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: headbar.cxx:116
virtual void EndDrag()
Definition: headbar.cxx:1030
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)
bool mbOutDrag
Definition: headbar.hxx:222
OUString GetItemText(sal_uInt16 nItemId) const
Definition: headbar.cxx:1226
tools::Long mnDX
Definition: headbar.hxx:211
css::uno::Reference< css::accessibility::XAccessible > mxAccessible
Definition: headbar.hxx:231
#define HEAD_HITTEST_DIVIDER
Definition: headbar.cxx:58
void InsertItem(sal_uInt16 nItemId, const OUString &rText, tools::Long nSize, HeaderBarItemBits nBits=HeaderBarItemBits::STDSTYLE, sal_uInt16 nPos=HEADERBAR_APPEND)
Definition: headbar.cxx:1044
Definition: help.hxx:60
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1348
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Definition: text.cxx:2069
HeaderBar(vcl::Window *pParent, WinBits nWinBits)
Definition: headbar.cxx:101
long Long
VCL_DLLPRIVATE void ImplInvertDrag(sal_uInt16 nStartPos, sal_uInt16 nEndPos)
Definition: headbar.cxx:222
const StyleSettings & GetStyleSettings() const
Link< HeaderBar *, void > maCreateAccessibleHdl
Definition: headbar.hxx:228
const Color & GetFaceColor() const
VCL_DLLPRIVATE tools::Rectangle ImplGetItemRect(sal_uInt16 nPos) const
Definition: headbar.cxx:153
const OUString & GetHelpText() const
Definition: window.cxx:3068
OUString maOutText
Definition: headbar.cxx:43
sal_Int64 n
void HideTracking()
Definition: window2.cxx:147
virtual Size GetSizePixel() const
Definition: window.cxx:2397
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1262
aBuf
void SetItemBits(sal_uInt16 nItemId, HeaderBarItemBits nNewBits)
Definition: headbar.cxx:1193
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: headbar.cxx:801
void SetTextFillColor()
Definition: text.cxx:701
void setTristateVal(ButtonValue nTristate)
tools::Long GetWidth() const
void Clear()
Definition: headbar.cxx:1103
DataChangedEventType GetType() const
Definition: event.hxx:356
void SetType(WindowType nType)
Definition: window2.cxx:968
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:546
tools::Long mnBorderOff2
Definition: headbar.hxx:209
HelpEventMode GetMode() const
Definition: event.hxx:205
void SetRight(tools::Long v)
Link< HeaderBar *, void > maSelectHdl
Definition: headbar.hxx:227
virtual void StateChanged(StateChangedType nStateChange) override
Definition: headbar.cxx:992
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: headbar.cxx:828
void DrawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWallpaper)
Definition: wallpaper.cxx:42
StateChangedType
Definition: window.hxx:317
Image maImage
Definition: headbar.cxx:42
sal_uInt16 GetClicks() const
Definition: event.hxx:123
sal_Int64 WinBits
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
tools::Long mnDY
Definition: headbar.hxx:212
tools::Long mnDragPos
Definition: headbar.hxx:215
tools::Long Left() const
void SetLeft(tools::Long v)
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
Definition: window2.cxx:124
bool IsMouseEvent() const
int nCount
AllSettingsFlags GetFlags() const
Definition: event.hxx:357
tools::Long Bottom() const
const Color & GetLightColor() const
#define HEADERBAR_TEXTOFF
Definition: headbar.cxx:51
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: headbar.cxx:877
tools::Long mnOffset
Definition: headbar.hxx:210
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
void setX(tools::Long x)
HeaderBarItemBits GetItemBits(sal_uInt16 nItemId) const
Definition: headbar.cxx:1207
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
const Point & GetMousePosPixel() const
Definition: event.hxx:204
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
Definition: headbar.cxx:1297
VCL_DLLPRIVATE tools::Long ImplGetItemPos(sal_uInt16 nPos) const
Definition: headbar.cxx:145
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: headbar.cxx:1142
Point BottomRight() const
const Color & GetDarkShadowColor() const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: headbar.cxx:850
void SetLineColor()
virtual OUString GetHelpText(const OUString &aHelpURL, const vcl::Window *pWindow)
Definition: help.cxx:67
Right
sal_uInt16 mnCurItemId
Definition: headbar.hxx:217
Size CalcWindowSizePixel() const
Definition: headbar.cxx:1253
#define DBG_ASSERT(sCon, aError)
int i
DrawFlags
Definition: window.hxx:360
const vcl::Font & GetToolFont() const
HeaderBarItemBits mnBits
Definition: headbar.cxx:39
#define WB_BUTTONSTYLE
Definition: headbar.hxx:177
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
void SetItemSize(sal_uInt16 nItemId, tools::Long nNewSize)
Definition: headbar.cxx:1170
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: headbar.cxx:951
bool IsUpdateMode() const
Definition: window2.cxx:1173
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
#define HEADERBAR_ARROWOFF
Definition: headbar.cxx:52
virtual void Select()
Definition: headbar.cxx:1035
CommandEventId GetCommand() const
bool mbDragable
Definition: headbar.hxx:219
void SetTextColor(const Color &rColor)
Definition: text.cxx:666
void SetOffset(tools::Long nNewOffset)
Definition: headbar.cxx:1111
bool mbItemMode
Definition: headbar.hxx:224
bool IsInside(const Point &rPOINT) const
sal_uInt16 GetItemCount() const
Definition: headbar.cxx:1127
tools::Long mnDragSize
Definition: headbar.hxx:213
bool mbDrag
Definition: headbar.hxx:220
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.
void SetTop(tools::Long v)
void SetBottom(tools::Long v)
const AllSettings & GetSettings() const
Definition: outdev.hxx:417
Size GetOutputSizePixel() const
Definition: outdev.hxx:440
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: headbar.cxx:840
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:489
tools::Long Top() const
std::vector< std::unique_ptr< ImplHeadItem > > mvItemList
Definition: headbar.hxx:207
sal_uInt16 mnItemDragPos
Definition: headbar.hxx:218
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2804
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
void DrawPixel(const Point &rPt)
Definition: pixel.cxx:54
bool IsTrackingEnded() const
Definition: event.hxx:263
void RemoveItem(sal_uInt16 nItemId)
Definition: headbar.cxx:1069
tools::Long AdjustTop(tools::Long nVertMoveDelta)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: headbar.cxx:1016
virtual Size GetOptimalSize() const override
Definition: headbar.cxx:109
const Point & GetMousePosPixel() const
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:828
WinBits const WB_3DLOOK
Link< HeaderBar *, void > maStartDragHdl
Definition: headbar.hxx:225
#define HEAD_ARROWSIZE2
Definition: headbar.cxx:49
void SetPointer(PointerStyle)
Definition: mouse.cxx:474
VCL_DLLPRIVATE void ImplStartDrag(const Point &rPos, bool bCommand)
Definition: headbar.cxx:600
VCL_DLLPRIVATE void ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
Definition: headbar.cxx:128
virtual ~HeaderBar() override
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2918
virtual void Command(const CommandEvent &rCEvt) override
Definition: headbar.cxx:940
tools::Rectangle GetItemRect(sal_uInt16 nItemId) const
Definition: headbar.cxx:1161
const Color & GetButtonTextColor() const
WinBits const WB_BORDER
tools::Long GetItemSize(sal_uInt16 nItemId) const
Definition: headbar.cxx:1184
void SetFont(const vcl::Font &rNewFont)
bool IsVisible() const
Definition: window2.cxx:1102
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:903
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:553
bool IsLeft() const
Definition: event.hxx:146
tools::Long mnSize
Definition: headbar.cxx:40
void SetRasterOp(RasterOp eRasterOp)
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
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.
Definition: text.cxx:892
tools::Long Height() const
void MoveItem(sal_uInt16 nItemId, sal_uInt16 nNewPos)
Definition: headbar.cxx:1082
#define HEAD_ARROWSIZE1
Definition: headbar.cxx:48
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Point & GetPosPixel() const
Definition: event.hxx:120
#define HEAD_HITTEST_ITEM
Definition: headbar.cxx:57
tools::Long AdjustHeight(tools::Long n)
PointerStyle
Definition: ptrstyle.hxx:25
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:529
void setNumericVal(tools::Long nNumeric)
sal_uInt16 mnId
Definition: headbar.cxx:38
VCL_DLLPRIVATE void ImplUpdate(sal_uInt16 nPos, bool bEnd=false)
Definition: headbar.cxx:578
tools::Long mnBorderOff1
Definition: headbar.hxx:208
void setHeight(tools::Long nHeight)
tools::Long GetHeight() const
bool IsEnabled() const
Definition: window2.cxx:1122
bool IsTrackingCanceled() const
Definition: event.hxx:265
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Definition: window2.cxx:449
tools::Long mnMouseOff
Definition: headbar.hxx:216
bool mbButtonStyle
Definition: headbar.hxx:223
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2798
#define HEADERBAR_SPLITOFF
Definition: headbar.cxx:53
bool mbItemDrag
Definition: headbar.hxx:221
VCL_DLLPRIVATE void ImplEndDrag(bool bCancel)
Definition: headbar.cxx:744
virtual void DoubleClick()
Definition: headbar.cxx:1040
OUString maHelpText
Definition: headbar.cxx:45
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:259
void SetItemText(sal_uInt16 nItemId, const OUString &rText)
Definition: headbar.cxx:1216
static void DrawSelectionBackground(vcl::RenderContext &rRenderContext, vcl::Window const &rWindow, const tools::Rectangle &rRect, sal_uInt16 nHighlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color *pSelectionTextColor=nullptr, tools::Long nCornerRadius=0, Color const *pPaintColor=nullptr)
Definition: paint.cxx:323
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
#define WB_BOTTOMBORDER
Definition: headbar.hxx:176
#define HEADERBAR_ITEM_NOTFOUND
Definition: headbar.hxx:201
sal_Int32 nState
DrawImageFlags
Definition: outdev.hxx:170
aStr
tools::Long mnStartPos
Definition: headbar.hxx:214
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates and returns the accessible object of the header bar.
Definition: headbar.cxx:1284
tools::Long Right() const
VCL_DLLPRIVATE sal_uInt16 ImplHitTest(const Point &rPos, tools::Long &nMouseOff, sal_uInt16 &nPos) const
Definition: headbar.cxx:163
Link< HeaderBar *, void > maEndDragHdl
Definition: headbar.hxx:226
HeaderBarItemBits
Definition: headbar.hxx:180
Point Center() const
sal_uInt16 nPos
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
Definition: help.cxx:157
OString maHelpId
Definition: headbar.cxx:41
WinBits const WB_DRAG
sal_uInt32 mnSize
#define HEADERBAR_DRAGOUTOFF
Definition: headbar.cxx:55