9 lines
4.6 KiB
HTML
9 lines
4.6 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>PaletteView class</title></head><body><h1>class <tt>PaletteView(<a href="GridView.html">GridView</a>)</tt></h1>A
|
|
PaletteView is a specialised subclass of GridView designed for
|
|
implementing tool palettes and other such components. Instead of row
|
|
and column numbers, the cells in a PaletteView are identified by a
|
|
single integer index, called an <i>item number,</i> with items being numbered from left to right, top to bottom.<br><br>The PaletteView also has a notion of one or more items being <i>selected</i>, and provides support for highlighting selected items in a variety of ways.<br><br>PaletteView inherits from <a href="ScrollableView.html">ScrollableView</a> and can therefore be made scrollable if needed, although it does not show any scroll bars by default.<br><br>The extent of a PaletteView is managed through the <tt>num_items</tt>, <tt>items_per_row</tt> and <tt>cell_size</tt> properties. The <tt>num_rows</tt> and <tt>num_columns</tt> properties inherited from GridView, and the <tt>extent</tt> property inherited from ScrollableView, should not be changed directly.<br><h2>Constructor</h2><blockquote><dl><dt><tt>PaletteView(</tt><i>num_items</i><tt>,</tt> <i>items_per_row</i><tt>, </tt><i>cell_size</i><tt>)</tt></dt><dd>Creates a palette view with the specified initial property values.</dd></dl></blockquote><h2>Properties</h2><blockquote><dl><dt><tt>num_items</tt></dt><dd>Total number of items in the palette. The items will be laid out with <tt>items_per_row</tt> items in each row, using as many rows as necessary. If <tt>num_items</tt> is not an even multiple of<tt> items_per_row</tt>, some cells in the last row will be left empty.<br><br></dd><dt><tt>items_per_row</tt></dt><dd>The number of items in each row of the palette's extent.<br><br></dd><dt><tt>highlight_style</tt></dt><dd>The style in which to highlight selected items. Possible values are:<br><br><ul><li><tt>'fill'</tt> - the cell is filled with the highlight_color before calling draw_item().<br></li><li><tt>'frame'</tt> - a rectangle is drawn around the cell as specified by highlight_color and highlight_thickness before calling draw_item().<br></li><li><tt>''</tt> or <tt>None</tt> - no automatic highlighting is performed.</li></ul><br></dd><dt><tt>highlight_color</tt></dt><dd><a href="Color.html">Color</a> to use for highlighting of selected items.<br><br></dd><dt><tt>highlight_thickness</tt></dt><dd>When using the <tt>'frame'</tt> highlight style, the pen width to use for drawing the highlight rectangle.<br></dd></dl></blockquote><h2>Abstract Methods</h2><blockquote><dl><dt><tt>draw_item(</tt><i>canvas</i><tt>,</tt> <i>item_number</i><tt>,</tt> <i>item_rect</i><tt>)</tt></dt><dd>Should draw the specified item in the given rectangle. Any automatic highlighting specified by the <tt>highlight_style</tt> property has already been applied.<br><br></dd><dt><tt>click_item(</tt><i>item_number</i><tt>,</tt><i> event</i><tt>)</tt></dt><dd>Called when a mouse_down event occurs in an item.<br><br></dd><dt><tt>item_is_selected(</tt><i>item_number</i><tt>)</tt></dt><dd>Should return true if the indicated item is to be regarded as selected.<br><br></dd><dt><tt>draw_item_and_highlight(</tt><i>canvas</i><tt>,</tt> <i>item_number</i><tt>,</tt> <i>item_rec</i>t<tt>, </tt><i>highlight</i><tt>)</tt></dt><dd>This method can optionally be overridden instead of <tt>draw_item()</tt>
|
|
to gain more control over how items are highlighted. Your
|
|
implementation should draw the specified item, and apply highlighting
|
|
if highlight is true. If you override this method, <tt>draw_item()</tt> is not called and no automatic highlighting is performed.</dd></dl></blockquote><h2>Methods</h2><blockquote><dl><dt><tt>item_rect(</tt><i>item_number</i><tt>)</tt></dt><dd>Returns the rectangle corresponding to the given item number. If the item number is out of bounds (less than 0 or greater than <tt>num_items</tt> - 1), returns <tt>None</tt>.<br><br></dd><dt><tt>item_no_of_cell(</tt><i>row_number</i><tt>,</tt> <i>column_number</i><tt>)</tt></dt><dd>Returns the item number corresponding to the specified cell, or <tt>None</tt> if the cell does not correspond to a valid item.<br><br></dd><dt><tt>cell_of_item_no(</tt><i>item_number</i><tt>)</tt></dt><dd>Returns the row and column numbers of the cell corresponding to the given item number. If the item number is out of bounds (less than 0 or greater than <tt>num_items</tt> - 1), returns <tt>None</tt>.</dd></dl></blockquote></body></html> |