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 trademarks 30 of Be Incorporated in the United States and other countries. Other brand product 31 names are registered trademarks or trademarks of their respective holders. 32 All rights reserved. 33 */ 34 #ifndef TIME_VIEW_H 35 #define TIME_VIEW_H 36 37 38 #include <OS.h> 39 #include <Messenger.h> 40 #include <View.h> 41 42 43 const uint32 kShowSeconds = 'ShSc'; 44 const uint32 kMilTime = 'MilT'; 45 const uint32 kFullDate = 'FDat'; 46 const uint32 kEuroDate = 'EDat'; 47 48 class BMessageRunner; 49 50 #ifdef AS_REPLICANT 51 class _EXPORT TTimeView; 52 #endif 53 54 class TTimeView : public BView { 55 public: 56 TTimeView(float maxWidth, float height, bool showSeconds = false, 57 bool milTime = false, bool fullDate = false, bool euroDate = false, 58 bool showInterval = false); 59 TTimeView(BMessage* data); 60 ~TTimeView(); 61 62 #ifdef AS_REPLICANT 63 status_t Archive(BMessage* data, bool deep = true) const; 64 static BArchivable* Instantiate(BMessage* data); 65 #endif 66 67 void AttachedToWindow(); 68 void Draw(BRect update); 69 void GetPreferredSize(float* width, float* height); 70 void ResizeToPreferred(); 71 void FrameMoved(BPoint); 72 void MessageReceived(BMessage*); 73 void MouseDown(BPoint where); 74 void MouseUp(BPoint where); 75 void Pulse(); 76 77 bool ShowingSeconds() { return fShowSeconds; } 78 void ShowSeconds(bool); 79 bool ShowingMilTime() { return fMilTime; } 80 void ShowMilTime(bool); 81 bool ShowingDate() { return fShowingDate; } 82 void ShowDate(bool); 83 bool ShowingFullDate() { return fFullDate; } 84 void ShowFullDate(bool); 85 bool CanShowFullDate() const { return fCanShowFullDate; } 86 void AllowFullDate(bool); 87 bool ShowingEuroDate() {return fEuroDate; } 88 void ShowEuroDate(bool); 89 void ShowCalendar(BPoint where); 90 void StartLongClickNotifier(BPoint where); 91 void StopLongClickNotifier(); 92 93 bool Orientation() const; 94 void SetOrientation(bool o); 95 96 private: 97 friend class TReplicantTray; 98 99 void Update(); 100 void GetCurrentTime(); 101 void GetCurrentDate(); 102 void CalculateTextPlacement(); 103 void ShowClockOptions(BPoint); 104 105 BView *fParent; 106 bool fNeedToUpdate; 107 108 time_t fTime; 109 time_t fLastTime; 110 111 char fTimeStr[64]; 112 char fLastTimeStr[64]; 113 char fDateStr[64]; 114 char fLastDateStr[64]; 115 116 int fSeconds; 117 int fMinute; 118 int fHour; 119 bool fInterval; 120 121 bool fShowInterval; 122 bool fShowSeconds; 123 bool fMilTime; 124 bool fShowingDate; 125 bool fFullDate; 126 bool fCanShowFullDate; 127 bool fEuroDate; 128 129 float fMaxWidth; 130 float fHeight; 131 bool fOrientation; // vertical = true 132 BPoint fTimeLocation; 133 BPoint fDateLocation; 134 135 BMessenger fCalendarWindow; 136 BMessageRunner* fLongClickMessageRunner; 137 }; 138 139 140 inline bool 141 TTimeView::Orientation() const 142 { 143 return fOrientation; 144 } 145 146 147 #endif /* TIME_VIEW_H */ 148 149