1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy of 9 this software and associated documentation files (the "Software"), to deal in 10 the Software without restriction, including without limitation the rights to 11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 of the Software, and to permit persons to whom the Software is furnished to do 13 so, subject to the following conditions: 14 15 The above copyright notice and this permission notice applies to all licensees 16 and shall be included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25 Except as contained in this notice, the name of Be Incorporated shall not be 26 used in advertising or otherwise to promote the sale, use or other dealings in 27 this Software without prior written authorization from Be Incorporated. 28 29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered 30 trademarks of Be Incorporated in the United States and other countries. Other 31 brand product names are registered trademarks or trademarks of their respective 32 holders. 33 All 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 46 const uint32 kChangeTime = 'ChTm'; 47 48 // pop the calendar 49 const uint32 kShowCalendar = 'ShCa'; 50 51 // show or hide clock 52 const uint32 kShowHideTime = 'ShTm'; 53 54 // show seconds 55 const uint32 kShowSeconds = 'SwSc'; 56 57 // show day of week 58 const uint32 kShowDayOfWeek = 'SwDw'; 59 60 // show time zone 61 const uint32 kShowTimeZone = 'SwTz'; 62 63 // get clock settings to send to Time prefs 64 const uint32 kGetClockSettings = 'GCkS'; 65 66 67 68 class BCountry; 69 class BMessageRunner; 70 71 #ifdef AS_REPLICANT 72 class _EXPORT TTimeView; 73 #endif 74 75 class TTimeView : public BView { 76 public: 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 110 private: 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 156 inline bool 157 TTimeView::Orientation() const 158 { 159 return fOrientation; 160 } 161 162 163 #endif /* TIME_VIEW_H */ 164