AdobeTipImpl.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Philip James, March 2, 1992 5:47 pm PST
Foote, July 13, 1993 3:17 pm PDT
DIRECTORY
AdobeCommon USING [EnumeratedTypes],
AdobeTip,
Cursors USING [SetCursor],
Imager USING [Color, Context, MaskRectangle, Rectangle, SetColor],
ImagerBox,
ImagerBackdoor USING [MakeStipple],
InputFocus USING [CaptureButtons, ReleaseButtons],
IO, Real USING [Round],
TIPTypes,
TIPUser USING [InstantiateNewTIPTable, TIPScreenCoords, TIPTable],
VFonts USING [FontHeight],
ViewerClasses USING [NotifyProc, Viewer, ViewerRec],
ViewerPrivate USING [PaintScreen];
AdobeTipImpl:
CEDAR
MONITOR
IMPORTS Cursors, Imager, ImagerBackdoor, InputFocus, Real, TIPUser, VFonts, ViewerPrivate
EXPORTS AdobeTip ~ {
PaintOp: TYPE = {paint, remove, change};
grey: CARDINAL ¬ 122645B;
xorStipple: Imager.Color = ImagerBackdoor.MakeStipple[stipple: grey, xor: TRUE];
defaultHeight: PUBLIC NAT ¬ VFonts.FontHeight[];
ButtonData: TYPE = REF ButtonDataObj;
ButtonDataObj:
TYPE =
RECORD [
ready: CONDITION,
mode: ATOM ¬ $Busy,
buttonData: AdobeCommon.EnumeratedTypes,
mouseX: REAL,
mouseY: REAL,
initY: REAL,
gridH: CARD,
viewer: ViewerClasses.Viewer ¬ NIL
];
ViewerFromAny:
PROCEDURE [any:
REF
ANY]
RETURNS [v: ViewerClasses.Viewer] ~ {
v ¬ NARROW[any]; };
NotifyProc:
ENTRY ViewerClasses.NotifyProc ~ {
data: ButtonData ¬ NARROW[self.data];
prev: Imager.Rectangle ¬ [0, 0, 0, 0];
rect: Imager.Rectangle ¬ [ViewerFromAny[data.buttonData.mainViewer.outer].wx, data.mouseY - 1,
ViewerFromAny[data.buttonData.mainViewer.outer].ww, 3];
minY: REAL ¬ data.initY + (data.gridH * (data.buttonData.currentHeight - 2));
maxY: INT ¬ ViewerFromAny[data.buttonData.mainViewer.outer].wy;
Clip:
PROC[position: TIPUser.TIPScreenCoords]
RETURNS [x, y:
INTEGER] = {
tmpY: INTEGER;
tmpY ¬ position.mouseY - ((position.mouseY - (data.gridH / 2)) MOD data.gridH);
x ¬ position.mouseX;
y ¬ Real.Round[MAX[MIN[minY, tmpY], maxY]];
};
Draw:
PROC [op: PaintOp ¬ paint] ~ {
Action:
PROC [context: Imager.Context] ~ {
Show: PROC [r: Imager.Rectangle] ~ {Imager.MaskRectangle[context, r]};
IF prev = rect AND op = change THEN RETURN;
Imager.SetColor[context, xorStipple];
SELECT op
FROM
paint => Show[rect];
remove => {
IF prev # [0.0, 0.0, 0.0, 0.0] THEN Show[prev];
prev ¬ [0.0, 0.0, 0.0, 0.0];
};
change => {
IF prev # [0.0, 0.0, 0.0, 0.0] THEN Show[prev];
Show[rect];
};
ENDCASE => ERROR;
};
ViewerPrivate.PaintScreen[main, Action, FALSE];
};
FOR list:
LIST
OF
REF
ANY ¬ input, list.rest
UNTIL list =
NIL
DO
WITH list.first
SELECT
FROM
x:
ATOM =>
SELECT x
FROM
$Abort => {
data.mode ¬ $Abort;
Draw[remove];
InputFocus.ReleaseButtons[];
NOTIFY data.ready;
};
$Move => {
Draw[change];
prev ¬ rect;
};
$End => {
data.mode ¬ $Done;
Draw[remove];
InputFocus.ReleaseButtons[];
NOTIFY data.ready;
};
ENDCASE => NULL;
z: TIPUser.TIPScreenCoords => {
[data.mouseX, data.mouseY] ¬ Clip[z];
rect ¬ [ViewerFromAny[data.buttonData.mainViewer.outer].wx, data.mouseY-1, ViewerFromAny[data.buttonData.mainViewer.outer].ww, 3];
};
ENDCASE => ERROR;
ENDLOOP;
};
AdjustStringField:
PUBLIC
ENTRY PROC [buttonData: AdobeCommon.EnumeratedTypes, gridH:
CARD ¬ defaultHeight]
RETURNS [linesChange:
INT ¬ 0] ~ {
fakeViewer: ViewerClasses.Viewer ¬ NEW[ViewerClasses.ViewerRec];
initY, mouseY:
REAL ¬ ViewerFromAny[buttonData.mainViewer.outer].wy + ViewerFromAny[buttonData.mainViewer.fieldViewer.outer].wh - ViewerFromAny[buttonData.controllerOf].wy - ViewerFromAny[buttonData.controllerOf].wh;
ViewerOps.UserToScreenCoords[
buttonData.mainViewer.fieldViewer.outer,
0, buttonData.controllerOf.wy + buttonData.controllerOf.wh].sy;
instanceData: ButtonData ¬
NEW[ButtonDataObj ¬ [
mode: $Busy,
buttonData: buttonData,
mouseX: 0.0,
mouseY: mouseY,
initY: initY,
gridH: gridH,
viewer: fakeViewer
]];
fakeViewer.data ¬ instanceData;
InputFocus.CaptureButtons[NotifyProc, adjStrTIP, fakeViewer];
Cursors.SetCursor[crossHairsCircle];
UNTIL instanceData.mode = $Done OR instanceData.mode = $Abort DO WAIT instanceData.ready ENDLOOP;
IF instanceData.mode = $Abort THEN RETURN[0];
RETURN[Real.Round[(instanceData.initY - instanceData.mouseY) / instanceData.gridH] ];
};
adjStrTIP: TIPUser.TIPTable ¬ TIPUser.InstantiateNewTIPTable["AdjustField.tip"];
}.