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