blob: ec14259d2e6c01dcee73a8a59143206f0713abab [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SGL: SkView.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.0 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">include</a>&nbsp;/&nbsp;<a class="el" href="dir_000001.html">skia</a></div>
<h1>SkView.h</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef SkView_DEFINED</span>
00002 <span class="preprocessor"></span><span class="preprocessor">#define SkView_DEFINED</span>
00003 <span class="preprocessor"></span>
00004 <span class="preprocessor">#include "SkEventSink.h"</span>
00005 <span class="preprocessor">#include "SkRect.h"</span>
00006 <span class="preprocessor">#include "SkDOM.h"</span>
00007 <span class="preprocessor">#include "SkTDict.h"</span>
00008
00009 <span class="keyword">class </span><a class="code" href="classSkCanvas.html">SkCanvas</a>;
00010 <span class="keyword">class </span>SkLayerView;
00011
<a name="l00017"></a><a class="code" href="classSkView.html">00017</a> <span class="keyword">class </span><a class="code" href="classSkView.html">SkView</a> : <span class="keyword">public</span> <a class="code" href="classSkEventSink.html">SkEventSink</a> {
00018 <span class="keyword">public</span>:
00019 <span class="keyword">enum</span> Flag_Shift {
00020 kVisible_Shift,
00021 kEnabled_Shift,
00022 kFocusable_Shift,
00023 kFlexH_Shift,
00024 kFlexV_Shift,
00025
00026 kFlagShiftCount
00027 };
<a name="l00028"></a><a class="code" href="classSkView.html#w16">00028</a> <span class="keyword">enum</span> <a class="code" href="classSkView.html#w16">Flag_Mask</a> {
00029 <a class="code" href="classSkView.html#w16w6">kVisible_Mask</a> = 1 &lt;&lt; kVisible_Shift,
00030 <a class="code" href="classSkView.html#w16w7">kEnabled_Mask</a> = 1 &lt;&lt; kEnabled_Shift,
00031 <a class="code" href="classSkView.html#w16w8">kFocusable_Mask</a> = 1 &lt;&lt; kFocusable_Shift,
00032 <a class="code" href="classSkView.html#w16w9">kFlexH_Mask</a> = 1 &lt;&lt; kFlexH_Shift,
00033 <a class="code" href="classSkView.html#w16w10">kFlexV_Mask</a> = 1 &lt;&lt; kFlexV_Shift,
00034
00035 kAllFlagMasks = (U32)(0 - 1) &gt;&gt; (32 - kFlagShiftCount)
00036 };
00037
00038 <a class="code" href="classSkView.html">SkView</a>(U32 flags = 0);
00039 <span class="keyword">virtual</span> ~<a class="code" href="classSkView.html">SkView</a>();
00040
<a name="l00043"></a><a class="code" href="classSkView.html#a2">00043</a> U32 <a class="code" href="classSkView.html#a2">getFlags</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fFlags; }
00046 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a3">setFlags</a>(U32 flags);
00047
<a name="l00050"></a><a class="code" href="classSkView.html#a4">00050</a> <span class="keywordtype">int</span> <a class="code" href="classSkView.html#a4">isVisible</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fFlags &amp; <a class="code" href="classSkView.html#w16w6">kVisible_Mask</a>; }
00051 <span class="keywordtype">int</span> isEnabled()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fFlags &amp; kEnabled_Mask; }
00052 <span class="keywordtype">int</span> isFocusable()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fFlags &amp; <a class="code" href="classSkView.html#w16w8">kFocusable_Mask</a>; }
00054 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a7">setVisibleP</a>(<span class="keywordtype">bool</span>);
00055 <span class="keywordtype">void</span> setEnabledP(<span class="keywordtype">bool</span>);
00056 <span class="keywordtype">void</span> setFocusableP(<span class="keywordtype">bool</span>);
00057
<a name="l00059"></a><a class="code" href="classSkView.html#a10">00059</a> SkScalar <a class="code" href="classSkView.html#a10">width</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fWidth; }
<a name="l00061"></a><a class="code" href="classSkView.html#a11">00061</a> SkScalar <a class="code" href="classSkView.html#a11">height</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fHeight; }
00063 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a12">setSize</a>(SkScalar width, SkScalar height);
00064 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a12">setSize</a>(<span class="keyword">const</span> SkPoint&amp; size) { this-&gt;<a class="code" href="classSkView.html#a12">setSize</a>(size.fX, size.fY); }
00065 <span class="keywordtype">void</span> setWidth(SkScalar width) { this-&gt;<a class="code" href="classSkView.html#a12">setSize</a>(width, fHeight); }
00066 <span class="keywordtype">void</span> setHeight(SkScalar height) { this-&gt;<a class="code" href="classSkView.html#a12">setSize</a>(fWidth, height); }
00068 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a16">getLocalBounds</a>(SkRect* bounds) <span class="keyword">const</span>;
00069
<a name="l00071"></a><a class="code" href="classSkView.html#a17">00071</a> SkScalar <a class="code" href="classSkView.html#a17">locX</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fLoc.fX; }
<a name="l00073"></a><a class="code" href="classSkView.html#a18">00073</a> SkScalar <a class="code" href="classSkView.html#a18">locY</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fLoc.fY; }
00075 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a19">setLoc</a>(SkScalar x, SkScalar y);
00076 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a19">setLoc</a>(<span class="keyword">const</span> SkPoint&amp; loc) { this-&gt;<a class="code" href="classSkView.html#a19">setLoc</a>(loc.fX, loc.fY); }
00077 <span class="keywordtype">void</span> setLocX(SkScalar x) { this-&gt;<a class="code" href="classSkView.html#a19">setLoc</a>(x, fLoc.fY); }
00078 <span class="keywordtype">void</span> setLocY(SkScalar y) { this-&gt;<a class="code" href="classSkView.html#a19">setLoc</a>(fLoc.fX, y); }
00080 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a23">offset</a>(SkScalar dx, SkScalar dy);
00081
00083 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a24">draw</a>(<a class="code" href="classSkCanvas.html">SkCanvas</a>* canvas);
00088 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a25">inval</a>(SkRect* rectOrNil);
00089
00090 <span class="comment">// Focus management</span>
00091
00092 <a class="code" href="classSkView.html">SkView</a>* getFocusView() <span class="keyword">const</span>;
00093 <span class="keywordtype">bool</span> hasFocus() <span class="keyword">const</span>;
00094
00095 <span class="keyword">enum</span> FocusDirection {
00096 kNext_FocusDirection,
00097 kPrev_FocusDirection,
00098
00099 kFocusDirectionCount
00100 };
00101 <span class="keywordtype">bool</span> acceptFocus();
00102 <a class="code" href="classSkView.html">SkView</a>* moveFocus(FocusDirection);
00103
00104 <span class="comment">// Click handling</span>
00105
00106 <span class="keyword">class </span>Click {
00107 <span class="keyword">public</span>:
00108 Click(<a class="code" href="classSkView.html">SkView</a>* target);
00109 <span class="keyword">virtual</span> ~Click();
00110
00111 <span class="keyword">const</span> <span class="keywordtype">char</span>* getType()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fType; }
00112 <span class="keywordtype">bool</span> isType(<span class="keyword">const</span> <span class="keywordtype">char</span> type[]) <span class="keyword">const</span>;
00113 <span class="keywordtype">void</span> setType(<span class="keyword">const</span> <span class="keywordtype">char</span> type[]); <span class="comment">// does NOT make a copy of the string</span>
00114 <span class="keywordtype">void</span> copyType(<span class="keyword">const</span> <span class="keywordtype">char</span> type[]); <span class="comment">// makes a copy of the string</span>
00115
00116 <span class="keyword">enum</span> State {
00117 kDown_State,
00118 kMoved_State,
00119 kUp_State
00120 };
00121 SkPoint fOrig, fPrev, fCurr;
00122 SkIPoint fIOrig, fIPrev, fICurr;
00123 State fState;
00124 <span class="keyword">private</span>:
00125 SkEventSinkID fTargetID;
00126 <span class="keywordtype">char</span>* fType;
00127 <span class="keywordtype">bool</span> fWeOwnTheType;
00128
00129 <span class="keywordtype">void</span> resetType();
00130
00131 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classSkView.html">SkView</a>;
00132 };
00133 Click* findClickHandler(SkScalar x, SkScalar y);
00134
00135 <span class="keyword">static</span> <span class="keywordtype">void</span> DoClickDown(Click*, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
00136 <span class="keyword">static</span> <span class="keywordtype">void</span> DoClickMoved(Click*, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
00137 <span class="keyword">static</span> <span class="keywordtype">void</span> DoClickUp(Click*, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
00138
00143 <a class="code" href="classSkView.html">SkView</a>* <a class="code" href="classSkView.html#a31">sendEventToParents</a>(<span class="keyword">const</span> <a class="code" href="classSkEvent.html">SkEvent</a>&amp;);
<a name="l00146"></a><a class="code" href="classSkView.html#a32">00146</a> <span class="keywordtype">bool</span> <a class="code" href="classSkView.html#a32">postEvent</a>(<a class="code" href="classSkEvent.html">SkEvent</a>* evt, SkEventSinkID sinkID, SkMSec delay) { <span class="keywordflow">return</span> evt-&gt;post(sinkID, delay); }
00147
00148 <span class="comment">// View hierarchy management</span>
00149
<a name="l00151"></a><a class="code" href="classSkView.html#a33">00151</a> <a class="code" href="classSkView.html">SkView</a>* <a class="code" href="classSkView.html#a33">getParent</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fParent; }
00152 <a class="code" href="classSkView.html">SkView</a>* attachChildToFront(<a class="code" href="classSkView.html">SkView</a>* child);
00157 <a class="code" href="classSkView.html">SkView</a>* <a class="code" href="classSkView.html#a35">attachChildToBack</a>(<a class="code" href="classSkView.html">SkView</a>* child);
00161 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a36">detachFromParent</a>();
00167 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a37">detachAllChildren</a>();
00168
<a name="l00171"></a><a class="code" href="classSkView.html#a38">00171</a> <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a38">globalToLocal</a>(SkPoint* pt)<span class="keyword"> const </span>{ <span class="keywordflow">if</span> (pt) this-&gt;<a class="code" href="classSkView.html#a38">globalToLocal</a>(pt-&gt;fX, pt-&gt;fY, pt); }
00175 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a38">globalToLocal</a>(SkScalar globalX, SkScalar globalY, SkPoint* local) <span class="keyword">const</span>;
00176
<a name="l00184"></a><a class="code" href="classSkView_1_1F2BIter.html">00184</a> <span class="keyword">class </span><a class="code" href="classSkView_1_1F2BIter.html">F2BIter</a> {
00185 <span class="keyword">public</span>:
00186 <a class="code" href="classSkView_1_1F2BIter.html">F2BIter</a>(<span class="keyword">const</span> <a class="code" href="classSkView.html">SkView</a>* parent);
00187 <a class="code" href="classSkView.html">SkView</a>* next();
00188 <span class="keyword">private</span>:
00189 <a class="code" href="classSkView.html">SkView</a>* fFirstChild, *fChild;
00190 };
00191
<a name="l00199"></a><a class="code" href="classSkView_1_1B2FIter.html">00199</a> <span class="keyword">class </span><a class="code" href="classSkView_1_1B2FIter.html">B2FIter</a> {
00200 <span class="keyword">public</span>:
00201 <a class="code" href="classSkView_1_1B2FIter.html">B2FIter</a>(<span class="keyword">const</span> <a class="code" href="classSkView.html">SkView</a>* parent);
00202 <a class="code" href="classSkView.html">SkView</a>* next();
00203 <span class="keyword">private</span>:
00204 <a class="code" href="classSkView.html">SkView</a>* fFirstChild, *fChild;
00205 };
00206
<a name="l00213"></a><a class="code" href="classSkView_1_1Artist.html">00213</a> <span class="keyword">class </span><a class="code" href="classSkView_1_1Artist.html">Artist</a> : <span class="keyword">public</span> <a class="code" href="classSkRefCnt.html">SkRefCnt</a> {
00214 <span class="keyword">public</span>:
00215 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a24">draw</a>(<a class="code" href="classSkView.html">SkView</a>*, <a class="code" href="classSkCanvas.html">SkCanvas</a>*);
00216 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a45">inflate</a>(<span class="keyword">const</span> SkDOM&amp;, <span class="keyword">const</span> SkDOM::Node*);
00217 <span class="keyword">protected</span>:
00218 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onDraw(<a class="code" href="classSkView.html">SkView</a>*, <a class="code" href="classSkCanvas.html">SkCanvas</a>*) = 0;
00219 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a50">onInflate</a>(<span class="keyword">const</span> SkDOM&amp;, <span class="keyword">const</span> SkDOM::Node*);
00220 };
00224 <a class="code" href="classSkView_1_1Artist.html">Artist</a>* <a class="code" href="classSkView.html#a40">getArtist</a>() <span class="keyword">const</span>;
00229 <a class="code" href="classSkView_1_1Artist.html">Artist</a>* <a class="code" href="classSkView.html#a41">setArtist</a>(<a class="code" href="classSkView_1_1Artist.html">Artist</a>* artist);
00230
<a name="l00237"></a><a class="code" href="classSkView_1_1Layout.html">00237</a> <span class="keyword">class </span><a class="code" href="classSkView_1_1Layout.html">Layout</a> : <span class="keyword">public</span> <a class="code" href="classSkRefCnt.html">SkRefCnt</a> {
00238 <span class="keyword">public</span>:
00239 <span class="keywordtype">void</span> layoutChildren(<a class="code" href="classSkView.html">SkView</a>* parent);
00240 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a45">inflate</a>(<span class="keyword">const</span> SkDOM&amp;, <span class="keyword">const</span> SkDOM::Node*);
00241 <span class="keyword">protected</span>:
00242 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onLayoutChildren(<a class="code" href="classSkView.html">SkView</a>* parent) = 0;
00243 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a50">onInflate</a>(<span class="keyword">const</span> SkDOM&amp;, <span class="keyword">const</span> SkDOM::Node*);
00244 };
00245
00249 <a class="code" href="classSkView_1_1Layout.html">Layout</a>* <a class="code" href="classSkView.html#a42">getLayout</a>() <span class="keyword">const</span>;
00254 <a class="code" href="classSkView_1_1Layout.html">Layout</a>* <a class="code" href="classSkView.html#a43">setLayout</a>(<a class="code" href="classSkView_1_1Layout.html">Layout</a>*, <span class="keywordtype">bool</span> invokeLayoutNow = <span class="keyword">true</span>);
00257 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a44">invokeLayout</a>();
00258
00261 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a45">inflate</a>(<span class="keyword">const</span> SkDOM&amp; dom, <span class="keyword">const</span> SkDOM::Node* node);
00269 <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a46">postInflate</a>(<span class="keyword">const</span> SkTDict&lt;SkView*&gt;&amp; ids);
00270
00271 SkDEBUGCODE(<span class="keywordtype">void</span> dump(<span class="keywordtype">bool</span> recurse) <span class="keyword">const</span>;)
00272
00273 <span class="keyword">protected</span>:
00275 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onDraw(<a class="code" href="classSkCanvas.html">SkCanvas</a>*);
00277 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onSizeChange();
00282 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classSkView.html#a47">handleInval</a>(<span class="keyword">const</span> SkRect&amp;);
00285 <span class="keyword">virtual</span> Click* <a class="code" href="classSkView.html#a48">onFindClickHandler</a>(SkScalar x, SkScalar y);
00289 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classSkView.html#a49">onClick</a>(Click*);
00291 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a50">onInflate</a>(<span class="keyword">const</span> SkDOM&amp; dom, <span class="keyword">const</span> SkDOM::Node* node);
00295 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classSkView.html#a51">onPostInflate</a>(<span class="keyword">const</span> SkTDict&lt;SkView*&gt;&amp;);
00296
00297 <span class="keyword">public</span>:
00298 <span class="comment">// default action is to inval the view</span>
00299 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onFocusChange(<span class="keywordtype">bool</span> gainFocusP);
00300 <span class="keyword">protected</span>:
00301
00302 <span class="comment">// override these if you're acting as a layer/host</span>
00303 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onGetFocusView(<a class="code" href="classSkView.html">SkView</a>**)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">false</span>; }
00304 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onSetFocusView(<a class="code" href="classSkView.html">SkView</a>*) { <span class="keywordflow">return</span> <span class="keyword">false</span>; }
00305
00306 <span class="keyword">private</span>:
00307 SkScalar fWidth, fHeight;
00308 SkPoint fLoc;
00309 <a class="code" href="classSkView.html">SkView</a>* fParent;
00310 <a class="code" href="classSkView.html">SkView</a>* fFirstChild;
00311 <a class="code" href="classSkView.html">SkView</a>* fNextSibling;
00312 <a class="code" href="classSkView.html">SkView</a>* fPrevSibling;
00313
00314 U8 fFlags;
00315 U8 fContainsFocus;
00316
00317 <span class="keyword">friend</span> <span class="keyword">class </span>B2FIter;
00318 <span class="keyword">friend</span> <span class="keyword">class </span>F2BIter;
00319
00320 <span class="keyword">friend</span> <span class="keyword">class </span>SkLayerView;
00321
00322 <span class="keywordtype">bool</span> setFocusView(<a class="code" href="classSkView.html">SkView</a>* fvOrNil);
00323 <a class="code" href="classSkView.html">SkView</a>* acceptFocus(FocusDirection);
00324 <span class="keywordtype">void</span> detachFromParent_NoLayout();
00325 };
00326
00327 <span class="preprocessor">#endif</span>
00328 <span class="preprocessor"></span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue May 9 14:35:23 2006 for SGL by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.0 </small></address>
</body>
</html>