<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>Replacing the View Widget</h1>
<p> The <tt>SetPage()</tt> function implementation is moved to the <tt>MainWindow::setPage()</tt> function in <tt>mainwindow.ui.h</tt>. We remove the
<tt>SetPage()</tt> function declaration and implementation from <tt>page.h</tt>
and <tt>actions.cpp</tt>, respectively. In order to make <tt>MainWindow::setPage()</tt> work correctly, we need to modify the code to
use the new widgets in our <em>Main Window</em> widget.
<p>
<pre></pre>
<p> First, we set the current value of the <tt>spinbox</tt> to the current page
number.
<p><pre></pre>
<p> Next, we set the current text and cursor position of the <tt>textedit</tt>
to the contents of the current page.
<p><pre></pre>
<p> If the current page has a custom label, we set it as the current text
of the <tt>textlabel</tt>; otherwise we set the <tt>textlabel</tt> contents to
"Page X" (where X is the current page number).
<p><pre></pre>
<p> If the current page has major and/or minor tab text, we append these
to the <tt>labeltext</tt>. This ensures that all information entered by the
user remains visible.
<p><pre></pre>
<p> We should continue to handle the possibility that the current page
does not exist. In this case, we clear the contents of the <tt>textedit</tt> widget and set the <tt>textlabel</tt> contents to the current page
number (with an indication that the page is invalid).
<p><pre></pre>
<p> The <tt>PageChange()</tt> function is moved from <tt>todo.cpp</tt> to the <tt>MainWindow::pageChange()</tt> function in <tt>mainwindow.ui.h</tt>. As with the
<tt>MainWindow::setPae()</tt> function, we need to modify the code to use
the new widgets in our <em>Main Window</em> widget.
string in the local encoding. We need to make the copy using <ahref="tqcstring.html#qstrdup">tqstrdup</a>() because the data contained in the <ahref="tqcstring.html">TQCString</a> returned by
<p> The <tt>TextChanged()</tt> function does nothing more than set the <tt>modified</tt> variable to 1. Our new <tt>MainWindow::textChanged()</tt> function
does exactly the same.
<p><pre></pre>
<p> Since both the <tt>MainWindow::pageChange()</tt> and <tt>MainWindow::textChanged()</tt> functions access the <tt>modified</tt> global
variable, we add a forward declaration at the top of <tt>mainwindow.ui.h</tt>.
<p><aname="io-cpp-view-widget-modifications"></a>
<p> The <tt>ReadDB()</tt> and \s SaveDB() implementations in <tt>io.cpp</tt> are
renamed to <tt>MainWindow::readDB()</tt> and <tt>MainWindow::saveDB()</tt>,
respectively. We need to modify the code in order to make the code
<p> The new <tt>MainWindow::readDB()</tt> and <tt>MainWindow::saveDB()</tt> functions
will not use any Xt/Motif functions, so we remove the Xt/Motif <tt>#include</tt> statements and the global variables <tt>notebook</tt> and <tt>textw</tt>.
These functions remain largely unchanged, maintaining compatibility
with previous versions. Also, the <tt>ReadDB()</tt> and <tt>SaveDB()</tt>
functions have been converted into <tt>MainWindow</tt> member functions, so
currently displayed, so we use <ahref="tqtextedit.html#text">TQTextEdit::text</a>() instead of <tt>XmTextGetString()</tt>. Note: TQTextEdit::text() returns a <ahref="tqstring.html">TQString</a>, which
<p> Since we will not be using any Motif widgets, we remove all Motif <tt>#include</tt> statements, including <ahref="tqmotifwidget-h.html">tqmotifwidget.h</a>.
<p> Next, we remove the <tt>center</tt> widget, which uses <ahref="tqmotifwidget.html">TQMotifWidget</a>. The <em>Main Window</em> widget and <em>View</em> widget are contained entirely in our