Maybe it has to do with the methods I define. Here is all the View specific code, complete except for the internals of the procedure DrawGraph:
PROCEDURE (v: View) Internalize (VAR rd: Stores.Reader);
VAR version: INTEGER;
BEGIN
rd.ReadVersion(minVersion, maxVersion, version)
END Internalize;
PROCEDURE (v: View) Externalize (VAR wr: Stores.Writer);
BEGIN
wr.WriteVersion(maxVersion)
END Externalize;
PROCEDURE (v: View) HandleModelMsg (VAR msg: Models.Message);
BEGIN
WITH msg: Msg DO
Views.Update(v, Views.keepFrames)
ELSE
END
END HandleModelMsg;
PROCEDURE (v: View) Restore (f: Views.Frame; l, t, r, b: INTEGER);
VAR w, h, i, j: INTEGER;
PROCEDURE DrawGraph;
BEGIN
(* module specific code here, using frame methods
- e.g. f.DrawLine, f.DrawString *)
...
END DrawGraph;
BEGIN
v.context.GetSize(w, h);
DrawGraph;
END Restore;
PROCEDURE (v: View) HandlePropMsg (VAR p: Properties.Message);
CONST min = Xrange * Ports.point; max = 2 * Xrange * Ports.point;
minY = Yrange * Ports.point; maxY = 2 * Yrange * Ports.point;
BEGIN
WITH p: Properties.SizePref DO (* prevent illegal sizes *)
IF p.w = Views.undefined THEN
p.w := max
ELSIF p.w < min THEN p.w := min
ELSIF p.w > max THEN p.w := max
END;
IF p.h = Views.undefined THEN p.h := maxY
ELSIF p.h < min THEN p.h := minY
ELSIF p.h > max THEN p.h := maxY
END
| p: Properties.ResizePref DO
p.horFitToWin := TRUE; p.verFitToWin := TRUE
ELSE
END
END HandlePropMsg;
On Sun, Dec 13, 2009 at 7:38 PM, Douglas G. Danforth <danforth{([at]})nowhere.xy
Antony,
Very good.
Unfortunately I can't get your suggestion to work (yet).
If I just open the form I don't get the right behavior.
Things are not initialized properly.
I still need to find the pointer in the form and then set all of
its fields correctly.
I'll keep searching for what else I might be doing wrong because
I like your way very much.
-Doug
Antony Tersol wrote:
The only way I use Models is:
TYPE
View = POINTER TO RECORD (Views.View) END;
Msg = RECORD (Models.Message) END;
PROCEDURE (v: View) HandleModelMsg (VAR msg: Models.Message);
BEGIN
WITH msg: Msg DO
Views.Update(v, Views.keepFrames)
ELSE
END
END HandleModelMsg;
PROCEDURE (v: View) HandlePropMsg (VAR p: Properties.Message);
CONST min = Xrange * Ports.point; max = 2 * Xrange * Ports.point;
minY = Yrange * Ports.point; maxY = 2 * Yrange * Ports.point;
BEGIN
WITH p: Properties.SizePref DO (* prevent illegal sizes *)
IF p.w = Views.undefined THEN
p.w := max
ELSIF p.w < min THEN p.w := min
ELSIF p.w > max THEN p.w := max
END;
IF p.h = Views.undefined THEN p.h := maxY
ELSIF p.h < min THEN p.h := minY
ELSIF p.h > max THEN p.h := maxY
END
| p: Properties.ResizePref DO
p.horFitToWin := TRUE; p.verFitToWin := TRUE
ELSE
END
END HandlePropMsg;
My summary seems simpler, but there are some other procedures as well, so maybe Douglas would react "Yuck" to my code as well.
Quick summary
(1) define View with appropriate handlers
(2) open an instance of View with desired size.
(3) select, copy, and paste the view into your form.
(4) save the form
For use, open the form.
That's all.
I couldn't decode Robert's, but I compiled the code, deposited a view, saved the form, and reopened and everything worked.
Antony
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Mon Dec 14 2009 - 06:28:00 UTC