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 20 class AppMenuItem; 21 class BEntry; 22 class BMenu; 23 class BPopUpMenu; 24 class BVolume; 25 struct entry_ref; 26 struct FileInfo; 27 class Scanner; 28 class MainWindow; 29 30 using std::map; 31 using std::vector; 32 33 34 class PieView: public BView { 35 public: 36 PieView(BRect frame, MainWindow* window); 37 virtual ~PieView(); 38 39 virtual void MessageReceived(BMessage* message); 40 virtual void MouseDown(BPoint where); 41 virtual void MouseUp(BPoint where); 42 virtual void MouseMoved(BPoint where, uint32 transit, 43 const BMessage* dragMessage); 44 virtual void Draw(BRect updateRect); 45 46 private: 47 void _HandleArg(const BEntry* entry); 48 void _ShowVolume(BVolume* volume); 49 void _DrawProgressBar(BRect updateRect); 50 void _DrawPieChart(BRect updateRect); 51 float _DrawDirectory(BRect b, FileInfo* info, 52 float parentSpan, float beginAngle, 53 int colorIdx, int level); 54 FileInfo* _FileAt(const BPoint& where); 55 void _AddAppToList(vector<AppMenuItem*>& list, 56 const char* appSignature, int category); 57 BMenu* _BuildOpenWithMenu(FileInfo* info); 58 void _ShowContextMenu(FileInfo* info, BPoint where); 59 void _Launch(FileInfo* info, 60 const entry_ref* ref = NULL); 61 void _OpenInfo(FileInfo* info, BPoint p); 62 private: 63 struct Segment { 64 Segment() 65 : begin(0.0), end(0.0), info(NULL) { } 66 Segment(float b, float e, FileInfo* i) 67 : begin(b), end(e), info(i) { } 68 Segment(const Segment &s) 69 : begin(s.begin), end(s.end), info(s.info) { } 70 ~Segment() { } 71 72 float begin; 73 float end; 74 FileInfo* info; 75 }; 76 typedef vector<Segment> SegmentList; 77 typedef map<int, SegmentList> MouseOverInfo; 78 79 typedef map<BVolume*, Scanner*> ScannerMap; 80 81 private: 82 MainWindow* fWindow; 83 ScannerMap fScanners; 84 BVolume* fCurrentVolume; 85 FileInfo* fCurrentDir; 86 MouseOverInfo fMouseOverInfo; 87 BPopUpMenu* fMouseOverMenu; 88 BPopUpMenu* fFileUnavailableMenu; 89 float fFontHeight; 90 bool fClicked; 91 bool fDragging; 92 BPoint fDragStart; 93 FileInfo* fClickedFile; 94 }; 95 96 #endif // PIE_VIEW_H 97