pbsw-code.net : pbsw-ToolPalette

pbsw-ToolPalette

Code for easy creation of a tool palette.

Requires: REALbasic 5.2.4 (has not been tested on other versions)



Basic use:
  1. Add the pbsw_ToolPalette Class to the project
  2. Create images for the selected and unselected versions of the palette. (the images must be exactly the same size, and the grid of tools must be evenly spaced)
  3. Add the images to the project
  4. Create a (floating) window for the palette
  5. Place a canvas in the window, the same size as the images created in step 1
  6. Set the subclass of the canvas to "pbsw_ToolPalette"
  7. Set the "numRows" and "numColumns" properties of the canvas to the appropriate values based on the images you created
  8. In the "open" event of your palette window, put a call to the tool palette canvas's "SetImages" method with the images as parameters

Class: pbsw_ToolPalette

(Superclass: Canvas)

This class is a canvas that acts as a tool palette.

Methods

GetSelectedToolName() as string
Returns the name of the selected tool.

GetSelectedToolNum() as integer
Returns the selected tool number.

(tool numbers start at 0 and go left to right, top to bottom)

SetImages(theUnselectedImage as Picture, theSelectedImage as Picture)
Sets the images to be used for the palette.

SetToolName(theToolNumber as integer, theName as string)
Sets the name of a tool.

theToolNumber is the tool number of which to set the name
theName is the name to set
(tool numbers start at 0 and go left to right, top to bottom)

NewEvents

Open()
(To allow subclasses/instances access to the open event)

ToolChanged(theToolNum as integer)
This event fires when a new tool has been selected.

theToolNum will be set to the number of the tool that was selected.
(tool numbers start at 0 and go left to right, top to bottom)


pbsw-code.net : pbsw-ToolPalette