2 * Copyright 2004-2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * McCall <mccall@@digitalparadise.co.uk>
7 * Mike Berg <mike@berg-net.us>
8 * Julun <host.haiku@gmx.de>
9 * Hamish Morrison <hamish@lavabit.com>
11 #ifndef _DATE_TIME_EDIT_H
12 #define _DATE_TIME_EDIT_H
15 #include <DateFormat.h>
19 #include <TimeFormat.h>
21 #include "SectionEdit.h"
24 class TTimeEdit
: public TSectionEdit
{
26 TTimeEdit(const char* name
, uint32 sections
);
29 virtual void KeyDown(const char* bytes
, int32 numBytes
);
31 virtual void InitView();
32 virtual void DrawSection(uint32 index
, BRect bounds
,
34 virtual void DrawSeparator(uint32 index
, BRect bounds
);
36 virtual void SectionFocus(uint32 index
);
37 virtual float MinSectionWidth();
38 virtual float SeparatorWidth();
40 virtual float PreferredHeight();
41 virtual void DoUpPress();
42 virtual void DoDownPress();
44 virtual void BuildDispatch(BMessage
* message
);
46 void SetTime(int32 hour
, int32 minute
, int32 second
);
51 bool _IsValidDoubleDigit(int32 value
);
52 int32
_SectionValue(int32 index
) const;
55 BTimeFormat fTimeFormat
;
56 bigtime_t fLastKeyDownTime
;
57 int32 fLastKeyDownInt
;
61 // TODO: morph the following into a proper class
62 BDateElement
* fFields
;
69 class TDateEdit
: public TSectionEdit
{
71 TDateEdit(const char* name
, uint32 sections
);
73 virtual void KeyDown(const char* bytes
, int32 numBytes
);
75 virtual void InitView();
76 virtual void DrawSection(uint32 index
, BRect bounds
,
78 virtual void DrawSeparator(uint32 index
, BRect bounds
);
80 virtual void SectionFocus(uint32 index
);
81 virtual float MinSectionWidth();
82 virtual float SeparatorWidth();
84 virtual float PreferredHeight();
85 virtual void DoUpPress();
86 virtual void DoDownPress();
88 virtual void BuildDispatch(BMessage
* message
);
91 void SetDate(int32 year
, int32 month
, int32 day
);
96 bool _IsValidDoubleDigit(int32 value
);
97 int32
_SectionValue(int32 index
) const;
100 BDateFormat fDateFormat
;
101 bigtime_t fLastKeyDownTime
;
102 int32 fLastKeyDownInt
;
106 // TODO: morph the following into a proper class
107 BDateElement
* fFields
;
109 int* fFieldPositions
;
114 #endif // _DATE_TIME_EDIT_H