Ticket #6265: 0001-drivesetup-resize.patch

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

    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  
    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::MainWindow()  
    283284    r.InsetBy(-1, -1);
    284285    fListView = new PartitionListView(r, B_FOLLOW_ALL);
    285286    AddChild(fListView);
    286 
     287   
    287288    // configure PartitionListView
    288289    fListView->SetSelectionMode(B_SINGLE_SELECTION_LIST);
    289290    fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED));
    290291    fListView->SetTarget(this);
    291292    fListView->MakeFocus(true);
    292 
    293293    status_t status = fDiskDeviceRoster.StartWatching(BMessenger(this));
    294294    if (status != B_OK) {
    295295        fprintf(stderr, "Failed to start watching for device changes: %s\n",
    MainWindow::_ScanDrives()  
    499499    } else {
    500500        _UpdateMenus(NULL, -1, -1);
    501501    }
     502    _UpdateWindowSizeLimit();
    502503}
    503504
    504505
    MainWindow::_ChangeParameters(BDiskDevice* disk, partition_id selectedPartition)  
    12781279    _ScanDrives();
    12791280    fDiskView->ForceUpdate();
    12801281}
     1282
     1283
     1284void
     1285MainWindow::_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}
  • MainWindow.h

    diff --git a/MainWindow.h b/MainWindow.h
    index dbf3f59..5a9afb5 100644
    a b  
    1919class BDiskDevice;
    2020class BPartition;
    2121class BMenu;
     22class BMenuBar;
    2223class BMenuItem;
    2324class DiskView;
    2425class PartitionListView;
    private:  
    7374                                    partition_id selectedPartition);
    7475            void                _ChangeParameters(BDiskDevice* disk,
    7576                                    partition_id selectedPartition);
     77            void                _UpdateWindowSizeLimit();
    7678
    7779private:
    7880            BDiskDeviceRoster   fDiskDeviceRoster;
    private:  
    8486
    8587            SpaceIDMap          fSpaceIDMap;
    8688
     89            BMenuBar*           fMenuBar;
     90           
    8791            BMenu*              fDiskMenu;
    8892            BMenu*              fDiskInitMenu;
    8993