| OLD | NEW |
| (Empty) |
| 1 | |
| 2 /* | |
| 3 * Copyright 2006 The Android Open Source Project | |
| 4 * | |
| 5 * Use of this source code is governed by a BSD-style license that can be | |
| 6 * found in the LICENSE file. | |
| 7 */ | |
| 8 | |
| 9 | |
| 10 #ifndef SkViewInflate_DEFINED | |
| 11 #define SkViewInflate_DEFINED | |
| 12 | |
| 13 #include "SkDOM.h" | |
| 14 #include "../private/SkTDict.h" | |
| 15 #include "SkEvent.h" | |
| 16 | |
| 17 class SkView; | |
| 18 | |
| 19 class SkViewInflate { | |
| 20 public: | |
| 21 SkViewInflate(); | |
| 22 virtual ~SkViewInflate(); | |
| 23 | |
| 24 /** Return the tree of inflated views. If root is null, create the root elem
ent | |
| 25 as a view, otherwise assume root is that view, and just "inflate" it. | |
| 26 | |
| 27 Returns null if the tree cannot be built. | |
| 28 */ | |
| 29 SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NU
LL); | |
| 30 SkView* inflate(const char xml[], size_t len, SkView* root = NULL); | |
| 31 | |
| 32 /** Given an id attribute value, return the corresponding view, or null | |
| 33 if no match is found. | |
| 34 */ | |
| 35 SkView* findViewByID(const char id[]) const; | |
| 36 | |
| 37 SkDEBUGCODE(void dump() const;) | |
| 38 | |
| 39 protected: | |
| 40 /* Override this in your subclass to handle instantiating views | |
| 41 Call the inherited version for nodes you don't recognize. | |
| 42 | |
| 43 Do not call "inflate" on the view, just return it. This will | |
| 44 get called automatically after createView returns. | |
| 45 */ | |
| 46 virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node); | |
| 47 /** Base implementation calls view->inflate(dom, node). Subclasses may overr
ide this | |
| 48 to perform additional initializations to view, either before or after ca
lling | |
| 49 the inherited version. | |
| 50 */ | |
| 51 virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node*
node); | |
| 52 | |
| 53 private: | |
| 54 enum { | |
| 55 kMinIDStrAlloc = 64 | |
| 56 }; | |
| 57 SkTDict<SkView*> fIDs; | |
| 58 | |
| 59 struct IDStr { | |
| 60 SkView* fView; | |
| 61 char* fStr; | |
| 62 }; | |
| 63 SkTDArray<IDStr> fListenTo, fBroadcastTo; | |
| 64 SkChunkAlloc fStrings; | |
| 65 | |
| 66 void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str); | |
| 67 | |
| 68 void rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent); | |
| 69 }; | |
| 70 | |
| 71 #endif | |
| OLD | NEW |