Ticket #5525: gridView.patch

File gridView.patch, 2.1 KB (added by yourpalal, 11 years ago)

implement archiving of BGridView class.

  • headers/os/interface/GridView.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 _GRID_VIEW_H
     
    1313public:
    1414                                BGridView(float horizontalSpacing = 0.0f,
    1515                                    float verticalSpacing = 0.0f);
     16                                BGridView(BMessage* from);
    1617    virtual                     ~BGridView();
    1718
    1819    virtual void                SetLayout(BLayout* layout);
     20            BGridLayout*        GridLayout() const;
    1921
    20             BGridLayout*        GridLayout() const;
     22    static  BArchivable*        Instantiate(BMessage* from);
    2123};
    2224
    2325
  • src/kits/interface/GridView.cpp

     
    11/*
     2 * Copyright 2010, Haiku, Inc.
    23 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
    34 * All rights reserved. Distributed under the terms of the MIT License.
    45 */
     
    67#include <GridView.h>
    78
    89
    9 // constructor
     10
    1011BGridView::BGridView(float horizontalSpacing, float verticalSpacing)
    11     : BView(NULL, 0, new BGridLayout(horizontalSpacing, verticalSpacing))
     12    :
     13    BView(NULL, 0, new BGridLayout(horizontalSpacing, verticalSpacing))
    1214{
    1315    SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    1416}
    1517
    16 // destructor
     18
     19BGridView::BGridView(BMessage* from)
     20    :
     21    BView(from)
     22{
     23}
     24
     25
    1726BGridView::~BGridView()
    1827{
    1928}
    2029
    21 // SetLayout
     30
    2231void
    2332BGridView::SetLayout(BLayout* layout)
    2433{
    2534    // only BGridLayouts are allowed
     35   
    2636    if (!dynamic_cast<BGridLayout*>(layout))
    2737        return;
    2838
    2939    BView::SetLayout(layout);
    3040}
    3141
    32 // GridLayout
     42
    3343BGridLayout*
    3444BGridView::GridLayout() const
    3545{
    3646    return dynamic_cast<BGridLayout*>(GetLayout());
    3747}
     48
     49
     50BArchivable*
     51BGridView::Instantiate(BMessage* from)
     52{
     53    if (validate_instantiation(from, "BGridView"))
     54        return new BGridView(from);
     55    return NULL;
     56}
     57