home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 106
/
EnigmaAmiga106CD.iso
/
www
/
afc
/
afc-dir
/
mgui_all.lha
/
mgui_Source.lha
/
Source
/
mgui.e
next >
Wrap
Text File
|
1999-02-20
|
33KB
|
1,269 lines
/*
$VER: MGui V2.30 - (C)Amiga Foundation Classes
Base: $000C0000
V1.00 - First Release
V1.10 - EasyGUI 3.3a updated.
V1.20 - Added:
+ MGUI_NAME a tag that allows user TO define a "name", (a LONG)
TO identify various GUIs.
+ action() method, you can DO a lot of things with it!
Updated: pos(): now can search FOR NAME, GUIHANDLES, AND MAIN.
Now is part of the AFC
V1.21 - MGUI_FREEGUI tag added.
V1.30 - Now it is EasuGUI 3.3b compatible.
V1.40 - Added addA() method
V1.50 - NEW multi-gui handling routines (EasyGUI compatible)
V2.00 - Completely rewritten.
V2.10 - Added the hide/show method.
V2.20 - Added MGUI_INFO field
V2.30 - Removed the MGUI_MGUI tag.
*/
OPT OSVERSION = 37
OPT PREPROCESS
OPT LARGE
->#define DO_MGUI_MODULE
->#define TEST
#define DO_FABIO_PLUGIN
#ifdef DO_MGUI_MODULE
OPT MODULE
OPT EXPORT
#endif
MODULE 'tools/easygui',
'afc/nodemaster',
'exec/memory'
#ifndef DO_MGUI_MODULE
MODULE 'tools/exceptions',
'intuition/intuition', 'exec/ports'
#ifdef DO_FABIO_PLUGIN
MODULE '*DOOPSI:NewVersion/PlugIns/CenterTxt',
'fabio/appwin_oo'
#endif
#endif
CONST MGUI_BASE = $000C0000
CONST MGUI_VERSION=2,
MGUI_REVISION=30
ENUM MGUI_MAIN=MGUI_BASE, MGUI_FREEPROC,
MGUI_ADDEXTERNAL, MGUI_REMEXTERNAL,
MGUI_LOCK, MGUI_LOCKALL,
MGUI_HIDE, MGUI_HIDEALL,
MGUI_NAME, MGUI_USER, MGUI_FREEGUI,
MGUI_SCREEN, MGUI_INFO
ENUM MGUI_SEARCH_NAME=1, MGUI_SEARCH_GUIHANDLE, MGUI_SEARCH_MAIN
SET MGUI_ACTION_TOFRONT, MGUI_ACTION_TOBACK, MGUI_ACTION_ACTIVATE,
MGUI_ACTION_ALL
-> /// Main Docs
/*
@node main "Amiga Foundation Classes: mgui/Main"
** Mgui- Original By Fabio Rotondo **
Part of Amiga Foundation Classes
--- NO LONGER SUPPORTED ---
@{" Introduction " LINK mgui_intro} @{" Author(s) Info " LINK author} @{" Amiga Foundation Classes " LINK "afc.guide/main"}
Requires: @{" NodeMaster " LINK "NodeMaster.guide/Main"}, EasyGUI
Base: $000C
COMMANDS BRIEF DESCRIPTION
-----------------------------------------------------------------------
@{" mgui() " LINK mgui_mgui} Init the object.
@{" addA(wtitle, gui, tags) " LINK mgui_addA} Add a new GUI.
@{" clear() " LINK mgui_clear} Close all GUIs.
@{" del() " LINK mgui_del} Delete a GUI.
@{" empty() " LINK mgui_empty} Check if mgui has no GUIs.
@{" first() " LINK mgui_first} Pos on first GUI.
@{" freeguis() " LINK mgui_INTERNAL} * INTERNAL USE ONLY *
@{" gui() " LINK mgui_gui} Actual GUI pointer.
@{" lock(mode=TRUE) " LINK mgui_lock} Lock/Unlock GUI.
@{" message() " LINK mgui_message} Parse a message.
@{" nm() " LINK mgui_nm} Returns related NodeMaster object.
@{" numgui() " LINK mgui_numgui} Number of avail GUIs.
@{" pop(pos=TRUE) " LINK mgui_pop} Pop a GUI from the stack.
@{" pos(v, m=NAME, here=FALSE) " LINK mgui_pos} Search for a GUI.
@{" push() " LINK mgui_push} Push a GUI into the stack.
@{" setattrs(tags) " LINK mgui_setattrs} Set various attributes.
@{" succ() " LINK mgui_succ} Pos on next GUI.
@{" version() " LINK mgui_version} Returns object's version and revision.
@{" ERROR TABLE " LINK Error_Table}
@endnode
@node author "Author(s) Info"
Original By: Fabio Rotondo (fsoft@intercom.it)
E Version By: Fabio Rotondo
Address:
Fabio Rotondo
C.so Vercelli 9
28100 Novara
ITALY
e-mail: fsoft@intercom.it
Fabio.Rotondo@deagostini.it
Phone: (ITA) - (0)321 - 459676 (home)
(ITA) - (0)2 - 38086520 (office)
(ITA) - (0)338 - 7336477 (GSM Phone)
Fax: (ITA) - (0)2 - 38086278
Web: http://www.intercom.it/~fsoft (my home page)
http://www.intercom.it/~fsoft/ablast.html (Amiga Blast Home Page)
@endnode
@node mgui_intro "mgui / Introduction"
MGUI
Mgui is a class that helps Amiga E programmers to write multi-gui programs
very easily.
It rely heavily on EasyGUI, so it is very hard that it will be ported to
any other language. Anyway, I decided to include it in AFC because it is
extremily useful.
Note: you must to know how to use EasyGUI to use mgui.
I have nothing more to add. Just try this class and enjoy yourself.
Cheers,
Fabio Rotondo
@endnode
@node Error_Table "mgui / Error Table"
At the moment, this class does not define any error.
@endnode
*/
-> ///
OBJECT gui_obj
PUBLIC
gh :PTR TO guihandle -> Puntatore ALL'HANDLE della GUI
main :CHAR -> Flag TRUE/FALSE per determinare se questa GUI è la principale
gui :PTR TO LONG -> Puntatore alla GUI allocata dinamicamente
user -> Qualcosa dell'utente...
info -> Qualcos'altro dell'utente...
mg :PTR TO mgui -> MGUI corrente.
PRIVATE
sig :LONG
kill :CHAR -> Flag TRUE/FALSE per uccidere una gui
kind :CHAR -> 0=GUI, 1=EXTERNAL
name :LONG -> "nome" della GUI: max una LONG.
free :CHAR -> Flag TRUE/FALSE per fare il disposegui() della GUI
fromdel:CHAR
xinfo :PTR TO LONG -> Puntatore agli oggetti da "Uccidere"
ENDOBJECT
OBJECT mgui
PRIVATE
nm :PTR TO nodemaster
extsig :LONG -> Messaggi "esterni" a MGUI
screen :PTR TO LONG
cgui :PTR TO gui_obj -> Puntatore alla GUI che ha generato il messaggio
multi :PTR TO multihandle -> Multi Handler
fromclear:CHAR
ENDOBJECT
#ifndef DO_MGUI_MODULE
#ifdef DO_FABIO_PLUGIN
DEF times=0
#endif
#endif
-> /// PROC mgui() OF mgui
/*
@node mgui_mgui "mgui / mgui()"
NAME: mgui()
DESCRIPTION: mgui class constructor.
INPUTS: NONE
RESULTS: NONE
SEE ALSO: @{" NodeMaster/nodemaster() " LINK "NodeMaster.guide/NodeMaster_nodemaster"}
@endnode
*/
PROC mgui() OF mgui
self.nm:=NIL
NEW self.nm.nodemaster()
self.screen :=NIL
self.extsig :=NIL
self.multi :=multiinit()
self.fromclear:=FALSE
ENDPROC
-> ///
-> /// end()
PROC end() OF mgui
self.clear()
END self.nm
ENDPROC
-> ///
-> /// PROC first() OF mgui IS self.nm.first()
/*
@node mgui_first "mgui / first()"
NAME: first()
DESCRIPTION: Set position to the first GUI in the mgui object.
INPUTS: NONE
RESULTS: a PTR to GUI - First() succeded.
NIL - First() failed.
SEE ALSO: @{" NodeMaster/first() " LINK "NodeMaster.guide/NodeMaster_first"}
@endnode
*/
PROC first() OF mgui IS self.nm.first()
-> ///
-> /// PROC succ() OF mgui IS self.nm.succ()
/*
@node mgui_succ "mgui / succ()"
NAME: succ()
DESCRIPTION: Set position to the next GUI in the mgui object.
INPUTS: NONE
RESULTS: a PTR to GUI - succ() succeded.
NIL - succ() failed.
SEE ALSO: @{" NodeMaster/succ() " LINK "NodeMaster.guide/NodeMaster_succ"}
@endnode
*/
PROC succ() OF mgui IS self.nm.succ()
-> ///
-> /// PROC empty() OF mgui IS self.nm.empty()
/*
@node mgui_empty "mgui / empty()"
NAME: empty()
DESCRIPTION: Checks if mgui object is empty or not.
INPUTS: NONE
RESULTS: TRUE - mgui object is empty.
FALSE - at least one GUI is present.
SEE ALSO: @{" NodeMaster/empty() " LINK "NodeMaster.guide/NodeMaster_empty"}
@endnode
*/
PROC empty() OF mgui IS self.nm.empty()
-> ///
-> /// PROC gui() OF mgui IS self.nm.obj()
/*
@node mgui_gui "mgui / gui()"
NAME: gui()
DESCRIPTION: Get actual GUI pointer.
INPUTS: NONE
RESULTS: a PTR to a GUI - gui() succeded.
NIL - gui() failed. (mgui is empty)
SEE ALSO: @{" NodeMaster/obj() " LINK "NodeMaster.guide/NodeMaster_obj"}
@endnode
*/
PROC gui() OF mgui IS self.nm.obj()
-> ///
-> /// PROC numgui() OF mgui IS self.nm.numitems()
/*
@node mgui_numgui "mgui / numgui()"
NAME: numgui()
DESCRIPTION: Get the number of GUIs opened at the moment.
INPUTS: NONE
RESULTS: a LONG containing the number of GUIs opened.
SEE ALSO: @{" NodeMaster/numitems() " LINK "NodeMaster.guide/NodeMaster_numitems"}
@endnode
*/
PROC numgui() OF mgui IS self.nm.numitems()
-> ///
-> /// PROC push() OF mgui IS self.nm.push()
/*
@node mgui_push "mgui / push()"
NAME: push()
DESCRIPTION: Push a GUI into the stack.
INPUTS: NONE
RESULTS: TRUE - GUI pushed into the stack.
FALSE - push() failed. (Stack is full)
SEE ALSO: @{" NodeMaster/push() " LINK "NodeMaster.guide/NodeMaster_push"}
@endnode
*/
PROC push() OF mgui IS self.nm.push()
-> ///
-> /// PROC pop(pos=TRUE) OF mgui IS self.nm.pop(pos)
/*
@node mgui_pop "mgui / pop()"
NAME: pop(pos=TRUE)
DESCRIPTION: Pop a GUI from the stack.
INPUTS: pos - Should be TRUE or FALSE:
TRUE - (default) a GUI is pop()ed from the stack
and the mgui object is positioned on it.
FALSE - a GUI is pop()ed from the stack, but mgui
IS NOT positioned on it (ie. just clear a
push()ed GUI)
RESULTS: a PTR to GUI - pop() succeded.
NIL - pop() failed (stack is empty or pos=FALSE)
SEE ALSO: @{" NodeMaster/pop() " LINK "NodeMaster.guide/NodeMaster_pop"}
@endnode
*/
PROC pop(pos=TRUE) OF mgui IS self.nm.pop(pos)
-> ///
-> /// PROC clear() OF mgui
/*
@node mgui_clear "mgui / clear()"
NAME: clear()
DESCRIPTION: Close all GUIs.
INPUTS: NONE
RESULTS: all GUIs are closed.
SEE ALSO: @{" NodeMaster/clear() " LINK "NodeMaster.guide/NodeMaster_clear"}
@endnode
*/
PROC clear() OF mgui
DEF gui:PTR TO gui_obj
#ifdef TEST
WriteF('Clearing ALL...\n')
#endif
self.fromclear:=TRUE
IF self.nm.empty()=FALSE
gui:=self.nm.first()
REPEAT
gui:=self.del(gui)
UNTIL gui=FALSE
ENDIF
self.nm.clear()
cleanmulti(self.multi)
self.fromclear:=FALSE
#ifdef TEST
-> WriteF('Multi Sig:\h\n', self.multi.sig)
#endif
ENDPROC
-> ///
-> /// PROC clearguis() OF mgui IS Raise("cgui")
/*
Private use only.
*/
PROC clearguis() OF mgui IS Raise("cgui")
-> ///
-> /// PROC addA(wtitle:PTR TO CHAR, gui, tags=NIL:PTR TO LONG) OF mgui HANDLE
/*
@node mgui_addA "mgui / addA()"
NAME: addA(wtitle:PTR TO CHAR, gui, tags=NIL:PTR TO LONG)
DESCRIPTION: Add a new GUI to mgui object using tag-list.
INPUTS: wtitle - Title of the GUI window.
gui - GUI description (see EasyGUI)
tags - Tag List. You can happily mix EasyGUI tags
with Mgui tags in the same list.
RESULTS: a PTR to a gui_obj - The GUI has been added.
NOTES: - This method may raise exceptions coming from NodeMaster() and
EasyGUI.
- Starting from EasyGUI V3.3a, new tags have been added to
allow better multiple GUIs handling.
Please, note that:
-->> you MUST NOT use the EG_CLEAN tag <<--
Use the MGUI_FREEPROC method instead.
- Don't use EG_INFO. Use MGUI_INFO instead.
- This method actually returns TWO values:
gui - a pointer to a valid gui_obj
gh - pointer to the gui handle
SEE ALSO: @{" setattrs() " LINK Mgui_setattrs}
EasyGUI/easyguiA()
@{" NodeMaster/add() " LINK "NodeMaster.guide/NodeMaster_add"}
@endnode
*/
PROC addA(wtitle:PTR TO CHAR, gui, tags=NIL:PTR TO LONG) OF mgui HANDLE
DEF gh=NIL:PTR TO guihandle
DEF guio=NIL:PTR TO gui_obj
DEF taglist=NIL:PTR TO LONG
DEF count=0, t, pos, v
NEW guio
guio.main := FALSE
guio.xinfo := NIL
guio.gui := gui
guio.kill := FALSE
guio.kind := 0
guio.name := NIL
guio.user := NIL
guio.free := TRUE
guio.mg := NIL
guio.fromdel:=FALSE
guio.mg := self
t:=tags
WHILE (Long(tags++))
count++
ENDWHILE
tags:=t
taglist:=List(count+8)
IF count
ListCopy(taglist, tags, count)
ListAdd(taglist, [EG_INFO, guio, EG_CLEAN, {closeproc}, NIL, NIL], 6)
ELSE
ListCopy(taglist, [EG_INFO, guio, EG_CLEAN, {closeproc}, NIL, NIL], 6)
ENDIF
gh:=addmultiA(self.multi, wtitle, gui, taglist) ->[EG_INFO, guio, EG_CLOSE, {closeproc}, NIL, NIL]) ->taglist) ->s)
guio.gh := gh
self.nm.add(guio)
self.setattrs(taglist)
Dispose(taglist)
RETURN guio, gh
EXCEPT
Dispose(taglist)
cleangui(gh)
END guio
ReThrow()
ENDPROC
-> ///
-> /// PROC message() OF mgui HANDLE
/*
@node mgui_message "mgui / message()"
NAME: message()
DESCRIPTION: Waits for a new message from the user.
This is one of the coolest methods of the object:
you just do not have to do anything: everything is
handled by this method, which minds also for
inputs coming from external signals.
INPUTS: NONE
RESULTS: This method returns THREE values at a time:
parsed - TRUE if signal arrived has been
correctly parsed.
sig - Signal arrived at Wait().
res - result returned by guimessage().
SEE ALSO: EasyGUI/guimessage()
@endnode
*/
PROC message() OF mgui HANDLE
DEF res=NIL, sig=NIL, parsed=FALSE
DEF gh:PTR TO guihandle
DEF quitvar = FALSE
DEF gui:PTR TO gui_obj
DEF prg
IF self.multi.sig OR self.extsig
sig:=Wait(self.multi.sig OR self.extsig)
IF sig AND self.multi.sig
parsed:=TRUE
sig :=sig
res:=multimessage(self.multi)
ENDIF
IF sig AND self.extsig
IF self.first()
REPEAT
gui:=self.gui()
IF gui.kind=1
IF (gui.sig AND sig)
parsed:=TRUE
prg:=gui.xinfo
prg(gui.gui)
ENDIF
ENDIF
UNTIL (self.succ()=FALSE) OR (parsed=TRUE)
ENDIF
ENDIF
ENDIF
EXCEPT
IF exception="cgui" THEN self.clear() ELSE ReThrow()
ENDPROC parsed, sig, res
-> ///
-> /// PROC setattrs(tags:PTR TO LONG) OF mgui
/*
@node mgui_setattrs "mgui / setattrs()"
NAME: setattrs(tags)
DESCRIPTION: This method is used to change some current GUI's attributes
and also to change mgui object's attributes.
This is the only way to modify mgui behaviours.
INPUTS: There are two kind of tags, those working on the current GUI
and the others working on mgui itself. We'll list them
separately.
GUI Tags, these are the tags acting on the current GUI:
MGUI_MAIN - Tells mgui whether the current GUI is the main one
or not. When the main GUI is closed, all the
others GUI will be closed at the same time.
Possible values, TRUE / FALSE.
MGUI_FREEPROC - Tells mgui what procedure(s) to call when
the current GUI'll be closed. This is very
useful, because you can create very complex
GUI with a lot of dinamycally allocated
objects and structures, that have to be freed
on GUI closing. This command needs a list
(or a structure) containing: PTR to proc and
arguments to pass to the procedure. Example:
[MGUI_FREEPROC, [{freeobj}, obj,
{freesig}, sig,
NIL, NIL],
NIL, NIL]
MGUI_NAME - This is not just a name, it is more like an
"handle". Name value can be of 4 bytes (4 CHARS)
just like the errors you usually Raise().
Possible values, anything 4 bytes long.
Example: "MAIN"
MGUI_USER - This is a field you should fill with anything you
want. It is just a PTR to something.
Possible values, everything.
Example: myobj.
MGUI_INFO - This is the MGui replacement FOR EG_INFO.
MGUI_LOCK - You can lock/unlock a GUI with this tag, so you
can receive user's inputs or just ignore them.
Possible values: TRUE (locks GUI), FALSE (unlock GUI)
MGUI_FREEGUI - You can tell to Mgui class whether to free a GUI
or not. Usually, Mgui will mind GUI deallocation
after closing the GUI, so you don't have to
worry about it, but sometimes, it is better if
YOU do it by yourself. For example, in a
multi-gui list. This TAG will allow you to do
whatever you want with your GUI definition.
Possible values: TRUE (default) free the gui
definition. FALSE do not free gui definition.
NOTE: by default the gui definition WILL BE
freed. And you have to set this tag to FALSE
for every GUI you do not want to free.
MGUI Tags, these are tags action on the mgui object as a whole:
MGUI_ADDSIGMASK - With this tag you can add to mgui Wait()
signal some external signals you want mgui to
hear about. When the Wait() is trigged by
one of these sigs, the message isn't parsed
and the message() method will return it to
your control: you should be able to handle
this message correctly.
MGUI_REMSIGMASK - With this tag you can remove an external
signal previously added with MGUI_ADDSIGMASK.
From now on, Wait() will not wait for it
anymore.
MGUI_ADDEXTERNAL - This is a tag very similar to
MGUI_ADDSIGMASK, but this time, you have to
provide to mgui also a procedure to call
whenever the Wait() is trigged by the sig
you want. This is very useful, for example,
to wait for Commodity or ARexx events and
then to have mgui to handle all these stuff
for you.
The syntax is the following:
[MGUI_ADDEXTERNAL, [{procedure}, signal,
proc_params],
NIL, NIL]
procedure - proc to call when Wait() is
trigged.
signal - External signal to check.
proc_params - Paramteres to pass to the
procedure. If you want to
pass more than one single
value, enclose them inside
[]. Example:
[param1, param2, param3]
MGUI_REMEXTERNAL - This tag removes a signal set with
MGUI_ADDEXTERNAL. From now on, Wait() will
not wait for external exents anymore.
Possible values: signal to remove.
Example:
[MGUI_REMEXTERNAL, signal, NIL, NIL]
MGUI_LOCKALL - This tag will enable you to lock/unlock
ALL GUIs in one single shot.
Possible values: TRUE (locks GUIs), FALSE
(unlock GUIs)
NOTES: - Don't use EG_INFO in your program. Use MGUI_INFO instead.
- Don't use EG_CLEAN in your program. Use MGUI_FREEPROC instead (it is
also more comfy than EG_CLEAN)
RESULTS: NONE
SEE ALSO: @{" message() " LINK mgui_message}
@{" action() " LINK mgui_action}
@endnode
*/
PROC setattrs(tags:PTR TO LONG) OF mgui
DEF t, i, x:PTR TO LONG
DEF gui:PTR TO gui_obj
DEF k
IF self.empty() THEN RETURN
gui:=self.gui()
WHILE (t:=Long(tags++))
i:=Long(tags++)
SELECT t
CASE MGUI_INFO
gui.info := i
CASE MGUI_MAIN
gui.main := i
CASE MGUI_NAME
gui.name := i
CASE MGUI_USER
gui.user := i
CASE MGUI_FREEGUI
gui.free := i
CASE MGUI_ADDEXTERNAL
gui:=NIL
x:=i
k:=self.extsig
k:=k OR x[1]
self.extsig:=k
NEW gui
gui.gh := NIL
gui.xinfo := x[0] -> PROC
gui.sig := x[1] -> Signal
gui.gui := x[2] -> Info
gui.kill := FALSE
gui.kind := 1
gui.mg := self
self.nm.add(gui)
CASE MGUI_REMEXTERNAL
self.nm.push()
IF gui:=self.first()
REPEAT
IF gui.kind=1 THEN IF gui.sig=i
gui.kill:=TRUE
k:=self.extsig
k:=k AND Not(i)
self.extsig:=k
ENDIF
UNTIL (gui:=self.succ())=FALSE
ENDIF
self.nm.pop()
CASE MGUI_LOCK
self.lock(i)
CASE MGUI_LOCKALL
self.nm.push()
IF self.first()
REPEAT
self.lock(i)
UNTIL self.succ() = NIL
ENDIF
self.nm.pop()
CASE MGUI_FREEPROC
gui.xinfo:=i
#ifdef TEST
WriteF('Free PROC:\h\n', gui.xinfo[0])
#endif
CASE MGUI_HIDE
self.hide(i)
CASE MGUI_HIDEALL
self.nm.push()
IF self.first()
REPEAT
self.hide(i)
UNTIL self.succ() = NIL
ENDIF
self.nm.pop()
CASE MGUI_SCREEN
self.screen:=i
ENDSELECT
ENDWHILE
ENDPROC
-> ///
-> /// PROC lock(mode=TRUE) OF mgui
/*
@node mgui_lock "mgui / lock()"
NAME: lock(mode=TRUE)
DESCRIPTION: This method locks or unlocks current GUI.
INPUTS: mode - TRUE locks the GUI (default),
FALSE unlocks the GUI.
RESULTS: NONE
SEE ALSO: @{" setattrs() " LINK mgui_setattrs}
EasyGUI/blockwin()
EasyGUI/unblockwin()
@endnode
*/
PROC lock(mode=TRUE) OF mgui
DEF gui:PTR TO gui_obj
gui:=self.gui()
IF gui.kind<>0 THEN RETURN
IF mode=TRUE
blockwin(gui.gh)
ELSE
unblockwin(gui.gh)
ENDIF
ENDPROC
->///
-> /// hide
PROC hide(mode=TRUE) OF mgui
DEF gui:PTR TO gui_obj
gui:=self.gui()
IF gui.kind<>0 THEN RETURN
IF mode=TRUE
closewin(gui.gh)
ELSE
openwin(gui.gh)
ENDIF
ENDPROC
-> ///
-> /// PROC del(gui=NIL:PTR TO gui_obj) OF mgui HANDLE
/*
@node mgui_del "mgui / del()"
NAME: del()
DESCRIPTION: This method close current GUI.
The current GUI is closed and the proc set using
MGUI_FREEPROC tag is called to free resources.
INPUTS: NONE
RESULTS: PTR to next avaible GUI or NIL if it was the last GUI.
SEE ALSO: @{" add() " LINK mgui_add}
@{" NodeMaster/del() " LINK "NodeMaster.guide/NodeMaster_del"}
@endnode
*/
PROC del(gui=NIL:PTR TO gui_obj) OF mgui HANDLE
DEF t:PTR TO LONG
DEF cproc, info
IF self.nm.empty() THEN RETURN
IF gui=NIL THEN gui:=self.nm.obj()
IF self.fromclear THEN gui.main:=FALSE
#ifdef TEST
WriteF('Deleting GUI:\h - Kind:\d (\d)\n', gui.gh, gui.kind, gui.main)
WriteF('Free PROC:\h\n', gui.xinfo[0])
#endif
-> gui:=self.nm.obj()
IF gui.kind=0
IF gui.main = FALSE
gui.fromdel:=TRUE
IF gui.gh.wnd<>NIL THEN cleangui(gui.gh)
IF (t:=gui.xinfo)
REPEAT
cproc:=Long(t++)
info :=Long(t++)
IF (cproc<>NIL) THEN cproc(info)
UNTIL (cproc=NIL)
disposegui(t)
ENDIF
disposegui(gui.gui)
END gui
gui:=self.nm.del()
ELSE
gui.free:=FALSE
gui.main:=FALSE
Raise("cgui")
ENDIF
ELSE
-> self.setattrs([MGUI_REMEXTERNAL, gui.sig, NIL, NIL])
END gui
gui:=self.nm.del()
ENDIF
EXCEPT
ReThrow()
ENDPROC gui
-> ///
-> /// PROC pos(v, mode=MGUI_SEARCH_NAME, fromhere=FALSE) OF mgui
/*
@node mgui_pos "mgui / pos() "
NAME: pos(value, mode=MGUI_SEARCH_NAME, fromhere=FALSE)
DESCRIPTION: This method will scan all GUIs to find the one matching the
value required. Value may vary and it is influenced by the
mode value.
INPUTS: value - Value to search.
mode - Search mode. Avaible modes are:
MGUI_SEARCH_NAME - Compare value with GUI's name
field.
MGUI_SEACH_GUIHANDLE - Compare value with GUI's
guihandle.
MGUI_SEARCH_MAIN - Will search for the first
GUI with the main flag set.
fromhere - Tells mgui whether to scan from the beginning
of the list of GUIs or just from the current
position. Default is FALSE: the list is scanned
from the first position.
RESULTS: a PTR to GUI - pos() succeded.
NIL - pos() failed.
NOTE: When the pos() has mode set to MGUI_SEARCH_MAIN, value is
ignored.
SEE ALSO:
@endnode
*/
PROC pos(v, mode=MGUI_SEARCH_NAME, fromhere=FALSE) OF mgui
DEF gui:PTR TO gui_obj
DEF ok=FALSE
IF self.nm.empty() THEN RETURN FALSE
self.nm.push()
IF fromhere=FALSE
gui:=self.nm.first()
ELSE
gui:=self.nm.obj()
ENDIF
IF gui
REPEAT
SELECT mode
CASE MGUI_SEARCH_NAME
IF gui.name=v THEN ok:=TRUE
CASE MGUI_SEARCH_GUIHANDLE
IF gui.gh = v THEN ok:=TRUE
CASE MGUI_SEARCH_MAIN
IF gui.main THEN ok:=TRUE
ENDSELECT
IF ok=FALSE THEN gui:=self.nm.succ()
UNTIL ((gui=FALSE) OR (ok=TRUE))
ENDIF
IF ok
self.nm.pop(FALSE)
ok:=self.nm.obj()
ELSE
self.nm.pop()
ENDIF
ENDPROC ok
-> ///
-> /// PROC nm() OF mgui IS self.nm
/*
@node mgui_nm "mgui / nm() "
NAME: nm()
DESCRIPTION: This method returns the PTR to the embedded
NodeMaster object.
INPUTS: NONE
RESULTS: a PTR to NodeMaster object.
SEE ALSO: @{" NodeMaster " LINK "NodeMaster.guide/main"}
@endnode
*/
PROC nm() OF mgui IS self.nm
-> ///
-> /// PROC action(act) OF mgui
/*
@node mgui_action "mgui / action() "
NAME: action(actions)
DESCRIPTION: This method is used to trig some actions on current GUI.
INPUTS: actions - Action to perform on current GUI.
Current defined actions are:
MGUI_ACTION_TOFRONT - Brings GUI window to front.
MGUI_ACTION_TOBACK - Brings GUI window to back.
MGUI_ACTION_ACTIVATE - Activate GUI window.
These actions can be ORed together. Example:
action(MGUI_ACTION_TOFRONT OR MGUI_ACTION_ACTIVATE)
RESULTS: TRUE - Actions performed.
FALSE - action() failed (maybe no GUI is avaible)
SEE ALSO: @{" setattrs() " LINK mgui_setattrs}
@endnode
*/
PROC action(act) OF mgui
DEF gui:PTR TO gui_obj
IF (gui:=self.nm.obj())=NIL THEN RETURN FALSE
IF act AND MGUI_ACTION_TOFRONT THEN WindowToFront(gui.gh.wnd)
IF act AND MGUI_ACTION_TOBACK THEN WindowToBack(gui.gh.wnd)
IF act AND MGUI_ACTION_ACTIVATE THEN ActivateWindow(gui.gh.wnd)
ENDPROC TRUE
-> ///
-> /// PROC version() OF mgui IS MGUI_VERSION, MGUI_REVISION
/*
@node mgui_version "mgui / version() "
NAME: version()
DESCRIPTION: This method returns current version and revision of the
mgui class currently in use.
INPUTS: NONE
RESULTS: This method returns TWO values: version and revision.
SEE ALSO:
@endnode
*/
PROC version() OF mgui IS MGUI_VERSION, MGUI_REVISION
-> ///
PROC closeproc(mh:PTR TO multihandle, gui:PTR TO gui_obj)
IF gui.free
gui.free:=FALSE
#ifdef TEST
WriteF('Closing gui:\h - (\h) Main:\d\n', gui.gh, gui, gui.main)
WriteF('Free PROC:\h\n', gui.xinfo[0])
#endif
IF gui.mg<>NIL
#ifdef TEST
-> WriteF('From clear:\d\n', gui.mg.fromclear)
#endif
IF (gui.mg.fromclear=FALSE) AND (gui.fromdel=FALSE)
IF gui.mg.pos(gui.gh, MGUI_SEARCH_GUIHANDLE) THEN gui.mg.del(gui)
ENDIF
ENDIF
ENDIF
ENDPROC
#ifndef DO_MGUI_MODULE
PROC main_end()
Raise("end")
ENDPROC
PROC main() HANDLE
DEF mg=NIL:PTR TO mgui
DEF win=NIL:PTR TO window
DEF sig
NEW mg.mgui()
mg.addA('MGUI Main', [ROWS, [SBUTTON, {kill_all}, 'Kill ALL'],
[SBUTTON, {newgui}, 'NEW!'],
[SBUTTON, {hideall}, 'Hide'],
[SBUTTON, {showall}, 'Show']
],
[MGUI_MAIN, TRUE, NIL, NIL]
)
test(mg)
test(mg)
test(mg)
-> mg.lock(TRUE)
IF (win:=OpenWindowTagList(NIL, [WA_WIDTH, 200,
WA_HEIGHT, 100,
WA_TITLE, 'Click Inside!',
WA_IDCMP, IDCMP_MOUSEBUTTONS,
NIL, NIL]))=NIL THEN Raise("win")
sig:=win.userport::mp.sigbit
sig:=Shl(1, sig)
mg.setattrs([MGUI_ADDEXTERNAL, [{click}, sig, [win, win.userport, mg, sig, {win}]],
0,0])
WHILE (mg.empty() = FALSE)
mg.message()
-> WriteF('Win:\d\n', win)
ENDWHILE
EXCEPT DO
IF win THEN CloseWindow(win)
report_exception()
WriteF('Exiting...\n')
END mg
CleanUp(0)
ENDPROC
#ifdef DO_FABIO_PLUGIN
PROC kill_pi(tx:PTR TO centertxt)
WriteF('Killing Plug in:\h\n', tx)
END tx
ENDPROC
#endif
PROC hideall(gui:PTR TO gui_obj)
gui.mg.setattrs([MGUI_HIDEALL, TRUE, NIL, NIL])
gui.mg.first()
gui.mg.hide(FALSE)
ENDPROC
PROC showall(gui:PTR TO gui_obj) IS gui.mg.setattrs([MGUI_HIDEALL, FALSE, NIL, NIL])
PROC newgui(gui:PTR TO gui_obj) IS test(gui.mg)
PROC kill_all(gui:PTR TO gui_obj) IS gui.mg.clearguis()
PROC msg() IS WriteF('Message!\n')
#ifdef DO_FABIO_PLUGIN
PROC test(mg:PTR TO mgui)
DEF txt=NIL:PTR TO centertxt
DEF gui:PTR TO LONG
gui:=NEW [ROWS,
NEW [PLUGIN, 0, NEW txt.centertxt('This is a PlugIN!', 2,1, TRUE,1)],
NEW [SBUTTON, {msg}, 'Msg'],
NEW [SBUTTON, 1, 'End']
]
WriteF('PlugIn:\h\n', txt)
mg.addA('Fabio PlugIn', gui, NEW [MGUI_FREEPROC, NEW [{kill_pi}, txt, NIL, NIL],
NIL, NIL])
ENDPROC
#endif
PROC click(t:PTR TO LONG)
DEF x:PTR TO LONG
x:=GetMsg(t[1])
ReplyMsg(x)
WriteF('Win Clicked: \d Times!\n', times++)
ENDPROC
/*
PROC main() HANDLE
DEF mg=NIL:PTR TO mgui
DEF gui:PTR TO gui_obj
NEW mg.mgui()
gui:=mg.addA('Main', [BUTTON, {kill_son}, 'Kill'], [MGUI_MAIN, TRUE, NIL, NIL]) ->, [EG_INFO, mg, NIL, NIL])
mg.addA('Son', [BUTTON, 1, 'Close Me!'], [MGUI_NAME, "son", NIL, NIL])
WHILE mg.empty() = FALSE
mg.message()
ENDWHILE
WriteF('No more GUIs\n')
EXCEPT DO
END mg
report_exception()
ENDPROC
PROC kill_son(gui:PTR TO gui_obj)
IF gui.mg.pos("son") THEN gui.mg.del()
ENDPROC
*/
#endif