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 trademarks 30of Be Incorporated in the United States and other countries. Other brand product 31names are registered trademarks or trademarks of their respective holders. 32All rights reserved. 33*/ 34 35 36#ifndef HEADERVIEW_H 37#define HEADERVIEW_H 38 39 40#include <Bitmap.h> 41#include <Handler.h> 42#include <Message.h> 43#include <MessageFilter.h> 44#include <Rect.h> 45#include <TextView.h> 46#include <View.h> 47 48#include "Model.h" 49 50 51class HeaderView: public BView { 52public: 53 HeaderView(Model*); 54 ~HeaderView(); 55 56 void ModelChanged(Model*, BMessage*); 57 void ReLinkTargetModel(Model*); 58 void BeginEditingTitle(); 59 void FinishEditingTitle(bool); 60 virtual void Draw(BRect); 61 virtual void MakeFocus(bool focus); 62 virtual void WindowActivated(bool active); 63 64 BTextView* TextView() const { return fTitleEditView; } 65 66protected: 67 virtual void MouseDown(BPoint where); 68 virtual void MouseMoved(BPoint where, uint32, const BMessage* dragMessage); 69 virtual void MouseUp(BPoint where); 70 virtual void MessageReceived(BMessage* message); 71 72 status_t BuildContextMenu(BMenu* parent); 73 static filter_result TextViewFilter(BMessage*, BHandler**, 74 BMessageFilter*); 75 76 float CurrentFontHeight(); 77 78private: 79 // States for tracking the mouse 80 enum track_state { 81 no_track = 0, 82 icon_track, 83 open_only_track 84 // This is for items that can be opened, but can't be 85 // drag and dropped or renamed (Trash, Desktop Folder...) 86 }; 87 88 // Layouting 89 BRect fTitleRect; 90 BRect fIconRect; 91 BPoint fClickPoint; 92 93 // Model data 94 Model* fModel; 95 Model* fIconModel; 96 BBitmap* fIcon; 97 BTextView* fTitleEditView; 98 99 // Mouse tracking 100 track_state fTrackingState; 101 bool fMouseDown; 102 bool fIsDropTarget; 103 bool fDoubleClick; 104 bool fDragging; 105 106 typedef BView _inherited; 107}; 108 109 110#endif /* !HEADERVIEW_H */ 111