From 3c0a17426b23203b1c9817b9f6eba60d45518f01 Mon Sep 17 00:00:00 2001
From: Freeman Lou <freemanlou2430@Yahoo.com>
Date: Thu, 21 Nov 2013 23:27:14 +0000
Subject: [PATCH] drivesetup resize
---
MainWindow.cpp | 48 ++++++++++++++++++++++++++++++++++++++++--------
MainWindow.h | 4 ++++
2 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 30b6c8f..cd350ae 100644
a
|
b
|
|
35 | 35 | #include <PartitioningInfo.h> |
36 | 36 | #include <Roster.h> |
37 | 37 | #include <Screen.h> |
| 38 | #include <ScrollBar.h> |
38 | 39 | #include <Volume.h> |
39 | 40 | #include <VolumeRoster.h> |
40 | 41 | |
… |
… |
private:
|
199 | 200 | MainWindow::MainWindow() |
200 | 201 | : |
201 | 202 | BWindow(BRect(50, 50, 600, 500), B_TRANSLATE_SYSTEM_NAME("DriveSetup"), |
202 | | B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE), |
| 203 | B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), |
203 | 204 | fCurrentDisk(NULL), |
204 | 205 | fCurrentPartitionID(-1), |
205 | 206 | fSpaceIDMap() |
206 | 207 | { |
207 | | BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu"); |
| 208 | fMenuBar = new BMenuBar(Bounds(), "root menu"); |
208 | 209 | |
209 | 210 | // create all the menu items |
210 | 211 | fWipeMenuItem = new BMenuItem(B_TRANSLATE("Wipe (not implemented)"), |
… |
… |
MainWindow::MainWindow()
|
245 | 246 | // fDiskMenu->AddItem(fSurfaceTestMenuItem); |
246 | 247 | fDiskMenu->AddItem(fRescanMenuItem); |
247 | 248 | |
248 | | menuBar->AddItem(fDiskMenu); |
| 249 | fMenuBar->AddItem(fDiskMenu); |
249 | 250 | |
250 | 251 | // Parition menu |
251 | 252 | fPartitionMenu = new BMenu(B_TRANSLATE("Partition")); |
… |
… |
MainWindow::MainWindow()
|
265 | 266 | fPartitionMenu->AddSeparatorItem(); |
266 | 267 | |
267 | 268 | fPartitionMenu->AddItem(fMountAllMenuItem); |
268 | | menuBar->AddItem(fPartitionMenu); |
| 269 | fMenuBar->AddItem(fPartitionMenu); |
269 | 270 | |
270 | | AddChild(menuBar); |
| 271 | AddChild(fMenuBar); |
271 | 272 | |
272 | 273 | // add DiskView |
273 | 274 | BRect r(Bounds()); |
274 | | r.top = menuBar->Frame().bottom + 1; |
| 275 | r.top = fMenuBar->Frame().bottom + 1; |
275 | 276 | r.bottom = floorf(r.top + r.Height() * 0.33); |
276 | 277 | fDiskView = new DiskView(r, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, |
277 | 278 | fSpaceIDMap); |
… |
… |
MainWindow::MainWindow()
|
283 | 284 | r.InsetBy(-1, -1); |
284 | 285 | fListView = new PartitionListView(r, B_FOLLOW_ALL); |
285 | 286 | AddChild(fListView); |
286 | | |
| 287 | |
287 | 288 | // configure PartitionListView |
288 | 289 | fListView->SetSelectionMode(B_SINGLE_SELECTION_LIST); |
289 | 290 | fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED)); |
290 | 291 | fListView->SetTarget(this); |
291 | 292 | fListView->MakeFocus(true); |
292 | | |
293 | 293 | status_t status = fDiskDeviceRoster.StartWatching(BMessenger(this)); |
294 | 294 | if (status != B_OK) { |
295 | 295 | fprintf(stderr, "Failed to start watching for device changes: %s\n", |
… |
… |
MainWindow::_ScanDrives()
|
499 | 499 | } else { |
500 | 500 | _UpdateMenus(NULL, -1, -1); |
501 | 501 | } |
| 502 | _UpdateWindowSizeLimit(); |
502 | 503 | } |
503 | 504 | |
504 | 505 | |
… |
… |
MainWindow::_ChangeParameters(BDiskDevice* disk, partition_id selectedPartition)
|
1278 | 1279 | _ScanDrives(); |
1279 | 1280 | fDiskView->ForceUpdate(); |
1280 | 1281 | } |
| 1282 | |
| 1283 | |
| 1284 | void |
| 1285 | MainWindow::_UpdateWindowSizeLimit() { |
| 1286 | |
| 1287 | float maxWidth = 0, maxHeight = 0; |
| 1288 | int32 numRows = fListView->CountRows(NULL); |
| 1289 | int32 numColumns = fListView->CountColumns(); |
| 1290 | |
| 1291 | BRow* row = NULL; |
| 1292 | BColumn* column = NULL; |
| 1293 | |
| 1294 | for(int32 i = 0; i < numRows; i++) { |
| 1295 | row = fListView->RowAt(i,NULL); |
| 1296 | maxHeight += row->Height(); |
| 1297 | } |
| 1298 | |
| 1299 | for( int32 i = 0; i < numColumns; i++) { |
| 1300 | column = fListView->ColumnAt(i); |
| 1301 | maxWidth += column->Width(); |
| 1302 | } |
| 1303 | |
| 1304 | maxHeight += B_H_SCROLL_BAR_HEIGHT; |
| 1305 | maxHeight += 1.5 * row->Height(); |
| 1306 | maxHeight += fDiskView->Bounds().Height(); |
| 1307 | maxHeight += fMenuBar->Bounds().Height(); |
| 1308 | |
| 1309 | maxWidth += B_V_SCROLL_BAR_WIDTH; |
| 1310 | |
| 1311 | SetZoomLimits(maxWidth, maxHeight); |
| 1312 | } |
diff --git a/MainWindow.h b/MainWindow.h
index dbf3f59..5a9afb5 100644
a
|
b
|
|
19 | 19 | class BDiskDevice; |
20 | 20 | class BPartition; |
21 | 21 | class BMenu; |
| 22 | class BMenuBar; |
22 | 23 | class BMenuItem; |
23 | 24 | class DiskView; |
24 | 25 | class PartitionListView; |
… |
… |
private:
|
73 | 74 | partition_id selectedPartition); |
74 | 75 | void _ChangeParameters(BDiskDevice* disk, |
75 | 76 | partition_id selectedPartition); |
| 77 | void _UpdateWindowSizeLimit(); |
76 | 78 | |
77 | 79 | private: |
78 | 80 | BDiskDeviceRoster fDiskDeviceRoster; |
… |
… |
private:
|
84 | 86 | |
85 | 87 | SpaceIDMap fSpaceIDMap; |
86 | 88 | |
| 89 | BMenuBar* fMenuBar; |
| 90 | |
87 | 91 | BMenu* fDiskMenu; |
88 | 92 | BMenu* fDiskInitMenu; |
89 | 93 | |