diff options
Diffstat (limited to 'doc/html/designer-manual-3.html')
-rw-r--r-- | doc/html/designer-manual-3.html | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/doc/html/designer-manual-3.html b/doc/html/designer-manual-3.html index 46dc87d3e..7acffbca9 100644 --- a/doc/html/designer-manual-3.html +++ b/doc/html/designer-manual-3.html @@ -74,7 +74,7 @@ body { background: #ffffff; color: black; } <a name="actions-and-action-groups-sidebar"></a><p>An <em>action</em> is an operation that the user initiates through the user interface, for example, saving a file or changing some text's font weight to bold.</p> <p>We often want the user to be able to perform an action using a variety of means. For example, to save a file we might want the user to be able to press <b>Ctrl+S</b>, or to click the <b>Save</b> toolbar button or to click the <b>File|Save</b> menu option. Although the means of invoking the action are all different, the underlying operation is the same and we don't want to duplicate the code that performs the operation. In TQt we can create an action (a <a href="tqaction.html">TQAction</a> object) which will call the appropriate function when the action is invoked. We can assign an accelerator, (e.g. <b>Ctrl+S</b>), to an action. We can also add an action to a menu and to a toolbar.</p> <p>If the action has an on/off state, e.g. bold is on or off, when the user changes the state, for example by clicking a toolbar button, the state of everything associated with the action, e.g. menu items and toolbar buttons, is updated.</p> -<p>Some actions should operate together like radio buttons. For example, if we have left align, center align and right align actions, only one should be 'on' at any one time. An <em>action group</em> (a <a href="tqactiongroup.html">TQActionGroup</a> object) is used to group a set of actions together. If the action group's <tt>exclusive</tt> property is TRUE then only one of the actions in the group can be on at any one time. If the user changes the state of an action in an action group where <tt>exclusive</tt> is TRUE, everything associated with the actions in the action group, e.g. menu items and toolbar buttons, is updated.</p> +<p>Some actions should operate together like radio buttons. For example, if we have left align, center align and right align actions, only one should be 'on' at any one time. An <em>action group</em> (a <a href="tqactiongroup.html">TQActionGroup</a> object) is used to group a set of actions together. If the action group's <tt>exclusive</tt> property is true then only one of the actions in the group can be on at any one time. If the user changes the state of an action in an action group where <tt>exclusive</tt> is true, everything associated with the actions in the action group, e.g. menu items and toolbar buttons, is updated.</p> <!-- index Actions and Action Groups --><p><em>TQt Designer</em> can create actions and action groups visually, assign accelerators to them, and associate them with menu items and toolbar buttons.</p> </blockquote> <h3><a name="4"></a>Creating the Main Window</h3> @@ -324,18 +324,18 @@ body { background: #ffffff; color: black; } { clipboard = TQApplication::<a href="tqapplication.html#clipboard">clipboard</a>(); if ( clipboard->supportsSelection() ) - clipboard->setSelectionMode( TRUE ); + clipboard->setSelectionMode( true ); findForm = 0; loadSettings(); m_filename = ""; - m_changed = FALSE; - m_table_dirty = TRUE; - m_icons_dirty = TRUE; - clearData( TRUE ); + m_changed = false; + m_table_dirty = true; + m_icons_dirty = true; + clearData( true ); } </pre> - <p>The first thing we do is take a pointer to the global clipboard object. The <tt>setSelectionMode()</tt> call ensures that the clipboard works as expected on all platforms. The "findForm" and "loadSettings()" lines will be covered later; if you're entering the code, comment them out for now. We set the filename to be empty because the user hasn't opened a file. We set changed to false since no changes have taken place yet. But we mark both the table and the icon view as dirty since we want these to be drawn straight away. We call the <tt>clearData()</tt> function that we'll write next; this function clears all the color data, and if called with "TRUE", it creates new colors with default values.</p> + <p>The first thing we do is take a pointer to the global clipboard object. The <tt>setSelectionMode()</tt> call ensures that the clipboard works as expected on all platforms. The "findForm" and "loadSettings()" lines will be covered later; if you're entering the code, comment them out for now. We set the filename to be empty because the user hasn't opened a file. We set changed to false since no changes have taken place yet. But we mark both the table and the icon view as dirty since we want these to be drawn straight away. We call the <tt>clearData()</tt> function that we'll write next; this function clears all the color data, and if called with "true", it creates new colors with default values.</p> <h4><a name="6-8"></a>clearData()</h4> <pre> void MainForm::clearData( bool fillWithDefaults ) { @@ -406,7 +406,7 @@ body { background: #ffffff; color: black; } } else colorTable->hideColumn( COL_WEB ); - m_table_dirty = FALSE; + m_table_dirty = false; } if ( m_icons_dirty ) { @@ -416,7 +416,7 @@ body { background: #ffffff; color: black; } for ( it = m_colors.constBegin(); it != m_colors.constEnd(); ++it ) (void) new <a href="tqiconviewitem.html">TQIconViewItem</a>( colorIconView, it.key(), colorSwatch( it.data() ) ); - m_icons_dirty = FALSE; + m_icons_dirty = false; } } </pre> @@ -424,8 +424,8 @@ body { background: #ffffff; color: black; } <p>We now create an iterator for our colors map, and iterate over every color. The colors map has the user's color names as its keys, and <a href="tqcolor.html">TQColor</a> instances as values. We retrieve the color and fill our pixmap with that color. We then set the "Name" column (column <tt>COL_NAME</tt>), to have the color's name (<tt>it.key()</tt>) and the pixmap we've just filled with that color. <a href="tqcolor.html">TQColor</a>'s <tt>name()</tt> function returns a string that is the hex representation of a color, e.g. "#12AB2F"; we retrieve this and set the second ("Hex") column to this value.</p> <p>If the user wants to see if which colors are web colors we create a <a href="tqchecktableitem.html">TQCheckTableItem</a>, and check it if it is a web color. (We'll cover <tt>isWebColor()</tt> shortly.) We then insert this <a href="tqchecktableitem.html">TQCheckTableItem</a> into the "Web" column.</p> <p>Having populated the table we call <tt>adjustColumn()</tt> to ensure that each column is just wide enough to show its widest entry, and show or hide the "Web" column depending on the user's preference.</p> -<p>Finally we set <tt>m_table_dirty</tt> to FALSE, since it is now up-to-date.</p> -<p>If the icon view is "dirty" we <tt>clear()</tt> it of any existing data. We then iterate over each color in our colors map. For each color we create a new <a href="tqiconviewitem.html">TQIconViewItem</a>; we label the item with the user's color name and provide a pixmap (generated by <tt>colorSwatch()</tt>, covered shortly) in the relevant color. Finally we set <tt>m_icons_dirty</tt> to "FALSE", since it is now up-to-date.</p> +<p>Finally we set <tt>m_table_dirty</tt> to false, since it is now up-to-date.</p> +<p>If the icon view is "dirty" we <tt>clear()</tt> it of any existing data. We then iterate over each color in our colors map. For each color we create a new <a href="tqiconviewitem.html">TQIconViewItem</a>; we label the item with the user's color name and provide a pixmap (generated by <tt>colorSwatch()</tt>, covered shortly) in the relevant color. Finally we set <tt>m_icons_dirty</tt> to "false", since it is now up-to-date.</p> <h4><a name="6-10"></a>isWebColor()</h4> <pre> bool MainForm::isWebColor( <a href="tqcolor.html">TQColor</a> color ) { @@ -565,10 +565,10 @@ body { background: #ffffff; color: black; } { if ( okToClear() ) { m_filename = ""; - m_changed = FALSE; - m_table_dirty = TRUE; - m_icons_dirty = TRUE; - clearData( FALSE ); + m_changed = false; + m_table_dirty = true; + m_icons_dirty = true; + clearData( false ); } } </pre> @@ -592,13 +592,13 @@ body { background: #ffffff; color: black; } if ( ans == 0 ) fileSave(); else if ( ans == 1 ) - return FALSE; + return false; } - return TRUE; + return true; } </pre> - <p>If the data has changed (<tt>m_changed</tt> is TRUE), we present the user with a message box offering the option of saving their data, or cancelling the current operation (e.g. not loading a new file, or not creating a new set of colors), or abandoning their changes and continuing. We make the <b>Save</b> button the default button (pressed by <b>Enter</b>) and the <b>Cancel</b> button the escape button (pressed by <b>Esc</b>).</p> + <p>If the data has changed (<tt>m_changed</tt> is true), we present the user with a message box offering the option of saving their data, or cancelling the current operation (e.g. not loading a new file, or not creating a new set of colors), or abandoning their changes and continuing. We make the <b>Save</b> button the default button (pressed by <b>Enter</b>) and the <b>Cancel</b> button the escape button (pressed by <b>Esc</b>).</p> <p>Since we're using a <a href="tqmessagebox.html">TQMessageBox</a> we need to include the relevant header. (Right click "Includes (in Implementation)", then click <b>New</b>. Type "tqmessagebox.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>"tqmessagebox.h"</p> @@ -624,7 +624,7 @@ body { background: #ffffff; color: black; } </ul><h4><a name="6-24"></a>load()</h4> <pre> void MainForm::load( const <a href="tqstring.html">TQString</a>& filename ) { - clearData( FALSE ); + clearData( false ); m_filename = filename; <a href="tqregexp.html">TQRegExp</a> regex( "^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\S+.*)$" ); <a href="tqfile.html">TQFile</a> file( filename ); @@ -652,7 +652,7 @@ body { background: #ffffff; color: black; } m_icons_dirty = ! ( m_table_dirty = ( <a href="tqwidget.html#visible-prop">visible</a> == tablePage ) ); populate(); m_icons_dirty = ! ( m_table_dirty = ( visible != tablePage ) ); - m_changed = FALSE; + m_changed = false; } else statusBar()->message( TQString( "Failed to load '%1'" ). @@ -740,7 +740,7 @@ Captures: cap(1) cap(2) cap(3) cap(4) statusBar()->message( TQString( "Saved %1 colors to '%2'" ). arg( m_colors.count() ). arg( m_filename ), 3000 ); - m_changed = FALSE; + m_changed = false; } else statusBar()->message( TQString( "Failed to save '%1'" ). @@ -777,7 +777,7 @@ Captures: cap(1) cap(2) cap(3) cap(4) colorTable->setCurrentCell( row, 0 ); else if ( colorTable->numRows() ) colorTable->setCurrentCell( colorTable->numRows() - 1, 0 ); - m_icons_dirty = TRUE; + m_icons_dirty = true; } else if ( <a href="tqwidget.html#visible-prop">visible</a> == iconsPage && colorIconView->currentItem() ) { <a href="tqiconviewitem.html">TQIconViewItem</a> *item = colorIconView->currentItem(); @@ -793,12 +793,12 @@ Captures: cap(1) cap(2) cap(3) cap(4) colorIconView->setCurrentItem( current ); colorIconView->arrangeItemsInGrid(); } - m_table_dirty = TRUE; + m_table_dirty = true; } if ( ! name.<a href="tqstring.html#isNull">isNull</a>() ) { m_colors.remove( <a href="tqobject.html#name-prop">name</a> ); - m_changed = TRUE; + m_changed = true; statusBar()->message( TQString( "Deleted '%1'" ).arg( <a href="tqobject.html#name-prop">name</a> ), 5000 ); } else |