Ticket #7052: Deskbar_StatusView_cpp_style_fix.diff

File Deskbar_StatusView_cpp_style_fix.diff, 10.3 KB (added by jscipione, 13 years ago)
  • src/apps/deskbar/StatusView.cpp

    diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
    index a504101..e1fc0b5 100644
    a b Except as contained in this notice, the name of Be Incorporated shall not be  
    2626used in advertising or otherwise to promote the sale, use or other dealings in
    2727this Software without prior written authorization from Be Incorporated.
    2828
    29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
    30 of Be Incorporated in the United States and other countries. Other brand product
    31 names are registered trademarks or trademarks of their respective holders.
     29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
     30trademarks of Be Incorporated in the United States and other countries. Other
     31brand product names are registered trademarks or trademarks of their respective
     32holders.
    3233All rights reserved.
    3334*/
    3435
    All rights reserved.  
    7475using std::max;
    7576
    7677#ifdef DB_ADDONS
    77 //  Add-on support
     78// Add-on support
    7879//
    79 //  Item - internal item list (node, eref, etc)
    80 //  Icon - physical replicant handed to the DeskbarClass class
    81 //  AddOn - attribute based add-on
     80// Item - internal item list (node, eref, etc)
     81// Icon - physical replicant handed to the DeskbarClass class
     82// AddOn - attribute based add-on
    8283
    8384const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item";
    8485const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry";
    8586const char* const kDeskbarSecurityCodeFile = "Deskbar_security_code";
    8687const char* const kDeskbarSecurityCodeAttr = "be:deskbar_security_code";
    8788const char* const kStatusPredicate = "be:deskbar_item_status";
    88 const char* const kEnabledPredicate = "be:deskbar_item_status=enabled";
    89 const char* const kDisabledPredicate = "be:deskbar_item_status=disabled";
     89const char* const kEnabledPredicate = "be:deskbar_item_status = enabled";
     90const char* const kDisabledPredicate = "be:deskbar_item_status = disabled";
    9091
    9192float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth;
    9293
    TReplicantTray::DealWithClock(bool showClock)  
    240241}
    241242
    242243
    243 /*!
    244     Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
     244/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
    245245    if not in multirowmode and greater than kMinimumReplicantCount
    246246    the width should be calculated based on the actual
    247247    replicant widths
    TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)  
    255255        if (fShelf->CountReplicants() > 0)
    256256            height = fRightBottomReplicant.bottom;
    257257
    258         // the height will be uniform for the number of rows
    259         // necessary to show all the reps + any gutters
    260         // necessary for spacing
     258        // the height will be uniform for the number of rows necessary to show
     259        // all the reps + any gutters necessary for spacing
    261260        int32 rowCount = (int32)(height / kMaxReplicantHeight);
    262261        height = kGutter + (rowCount * kMaxReplicantHeight)
    263262            + ((rowCount - 1) * kIconGap) + kGutter;
    264263        height = max(kMinimumTrayHeight, height);
    265264        width = fMinimumTrayWidth;
    266265    } else {
    267         // if last replicant overruns clock then
    268         // resize to accomodate
     266        // if last replicant overruns clock then resize to accomodate
    269267        if (fShelf->CountReplicants() > 0) {
    270268            if (fBarView->ShowingClock()
    271269                && fRightBottomReplicant.right + 6 >= fClock->Frame().left) {
    TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)  
    274272            } else
    275273                width = fRightBottomReplicant.right + 3;
    276274        }
     275
    277276        // this view has a fixed minimum width
    278277        width = max(fMinimumTrayWidth, width);
    279278    }
    280279
    281280    *preferredWidth = width;
    282     // add 2 for the border
     281    // add 1 for the border
    283282    *preferredHeight = height + 1;
    284283}
    285284
    TReplicantTray::ShowReplicantMenu(BPoint point)  
    350349    BPopUpMenu* menu = new BPopUpMenu("", false, false);
    351350    menu->SetFont(be_plain_font);
    352351
    353     // If the clock is visible, show the extended menu
    354     // otheriwse, show "Show Time".
     352    // If clock is visible show the extended menu, otherwise show "Show Time"
    355353
    356354    if (fBarView->ShowingClock())
    357355        fClock->ShowClockOptions(ConvertToScreen(point));
    TReplicantTray::MouseDown(BPoint where)  
    375373        DumpList(fItemList);
    376374#endif
    377375
    378     uint32  buttons;
     376    uint32 buttons;
    379377
    380378    Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
    381379    if (buttons == B_SECONDARY_MOUSE_BUTTON) {
    TReplicantTray::InitAddOnSupport()  
    412410{
    413411    // list to maintain refs to each rep added/deleted
    414412    fItemList = new BList();
    415 
    416413    bool haveKey = false;
    417     BPath path;
     414    BPath path;
     415
    418416    if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
    419417        path.Append(kDeskbarSecurityCodeFile);
    420418
    421         BFile file(path.Path(),B_READ_ONLY);
     419        BFile file(path.Path(), B_READ_ONLY);
    422420        if (file.InitCheck() == B_OK
    423             && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode))
     421            && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode))
    424422                == sizeof(fDeskbarSecurityCode))
    425423            haveKey = true;
    426424    }
    TReplicantTray::InitAddOnSupport()  
    443441        }
    444442    }
    445443
    446     // for each volume currently mounted
    447     //      index the volume with our indices
     444    // for each volume currently mounted index the volume with our indices
    448445    BVolumeRoster roster;
    449446    BVolume volume;
    450447    while (roster.GetNextVolume(&volume) == B_OK) {
    TReplicantTray::RunAddOnQuery(BVolume* volume, const char* predicate)  
    488485        || fs_stat_index(volume->Device(), kStatusPredicate, &info) != 0)
    489486        return;
    490487
    491     // run a new query on a specific volume
    492     // make it live
     488    // run a new query on a specific volume and make it live
    493489    BQuery query;
    494490    query.SetVolume(volume);
    495491    query.SetPredicate(predicate);
    TReplicantTray::NodeExists(node_ref& nodeRef)  
    557553}
    558554
    559555
    560 /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received
     556/*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received
    561557    for the registered add-ons.
    562558*/
    563559void
    TReplicantTray::HandleEntryUpdate(BMessage* message)  
    697693}
    698694
    699695
    700 /*!
    701     The add-ons must support the exported C function API
     696/*! The add-ons must support the exported C function API
    702697    if they do, they will be loaded and added to deskbar
    703698    primary function is the Instantiate function
    704699*/
    TReplicantTray::MoveItem(entry_ref* ref, ino_t toDirectory)  
    883878    }
    884879}
    885880
    886 #endif  //  add-on support
     881#endif // add-on support
    887882
    888883//  external add-on API routines
    889884//  called using the new BDeskbar class
    TReplicantTray::IconCount() const  
    989984}
    990985
    991986
    992 /*! Message must contain an archivable view for later rehydration.
     987/*! Message must contain an archivable view for later rehydration.
    993988    This function takes over ownership of the provided message on success
    994989    only.
    995990    Returns the current replicant ID.
    TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)  
    10081003        ref = *addOn;
    10091004    } else {
    10101005        const char* signature;
     1006
    10111007        status_t status = archive->FindString("add_on", &signature);
    10121008        if (status == B_OK) {
    10131009            BRoster roster;
    TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)  
    10281024        return status;
    10291025
    10301026    BEntry entry(&ref, true);
    1031         // ToDo: this resolves an eventual link for the item
    1032         // being added - this is okay for now, but in multi-user
    1033         // environments, one might want to have links that
    1034         // carry the be:deskbar_item_status attribute
     1027        // TODO: this resolves an eventual link for the item being added - this
     1028        // is okay for now, but in multi-user environments, one might want to
     1029        // have links that carry the be:deskbar_item_status attribute
    10351030    status = entry.InitCheck();
    10361031    if (status != B_OK)
    10371032        return status;
    TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)  
    10411036        archive->what = 0;
    10421037
    10431038    BRect originalBounds = archive->FindRect("_frame");
    1044         // this is a work-around for buggy replicants that change their
    1045         // size in AttachedToWindow() (such as "SVM")
     1039        // this is a work-around for buggy replicants that change their size in
     1040        // AttachedToWindow() (such as "SVM")
    10461041
    1047     // !! check for name collisions?
     1042    // TODO: check for name collisions?
    10481043    status = fShelf->AddReplicant(archive, BPoint(1, 1));
    10491044    if (status != B_OK)
    10501045        return status;
    TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)  
    10701065    // add the item to the add-on list
    10711066
    10721067    AddItem(*id, nodeRef, entry, addOn != NULL);
    1073     return B_OK;
     1068    return B_OK;
    10741069}
    10751070
    10761071
    TReplicantTray::RealReplicantAdjustment(int32 startIndex)  
    11291124    float width, height;
    11301125    GetPreferredSize(&width, &height);
    11311126    if (oldWidth != width || oldHeight != height) {
    1132         // resize view to accomodate the replicants
    1133         // redraw as necessary
     1127        // resize view to accomodate the replicants, redraw as necessary
    11341128        AdjustPlacement();
    11351129    }
    11361130}
    TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex)  
    11541148            }
    11551149        }
    11561150    } else {
    1157         int32 count = fShelf->CountReplicants()-1;
     1151        int32 count = fShelf->CountReplicants() - 1;
    11581152        int32 localid;
    11591153        for (int32 repIndex = count ; repIndex >= 0 ; repIndex--) {
    11601154            fShelf->ReplicantAt(repIndex, &view, (uint32*)&localid);
    TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex)  
    11651159            }
    11661160        }
    11671161    }
    1168 
    11691162    return NULL;
    11701163}
    11711164
    TReplicantTray::ViewAt(int32* index, int32* id, const char* name)  
    11891182            return view;
    11901183        }
    11911184    }
    1192 
    11931185    return NULL;
    11941186}
    11951187
    TReplicantTray::SetMultiRow(bool state)  
    13531345//  #pragma mark -
    13541346
    13551347
    1356 /*! Draggable region that is asynchronous so that dragging does not block
     1348/*! Draggable region that is asynchronous so that dragging does not block
    13571349    other activities.
    13581350*/
    13591351TDragRegion::TDragRegion(TBarView* parent, BView* child)
    bool  
    15831575TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect,
    15841576    bool newVertical, bool newLeft, bool newTop, int32 newState)
    15851577{
    1586     if (!rect.Contains(mouse))
     1578    if (!rect.Contains(mouse)) {
    15871579        // not our rect
    15881580        return false;
     1581    }
    15891582
    1590     if (newVertical == fBarView->Vertical()
    1591         && newLeft == fBarView->Left()
    1592         && newTop == fBarView->Top()
    1593         && newState == fBarView->State())
     1583    if (newVertical == fBarView->Vertical() && newLeft == fBarView->Left()
     1584        && newTop == fBarView->Top() && newState == fBarView->State()) {
    15941585        // already in the correct mode
    15951586        return true;
     1587    }
    15961588
    15971589    fBarView->ChangeState(newState, newVertical, newLeft, newTop);
    15981590    return true;