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