Ticket #5525: splitView.2.patch

File splitView.2.patch, 2.3 KB (added by yourpalal, 11 years ago)

Updated BSplitView archiving patch, which doesn't archive its layout.

  • src/kits/interface/SplitView.cpp

     
    77
    88#include <stdio.h>
    99
     10#include <Archivable.h>
    1011#include <ControlLook.h>
    1112#include <Cursor.h>
    1213
     
    2324}
    2425
    2526
     27BSplitView::BSplitView(BMessage* from)
     28    :
     29    BView(BUnarchiver::PrepareArchive(from)),
     30    fSplitLayout(NULL)
     31{
     32    BUnarchiver(from).Finish();
     33}
     34
     35
    2636BSplitView::~BSplitView()
    2737{
    2838}
     
    216226}
    217227
    218228
     229status_t
     230BSplitView::Archive(BMessage* into, bool deep) const
     231{
     232    return BView::Archive(into, deep);
     233}
     234
     235
     236status_t
     237BSplitView::AllUnarchived(const BMessage* from)
     238{
     239    status_t err = BView::AllUnarchived(from);
     240    if (err == B_OK) {
     241        fSplitLayout = dynamic_cast<BSplitLayout*>(GetLayout());
     242        if (!fSplitLayout && GetLayout())
     243            return B_BAD_TYPE;
     244        else if (!fSplitLayout)
     245            return B_ERROR;
     246    }
     247    return err;
     248}
     249
     250
     251BArchivable*
     252BSplitView::Instantiate(BMessage* from)
     253{
     254    if (validate_instantiation(from, "BSplitView"))
     255        return new BSplitView(from);
     256    return NULL;
     257}
     258
     259
    219260void
    220261BSplitView::DrawSplitter(BRect frame, const BRect& updateRect,
    221262    enum orientation orientation, bool pressed)
  • headers/os/interface/SplitView.h

     
    11/*
    2  * Copyright 2006, Haiku, Inc. All rights reserved.
     2 * Copyright 2006-2010, Haiku, Inc. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 */
    55#ifndef _SPLIT_VIEW_H
     
    1616                                    enum orientation orientation
    1717                                        = B_HORIZONTAL,
    1818                                    float spacing = 0.0f);
     19                                BSplitView(BMessage* from);
    1920    virtual                     ~BSplitView();
    2021
    2122            void                SetInsets(float left, float top, float right,
     
    5960    virtual void                SetLayout(BLayout* layout);
    6061                                    // overridden to avoid use
    6162
     63    virtual status_t            Archive(BMessage* into, bool deep = true) const;
     64    virtual status_t            AllUnarchived(const BMessage* from);
     65    static  BArchivable*        Instantiate(BMessage* from);
     66
    6267protected:
    6368    virtual void                DrawSplitter(BRect frame,
    6469                                    const BRect& updateRect,