if the optionkey is down then put script of me into bkgnd field lowerpane
end mousedown
-- part contents for background part 1
----- text -----
VESTIGIAL CARD: This is the complete text of the Lightspeed Pascal source of the BarButton XCMD. If you want to recompile with modifications, be sure the files DA PasLib and MacTraps are in the Project, and Build and Save As a Code resource of type 'XCMD'. Then ResEdit the XCMD into your stack.
This XCMD was written more as an experiment than anything else.
If you would like your own custom version, and don't feel like writing it yourself, give me a call. There are many simple tasks that Hypercard cannot do well, or quickly, or at all. But XCMD's and XFCN's can avoid most of these deficencies.
Infosynthesis
2960 Ferry Street
Eugene, OR 97405
(503) 344-3322
{BarButton adjusts the size of the bar contained within rect passed in "It", and using the }
{options in the first 4 parameters.}
UNIT Main;
INTERFACE
USES
HyperXCMD;
-- part contents for background part 2
----- text -----
{BarButton adjusts the size of the bar contained within rect in first 4}
DrawRect := ViewRect;{now will be used for the redrawing}
InsetRect(ButtonRect, -10, -10);
IF InitialValue > -32767 THEN
BEGIN{Display forced starting value}
CurrentValue := InitialValue;
DisplayValue;
END
ELSE
BEGIN
ComputeValue;{Display first real value if requested}
REPEAT
GetMouse(spot);
InRect := PtInRect(spot, ButtonRect) AND Button;
IF InRect THEN
BEGIN
newLoc := TRUE;{guilty unless proven innocent}
CASE direction OF
leftToRight, rightToLeft :
BEGIN
IF spot.h = oldspot.h THEN{no horizontal movement; don't redraw at all}
newLoc := FALSE
ELSE
BEGIN
IF spot.h > oldspot.h THEN{moving right}
BEGIN
DrawRect.right := spot.h;
DrawRect.left := oldspot.h;
END
ELSE{moving left}
BEGIN
DrawRect.left := spot.h;
DrawRect.right := oldspot.h;
END;
END;{end new horizontal loc}
DrawRect.top := ViewRect.top;{restore top and bottom in case SectRect wiped them out with empty rect}
DrawRect.bottom := ViewRect.bottom;
END;{end horizontal case}
bottomToTop, topToBottom :
BEGIN
IF spot.v = oldspot.v THEN{no vertical movement; don't redraw at all}
newLoc := FALSE
ELSE
BEGIN
IF spot.v > oldspot.v THEN{moving down}
BEGIN
DrawRect.bottom := spot.v;
DrawRect.top := oldspot.v;
END
ELSE{moving up}
BEGIN
DrawRect.top := spot.v;
DrawRect.bottom := oldspot.v;
END;
END;{end new vertical loc}
DrawRect.left := ViewRect.left;{restore left and right in case SectRect wiped them out with empty rect}
DrawRect.right := ViewRect.right;
END;{end vertical case}
END;{case block}
dummy := SectRect(ViewRect, DrawRect, DrawRect);
IF newLoc THEN{Redraw if necessary}
BEGIN
InvertRect(DrawRect);
IF ShowValue THEN
ComputeValue;{Display current value if requested}
END;
oldspot := spot;{today becomes yesterday}
END;{end InRect}
UNTIL NOT Button;{loop until mouseUp}
ComputeValue;{Put result in "the Result" even if they don't want it displayed}
END;{end of event loop for real values}
str := NumToStr(CurrentValue);
paramPtr^.returnValue := PasToZero(str);
END;{end BarButton}
END.
-- part contents for card part 2
----- text -----
sdsdfsdfsdsfsdf
-- part contents for background part 5
----- text -----
This XCMD was written more as an experiment than anything else.
If you would like your own custom version, and don't feel like writing it yourself, give me a call. There are many simple tasks that Hypercard cannot do well, or quickly, or at all. But XCMD's and XFCN's can avoid most of these deficencies.
Infosynthesis
2960 Ferry Street
Eugene, OR 97405
(503) 344-3322
{BarButton adjusts the size of the bar contained within rect passed in "It", and using the }
DrawRect := ViewRect;{now will be used for the redrawing}
InsetRect(ButtonRect, -10, -10);{allow user to miss rect by 10 pixels}
if InitialValue > -32767 then{force initial value}
begin{Display forced starting value}
CurrentValue := InitialValue;
DisplayValue;
end
else
begin
ComputeValue;{Display first real value if requested}
repeat
GetMouse(spot);{Get current position of mouse}
InRect := PtInRect(spot, ButtonRect) and Button;
if InRect then
begin
newLoc := TRUE;{guilty unless proven innocent}
case direction of
leftToRight, rightToLeft :
begin
if spot.h = oldspot.h then{no horizontal movement; don't redraw at all}
newLoc := FALSE
else
begin
if spot.h > oldspot.h then{moving right}
begin
DrawRect.right := spot.h;
DrawRect.left := oldspot.h;
end
else{moving left}
begin
DrawRect.left := spot.h;
DrawRect.right := oldspot.h;
end;
end;{end new horizontal loc}
DrawRect.top := ViewRect.top;{restore top and bottom in case SectRect wiped them out with empty rect}
DrawRect.bottom := ViewRect.bottom;
end;{end horizontal case}
bottomToTop, topToBottom :
begin
if spot.v = oldspot.v then{no vertical movement; don't redraw at all}
newLoc := FALSE
else
begin
if spot.v > oldspot.v then{moving down}
begin
DrawRect.bottom := spot.v;
DrawRect.top := oldspot.v;
end
else{moving up}
begin
DrawRect.top := spot.v;
DrawRect.bottom := oldspot.v;
end;
end;{end new vertical loc}
DrawRect.left := ViewRect.left;{restore left and right in case SectRect wiped them out with empty rect}
DrawRect.right := ViewRect.right;
end;{end vertical case}
end;{case block}
dummy := SectRect(ViewRect, DrawRect, DrawRect);
if newLoc then{Redraw if necessary}
begin
InvertRect(DrawRect);{Invert only the change in position}
if ShowValue then
ComputeValue;{Display current value if requested}
end;
oldspot := spot;{today becomes yesterday}
end;{end InRect}
until not Button;{loop until mouseUp}
ComputeValue;{Put result in "the Result" even if they don't want it displayed}
end;{end of event loop for real values}
str := NumToStr(CurrentValue);{convert last value to string}
paramPtr^.returnValue := PasToZero(str);{put string in "the result"}
end;{end BarButton}
end.
-- part contents for card part 5
----- text -----
VESTIGIAL CARD: This is the complete text of the Lightspeed Pascal source of the BarButton XCMD. If you want to recompile with modifications, be sure the files DA PasLib and MacTraps are in the Project, and then "Build and Save As" a Code resource of type 'XCMD'. Then ResEdit the XCMD into your stack.