1/*
2 * Copyright 2002-2013 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
4 *
5 * Authors:
6 *		Ithamar R. Adema <ithamar@unet.nl>
7 *		Stephan A��mus <superstippi@gmx.de>
8 */
9#ifndef MAIN_WINDOW_H
10#define MAIN_WINDOW_H
11
12
13#include <DiskDeviceRoster.h>
14#include <PopUpMenu.h>
15#include <Window.h>
16
17#include "Support.h"
18
19
20class BColumnListView;
21class BDiskDevice;
22class BMenu;
23class BMenuBar;
24class BMenuItem;
25class BPartition;
26class BRow;
27class DiskView;
28class PartitionListView;
29
30
31enum {
32	MSG_SELECTED_PARTITION_ID	= 'spid',
33	MSG_UPDATE_ZOOM_LIMITS		= 'uzls'
34};
35
36
37class MainWindow : public BWindow {
38public:
39								MainWindow();
40	virtual						~MainWindow();
41
42	// BWindow interface
43	virtual	bool				QuitRequested();
44	virtual	void				MessageReceived(BMessage* message);
45
46	// MainWindow
47			status_t			StoreSettings(BMessage* archive) const;
48			status_t			RestoreSettings(BMessage* archive);
49			void				ApplyDefaultSettings();
50
51private:
52			void				_ScanDrives();
53
54			void				_AdaptToSelectedPartition();
55			void				_SetToDiskAndPartition(partition_id diskID,
56									partition_id partitionID,
57									partition_id parentID);
58			void				_UpdateMenus(BDiskDevice* disk,
59									partition_id selectedPartition,
60									partition_id parentID);
61
62			void				_DisplayPartitionError(BString message,
63									const BPartition* partition = NULL,
64									status_t error = B_OK) const;
65
66			void				_Mount(BDiskDevice* disk,
67									partition_id selectedPartition);
68			void				_Unmount(BDiskDevice* disk,
69									partition_id selectedPartition);
70			void				_MountAll();
71
72			void				_Initialize(BDiskDevice* disk,
73									partition_id selectedPartition,
74									const BString& diskSystemName);
75			void				_Create(BDiskDevice* disk,
76									partition_id selectedPartition);
77			void				_Delete(BDiskDevice* disk,
78									partition_id selectedPartition);
79			void				_ChangeParameters(BDiskDevice* disk,
80									partition_id selectedPartition);
81			float				_ColumnListViewHeight(BColumnListView* list,
82									BRow* currentRow);
83			void				_UpdateWindowZoomLimits();
84
85private:
86			BDiskDeviceRoster	fDiskDeviceRoster;
87			BDiskDevice*		fCurrentDisk;
88			partition_id		fCurrentPartitionID;
89
90			PartitionListView*	fListView;
91			DiskView*			fDiskView;
92
93			SpaceIDMap			fSpaceIDMap;
94
95			BMenu*				fDiskMenu;
96			BMenu*				fDiskInitMenu;
97
98			BMenu*				fPartitionMenu;
99			BMenu*				fFormatMenu;
100
101			BMenuBar* 			fMenuBar;
102
103			BMenuItem*			fWipeMenuItem;
104			BMenuItem*			fEjectMenuItem;
105			BMenuItem*			fSurfaceTestMenuItem;
106			BMenuItem*			fRescanMenuItem;
107
108			BMenuItem*			fCreateMenuItem;
109			BMenuItem*			fChangeMenuItem;
110			BMenuItem*			fDeleteMenuItem;
111			BMenuItem*			fMountMenuItem;
112			BMenuItem*			fUnmountMenuItem;
113			BMenuItem*			fMountAllMenuItem;
114			BMenuItem*			fOpenDiskProbeMenuItem;
115
116			BMenu*				fFormatContextMenuItem;
117			BMenuItem*			fCreateContextMenuItem;
118			BMenuItem*			fChangeContextMenuItem;
119			BMenuItem*			fDeleteContextMenuItem;
120			BMenuItem*			fMountContextMenuItem;
121			BMenuItem*			fUnmountContextMenuItem;
122			BMenuItem*			fOpenDiskProbeContextMenuItem;
123			BPopUpMenu*			fContextMenu;
124};
125
126
127#endif // MAIN_WINDOW_H
128