diff options
Diffstat (limited to 'doc/html/designer-manual-3.html')
-rw-r--r-- | doc/html/designer-manual-3.html | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/doc/html/designer-manual-3.html b/doc/html/designer-manual-3.html index 553ea58cb..51e2bb3aa 100644 --- a/doc/html/designer-manual-3.html +++ b/doc/html/designer-manual-3.html @@ -263,7 +263,7 @@ body { background: #ffffff; color: black; } <ul><li><p>class TQString;</p> <li><p>class TQColor;</p> </ul><h4><a name="6-3"></a>Adding Includes</h4> -<p>Our form will also need some included files. Includes may be added in the declaration, or (for preference) in the implementation. Right click "Includes (in Implementation)", then click <b>Edit</b>. Use the dialog that pops up to enter "ntqcolor.h" and "tqstring.h". Since we're going to use the clipboard we'll need access to the global clipboard object via <a href="ntqapplication.html">TQApplication</a>, so also add "ntqapplication.h" and "ntqclipboard.h". We'll also be doing some drawing (e.g. the color swatches), so add "ntqpainter.h" too, then close the dialog.</p> +<p>Our form will also need some included files. Includes may be added in the declaration, or (for preference) in the implementation. Right click "Includes (in Implementation)", then click <b>Edit</b>. Use the dialog that pops up to enter "ntqcolor.h" and "tqstring.h". Since we're going to use the clipboard we'll need access to the global clipboard object via <a href="ntqapplication.html">TQApplication</a>, so also add "ntqapplication.h" and "tqclipboard.h". We'll also be doing some drawing (e.g. the color swatches), so add "ntqpainter.h" too, then close the dialog.</p> <p align="center"><img align="middle" src="mw-editincimp.png" width="339" height="327"> </p> <p>When entering include files you can include double quotes or angle brackets if you wish; if you don't use either <em>TQt Designer</em> will put in double quotes automatically.</p> @@ -271,7 +271,7 @@ body { background: #ffffff; color: black; } <ul><li><p>"ntqcolor.h"</p> <li><p>"tqstring.h"</p> <li><p>"ntqapplication.h"</p> -<li><p>"ntqclipboard.h"</p> +<li><p>"tqclipboard.h"</p> <li><p>"ntqpainter.h"</p> </ul><h4><a name="6-4"></a>Signals and Slots Connections</h4> <p>Most of the signals and slots connections were created automatically by the main window wizard when we created the main form. We have added some new actions since then, and we need to ensure that they are connected to slots so that we can code their behavior.</p> @@ -318,7 +318,7 @@ body { background: #ffffff; color: black; } const <a href="tqstring.html">TQString</a> WINDOWS_REGISTRY = "/TQtExamples"; const <a href="tqstring.html">TQString</a> APP_KEY = "/ColorTool/"; </pre> - <p>We define some useful constants for our form since it's easier to remember "CLIP_AS_RGB" than "2". The two <a href="tqstring.html">TQString</a>s are used by <a href="ntqsettings.html">TQSettings</a> when we come to load and save user preferences; they're explained when we cover <tt>loadOptions()</tt> and <tt>saveOptions()</tt>. Note that we can insert any valid C++ into a <tt>.ui.h</tt> file including constant declarations as we've done here and <tt>#include</tt>s, etc.</p> + <p>We define some useful constants for our form since it's easier to remember "CLIP_AS_RGB" than "2". The two <a href="tqstring.html">TQString</a>s are used by <a href="tqsettings.html">TQSettings</a> when we come to load and save user preferences; they're explained when we cover <tt>loadOptions()</tt> and <tt>saveOptions()</tt>. Note that we can insert any valid C++ into a <tt>.ui.h</tt> file including constant declarations as we've done here and <tt>#include</tt>s, etc.</p> <p>Since we're not subclassing if we want to have code executed during construction we must create an <tt>init()</tt> function; this will be called at the end of the form's constructor.</p> <h4><a name="6-7"></a>init()</h4> <pre> void MainForm::init() @@ -609,7 +609,7 @@ body { background: #ffffff; color: black; } if ( ! okToClear() ) return; - <a href="tqstring.html">TQString</a> filename = TQFileDialog::<a href="ntqfiledialog.html#getOpenFileName">getOpenFileName</a>( + <a href="tqstring.html">TQString</a> filename = TQFileDialog::<a href="tqfiledialog.html#getOpenFileName">getOpenFileName</a>( TQString::null, "Colors (*.txt)", this, "file open", "Color Tool -- File Open" ); if ( ! filename.<a href="tqstring.html#isEmpty">isEmpty</a>() ) @@ -618,18 +618,18 @@ body { background: #ffffff; color: black; } statusBar()->message( "File Open abandoned", 2000 ); } </pre> - <p>If it isn't okay to clear the data (i.e. the user has unsaved changes and clicked <b>Cancel</b> in the message box popped up by <tt>okToClear()</tt>), we simply return. Otherwise we ask the user for a filename using one of <a href="ntqfiledialog.html">TQFileDialog</a>'s static functions, and if we got the filename we attempt to load the file.</p> -<p>Since we're using a <a href="ntqfiledialog.html">TQFileDialog</a> we need to include the relevant header. (Right click "Includes (in Implementation)", then click <b>New</b>. Type "ntqfiledialog.h" and press <b>Enter</b>.)</p> + <p>If it isn't okay to clear the data (i.e. the user has unsaved changes and clicked <b>Cancel</b> in the message box popped up by <tt>okToClear()</tt>), we simply return. Otherwise we ask the user for a filename using one of <a href="tqfiledialog.html">TQFileDialog</a>'s static functions, and if we got the filename we attempt to load the file.</p> +<p>Since we're using a <a href="tqfiledialog.html">TQFileDialog</a> we need to include the relevant header. (Right click "Includes (in Implementation)", then click <b>New</b>. Type "tqfiledialog.h" and press <b>Enter</b>.)</p> <p>You should now have added the following declaration to your includes (in implementation):</p> -<ul><li><p>"ntqfiledialog.h"</p> +<ul><li><p>"tqfiledialog.h"</p> </ul><h4><a name="6-24"></a>load()</h4> <pre> void MainForm::load( const <a href="tqstring.html">TQString</a>& filename ) { clearData( FALSE ); m_filename = filename; <a href="tqregexp.html">TQRegExp</a> regex( "^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\S+.*)$" ); - <a href="ntqfile.html">TQFile</a> file( filename ); - if ( file.<a href="ntqfile.html#open">open</a>( IO_ReadOnly ) ) { + <a href="tqfile.html">TQFile</a> file( filename ); + if ( file.<a href="tqfile.html#open">open</a>( IO_ReadOnly ) ) { statusBar()->message( TQString( "Loading '%1'..." ). arg( filename ) ); <a href="tqtextstream.html">TQTextStream</a> stream( &file ); @@ -644,7 +644,7 @@ body { background: #ffffff; color: black; } regex.<a href="tqregexp.html#cap">cap</a>( 2 ).toInt(), regex.<a href="tqregexp.html#cap">cap</a>( 3 ).toInt() ); } - file.<a href="ntqfile.html#close">close</a>(); + file.<a href="tqfile.html#close">close</a>(); m_filename = filename; <a href="tqwidget.html#setCaption">setCaption</a>( TQString( "Color Tool -- %1" ).arg( m_filename ) ); statusBar()->message( TQString( "Loaded '%1'" ). @@ -674,9 +674,9 @@ RED WHITESPACE GREEN WHITESPACE BLUE WHITESPACE NAME <p>There are numerous approaches we could have taken to parsing these files, but we've opted for a simple regular expression (regex). The regex is more "liberal" regarding the whitespace in the input than the format demands.</p> <p>If a line matches the regex we create a new entry in the <tt>m_colors</tt> <a href="tqmap.html">TQMap</a>, setting its text to be the name of the color (<tt>regex.cap( 4 )</tt>), and its value to be a new <a href="ntqcolor.html">TQColor</a> created from the red, green and blue values. Lines that don't match the regex are treated as comments and are stored in the <tt>m_comments</tt> string list. (When we save the file we write all the comments out first even if they appeared in the middle of the file.)</p> <p>Once we've populated the <tt>m_colors</tt> map we mark the visible view as "dirty" and call <tt>populate()</tt> to update it. We then mark the visible view as not dirty and the non-visible view as dirty. This ensures that when user changes the view, the view they switch to will be updated. We could have simply marked both views as dirty and updated them both, but it is more efficient to update "lazily", after all the user may only ever use one view, so why waste their time updating the other one.</p> -<p>Since we're using <a href="ntqfile.html">TQFile</a> and <a href="tqregexp.html">TQRegExp</a> we need to include the relevant headers. (Right click "Includes (in Implementation)", then click <b>New</b>. Type "ntqfile.h" and press <b>Enter</b>. Repeat this process to add "tqregexp.h".)</p> +<p>Since we're using <a href="tqfile.html">TQFile</a> and <a href="tqregexp.html">TQRegExp</a> we need to include the relevant headers. (Right click "Includes (in Implementation)", then click <b>New</b>. Type "tqfile.h" and press <b>Enter</b>. Repeat this process to add "tqregexp.h".)</p> <p>You should now have added the following declarations to your includes (in implementation):</p> -<ul><li><p>"ntqfile.h"</p> +<ul><li><p>"tqfile.h"</p> <li><p>"tqregexp.h"</p> </ul><blockquote> <p align="center"><b> The Regular Expression</b></p> @@ -693,12 +693,12 @@ Captures: cap(1) cap(2) cap(3) cap(4) <h4><a name="6-25"></a>fileSaveAs()</h4> <pre> void MainForm::fileSaveAs() { - <a href="tqstring.html">TQString</a> filename = TQFileDialog::<a href="ntqfiledialog.html#getSaveFileName">getSaveFileName</a>( + <a href="tqstring.html">TQString</a> filename = TQFileDialog::<a href="tqfiledialog.html#getSaveFileName">getSaveFileName</a>( TQString::null, "Colors (*.txt)", this, "file save as", "Color Tool -- File Save As" ); if ( ! filename.<a href="tqstring.html#isEmpty">isEmpty</a>() ) { int ans = 0; - if ( TQFile::<a href="ntqfile.html#exists">exists</a>( filename ) ) + if ( TQFile::<a href="tqfile.html#exists">exists</a>( filename ) ) ans = TQMessageBox::<a href="ntqmessagebox.html#warning">warning</a>( this, "Color Tool -- Overwrite File", TQString( "Overwrite\n'%1'?" ). @@ -722,8 +722,8 @@ Captures: cap(1) cap(2) cap(3) cap(4) return; } - <a href="ntqfile.html">TQFile</a> file( m_filename ); - if ( file.<a href="ntqfile.html#open">open</a>( IO_WriteOnly ) ) { + <a href="tqfile.html">TQFile</a> file( m_filename ); + if ( file.<a href="tqfile.html#open">open</a>( IO_WriteOnly ) ) { <a href="tqtextstream.html">TQTextStream</a> stream( &file ); if ( ! m_comments.isEmpty() ) stream << m_comments.join( "\n" ) << "\n"; @@ -736,7 +736,7 @@ Captures: cap(1) cap(2) cap(3) cap(4) arg( color.<a href="ntqcolor.html#blue">blue</a>(), 3 ). arg( it.key() ) << "\n"; } - file.<a href="ntqfile.html#close">close</a>(); + file.<a href="tqfile.html#close">close</a>(); <a href="tqwidget.html#setCaption">setCaption</a>( TQString( "Color Tool -- %1" ).arg( m_filename ) ); statusBar()->message( TQString( "Saved %1 colors to '%2'" ). arg( m_colors.count() ). |