\ component 04mar00py
: get-win ( -- win ) & displays @ object class?
IF displays get-win ELSE widget dpy get-win THEN ;
modal class component
early open immediate
early dialog immediate
early open-app immediate
early menu immediate
early open-win
method params
method widget
how:
: widget s" Nothing" text-label new ;
: params DF[ 0 ]DF s" No Title" ;
: init ( -- ) ^>^^ assign
widget 1 ^ params 2drop nip super init ;
: open-win ( -- ) self params rot drop
screen self window new window with assign show endwith ;
: make ( o -- win )
new, dup >o params o> rot drop
screen self window new window with assign ^ endwith ;
: open, make window with show endwith ;
: dialog, make get-win
swap window with set-parent show endwith ;
: open-app, make window with show up@ app ! 1 apprefcnt +! endwith ;
: menu, ( o -- o ) >o widget o> ;
: open ( -- ) o@ state @
IF postpone ALiteral postpone open, ELSE open, THEN ;
: dialog ( -- ) o@ state @
IF postpone ALiteral postpone dialog, ELSE dialog, THEN ;
: open-app ( -- ) o@ state @
IF postpone ALiteral postpone open-app, ELSE open-app, THEN ;
: menu ( -- ) ^ state @
IF postpone ALiteral postpone menu, ELSE menu, THEN ;
class;
: new-component ( o od addr u -- o )
>r >r 1 swap modal new r> r>
screen self window new window with assign ^ endwith ;
: open-component ( o od addr u -- )
new-component window with show endwith ;
: open-dialog ( o od addr u -- )
new-component get-win
swap window with set-parent show endwith ;
: open-application ( o od addr u -- )
new-component window with show up@ app ! 1 apprefcnt +! endwith ;
\ empty menu stub
component class