Work on #7947 (CalendarView not respecting locale's start of week)
* support all weekdays as start of week, not only Sunday and Monday (at least Saturday is used for real, too) * introduce BWeekday as enumeration of weekdays (currently in Locale.h, may be moved somewhere else later) * change CalendarView to use BDate as its model, not individual values for day, month and year, such that no more date computation is done in CalendarView itself * some more style cleanups in CalendarView along the way * add monthwise paging to CalendarView * adjusted Deskbar and Time preflet accordingly git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42720 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,7 +22,7 @@ class BString;
|
||||
class BTimeZone;
|
||||
|
||||
|
||||
typedef enum {
|
||||
enum BDateElement {
|
||||
B_DATE_ELEMENT_INVALID = B_BAD_DATA,
|
||||
B_DATE_ELEMENT_YEAR = 0,
|
||||
B_DATE_ELEMENT_MONTH,
|
||||
@@ -31,14 +31,26 @@ typedef enum {
|
||||
B_DATE_ELEMENT_HOUR,
|
||||
B_DATE_ELEMENT_MINUTE,
|
||||
B_DATE_ELEMENT_SECOND
|
||||
} BDateElement;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
enum BNumberElement {
|
||||
B_NUMBER_ELEMENT_INVALID = B_BAD_DATA,
|
||||
B_NUMBER_ELEMENT_INTEGER = 0,
|
||||
B_NUMBER_ELEMENT_FRACTIONAL,
|
||||
B_NUMBER_ELEMENT_CURRENCY
|
||||
} BNumberElement;
|
||||
};
|
||||
|
||||
|
||||
// TODO: move this to BCalendar (should we ever have that) or BDate
|
||||
enum BWeekday {
|
||||
B_WEEKDAY_MONDAY = 1,
|
||||
B_WEEKDAY_TUESDAY,
|
||||
B_WEEKDAY_WEDNESDAY,
|
||||
B_WEEKDAY_THURSDAY,
|
||||
B_WEEKDAY_FRIDAY,
|
||||
B_WEEKDAY_SATURDAY,
|
||||
B_WEEKDAY_SUNDAY,
|
||||
};
|
||||
|
||||
|
||||
class BLocale {
|
||||
@@ -99,7 +111,7 @@ public:
|
||||
int& fieldCount, BDateFormatStyle style
|
||||
) const;
|
||||
|
||||
int StartOfWeek() const;
|
||||
status_t GetStartOfWeek(BWeekday* weekday) const;
|
||||
|
||||
// Time
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <Invoker.h>
|
||||
#include <List.h>
|
||||
#include <Locale.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
|
||||
@@ -21,12 +22,6 @@ class BMessage;
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
enum week_start {
|
||||
B_WEEK_START_MONDAY,
|
||||
B_WEEK_START_SUNDAY
|
||||
};
|
||||
|
||||
|
||||
class BCalendarView : public BView, public BInvoker {
|
||||
public:
|
||||
BCalendarView(BRect frame, const char* name,
|
||||
@@ -35,21 +30,10 @@ class BCalendarView : public BView, public BInvoker {
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE);
|
||||
|
||||
BCalendarView(BRect frame, const char *name,
|
||||
week_start start,
|
||||
uint32 resizeMask = B_FOLLOW_LEFT
|
||||
| B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE);
|
||||
|
||||
BCalendarView(const char* name,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE);
|
||||
|
||||
BCalendarView(const char* name,
|
||||
week_start start, uint32 flags = B_WILL_DRAW
|
||||
| B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
|
||||
virtual ~BCalendarView();
|
||||
|
||||
BCalendarView(BMessage* archive);
|
||||
@@ -58,12 +42,7 @@ class BCalendarView : public BView, public BInvoker {
|
||||
bool deep = true) const;
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
@@ -76,8 +55,6 @@ class BCalendarView : public BView, public BInvoker {
|
||||
virtual void DrawWeekNumber(BView* owner, BRect frame,
|
||||
const char* text);
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
uint32 SelectionCommand() const;
|
||||
BMessage* SelectionMessage() const;
|
||||
virtual void SetSelectionMessage(BMessage* message);
|
||||
@@ -86,23 +63,13 @@ class BCalendarView : public BView, public BInvoker {
|
||||
BMessage* InvocationMessage() const;
|
||||
virtual void SetInvocationMessage(BMessage* message);
|
||||
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual status_t Invoke(BMessage* message = NULL);
|
||||
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseMoved(BPoint point, uint32 code,
|
||||
const BMessage *dragMessage);
|
||||
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage *message, int32 index,
|
||||
BMessage *specifier, int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
virtual status_t Perform(perform_code code, void* arg);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* width, float* height);
|
||||
|
||||
@@ -118,8 +85,8 @@ class BCalendarView : public BView, public BInvoker {
|
||||
bool SetDate(const BDate& date);
|
||||
bool SetDate(int32 year, int32 month, int32 day);
|
||||
|
||||
week_start WeekStart() const;
|
||||
void SetWeekStart(week_start start);
|
||||
BWeekday StartOfWeek() const;
|
||||
void SetStartOfWeek(BWeekday startOfWeek);
|
||||
|
||||
bool IsDayNameHeaderVisible() const;
|
||||
void SetDayNameHeaderVisible(bool visible);
|
||||
@@ -127,43 +94,19 @@ class BCalendarView : public BView, public BInvoker {
|
||||
bool IsWeekNumberHeaderVisible() const;
|
||||
void SetWeekNumberHeaderVisible(bool visible);
|
||||
|
||||
private:
|
||||
void _InitObject();
|
||||
|
||||
void _SetToDay();
|
||||
void _GetYearMonth(int32 *year, int32 *month) const;
|
||||
void _GetPreferredSize(float *width, float *height);
|
||||
|
||||
void _SetupDayNames();
|
||||
void _SetupDayNumbers();
|
||||
void _SetupWeekNumbers();
|
||||
|
||||
void _DrawDays();
|
||||
void _DrawFocusRect();
|
||||
void _DrawDayHeader();
|
||||
void _DrawWeekHeader();
|
||||
void _DrawDay(int32 curRow, int32 curColumn,
|
||||
int32 row, int32 column, int32 counter,
|
||||
BRect frame, const char *text,
|
||||
bool focus = false);
|
||||
void _DrawItem(BView *owner, BRect frame,
|
||||
const char *text, bool isSelected = false,
|
||||
bool isEnabled = true, bool focus = false);
|
||||
|
||||
void _UpdateSelection();
|
||||
BRect _FirstCalendarItemFrame() const;
|
||||
BRect _SetNewSelectedDay(const BPoint &where);
|
||||
|
||||
BCalendarView(const BCalendarView &view);
|
||||
BCalendarView& operator=(const BCalendarView &view);
|
||||
|
||||
private:
|
||||
struct Selection {
|
||||
Selection()
|
||||
: row(0), column(0) { }
|
||||
: row(0), column(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SetTo(int32 _row, int32 _column)
|
||||
{ row = _row; column = _column; }
|
||||
void
|
||||
SetTo(int32 _row, int32 _column)
|
||||
{
|
||||
row = _row;
|
||||
column = _column;
|
||||
}
|
||||
|
||||
int32 row;
|
||||
int32 column;
|
||||
@@ -187,29 +130,61 @@ class BCalendarView : public BView, public BInvoker {
|
||||
|| column != s.column;
|
||||
}
|
||||
};
|
||||
|
||||
void _InitObject();
|
||||
|
||||
void _SetToDay();
|
||||
void _GetYearMonthForSelection(
|
||||
const Selection& selection, int32* year,
|
||||
int32* month) const;
|
||||
void _GetPreferredSize(float* width, float* height);
|
||||
|
||||
void _SetupDayNames();
|
||||
void _SetupDayNumbers();
|
||||
void _SetupWeekNumbers();
|
||||
|
||||
void _DrawDays();
|
||||
void _DrawFocusRect();
|
||||
void _DrawDayHeader();
|
||||
void _DrawWeekHeader();
|
||||
void _DrawDay(int32 curRow, int32 curColumn,
|
||||
int32 row, int32 column, int32 counter,
|
||||
BRect frame, const char* text,
|
||||
bool focus = false);
|
||||
void _DrawItem(BView* owner, BRect frame,
|
||||
const char* text, bool isSelected = false,
|
||||
bool isEnabled = true, bool focus = false);
|
||||
|
||||
void _UpdateSelection();
|
||||
BRect _FirstCalendarItemFrame() const;
|
||||
BRect _SetNewSelectedDay(const BPoint& where);
|
||||
|
||||
BRect _RectOfDay(const Selection& selection) const;
|
||||
|
||||
private:
|
||||
BMessage* fSelectionMessage;
|
||||
|
||||
int32 fDay;
|
||||
int32 fYear;
|
||||
int32 fMonth;
|
||||
BDate fDate;
|
||||
|
||||
Selection fFocusedDay;
|
||||
bool fFocusChanged;
|
||||
Selection fNewFocusedDay;
|
||||
bool fFocusChanged;
|
||||
|
||||
Selection fSelectedDay;
|
||||
Selection fNewSelectedDay;
|
||||
bool fSelectionChanged;
|
||||
|
||||
week_start fWeekStart;
|
||||
int32 fStartOfWeek;
|
||||
bool fDayNameHeaderVisible;
|
||||
bool fWeekNumberHeaderVisible;
|
||||
|
||||
BString fDayNames[7];
|
||||
BString fWeekNumbers[6];
|
||||
BString fDayNumbers[6][7];
|
||||
|
||||
// hide copy constructor & assignment
|
||||
BCalendarView(const BCalendarView& view);
|
||||
BCalendarView& operator=(const BCalendarView& view);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
|
||||
using BPrivate::BCalendarView;
|
||||
using BPrivate::B_WEEK_START_SUNDAY;
|
||||
using BPrivate::B_WEEK_START_MONDAY;
|
||||
|
||||
|
||||
enum {
|
||||
@@ -90,17 +88,13 @@ CalendarMenuWindow::CalendarMenuWindow(BPoint where)
|
||||
{
|
||||
SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||
|
||||
BPrivate::week_start startOfWeek
|
||||
= (BPrivate::week_start)BLocale::Default()->StartOfWeek();
|
||||
|
||||
RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY);
|
||||
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
|
||||
fYearLabel = new BStringView("year", "");
|
||||
fMonthLabel = new BStringView("month", "");
|
||||
|
||||
fCalendarView = new BCalendarView(Bounds(), "calendar",
|
||||
startOfWeek, B_FOLLOW_ALL);
|
||||
fCalendarView = new BCalendarView(Bounds(), "calendar", B_FOLLOW_ALL);
|
||||
fCalendarView->SetInvocationMessage(new BMessage(kInvokationMessage));
|
||||
|
||||
BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL);
|
||||
|
||||
+40
-14
@@ -30,8 +30,6 @@
|
||||
|
||||
|
||||
using BPrivate::ObjectDeleter;
|
||||
using BPrivate::B_WEEK_START_MONDAY;
|
||||
using BPrivate::B_WEEK_START_SUNDAY;
|
||||
|
||||
|
||||
BLocale::BLocale(const BLanguage* language,
|
||||
@@ -353,26 +351,54 @@ BLocale::GetDateFields(BDateElement*& fields, int& fieldCount,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
BLocale::StartOfWeek() const
|
||||
status_t
|
||||
BLocale::GetStartOfWeek(BWeekday* startOfWeek) const
|
||||
{
|
||||
if (startOfWeek == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BAutolock lock(fLock);
|
||||
if (!lock.IsLocked())
|
||||
return B_WOULD_BLOCK;
|
||||
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
Calendar* c = Calendar::createInstance(
|
||||
*BFormattingConventions::Private(&fConventions).ICULocale(),
|
||||
err);
|
||||
ObjectDeleter<Calendar> calendar = Calendar::createInstance(
|
||||
*BFormattingConventions::Private(&fConventions).ICULocale(), err);
|
||||
|
||||
if (err == U_ZERO_ERROR && c->getFirstDayOfWeek(err) == UCAL_SUNDAY) {
|
||||
delete c;
|
||||
return B_WEEK_START_SUNDAY;
|
||||
} else {
|
||||
delete c;
|
||||
// Might be another day, but BeAPI will not handle it
|
||||
return B_WEEK_START_MONDAY;
|
||||
if (U_FAILURE(err))
|
||||
return B_ERROR;
|
||||
|
||||
UCalendarDaysOfWeek icuWeekStart = calendar->getFirstDayOfWeek(err);
|
||||
if (U_FAILURE(err))
|
||||
return B_ERROR;
|
||||
|
||||
switch (icuWeekStart) {
|
||||
case UCAL_SUNDAY:
|
||||
*startOfWeek = B_WEEKDAY_SUNDAY;
|
||||
break;
|
||||
case UCAL_MONDAY:
|
||||
*startOfWeek = B_WEEKDAY_MONDAY;
|
||||
break;
|
||||
case UCAL_TUESDAY:
|
||||
*startOfWeek = B_WEEKDAY_TUESDAY;
|
||||
break;
|
||||
case UCAL_WEDNESDAY:
|
||||
*startOfWeek = B_WEEKDAY_WEDNESDAY;
|
||||
break;
|
||||
case UCAL_THURSDAY:
|
||||
*startOfWeek = B_WEEKDAY_THURSDAY;
|
||||
break;
|
||||
case UCAL_FRIDAY:
|
||||
*startOfWeek = B_WEEKDAY_FRIDAY;
|
||||
break;
|
||||
case UCAL_SATURDAY:
|
||||
*startOfWeek = B_WEEKDAY_SATURDAY;
|
||||
break;
|
||||
default:
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+132
-322
@@ -35,37 +35,16 @@ FontHeight(const BView *view)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
BCalendarView::BCalendarView(BRect frame, const char *name,
|
||||
uint32 resizeMask, uint32 flags)
|
||||
BCalendarView::BCalendarView(BRect frame, const char* name, uint32 resizeMask,
|
||||
uint32 flags)
|
||||
:
|
||||
BView(frame, name, resizeMask, flags),
|
||||
BInvoker(),
|
||||
fSelectionMessage(NULL),
|
||||
fDay(0),
|
||||
fYear(0),
|
||||
fMonth(0),
|
||||
fDate(),
|
||||
fFocusChanged(false),
|
||||
fSelectionChanged(false),
|
||||
fWeekStart(B_WEEK_START_SUNDAY),
|
||||
fDayNameHeaderVisible(true),
|
||||
fWeekNumberHeaderVisible(true)
|
||||
{
|
||||
_InitObject();
|
||||
}
|
||||
|
||||
|
||||
BCalendarView::BCalendarView(BRect frame, const char *name, week_start start,
|
||||
uint32 resizeMask, uint32 flags)
|
||||
:
|
||||
BView(frame, name, resizeMask, flags),
|
||||
BInvoker(),
|
||||
fSelectionMessage(NULL),
|
||||
fDay(0),
|
||||
fYear(0),
|
||||
fMonth(0),
|
||||
fFocusChanged(false),
|
||||
fSelectionChanged(false),
|
||||
fWeekStart(start),
|
||||
fStartOfWeek((int32)B_WEEKDAY_MONDAY),
|
||||
fDayNameHeaderVisible(true),
|
||||
fWeekNumberHeaderVisible(true)
|
||||
{
|
||||
@@ -78,31 +57,10 @@ BCalendarView::BCalendarView(const char* name, uint32 flags)
|
||||
BView(name, flags),
|
||||
BInvoker(),
|
||||
fSelectionMessage(NULL),
|
||||
fDay(0),
|
||||
fYear(0),
|
||||
fMonth(0),
|
||||
fDate(),
|
||||
fFocusChanged(false),
|
||||
fSelectionChanged(false),
|
||||
fWeekStart(B_WEEK_START_SUNDAY),
|
||||
fDayNameHeaderVisible(true),
|
||||
fWeekNumberHeaderVisible(true)
|
||||
{
|
||||
_InitObject();
|
||||
}
|
||||
|
||||
|
||||
BCalendarView::BCalendarView(const char* name, week_start start,
|
||||
uint32 flags)
|
||||
:
|
||||
BView(name, flags),
|
||||
BInvoker(),
|
||||
fSelectionMessage(NULL),
|
||||
fDay(0),
|
||||
fYear(0),
|
||||
fMonth(0),
|
||||
fFocusChanged(false),
|
||||
fSelectionChanged(false),
|
||||
fWeekStart(start),
|
||||
fStartOfWeek((int32)B_WEEKDAY_MONDAY),
|
||||
fDayNameHeaderVisible(true),
|
||||
fWeekNumberHeaderVisible(true)
|
||||
{
|
||||
@@ -121,12 +79,10 @@ BCalendarView::BCalendarView(BMessage *archive)
|
||||
BView(archive),
|
||||
BInvoker(),
|
||||
fSelectionMessage(NULL),
|
||||
fDay(0),
|
||||
fYear(0),
|
||||
fMonth(0),
|
||||
fDate(archive),
|
||||
fFocusChanged(false),
|
||||
fSelectionChanged(false),
|
||||
fWeekStart(B_WEEK_START_SUNDAY),
|
||||
fStartOfWeek((int32)B_WEEKDAY_MONDAY),
|
||||
fDayNameHeaderVisible(true),
|
||||
fWeekNumberHeaderVisible(true)
|
||||
{
|
||||
@@ -142,16 +98,8 @@ BCalendarView::BCalendarView(BMessage *archive)
|
||||
SetSelectionMessage(selectionMessage);
|
||||
}
|
||||
|
||||
if (archive->FindInt32("_day", &fDay) != B_OK
|
||||
|| archive->FindInt32("_month", &fMonth) != B_OK
|
||||
|| archive->FindInt32("_year", &fYear) != B_OK) {
|
||||
BDate date = BDate::CurrentDate(B_LOCAL_TIME);
|
||||
date.GetDate(&fYear, &fMonth, &fDay);
|
||||
}
|
||||
|
||||
int32 start;
|
||||
if (archive->FindInt32("_weekStart", &start) == B_OK)
|
||||
fWeekStart = week_start(start);
|
||||
if (archive->FindInt32("_weekStart", &fStartOfWeek) != B_OK)
|
||||
fStartOfWeek = (int32)B_WEEKDAY_MONDAY;
|
||||
|
||||
if (archive->FindBool("_dayHeader", &fDayNameHeaderVisible) != B_OK)
|
||||
fDayNameHeaderVisible = true;
|
||||
@@ -187,16 +135,10 @@ BCalendarView::Archive(BMessage *archive, bool deep) const
|
||||
status = archive->AddMessage("_selectMsg", SelectionMessage());
|
||||
|
||||
if (status == B_OK)
|
||||
status = archive->AddInt32("_day", fDay);
|
||||
status = fDate.Archive(archive);
|
||||
|
||||
if (status == B_OK)
|
||||
status = archive->AddInt32("_month", fMonth);
|
||||
|
||||
if (status == B_OK)
|
||||
status = archive->AddInt32("_year", fYear);
|
||||
|
||||
if (status == B_OK)
|
||||
status = archive->AddInt32("_weekStart", int32(fWeekStart));
|
||||
status = archive->AddInt32("_weekStart", fStartOfWeek);
|
||||
|
||||
if (status == B_OK)
|
||||
status = archive->AddBool("_dayHeader", fDayNameHeaderVisible);
|
||||
@@ -218,34 +160,6 @@ BCalendarView::AttachedToWindow()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::DetachedFromWindow()
|
||||
{
|
||||
BView::DetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::AllAttached()
|
||||
{
|
||||
BView::AllAttached();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::AllDetached()
|
||||
{
|
||||
BView::AllDetached();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::FrameMoved(BPoint newPosition)
|
||||
{
|
||||
BView::FrameMoved(newPosition);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::FrameResized(float width, float height)
|
||||
{
|
||||
@@ -308,13 +222,6 @@ BCalendarView::DrawWeekNumber(BView *owner, BRect frame, const char *text)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::MessageReceived(BMessage *message)
|
||||
{
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
BCalendarView::SelectionCommand() const
|
||||
{
|
||||
@@ -361,13 +268,6 @@ BCalendarView::SetInvocationMessage(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::WindowActivated(bool state)
|
||||
{
|
||||
BView::WindowActivated(state);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::MakeFocus(bool state)
|
||||
{
|
||||
@@ -407,11 +307,11 @@ BCalendarView::Invoke(BMessage *message)
|
||||
|
||||
int32 year;
|
||||
int32 month;
|
||||
_GetYearMonth(&year, &month);
|
||||
_GetYearMonthForSelection(fSelectedDay, &year, &month);
|
||||
|
||||
clone.AddInt32("year", year);
|
||||
clone.AddInt32("month", month);
|
||||
clone.AddInt32("day", fDay);
|
||||
clone.AddInt32("year", fDate.Year());
|
||||
clone.AddInt32("month", fDate.Month());
|
||||
clone.AddInt32("day", fDate.Day());
|
||||
|
||||
if (message)
|
||||
status = BInvoker::Invoke(&clone);
|
||||
@@ -422,13 +322,6 @@ BCalendarView::Invoke(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::MouseUp(BPoint point)
|
||||
{
|
||||
BView::MouseUp(point);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::MouseDown(BPoint where)
|
||||
{
|
||||
@@ -477,14 +370,6 @@ BCalendarView::MouseDown(BPoint where)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::MouseMoved(BPoint point, uint32 code,
|
||||
const BMessage *dragMessage)
|
||||
{
|
||||
BView::MouseMoved(point, code, dragMessage);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::KeyDown(const char* bytes, int32 numBytes)
|
||||
{
|
||||
@@ -496,7 +381,6 @@ BCalendarView::KeyDown(const char *bytes, int32 numBytes)
|
||||
|
||||
switch (bytes[0]) {
|
||||
case B_LEFT_ARROW:
|
||||
{
|
||||
column -= 1;
|
||||
if (column < 0) {
|
||||
column = kColumns - 1;
|
||||
@@ -505,10 +389,9 @@ BCalendarView::KeyDown(const char *bytes, int32 numBytes)
|
||||
fFocusChanged = true;
|
||||
} else
|
||||
fFocusChanged = true;
|
||||
} break;
|
||||
break;
|
||||
|
||||
case B_RIGHT_ARROW:
|
||||
{
|
||||
column += 1;
|
||||
if (column == kColumns) {
|
||||
column = 0;
|
||||
@@ -517,24 +400,43 @@ BCalendarView::KeyDown(const char *bytes, int32 numBytes)
|
||||
fFocusChanged = true;
|
||||
} else
|
||||
fFocusChanged = true;
|
||||
} break;
|
||||
break;
|
||||
|
||||
case B_UP_ARROW:
|
||||
{
|
||||
row -= 1;
|
||||
if (row >= 0)
|
||||
fFocusChanged = true;
|
||||
} break;
|
||||
break;
|
||||
|
||||
case B_DOWN_ARROW:
|
||||
{
|
||||
row += 1;
|
||||
if (row < kRows)
|
||||
fFocusChanged = true;
|
||||
} break;
|
||||
break;
|
||||
|
||||
case B_PAGE_UP:
|
||||
{
|
||||
BDate date(fDate);
|
||||
date.AddMonths(-1);
|
||||
SetDate(date);
|
||||
|
||||
Invoke();
|
||||
break;
|
||||
}
|
||||
|
||||
case B_PAGE_DOWN:
|
||||
{
|
||||
BDate date(fDate);
|
||||
date.AddMonths(1);
|
||||
SetDate(date);
|
||||
|
||||
Invoke();
|
||||
break;
|
||||
}
|
||||
|
||||
case B_RETURN:
|
||||
case B_SPACE: {
|
||||
case B_SPACE:
|
||||
{
|
||||
fSelectionChanged = true;
|
||||
BPoint pt = _RectOfDay(fFocusedDay).LeftTop();
|
||||
Draw(_SetNewSelectedDay(pt + BPoint(4.0, 4.0)));
|
||||
@@ -542,7 +444,8 @@ BCalendarView::KeyDown(const char *bytes, int32 numBytes)
|
||||
fSelectionChanged = false;
|
||||
|
||||
Invoke();
|
||||
} break;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::KeyDown(bytes, numBytes);
|
||||
@@ -558,28 +461,6 @@ BCalendarView::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
|
||||
BHandler*
|
||||
BCalendarView::ResolveSpecifier(BMessage *message, int32 index,
|
||||
BMessage *specifier, int32 form, const char *property)
|
||||
{
|
||||
return BView::ResolveSpecifier(message, index, specifier, form, property);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCalendarView::GetSupportedSuites(BMessage *data)
|
||||
{
|
||||
return BView::GetSupportedSuites(data);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCalendarView::Perform(perform_code code, void *arg)
|
||||
{
|
||||
return BView::Perform(code, arg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::ResizeToPreferred()
|
||||
{
|
||||
@@ -611,23 +492,21 @@ BCalendarView::MinSize()
|
||||
{
|
||||
float width, height;
|
||||
_GetPreferredSize(&width, &height);
|
||||
return BLayoutUtils::ComposeSize(ExplicitMinSize(),
|
||||
BSize(width, height));
|
||||
return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(width, height));
|
||||
}
|
||||
|
||||
|
||||
BSize
|
||||
BCalendarView::PreferredSize()
|
||||
{
|
||||
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(),
|
||||
MinSize());
|
||||
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), MinSize());
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BCalendarView::Day() const
|
||||
{
|
||||
return fDay;
|
||||
return fDate.Day();
|
||||
}
|
||||
|
||||
|
||||
@@ -635,8 +514,7 @@ int32
|
||||
BCalendarView::Year() const
|
||||
{
|
||||
int32 year;
|
||||
int32 month;
|
||||
_GetYearMonth(&year, &month);
|
||||
_GetYearMonthForSelection(fSelectedDay, &year, NULL);
|
||||
|
||||
return year;
|
||||
}
|
||||
@@ -645,9 +523,8 @@ BCalendarView::Year() const
|
||||
int32
|
||||
BCalendarView::Month() const
|
||||
{
|
||||
int32 year;
|
||||
int32 month;
|
||||
_GetYearMonth(&year, &month);
|
||||
_GetYearMonthForSelection(fSelectedDay, NULL, &month);
|
||||
|
||||
return month;
|
||||
}
|
||||
@@ -658,8 +535,8 @@ BCalendarView::Date() const
|
||||
{
|
||||
int32 year;
|
||||
int32 month;
|
||||
_GetYearMonth(&year, &month);
|
||||
return BDate(year, month, fDay);
|
||||
_GetYearMonthForSelection(fSelectedDay, &year, &month);
|
||||
return BDate(year, month, fDate.Day());
|
||||
}
|
||||
|
||||
|
||||
@@ -669,21 +546,12 @@ BCalendarView::SetDate(const BDate &date)
|
||||
if (!date.IsValid())
|
||||
return false;
|
||||
|
||||
return SetDate(date.Year(), date.Month(), date.Day());
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BCalendarView::SetDate(int32 year, int32 month, int32 day)
|
||||
{
|
||||
if (!BDate(year, month, day).IsValid())
|
||||
return false;
|
||||
|
||||
if (fYear == year && fMonth == month && fDay == day)
|
||||
if (fDate == date)
|
||||
return true;
|
||||
|
||||
fDay = day;
|
||||
if (fYear == year && fMonth == month) {
|
||||
if (fDate.Year() == date.Year() && fDate.Month() == date.Month()) {
|
||||
fDate = date;
|
||||
|
||||
_SetToDay();
|
||||
// update focus
|
||||
fFocusChanged = true;
|
||||
@@ -696,8 +564,7 @@ BCalendarView::SetDate(int32 year, int32 month, int32 day)
|
||||
Draw(_RectOfDay(fNewSelectedDay));
|
||||
fSelectionChanged = false;
|
||||
} else {
|
||||
fYear = year;
|
||||
fMonth = month;
|
||||
fDate = date;
|
||||
|
||||
_SetupDayNumbers();
|
||||
_SetupWeekNumbers();
|
||||
@@ -716,20 +583,27 @@ BCalendarView::SetDate(int32 year, int32 month, int32 day)
|
||||
}
|
||||
|
||||
|
||||
week_start
|
||||
BCalendarView::WeekStart() const
|
||||
bool
|
||||
BCalendarView::SetDate(int32 year, int32 month, int32 day)
|
||||
{
|
||||
return fWeekStart;
|
||||
return SetDate(BDate(year, month, day));
|
||||
}
|
||||
|
||||
|
||||
BWeekday
|
||||
BCalendarView::StartOfWeek() const
|
||||
{
|
||||
return BWeekday(fStartOfWeek);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::SetWeekStart(week_start start)
|
||||
BCalendarView::SetStartOfWeek(BWeekday startOfWeek)
|
||||
{
|
||||
if (fWeekStart == start)
|
||||
if (fStartOfWeek == (int32)startOfWeek)
|
||||
return;
|
||||
|
||||
fWeekStart = start;
|
||||
fStartOfWeek = (int32)startOfWeek;
|
||||
|
||||
_SetupDayNames();
|
||||
_SetupDayNumbers();
|
||||
@@ -778,8 +652,9 @@ BCalendarView::SetWeekNumberHeaderVisible(bool visible)
|
||||
void
|
||||
BCalendarView::_InitObject()
|
||||
{
|
||||
BDate date = BDate::CurrentDate(B_LOCAL_TIME);
|
||||
date.GetDate(&fYear, &fMonth, &fDay);
|
||||
fDate = BDate::CurrentDate(B_LOCAL_TIME);
|
||||
|
||||
BLocale::Default()->GetStartOfWeek((BWeekday*)&fStartOfWeek);
|
||||
|
||||
_SetupDayNames();
|
||||
_SetupDayNumbers();
|
||||
@@ -790,89 +665,48 @@ BCalendarView::_InitObject()
|
||||
void
|
||||
BCalendarView::_SetToDay()
|
||||
{
|
||||
BDate date(fYear, fMonth, 1);
|
||||
BDate date(fDate.Year(), fDate.Month(), 1);
|
||||
if (!date.IsValid())
|
||||
return;
|
||||
|
||||
fNewFocusedDay.SetTo(0, 0);
|
||||
fNewSelectedDay.SetTo(0, 0);
|
||||
const int32 firstDayOffset = (7 + date.DayOfWeek() - fStartOfWeek) % 7;
|
||||
|
||||
const int32 dayCountCurrent = date.DaysInMonth();
|
||||
|
||||
int32 firstDay = date.DayOfWeek();
|
||||
if (fWeekStart == B_WEEK_START_MONDAY)
|
||||
firstDay = ((firstDay - 1) < 0) ? 6 : firstDay -1;
|
||||
|
||||
int32 counter = 0;
|
||||
int32 day = 1 - firstDayOffset;
|
||||
for (int32 row = 0; row < 6; ++row) {
|
||||
for (int32 column = 0; column < 7; ++column) {
|
||||
int32 day = counter - (firstDay - 1);
|
||||
if (counter >= firstDay
|
||||
&& counter <= dayCountCurrent + firstDay - 1) {
|
||||
if (day == fDay) {
|
||||
if (day == fDate.Day()) {
|
||||
fNewFocusedDay.SetTo(row, column);
|
||||
fNewSelectedDay.SetTo(row, column);
|
||||
return;
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
day++;
|
||||
}
|
||||
}
|
||||
|
||||
fNewFocusedDay.SetTo(0, 0);
|
||||
fNewSelectedDay.SetTo(0, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::_GetYearMonth(int32 *year, int32 *month) const
|
||||
BCalendarView::_GetYearMonthForSelection(const Selection& selection,
|
||||
int32* year, int32* month) const
|
||||
{
|
||||
BDate date(fYear, fMonth, 1);
|
||||
BDate startOfMonth(fDate.Year(), fDate.Month(), 1);
|
||||
const int32 firstDayOffset
|
||||
= (7 + startOfMonth.DayOfWeek() - fStartOfWeek) % 7;
|
||||
const int32 daysInMonth = startOfMonth.DaysInMonth();
|
||||
|
||||
const int32 dayCountCurrent = date.DaysInMonth();
|
||||
|
||||
int32 firstDay = date.DayOfWeek();
|
||||
if (fWeekStart == B_WEEK_START_MONDAY)
|
||||
firstDay = ((firstDay - 1) < 0) ? 6 : firstDay -1;
|
||||
|
||||
// set the date to one month before
|
||||
if (date.Month() == 1)
|
||||
date.SetDate(date.Year() -1, 12, fDay);
|
||||
else
|
||||
date.SetDate(date.Year(), date.Month() - 1, fDay);
|
||||
|
||||
const int32 currRow = fSelectedDay.row;
|
||||
const int32 currColumn = fSelectedDay.column;
|
||||
|
||||
*year = fYear;
|
||||
*month = fMonth;
|
||||
|
||||
int32 counter = 0;
|
||||
for (int32 row = 0; row < 6; ++row) {
|
||||
for (int32 column = 0; column < 7; ++column) {
|
||||
if (counter < firstDay
|
||||
|| counter > dayCountCurrent + firstDay - 1) {
|
||||
if (counter - firstDay < 0) {
|
||||
if (row == currRow && column == currColumn) {
|
||||
BDate date(fDate);
|
||||
const int32 dayOffset = selection.row * 7 + selection.column;
|
||||
if (dayOffset < firstDayOffset)
|
||||
date.AddMonths(-1);
|
||||
else if (dayOffset >= firstDayOffset + daysInMonth)
|
||||
date.AddMonths(1);
|
||||
if (year != NULL)
|
||||
*year = date.Year();
|
||||
if (month != NULL)
|
||||
*month = date.Month();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (row == currRow && column == currColumn) {
|
||||
*year = fYear;
|
||||
*month = fMonth +1;
|
||||
if (fMonth == 12) {
|
||||
*year = fYear +1;
|
||||
*month = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (row == currRow && column == currColumn)
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -911,87 +745,60 @@ BCalendarView::_GetPreferredSize(float *_width, float *_height)
|
||||
void
|
||||
BCalendarView::_SetupDayNames()
|
||||
{
|
||||
const BDate date(fYear, fMonth, fDay);
|
||||
if (!date.IsValid())
|
||||
return;
|
||||
|
||||
if (fWeekStart == B_WEEK_START_MONDAY) {
|
||||
for (int32 i = 1; i <= 7; ++i) {
|
||||
fDayNames[i -1] = date.ShortDayName(i);
|
||||
}
|
||||
} else {
|
||||
fDayNames[0] = date.ShortDayName(7);
|
||||
for (int32 i = 1; i < 7; ++i) {
|
||||
fDayNames[i] = date.ShortDayName(i);
|
||||
}
|
||||
}
|
||||
for (int32 i = 0; i <= 6; ++i)
|
||||
fDayNames[i] = fDate.ShortDayName(1 + (fStartOfWeek - 1 + i) % 7);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::_SetupDayNumbers()
|
||||
{
|
||||
BDate date(fYear, fMonth, 1);
|
||||
if (!date.IsValid())
|
||||
BDate startOfMonth(fDate.Year(), fDate.Month(), 1);
|
||||
if (!startOfMonth.IsValid())
|
||||
return;
|
||||
|
||||
fFocusedDay.SetTo(0, 0);
|
||||
fSelectedDay.SetTo(0, 0);
|
||||
fNewFocusedDay.SetTo(0, 0);
|
||||
|
||||
const int32 dayCountCurrent = date.DaysInMonth();
|
||||
|
||||
int32 firstDay = date.DayOfWeek();
|
||||
if (fWeekStart == B_WEEK_START_MONDAY)
|
||||
firstDay = ((firstDay - 1) < 0) ? 6 : firstDay -1;
|
||||
const int32 daysInMonth = startOfMonth.DaysInMonth();
|
||||
const int32 firstDayOffset
|
||||
= (7 + startOfMonth.DayOfWeek() - fStartOfWeek) % 7;
|
||||
|
||||
// calc the last day one month before
|
||||
if (date.Month() == 1)
|
||||
date.SetDate(date.Year() -1, 12, 1);
|
||||
else
|
||||
date.SetDate(date.Year(), date.Month() - 1, 1);
|
||||
const int32 lastDayBefore = date.DaysInMonth();
|
||||
BDate lastDayInMonthBefore(startOfMonth);
|
||||
lastDayInMonthBefore.AddDays(-1);
|
||||
const int32 lastDayBefore = lastDayInMonthBefore.DaysInMonth();
|
||||
|
||||
int32 counter = 0;
|
||||
int32 firstDayAfter = 1;
|
||||
for (int32 row = 0; row < 6; ++row) {
|
||||
for (int32 column = 0; column < 7; ++column) {
|
||||
int32 day = counter - (firstDay - 1);
|
||||
if (counter < firstDay
|
||||
|| counter > dayCountCurrent + firstDay - 1) {
|
||||
if (counter - firstDay < 0)
|
||||
int32 day = 1 + counter - firstDayOffset;
|
||||
if (counter < firstDayOffset)
|
||||
day += lastDayBefore;
|
||||
else
|
||||
else if (counter >= firstDayOffset + daysInMonth)
|
||||
day = firstDayAfter++;
|
||||
} else {
|
||||
if (day == fDay) {
|
||||
else if (day == fDate.Day()) {
|
||||
fFocusedDay.SetTo(row, column);
|
||||
fSelectedDay.SetTo(row, column);
|
||||
fNewFocusedDay.SetTo(row, column);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
fDayNumbers[row][column].SetTo("");
|
||||
fDayNumbers[row][column].Truncate(0);
|
||||
fDayNumbers[row][column] << day;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCalendarView::_SetupWeekNumbers()
|
||||
{
|
||||
BDate date(fYear, fMonth, 1);
|
||||
BDate date(fDate.Year(), fDate.Month(), 1);
|
||||
if (!date.IsValid())
|
||||
return;
|
||||
|
||||
// date on Thursday determines week number (ISO 8601)
|
||||
int dayOfWeek = date.DayOfWeek();
|
||||
// adjust weekday if Monday is week start,
|
||||
// then Sunday is last day in week
|
||||
if (fWeekStart == B_WEEK_START_MONDAY && dayOfWeek == 0)
|
||||
dayOfWeek = 7;
|
||||
date.AddDays(4 - dayOfWeek);
|
||||
|
||||
for (int32 row = 0; row < 6; ++row) {
|
||||
fWeekNumbers[row].SetTo("");
|
||||
fWeekNumbers[row] << date.WeekNumber();
|
||||
@@ -1004,24 +811,22 @@ void
|
||||
BCalendarView::_DrawDay(int32 currRow, int32 currColumn, int32 row,
|
||||
int32 column, int32 counter, BRect frame, const char* text, bool focus)
|
||||
{
|
||||
const BDate date(fYear, fMonth, 1);
|
||||
const int32 daysMonth = date.DaysInMonth();
|
||||
|
||||
int32 firstDay = date.DayOfWeek();
|
||||
if (fWeekStart == B_WEEK_START_MONDAY)
|
||||
firstDay = ((firstDay - 1) < 0) ? 6 : firstDay -1;
|
||||
BDate startOfMonth(fDate.Year(), fDate.Month(), 1);
|
||||
const int32 firstDayOffset
|
||||
= (7 + startOfMonth.DayOfWeek() - fStartOfWeek) % 7;
|
||||
const int32 daysMonth = startOfMonth.DaysInMonth();
|
||||
|
||||
bool enabled = true;
|
||||
bool selected = false;
|
||||
// check for the current date
|
||||
if (currRow == row && currColumn == column) {
|
||||
selected = true; // draw current date selected
|
||||
if (counter <= firstDay || counter > firstDay + daysMonth) {
|
||||
if (counter <= firstDayOffset || counter > firstDayOffset + daysMonth) {
|
||||
enabled = false; // days of month before or after
|
||||
selected = false; // not selected but able to get focus
|
||||
}
|
||||
} else {
|
||||
if (counter <= firstDay || counter > firstDay + daysMonth)
|
||||
if (counter <= firstDayOffset || counter > firstDayOffset + daysMonth)
|
||||
enabled = false; // days of month before or after
|
||||
}
|
||||
|
||||
@@ -1081,8 +886,7 @@ BCalendarView::_DrawFocusRect()
|
||||
const char* day = fDayNumbers[row][column].String();
|
||||
_DrawDay(currRow, currColumn, row, column, counter, tmp, day,
|
||||
focus);
|
||||
}
|
||||
else if (focusRow == row && focusColumn == column) {
|
||||
} else if (focusRow == row && focusColumn == column) {
|
||||
const char* day = fDayNumbers[row][column].String();
|
||||
_DrawDay(currRow, currColumn, row, column, counter, tmp, day,
|
||||
false);
|
||||
@@ -1179,10 +983,10 @@ BCalendarView::_DrawItem(BView *owner, BRect frame, const char *text,
|
||||
SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
|
||||
|
||||
float offsetH = frame.Width() / 2.0;
|
||||
float offsetV = (frame.Height() / 2.0) + (FontHeight(owner) / 2.0) - 2.0;
|
||||
float offsetV = frame.Height() / 2.0 + FontHeight(owner) / 2.0 - 2.0;
|
||||
|
||||
DrawString(text, BPoint(frame.right - offsetH
|
||||
- (StringWidth(text) / 2.0), frame.top + offsetV));
|
||||
DrawString(text, BPoint(frame.right - offsetH - StringWidth(text) / 2.0,
|
||||
frame.top + offsetV));
|
||||
|
||||
SetLowColor(lColor);
|
||||
SetHighColor(highColor);
|
||||
@@ -1213,8 +1017,7 @@ BCalendarView::_UpdateSelection()
|
||||
bool focus = IsFocus() && focusRow == row
|
||||
&& focusColumn == column;
|
||||
_DrawDay(row, column, row, column, counter, tmp, day, focus);
|
||||
}
|
||||
else if (currRow == row && currColumn == column) {
|
||||
} else if (currRow == row && currColumn == column) {
|
||||
const char* day = fDayNumbers[row][column].String();
|
||||
bool focus = IsFocus() && focusRow == row
|
||||
&& focusColumn == column;
|
||||
@@ -1267,7 +1070,15 @@ BCalendarView::_SetNewSelectedDay(const BPoint &where)
|
||||
counter++;
|
||||
if (tmp.Contains(where)) {
|
||||
fNewSelectedDay.SetTo(row, column);
|
||||
fDay = atoi(fDayNumbers[row][column].String());
|
||||
int32 year;
|
||||
int32 month;
|
||||
_GetYearMonthForSelection(fNewSelectedDay, &year, &month);
|
||||
if (month == fDate.Month()) {
|
||||
// only change date if a day in the current month has been
|
||||
// selected
|
||||
int32 day = atoi(fDayNumbers[row][column].String());
|
||||
fDate.SetDate(year, month, day);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
tmp.OffsetBy(tmp.Width(), 0.0);
|
||||
@@ -1289,9 +1100,8 @@ BCalendarView::_RectOfDay(const Selection &selection) const
|
||||
BRect tmp = frame;
|
||||
for (int32 column = 0; column < 7; ++column) {
|
||||
counter++;
|
||||
if (selection.row == row && selection.column == column) {
|
||||
if (selection.row == row && selection.column == column)
|
||||
return tmp;
|
||||
}
|
||||
tmp.OffsetBy(tmp.Width(), 0.0);
|
||||
}
|
||||
frame.OffsetBy(0.0, frame.Height());
|
||||
|
||||
@@ -187,9 +187,7 @@ DateTimeView::_PrefletUptime() const
|
||||
void
|
||||
DateTimeView::_InitView()
|
||||
{
|
||||
BPrivate::week_start weekStart = (BPrivate::week_start)
|
||||
BLocale::Default()->StartOfWeek();
|
||||
fCalendarView = new BCalendarView("calendar", weekStart);
|
||||
fCalendarView = new BCalendarView("calendar");
|
||||
fCalendarView->SetWeekNumberHeaderVisible(false);
|
||||
fCalendarView->SetSelectionMessage(new BMessage(kDayChanged));
|
||||
fCalendarView->SetInvocationMessage(new BMessage(kDayChanged));
|
||||
@@ -305,8 +303,16 @@ DateTimeView::_UpdateDateTime(BMessage* message)
|
||||
if (message->FindInt32("month", &month) == B_OK
|
||||
&& message->FindInt32("day", &day) == B_OK
|
||||
&& message->FindInt32("year", &year) == B_OK) {
|
||||
static int32 lastDay;
|
||||
static int32 lastMonth;
|
||||
static int32 lastYear;
|
||||
if (day != lastDay || month != lastMonth || year != lastYear) {
|
||||
fDateEdit->SetDate(year, month, day);
|
||||
fCalendarView->SetDate(year, month, day);
|
||||
lastDay = day;
|
||||
lastMonth = month;
|
||||
lastYear = year;
|
||||
}
|
||||
}
|
||||
|
||||
int32 hour;
|
||||
|
||||
Reference in New Issue
Block a user