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  rRenderContext.DrawTextArray(Point(nDayX + mnDayOfWeekAry[0], nDayY), maDayOfWeekText, &(mnDayOfWeekAry[1]));
708 
709  // display days
710  sal_uInt16 nDaysInMonth = aDate.GetDaysInMonth();
711  nDayX = nX + mnDaysOffX;
712  nDayY = nY + mnDaysOffY;
713  sal_uInt16 nDayIndex = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
714  nDayIndex = (nDayIndex + (7 - static_cast<sal_uInt16>(eStartDay))) % 7;
715  if (i == 0 && j == 0)
716  {
717  Date aTempDate = aDate;
718  aTempDate.AddDays( -nDayIndex );
719  for (nDay = 0; nDay < nDayIndex; ++nDay)
720  {
721  nDeltaX = nDayX + (nDay * mnDayWidth);
722  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay + aTempDate.GetDay(),
723  aTempDate.GetMonth(), aTempDate.GetYear(),
724  true, nToday);
725  }
726  }
727  for (nDay = 1; nDay <= nDaysInMonth; nDay++)
728  {
729  nDeltaX = nDayX + (nDayIndex * mnDayWidth);
730  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay, nMonth, nYear,
731  false, nToday);
732  if (nDayIndex == 6)
733  {
734  nDayIndex = 0;
735  nDayY += mnDayHeight;
736  }
737  else
738  nDayIndex++;
739  }
740  if ((i == mnLines - 1) && (j == mnMonthPerLine - 1))
741  {
742  sal_uInt16 nWeekDay = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
743  nWeekDay = (nWeekDay + (7 - static_cast<sal_uInt16>(eStartDay))) % 7;
744  sal_uInt16 nDayCount = 42 - nDaysInMonth - nWeekDay;
745  Date aTempDate = aDate;
746  aTempDate.AddDays( nDaysInMonth );
747  for (nDay = 1; nDay <= nDayCount; ++nDay)
748  {
749  nDeltaX = nDayX + (nDayIndex * mnDayWidth);
750  ImplDrawDate(rRenderContext, nDeltaX, nDayY, nDay,
751  aTempDate.GetMonth(), aTempDate.GetYear(),
752  true, nToday);
753  if (nDayIndex == 6)
754  {
755  nDayIndex = 0;
756  nDayY += mnDayHeight;
757  }
758  else
759  nDayIndex++;
760  }
761  }
762 
763  aDate.AddDays( nDaysInMonth );
764  nX += mnMonthWidth;
765  }
766 
767  nY += mnMonthHeight;
768  }
769 
770  // draw spin buttons
771  ImplDrawSpin(rRenderContext);
772 }
773 
774 void Calendar::ImplUpdateDate( const Date& rDate )
775 {
776  if (IsReallyVisible() && IsUpdateMode())
777  {
778  tools::Rectangle aDateRect(GetDateRect(rDate));
779  if (!aDateRect.IsEmpty())
780  {
781  Invalidate(aDateRect);
782  }
783  }
784 }
785 
787 {
788  IntDateSet* pNew = mpSelectTable.get();
789 
790  for (auto const& nKey : *pOld)
791  {
792  if ( pNew->find(nKey) == pNew->end() )
793  {
794  Date aTempDate(nKey);
795  ImplUpdateDate(aTempDate);
796  }
797  }
798 
799  for (auto const& nKey : *pNew)
800  {
801  if ( pOld->find(nKey) == pOld->end() )
802  {
803  Date aTempDate(nKey);
804  ImplUpdateDate(aTempDate);
805  }
806  }
807 }
808 
809 void Calendar::ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest )
810 {
811  IntDateSet aOldSel( *mpSelectTable );
812  Date aOldDate = maCurDate;
813  Date aTempDate = rDate;
814 
815  if ( !(nHitTest & CALENDAR_HITTEST_DAY) )
816  --aTempDate;
817 
818  if ( !(nHitTest & CALENDAR_HITTEST_DAY) )
819  aTempDate = maOldCurDate;
820  if ( aTempDate != maCurDate )
821  {
822  maCurDate = aTempDate;
823  ImplCalendarSelectDate( mpSelectTable.get(), aOldDate, false );
825  }
826 
827  bool bNewSel = aOldSel != *mpSelectTable;
828  if ( (maCurDate != aOldDate) || bNewSel )
829  {
830  HideFocus();
831  if ( bNewSel )
832  ImplUpdateSelection( &aOldSel );
833  if ( !bNewSel || aOldSel.find( aOldDate.GetDate() ) == aOldSel.end() )
834  ImplUpdateDate( aOldDate );
835  // assure focus rectangle is displayed again
836  if ( HasFocus() || !bNewSel
837  || mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
839  }
840 }
841 
842 void Calendar::ImplUpdate( bool bCalcNew )
843 {
844  if (IsReallyVisible() && IsUpdateMode())
845  {
846  if (bCalcNew && !mbCalc)
847  {
848  Invalidate();
849  }
850  else if (!mbFormat && !mbCalc)
851  {
852  Invalidate();
853  }
854  }
855 
856  if (bCalcNew)
857  mbCalc = true;
858  mbFormat = true;
859 }
860 
861 void Calendar::ImplScroll( bool bPrev )
862 {
863  Date aNewFirstMonth = GetFirstMonth();
864  if ( bPrev )
865  {
866  --aNewFirstMonth;
867  aNewFirstMonth.AddDays( -(aNewFirstMonth.GetDaysInMonth()-1));
868  }
869  else
870  aNewFirstMonth.AddDays( aNewFirstMonth.GetDaysInMonth());
871  SetFirstDate( aNewFirstMonth );
872 }
873 
874 void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate )
875 {
876  EndSelection();
877 
878  Date aOldFirstDate = GetFirstMonth();
880  sal_uInt16 nMonthOff;
881  sal_uInt16 nCurItemId;
882  sal_uInt16 nYear = rDate.GetYear()-1;
883  sal_uInt16 i;
884  sal_uInt16 j;
885  sal_uInt16 nYearIdCount = 1000;
886 
887  nMonthOff = (rDate.GetYear()-aOldFirstDate.GetYear())*12;
888  if ( aOldFirstDate.GetMonth() < rDate.GetMonth() )
889  nMonthOff += rDate.GetMonth()-aOldFirstDate.GetMonth();
890  else
891  nMonthOff -= aOldFirstDate.GetMonth()-rDate.GetMonth();
892 
893  // construct menu (include years with different months)
894  for ( i = 0; i < MENU_YEAR_COUNT; i++ )
895  {
896  VclPtrInstance<PopupMenu> pYearPopupMenu;
897  for ( j = 1; j <= 12; j++ )
898  pYearPopupMenu->InsertItem( nYearIdCount+j,
900  i18n::CalendarDisplayIndex::MONTH, j-1, 1));
901  aPopupMenu->InsertItem( 10+i, OUString::number( nYear+i ) );
902  aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenu );
903  nYearIdCount += 1000;
904  }
905 
906  mbMenuDown = true;
907  nCurItemId = aPopupMenu->Execute( this, rPos );
908  mbMenuDown = false;
909 
910  if ( !nCurItemId )
911  return;
912 
913  sal_uInt16 nTempMonthOff = nMonthOff % 12;
914  sal_uInt16 nTempYearOff = nMonthOff / 12;
915  sal_uInt16 nNewMonth = nCurItemId % 1000;
916  sal_uInt16 nNewYear = nYear+((nCurItemId-1000)/1000);
917  if ( nTempMonthOff < nNewMonth )
918  nNewMonth = nNewMonth - nTempMonthOff;
919  else
920  {
921  nNewYear--;
922  nNewMonth = 12-(nTempMonthOff-nNewMonth);
923  }
924  nNewYear = nNewYear - nTempYearOff;
925  SetFirstDate( Date( 1, nNewMonth, nNewYear ) );
926 }
927 
928 void Calendar::ImplTracking( const Point& rPos, bool bRepeat )
929 {
930  Date aTempDate = maCurDate;
931  sal_uInt16 nHitTest = ImplDoHitTest( rPos, aTempDate );
932 
933  if ( mbSpinDown )
934  {
935  mbPrevIn = (nHitTest & CALENDAR_HITTEST_PREV) != 0;
936  mbNextIn = (nHitTest & CALENDAR_HITTEST_NEXT) != 0;
937 
938  if ( bRepeat && (mbPrevIn || mbNextIn) )
939  {
940  ImplScroll( mbPrevIn );
941  }
942  }
943  else
944  ImplMouseSelect( aTempDate, nHitTest );
945 }
946 
947 void Calendar::ImplEndTracking( bool bCancel )
948 {
949  bool bSelection = false;
950  bool bSpinDown = mbSpinDown;
951 
952  mbDrag = false;
953  mbSpinDown = false;
954  mbPrevIn = false;
955  mbNextIn = false;
956 
957  if ( bCancel )
958  {
959  if ( maOldFirstDate != maFirstDate )
961 
962  if ( !bSpinDown )
963  {
964  IntDateSet aOldSel( *mpSelectTable );
965  Date aOldDate = maCurDate;
968  HideFocus();
969  ImplUpdateSelection( &aOldSel );
970  if ( aOldSel.find( aOldDate.GetDate() ) == aOldSel.end() )
971  ImplUpdateDate( aOldDate );
972  // assure focus rectangle is displayed again
973  if ( HasFocus() || mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
975  }
976  }
977 
978  if ( bSpinDown )
979  return;
980 
981  if ( !bCancel )
982  {
983  // determine if we should scroll the visible area
984  if ( !mpSelectTable->empty() )
985  {
986  Date aFirstSelDate( *mpSelectTable->begin() );
987  Date aLastSelDate( *mpSelectTable->rbegin() );
988  if ( aLastSelDate < GetFirstMonth() )
989  ImplScroll( true );
990  else if ( GetLastMonth() < aFirstSelDate )
991  ImplScroll( false );
992  }
993  }
994 
995  if ( !bCancel && ((maCurDate != maOldCurDate) || (*mpOldSelectTable != *mpSelectTable)) )
996  Select();
997 
998  if ( !bSelection && (mnWinStyle & WB_TABSTOP) && !bCancel )
999  GrabFocus();
1000 
1001  mpOldSelectTable.reset();
1002 }
1003 
1005 {
1006  if ( rMEvt.IsLeft() && !mbMenuDown )
1007  {
1008  Date aTempDate = maCurDate;
1009  sal_uInt16 nHitTest = ImplDoHitTest( rMEvt.GetPosPixel(), aTempDate );
1010  if ( nHitTest )
1011  {
1012  if ( nHitTest & CALENDAR_HITTEST_MONTHTITLE )
1013  ImplShowMenu( rMEvt.GetPosPixel(), aTempDate );
1014  else
1015  {
1017 
1018  mbPrevIn = (nHitTest & CALENDAR_HITTEST_PREV) != 0;
1019  mbNextIn = (nHitTest & CALENDAR_HITTEST_NEXT) != 0;
1020  if ( mbPrevIn || mbNextIn )
1021  {
1022  mbSpinDown = true;
1023  ImplScroll( mbPrevIn );
1024  // it should really read BUTTONREPEAT, therefore do not
1025  // change it to SCROLLREPEAT, check with TH,
1026  // why it could be different (71775)
1028  }
1029  else
1030  {
1031  if ( (rMEvt.GetClicks() != 2) || !(nHitTest & CALENDAR_HITTEST_DAY) )
1032  {
1034  mpOldSelectTable.reset(new IntDateSet( *mpSelectTable ));
1035 
1036  mbDrag = true;
1037  StartTracking();
1038 
1039  ImplMouseSelect( aTempDate, nHitTest );
1040  }
1041  if (rMEvt.GetClicks() == 2)
1042  maActivateHdl.Call(this);
1043  }
1044  }
1045  }
1046 
1047  return;
1048  }
1049 
1050  Control::MouseButtonDown( rMEvt );
1051 }
1052 
1053 void Calendar::Tracking( const TrackingEvent& rTEvt )
1054 {
1055  Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
1056 
1057  if ( rTEvt.IsTrackingEnded() )
1059  else
1060  ImplTracking( aMousePos, rTEvt.IsTrackingRepeat() );
1061 }
1062 
1063 void Calendar::KeyInput( const KeyEvent& rKEvt )
1064 {
1065  Date aNewDate = maCurDate;
1066 
1067  switch ( rKEvt.GetKeyCode().GetCode() )
1068  {
1069  case KEY_HOME:
1070  aNewDate.SetDay( 1 );
1071  break;
1072 
1073  case KEY_END:
1074  aNewDate.SetDay( aNewDate.GetDaysInMonth() );
1075  break;
1076 
1077  case KEY_LEFT:
1078  --aNewDate;
1079  break;
1080 
1081  case KEY_RIGHT:
1082  ++aNewDate;
1083  break;
1084 
1085  case KEY_UP:
1086  aNewDate.AddDays( -7 );
1087  break;
1088 
1089  case KEY_DOWN:
1090  aNewDate.AddDays( 7 );
1091  break;
1092 
1093  case KEY_PAGEUP:
1094  {
1095  Date aTempDate = aNewDate;
1096  aTempDate.AddDays( -(aNewDate.GetDay()+1) );
1097  aNewDate.AddDays( -aTempDate.GetDaysInMonth() );
1098  }
1099  break;
1100 
1101  case KEY_PAGEDOWN:
1102  aNewDate.AddDays( aNewDate.GetDaysInMonth() );
1103  break;
1104 
1105  case KEY_RETURN:
1106  break;
1107 
1108  default:
1109  Control::KeyInput( rKEvt );
1110  break;
1111  }
1112 
1113  if ( aNewDate != maCurDate )
1114  {
1115  SetCurDate( aNewDate );
1116  Select();
1117  }
1118 
1119  if (rKEvt.GetKeyCode().GetCode() == KEY_RETURN)
1120  {
1121  if (maActivateHdl.IsSet())
1122  maActivateHdl.Call(this);
1123  else
1124  Control::KeyInput(rKEvt);
1125  }
1126 }
1127 
1128 void Calendar::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
1129 {
1130  ImplDraw(rRenderContext);
1131 }
1132 
1134 {
1137 }
1138 
1140 {
1141  HideFocus();
1143 }
1144 
1146 {
1147  ImplUpdate( true );
1148  Control::Resize();
1149 }
1150 
1151 void Calendar::RequestHelp( const HelpEvent& rHEvt )
1152 {
1154  {
1155  Date aDate = maCurDate;
1156  if ( GetDate( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ), aDate ) )
1157  {
1158  tools::Rectangle aDateRect = GetDateRect( aDate );
1159  Point aPt = OutputToScreenPixel( aDateRect.TopLeft() );
1160  aDateRect.SetLeft( aPt.X() );
1161  aDateRect.SetTop( aPt.Y() );
1162  aPt = OutputToScreenPixel( aDateRect.BottomRight() );
1163  aDateRect.SetRight( aPt.X() );
1164  aDateRect.SetBottom( aPt.Y() );
1165 
1166  if ( rHEvt.GetMode() & HelpEventMode::QUICK )
1167  {
1169  sal_uInt16 nWeek = static_cast<sal_uInt16>(maCalendarWrapper.getValue( i18n::CalendarFieldIndex::WEEK_OF_YEAR));
1170  sal_uInt16 nMonth = aDate.GetMonth();
1171  OUString aStr = maDayText
1172  + ": "
1173  + OUString::number(aDate.GetDayOfYear())
1174  + " / "
1175  + maWeekText
1176  + ": "
1177  + OUString::number(nWeek);
1178  // if year is not the same, add it
1179  if ( (nMonth == 12) && (nWeek == 1) )
1180  {
1181  aStr += ", " + OUString::number(aDate.GetNextYear());
1182  }
1183  else if ( (nMonth == 1) && (nWeek > 50) )
1184  {
1185  aStr += ", " + OUString::number(aDate.GetYear()-1);
1186  }
1187  Help::ShowQuickHelp( this, aDateRect, aStr );
1188  return;
1189  }
1190  }
1191  }
1192 
1193  Control::RequestHelp( rHEvt );
1194 }
1195 
1196 void Calendar::Command( const CommandEvent& rCEvt )
1197 {
1198  if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1199  {
1200  if ( rCEvt.IsMouseEvent() )
1201  {
1202  Date aTempDate = maCurDate;
1203  sal_uInt16 nHitTest = ImplDoHitTest( rCEvt.GetMousePosPixel(), aTempDate );
1204  if ( nHitTest & CALENDAR_HITTEST_MONTHTITLE )
1205  {
1206  ImplShowMenu( rCEvt.GetMousePosPixel(), aTempDate );
1207  return;
1208  }
1209  }
1210  }
1211  else if ( rCEvt.GetCommand() == CommandEventId::Wheel )
1212  {
1213  const CommandWheelData* pData = rCEvt.GetWheelData();
1214  if ( pData->GetMode() == CommandWheelMode::SCROLL )
1215  {
1216  tools::Long nNotchDelta = pData->GetNotchDelta();
1217  if ( nNotchDelta < 0 )
1218  {
1219  while ( nNotchDelta < 0 )
1220  {
1221  ImplScroll( true );
1222  nNotchDelta++;
1223  }
1224  }
1225  else
1226  {
1227  while ( nNotchDelta > 0 )
1228  {
1229  ImplScroll( false );
1230  nNotchDelta--;
1231  }
1232  }
1233 
1234  return;
1235  }
1236  }
1237 
1238  Control::Command( rCEvt );
1239 }
1240 
1242 {
1243  Control::StateChanged( nType );
1244 
1245  if ( nType == StateChangedType::InitShow )
1246  ImplFormat();
1247 }
1248 
1250 {
1251  Control::DataChanged( rDCEvt );
1252 
1253  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1255  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1256  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1257  {
1258  ImplInitSettings();
1259  Invalidate();
1260  }
1261 }
1262 
1264 {
1265  maSelectHdl.Call( this );
1266 }
1267 
1269 {
1270  if ( !mpSelectTable->empty() )
1271  return Date( *mpSelectTable->begin() );
1272  else
1273  {
1274  Date aDate( 0, 0, 0 );
1275  return aDate;
1276  }
1277 }
1278 
1279 void Calendar::SetCurDate( const Date& rNewDate )
1280 {
1281  if ( !rNewDate.IsValidAndGregorian() )
1282  return;
1283 
1284  if ( maCurDate == rNewDate )
1285  return;
1286 
1287  bool bUpdate = IsVisible() && IsUpdateMode();
1288  Date aOldDate = maCurDate;
1289  maCurDate = rNewDate;
1290 
1291  ImplCalendarSelectDate( mpSelectTable.get(), aOldDate, false );
1293 
1294  // shift actual date in the visible area
1295  if ( mbFormat || (maCurDate < GetFirstMonth()) )
1297  else if ( maCurDate > GetLastMonth() )
1298  {
1299  Date aTempDate = GetLastMonth();
1300  tools::Long nDateOff = maCurDate-aTempDate;
1301  if ( nDateOff < 365 )
1302  {
1303  Date aFirstDate = GetFirstMonth();
1304  aFirstDate.AddDays( aFirstDate.GetDaysInMonth() );
1305  ++aTempDate;
1306  while ( nDateOff > aTempDate.GetDaysInMonth() )
1307  {
1308  aFirstDate.AddDays( aFirstDate.GetDaysInMonth() );
1309  sal_Int32 nDaysInMonth = aTempDate.GetDaysInMonth();
1310  aTempDate.AddDays( nDaysInMonth );
1311  nDateOff -= nDaysInMonth;
1312  }
1313  SetFirstDate( aFirstDate );
1314  }
1315  else
1317  }
1318  else
1319  {
1320  if ( bUpdate )
1321  {
1322  HideFocus();
1323  ImplUpdateDate( aOldDate );
1325  }
1326  }
1327 }
1328 
1329 void Calendar::SetFirstDate( const Date& rNewFirstDate )
1330 {
1331  if ( maFirstDate != rNewFirstDate )
1332  {
1333  maFirstDate = Date( 1, rNewFirstDate.GetMonth(), rNewFirstDate.GetYear() );
1334  ImplUpdate();
1335  }
1336 }
1337 
1339 {
1340  if ( maFirstDate.GetDay() > 1 )
1341  {
1342  if ( maFirstDate.GetMonth() == 12 )
1343  return Date( 1, 1, maFirstDate.GetNextYear() );
1344  else
1345  return Date( 1, maFirstDate.GetMonth()+1, maFirstDate.GetYear() );
1346  }
1347  else
1348  return maFirstDate;
1349 }
1350 
1352 {
1353  Date aDate = GetFirstMonth();
1354  sal_uInt16 nMonthCount = GetMonthCount();
1355  for ( sal_uInt16 i = 0; i < nMonthCount; i++ )
1356  aDate.AddDays( aDate.GetDaysInMonth() );
1357  --aDate;
1358  return aDate;
1359 }
1360 
1361 sal_uInt16 Calendar::GetMonthCount() const
1362 {
1363  if ( mbFormat )
1364  return 1;
1365  else
1366  return static_cast<sal_uInt16>(mnMonthPerLine*mnLines);
1367 }
1368 
1369 bool Calendar::GetDate( const Point& rPos, Date& rDate ) const
1370 {
1371  Date aDate = maCurDate;
1372  sal_uInt16 nHitTest = ImplDoHitTest( rPos, aDate );
1373  if ( nHitTest & CALENDAR_HITTEST_DAY )
1374  {
1375  rDate = aDate;
1376  return true;
1377  }
1378  else
1379  return false;
1380 }
1381 
1383 {
1384  tools::Rectangle aRect;
1385 
1386  if ( mbFormat || (rDate < maFirstDate) || (rDate > (maFirstDate+mnDayCount)) )
1387  return aRect;
1388 
1389  tools::Long nX;
1390  tools::Long nY;
1391  sal_Int32 nDaysOff;
1392  sal_uInt16 nDayIndex;
1393  Date aDate = GetFirstMonth();
1394 
1395  if ( rDate < aDate )
1396  {
1397  aRect = GetDateRect( aDate );
1398  nDaysOff = aDate-rDate;
1399  nX = nDaysOff*mnDayWidth;
1400  aRect.AdjustLeft( -nX );
1401  aRect.AdjustRight( -nX );
1402  return aRect;
1403  }
1404  else
1405  {
1406  Date aLastDate = GetLastMonth();
1407  if ( rDate > aLastDate )
1408  {
1409  sal_Int32 nWeekDay = static_cast<sal_Int32>(aLastDate.GetDayOfWeek());
1410  nWeekDay = (nWeekDay+(7-ImplGetWeekStart())) % 7;
1411  aLastDate.AddDays( -nWeekDay );
1412  aRect = GetDateRect( aLastDate );
1413  nDaysOff = rDate-aLastDate;
1414  nDayIndex = 0;
1415  for ( sal_Int32 i = 0; i <= nDaysOff; i++ )
1416  {
1417  if ( aLastDate == rDate )
1418  {
1419  aRect.AdjustLeft(nDayIndex*mnDayWidth );
1420  aRect.SetRight( aRect.Left()+mnDayWidth );
1421  return aRect;
1422  }
1423  if ( nDayIndex == 6 )
1424  {
1425  nDayIndex = 0;
1426  aRect.AdjustTop(mnDayHeight );
1427  aRect.AdjustBottom(mnDayHeight );
1428  }
1429  else
1430  nDayIndex++;
1431  ++aLastDate;
1432  }
1433  }
1434  }
1435 
1436  nY = 0;
1437  for ( tools::Long i = 0; i < mnLines; i++ )
1438  {
1439  nX = 0;
1440  for ( tools::Long j = 0; j < mnMonthPerLine; j++ )
1441  {
1442  sal_uInt16 nDaysInMonth = aDate.GetDaysInMonth();
1443 
1444  // month is called
1445  if ( (aDate.GetMonth() == rDate.GetMonth()) &&
1446  (aDate.GetYear() == rDate.GetYear()) )
1447  {
1448  tools::Long nDayX = nX+mnDaysOffX;
1449  tools::Long nDayY = nY+mnDaysOffY;
1450  nDayIndex = static_cast<sal_uInt16>(aDate.GetDayOfWeek());
1451  nDayIndex = (nDayIndex+(7-static_cast<sal_uInt16>(ImplGetWeekStart()))) % 7;
1452  for ( sal_uInt16 nDay = 1; nDay <= nDaysInMonth; nDay++ )
1453  {
1454  if ( nDay == rDate.GetDay() )
1455  {
1456  aRect.SetLeft( nDayX + (nDayIndex*mnDayWidth) );
1457  aRect.SetTop( nDayY );
1458  aRect.SetRight( aRect.Left()+mnDayWidth );
1459  aRect.SetBottom( aRect.Top()+mnDayHeight );
1460  break;
1461  }
1462  if ( nDayIndex == 6 )
1463  {
1464  nDayIndex = 0;
1465  nDayY += mnDayHeight;
1466  }
1467  else
1468  nDayIndex++;
1469  }
1470  }
1471 
1472  aDate.AddDays( nDaysInMonth );
1473  nX += mnMonthWidth;
1474  }
1475 
1476  nY += mnMonthHeight;
1477  }
1478 
1479  return aRect;
1480 }
1481 
1483 {
1484  if ( mbDrag || mbSpinDown )
1485  {
1486  ReleaseMouse();
1487 
1488  mbDrag = false;
1489  mbSpinDown = false;
1490  mbPrevIn = false;
1491  mbNextIn = false;
1492  }
1493 }
1494 
1496 {
1497  Size aSize;
1498  tools::Long n99TextWidth = GetTextWidth( "99" );
1499  tools::Long nTextHeight = GetTextHeight();
1500 
1501  aSize.AdjustWidth((n99TextWidth+DAY_OFFX)*7);
1502  aSize.AdjustWidth(MONTH_BORDERX*2 );
1503 
1504  aSize.setHeight( nTextHeight + TITLE_OFFY + (TITLE_BORDERY*2) );
1505  aSize.AdjustHeight(nTextHeight + WEEKDAY_OFFY );
1506  aSize.AdjustHeight((nTextHeight+DAY_OFFY)*6);
1507  aSize.AdjustHeight(MONTH_OFFY );
1508 
1509  return aSize;
1510 }
1511 
1513 {
1514  return CalcWindowSizePixel();
1515 }
1516 
1517 namespace
1518 {
1519  class ImplCFieldFloat final
1520  {
1521  private:
1522  std::unique_ptr<weld::Builder> mxBuilder;
1523  std::unique_ptr<weld::Container> mxContainer;
1524  std::unique_ptr<weld::Calendar> mxCalendar;
1525  std::unique_ptr<weld::Button> mxTodayBtn;
1526  std::unique_ptr<weld::Button> mxNoneBtn;
1527 
1528  public:
1529  ImplCFieldFloat(vcl::Window* pContainer)
1530  : mxBuilder(Application::CreateInterimBuilder(pContainer, "svt/ui/calendar.ui", false))
1531  , mxContainer(mxBuilder->weld_container("Calendar"))
1532  , mxCalendar(mxBuilder->weld_calendar("date"))
1533  , mxTodayBtn(mxBuilder->weld_button("today"))
1534  , mxNoneBtn(mxBuilder->weld_button("none"))
1535  {
1536  }
1537 
1538  weld::Calendar* GetCalendar() { return mxCalendar.get(); }
1539  weld::Button* EnableTodayBtn(bool bEnable);
1540  weld::Button* EnableNoneBtn(bool bEnable);
1541 
1542  void GrabFocus()
1543  {
1544  mxCalendar->grab_focus();
1545  }
1546  };
1547 }
1548 
1550 {
1551  explicit ImplCFieldFloatWin(vcl::Window* pParent);
1552  virtual void dispose() override;
1553  virtual ~ImplCFieldFloatWin() override;
1554  virtual void GetFocus() override;
1555 
1556  std::unique_ptr<ImplCFieldFloat> mxWidget;
1557 };
1558 
1560  : DropdownDockingWindow(pParent)
1561 {
1563  mxWidget.reset(new ImplCFieldFloat(m_xBox.get()));
1564 }
1565 
1567 {
1568  disposeOnce();
1569 }
1570 
1572 {
1573  mxWidget.reset();
1575 }
1576 
1578 {
1580  if (!mxWidget)
1581  return;
1582  mxWidget->GrabFocus();
1583 }
1584 
1585 weld::Button* ImplCFieldFloat::EnableTodayBtn(bool bEnable)
1586 {
1587  mxTodayBtn->set_visible(bEnable);
1588  return bEnable ? mxTodayBtn.get() : nullptr;
1589 }
1590 
1591 weld::Button* ImplCFieldFloat::EnableNoneBtn(bool bEnable)
1592 {
1593  mxNoneBtn->set_visible(bEnable);
1594  return bEnable ? mxNoneBtn.get() : nullptr;
1595 }
1596 
1598  : DateField(pParent, nWinStyle)
1599  , mpFloatWin(nullptr)
1600  , mpTodayBtn(nullptr)
1601  , mpNoneBtn(nullptr)
1602  , mbToday(false)
1603  , mbNone(false)
1604 {
1605 }
1606 
1608 {
1609  disposeOnce();
1610 }
1611 
1613 {
1614  mpTodayBtn = nullptr;
1615  mpNoneBtn = nullptr;
1618 }
1619 
1620 IMPL_LINK(CalendarField, ImplSelectHdl, weld::Calendar&, rCalendar, void)
1621 {
1622  Date aNewDate = rCalendar.get_date();
1623 
1625  mpFloatWin->EnableDocking(false);
1626  EndDropDown();
1627  GrabFocus();
1628  if ( IsEmptyDate() || ( aNewDate != GetDate() ) )
1629  {
1630  SetDate( aNewDate );
1631  SetModifyFlag();
1632  Modify();
1633  }
1634 }
1635 
1636 IMPL_LINK(CalendarField, ImplClickHdl, weld::Button&, rBtn, void)
1637 {
1639  mpFloatWin->EnableDocking(false);
1640  EndDropDown();
1641  GrabFocus();
1642 
1643  if (&rBtn == mpTodayBtn)
1644  {
1645  Date aToday( Date::SYSTEM );
1646  if ( (aToday != GetDate()) || IsEmptyDate() )
1647  {
1648  SetDate( aToday );
1649  SetModifyFlag();
1650  Modify();
1651  }
1652  }
1653  else if (&rBtn == mpNoneBtn)
1654  {
1655  if ( !IsEmptyDate() )
1656  {
1657  SetEmptyDate();
1658  SetModifyFlag();
1659  Modify();
1660  }
1661  }
1662 }
1663 
1664 IMPL_LINK_NOARG(CalendarField, ImplPopupModeEndHdl, FloatingWindow*, void)
1665 {
1666  EndDropDown();
1667  GrabFocus();
1668 }
1669 
1671 {
1672  if ( bShow )
1673  {
1674  if ( !mpFloatWin )
1676 
1677  Date aDate = GetDate();
1678  if ( IsEmptyDate() || !aDate.IsValidAndGregorian() )
1679  {
1680  aDate = Date( Date::SYSTEM );
1681  }
1682  weld::Calendar* pCalendar = mpFloatWin->mxWidget->GetCalendar();
1683  pCalendar->set_date( aDate );
1684  pCalendar->connect_activated(LINK(this, CalendarField, ImplSelectHdl));
1685  mpTodayBtn = mpFloatWin->mxWidget->EnableTodayBtn(mbToday);
1686  mpNoneBtn = mpFloatWin->mxWidget->EnableNoneBtn(mbNone);
1687  if (mpTodayBtn)
1688  mpTodayBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) );
1689  if (mpNoneBtn)
1690  mpNoneBtn->connect_clicked( LINK( this, CalendarField, ImplClickHdl ) );
1692  tools::Rectangle aRect(aPos, GetSizePixel());
1693  aRect.AdjustBottom( -1 );
1694  DockingManager* pDockingManager = vcl::Window::GetDockingManager();
1695  mpFloatWin->EnableDocking(true);
1696  pDockingManager->SetPopupModeEndHdl(mpFloatWin, LINK(this, CalendarField, ImplPopupModeEndHdl));
1698  }
1699  else
1700  {
1702  mpFloatWin->EnableDocking(false);
1703  EndDropDown();
1704  }
1705  return true;
1706 }
1707 
1709 {
1710  DateField::StateChanged( nStateChange );
1711 
1712  if ( ( nStateChange == StateChangedType::Style ) && GetSubEdit() )
1713  {
1714  WinBits nAllAlignmentBits = ( WB_LEFT | WB_CENTER | WB_RIGHT | WB_TOP | WB_VCENTER | WB_BOTTOM );
1715  WinBits nMyAlignment = GetStyle() & nAllAlignmentBits;
1716  GetSubEdit()->SetStyle( ( GetSubEdit()->GetStyle() & ~nAllAlignmentBits ) | nMyAlignment );
1717  }
1718 }
1719 
1720 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2791
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:1011
const Color & GetShadowColor() const
sal_Int16 GetNextYear() const
void SetBackground()
Definition: window3.cxx:100
void setDeferredProperties()
Definition: dialog.cxx:1572
virtual void LoseFocus() override
Definition: calendar.cxx:1139
void HideFocus()
Definition: window2.cxx:93
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:419
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
constexpr tools::Long Left() const
sal_Int16 getFirstDayOfWeek() const
bool Contains(const Point &rPOINT) const
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:1607
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:842
std::unique_ptr< IntDateSet > mpOldSelectTable
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:255
sal_Int64 n
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: calendar.cxx:115
virtual Size GetSizePixel() const
Definition: window.cxx:2402
void ImplUpdateDate(const Date &rDate)
Definition: calendar.cxx:774
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:1249
DataChangedEventType GetType() const
Definition: event.hxx:362
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2779
virtual void GetFocus() override
Definition: calendar.cxx:1577
std::unique_ptr< ImplCFieldFloat > mxWidget
Definition: calendar.cxx:1556
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
Size CalcWindowSizePixel() const
Definition: calendar.cxx:1495
const CommandWheelData * GetWheelData() const
FRIDAY
tools::Long mnWeekDayOffY
virtual void StateChanged(StateChangedType nStateChange) override
Definition: calendar.cxx:1708
void ImplUpdateSelection(IntDateSet *pOld)
Definition: calendar.cxx:786
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
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:1597
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
void DrawTextArray(const Point &rStartPt, const OUString &rStr, const tools::Long *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, SalLayoutFlags flags=SalLayoutFlags::NONE, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:900
const Color & GetHighlightColor() const
void ImplInitSettings()
Definition: calendar.cxx:124
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: calendar.cxx:1128
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:1369
void ImplShowMenu(const Point &rPos, const Date &rDate)
Definition: calendar.cxx:874
WinBits const WB_BOTTOM
WinBits const WB_TOP
tools::Rectangle GetDateRect(const Date &rDate) const
Definition: calendar.cxx:1382
sal_uInt16 GetMonth() const
virtual void GetFocus() override
Definition: calendar.cxx:1133
#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:1512
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: field2.cxx:2016
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: calendar.cxx:1004
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:1338
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:258
virtual void set_date(const Date &rDate)=0
constexpr void SetLeft(tools::Long v)
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:735
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:1429
sal_uInt16 GetDaysInMonth() const
virtual void Tracking(const TrackingEvent &rMEvt) override
Definition: calendar.cxx:1053
virtual bool ShowDropDown(bool bShow) override
Definition: calendar.cxx:1670
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: calendar.cxx:1612
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:863
void ImplMouseSelect(const Date &rDate, sal_uInt16 nHitTest)
Definition: calendar.cxx:809
void SetDay(sal_uInt16 nNewDay)
void ImplScroll(bool bPrev)
Definition: calendar.cxx:861
const vcl::Font & GetToolFont() const
std::unique_ptr< IntDateSet > mpSelectTable
static const LocaleDataWrapper & GetAppLocaleDataWrapper()
Get the application's locale data wrapper.
Definition: svapp.cxx:1541
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:1559
tools::Long GetNotchDelta() const
CommandWheelMode GetMode() const
WinBits const WB_VCENTER
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1165
sal_uInt16 GetMonthCount() const
Definition: calendar.cxx:1361
TUESDAY
OUString maDayText
void ImplFormat()
Definition: calendar.cxx:193
bool IsUpdateMode() const
Definition: window2.cxx:1167
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:168
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:688
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
virtual void Resize() override
Definition: calendar.cxx:1145
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:57
MONDAY
const AllSettings & GetSettings() const
Definition: outdev.hxx:287
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:1855
bool IsRGBEqual(const Color &rColor) const
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2809
void GrabFocus()
Definition: window.cxx:2976
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: calendar.cxx:1063
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:51
vcl::Window * GetParent() const
Definition: window2.cxx:1091
WinBits const WB_LEFT
IMPL_LINK_NOARG(CalendarField, ImplPopupModeEndHdl, FloatingWindow *, void)
Definition: calendar.cxx:1664
Date maOldFormatLastDate
constexpr void SetTop(tools::Long v)
void SetCurDate(const Date &rNewDate)
Definition: calendar.cxx:1279
bool IsTrackingEnded() const
Definition: event.hxx:261
void SetStyle(WinBits nStyle)
Definition: window.cxx:1962
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:2173
#define DAY_OFFY
Definition: calendar.cxx:42
const Point & GetMousePosPixel() const
void ReleaseMouse()
Definition: mouse.cxx:463
#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:1805
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:1571
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:797
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:73
Definition: ctrl.hxx:81
OUString maDayOfWeekText
virtual void GetFocus()
Definition: window.cxx:1841
const Color & GetButtonTextColor() const
constexpr tools::Long Height() const
WinBits const WB_BORDER
DayOfWeek
Date GetLastMonth() const
Definition: calendar.cxx:1351
void ImplTracking(const Point &rPos, bool bRepeat)
Definition: calendar.cxx:928
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dockwin.cxx:1100
bool IsVisible() const
Definition: window2.cxx:1096
Date maOldFormatFirstDate
#define SPIN_OFFX
Definition: calendar.cxx:48
void ImplEndTracking(bool bCancel)
Definition: calendar.cxx:947
::OutputDevice const * GetOutDev() const
Definition: window.cxx:568
bool IsLeft() const
Definition: event.hxx:149
void SetFirstDate(const Date &rNewFirstDate)
Definition: calendar.cxx:1329
tools::Long AdjustWidth(tools::Long n)
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: calendar.cxx:1151
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:1268
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:1566
void connect_activated(const Link< Calendar &, void > &rLink)
Definition: weld.hxx:1807
tools::Long mnDayOfWeekAry[7]
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:947
#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:2803
WinBits const WB_GROUP
sal_uInt16 GetDayOfYear() const
IMPL_LINK(CalendarField, ImplSelectHdl, weld::Calendar &, rCalendar, void)
Definition: calendar.cxx:1620
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1923
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:257
bool IsReallyVisible() const
Definition: window2.cxx:1101
sal_Int16 mnLastYear
tools::Long mnDaysOffY
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
bool HasFocus() const
Definition: window.cxx:2981
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:774
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1869
void loadCalendar(const OUString &rUniqueID, const css::lang::Locale &rLocale, bool bTimeZoneUTC=true)
aStr
const Color & GetWindowTextColor() const
void EndSelection()
Definition: calendar.cxx:1482
virtual void set_visible(bool visible)
Definition: weld.hxx:104
virtual void StateChanged(StateChangedType nType) override
Definition: spinfld.cxx:750
static DockingManager * GetDockingManager()
Definition: window2.cxx:792
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
void Select()
Definition: calendar.cxx:1263
virtual void StateChanged(StateChangedType nStateChange) override
Definition: calendar.cxx:1241
constexpr tools::Long GetHeight() const
virtual void Command(const CommandEvent &rCEvt) override
Definition: calendar.cxx:1196