repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / diskusage / PieView.h
blob4890de8ba56f3e707a7f4fc1c9cd22ee1b019053
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.
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
14 #include <View.h>
16 #include <map>
17 #include <vector>
20 class AppMenuItem;
21 class BEntry;
22 class BMenu;
23 class BPath;
24 class BPopUpMenu;
25 class BVolume;
26 struct entry_ref;
27 struct FileInfo;
28 class Scanner;
29 class MainWindow;
31 using std::map;
32 using std::vector;
35 class PieView: public BView {
36 public:
37 PieView(BVolume* volume);
38 virtual ~PieView();
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);
49 private:
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);
65 private:
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() { }
75 float begin;
76 float end;
77 FileInfo* info;
79 typedef vector<Segment> SegmentList;
80 typedef map<int, SegmentList> MouseOverInfo;
82 private:
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;
99 #endif // PIE_VIEW_H