1/* 2 * Copyright (c) 2008 Stephan A��mus <superstippi@gmx.de>. 3 * Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com 4 * All rights reserved. Distributed under the terms of the MIT license. 5 * 6 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software 7 * as long as it is accompanied by it's documentation and this copyright notice. 8 * The software comes with no warranty, etc. 9 */ 10#ifndef PIE_VIEW_H 11#define PIE_VIEW_H 12 13 14#include <View.h> 15 16#include <map> 17#include <vector> 18 19 20class AppMenuItem; 21class BEntry; 22class BMenu; 23class BPath; 24class BPopUpMenu; 25class BVolume; 26struct entry_ref; 27struct FileInfo; 28class Scanner; 29class MainWindow; 30 31using std::map; 32using std::vector; 33 34 35class PieView: public BView { 36public: 37 PieView(BVolume* volume); 38 virtual ~PieView(); 39 40 virtual void AttachedToWindow(); 41 virtual void MessageReceived(BMessage* message); 42 virtual void MouseDown(BPoint where); 43 virtual void MouseUp(BPoint where); 44 virtual void MouseMoved(BPoint where, uint32 transit, 45 const BMessage* dragMessage); 46 virtual void Draw(BRect updateRect); 47 void SetPath(BPath path); 48 49private: 50 void _ShowVolume(BVolume* volume); 51 void _DrawProgressBar(BRect updateRect); 52 void _DrawPieChart(BRect updateRect); 53 float _DrawDirectory(BRect b, FileInfo* info, 54 float parentSpan, float beginAngle, 55 int colorIdx, int level); 56 FileInfo* _FileAt(const BPoint& where); 57 void _AddAppToList(vector<AppMenuItem*>& list, 58 const char* appSignature, int category); 59 BMenu* _BuildOpenWithMenu(FileInfo* info); 60 void _ShowContextMenu(FileInfo* info, BPoint where); 61 void _Launch(FileInfo* info, 62 const entry_ref* ref = NULL); 63 void _OpenInfo(FileInfo* info, BPoint p); 64 65private: 66 struct Segment { 67 Segment() 68 : begin(0.0), end(0.0), info(NULL) { } 69 Segment(float b, float e, FileInfo* i) 70 : begin(b), end(e), info(i) { } 71 Segment(const Segment &s) 72 : begin(s.begin), end(s.end), info(s.info) { } 73 ~Segment() { } 74 75 float begin; 76 float end; 77 FileInfo* info; 78 }; 79 typedef vector<Segment> SegmentList; 80 typedef map<int, SegmentList> MouseOverInfo; 81 82private: 83 MainWindow* fWindow; 84 Scanner* fScanner; 85 BVolume* fVolume; 86 FileInfo* fCurrentDir; 87 MouseOverInfo fMouseOverInfo; 88 BPopUpMenu* fMouseOverMenu; 89 BPopUpMenu* fFileUnavailableMenu; 90 float fFontHeight; 91 bool fClicked; 92 bool fDragging; 93 BPoint fDragStart; 94 FileInfo* fClickedFile; 95 BPoint fLastWhere; 96 bool fUpdateFileAt; 97}; 98 99#endif // PIE_VIEW_H 100