news
About Elegant Chaos
info
About me and my friends
people
Software from Elegant Chaos
software
Other stuff...
stuff

SamsPalette

A command for creating tool palettes (like those created with the palette command), that can be modified , stored and retrieved under script control.

SamsPalette XCMD. Version 2.2d4, by Sam Deane. Copyright ©1994 ULTRALAB. Compiled 14:46:40, 02/12/94. Debugging code included.


[last exit to hypercard] [externals index] [download SamsPalette]

Description

This XCMD is similar to the built-in Palette command, but it implements a large number of features not available in standard hypercard.

These include:

+ mixed sticky and clicky buttons

+ everything changable under script control

+ palettes loaded from resources or created from scratch using hypertalk commands

+ Êhelp balloons for each button

+ Êuser defined messages for move,close,within,idle

+ optional mono and colour versions of a picture, chosen on the fly to suit the screen


Commands

create

Most of the features of the SamsPalette XCMD are accessed by getting and setting the properties of palette windows.

First, of course, you need a palette window to work with. You can either create a new palette window or retrieve an old one from a resource. The syntax for this is as follows:

    SamsPalette "create",<name> {,<WDEF id> {,<WDEF variation> }}
  

The <name> parameter is the name of the palette that you want to use or create. If an SPLT resource with that name is found (see below for an explanation of these resources), then it is used to define the palette. If not, a new empty palette is created.

A new palette is initially hidden, with no buttons, no picture, and all other properties set to default values.

The <WDEF id> and <WDEF variation> parameters are both optional. They specify the id and variation code of a WDEF resource, which will be used to draw the palette, instead of the hypercard'sstandard windoid WDEF.


Properties

buttons

This property indicates how many buttons the palette has. It is initially set to zero.

Increasing the value of the property will create new buttons, but until their position and behaviour have been properly specified (see the current and data properties below), they will in an undefined state.

If the value of the property is decreased, any buttons over the new limit will not be destroyed, but simply disabled.

Æ NB: The current version of this XCMD limits the number of buttons allowed to 32. This restriction will be removed in a future version.

buttonAutoHilite

Example script for buttonAutoHilite

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "AutoHilite of button 1?" with the buttonHilite of window "test"
    if it ­ empty then
      set buttonHilite of window "test" to it
    end if
  end if
end mouseUp

current

Setting up a particular button is a two stage process.

First, to indicate which button you are going to work on, you must set the current property of a palette.

The various properties of the current button can now be inspected or set using a number of other properties: buttonDown, buttonUp, buttonRect, etc...

data

This propery is included for compatability with previous versions of the XCMD.

It has been superceded by the buttonDown, buttonUp, buttonRect etc properties.

help

hide

idle

loc

move

pict

The PICT property of a palette window determines the picture that the palette displays.

Getting the property will return the name or id of the PICT resource that is currently being displayed. The picture can be changed at any time, by setting the property to the name or id of a new resource.

Example script for pict

on mouseUp
  if GotTest() then
    get the pict of window "test"
    if it is "test" then
      set the pict of window "test" to "test 2"
    else
      set the pict of window "test" to "test"
    end if
  end if
end mouseUp

PropertyTable

rect

Example script for rect

on mouseUp
  if GotTest() then
    ask "Rect of window?" with the rect of window "test"
    if it ­ empty then
      set the rect of window "Test" to it
    end if
  end if
end mouseUp

selected

cursor

Example script for cursor

on mouseUp
  if GotTest() then
    ask "Cursor?" with the cursor of window "test"
    if it ­ empty then
      set cursor of window "test" to it
    end if
  end if
end mouseUp

visible

buttonDown

Setting up a particular button is a two stage process.

First, to indicate which button you are going to work on, you must set the current property of a palette.

The various properties of the current button can now be inspected or set using a number of other propert The data property can then be used to get or set the data for the current button.

The data for each button has the following format:

   message,sticky,hilite,icon,help,rect

where:

message
is the message that the button should send to the card when clicked. It should be a short HyperTalk expression, without any commas in it. Typically this is the name of a hypercard handler defined somewhere else.

sticky
is a boolean flag saying whether the button stays selected after it has been clicked on.

hilite
is a boolean flag saying whether the button is currently hilited.

icon
is unused at the moment. It should be set to 0. This property will be supported in a future version.

rect
is the rectangle of the button, relative to the top-left corner of the palette.

help
is the name of a TEXT resource (or TEXT and styl resource pair) containing a baloon help message for the button. When balloon help is switched on, the text in this resource will be displayed when the mouse is over the button.

Here is a script to set the first button in a three button palette so that it beeps when clicked on, it is not sticky, it is unhilited, and it is positioned at 16,16,32,32.

   -- set palette to have three buttons
   set the buttons of window "example" to 3
   
   -- set up the button data for button 1
   put "beep,false,false,0,button 1 help,16,16,32,32" into bdata
   
   --- set up button 1
   set the current of window "example" to 1
   set the data of window "example" to bdata

Example script for buttonDown

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonDown of button 1?" with the buttonDown of window "test"
    if it ­ empty then
      set buttonDown of window "test" to it
    end if
  end if
end mouseUp

buttonUp

Example script for buttonUp

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonUp of button 1?" with the buttonUp of window "test"
    if it ­ empty then
      set buttonUp of window "test" to it
    end if
  end if
end mouseUp

buttonRect

Example script for buttonRect

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonRect of button 1?" with the buttonRect of window "test"
    if it ­ empty then
      set buttonRect of window "test" to it
    end if
  end if
end mouseUp

buttonHilite

Example script for buttonHilite

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonHilite of button 1?" with the buttonHilite of window "test"
    if it ­ empty then
      set buttonHilite of window "test" to it
    end if
  end if
end mouseUp

buttonSticky

Example script for buttonSticky

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonSticky of button 1?" with the buttonSticky of window "test"
    if it ­ empty then
      set buttonSticky of window "test" to it
    end if
  end if
end mouseUp

buttonHelp

Example script for buttonHelp

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonHelp of button 1?" with the buttonHelp of window "test"
    if it ­ empty then
      set buttonHelp of window "test" to it
    end if
  end if
end mouseUp

colourQD

prefix

globalRect

Example script for globalRect

on mouseUp
  if GotTest() then
    ask "Rect of window?" with the globalRect of window "test"
    if it ­ empty then
      set the globalRect of window "Test" to it
    end if
  end if
end mouseUp

buttonEnabled

Example script for buttonEnabled

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonEnabled of button 1?" with the buttonEnabled of window "test"
    if it ­ empty then
      set buttonEnabled of window "test" to it
    end if
  end if
end mouseUp

buttonKind

Example script for buttonKind

on mouseUp
  if GotTest() then
    set current of window "test" to 1
    ask "buttonKind of button 1?" with the buttonKind of window "test"
    if it ­ empty then
      set buttonKind of window "test" to it
    end if
  end if
end mouseUp

keepBack

Example script for keepBack

on mouseUp
  if GotTest() then
    ask "Keep back?" with the keepBack of window "test"
    if it ­ empty then
      set keepBack of window "test" to it
    end if
  end if
end mouseUp

Messages

save

Example script for save

on mouseUp
  if GotTest() then
    send save to window "Test"
  end if
end mouseUp

[last exit to hypercard] [externals index] [download SamsPalette]

This page was created automatically, on 25/03/1999 from version 3.0d4 of Last Exit To Hypercard.