Annotation of gforth/moof-exm.fs, revision 1.3
1.2 anton 1: \ mini-oof example
2:
1.3 ! anton 3: \ Copyright (C) 1998,2003 Free Software Foundation, Inc.
1.2 anton 4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20:
1.1 pazsan 21: \ usage:
22:
23: object class
24: cell var text
25: cell var len
26: cell var x
27: cell var y
28: method init
29: method draw
30: end-class button
31:
32: :noname ( o -- ) >r
33: r@ x @ r@ y @ at-xy r@ text @ r> len @ type ;
34: button defines draw
35: :noname ( addr u o -- ) >r
36: 0 r@ x ! 0 r@ y ! r@ len ! r> text ! ;
37: button defines init
38:
39: \ interitance
40:
41: : bold 27 emit ." [1m" ;
42: : normal 27 emit ." [0m" ;
43:
44: button class end-class bold-button
45: :noname bold [ button :: draw ] normal ; bold-button defines draw
46:
47: \ Create and draw a button:
48:
49: button new Constant foo
50: s" thin foo" foo init
51: page
52: foo draw
53: bold-button new Constant bar
54: s" fat bar" bar init
55: 1 bar y !
56: bar draw
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>