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 const uint32 kShowSeconds = 'ShSc'; 46 const uint32 kFullDate = 'FDat'; 47 48 class BCountry; 49 class BMessageRunner; 50 51 #ifdef AS_REPLICANT 52 class _EXPORT TTimeView; 53 #endif 54 55 56 class TTimeView : public BView { 57 public: 58 TTimeView(float maxWidth, float height, bool showSeconds = false, 59 bool showInterval = false); 60 TTimeView(BMessage* data); 61 ~TTimeView(); 62 63 #ifdef AS_REPLICANT 64 status_t Archive(BMessage* data, bool deep = true) const; 65 static BArchivable* Instantiate(BMessage* data); 66 #endif 67 68 void AttachedToWindow(); 69 void Draw(BRect update); 70 void GetPreferredSize(float* width, float* height); 71 void ResizeToPreferred(); 72 void FrameMoved(BPoint); 73 void MessageReceived(BMessage*); 74 void MouseDown(BPoint where); 75 void Pulse(); 76 77 bool ShowingSeconds() { return fShowSeconds; } 78 void ShowSeconds(bool); 79 void ShowCalendar(BPoint where); 80 81 bool Orientation() const; 82 void SetOrientation(bool o); 83 84 private: 85 friend class TReplicantTray; 86 87 void Update(); 88 void GetCurrentTime(); 89 void GetCurrentDate(); 90 void CalculateTextPlacement(); 91 void ShowClockOptions(BPoint); 92 93 BView *fParent; 94 bool fNeedToUpdate; 95 96 time_t fTime; 97 time_t fLastTime; 98 99 char fTimeStr[64]; 100 char fLastTimeStr[64]; 101 char fDateStr[64]; 102 char fLastDateStr[64]; 103 104 int fSeconds; 105 int fMinute; 106 int fHour; 107 108 bool fShowInterval; 109 bool fShowSeconds; 110 111 float fMaxWidth; 112 float fHeight; 113 bool fOrientation; // vertical = true 114 BPoint fTimeLocation; 115 BPoint fDateLocation; 116 117 BMessenger fCalendarWindow; 118 119 BLocale fLocale; // For date and time localizing purposes 120 }; 121 122 123 inline bool 124 TTimeView::Orientation() const 125 { 126 return fOrientation; 127 } 128 129 130 #endif /* TIME_VIEW_H */ 131 132