diff options
Diffstat (limited to 'doc/html/designer-manual-4.html')
-rw-r--r-- | doc/html/designer-manual-4.html | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/doc/html/designer-manual-4.html b/doc/html/designer-manual-4.html index a13478de7..0e8e5600f 100644 --- a/doc/html/designer-manual-4.html +++ b/doc/html/designer-manual-4.html @@ -173,7 +173,7 @@ body { background: #ffffff; color: black; } if ( color.<a href="tqcolor.html#isValid">isValid</a>() ) { <a href="tqpixmap.html">TQPixmap</a> pixmap( 80, 10 ); pixmap.<a href="tqpixmap.html#fill">fill</a>( color ); - ColorNameForm *colorForm = new ColorNameForm( this, "color", TRUE ); + ColorNameForm *colorForm = new ColorNameForm( this, "color", true ); colorForm->setColors( m_colors ); colorForm->colorLabel->setPixmap( pixmap ); if ( colorForm->exec() ) { @@ -195,13 +195,13 @@ body { background: #ffffff; color: black; } (void) new <a href="tqiconviewitem.html">TQIconViewItem</a>( colorIconView, name, colorSwatch( color ) ); - m_changed = TRUE; + m_changed = true; } } } </pre> <p>The code for this function is quite long, but it isn't difficult. We start by setting a default color to white. If there are any colors in the <tt>m_colors</tt> map we set the default color to be the current color showing in the current view. We then invoke TQt's static <a href="tqcolordialog.html#getColor">getColor()</a> dialog, passing it the default color. (If the user cancels an invalid color is returned.)</p> -<p>If the user chose a color we want to show their chosen color in our custom dialog, so we create a pixmap and fill it with their chosen color. We create an instance of our ColorNameForm as a modal dialog (third argument is TRUE). We then call its <tt>setColors()</tt> function to set the colors in the <tt>m_colors</tt> map (so that the <tt>validate()</tt> function will work correctly). We set its colorLabel's pixmap to the pixmap we've just created, i.e. to a rectangle in the user's chosen color.</p> +<p>If the user chose a color we want to show their chosen color in our custom dialog, so we create a pixmap and fill it with their chosen color. We create an instance of our ColorNameForm as a modal dialog (third argument is true). We then call its <tt>setColors()</tt> function to set the colors in the <tt>m_colors</tt> map (so that the <tt>validate()</tt> function will work correctly). We set its colorLabel's pixmap to the pixmap we've just created, i.e. to a rectangle in the user's chosen color.</p> <p>We execute (<tt>exec()</tt>) the dialog. If the user clicks OK (and the color name they've entered is valid), the call will return a true value. In this case we retrieve the name they've entered from the line edit and create a new entry in the <tt>m_colors</tt> map using the name the user has given and the color they chose.</p> <p>At this point we could simply mark the views "dirty" and call repopulate. Instead we'll add the new color to each view directly and save the overhead of a full update (which might be considerable if we have thousands of colors).</p> <p>We create a pixmap and fill it with the new color. We then insert a new row in the table and set the columns to the new color's values, in the same way as we've already seen in the <tt>populate()</tt> function. Similarly we create a new icon for the icon view. Finally we mark the data as changed so that the user will be prompted to save if they attempt to exit or load another color file before they've saved this one.</p> @@ -284,7 +284,7 @@ body { background: #ffffff; color: black; } return; <a href="tqstring.html">TQString</a> ltext = text.<a href="tqstring.html#lower">lower</a>(); <a href="tqwidget.html">TQWidget</a> *visible = colorWidgetStack->visibleWidget(); - bool found = FALSE; + bool found = false; if ( <a href="tqwidget.html#visible-prop">visible</a> == tablePage && colorTable->numRows() ) { int row = colorTable->currentRow(); @@ -293,7 +293,7 @@ body { background: #ffffff; color: black; } colorTable->setCurrentCell( i, 0 ); colorTable->clearSelection(); colorTable->selectRow( i ); - found = TRUE; + found = true; break; } if ( ! found ) @@ -306,7 +306,7 @@ body { background: #ffffff; color: black; } if ( item-><a href="tqtableitem.html#text">text</a>().lower().contains( ltext ) ) { colorIconView->setCurrentItem( item ); colorIconView->ensureItemVisible( item ); - found = TRUE; + found = true; break; } if ( ! found && start ) @@ -321,7 +321,7 @@ body { background: #ffffff; color: black; } </pre> <p>This slot is invoked when the user clicks the "Find" button in the FindForm. The text the user entered in the FindForm's line edit is passed in as the <tt>text</tt> parameter. If there is no text we simply return.</p> <p>We take a lower case copy of the text because we want to do a case-insensitive search. We find out which view the user is using (so that we can look in the right one), and set a flag <tt>found</tt>, that we'll use further on.</p> -<p>If the user is using the table view we start looking from the row following the row they're on. If we get a match we select the row containing the match, set <tt>found</tt> to TRUE and stop looking. If we didn't find a match we set the current cell back to the cell we started from.</p> +<p>If the user is using the table view we start looking from the row following the row they're on. If we get a match we select the row containing the match, set <tt>found</tt> to true and stop looking. If we didn't find a match we set the current cell back to the cell we started from.</p> <p>If the user is using the icon view, we start looking from the item following the current item. If we find a match we select the corresponding item and ensure that it is visible. Again, if we didn't find a match we set the current item to be the item we started looking from.</p> <p>If we found the text, the relevant item is highlighted (because we have selected it) in the user's view. If we didn't find the text we issue a message on the status bar and call the FindForm's <tt>notfound()</tt> function (which simply selects the search text).</p> <p>Functions that are typed directly into the code editor become public functions (unless their return value is <tt>void</tt> in which case they become public slots). These can be changed later by editing the function's properties. We need <tt>lookfor()</tt> to be a slot because we connect to it. Click Object Explorer's Members tab, then right click <tt>lookfor()</tt>, then click <b>Properties</b>. This invokes the <em>Edit Functions</em> dialog. Change the Type to "slot", then click <b>OK</b>.</p> @@ -366,16 +366,16 @@ body { background: #ffffff; color: black; } <h5><a name="3-2-1"></a>editOptions()</h5> <pre> void MainForm::editOptions() { - OptionsForm *options = new OptionsForm( this, "options", TRUE ); + OptionsForm *options = new OptionsForm( this, "options", true ); switch ( m_clip_as ) { case CLIP_AS_HEX: - options->hexRadioButton->setChecked( TRUE ); + options->hexRadioButton->setChecked( true ); break; case CLIP_AS_NAME: - options->nameRadioButton->setChecked( TRUE ); + options->nameRadioButton->setChecked( true ); break; case CLIP_AS_RGB: - options->rgbRadioButton->setChecked( TRUE ); + options->rgbRadioButton->setChecked( true ); break; } options->webCheckBox->setChecked( m_show_web ); @@ -395,7 +395,7 @@ body { background: #ffffff; color: black; } } } </pre> - <p>We create a new options form, passing it TRUE to make it modal. We set the radio buttons depending on the current setting of the <tt>m_clip_as</tt> variable. We set the check box to correspond with the <tt>m_show_web</tt> variable. We execute the form, and if the user clicks <b>OK</b>, we reflect their choices back into the relevant main form variables. If the user changed the <tt>m_show_web</tt> variable (by clicking the webCheckBox), we mark the table as "dirty" since it will need updating. We then call <tt>populate()</tt> which will update the table view if required.</p> + <p>We create a new options form, passing it true to make it modal. We set the radio buttons depending on the current setting of the <tt>m_clip_as</tt> variable. We set the check box to correspond with the <tt>m_show_web</tt> variable. We execute the form, and if the user clicks <b>OK</b>, we reflect their choices back into the relevant main form variables. If the user changed the <tt>m_show_web</tt> variable (by clicking the webCheckBox), we mark the table as "dirty" since it will need updating. We then call <tt>populate()</tt> which will update the table view if required.</p> <p>Because we use our OptionsForm and access its radio buttons and checkbox we must add "optionsform.h", "tqradiobutton.h" and "tqcheckbox.h" to our includes in implementation. (Click Object Explorer's Members tab, right click "Includes (in Implementation)", then click <b>Edit</b>. Click <b>Add</b> and enter "optionsform.h"; click <b>Add</b> again and enter "tqradiobutton.h"; click <b>Add</b> again and enter "tqcheckbox.h". Press <b>Enter</b>, then click <b>Close</b>.)</p> <p>You should now have added the following declarations to your includes (in implementation):</p> <ul><li><p>"optionsform.h"</p> @@ -443,10 +443,10 @@ body { background: #ffffff; color: black; } int windowX = settings.<a href="tqsettings.html#readNumEntry">readNumEntry</a>( APP_KEY + "WindowX", 0 ); int windowY = settings.<a href="tqsettings.html#readNumEntry">readNumEntry</a>( APP_KEY + "WindowY", 0 ); m_clip_as = settings.<a href="tqsettings.html#readNumEntry">readNumEntry</a>( APP_KEY + "ClipAs", CLIP_AS_HEX ); - m_show_web = settings.<a href="tqsettings.html#readBoolEntry">readBoolEntry</a>( APP_KEY + "ShowWeb", TRUE ); - if ( ! settings.<a href="tqsettings.html#readBoolEntry">readBoolEntry</a>( APP_KEY + "View", TRUE ) ) { + m_show_web = settings.<a href="tqsettings.html#readBoolEntry">readBoolEntry</a>( APP_KEY + "ShowWeb", true ); + if ( ! settings.<a href="tqsettings.html#readBoolEntry">readBoolEntry</a>( APP_KEY + "View", true ) ) { colorWidgetStack->raiseWidget( iconsPage ); - viewIconsAction->setOn( TRUE ); + viewIconsAction->setOn( true ); } </pre> <p>We read in the settings using default values if there are not settings (i.e. if the settings were deleted or if this is the first time the user has run the application). Again, the <tt>insertSearchPath()</tt> call should be made on all platforms.</p> |