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 ( 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 = false;
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 )
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  {
675  if ( (rMousePos.Y() >= aItemRect.Top()) && (rMousePos.Y() <= aItemRect.Bottom()) )
676  {
677  mbItemDrag = true;
678  Invalidate();
679  }
680  }
681 
682  sal_uInt16 nOldItemDragPos = mnItemDragPos;
683  if ( mbItemDrag )
684  {
685  bNewOutDrag = (rMousePos.Y() < -HEADERBAR_DRAGOUTOFF) || (rMousePos.Y() > mnDY+HEADERBAR_DRAGOUTOFF);
686 
687  if ( bNewOutDrag )
689  else
690  {
691  sal_uInt16 nTempId = GetItemId( Point( rMousePos.X(), 2 ) );
692  if ( nTempId )
693  mnItemDragPos = GetItemPos( nTempId );
694  else
695  {
696  if ( rMousePos.X() <= 0 )
697  mnItemDragPos = 0;
698  else
700  }
701  }
702 
703  if ( (mnItemDragPos != nOldItemDragPos) &&
704  (nOldItemDragPos != nPos) &&
705  (nOldItemDragPos != HEADERBAR_ITEM_NOTFOUND) )
706  {
707  ImplInvertDrag( nPos, nOldItemDragPos );
708  Invalidate();
709  }
710  }
711 
712  if ( bNewOutDrag != mbOutDrag )
713  Invalidate();
714 
715  if ( mbItemDrag )
716  {
717  if ( (mnItemDragPos != nOldItemDragPos) &&
718  (mnItemDragPos != nPos) &&
720  {
721  Invalidate();
722  ImplInvertDrag( nPos, mnItemDragPos );
723  }
724  }
725 
726  mbOutDrag = bNewOutDrag;
727  }
728  else
729  {
730  tools::Rectangle aItemRect = ImplGetItemRect( nPos );
731  if ( mnDragPos < aItemRect.Left() )
732  mnDragPos = aItemRect.Left();
733  if ( (mnDragPos < 0) || (mnDragPos > mnDX-1) )
734  HideTracking();
735  else
736  {
738  ShowTracking( aSizeRect, ShowTrackFlags::Split );
739  }
740  }
741 }
742 
743 void HeaderBar::ImplEndDrag( bool bCancel )
744 {
745  HideTracking();
746 
747  if ( bCancel || mbOutDrag )
748  {
749  if ( mbItemMode && (!mbOutDrag || mbItemDrag) )
750  {
751  Invalidate();
752  }
753 
754  mnCurItemId = 0;
755  }
756  else
757  {
758  sal_uInt16 nPos = GetItemPos( mnCurItemId );
759  if ( mbItemMode )
760  {
761  if ( mbItemDrag )
762  {
764  if ( (mnItemDragPos != nPos) &&
766  {
767  ImplInvertDrag( nPos, mnItemDragPos );
769  }
770  else
771  Invalidate();
772  }
773  else
774  {
775  Select();
776  ImplUpdate( nPos );
777  }
778  }
779  else
780  {
781  long nDelta = mnDragPos - mnStartPos;
782  if ( nDelta )
783  {
784  auto& pItem = mvItemList[ nPos ];
785  pItem->mnSize += nDelta;
786  ImplUpdate( nPos, true );
787  }
788  }
789  }
790 
791  mbDrag = false;
792  EndDrag();
793  mnCurItemId = 0;
795  mbOutDrag = false;
796  mbItemMode = false;
797  mbItemDrag = false;
798 }
799 
801 {
802  if ( !rMEvt.IsLeft() )
803  return;
804 
805  if ( rMEvt.GetClicks() == 2 )
806  {
807  long nTemp;
808  sal_uInt16 nPos;
809  sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp, nPos );
810  if ( nHitTest )
811  {
812  auto& pItem = mvItemList[ nPos ];
813  if ( nHitTest & HEAD_HITTEST_DIVIDER )
814  mbItemMode = false;
815  else
816  mbItemMode = true;
817  mnCurItemId = pItem->mnId;
818  DoubleClick();
819  mbItemMode = false;
820  mnCurItemId = 0;
821  }
822  }
823  else
824  ImplStartDrag( rMEvt.GetPosPixel(), false );
825 }
826 
827 void HeaderBar::MouseMove( const MouseEvent& rMEvt )
828 {
829  long nTemp1;
830  sal_uInt16 nTemp2;
832  sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp1, nTemp2 );
833 
834  if ( nHitTest & HEAD_HITTEST_DIVIDER )
835  eStyle = PointerStyle::HSizeBar;
836  SetPointer( eStyle );
837 }
838 
839 void HeaderBar::Tracking( const TrackingEvent& rTEvt )
840 {
841  Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
842 
843  if ( rTEvt.IsTrackingEnded() )
844  ImplEndDrag( rTEvt.IsTrackingCanceled() );
845  else
846  ImplDrag( aMousePos );
847 }
848 
849 void HeaderBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
850 {
851  if (mnBorderOff1 || mnBorderOff2)
852  {
853  rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
854  if (mnBorderOff1)
855  rRenderContext.DrawLine(Point(0, 0), Point(mnDX - 1, 0));
856  if (mnBorderOff2)
857  rRenderContext.DrawLine(Point(0, mnDY - 1), Point(mnDX - 1, mnDY - 1));
858  // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
859  if (mnBorderOff1 && mnBorderOff2)
860  {
861  rRenderContext.DrawLine(Point(0, 0), Point(0, mnDY - 1));
862  rRenderContext.DrawLine(Point(mnDX - 1, 0), Point(mnDX - 1, mnDY - 1));
863  }
864  }
865 
866  sal_uInt16 nCurItemPos;
867  if (mbDrag)
868  nCurItemPos = GetItemPos(mnCurItemId);
869  else
870  nCurItemPos = HEADERBAR_ITEM_NOTFOUND;
871  sal_uInt16 nItemCount = static_cast<sal_uInt16>(mvItemList.size());
872  for (sal_uInt16 i = 0; i < nItemCount; i++)
873  ImplDrawItem(rRenderContext, i, (i == nCurItemPos), &rRect);
874 }
875 
876 void HeaderBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
877  DrawFlags nFlags )
878 {
879  Point aPos = pDev->LogicToPixel( rPos );
880  Size aSize = pDev->LogicToPixel( rSize );
881  tools::Rectangle aRect( aPos, aSize );
882  vcl::Font aFont = GetDrawPixelFont( pDev );
883 
884  pDev->Push();
885  pDev->SetMapMode();
886  pDev->SetFont( aFont );
887  if ( nFlags & DrawFlags::Mono )
888  pDev->SetTextColor( COL_BLACK );
889  else
890  pDev->SetTextColor( GetTextColor() );
891  pDev->SetTextFillColor();
892 
893  // draw background
894  {
895  pDev->DrawWallpaper( aRect, GetBackground() );
896  if ( mnBorderOff1 || mnBorderOff2 )
897  {
898  pDev->SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
899  if ( mnBorderOff1 )
900  pDev->DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
901  if ( mnBorderOff2 )
902  pDev->DrawLine( Point( aRect.Left(), aRect.Bottom() ), Point( aRect.Right(), aRect.Bottom() ) );
903  // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
904  if ( mnBorderOff1 && mnBorderOff2 )
905  {
906  pDev->DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() ) );
907  pDev->DrawLine( Point( aRect.Right(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) );
908  }
909  }
910  }
911 
912  tools::Rectangle aItemRect( aRect );
913  size_t nItemCount = mvItemList.size();
914  for ( size_t i = 0; i < nItemCount; i++ )
915  {
916  aItemRect.SetLeft( aRect.Left()+ImplGetItemPos( i ) );
917  aItemRect.SetRight( aItemRect.Left() + mvItemList[ i ]->mnSize - 1 );
918  // check for overflow on some systems
919  if ( aItemRect.Right() > 16000 )
920  aItemRect.SetRight( 16000 );
921  vcl::Region aRegion( aRect );
922  pDev->SetClipRegion( aRegion );
923  ImplDrawItem(*pDev, i, false, aItemRect, &aRect );
924  pDev->SetClipRegion();
925  }
926 
927  pDev->Pop();
928 }
929 
931 {
932  Size aSize = GetOutputSizePixel();
933  if ( IsVisible() && (mnDY != aSize.Height()) )
934  Invalidate();
935  mnDX = aSize.Width();
936  mnDY = aSize.Height();
937 }
938 
939 void HeaderBar::Command( const CommandEvent& rCEvt )
940 {
941  if ( rCEvt.IsMouseEvent() && (rCEvt.GetCommand() == CommandEventId::StartDrag) && !mbDrag )
942  {
943  ImplStartDrag( rCEvt.GetMousePosPixel(), true );
944  return;
945  }
946 
947  Window::Command( rCEvt );
948 }
949 
950 void HeaderBar::RequestHelp( const HelpEvent& rHEvt )
951 {
952  sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
953  if ( nItemId )
954  {
956  {
957  tools::Rectangle aItemRect = GetItemRect( nItemId );
958  Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
959  aItemRect.SetLeft( aPt.X() );
960  aItemRect.SetTop( aPt.Y() );
961  aPt = OutputToScreenPixel( aItemRect.BottomRight() );
962  aItemRect.SetRight( aPt.X() );
963  aItemRect.SetBottom( aPt.Y() );
964 
965  OUString aStr = GetHelpText( nItemId );
966  if ( aStr.isEmpty() || !(rHEvt.GetMode() & HelpEventMode::BALLOON) )
967  {
968  auto& pItem = mvItemList[ GetItemPos( nItemId ) ];
969  // Quick-help is only displayed if the text is not fully visible.
970  // Otherwise we display Helptext only if the items do not contain text
971  if ( pItem->maOutText != pItem->maText )
972  aStr = pItem->maText;
973  else if (!pItem->maText.isEmpty())
974  aStr.clear();
975  }
976 
977  if (!aStr.isEmpty())
978  {
979  if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
980  Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
981  else
982  Help::ShowQuickHelp( this, aItemRect, aStr );
983  return;
984  }
985  }
986  }
987 
988  Window::RequestHelp( rHEvt );
989 }
990 
992 {
993  Window::StateChanged( nType );
994 
995  if ( nType == StateChangedType::Enable )
996  Invalidate();
997  else if ( (nType == StateChangedType::Zoom) ||
998  (nType == StateChangedType::ControlFont) )
999  {
1000  ImplInitSettings( true, false, false );
1001  Invalidate();
1002  }
1003  else if ( nType == StateChangedType::ControlForeground )
1004  {
1005  ImplInitSettings( false, true, false );
1006  Invalidate();
1007  }
1008  else if ( nType == StateChangedType::ControlBackground )
1009  {
1010  ImplInitSettings( false, false, true );
1011  Invalidate();
1012  }
1013 }
1014 
1016 {
1017  Window::DataChanged( rDCEvt );
1018 
1019  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1021  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1022  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1023  {
1024  ImplInitSettings( true, true, true );
1025  Invalidate();
1026  }
1027 }
1028 
1030 {
1031  maEndDragHdl.Call( this );
1032 }
1033 
1035 {
1036  maSelectHdl.Call( this );
1037 }
1038 
1040 {
1041 }
1042 
1043 void HeaderBar::InsertItem( sal_uInt16 nItemId, const OUString& rText,
1044  long nSize, HeaderBarItemBits nBits, sal_uInt16 nPos )
1045 {
1046  DBG_ASSERT( nItemId, "HeaderBar::InsertItem(): ItemId == 0" );
1048  "HeaderBar::InsertItem(): ItemId already exists" );
1049 
1050  // create item and insert in the list
1051  std::unique_ptr<ImplHeadItem> pItem(new ImplHeadItem);
1052  pItem->mnId = nItemId;
1053  pItem->mnBits = nBits;
1054  pItem->mnSize = nSize;
1055  pItem->maText = rText;
1056  if ( nPos < mvItemList.size() ) {
1057  auto it = mvItemList.begin();
1058  it += nPos;
1059  mvItemList.insert( it, std::move(pItem) );
1060  } else {
1061  mvItemList.push_back( std::move(pItem) );
1062  }
1063 
1064  // update display
1065  ImplUpdate( nPos, true );
1066 }
1067 
1068 void HeaderBar::RemoveItem( sal_uInt16 nItemId )
1069 {
1070  sal_uInt16 nPos = GetItemPos( nItemId );
1071  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1072  {
1073  if ( nPos < mvItemList.size() ) {
1074  auto it = mvItemList.begin();
1075  it += nPos;
1076  mvItemList.erase( it );
1077  }
1078  }
1079 }
1080 
1081 void HeaderBar::MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos )
1082 {
1083  sal_uInt16 nPos = GetItemPos( nItemId );
1084  if ( nPos == HEADERBAR_ITEM_NOTFOUND )
1085  return;
1086 
1087  if ( nPos == nNewPos )
1088  return;
1089 
1090  auto it = mvItemList.begin();
1091  it += nPos;
1092  std::unique_ptr<ImplHeadItem> pItem = std::move(*it);
1093  mvItemList.erase( it );
1094  if ( nNewPos < nPos )
1095  nPos = nNewPos;
1096  it = mvItemList.begin();
1097  it += nNewPos;
1098  mvItemList.insert( it, std::move(pItem) );
1099  ImplUpdate( nPos, true);
1100 }
1101 
1103 {
1104  // delete all items
1105  mvItemList.clear();
1106 
1107  ImplUpdate( 0, true );
1108 }
1109 
1110 void HeaderBar::SetOffset( long nNewOffset )
1111 {
1112  // move area
1114  long nDelta = mnOffset-nNewOffset;
1115  mnOffset = nNewOffset;
1116  Scroll( nDelta, 0, aRect );
1117 }
1118 
1119 sal_uInt16 HeaderBar::GetItemCount() const
1120 {
1121  return static_cast<sal_uInt16>(mvItemList.size());
1122 }
1123 
1124 sal_uInt16 HeaderBar::GetItemPos( sal_uInt16 nItemId ) const
1125 {
1126  for ( size_t i = 0, n = mvItemList.size(); i < n; ++i ) {
1127  auto& pItem = mvItemList[ i ];
1128  if ( pItem->mnId == nItemId )
1129  return static_cast<sal_uInt16>(i);
1130  }
1131  return HEADERBAR_ITEM_NOTFOUND;
1132 }
1133 
1134 sal_uInt16 HeaderBar::GetItemId( sal_uInt16 nPos ) const
1135 {
1136  ImplHeadItem* pItem = (nPos < mvItemList.size() ) ? mvItemList[ nPos ].get() : nullptr;
1137  if ( pItem )
1138  return pItem->mnId;
1139  else
1140  return 0;
1141 }
1142 
1143 sal_uInt16 HeaderBar::GetItemId( const Point& rPos ) const
1144 {
1145  for ( size_t i = 0, n = mvItemList.size(); i < n; ++i ) {
1146  if ( ImplGetItemRect( i ).IsInside( rPos ) ) {
1147  return GetItemId( i );
1148  }
1149  }
1150  return 0;
1151 }
1152 
1153 tools::Rectangle HeaderBar::GetItemRect( sal_uInt16 nItemId ) const
1154 {
1155  tools::Rectangle aRect;
1156  sal_uInt16 nPos = GetItemPos( nItemId );
1157  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1158  aRect = ImplGetItemRect( nPos );
1159  return aRect;
1160 }
1161 
1162 void HeaderBar::SetItemSize( sal_uInt16 nItemId, long nNewSize )
1163 {
1164  sal_uInt16 nPos = GetItemPos( nItemId );
1165  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1166  {
1167  auto& pItem = mvItemList[ nPos ];
1168  if ( pItem->mnSize != nNewSize )
1169  {
1170  pItem->mnSize = nNewSize;
1171  ImplUpdate( nPos, true );
1172  }
1173  }
1174 }
1175 
1176 long HeaderBar::GetItemSize( sal_uInt16 nItemId ) const
1177 {
1178  sal_uInt16 nPos = GetItemPos( nItemId );
1179  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1180  return mvItemList[ nPos ]->mnSize;
1181  else
1182  return 0;
1183 }
1184 
1185 void HeaderBar::SetItemBits( sal_uInt16 nItemId, HeaderBarItemBits nNewBits )
1186 {
1187  sal_uInt16 nPos = GetItemPos( nItemId );
1188  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1189  {
1190  auto& pItem = mvItemList[ nPos ];
1191  if ( pItem->mnBits != nNewBits )
1192  {
1193  pItem->mnBits = nNewBits;
1194  ImplUpdate( nPos );
1195  }
1196  }
1197 }
1198 
1199 HeaderBarItemBits HeaderBar::GetItemBits( sal_uInt16 nItemId ) const
1200 {
1201  sal_uInt16 nPos = GetItemPos( nItemId );
1202  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1203  return mvItemList[ nPos ]->mnBits;
1204  else
1205  return HeaderBarItemBits::NONE;
1206 }
1207 
1208 void HeaderBar::SetItemText( sal_uInt16 nItemId, const OUString& rText )
1209 {
1210  sal_uInt16 nPos = GetItemPos( nItemId );
1211  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1212  {
1213  mvItemList[ nPos ]->maText = rText;
1214  ImplUpdate( nPos );
1215  }
1216 }
1217 
1218 OUString HeaderBar::GetItemText( sal_uInt16 nItemId ) const
1219 {
1220  sal_uInt16 nPos = GetItemPos( nItemId );
1221  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1222  return mvItemList[ nPos ]->maText;
1223  return OUString();
1224 }
1225 
1226 OUString HeaderBar::GetHelpText( sal_uInt16 nItemId ) const
1227 {
1228  sal_uInt16 nPos = GetItemPos( nItemId );
1229  if ( nPos != HEADERBAR_ITEM_NOTFOUND )
1230  {
1231  auto& pItem = mvItemList[ nPos ];
1232  if ( pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty() )
1233  {
1234  Help* pHelp = Application::GetHelp();
1235  if ( pHelp )
1236  pItem->maHelpText = pHelp->GetHelpText( OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this );
1237  }
1238 
1239  return pItem->maHelpText;
1240  }
1241 
1242  return OUString();
1243 }
1244 
1246 {
1247  long nMaxImageSize = 0;
1248  Size aSize( 0, GetTextHeight() );
1249 
1250  for (auto& pItem : mvItemList)
1251  {
1252  // take image size into account
1253  long nImageHeight = pItem->maImage.GetSizePixel().Height();
1254  if ( !(pItem->mnBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)) && !pItem->maText.isEmpty() )
1255  nImageHeight += aSize.Height();
1256  if ( nImageHeight > nMaxImageSize )
1257  nMaxImageSize = nImageHeight;
1258 
1259  // add width
1260  aSize.AdjustWidth(pItem->mnSize );
1261  }
1262 
1263  if ( nMaxImageSize > aSize.Height() )
1264  aSize.setHeight( nMaxImageSize );
1265 
1266  // add border
1267  if ( mbButtonStyle )
1268  aSize.AdjustHeight(4 );
1269  else
1270  aSize.AdjustHeight(2 );
1272 
1273  return aSize;
1274 }
1275 
1276 css::uno::Reference< css::accessibility::XAccessible > HeaderBar::CreateAccessible()
1277 {
1278  if ( !mxAccessible.is() )
1279  {
1280  maCreateAccessibleHdl.Call( this );
1281 
1282  if ( !mxAccessible.is() )
1283  mxAccessible = Window::CreateAccessible();
1284  }
1285 
1286  return mxAccessible;
1287 }
1288 
1289 void HeaderBar::SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& _xAccessible )
1290 {
1291  mxAccessible = _xAccessible;
1292 }
1293 
1294 /* 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:781
const Color & GetShadowColor() const
VCL_DLLPRIVATE void ImplInit(WinBits nWinStyle)
Definition: headbar.cxx:59
virtual void Resize() override
Definition: headbar.cxx:930
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:1124
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:1029
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:222
OUString GetItemText(sal_uInt16 nItemId) const
Definition: headbar.cxx:1218
long AdjustWidth(long n)
css::uno::Reference< css::accessibility::XAccessible > mxAccessible
Definition: headbar.hxx:231
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:321
long Height() const
long mnDragPos
Definition: headbar.hxx:215
Definition: help.hxx:60
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1328
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:2057
VCL_DLLPRIVATE long ImplGetItemPos(sal_uInt16 nPos) const
Definition: headbar.cxx:144
long mnMouseOff
Definition: headbar.hxx:216
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:228
const Color & GetFaceColor() const
VCL_DLLPRIVATE tools::Rectangle ImplGetItemRect(sal_uInt16 nPos) const
Definition: headbar.cxx:152
long mnDragSize
Definition: headbar.hxx:213
const OUString & GetHelpText() const
Definition: window.cxx:3091
OUString maOutText
Definition: headbar.cxx:42
long mnSize
Definition: headbar.cxx:39
sal_Int64 n
void HideTracking()
Definition: window2.cxx:147
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1257
aBuf
void SetItemBits(sal_uInt16 nItemId, HeaderBarItemBits nNewBits)
Definition: headbar.cxx:1185
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: headbar.cxx:800
void SetTextFillColor()
Definition: text.cxx:699
void setTristateVal(ButtonValue nTristate)
OString const maHelpId
Definition: headbar.cxx:40
void Clear()
Definition: headbar.cxx:1102
DataChangedEventType GetType() const
Definition: event.hxx:348
void SetType(WindowType nType)
Definition: window2.cxx:963
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:227
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: headbar.cxx:876
long AdjustBottom(long nVertMoveDelta)
virtual void StateChanged(StateChangedType nStateChange) override
Definition: headbar.cxx:991
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: headbar.cxx:827
void DrawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWallpaper)
Definition: wallpaper.cxx:42
StateChangedType
Definition: window.hxx:311
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
int nCount
AllSettingsFlags GetFlags() const
Definition: event.hxx:349
const Color & GetLightColor() const
void SetItemSize(sal_uInt16 nItemId, long nNewSize)
Definition: headbar.cxx:1162
#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:1043
HeaderBarItemBits GetItemBits(sal_uInt16 nItemId) const
Definition: headbar.cxx:1199
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:1289
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: headbar.cxx:1134
Point BottomRight() const
const Color & GetDarkShadowColor() const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: headbar.cxx:849
void SetLineColor()
long mnBorderOff1
Definition: headbar.hxx:208
virtual OUString GetHelpText(const OUString &aHelpURL, const vcl::Window *pWindow)
Definition: help.cxx:67
Right
sal_uInt16 mnCurItemId
Definition: headbar.hxx:217
void SetTop(long v)
Size CalcWindowSizePixel() const
Definition: headbar.cxx:1245
#define DBG_ASSERT(sCon, aError)
DrawFlags
Definition: window.hxx:354
const vcl::Font & GetToolFont() const
HeaderBarItemBits mnBits
Definition: headbar.cxx:38
#define WB_BUTTONSTYLE
Definition: headbar.hxx:177
long mnDX
Definition: headbar.hxx:211
int i
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1160
void SetRight(long v)
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: headbar.cxx:950
bool IsUpdateMode() const
Definition: window2.cxx:1168
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:1034
CommandEventId GetCommand() const
bool mbDragable
Definition: headbar.hxx:219
void SetTextColor(const Color &rColor)
Definition: text.cxx:664
long Bottom() const
Image const maImage
Definition: headbar.cxx:41
bool mbItemMode
Definition: headbar.hxx:224
bool IsInside(const Point &rPOINT) const
sal_uInt16 GetItemCount() const
Definition: headbar.cxx:1119
bool mbDrag
Definition: headbar.hxx:220
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
long GetItemSize(sal_uInt16 nItemId) const
Definition: headbar.cxx:1176
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: headbar.cxx:839
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:207
sal_uInt16 mnItemDragPos
Definition: headbar.hxx:218
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:2821
long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:890
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
long X() const
bool IsTrackingEnded() const
Definition: event.hxx:254
void RemoveItem(sal_uInt16 nItemId)
Definition: headbar.cxx:1068
void SetOffset(long nNewOffset)
Definition: headbar.cxx:1110
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: headbar.cxx:1015
virtual Size GetOptimalSize() const override
Definition: headbar.cxx:108
const Point & GetMousePosPixel() const
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:934
WinBits const WB_3DLOOK
Link< HeaderBar *, void > maStartDragHdl
Definition: headbar.hxx:225
#define HEAD_ARROWSIZE2
Definition: headbar.cxx:48
void SetPointer(PointerStyle)
Definition: mouse.cxx:474
virtual void Scroll(long nHorzScroll, long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2941
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:210
virtual ~HeaderBar() override
virtual void Command(const CommandEvent &rCEvt) override
Definition: headbar.cxx:939
tools::Rectangle GetItemRect(sal_uInt16 nItemId) const
Definition: headbar.cxx:1153
const Color & GetButtonTextColor() const
WinBits const WB_BORDER
void SetFont(const vcl::Font &rNewFont)
bool IsVisible() const
Definition: window2.cxx:1097
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:40
long mnBorderOff2
Definition: headbar.hxx:209
void SetBottom(long v)
void MoveItem(sal_uInt16 nItemId, sal_uInt16 nNewPos)
Definition: headbar.cxx:1081
long AdjustTop(long nVertMoveDelta)
#define HEAD_ARROWSIZE1
Definition: headbar.cxx:47
const Point & GetPosPixel() const
Definition: event.hxx:117
long mnStartPos
Definition: headbar.hxx:214
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:879
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:1117
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:223
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2815
#define HEADERBAR_SPLITOFF
Definition: headbar.cxx:52
bool mbItemDrag
Definition: headbar.hxx:221
VCL_DLLPRIVATE void ImplEndDrag(bool bCancel)
Definition: headbar.cxx:743
virtual void DoubleClick()
Definition: headbar.cxx:1039
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:1208
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
#define WB_BOTTOMBORDER
Definition: headbar.hxx:176
void setWidth(long nWidth)
#define HEADERBAR_ITEM_NOTFOUND
Definition: headbar.hxx:201
sal_Int32 nState
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:1276
Link< HeaderBar *, void > maEndDragHdl
Definition: headbar.hxx:226
HeaderBarItemBits
Definition: headbar.hxx:180
Point Center() const
long Y() const
sal_uInt16 nPos
long mnDY
Definition: headbar.hxx:212
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
Definition: help.cxx:157
WinBits const WB_DRAG
void setHeight(long nHeight)
#define HEADERBAR_DRAGOUTOFF
Definition: headbar.cxx:54