gfx/skia/trunk/include/views/SkViewInflate.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/views/SkViewInflate.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkViewInflate_DEFINED
    1.14 +#define SkViewInflate_DEFINED
    1.15 +
    1.16 +#include "SkDOM.h"
    1.17 +#include "SkTDict.h"
    1.18 +#include "SkEvent.h"
    1.19 +
    1.20 +class SkView;
    1.21 +
    1.22 +class SkViewInflate {
    1.23 +public:
    1.24 +            SkViewInflate();
    1.25 +    virtual ~SkViewInflate();
    1.26 +
    1.27 +    /** Return the tree of inflated views. If root is null, create the root element
    1.28 +        as a view, otherwise assume root is that view, and just "inflate" it.
    1.29 +
    1.30 +        Returns null if the tree cannot be built.
    1.31 +    */
    1.32 +    SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NULL);
    1.33 +    SkView* inflate(const char xml[], size_t len, SkView* root = NULL);
    1.34 +
    1.35 +    /** Given an id attribute value, return the corresponding view, or null
    1.36 +        if no match is found.
    1.37 +    */
    1.38 +    SkView* findViewByID(const char id[]) const;
    1.39 +
    1.40 +    SkDEBUGCODE(void dump() const;)
    1.41 +
    1.42 +protected:
    1.43 +    /*  Override this in your subclass to handle instantiating views
    1.44 +        Call the inherited version for nodes you don't recognize.
    1.45 +
    1.46 +        Do not call "inflate" on the view, just return it. This will
    1.47 +        get called automatically after createView returns.
    1.48 +    */
    1.49 +    virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
    1.50 +    /** Base implementation calls view->inflate(dom, node). Subclasses may override this
    1.51 +        to perform additional initializations to view, either before or after calling
    1.52 +        the inherited version.
    1.53 +    */
    1.54 +    virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
    1.55 +
    1.56 +private:
    1.57 +    enum {
    1.58 +        kMinIDStrAlloc = 64
    1.59 +    };
    1.60 +    SkTDict<SkView*> fIDs;
    1.61 +
    1.62 +    struct IDStr {
    1.63 +        SkView* fView;
    1.64 +        char*   fStr;
    1.65 +    };
    1.66 +    SkTDArray<IDStr>    fListenTo, fBroadcastTo;
    1.67 +    SkChunkAlloc        fStrings;
    1.68 +
    1.69 +    void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
    1.70 +
    1.71 +    void    rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
    1.72 +};
    1.73 +
    1.74 +#endif

mercurial