LibreOffice Module vcl (master)  1
calendar.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/svapp.hxx>
21 #include <vcl/help.hxx>
22 #include <vcl/menu.hxx>
23 #include <vcl/settings.hxx>
24 #include <vcl/event.hxx>
25 #include <vcl/toolkit/calendar.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/dockwin.hxx>
30 #include <com/sun/star/i18n/Weekdays.hpp>
31 #include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
32 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
33 #include <sal/log.hxx>
34 
35 #include <calendar.hxx>
36 #include <svdata.hxx>
37 #include <strings.hrc>
38 #include <memory>
39 
40 #define DAY_OFFX 4
41 #define DAY_OFFY 2
42 #define MONTH_BORDERX 4
43 #define MONTH_OFFY 3
44 #define WEEKDAY_OFFY 3
45 #define TITLE_OFFY 3
46 #define TITLE_BORDERY 2
47 #define SPIN_OFFX 4
48 #define SPIN_OFFY TITLE_BORDERY
49 
50 #define CALENDAR_HITTEST_DAY (sal_uInt16(0x0001))
51 #define CALENDAR_HITTEST_MONTHTITLE (sal_uInt16(0x0004))
52 #define CALENDAR_HITTEST_PREV (sal_uInt16(0x0008))
53 #define CALENDAR_HITTEST_NEXT (sal_uInt16(0x0010))
54 
55 #define MENU_YEAR_COUNT 3
56 
57 using namespace ::com::sun::star;
58 
59 static void ImplCalendarSelectDate( IntDateSet* pTable, const Date& rDate, bool bSelect )
60 {
61  if ( bSelect )
62  pTable->insert( rDate.GetDate() );
63  else
64  pTable->erase( rDate.GetDate() );
65 }
66 
67 
68 
69 void Calendar::ImplInit( WinBits nWinStyle )
70 {
71  mpSelectTable.reset(new IntDateSet);
72  mnDayCount = 0;
73  mnWinStyle = nWinStyle;
74  mnFirstYear = 0;
75  mnLastYear = 0;
76  mbCalc = true;
77  mbFormat = true;
78  mbDrag = false;
79  mbMenuDown = false;
80  mbSpinDown = false;
81  mbPrevIn = false;
82  mbNextIn = false;
83 
84  OUString aGregorian( "gregorian");
85  maCalendarWrapper.loadCalendar( aGregorian,
87  if (maCalendarWrapper.getUniqueID() != aGregorian)
88  {
89  SAL_WARN( "vcl.control", "Calendar::ImplInit: No ``gregorian'' calendar available for locale ``"
91  << "'' and other calendars aren't supported. Using en-US fallback." );
92 
93  /* If we ever wanted to support other calendars than Gregorian a lot of
94  * rewrite would be necessary to internally replace use of class Date
95  * with proper class CalendarWrapper methods, get rid of fixed 12
96  * months, fixed 7 days, ... */
97  maCalendarWrapper.loadCalendar( aGregorian, lang::Locale( "en", "US", ""));
98  }
99 
102 
103  // Sonstige Strings erzeugen
104  maDayText = VclResId(STR_SVT_CALENDAR_DAY);
105  maWeekText = VclResId(STR_SVT_CALENDAR_WEEK);
106 
107  // Tagestexte anlegen
108  for (sal_Int32 i = 0; i < 31; ++i)
109  maDayTexts[i] = OUString::number(i+1);
110 
112 }
113 
115 {
116  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
117  maSelColor = rStyleSettings.GetHighlightTextColor();
118  SetPointFont(rRenderContext, rStyleSettings.GetToolFont());
119  rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
120  rRenderContext.SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
121 }
122 
124 {
125  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
126  maSelColor = rStyleSettings.GetHighlightTextColor();
127  SetPointFont(*this, rStyleSettings.GetToolFont());
128  SetTextColor(rStyleSettings.GetFieldTextColor());
129  SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
130 }
131 
132 Calendar::Calendar( vcl::Window* pParent, WinBits nWinStyle ) :
133  Control( pParent, nWinStyle & (WB_TABSTOP | WB_GROUP | WB_BORDER | WB_3DLOOK) ),
134  maCalendarWrapper( Application::GetAppLocaleDataWrapper().getComponentContext() ),
135  maOldFormatFirstDate( 0, 0, 1900 ),
136  maOldFormatLastDate( 0, 0, 1900 ),
137  maFirstDate( 0, 0, 1900 ),
138  maOldFirstDate( 0, 0, 1900 ),
139  maCurDate( Date::SYSTEM ),
140  maOldCurDate( 0, 0, 1900 )
141 {
142  ImplInit( nWinStyle );
143 }
144 
146 {
147  disposeOnce();
148 }
149 
151 {
152  mpSelectTable.reset();
153  mpOldSelectTable.reset();
155 }
156 
158 {
159  // Map i18n::Weekdays to Date DayOfWeek
160  DayOfWeek eDay;
161  sal_Int16 nDay = maCalendarWrapper.getFirstDayOfWeek();
162  switch (nDay)
163  {
164  case i18n::Weekdays::SUNDAY :
165  eDay = SUNDAY;
166  break;
167  case i18n::Weekdays::MONDAY :
168  eDay = MONDAY;
169  break;
170  case i18n::Weekdays::TUESDAY :
171  eDay = TUESDAY;
172  break;
173  case i18n::Weekdays::WEDNESDAY :
174  eDay = WEDNESDAY;
175  break;
176  case i18n::Weekdays::THURSDAY :
177  eDay = THURSDAY;
178  break;
179  case i18n::Weekdays::FRIDAY :
180  eDay = FRIDAY;
181  break;
182  case i18n::Weekdays::SATURDAY :
183  eDay = SATURDAY;
184  break;
185  default:
186  SAL_WARN( "vcl.control", "Calendar::ImplGetWeekStart: broken i18n Gregorian calendar (getFirstDayOfWeek())");
187  eDay = SUNDAY;
188  }
189  return eDay;
190 }
191 
193 {
194  if ( !mbFormat )
195  return;
196 
197  if ( mbCalc )
198  {
199  Size aOutSize = GetOutputSizePixel();
200 
201  if ( (aOutSize.Width() <= 1) || (aOutSize.Height() <= 1) )
202  return;
203 
204  long n99TextWidth = GetTextWidth( "99" );
205  long nTextHeight = GetTextHeight();
206 
207  // calculate width and x-position
208  mnDayWidth = n99TextWidth+DAY_OFFX;
211  mnMonthPerLine = aOutSize.Width() / mnMonthWidth;
212  if ( !mnMonthPerLine )
213  mnMonthPerLine = 1;
214  long nOver = (aOutSize.Width()-(mnMonthPerLine*mnMonthWidth)) / mnMonthPerLine;
215  mnMonthWidth += nOver;
217  mnDaysOffX += nOver/2;
218 
219  // calculate height and y-position
220  mnDayHeight = nTextHeight + DAY_OFFY;
221  mnWeekDayOffY = nTextHeight + TITLE_OFFY + (TITLE_BORDERY*2);
222  mnDaysOffY = mnWeekDayOffY + nTextHeight + WEEKDAY_OFFY;
223  mnMonthHeight = (mnDayHeight*6) + mnDaysOffY;
225  mnLines = aOutSize.Height() / mnMonthHeight;
226  if ( !mnLines )
227  mnLines = 1;
228  mnMonthHeight += (aOutSize.Height()-(mnLines*mnMonthHeight)) / mnLines;
229 
230  // calculate spinfields
231  long nSpinSize = nTextHeight+TITLE_BORDERY-SPIN_OFFY;
233  maPrevRect.SetTop( SPIN_OFFY );
234  maPrevRect.SetRight( maPrevRect.Left()+nSpinSize );
235  maPrevRect.SetBottom( maPrevRect.Top()+nSpinSize );
236  maNextRect.SetLeft( aOutSize.Width()-SPIN_OFFX-nSpinSize-1 );
237  maNextRect.SetTop( SPIN_OFFY );
238  maNextRect.SetRight( maNextRect.Left()+nSpinSize );
239  maNextRect.SetBottom( maNextRect.Top()+nSpinSize );
240 
241  // Calculate DayOfWeekText (gets displayed in a narrow font)
242  maDayOfWeekText.clear();
243  long nStartOffX = 0;
244  sal_Int16 nDay = maCalendarWrapper.getFirstDayOfWeek();
245  for ( sal_Int16 nDayOfWeek = 0; nDayOfWeek < 7; nDayOfWeek++ )
246  {
247  // Use narrow name.
248  OUString aDayOfWeek( maCalendarWrapper.getDisplayName(
249  i18n::CalendarDisplayIndex::DAY, nDay, 2));
250  long nOffX = (mnDayWidth-GetTextWidth( aDayOfWeek ))/2;
251  if ( !nDayOfWeek )
252  nStartOffX = nOffX;
253  else
254  nOffX -= nStartOffX;
255  nOffX += nDayOfWeek * mnDayWidth;
256  mnDayOfWeekAry[nDayOfWeek] = nOffX;
257  maDayOfWeekText += aDayOfWeek;
258  nDay++;
259  nDay %= 7;
260  }
261 
262  mbCalc = false;
263  }
264 
265  // calculate number of days
266 
267  DayOfWeek eStartDay = ImplGetWeekStart();
268 
269  sal_uInt16 nWeekDay;
270  Date aTempDate = GetFirstMonth();
271  maFirstDate = aTempDate;
272  nWeekDay = static_cast<sal_uInt16>(aTempDate.GetDayOfWeek());
273  nWeekDay = (nWeekDay+(7-static_cast<sal_uInt16>(eStartDay))) % 7;
274  maFirstDate.AddDays( -nWeekDay );
275  mnDayCount = nWeekDay;
276  sal_uInt16 nDaysInMonth;
277  sal_uInt16 nMonthCount = static_cast<sal_uInt16>(mnMonthPerLine*mnLines);
278  for ( sal_uInt16 i = 0; i < nMonthCount; i++ )
279  {
280  nDaysInMonth = aTempDate.GetDaysInMonth();
281  mnDayCount += nDaysInMonth;
282  aTempDate.AddDays( nDaysInMonth );
283  }
284  Date aTempDate2 = aTempDate;
285  --aTempDate2;
286  nDaysInMonth = aTempDate2.GetDaysInMonth();
287  aTempDate2.AddDays( -(nDaysInMonth-1) );
288  nWeekDay = static_cast<sal_uInt16>(aTempDate2.GetDayOfWeek());
289  nWeekDay = (nWeekDay+(7-static_cast<sal_uInt16>(eStartDay))) % 7;
290  mnDayCount += 42-nDaysInMonth-nWeekDay;
291 
292  // determine colours
294  if ( maOtherColor.IsRGBEqual( GetBackground().GetColor() ) )
296 
297  Date aLastDate = GetLastDate();
298  if ( (maOldFormatLastDate != aLastDate) ||
300  {
302  maOldFormatLastDate = aLastDate;
303  }
304 
305  // get DateInfo
306  sal_Int16 nNewFirstYear = maFirstDate.GetYear();
307  sal_Int16 nNewLastYear = GetLastDate().GetYear();
308  if ( mnFirstYear )
309  {
310  if ( nNewFirstYear < mnFirstYear )
311  {
312  mnFirstYear = nNewFirstYear;
313  }
314  if ( nNewLastYear > mnLastYear )
315  {
316  mnLastYear = nNewLastYear;
317  }
318  }
319  else
320  {
321  mnFirstYear = nNewFirstYear;
322  mnLastYear = nNewLastYear;
323  }
324 
325  mbFormat = false;
326 }
327 
328 sal_uInt16 Calendar::ImplHitTest( const Point& rPos, Date& rDate ) const
329 {
330  if ( mbFormat )
331  return 0;
332 
333  if ( maPrevRect.IsInside( rPos ) )
334  return CALENDAR_HITTEST_PREV;
335  else if ( maNextRect.IsInside( rPos ) )
336  return CALENDAR_HITTEST_NEXT;
337 
338  long nY;
339  long nOffX;
340  sal_Int32 nDay;
341  DayOfWeek eStartDay = ImplGetWeekStart();
342 
343  rDate = GetFirstMonth();
344  nY = 0;
345  for ( long i = 0; i < mnLines; i++ )
346  {
347  if ( rPos.Y() < nY )
348  return 0;
349 
350  long nX = 0;
351  long nYMonth = nY+mnMonthHeight;
352  for ( long j = 0; j < mnMonthPerLine; j++ )
353  {
354  if ( (rPos.X() < nX) && (rPos.Y() < nYMonth) )
355  return 0;
356 
357  sal_uInt16 nDaysInMonth = rDate.GetDaysInMonth();
358 
359  // matching month was found
360  if ( (rPos.X() > nX) && (rPos.Y() < nYMonth) &&
361  (rPos.X() < nX+mnMonthWidth) )
362  {
363  if ( rPos.Y() < (nY+(TITLE_BORDERY*2)+mnDayHeight))
365  else
366  {
367  long nDayX = nX+mnDaysOffX;
368  long nDayY = nY+mnDaysOffY;
369  if ( rPos.Y() < nDayY )
370  return 0;
371  sal_Int32 nDayIndex = static_cast<sal_Int32>(rDate.GetDayOfWeek());
372  nDayIndex = (nDayIndex+(7-static_cast<sal_Int32>(eStartDay))) % 7;
373  if ( (i == 0) && (j == 0) )
374  {
375  Date aTempDate = rDate;
376  aTempDate.AddDays( -nDayIndex );
377  for ( nDay = 0; nDay < nDayIndex; nDay++ )
378  {
379  nOffX = nDayX + (nDay*mnDayWidth);
380  if ( (rPos.Y() >= nDayY) && (rPos.Y() < nDayY+mnDayHeight) &&
381  (rPos.X() >= nOffX) && (rPos.X() < nOffX+mnDayWidth) )
382  {
383  rDate = aTempDate;
384  rDate.AddDays( nDay );
385  return CALENDAR_HITTEST_DAY;
386  }
387  }
388  }
389  for ( nDay = 1; nDay <= nDaysInMonth; nDay++ )
390  {
391  if ( rPos.Y() < nDayY )
392  {
393  rDate.AddDays( nDayIndex );
394  return 0;
395  }
396  nOffX = nDayX + (nDayIndex*mnDayWidth);
397  if ( (rPos.Y() >= nDayY) && (rPos.Y() < nDayY+mnDayHeight) &&
398  (rPos.X() >= nOffX) && (rPos.X() < nOffX+mnDayWidth) )
399  {
400  rDate.AddDays( nDay-1 );
401  return CALENDAR_HITTEST_DAY;
402  }
403  if ( nDayIndex == 6 )
404  {
405  nDayIndex = 0;
406  nDayY += mnDayHeight;
407  }
408  else
409  nDayIndex++;
410  }
411  if ( (i == mnLines-1) && (j == mnMonthPerLine-1) )
412  {
413  sal_uInt16 nWeekDay = static_cast<sal_uInt16>(rDate.GetDayOfWeek());
414  nWeekDay = (nWeekDay+(7-static_cast<sal_uInt16>(eStartDay))) % 7;
415  sal_Int32 nDayCount = 42-nDaysInMonth-nWeekDay;
416  Date aTempDate = rDate;
417  aTempDate.AddDays( nDaysInMonth );
418  for ( nDay = 1; nDay <= nDayCount; nDay++ )
419  {
420  if ( rPos.Y() < nDayY )
421  {
422  rDate.AddDays( nDayIndex );
423  return 0;
424  }
425  nOffX = nDayX + (nDayIndex*mnDayWidth);
426  if ( (rPos.Y() >= nDayY) && (rPos.Y() < nDayY+mnDayHeight) &&
427  (rPos.X() >= nOffX) && (rPos.X() < nOffX+mnDayWidth) )
428  {
429  rDate = aTempDate;
430  rDate.AddDays( nDay-1 );
431  return CALENDAR_HITTEST_DAY;
432  }
433  if ( nDayIndex == 6 )
434  {
435  nDayIndex = 0;
436  nDayY += mnDayHeight;
437  }
438  else
439  nDayIndex++;
440  }
441  }
442  }
443  }
444 
445  rDate.AddDays( nDaysInMonth );
446  nX += mnMonthWidth;
447  }
448 
449  nY += mnMonthHeight;
450  }
451 
452  return 0;
453 }
454 
455 namespace
456 {
457 
458 void ImplDrawSpinArrow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, bool bPrev)
459 {
460  long i;
461  long n;
462  long nLines;
463  long nHeight = rRect.GetHeight();
464  long nWidth = rRect.GetWidth();
465  if (nWidth < nHeight)
466  n = nWidth;
467  else
468  n = nHeight;
469  if (!(n & 0x01))
470  n--;
471  nLines = n/2;
472 
473  tools::Rectangle aRect(Point( rRect.Left() + (nWidth / 2) - (nLines / 2),
474  rRect.Top() + (nHeight / 2) ),
475  Size(1, 1));
476  if (!bPrev)
477  {
478  aRect.AdjustLeft(nLines );
479  aRect.AdjustRight(nLines );
480  }
481 
482  rRenderContext.DrawRect(aRect);
483  for (i = 0; i < nLines; i++)
484  {
485  if (bPrev)
486  {
487  aRect.AdjustLeft( 1 );
488  aRect.AdjustRight( 1 );
489  }
490  else
491  {
492  aRect.AdjustLeft( -1 );
493  aRect.AdjustRight( -1 );
494  }
495  aRect.AdjustTop( -1 );
496  aRect.AdjustBottom( 1 );
497  rRenderContext.DrawRect(aRect);
498  }
499 }
500 
501 } //end anonymous namespace
502 
504 {
505  rRenderContext.SetLineColor();
506  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetButtonTextColor());
507  tools::Rectangle aOutRect = maPrevRect;
508  aOutRect.AdjustLeft(3 );
509  aOutRect.AdjustTop(3 );
510  aOutRect.AdjustRight( -3 );
511  aOutRect.AdjustBottom( -3 );
512  ImplDrawSpinArrow(rRenderContext, aOutRect, true);
513  aOutRect = maNextRect;
514  aOutRect.AdjustLeft(3 );
515  aOutRect.AdjustTop(3 );
516  aOutRect.AdjustRight( -3 );
517  aOutRect.AdjustBottom( -3 );
518  ImplDrawSpinArrow(rRenderContext, aOutRect, false);
519 }
520 
522  long nX, long nY,
523  sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear,
524  bool bOther, sal_Int32 nToday )
525 {
526  Color const * pTextColor = nullptr;
527  const OUString& rDay = maDayTexts[nDay - 1];
528  tools::Rectangle aDateRect(nX, nY, nX + mnDayWidth - 1, nY + mnDayHeight - 1);
529 
530  bool bSel = false;
531  bool bFocus = false;
532  // actual day
533  if ((nDay == maCurDate.GetDay()) &&
534  (nMonth == maCurDate.GetMonth()) &&
535  (nYear == maCurDate.GetYear()))
536  {
537  bFocus = true;
538  }
539  if (mpSelectTable)
540  {
541  if (mpSelectTable->find(Date(nDay, nMonth, nYear).GetDate()) != mpSelectTable->end())
542  bSel = true;
543  }
544 
545  // get textcolour
546  if (bSel)
547  pTextColor = &maSelColor;
548  else if (bOther)
549  pTextColor = &maOtherColor;
550 
551  if (bFocus)
552  HideFocus();
553 
554  // display background
555  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
556  if (bSel)
557  {
558  rRenderContext.SetLineColor();
559  rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
560  rRenderContext.DrawRect(aDateRect);
561  }
562 
563  // display text
564  long nTextX = nX + (mnDayWidth - GetTextWidth(rDay)) - (DAY_OFFX / 2);
565  long nTextY = nY + (mnDayHeight - GetTextHeight()) / 2;
566  if (pTextColor)
567  {
568  Color aOldColor = rRenderContext.GetTextColor();
569  rRenderContext.SetTextColor(*pTextColor);
570  rRenderContext.DrawText(Point(nTextX, nTextY), rDay);
571  rRenderContext.SetTextColor(aOldColor);
572  }
573  else
574  rRenderContext.DrawText(Point(nTextX, nTextY), rDay);
575 
576  // today
577  Date aTodayDate(maCurDate);
578  if (nToday)
579  aTodayDate.SetDate(nToday);
580  else
581  aTodayDate = Date(Date::SYSTEM);
582  if ((nDay == aTodayDate.GetDay()) &&
583  (nMonth == aTodayDate.GetMonth()) &&
584  (nYear == aTodayDate.GetYear()))
585  {
586  rRenderContext.SetLineColor(rStyleSettings.GetWindowTextColor());
587  rRenderContext.SetFillColor();
588  rRenderContext.DrawRect(aDateRect);
589  }
590 
591  // if needed do FocusRect
592  if (bFocus && HasFocus())
593  ShowFocus(aDateRect);
594 }
595 
597 {
598  ImplFormat();
599 
600  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
601  Size aOutSize(GetOutputSizePixel());
602  long i;
603  long j;
604  long nY;
605  long nDeltaX;
606  long nDeltaY;
607  long nDayX;
608  long nDayY;
609  sal_Int32 nToday = Date(Date::SYSTEM).GetDate();
610  sal_uInt16 nDay;
611  sal_uInt16 nMonth;
612  sal_Int16 nYear;
613  Date aDate = GetFirstMonth();
614  DayOfWeek eStartDay = ImplGetWeekStart();
615 
616  HideFocus();
617 
618  nY = 0;
619  for (i = 0; i < mnLines; i++)
620  {
621  // display title bar
622  rRenderContext.SetLineColor();
623  rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
624  tools::Rectangle aTitleRect(0, nY, aOutSize.Width() - 1, nY + mnDayHeight - DAY_OFFY + TITLE_BORDERY * 2);
625  rRenderContext.DrawRect(aTitleRect);
626  Point aTopLeft1(aTitleRect.Left(), aTitleRect.Top());
627  Point aTopLeft2(aTitleRect.Left(), aTitleRect.Top() + 1);
628  Point aBottomRight1(aTitleRect.Right(), aTitleRect.Bottom());
629  Point aBottomRight2(aTitleRect.Right(), aTitleRect.Bottom() - 1);
630  rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
631  rRenderContext.DrawLine(aTopLeft1, Point(aBottomRight1.X(), aTopLeft1.Y()));
632  rRenderContext.SetLineColor(rStyleSettings.GetLightColor() );
633  rRenderContext.DrawLine(aTopLeft2, Point(aBottomRight2.X(), aTopLeft2.Y()));
634  rRenderContext.DrawLine(aTopLeft2, Point(aTopLeft2.X(), aBottomRight2.Y()));
635  rRenderContext.SetLineColor(rStyleSettings.GetShadowColor() );
636  rRenderContext.DrawLine(Point(aTopLeft2.X(), aBottomRight2.Y()), aBottomRight2);
637  rRenderContext.DrawLine(Point(aBottomRight2.X(), aTopLeft2.Y()), aBottomRight2);
638  rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
639  rRenderContext.DrawLine(Point(aTopLeft1.X(), aBottomRight1.Y()), aBottomRight1);
640  Point aSepPos1(0, aTitleRect.Top() + TITLE_BORDERY);
641  Point aSepPos2(0, aTitleRect.Bottom() - TITLE_BORDERY);
642  for (j = 0; j < mnMonthPerLine-1; j++)
643  {
644  aSepPos1.AdjustX(mnMonthWidth-1 );
645  aSepPos2.setX( aSepPos1.X() );
646  rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
647  rRenderContext.DrawLine(aSepPos1, aSepPos2);
648  aSepPos1.AdjustX( 1 );
649  aSepPos2.setX( aSepPos1.X() );
650  rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
651  rRenderContext.DrawLine(aSepPos1, aSepPos2);
652  }
653 
654  long nX = 0;
655  for (j = 0; j < mnMonthPerLine; j++)
656  {
657  nMonth = aDate.GetMonth();
658  nYear = aDate.GetYear();
659 
660  // display month in title bar
661  nDeltaX = nX;
662  nDeltaY = nY + TITLE_BORDERY;
663  OUString aMonthText = maCalendarWrapper.getDisplayName(i18n::CalendarDisplayIndex::MONTH, nMonth - 1, 1)
664  + " "
665  + OUString::number(nYear);
666  long nMonthTextWidth = rRenderContext.GetTextWidth(aMonthText);
667  long nMonthOffX1 = 0;
668  long nMonthOffX2 = 0;
669  if (i == 0)
670  {
671  if (j == 0)
672  nMonthOffX1 = maPrevRect.Right() + 1;
673  if (j == mnMonthPerLine - 1)
674  nMonthOffX2 = aOutSize.Width() - maNextRect.Left() + 1;
675  }
676  long nMaxMonthWidth = mnMonthWidth - nMonthOffX1 - nMonthOffX2 - 4;
677  if (nMonthTextWidth > nMaxMonthWidth)
678  {
679  // Abbreviated month name.
680  aMonthText = maCalendarWrapper.getDisplayName(i18n::CalendarDisplayIndex::MONTH, nMonth - 1, 0)
681  + " "
682  + OUString::number(nYear);
683  nMonthTextWidth = rRenderContext.GetTextWidth(aMonthText);
684  }
685  long nTempOff = (mnMonthWidth - nMonthTextWidth + 1) / 2;
686  if (nTempOff < nMonthOffX1)
687  nDeltaX += nMonthOffX1 + 1;
688  else
689  {
690  if (nTempOff + nMonthTextWidth > mnMonthWidth - nMonthOffX2)
691  nDeltaX += mnMonthWidth - nMonthOffX2 - nMonthTextWidth;
692  else
693  nDeltaX += nTempOff;
694  }
695  rRenderContext.SetTextColor(rStyleSettings.GetButtonTextColor());
696  rRenderContext.DrawText(Point(nDeltaX, nDeltaY), aMonthText);
697  rRenderContext.SetTextColor(rStyleSettings.GetWindowTextColor());
698 
699  // display week bar
700  nDayX = nX + mnDaysOffX;
701  nDayY = nY + mnWeekDayOffY;
702  nDeltaY = nDayY + mnDayHeight;
703  rRenderContext.SetLineColor(rStyleSettings.GetWindowTextColor());
704  Point aStartPos(nDayX, nDeltaY);
705  rRenderContext.DrawLine(aStartPos, Point(nDayX + (7 * mnDayWidth), nDeltaY));
706  rRenderContext.DrawTextArray(Point(nDayX + mnDayOfWeekAry[0], nDayY), maDayOfWeekText, &(mnDayOfWeekAry[1]));
707 
708  // display days
709  sal_uInt16 nDaysInMonth = aDate.GetDaysInMonth();
710  nDayX = nX + mnDaysOffX;
711  nDayY = nY + mnDaysOffY;
712  sal_uInt16 nDayIndex = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
713  nDayIndex = (nDayIndex + (7 - static_cast<sal_uInt16>(eStartDay))) % 7;
714  if (i == 0 && j == 0)
715  {
716  Date aTempDate = aDate;
717  aTempDate.AddDays( -nDayIndex );
718  for (nDay = 0; nDay < nDayIndex; ++nDay)
719  {
720  nDeltaX = nDayX + (nDay * mnDayWidth);
721  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay + aTempDate.GetDay(),
722  aTempDate.GetMonth(), aTempDate.GetYear(),
723  true, nToday);
724  }
725  }
726  for (nDay = 1; nDay <= nDaysInMonth; nDay++)
727  {
728  nDeltaX = nDayX + (nDayIndex * mnDayWidth);
729  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay, nMonth, nYear,
730  false, nToday);
731  if (nDayIndex == 6)
732  {
733  nDayIndex = 0;
734  nDayY += mnDayHeight;
735  }
736  else
737  nDayIndex++;
738  }
739  if ((i == mnLines - 1) && (j == mnMonthPerLine - 1))
740  {
741  sal_uInt16 nWeekDay = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
742  nWeekDay = (nWeekDay + (7 - static_cast<sal_uInt16>(eStartDay))) % 7;
743  sal_uInt16 nDayCount = 42 - nDaysInMonth - nWeekDay;
744  Date aTempDate = aDate;
745  aTempDate.AddDays( nDaysInMonth );
746  for (nDay = 1; nDay <= nDayCount; ++nDay)
747  {
748  nDeltaX = nDayX + (nDayIndex * mnDayWidth);
749  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay,
750  aTempDate.GetMonth(), aTempDate.GetYear(),
751  true, nToday);
752  if (nDayIndex == 6)
753  {
754  nDayIndex = 0;
755  nDayY += mnDayHeight;
756  }
757  else
758  nDayIndex++;
759  }
760  }
761 
762  aDate.AddDays( nDaysInMonth );
763  nX += mnMonthWidth;
764  }
765 
766  nY += mnMonthHeight;
767  }
768 
769  // draw spin buttons
770  ImplDrawSpin(rRenderContext);
771 }
772 
773 void Calendar::ImplUpdateDate( const Date& rDate )
774 {
775  if (IsReallyVisible() && IsUpdateMode())
776  {
777  tools::Rectangle aDateRect(GetDateRect(rDate));
778  if (!aDateRect.IsEmpty())
779  {
780  Invalidate(aDateRect);
781  }
782  }
783 }
784 
786 {
787  IntDateSet* pNew = mpSelectTable.get();
788 
789  for (auto const& nKey : *pOld)
790  {
791  if ( pNew->find(nKey) == pNew->end() )
792  {
793  Date aTempDate(nKey);
794  ImplUpdateDate(aTempDate);
795  }
796  }
797 
798  for (auto const& nKey : *pNew)
799  {
800  if ( pOld->find(nKey) == pOld->end() )
801  {
802  Date aTempDate(nKey);
803  ImplUpdateDate(aTempDate);
804  }
805  }
806 }
807 
808 void Calendar::ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest )
809 {
810  std::unique_ptr<IntDateSet> pOldSel(new IntDateSet( *mpSelectTable ));
811  Date aOldDate = maCurDate;
812  Date aTempDate = rDate;
813 
814  if ( !(nHitTest & CALENDAR_HITTEST_DAY) )
815  --aTempDate;
816 
817  if ( !(nHitTest & CALENDAR_HITTEST_DAY) )
818  aTempDate = maOldCurDate;
819  if ( aTempDate != maCurDate )
820  {
821  maCurDate = aTempDate;
822  ImplCalendarSelectDate( mpSelectTable.get(), aOldDate, false );
824  }
825 
826  bool bNewSel = *pOldSel != *mpSelectTable;
827  if ( (maCurDate != aOldDate) || bNewSel )
828  {
829  HideFocus();
830  if ( bNewSel )
831  ImplUpdateSelection( pOldSel.get() );
832  if ( !bNewSel || pOldSel->find( aOldDate.GetDate() ) == pOldSel->end() )
833  ImplUpdateDate( aOldDate );
834  // assure focus rectangle is displayed again
835  if ( HasFocus() || !bNewSel
836  || mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
838  }
839 }
840 
841 void Calendar::ImplUpdate( bool bCalcNew )
842 {
843  if (IsReallyVisible() && IsUpdateMode())
844  {
845  if (bCalcNew && !mbCalc)
846  {
847  Invalidate();
848  }
849  else if (!mbFormat && !mbCalc)
850  {
851  Invalidate();
852  }
853  }
854 
855  if (bCalcNew)
856  mbCalc = true;
857  mbFormat = true;
858 }
859 
860 void Calendar::ImplScroll( bool bPrev )
861 {
862  Date aNewFirstMonth = GetFirstMonth();
863  if ( bPrev )
864  {
865  --aNewFirstMonth;
866  aNewFirstMonth.AddDays( -(aNewFirstMonth.GetDaysInMonth()-1));
867  }
868  else
869  aNewFirstMonth.AddDays( aNewFirstMonth.GetDaysInMonth());
870  SetFirstDate( aNewFirstMonth );
871 }
872 
873 void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate )
874 {
875  EndSelection();
876 
877  Date aOldFirstDate = GetFirstMonth();
879  sal_uInt16 nMonthOff;
880  sal_uInt16 nCurItemId;
881  sal_uInt16 nYear = rDate.GetYear()-1;
882  sal_uInt16 i;
883  sal_uInt16 j;
884  sal_uInt16 nYearIdCount = 1000;
885 
886  nMonthOff = (rDate.GetYear()-aOldFirstDate.GetYear())*12;
887  if ( aOldFirstDate.GetMonth() < rDate.GetMonth() )
888  nMonthOff += rDate.GetMonth()-aOldFirstDate.GetMonth();
889  else
890  nMonthOff -= aOldFirstDate.GetMonth()-rDate.GetMonth();
891 
892  // construct menu (include years with different months)
893  for ( i = 0; i < MENU_YEAR_COUNT; i++ )
894  {
895  VclPtrInstance<PopupMenu> pYearPopupMenu;
896  for ( j = 1; j <= 12; j++ )
897  pYearPopupMenu->InsertItem( nYearIdCount+j,
899  i18n::CalendarDisplayIndex::MONTH, j-1, 1));
900  aPopupMenu->InsertItem( 10+i, OUString::number( nYear+i ) );
901  aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenu );
902  nYearIdCount += 1000;
903  }
904 
905  mbMenuDown = true;
906  nCurItemId = aPopupMenu->Execute( this, rPos );
907  mbMenuDown = false;
908 
909  if ( !nCurItemId )
910  return;
911 
912  sal_uInt16 nTempMonthOff = nMonthOff % 12;
913  sal_uInt16 nTempYearOff = nMonthOff / 12;
914  sal_uInt16 nNewMonth = nCurItemId % 1000;
915  sal_uInt16 nNewYear = nYear+((nCurItemId-1000)/1000);
916  if ( nTempMonthOff < nNewMonth )
917  nNewMonth = nNewMonth - nTempMonthOff;
918  else
919  {
920  nNewYear--;
921  nNewMonth = 12-(nTempMonthOff-nNewMonth);
922  }
923  nNewYear = nNewYear - nTempYearOff;
924  SetFirstDate( Date( 1, nNewMonth, nNewYear ) );
925 }
926 
927 void Calendar::ImplTracking( const Point& rPos, bool bRepeat )
928 {
929  Date aTempDate = maCurDate;
930  sal_uInt16 nHitTest = ImplHitTest( rPos, aTempDate );
931 
932  if ( mbSpinDown )
933  {
934  mbPrevIn = (nHitTest & CALENDAR_HITTEST_PREV) != 0;
935  mbNextIn = (nHitTest & CALENDAR_HITTEST_NEXT) != 0;
936 
937  if ( bRepeat && (mbPrevIn || mbNextIn) )
938  {
939  ImplScroll( mbPrevIn );
940  }
941  }
942  else
943  ImplMouseSelect( aTempDate, nHitTest );
944 }
945 
946 void Calendar::ImplEndTracking( bool bCancel )
947 {
948  bool bSelection = false;
949  bool bSpinDown = mbSpinDown;
950 
951  mbDrag = false;
952  mbSpinDown = false;
953  mbPrevIn = false;
954  mbNextIn = false;
955 
956  if ( bCancel )
957  {
958  if ( maOldFirstDate != maFirstDate )
960 
961  if ( !bSpinDown )
962  {
963  std::unique_ptr<IntDateSet> pOldSel(new IntDateSet( *mpSelectTable ));
964  Date aOldDate = maCurDate;
967  HideFocus();
968  ImplUpdateSelection( pOldSel.get() );
969  if ( pOldSel->find( aOldDate.GetDate() ) == pOldSel->end() )
970  ImplUpdateDate( aOldDate );
971  // assure focus rectangle is displayed again
972  if ( HasFocus() || mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
974  }
975  }
976 
977  if ( bSpinDown )
978  return;
979 
980  if ( !bCancel )
981  {
982  // determine if we should scroll the visible area
983  if ( !mpSelectTable->empty() )
984  {
985  Date aFirstSelDate( *mpSelectTable->begin() );
986  Date aLastSelDate( *mpSelectTable->rbegin() );
987  if ( aLastSelDate < GetFirstMonth() )
988  ImplScroll( true );
989  else if ( GetLastMonth() < aFirstSelDate )
990  ImplScroll( false );
991  }
992  }
993 
994  if ( !bCancel && ((maCurDate != maOldCurDate) || (*mpOldSelectTable != *mpSelectTable)) )
995  Select();
996 
997  if ( !bSelection && (mnWinStyle & WB_TABSTOP) && !bCancel )
998  GrabFocus();
999 
1000  mpOldSelectTable.reset();
1001 }
1002 
1004 {
1005  if ( rMEvt.IsLeft() && !mbMenuDown )
1006  {
1007  Date aTempDate = maCurDate;
1008  sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), aTempDate );
1009  if ( nHitTest )
1010  {
1011  if ( nHitTest & CALENDAR_HITTEST_MONTHTITLE )
1012  ImplShowMenu( rMEvt.GetPosPixel(), aTempDate );
1013  else
1014  {
1016 
1017  mbPrevIn = (nHitTest & CALENDAR_HITTEST_PREV) != 0;
1018  mbNextIn = (nHitTest & CALENDAR_HITTEST_NEXT) != 0;
1019  if ( mbPrevIn || mbNextIn )
1020  {
1021  mbSpinDown = true;
1022  ImplScroll( mbPrevIn );
1023  // it should really read BUTTONREPEAT, therefore do not
1024  // change it to SCROLLREPEAT, check with TH,
1025  // why it could be different (71775)
1027  }
1028  else
1029  {
1030  if ( (rMEvt.GetClicks() != 2) || !(nHitTest & CALENDAR_HITTEST_DAY) )
1031  {
1033  mpOldSelectTable.reset(new IntDateSet( *mpSelectTable ));
1034 
1035  mbDrag = true;
1036  StartTracking();
1037 
1038  ImplMouseSelect( aTempDate, nHitTest );
1039  }
1040  if (rMEvt.GetClicks() == 2)
1041  maActivateHdl.Call(this);
1042  }
1043  }
1044  }
1045 
1046  return;
1047  }
1048 
1049  Control::MouseButtonDown( rMEvt );
1050 }
1051 
1052 void Calendar::Tracking( const TrackingEvent& rTEvt )
1053 {
1054  Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
1055 
1056  if ( rTEvt.IsTrackingEnded() )
1058  else
1059  ImplTracking( aMousePos, rTEvt.IsTrackingRepeat() );
1060 }
1061 
1062 void Calendar::KeyInput( const KeyEvent& rKEvt )
1063 {
1064  Date aNewDate = maCurDate;
1065 
1066  switch ( rKEvt.GetKeyCode().GetCode() )
1067  {
1068  case KEY_HOME:
1069  aNewDate.SetDay( 1 );
1070  break;
1071 
1072  case KEY_END:
1073  aNewDate.SetDay( aNewDate.GetDaysInMonth() );
1074  break;
1075 
1076  case KEY_LEFT:
1077  --aNewDate;
1078  break;
1079 
1080  case KEY_RIGHT:
1081  ++aNewDate;
1082  break;
1083 
1084  case KEY_UP:
1085  aNewDate.AddDays( -7 );
1086  break;
1087 
1088  case KEY_DOWN:
1089  aNewDate.AddDays( 7 );
1090  break;
1091 
1092  case KEY_PAGEUP:
1093  {
1094  Date aTempDate = aNewDate;
1095  aTempDate.AddDays( -(aNewDate.GetDay()+1) );
1096  aNewDate.AddDays( -aTempDate.GetDaysInMonth() );
1097  }
1098  break;
1099 
1100  case KEY_PAGEDOWN:
1101  aNewDate.AddDays( aNewDate.GetDaysInMonth() );
1102  break;
1103 
1104  case KEY_RETURN:
1105  break;
1106 
1107  default:
1108  Control::KeyInput( rKEvt );
1109  break;
1110  }
1111 
1112  if ( aNewDate != maCurDate )
1113  {
1114  SetCurDate( aNewDate );
1115  Select();
1116  }
1117 
1118  if (rKEvt.GetKeyCode().GetCode() == KEY_RETURN)
1119  {
1120  if (maActivateHdl.IsSet())
1121  maActivateHdl.Call(this);
1122  else
1123  Control::KeyInput(rKEvt);
1124  }
1125 }
1126 
1127 void Calendar::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
1128 {
1129  ImplDraw(rRenderContext);
1130 }
1131 
1133 {
1136 }
1137 
1139 {
1140  HideFocus();
1142 }
1143 
1145 {
1146  ImplUpdate( true );
1147  Control::Resize();
1148 }
1149 
1150 void Calendar::RequestHelp( const HelpEvent& rHEvt )
1151 {
1153  {
1154  Date aDate = maCurDate;
1155  if ( GetDate( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ), aDate ) )
1156  {
1157  tools::Rectangle aDateRect = GetDateRect( aDate );
1158  Point aPt = OutputToScreenPixel( aDateRect.TopLeft() );
1159  aDateRect.SetLeft( aPt.X() );
1160  aDateRect.SetTop( aPt.Y() );
1161  aPt = OutputToScreenPixel( aDateRect.BottomRight() );
1162  aDateRect.SetRight( aPt.X() );
1163  aDateRect.SetBottom( aPt.Y() );
1164 
1165  if ( rHEvt.GetMode() & HelpEventMode::QUICK )
1166  {
1168  sal_uInt16 nWeek = static_cast<sal_uInt16>(maCalendarWrapper.getValue( i18n::CalendarFieldIndex::WEEK_OF_YEAR));
1169  sal_uInt16 nMonth = aDate.GetMonth();
1170  OUString aStr = maDayText
1171  + ": "
1172  + OUString::number(aDate.GetDayOfYear())
1173  + " / "
1174  + maWeekText
1175  + ": "
1176  + OUString::number(nWeek);
1177  // if year is not the same, add it
1178  if ( (nMonth == 12) && (nWeek == 1) )
1179  {
1180  aStr += ", " + OUString::number(aDate.GetNextYear());
1181  }
1182  else if ( (nMonth == 1) && (nWeek > 50) )
1183  {
1184  aStr += ", " + OUString::number(aDate.GetYear()-1);
1185  }
1186  Help::ShowQuickHelp( this, aDateRect, aStr );
1187  return;
1188  }
1189  }
1190  }
1191 
1192  Control::RequestHelp( rHEvt );
1193 }
1194 
1195 void Calendar::Command( const CommandEvent& rCEvt )
1196 {
1197  if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1198  {
1199  if ( rCEvt.IsMouseEvent() )
1200  {
1201  Date aTempDate = maCurDate;
1202  sal_uInt16 nHitTest = ImplHitTest( rCEvt.GetMousePosPixel(), aTempDate );
1203  if ( nHitTest & CALENDAR_HITTEST_MONTHTITLE )
1204  {
1205  ImplShowMenu( rCEvt.GetMousePosPixel(), aTempDate );
1206  return;
1207  }
1208  }
1209  }
1210  else if ( rCEvt.GetCommand() == CommandEventId::Wheel )
1211  {
1212  const CommandWheelData* pData = rCEvt.GetWheelData();
1213  if ( pData->GetMode() == CommandWheelMode::SCROLL )
1214  {
1215  long nNotchDelta = pData->GetNotchDelta();
1216  if ( nNotchDelta < 0 )
1217  {
1218  while ( nNotchDelta < 0 )
1219  {
1220  ImplScroll( true );
1221  nNotchDelta++;
1222  }
1223  }
1224  else
1225  {
1226  while ( nNotchDelta > 0 )
1227  {
1228  ImplScroll( false );
1229  nNotchDelta--;
1230  }
1231  }
1232 
1233  return;
1234  }
1235  }
1236 
1237  Control::Command( rCEvt );
1238 }
1239 
1241 {
1242  Control::StateChanged( nType );
1243 
1244  if ( nType == StateChangedType::InitShow )
1245  ImplFormat();
1246 }
1247 
1249 {
1250  Control::DataChanged( rDCEvt );
1251 
1252  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1254  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1255  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1256  {
1257  ImplInitSettings();
1258  Invalidate();
1259  }
1260 }
1261 
1263 {
1264  maSelectHdl.Call( this );
1265 }
1266 
1268 {
1269  if ( !mpSelectTable->empty() )
1270  return Date( *mpSelectTable->begin() );
1271  else
1272  {
1273  Date aDate( 0, 0, 0 );
1274  return aDate;
1275  }
1276 }
1277 
1278 void Calendar::SetCurDate( const Date& rNewDate )
1279 {
1280  if ( !rNewDate.IsValidAndGregorian() )
1281  return;
1282 
1283  if ( maCurDate == rNewDate )
1284  return;
1285 
1286  bool bUpdate = IsVisible() && IsUpdateMode();
1287  Date aOldDate = maCurDate;
1288  maCurDate = rNewDate;
1289 
1290  ImplCalendarSelectDate( mpSelectTable.get(), aOldDate, false );
1292 
1293  // shift actual date in the visible area
1294  if ( mbFormat || (maCurDate < GetFirstMonth()) )
1296  else if ( maCurDate > GetLastMonth() )
1297  {
1298  Date aTempDate = GetLastMonth();
1299  long nDateOff = maCurDate-aTempDate;
1300  if ( nDateOff < 365 )
1301  {
1302  Date aFirstDate = GetFirstMonth();
1303  aFirstDate.AddDays( aFirstDate.GetDaysInMonth() );
1304  ++aTempDate;
1305  while ( nDateOff > aTempDate.GetDaysInMonth() )
1306  {
1307  aFirstDate.AddDays( aFirstDate.GetDaysInMonth() );
1308  sal_Int32 nDaysInMonth = aTempDate.GetDaysInMonth();
1309  aTempDate.AddDays( nDaysInMonth );
1310  nDateOff -= nDaysInMonth;
1311  }
1312  SetFirstDate( aFirstDate );
1313  }
1314  else
1316  }
1317  else
1318  {
1319  if ( bUpdate )
1320  {
1321  HideFocus();
1322  ImplUpdateDate( aOldDate );
1324  }
1325  }
1326 }
1327 
1328 void Calendar::SetFirstDate( const Date& rNewFirstDate )
1329 {
1330  if ( maFirstDate != rNewFirstDate )
1331  {
1332  maFirstDate = Date( 1, rNewFirstDate.GetMonth(), rNewFirstDate.GetYear() );
1333  ImplUpdate();
1334  }
1335 }
1336 
1338 {
1339  if ( maFirstDate.GetDay() > 1 )
1340  {
1341  if ( maFirstDate.GetMonth() == 12 )
1342  return Date( 1, 1, maFirstDate.GetNextYear() );
1343  else
1344  return Date( 1, maFirstDate.GetMonth()+1, maFirstDate.GetYear() );
1345  }
1346  else
1347  return maFirstDate;
1348 }
1349 
1351 {
1352  Date aDate = GetFirstMonth();
1353  sal_uInt16 nMonthCount = GetMonthCount();
1354  for ( sal_uInt16 i = 0; i < nMonthCount; i++ )
1355  aDate.AddDays( aDate.GetDaysInMonth() );
1356  --aDate;
1357  return aDate;
1358 }
1359 
1360 sal_uInt16 Calendar::GetMonthCount() const
1361 {
1362  if ( mbFormat )
1363  return 1;
1364  else
1365  return static_cast<sal_uInt16>(mnMonthPerLine*mnLines);
1366 }
1367 
1368 bool Calendar::GetDate( const Point& rPos, Date& rDate ) const
1369 {
1370  Date aDate = maCurDate;
1371  sal_uInt16 nHitTest = ImplHitTest( rPos, aDate );
1372  if ( nHitTest & CALENDAR_HITTEST_DAY )
1373  {
1374  rDate = aDate;
1375  return true;
1376  }
1377  else
1378  return false;
1379 }
1380 
1382 {
1383  tools::Rectangle aRect;
1384 
1385  if ( mbFormat || (rDate < maFirstDate) || (rDate > (maFirstDate+mnDayCount)) )
1386  return aRect;
1387 
1388  long nX;
1389  long nY;
1390  sal_Int32 nDaysOff;
1391  sal_uInt16 nDayIndex;
1392  Date aDate = GetFirstMonth();
1393 
1394  if ( rDate < aDate )
1395  {
1396  aRect = GetDateRect( aDate );
1397  nDaysOff = aDate-rDate;
1398  nX = nDaysOff*mnDayWidth;
1399  aRect.AdjustLeft( -nX );
1400  aRect.AdjustRight( -nX );
1401  return aRect;
1402  }
1403  else
1404  {
1405  Date aLastDate = GetLastMonth();
1406  if ( rDate > aLastDate )
1407  {
1408  sal_Int32 nWeekDay = static_cast<sal_Int32>(aLastDate.GetDayOfWeek());
1409  nWeekDay = (nWeekDay+(7-ImplGetWeekStart())) % 7;
1410  aLastDate.AddDays( -nWeekDay );
1411  aRect = GetDateRect( aLastDate );
1412  nDaysOff = rDate-aLastDate;
1413  nDayIndex = 0;
1414  for ( sal_Int32 i = 0; i <= nDaysOff; i++ )
1415  {
1416  if ( aLastDate == rDate )
1417  {
1418  aRect.AdjustLeft(nDayIndex*mnDayWidth );
1419  aRect.SetRight( aRect.Left()+mnDayWidth );
1420  return aRect;
1421  }
1422  if ( nDayIndex == 6 )
1423  {
1424  nDayIndex = 0;
1425  aRect.AdjustTop(mnDayHeight );
1426  aRect.AdjustBottom(mnDayHeight );
1427  }
1428  else
1429  nDayIndex++;
1430  ++aLastDate;
1431  }
1432  }
1433  }
1434 
1435  nY = 0;
1436  for ( long i = 0; i < mnLines; i++ )
1437  {
1438  nX = 0;
1439  for ( long j = 0; j < mnMonthPerLine; j++ )
1440  {
1441  sal_uInt16 nDaysInMonth = aDate.GetDaysInMonth();
1442 
1443  // month is called
1444  if ( (aDate.GetMonth() == rDate.GetMonth()) &&
1445  (aDate.GetYear() == rDate.GetYear()) )
1446  {
1447  long nDayX = nX+mnDaysOffX;
1448  long nDayY = nY+mnDaysOffY;
1449  nDayIndex = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
1450  nDayIndex = (nDayIndex+(7-static_cast<sal_uInt16>(ImplGetWeekStart()))) % 7;
1451  for ( sal_uInt16 nDay = 1; nDay <= nDaysInMonth; nDay++ )
1452  {
1453  if ( nDay == rDate.GetDay() )
1454  {
1455  aRect.SetLeft( nDayX + (nDayIndex*mnDayWidth) );
1456  aRect.SetTop( nDayY );
1457  aRect.SetRight( aRect.Left()+mnDayWidth );
1458  aRect.SetBottom( aRect.Top()+mnDayHeight );
1459  break;
1460  }
1461  if ( nDayIndex == 6 )
1462  {
1463  nDayIndex = 0;
1464  nDayY += mnDayHeight;
1465  }
1466  else
1467  nDayIndex++;
1468  }
1469  }
1470 
1471  aDate.AddDays( nDaysInMonth );
1472  nX += mnMonthWidth;
1473  }
1474 
1475  nY += mnMonthHeight;
1476  }
1477 
1478  return aRect;
1479 }
1480 
1482 {
1483  if ( mbDrag || mbSpinDown )
1484  {
1485  ReleaseMouse();
1486 
1487  mbDrag = false;
1488  mbSpinDown = false;
1489  mbPrevIn = false;
1490  mbNextIn = false;
1491  }
1492 }
1493 
1495 {
1496  Size aSize;
1497  long n99TextWidth = GetTextWidth( "99" );
1498  long nTextHeight = GetTextHeight();
1499 
1500  aSize.AdjustWidth((n99TextWidth+DAY_OFFX)*7);
1501  aSize.AdjustWidth(MONTH_BORDERX*2 );
1502 
1503  aSize.setHeight( nTextHeight + TITLE_OFFY + (TITLE_BORDERY*2) );
1504  aSize.AdjustHeight(nTextHeight + WEEKDAY_OFFY );
1505  aSize.AdjustHeight((nTextHeight+DAY_OFFY)*6);
1506  aSize.AdjustHeight(MONTH_OFFY );
1507 
1508  return aSize;
1509 }
1510 
1512 {
1513  return CalcWindowSizePixel();
1514 }
1515 
1516 namespace
1517 {
1518  class ImplCFieldFloat final
1519  {
1520  private:
1521  std::unique_ptr<weld::Builder> mxBuilder;
1522  std::unique_ptr<weld::Container> mxContainer;
1523  std::unique_ptr<weld::Calendar> mxCalendar;
1524  std::unique_ptr<weld::Button> mxTodayBtn;
1525  std::unique_ptr<weld::Button> mxNoneBtn;
1526 
1527  public:
1528  ImplCFieldFloat(vcl::Window* pContainer)
1529  : mxBuilder(Application::CreateInterimBuilder(pContainer, "svt/ui/calendar.ui", false))
1530  , mxContainer(mxBuilder->weld_container("Calendar"))
1531  , mxCalendar(mxBuilder->weld_calendar("date"))
1532  , mxTodayBtn(mxBuilder->weld_button("today"))
1533  , mxNoneBtn(mxBuilder->weld_button("none"))
1534  {
1535  }
1536 
1537  weld::Calendar* GetCalendar() { return mxCalendar.get(); }
1538  weld::Button* EnableTodayBtn(bool bEnable);
1539  weld::Button* EnableNoneBtn(bool bEnable);
1540 
1541  void GrabFocus()
1542  {
1543  mxCalendar->grab_focus();
1544  }
1545  };
1546 }
1547 
1549 {
1550  explicit ImplCFieldFloatWin(vcl::Window* pParent);
1551  virtual void dispose() override;
1552  virtual ~ImplCFieldFloatWin() override;
1553  virtual void GetFocus() override;
1554 
1556  std::unique_ptr<ImplCFieldFloat> mxWidget;
1557 };
1558 
1560  : DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui")
1561  , mxBox(get("box"))
1562 {
1564  mxWidget.reset(new ImplCFieldFloat(mxBox.get()));
1565 }
1566 
1568 {
1569  disposeOnce();
1570 }
1571 
1573 {
1574  mxWidget.reset();
1577 }
1578 
1580 {
1582  if (!mxWidget)
1583  return;
1584  mxWidget->GrabFocus();
1585 }
1586 
1587 weld::Button* ImplCFieldFloat::EnableTodayBtn(bool bEnable)
1588 {
1589  mxTodayBtn->set_visible(bEnable);
1590  return bEnable ? mxTodayBtn.get() : nullptr;
1591 }
1592 
1593 weld::Button* ImplCFieldFloat::EnableNoneBtn(bool bEnable)
1594 {
1595  mxNoneBtn->set_visible(bEnable);
1596  return bEnable ? mxNoneBtn.get() : nullptr;
1597 }
1598 
1600  : DateField(pParent, nWinStyle)
1601  , mpFloatWin(nullptr)
1602  , mpTodayBtn(nullptr)
1603  , mpNoneBtn(nullptr)
1604  , mbToday(false)
1605  , mbNone(false)
1606 {
1607 }
1608 
1610 {
1611  disposeOnce();
1612 }
1613 
1615 {
1616  mpTodayBtn = nullptr;
1617  mpNoneBtn = nullptr;
1620 }
1621 
1622 IMPL_LINK(CalendarField, ImplSelectHdl, weld::Calendar&, rCalendar, void)
1623 {
1624  Date aNewDate = rCalendar.get_date();
1625 
1627  mpFloatWin->EnableDocking(false);
1628  EndDropDown();
1629  GrabFocus();
1630  if ( IsEmptyDate() || ( aNewDate != GetDate() ) )
1631  {
1632  SetDate( aNewDate );
1633  SetModifyFlag();
1634  Modify();
1635  }
1636 }
1637 
1638 IMPL_LINK(CalendarField, ImplClickHdl, weld::Button&, rBtn, void)
1639 {
1641  mpFloatWin->EnableDocking(false);
1642  EndDropDown();
1643  GrabFocus();
1644 
1645  if (&rBtn == mpTodayBtn)
1646  {
1647  Date aToday( Date::SYSTEM );
1648  if ( (aToday != GetDate()) || IsEmptyDate() )
1649  {
1650  SetDate( aToday );
1651  SetModifyFlag();
1652  Modify();
1653  }
1654  }
1655  else if (&rBtn == mpNoneBtn)
1656  {
1657  if ( !IsEmptyDate() )
1658  {
1659  SetEmptyDate();
1660  SetModifyFlag();
1661  Modify();
1662  }
1663  }
1664 }
1665 
1666 IMPL_LINK_NOARG(CalendarField, ImplPopupModeEndHdl, FloatingWindow*, void)
1667 {
1668  EndDropDown();
1669  GrabFocus();
1670 }
1671 
1673 {
1674  if ( bShow )
1675  {
1676  if ( !mpFloatWin )
1678 
1679  Date aDate = GetDate();
1680  if ( IsEmptyDate() || !aDate.IsValidAndGregorian() )
1681  {
1682  aDate = Date( Date::SYSTEM );
1683  }
1684  weld::Calendar* pCalendar = mpFloatWin->mxWidget->GetCalendar();
1685  pCalendar->set_date( aDate );
1686  pCalendar->connect_activated(LINK(this, CalendarField, ImplSelectHdl));
1687  mpTodayBtn = mpFloatWin->mxWidget->EnableTodayBtn(mbToday);
1688  mpNoneBtn = mpFloatWin->mxWidget->EnableNoneBtn(mbNone);
1689  if (mpTodayBtn)
1690  mpTodayBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) );
1691  if (mpNoneBtn)
1692  mpNoneBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) );
1694  tools::Rectangle aRect(aPos, GetSizePixel());
1695  aRect.AdjustBottom( -1 );
1696  DockingManager* pDockingManager = vcl::Window::GetDockingManager();
1697  mpFloatWin->EnableDocking(true);
1698  pDockingManager->SetPopupModeEndHdl(mpFloatWin, LINK(this, CalendarField, ImplPopupModeEndHdl));
1700  }
1701  else
1702  {
1704  mpFloatWin->EnableDocking(false);
1705  EndDropDown();
1706  }
1707  return true;
1708 }
1709 
1711 {
1712  DateField::StateChanged( nStateChange );
1713 
1714  if ( ( nStateChange == StateChangedType::Style ) && GetSubEdit() )
1715  {
1716  WinBits nAllAlignmentBits = ( WB_LEFT | WB_CENTER | WB_RIGHT | WB_TOP | WB_VCENTER | WB_BOTTOM );
1717  WinBits nMyAlignment = GetStyle() & nAllAlignmentBits;
1718  GetSubEdit()->SetStyle( ( GetSubEdit()->GetStyle() & ~nAllAlignmentBits ) | nMyAlignment );
1719  }
1720 }
1721 
1722 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual Point GetPosPixel() const
Definition: window.cxx:2792
Point TopLeft() const
void ImplDrawDate(vcl::RenderContext &rRenderContext, long nX, long nY, sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear, bool bOther, sal_Int32 nToday)
Definition: calendar.cxx:521
long Width() const
const Color & GetTextColor() const
Definition: outdev.hxx:1135
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:795
const Color & GetShadowColor() const
sal_Int16 GetNextYear() const
long GetWidth() const
const Wallpaper & GetBackground() const
Definition: outdev.hxx:643
void setDeferredProperties()
Definition: builder.hxx:478
virtual void LoseFocus() override
Definition: calendar.cxx:1138
void HideFocus()
Definition: window2.cxx:91
tools::Rectangle maNextRect
long GetHeight() const
DayOfWeek GetDayOfWeek() const
void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: calendar.cxx:596
long AdjustWidth(long n)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
const Color & GetHighlightTextColor() const
std::unique_ptr< ContentProperties > pData
Edit * GetSubEdit() const
Definition: edit.hxx:217
sal_Int16 getValue(sal_Int16 nFieldIndex) const
Link< Calendar *, void > maActivateHdl
long Height() const
sal_Int16 getFirstDayOfWeek() const
sal_Int16 mnFirstYear
long AdjustLeft(long nHorzMoveDelta)
SATURDAY
void disposeAndClear()
Definition: vclptr.hxx:200
const StyleSettings & GetStyleSettings() const
virtual ~CalendarField() override
Definition: calendar.cxx:1609
const Color & GetFaceColor() const
virtual ~Calendar() override
Definition: calendar.cxx:145
#define CALENDAR_HITTEST_PREV
Definition: calendar.cxx:52
void ImplUpdate(bool bCalcNew=false)
Definition: calendar.cxx:841
std::unique_ptr< IntDateSet > mpOldSelectTable
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
sal_Int64 n
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: calendar.cxx:114
virtual Size GetSizePixel() const
Definition: window.cxx:2395
void ImplUpdateDate(const Date &rDate)
Definition: calendar.cxx:773
WinBits const WB_RIGHT
void SetPopupModeEndHdl(const vcl::Window *pWindow, const Link< FloatingWindow *, void > &rLink)
Definition: dockmgr.cxx:369
Reference< container::XNameAccess > mxContainer
#define SPIN_OFFY
Definition: calendar.cxx:48
#define CALENDAR_HITTEST_NEXT
Definition: calendar.cxx:53
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: calendar.cxx:1248
long GetNotchDelta() const
DataChangedEventType GetType() const
Definition: event.hxx:357
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2794
virtual void GetFocus() override
Definition: calendar.cxx:1579
std::unique_ptr< ImplCFieldFloat > mxWidget
Definition: calendar.cxx:1556
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
Size CalcWindowSizePixel() const
Definition: calendar.cxx:1494
const CommandWheelData * GetWheelData() const
FRIDAY
virtual void StateChanged(StateChangedType nStateChange) override
Definition: calendar.cxx:1710
void ImplUpdateSelection(IntDateSet *pOld)
Definition: calendar.cxx:785
long AdjustHeight(long n)
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
CalendarWrapper maCalendarWrapper
HelpEventMode GetMode() const
Definition: event.hxx:205
#define DAY_OFFX
Definition: calendar.cxx:40
const Color & GetFieldTextColor() const
CalendarField(vcl::Window *pParent, WinBits nWinStyle)
Definition: calendar.cxx:1599
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
const Color & GetHighlightColor() const
void ImplInitSettings()
Definition: calendar.cxx:123
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: calendar.cxx:1127
long AdjustBottom(long nVertMoveDelta)
bool IsTrackingRepeat() const
Definition: event.hxx:261
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
bool IsEmpty() const
StateChangedType
Definition: window.hxx:317
bool IsValidAndGregorian() const
WEDNESDAY
OUString maWeekText
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:407
sal_uInt16 GetClicks() const
Definition: event.hxx:123
sal_Int64 WinBits
void SetBackground()
bool GetDate(const Point &rPos, Date &rDate) const
Definition: calendar.cxx:1368
long Right() const
void ImplShowMenu(const Point &rPos, const Date &rDate)
Definition: calendar.cxx:873
WinBits const WB_BOTTOM
WinBits const WB_TOP
tools::Rectangle GetDateRect(const Date &rDate) const
Definition: calendar.cxx:1381
sal_uInt16 GetMonth() const
virtual void GetFocus() override
Definition: calendar.cxx:1132
#define TITLE_BORDERY
Definition: calendar.cxx:46
bool IsMouseEvent() const
AllSettingsFlags GetFlags() const
Definition: event.hxx:358
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
sal_uInt16 ImplHitTest(const Point &rPos, Date &rDate) const
Definition: calendar.cxx:328
const Color & GetLightColor() const
THURSDAY
sal_Int32 mnDayCount
void setGregorianDateTime(const DateTime &rDateTime)
sal_Int32 GetDate() const
long Top() const
virtual Size GetOptimalSize() const override
Definition: calendar.cxx:1511
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: field2.cxx:1977
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: calendar.cxx:1003
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
void SetDate(sal_Int32 nNewDate)
OUString maDayTexts[31]
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
static void ImplCalendarSelectDate(IntDateSet *pTable, const Date &rDate, bool bSelect)
Definition: calendar.cxx:59
Date GetFirstMonth() const
Definition: calendar.cxx:1337
virtual void set_date(const Date &rDate)=0
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:724
const Point & GetMousePosPixel() const
Definition: event.hxx:204
#define MENU_YEAR_COUNT
Definition: calendar.cxx:55
sal_Int16 GetYear() const
std::set< sal_Int32 > IntDateSet
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
Point BottomRight() const
const Color & GetDarkShadowColor() const
void DrawTextArray(const Point &rStartPt, const OUString &rStr, const long *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, SalLayoutFlags flags=SalLayoutFlags::NONE, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:929
void SetLineColor()
OUString getUniqueID() const
void connect_clicked(const Link< Button &, void > &rLink)
Definition: weld.hxx:1284
sal_uInt16 GetDaysInMonth() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dockwin.cxx:390
virtual void Tracking(const TrackingEvent &rMEvt) override
Definition: calendar.cxx:1052
virtual bool ShowDropDown(bool bShow) override
Definition: calendar.cxx:1672
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: calendar.cxx:1614
void SetTop(long v)
int i
void ImplMouseSelect(const Date &rDate, sal_uInt16 nHitTest)
Definition: calendar.cxx:808
void SetDay(sal_uInt16 nNewDay)
void ImplScroll(bool bPrev)
Definition: calendar.cxx:860
const vcl::Font & GetToolFont() const
std::unique_ptr< IntDateSet > mpSelectTable
static const LocaleDataWrapper & GetAppLocaleDataWrapper()
Get the application's locale data wrapper.
Definition: svapp.cxx:1519
tools::Rectangle maPrevRect
#define WEEKDAY_OFFY
Definition: calendar.cxx:44
#define MONTH_OFFY
Definition: calendar.cxx:43
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
Calendar(vcl::Window *pParent, WinBits nWinStyle)
Definition: calendar.cxx:132
ImplCFieldFloatWin(vcl::Window *pParent)
Definition: calendar.cxx:1559
CommandWheelMode GetMode() const
WinBits const WB_VCENTER
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1162
sal_uInt16 GetMonthCount() const
Definition: calendar.cxx:1360
TUESDAY
OUString maDayText
void ImplFormat()
Definition: calendar.cxx:192
void SetRight(long v)
bool IsUpdateMode() const
Definition: window2.cxx:1173
void SetFillColor()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_GRAY
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
const Color & GetFieldColor() const
CommandEventId GetCommand() const
void SetTextColor(const Color &rColor)
Definition: text.cxx:666
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
virtual void Resize() override
Definition: calendar.cxx:1144
sal_uInt16 GetDay() const
SUNDAY
bool IsInside(const Point &rPOINT) const
void AddDays(sal_Int32 nAddDays)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
MONDAY
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
void ImplDrawSpin(vcl::RenderContext &rRenderContext)
Definition: calendar.cxx:503
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:230
const LanguageTag & getLanguageTag()
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
virtual void LoseFocus()
Definition: window.cxx:1849
bool IsRGBEqual(const Color &rColor) const
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2810
void GrabFocus()
Definition: window.cxx:2960
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: calendar.cxx:1062
DayOfWeek ImplGetWeekStart() const
Definition: calendar.cxx:157
long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:903
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:49
long mnDayOfWeekAry[7]
vcl::Window * GetParent() const
Definition: window2.cxx:1097
WinBits const WB_LEFT
IMPL_LINK_NOARG(CalendarField, ImplPopupModeEndHdl, FloatingWindow *, void)
Definition: calendar.cxx:1666
Date maOldFormatLastDate
void SetCurDate(const Date &rNewDate)
Definition: calendar.cxx:1278
bool IsTrackingEnded() const
Definition: event.hxx:263
void SetStyle(WinBits nStyle)
Definition: window.cxx:1956
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
OUString getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) const
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
void SetPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
Definition: window.cxx:2167
#define DAY_OFFY
Definition: calendar.cxx:41
const Point & GetMousePosPixel() const
void ReleaseMouse()
Definition: mouse.cxx:458
#define MONTH_BORDERX
Definition: calendar.cxx:42
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1799
const LanguageTag & getLocale()
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: calendar.cxx:1572
WinBits const WB_3DLOOK
void ImplInit(WinBits nWinStyle)
Definition: calendar.cxx:69
VclPtr< ImplCFieldFloatWin > mpFloatWin
WinBits mnWinStyle
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
#define TITLE_OFFY
Definition: calendar.cxx:45
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:421
void EndDropDown()
Definition: spinfld.cxx:879
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
void EnableDocking(bool bEnable=true)
Definition: window2.cxx:808
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: calendar.cxx:150
virtual void Resize() override
Definition: ctrl.cxx:74
long AdjustRight(long nHorzMoveDelta)
Definition: ctrl.hxx:33
OUString maDayOfWeekText
virtual void GetFocus()
Definition: window.cxx:1835
const Color & GetButtonTextColor() const
WinBits const WB_BORDER
DayOfWeek
Date GetLastMonth() const
Definition: calendar.cxx:1350
void ImplTracking(const Point &rPos, bool bRepeat)
Definition: calendar.cxx:927
bool IsVisible() const
Definition: window2.cxx:1102
Date maOldFormatFirstDate
#define SPIN_OFFX
Definition: calendar.cxx:47
void ImplEndTracking(bool bCancel)
Definition: calendar.cxx:946
bool IsLeft() const
Definition: event.hxx:146
void SetFirstDate(const Date &rNewFirstDate)
Definition: calendar.cxx:1328
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: calendar.cxx:1150
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
void SetBottom(long v)
Date GetFirstSelectedDate() const
Definition: calendar.cxx:1267
long AdjustTop(long nVertMoveDelta)
const Point & GetPosPixel() const
Definition: event.hxx:120
void EndPopupMode(const vcl::Window *pWin)
Definition: dockmgr.cxx:362
long Left() const
long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:892
WinBits const WB_TABSTOP
Date GetLastDate() const
Link< Calendar *, void > maSelectHdl
virtual ~ImplCFieldFloatWin() override
Definition: calendar.cxx:1567
void connect_activated(const Link< Calendar &, void > &rLink)
Definition: weld.hxx:1645
WinBits const WB_CENTER
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
void StartPopupMode(const vcl::Window *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
Definition: dockmgr.cxx:335
void SetLeft(long v)
#define SAL_WARN(area, stream)
bool IsTrackingCanceled() const
Definition: event.hxx:265
OUString VclResId(const char *pId)
Definition: svdata.cxx:267
WinBits GetStyle() const
Definition: window2.cxx:953
#define CALENDAR_HITTEST_DAY
Definition: calendar.cxx:50
#define CALENDAR_HITTEST_MONTHTITLE
Definition: calendar.cxx:51
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2804
VclPtr< vcl::Window > mxBox
Definition: calendar.cxx:1555
WinBits const WB_GROUP
sal_uInt16 GetDayOfYear() const
IMPL_LINK(CalendarField, ImplSelectHdl, weld::Calendar &, rCalendar, void)
Definition: calendar.cxx:1622
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1917
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:259
bool IsReallyVisible() const
Definition: window2.cxx:1107
sal_Int16 mnLastYear
bool HasFocus() const
Definition: window.cxx:2965
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1863
void loadCalendar(const OUString &rUniqueID, const css::lang::Locale &rLocale, bool bTimeZoneUTC=true)
aStr
const Color & GetWindowTextColor() const
void EndSelection()
Definition: calendar.cxx:1481
virtual void set_visible(bool visible)
Definition: weld.hxx:95
virtual void StateChanged(StateChangedType nType) override
Definition: spinfld.cxx:751
static DockingManager * GetDockingManager()
Definition: window2.cxx:803
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
void Select()
Definition: calendar.cxx:1262
virtual void StateChanged(StateChangedType nStateChange) override
Definition: calendar.cxx:1240
void setHeight(long nHeight)
virtual void Command(const CommandEvent &rCEvt) override
Definition: calendar.cxx:1195