From 057a239d8f9515ab91e44e1721c9ef9a3f233068 Mon Sep 17 00:00:00 2001
From: Freeman Lou <freemanlou2430@Yahoo.com>
Date: Sat, 23 Nov 2013 04:50:13 +0000
Subject: [PATCH] resize drivesetup
---
MainWindow.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++------
MainWindow.h | 7 +++++++
PartitionList.cpp | 12 ++++++++++++
PartitionList.h | 1 +
4 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 30b6c8f..c4b969e 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::_ScanDrives()
|
499 | 500 | } else { |
500 | 501 | _UpdateMenus(NULL, -1, -1); |
501 | 502 | } |
| 503 | UpdateWindowSizeLimit(); |
502 | 504 | } |
503 | 505 | |
504 | 506 | |
… |
… |
MainWindow::_ChangeParameters(BDiskDevice* disk, partition_id selectedPartition)
|
1278 | 1280 | _ScanDrives(); |
1279 | 1281 | fDiskView->ForceUpdate(); |
1280 | 1282 | } |
| 1283 | |
| 1284 | |
| 1285 | void |
| 1286 | MainWindow::UpdateWindowSizeLimit() { |
| 1287 | float maxWidth = 0; |
| 1288 | float maxHeight = 0; |
| 1289 | int32 numParents = fListView->CountRows(NULL); |
| 1290 | int32 numColumns = fListView->CountColumns(); |
| 1291 | BRow* parentRow = NULL; |
| 1292 | BColumn* column = NULL; |
| 1293 | |
| 1294 | maxHeight += _CalcHeight(fListView, NULL); |
| 1295 | |
| 1296 | for(int32 i = 0;i < numColumns;i++) { |
| 1297 | column = fListView->ColumnAt(i); |
| 1298 | maxWidth += column->Width(); |
| 1299 | } |
| 1300 | parentRow = fListView->RowAt(0,NULL); |
| 1301 | maxHeight += B_H_SCROLL_BAR_HEIGHT; |
| 1302 | maxHeight += 1.5 * parentRow->Height(); //For the label row |
| 1303 | maxHeight += fDiskView->Bounds().Height(); |
| 1304 | maxHeight += fMenuBar->Bounds().Height(); |
| 1305 | maxWidth += 2 * B_V_SCROLL_BAR_WIDTH; //For scroll bar & tiny column |
| 1306 | SetZoomLimits(maxWidth, maxHeight); |
| 1307 | } |
| 1308 | |
| 1309 | |
| 1310 | float |
| 1311 | MainWindow::_CalcHeight(BColumnListView* list, BRow* currentRow) { |
| 1312 | float height = 0; |
| 1313 | int32 rows = list->CountRows(currentRow); |
| 1314 | for(int32 i =0;i<rows;i++) { |
| 1315 | BRow* row = list->RowAt(i, currentRow); |
| 1316 | height += row->Height() + 1; |
| 1317 | if(row->IsExpanded() && list->CountRows(row) > 0) |
| 1318 | height += _CalcHeight(list,row); |
| 1319 | } |
| 1320 | return height; |
| 1321 | } |
diff --git a/MainWindow.h b/MainWindow.h
index dbf3f59..08f1013 100644
a
|
b
|
|
13 | 13 | #include <DiskDeviceRoster.h> |
14 | 14 | #include <Window.h> |
15 | 15 | |
| 16 | #include "ColumnListView.h" |
16 | 17 | #include "Support.h" |
17 | 18 | |
18 | 19 | |
19 | 20 | class BDiskDevice; |
20 | 21 | class BPartition; |
21 | 22 | class BMenu; |
| 23 | class BMenuBar; |
22 | 24 | class BMenuItem; |
23 | 25 | class DiskView; |
24 | 26 | class PartitionListView; |
… |
… |
public:
|
42 | 44 | status_t StoreSettings(BMessage* archive) const; |
43 | 45 | status_t RestoreSettings(BMessage* archive); |
44 | 46 | void ApplyDefaultSettings(); |
| 47 | void UpdateWindowSizeLimit(); |
45 | 48 | |
46 | 49 | private: |
47 | 50 | void _ScanDrives(); |
… |
… |
private:
|
73 | 76 | partition_id selectedPartition); |
74 | 77 | void _ChangeParameters(BDiskDevice* disk, |
75 | 78 | partition_id selectedPartition); |
| 79 | float _CalcHeight(BColumnListView* list, |
| 80 | BRow* currentRow); |
76 | 81 | |
77 | 82 | private: |
78 | 83 | BDiskDeviceRoster fDiskDeviceRoster; |
… |
… |
private:
|
90 | 95 | BMenu* fPartitionMenu; |
91 | 96 | BMenu* fFormatMenu; |
92 | 97 | |
| 98 | BMenuBar* fMenuBar; |
| 99 | |
93 | 100 | BMenuItem* fWipeMenuItem; |
94 | 101 | BMenuItem* fEjectMenuItem; |
95 | 102 | BMenuItem* fSurfaceTestMenuItem; |
diff --git a/PartitionList.cpp b/PartitionList.cpp
index 04246ed..c2e754b 100644
a
|
b
|
|
20 | 20 | #include <driver_settings.h> |
21 | 21 | |
22 | 22 | #include "Support.h" |
| 23 | #include "MainWindow.h" |
23 | 24 | |
24 | 25 | |
25 | 26 | #undef B_TRANSLATION_CONTEXT |
… |
… |
PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected)
|
384 | 385 | } |
385 | 386 | |
386 | 387 | |
| 388 | void |
| 389 | PartitionListView::ExpandOrCollapse(BRow* row, bool expand) { |
| 390 | BColumnListView::ExpandOrCollapse(row, expand); |
| 391 | MainWindow* window = dynamic_cast<MainWindow*>(Window()); |
| 392 | if (window != NULL && window->Lock()) { |
| 393 | window->UpdateWindowSizeLimit(); |
| 394 | window->Unlock(); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | |
387 | 399 | PartitionListRow* |
388 | 400 | PartitionListView::FindRow(partition_id id, PartitionListRow* parent) |
389 | 401 | { |
diff --git a/PartitionList.h b/PartitionList.h
index acc0374..c59fe92 100644
a
|
b
|
public:
|
97 | 97 | virtual void AttachedToWindow(); |
98 | 98 | |
99 | 99 | virtual bool InitiateDrag(BPoint rowPoint, bool wasSelected); |
| 100 | void ExpandOrCollapse(BRow* row, bool expand); |
100 | 101 | |
101 | 102 | PartitionListRow* FindRow(partition_id id, |
102 | 103 | PartitionListRow* parent = NULL); |