Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > b3a1f4d91c26f535919e39e25606614a > files > 2260

wt-doc-3.2.3-1.fc18.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Wt: Wt::WViewWidget Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Wt
   &#160;<span id="projectnumber">3.2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a>      </li>
      <li class="navelem"><a class="el" href="classWt_1_1WViewWidget.html">WViewWidget</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">Wt::WViewWidget Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="Wt::WViewWidget" --><!-- doxytag: inherits="Wt::WWebWidget" -->
<p>An abstract base class for an MVC view that is rendered using a widget.  
 <a href="classWt_1_1WViewWidget.html#details">More...</a></p>

<p><code>#include &lt;Wt/WViewWidget&gt;</code></p>
<div class="dynheader">
Inheritance diagram for Wt::WViewWidget:</div>
<div class="dyncontent">
<div class="center"><img src="classWt_1_1WViewWidget__inherit__graph.png" border="0" usemap="#Wt_1_1WViewWidget_inherit__map" alt="Inheritance graph"/></div>
<map name="Wt_1_1WViewWidget_inherit__map" id="Wt_1_1WViewWidget_inherit__map">
<area shape="rect" href="classWt_1_1WStaticModelView.html" title="A widget that implements a view for a non&#45;changing model." alt="" coords="5,304,237,331"/><area shape="rect" href="classWt_1_1WWebWidget.html" title="A base class for widgets with an HTML counterpart." alt="" coords="57,155,185,181"/><area shape="rect" href="classWt_1_1WWidget.html" title="The abstract base class for a user&#45;interface component." alt="" coords="72,80,171,107"/><area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="73,5,169,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="classWt_1_1WViewWidget-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3537a36594d1a8135d63027d6679f279"></a><!-- doxytag: member="Wt::WViewWidget::WViewWidget" ref="a3537a36594d1a8135d63027d6679f279" args="(WContainerWidget *parent=0)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WViewWidget.html#a3537a36594d1a8135d63027d6679f279">WViewWidget</a> (<a class="el" href="classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent=0)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a new view widget. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WViewWidget.html#a7dcbc05eb15c4d4168141871d5908e37">update</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Updates the view.  <a href="#a7dcbc05eb15c4d4168141871d5908e37"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WViewWidget.html#aa7865b89645f229c4dbfc6eb9ddf46d4">load</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Loads content just before the widget is used.  <a href="#aa7865b89645f229c4dbfc6eb9ddf46d4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WViewWidget.html#a3481f6ab6f0db72c4489f31216b40c8b">refresh</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Refresh the widget.  <a href="#a3481f6ab6f0db72c4489f31216b40c8b"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classWt_1_1WWidget.html">WWidget</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WViewWidget.html#af7df983ff1ca6e1368579f254b85fcd6">renderView</a> ()=0</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a widget that renders the View.  <a href="#af7df983ff1ca6e1368579f254b85fcd6"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>An abstract base class for an MVC view that is rendered using a widget. </p>
<p>In principle, Wt widgets are self-contained and manage both their content, behavior and layout. From the point of view of a Model-View-Controller (MVC) design pattern, they implement each of these, except for the view widgets that work in conjunction with <a class="el" href="classWt_1_1WAbstractItemModel.html" title="An abstract model for use with Wt&#39;s view classes.">WAbstractItemModel</a>. As a developer you can chose to keep Model, View and Controller together or separate them as you wish.</p>
<p>This widget facilitates separation of the View from the Model and Controller in a particular way. The View is rendered as a Wt widget. The use of this widget provides two benefits. The classic MVC benefit is a decoupling between view and model, which may allow easier maintainance of code. In addition, this widget enforces the View to be stateless, as it is only created transiently on the server. Therefore the View does not require session resources. This may increase scalability for Internet-deployments.</p>
<p>The rendered View widget returned by <a class="el" href="classWt_1_1WViewWidget.html#af7df983ff1ca6e1368579f254b85fcd6" title="Creates a widget that renders the View.">renderView()</a> should reflect the current model state. Whenever the model changes, rerendering can be triggered by calling <a class="el" href="classWt_1_1WViewWidget.html#a7dcbc05eb15c4d4168141871d5908e37" title="Updates the view.">update()</a>.</p>
<p>Currently, the View cannot enclose <a class="el" href="classWt_1_1WFormWidget.html">WFormWidgets</a> which would allow direct manipulation of the model (but we are working to remove this limitation in the future, and let the Model/Controller handle editing changes) and the View may only be updated by a complete rerendering of the entire view.</p>
<p>The View widget may contain event handling code, but only in one of the following ways: </p>
<ul>
<li>
event handling implemented directly in JavaScript code </li>
<li>
event handling implemented in pre-learned stateless slot implementations </li>
</ul>
<p>Thus, currently, event handling code related to the View cannot be implemented at server-side (but we are thinking about a solution for this as well...).</p>
<p>Implementation example: </p>
<div class="fragment"><pre class="fragment"> <span class="comment">// Shows the contents for a specific role of a model index in a WText widget</span>
 <span class="keyword">class </span>SourceView : <span class="keyword">public</span> Wt::<a class="code" href="classWt_1_1WViewWidget.html#a3537a36594d1a8135d63027d6679f279" title="Creates a new view widget.">WViewWidget</a>
 {
 <span class="keyword">public</span>:
   <span class="comment">// role is the ItemDataRole</span>
   SourceView(<span class="keywordtype">int</span> role)
     : role_(role)
   { }

   <span class="comment">// set an index</span>
   <span class="keywordtype">void</span> setIndex(<span class="keyword">const</span> <a class="code" href="classWt_1_1WModelIndex.html" title="A value class that describes an index to an item in a data model.">Wt::WModelIndex</a>&amp; index) {
     <span class="keywordflow">if</span> (index != index_
         &amp;&amp; (!index.<a class="code" href="classWt_1_1WModelIndex.html#a1d4b05ee51c5c6961d6123565fd77c82" title="Returns whether the index is a real valid index.">isValid</a>() || !index.<a class="code" href="classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e" title="Returns data in the model at this index.">data</a>(role_).empty())) {
       index_ = index;
       <a class="code" href="classWt_1_1WViewWidget.html#a7dcbc05eb15c4d4168141871d5908e37" title="Updates the view.">update</a>(); <span class="comment">// trigger rerendering of the view</span>
     }
   }

 <span class="keyword">private</span>:
   <a class="code" href="classWt_1_1WModelIndex.html" title="A value class that describes an index to an item in a data model.">Wt::WModelIndex</a> index_;
   <span class="keywordtype">int</span>             role_;

 <span class="keyword">protected</span>:
   <span class="keyword">virtual</span> <a class="code" href="classWt_1_1WWidget.html" title="The abstract base class for a user-interface component.">Wt::WWidget</a> *<a class="code" href="classWt_1_1WViewWidget.html#af7df983ff1ca6e1368579f254b85fcd6" title="Creates a widget that renders the View.">renderView</a>() {
     <a class="code" href="classWt_1_1WText.html" title="A widget that renders (XHTML) text.">Wt::WText</a> *result = <span class="keyword">new</span> <a class="code" href="classWt_1_1WText.html" title="A widget that renders (XHTML) text.">Wt::WText</a>();
     result-&gt;<a class="code" href="classWt_1_1WWebWidget.html#ad0957c892e70c6bf5399cf71e66f3e11" title="Sets whether the widget is displayed inline or as a block.">setInline</a>(<span class="keyword">false</span>);

     <span class="keywordflow">if</span> (!index_.isValid())
       <span class="keywordflow">return</span> result;

     boost::any d = index_.data(role_);
     <span class="keyword">const</span> std::string&amp; t = boost::any_cast&lt;<span class="keyword">const</span> std::string&amp;&gt;(d);

     result-&gt;<a class="code" href="classWt_1_1WText.html#af22c64c4c5fed3d2aef0915a7e5c5866" title="Sets the text format.">setTextFormat</a>(<a class="code" href="namespaceWt.html#a140dea437d52d3d7c438ea3bd16a1480ae06bb9ae9a26d13c3dcf9f20d5067885" title="Format text as plain text.">Wt::PlainText</a>);
     result-&gt;<a class="code" href="classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6" title="Sets the text.">setText</a>(t);

     <span class="keywordflow">return</span> result;
   }
 };
</pre></div><h3>CSS</h3>
<p>This widget does not provide styling, and can be styled using inline or external CSS as appropriate. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa7865b89645f229c4dbfc6eb9ddf46d4"></a><!-- doxytag: member="Wt::WViewWidget::load" ref="aa7865b89645f229c4dbfc6eb9ddf46d4" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Wt::WViewWidget::load </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Loads content just before the widget is used. </p>
<p>When the widget is inserted in the widget hierarchy, this method is called. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.</p>
<p>The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.</p>
<p>During the life-time of a widget, this method may be called multiple times, so you should make sure that you do a deferred initializiation only once. </p>

<p>Reimplemented from <a class="el" href="classWt_1_1WWebWidget.html#a1afb15f5c5d76a22705b9fd4b4441aee">Wt::WWebWidget</a>.</p>

</div>
</div>
<a class="anchor" id="a3481f6ab6f0db72c4489f31216b40c8b"></a><!-- doxytag: member="Wt::WViewWidget::refresh" ref="a3481f6ab6f0db72c4489f31216b40c8b" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Wt::WViewWidget::refresh </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Refresh the widget. </p>
<p>The refresh method is invoked when the locale is changed using <a class="el" href="classWt_1_1WApplication.html#a5c9cc1350019d69f154a2b44cdaf2596" title="Changes the locale.">WApplication::setLocale()</a> or when the user hit the refresh button.</p>
<p>The widget must actualize its contents in response. </p>

<p>Reimplemented from <a class="el" href="classWt_1_1WWebWidget.html#a48f8c17376bd04d1359481c5441f072a">Wt::WWebWidget</a>.</p>

</div>
</div>
<a class="anchor" id="af7df983ff1ca6e1368579f254b85fcd6"></a><!-- doxytag: member="Wt::WViewWidget::renderView" ref="af7df983ff1ca6e1368579f254b85fcd6" args="()=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="classWt_1_1WWidget.html">WWidget</a>* Wt::WViewWidget::renderView </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected, pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates a widget that renders the View. </p>
<p>This method must be reimplemented to return a widget that renders the view. The returned widget will be deleted by WViewWidget. </p>

<p>Implemented in <a class="el" href="classWt_1_1WStaticModelView.html#a07efb77007dc9311e47ee15244770426">Wt::WStaticModelView&lt; Renderer &gt;</a>.</p>

</div>
</div>
<a class="anchor" id="a7dcbc05eb15c4d4168141871d5908e37"></a><!-- doxytag: member="Wt::WViewWidget::update" ref="a7dcbc05eb15c4d4168141871d5908e37" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Wt::WViewWidget::update </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Updates the view. </p>
<p>Typically, the model will want to update the view when the model has changed.</p>
<p>This will trigger a call to <a class="el" href="classWt_1_1WViewWidget.html#af7df983ff1ca6e1368579f254b85fcd6" title="Creates a widget that renders the View.">renderView()</a> to ask for a new rendering of the view. </p>

</div>
</div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by&nbsp;<a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>