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