Ticket #6265: 0001-resize-drivesetup.patch

File 0001-resize-drivesetup.patch, 5.5 KB (added by Freeman, 10 years ago)
  • MainWindow.cpp

    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  
    3535#include <PartitioningInfo.h>
    3636#include <Roster.h>
    3737#include <Screen.h>
     38#include <ScrollBar.h>
    3839#include <Volume.h>
    3940#include <VolumeRoster.h>
    4041
    private:  
    199200MainWindow::MainWindow()
    200201    :
    201202    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),
    203204    fCurrentDisk(NULL),
    204205    fCurrentPartitionID(-1),
    205206    fSpaceIDMap()
    206207{
    207     BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu");
     208    fMenuBar = new BMenuBar(Bounds(), "root menu");
    208209
    209210    // create all the menu items
    210211    fWipeMenuItem = new BMenuItem(B_TRANSLATE("Wipe (not implemented)"),
    MainWindow::MainWindow()  
    245246    // fDiskMenu->AddItem(fSurfaceTestMenuItem);
    246247    fDiskMenu->AddItem(fRescanMenuItem);
    247248
    248     menuBar->AddItem(fDiskMenu);
     249    fMenuBar->AddItem(fDiskMenu);
    249250
    250251    // Parition menu
    251252    fPartitionMenu = new BMenu(B_TRANSLATE("Partition"));
    MainWindow::MainWindow()  
    265266    fPartitionMenu->AddSeparatorItem();
    266267
    267268    fPartitionMenu->AddItem(fMountAllMenuItem);
    268     menuBar->AddItem(fPartitionMenu);
     269    fMenuBar->AddItem(fPartitionMenu);
    269270
    270     AddChild(menuBar);
     271    AddChild(fMenuBar);
    271272
    272273    // add DiskView
    273274    BRect r(Bounds());
    274     r.top = menuBar->Frame().bottom + 1;
     275    r.top = fMenuBar->Frame().bottom + 1;
    275276    r.bottom = floorf(r.top + r.Height() * 0.33);
    276277    fDiskView = new DiskView(r, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
    277278        fSpaceIDMap);
    MainWindow::_ScanDrives()  
    499500    } else {
    500501        _UpdateMenus(NULL, -1, -1);
    501502    }
     503    UpdateWindowSizeLimit();
    502504}
    503505
    504506
    MainWindow::_ChangeParameters(BDiskDevice* disk, partition_id selectedPartition)  
    12781280    _ScanDrives();
    12791281    fDiskView->ForceUpdate();
    12801282}
     1283
     1284
     1285void
     1286MainWindow::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
     1310float
     1311MainWindow::_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}
  • MainWindow.h

    diff --git a/MainWindow.h b/MainWindow.h
    index dbf3f59..08f1013 100644
    a b  
    1313#include <DiskDeviceRoster.h>
    1414#include <Window.h>
    1515
     16#include "ColumnListView.h"
    1617#include "Support.h"
    1718
    1819
    1920class BDiskDevice;
    2021class BPartition;
    2122class BMenu;
     23class BMenuBar;
    2224class BMenuItem;
    2325class DiskView;
    2426class PartitionListView;
    public:  
    4244            status_t            StoreSettings(BMessage* archive) const;
    4345            status_t            RestoreSettings(BMessage* archive);
    4446            void                ApplyDefaultSettings();
     47            void                UpdateWindowSizeLimit();
    4548
    4649private:
    4750            void                _ScanDrives();
    private:  
    7376                                    partition_id selectedPartition);
    7477            void                _ChangeParameters(BDiskDevice* disk,
    7578                                    partition_id selectedPartition);
     79            float               _CalcHeight(BColumnListView* list,
     80                                    BRow* currentRow);
    7681
    7782private:
    7883            BDiskDeviceRoster   fDiskDeviceRoster;
    private:  
    9095            BMenu*              fPartitionMenu;
    9196            BMenu*              fFormatMenu;
    9297
     98            BMenuBar*           fMenuBar;
     99
    93100            BMenuItem*          fWipeMenuItem;
    94101            BMenuItem*          fEjectMenuItem;
    95102            BMenuItem*          fSurfaceTestMenuItem;
  • PartitionList.cpp

    diff --git a/PartitionList.cpp b/PartitionList.cpp
    index 04246ed..c2e754b 100644
    a b  
    2020#include <driver_settings.h>
    2121
    2222#include "Support.h"
     23#include "MainWindow.h"
    2324
    2425
    2526#undef B_TRANSLATION_CONTEXT
    PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected)  
    384385}
    385386
    386387
     388void
     389PartitionListView::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
    387399PartitionListRow*
    388400PartitionListView::FindRow(partition_id id, PartitionListRow* parent)
    389401{
  • PartitionList.h

    diff --git a/PartitionList.h b/PartitionList.h
    index acc0374..c59fe92 100644
    a b public:  
    9797    virtual void                AttachedToWindow();
    9898
    9999    virtual bool                InitiateDrag(BPoint rowPoint, bool wasSelected);
     100            void                ExpandOrCollapse(BRow* row, bool expand);
    100101
    101102            PartitionListRow*   FindRow(partition_id id,
    102103                                    PartitionListRow* parent = NULL);