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 <View.h> 40 41 42 const uint32 kMsgShowSeconds = 'ShSc'; 43 const uint32 kMsgMilTime = 'MilT'; 44 const uint32 kMsgFullDate = 'FDat'; 45 const uint32 kMsgEuroDate = 'EDat'; 46 47 48 #ifdef AS_REPLICANT 49 class _EXPORT TTimeView; 50 #endif 51 52 class TTimeView : public BView { 53 public: 54 TTimeView(bool showSeconds = false, bool milTime = false, bool fullDate = false, 55 bool euroDate = false, bool showInterval = false); 56 TTimeView(BMessage *data); 57 ~TTimeView(); 58 59 #ifdef AS_REPLICANT 60 status_t Archive(BMessage *data, bool deep = true) const; 61 static BArchivable *Instantiate(BMessage *data); 62 #endif 63 64 void AttachedToWindow(); 65 void Draw(BRect update); 66 void GetPreferredSize(float *width, float *height); 67 void ResizeToPreferred(); 68 void FrameMoved(BPoint); 69 void MessageReceived(BMessage*); 70 void MouseDown(BPoint where); 71 void Pulse(); 72 73 bool ShowingSeconds() { return fShowSeconds; } 74 void ShowSeconds(bool); 75 bool ShowingMilTime() { return fMilTime; } 76 void ShowMilTime(bool); 77 bool ShowingDate() { return fShowingDate; } 78 void ShowDate(bool); 79 bool ShowingFullDate() { return fFullDate; } 80 void ShowFullDate(bool); 81 bool CanShowFullDate() const { return fCanShowFullDate; } 82 void AllowFullDate(bool); 83 bool ShowingEuroDate() {return fEuroDate; } 84 void ShowEuroDate(bool); 85 86 bool Orientation() const; 87 void SetOrientation(bool o); 88 89 private: 90 friend class TReplicantTray; 91 92 void Update(); 93 void GetCurrentTime(); 94 void GetCurrentDate(); 95 void CalculateTextPlacement(); 96 void ShowClockOptions(BPoint); 97 98 BView *fParent; 99 bool fNeedToUpdate; 100 101 time_t fTime; 102 time_t fLastTime; 103 104 char fTimeStr[64]; 105 char fLastTimeStr[64]; 106 char fDateStr[64]; 107 char fLastDateStr[64]; 108 109 int fSeconds; 110 int fMinute; 111 int fHour; 112 bool fInterval; 113 114 bool fShowInterval; 115 bool fShowSeconds; 116 bool fMilTime; 117 bool fShowingDate; 118 bool fFullDate; 119 bool fCanShowFullDate; 120 bool fEuroDate; 121 122 float fFontHeight; 123 bool fOrientation; // vertical = true 124 BPoint fTimeLocation; 125 BPoint fDateLocation; 126 }; 127 128 129 inline bool 130 TTimeView::Orientation() const 131 { 132 return fOrientation; 133 } 134 135 136 #endif /* TIME_VIEW_H */ 137