1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
30trademarks of Be Incorporated in the United States and other countries. Other
31brand product names are registered trademarks or trademarks of their respective
32holders.
33All rights reserved.
34*/
35#ifndef TIME_VIEW_H
36#define TIME_VIEW_H
37
38
39#include <OS.h>
40#include <Locale.h>
41#include <Messenger.h>
42#include <View.h>
43
44
45// open Time preferences
46const uint32 kChangeTime = 'ChTm';
47
48// pop the calendar
49const uint32 kShowCalendar = 'ShCa';
50
51// show or hide clock
52const uint32 kShowHideTime = 'ShTm';
53
54// show seconds
55const uint32 kShowSeconds = 'SwSc';
56
57// show day of week
58const uint32 kShowDayOfWeek = 'SwDw';
59
60// show time zone
61const uint32 kShowTimeZone = 'SwTz';
62
63// get clock settings to send to Time prefs
64const uint32 kGetClockSettings = 'GCkS';
65
66
67
68class BCountry;
69class BMessageRunner;
70
71#ifdef AS_REPLICANT
72class _EXPORT	TTimeView;
73#endif
74
75class TTimeView : public BView {
76public:
77								TTimeView(float maxWidth, float height);
78								TTimeView(BMessage* data);
79								~TTimeView();
80
81#ifdef AS_REPLICANT
82				status_t		Archive(BMessage* data,
83									bool deep = true) const;
84		static	BArchivable*	Instantiate(BMessage* data);
85#endif
86
87				void			AttachedToWindow();
88				void			Draw(BRect update);
89				void			FrameMoved(BPoint);
90				void			GetPreferredSize(float* width, float* height);
91				void			MessageReceived(BMessage*);
92				void			MouseDown(BPoint where);
93				void			Pulse();
94				void			ResizeToPreferred();
95
96				bool			Orientation() const;
97				void			SetOrientation(bool o);
98
99				bool			ShowSeconds() const;
100				void			SetShowSeconds(bool show);
101
102				bool			ShowDayOfWeek() const;
103				void			SetShowDayOfWeek(bool show);
104
105				bool			ShowTimeZone() const;
106				void			SetShowTimeZone(bool show);
107
108				void			ShowCalendar(BPoint where);
109
110private:
111		friend class TReplicantTray;
112
113				void			GetCurrentTime();
114				void			GetCurrentDate();
115				void			CalculateTextPlacement();
116				void			ShowTimeOptions(BPoint);
117				void			Update();
118
119				BView*			fParent;
120				bool			fNeedToUpdate;
121
122				time_t			fCurrentTime;
123				time_t			fLastTime;
124
125				char			fCurrentTimeStr[64];
126				char			fLastTimeStr[64];
127				char			fCurrentDateStr[64];
128				char			fLastDateStr[64];
129
130				int				fSeconds;
131				int				fMinute;
132				int				fHour;
133
134				float			fMaxWidth;
135				float			fHeight;
136				bool			fOrientation; // vertical = true
137
138				bool			fOverrideLocale;
139				bool			fUse24HourClock;
140				bool			fShowSeconds;
141				bool			fShowDayOfWeek;
142				bool			fShowTimeZone;
143
144				BString			fTimeFormat;
145
146				BPoint			fTimeLocation;
147				BPoint			fDateLocation;
148
149				BMessenger		fCalendarWindow;
150
151				// For date and time localization purposes
152				BLocale			fLocale;
153};
154
155
156inline bool
157TTimeView::Orientation() const
158{
159	return fOrientation;
160}
161
162
163#endif	/* TIME_VIEW_H */
164