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