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