• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "SkViewPriv.h"
2 
3 //////////////////////////////////////////////////////////////////////
4 
draw(SkView * view,SkCanvas * canvas)5 void SkView::Artist::draw(SkView* view, SkCanvas* canvas)
6 {
7 	SkASSERT(view && canvas);
8 	this->onDraw(view, canvas);
9 }
10 
inflate(const SkDOM & dom,const SkDOM::Node * node)11 void SkView::Artist::inflate(const SkDOM& dom, const SkDOM::Node* node)
12 {
13 	SkASSERT(&dom && node);
14 	this->onInflate(dom, node);
15 }
16 
onInflate(const SkDOM & dom,const SkDOM::Node * node)17 void SkView::Artist::onInflate(const SkDOM& dom, const SkDOM::Node* node)
18 {
19 	// subclass should override this as needed
20 }
21 
getArtist() const22 SkView::Artist* SkView::getArtist() const
23 {
24 	Artist_SkTagList* rec = (Artist_SkTagList*)this->findTagList(kViewArtist_SkTagList);
25 	SkASSERT(rec == NULL || rec->fArtist != NULL);
26 
27 	return rec ? rec->fArtist : NULL;
28 }
29 
setArtist(Artist * obj)30 SkView::Artist* SkView::setArtist(Artist* obj)
31 {
32 	if (obj == NULL)
33 	{
34 		this->removeTagList(kViewArtist_SkTagList);
35 	}
36 	else	// add/replace
37 	{
38 		Artist_SkTagList* rec = (Artist_SkTagList*)this->findTagList(kViewArtist_SkTagList);
39 
40 		if (rec)
41 			SkRefCnt_SafeAssign(rec->fArtist, obj);
42 		else
43 			this->addTagList(new Artist_SkTagList(obj));
44 	}
45 	return obj;
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 
layoutChildren(SkView * parent)50 void SkView::Layout::layoutChildren(SkView* parent)
51 {
52 	SkASSERT(parent);
53 	if (parent->width() > 0 && parent->height() > 0)
54 		this->onLayoutChildren(parent);
55 }
56 
inflate(const SkDOM & dom,const SkDOM::Node * node)57 void SkView::Layout::inflate(const SkDOM& dom, const SkDOM::Node* node)
58 {
59 	SkASSERT(&dom && node);
60 	this->onInflate(dom, node);
61 }
62 
onInflate(const SkDOM & dom,const SkDOM::Node * node)63 void SkView::Layout::onInflate(const SkDOM& dom, const SkDOM::Node* node)
64 {
65 	// subclass should override this as needed
66 }
67 
getLayout() const68 SkView::Layout* SkView::getLayout() const
69 {
70 	Layout_SkTagList* rec = (Layout_SkTagList*)this->findTagList(kViewLayout_SkTagList);
71 	SkASSERT(rec == NULL || rec->fLayout != NULL);
72 
73 	return rec ? rec->fLayout : NULL;
74 }
75 
setLayout(Layout * obj,bool invokeLayoutNow)76 SkView::Layout* SkView::setLayout(Layout* obj, bool invokeLayoutNow)
77 {
78 	if (obj == NULL)
79 	{
80 		this->removeTagList(kViewLayout_SkTagList);
81 	}
82 	else	// add/replace
83 	{
84 		Layout_SkTagList* rec = (Layout_SkTagList*)this->findTagList(kViewLayout_SkTagList);
85 
86 		if (rec)
87 			SkRefCnt_SafeAssign(rec->fLayout, obj);
88 		else
89 			this->addTagList(new Layout_SkTagList(obj));
90 	}
91 
92 	if (invokeLayoutNow)
93 		this->invokeLayout();
94 
95 	return obj;
96 }
97 
98