home *** CD-ROM | disk | FTP | other *** search
- TRITON.bb2
- A short documentation
- "The key to TRITON"
-
- by Philipp Lonke
-
-
- 1. Introduction
-
- First of all, forget everything about GUI programming in Blitz. It
- is not the same creating a GadTool-GUI or a TRITON GUI.
-
- Read this documentation carefully, so you really understand the
- difference.
-
- I wish to thank a lot Rupert "HelpApp" Henson, without his help
- this conversion could not been finished. He had the trick how to
- do the Project-TagList and helped me converting the macros.
-
- 2. Some useful definitions
-
- When speaking of TRITON, there are to major terms:
- an application: That is your program. The informations
- (application tags) are for use in the
- TRITON Preferences Editor (ShareWare)
-
- an project : In fact, that's your GUI. For every
- window you use, you create a new project.
-
- Second, every string passed to any TRITON function or macro or
- whatever, has to be null-terminated. So do never use something
- like "#TRCA_Name, name$" but always use
-
- #TRCA_Name, Null(name$)
-
- 3. How to start??
-
- First of all, you have to convert the file "triton/developer/fd/
- triton_lib.fd" with FDConvert. This program you should find in
- your Blitz2:BBTools-drawer or on any Blitz2-ftp-site.
- Put the converted library in "blitzlibs:amigalibs/..." and create
- a new DefLibs-file with MakeDefLibs.
-
- I use the program "tritontemplate.bb2" to explain how you get
- to a simple GUI. Further information an tricks you can take off
- all the other demo listings (for cycle gadgets, listviews etc.)
-
- -------------- beginning of documented sourcecode -----------------
-
- ;/*
- ; * Triton - The object oriented GUI creation system For the AMIGA
- ; * Written by Stefan Zeiger in 1993-1995
- ; * Transfer to BlitzBasic2 by Ph. Lonke and Rupert Henson
- ; *
-
- ; this include must precede everything. And remember also to include
- ; amigalibs.res somewhere!! (amiga-o)
- INCLUDE "blitz2:bbincludes/libraries/triton.bb2"
-
- ; if you plan to open more windows, you should create more tmp_tags
- ; i.e. tmp_tags1,tmp_tags2 etc.
- ; the newtype "taggies" is defined in "triton.bb2"
- DEFTYPE .taggies tmp_tags
-
-
- ; we have to name our application and project(s) for use in our code
- *application.TR_App=0
- *project.TR_Project=0
-
- Dim apptags.TagItem(7)
- Dim projtags.TagItem(1000)
-
- ;the following statement is used to create our taglist. remember that
- ;you need a new statement for every project (window!) you create!!!
- ;do never use the same variables in the projects. The simplest way is
- ;to numerate it (projindex1,projindex2 etc)
-
- Statement addtags{}
- ; projindex points to free space in projtags array
-
- SHARED projindex,projtags(),tmp_tags.taggies
-
- tmp.l=&tmp_tags\a1
-
- While ( Peek.l(tmp)<>#TAG_END )
- projtags(projindex)\ti_Tag=Peek.l(tmp)
- tmp=tmp+4
- projtags(projindex)\ti_Data=Peek.l(tmp)
- tmp=tmp+4
- projindex+1
-
- projtags(projindex)\ti_Tag=#TAG_END,0
-
- End While
-
- End Statement
-
- ; these Application tags are used only for information in the
- ; Prefs Editor. You should at least have a Name, LongName and Info
- ; string set.
- ; btw: always set tags BEFORE you create the application/project!
-
- apptags(1)\ti_Tag=#TRCA_Name,Null("TritonTemplate")
- apptags(2)\ti_Tag=#TRCA_LongName,Null("TritonTemplate")
- apptags(3)\ti_Tag=#TRCA_Info,Null("Looks like a template")
- apptags(4)\ti_Tag=#TRCA_Version,Null("1.0")
- apptags(5)\ti_Tag=#TRCA_Release,Null("1")
- apptags(6)\ti_Tag=#TRCA_Date,Null("Today")
- apptags(7)\ti_Tag=#TAG_END,0
-
- ; now, the tags are set and we create our application
- *application=TR_CreateApp_(&apptags(1))
-
- If (*application)
-
- ; Here are tags to build into projtags
- ; I dislike gosub'ing and goto'ing in programs, so put the tags
- ; where they belong. It's faster and better.
-
- projindex=1
-
- ; you'll find the flags explained in "triton.bb2".
- ; every tmp_tags line must be ended with #TAG_END
-
- tmp_tags\a1=!WindowID{0},!WindowPosition{#TRWP_BELOWTITLEBAR},#TAG_END
- addtags{}
- tmp_tags\a1=!WindowTitle{Null("Triton Test Interface")},#TAG_END
- addtags{}
- tmp_tags\a1=!WindowFlags{#TRWF_NOSIZEGADGET OR #TRWF_NODELZIP OR #TRWF_NOZIPGADGET OR #TRWF_NOESCCLOSE},#TAG_END
- addtags{}
- tmp_tags\a1=!WindowBackfillNone,#TAG_END
- addtags{}
-
- ; now the buttons: You must start every button group either with
- ; !VertGroup or with !HorizGroup, depending on how they should
- ; be aligned. After finishing a group, there must be an !EndGroup
- ;
- ; looks like: !VertGroup
- ; ; all your buttons
- ; !EndGroup
-
- tmp_tags\a1=!VertGroupA,#TAG_END
- addtags{}
- tmp_tags\a1=!Space,#TAG_END
- addtags{}
-
- tmp_tags\a1=!HorizGroupA,#TAG_END
- addtags{}
- tmp_tags\a1=!Space,#TAG_END
- addtags{}
-
- tmp_tags\a1=!Button{Null("_Save"),12},#TAG_END
- addtags{}
- tmp_tags\a1=!Button{Null("_Cancel"),15},#TAG_END
- addtags{}
- tmp_tags\a1=!Space,#TAG_END
- addtags{}
-
- tmp_tags\a1=!EndGroup,#TAG_END
- addtags{}
-
- tmp_tags\a1=!Space,#TAG_END
- addtags{}
-
- tmp_tags\a1=!EndGroup,#TAG_END
- addtags{}
-
- ; this here *must* follow at the end of a taglist!!
-
- tmp_tags\a1=#TAG_END
- addtags{}
-
- ; the project tags are set, now we can open our window
-
- *project=TR_OpenProject_(*application,&projtags(1))
-
- If (*project)
-
- ; we have to check if the user closed our window.
- user_closed=0
-
- While (user_closed=0)
-
- ; for communication we need to get TRITONs messages so we
- ; know, what the user's doing.
-
- TR_Wait_ *application,1 ; waiting for a message
- *trmsg.TR_Message=TR_GetMsg_(*application)
-
- While (*trmsg)
-
- If (*trmsg\trm_Project=*project)
-
- ; the kind of message we find in \trm_Class
- ; look in "triton.bb2" for all kind of TRITON-Messages.
- ; the name of these constants should be self-explaining ;)
-
- Select *trmsg\trm_Class
-
- Case #TRMS_CLOSEWINDOW
- user_closed=True
- End Select
- EndIf
-
- ; every message we get *MUST* be replied!
- TR_ReplyMsg_ *trmsg
-
- ; let's wait for and get the next message
- TR_Wait_ *application,1
- *trmsg=TR_GetMsg_(*application)
- End While
- End While
-
- ; if the user wanted it, we close our window
- TR_CloseProject_ *project
- Else
- NPrint "Unable to create the project"
- EndIf
-
- ; and we delete our application from memory.
- TR_DeleteApp_ *application
-
- Else
- NPrint "Unable to create application"
- EndIf
-
- End
-
- --------------------- end of documented sourcecode --------------------
-
- 4. Some final words on programming with TRITON and how to get help
-
- I think you got now the difference between a GadTools (or, worse,
- a Blitz) GUI and TRITON. But from now on you just don't need to
- care about fontsensitivity and calculating positions of gadgets.
-
- You should only take the above example as a model to program
- a TRITON GUI. I have to admit that I didn't change the other
- demo listings to this way, so just take them to see how to
- create other gadgets or layouts. Take care of these rules:
-
- a) Do never use goto and/or gosub in your program. This
- is a worse basic-like style which should be avoided.
- Blitz2 offers many possibilities for it: statements and
- function, or just put the code where it belongs instead
- of gosub'ing to it (see toolmanager listings how not to
- do it [sorry, Rupert :) ]
-
- b) Every macro that has the same name as a Blitz2-Keyword
- begins with an Underscore. So the original macro
- !StringGadget{...} is named !_StringGadget{...}. If a
- TRITON macro turns yellow in your TED, just put a "_"
- in front :)
-
- c) Before getting a message, use TR_Wait_ *app,otherbits
-
- d) Always check that your project/application was opened!
-
- e) Reply every Message you get from TRITON.
-
- f) To program, use the macros - they are the easiest way
- to create a TRITON GUI. To explain all macros would
- exceed this little docu, but just take a look at either
- the Blitz2-Includes oder the original C-Includes (in
- "triton/developer/includes/libraries"). The name of all
- constants and macros should be self-explaining. Try them
- out!
-
- g) A little hint: When you use a button which is triggered by
- <return> (!ButtonR{...}) and a StringGadget in your GUI,
- everytime you hit <return> in the StringGadget, the button
- will be triggered. To avoid that, use
- !_StringGadget{...},#TRAT_Flags,#TRST_NORETURNBROADCAST
-
- But always remember: Due to the TRITON Preferences Editor, the
- user can not only change the look of the gadgets but also place
- your window(s) on any screen he likes. So do never use fixed
- coords! In fact, you do not need to size your window - the user
- can change it and it will be safed in ENV: and ENVARC:, so with
- every startup of your program, the window opens in the same
- dimensions and coords where the user closed it last.
-
- If you have any suggestions, ideas or if you just need a little
- help, contact me
-
- via eMail: phips@scout.rhein-main.de
- [this adress is probably only valid until october]
-
- in the BlitzBasic Mailing list
- to subscribe write to:
-
- majordomo@helsinki.fi
- any subject, and put in the body of your msg
-
- subscribe blitz-list <your@e.mail.adress>
-
- via FTP : some TRITON-Blitz-Programs or updates you will
- find in the anonymous ftp server
-
- x2ftp.oulu.fi/pub/amiga/prog/blitz
-
- If you really don't reach me, just write to the programmer of
- TRITON, Stefan Zeiger (adress in the orig. docu!), he surely
- knows where I am and how you reach me - he's nearly a neighbor
- of mine :)
-
-
- 5. The end and the future
-
- So I wish you happy blitzing with TRITON and hope to see some
- of your programs which use TRITON. I'd really appreciate, if you
- send me just a few words when you finished a program.
-
- I included a little program called "memo" to this package - it can
- only be started via CLI and pops up a TRITON requester with your text
- in it. You need two arguments!
-
- memo "Hello World!" "Remember to write Philipp!!"
-
- This program could be used with CyberCron, DCron etc. for
- reminding.
-
- I plan to make a little programming guide for TRITON programming
- where you can "learn" how to change the window-/gadgetfont, and
- some other tricks.
-
- Eventually I'll program a little GUI-Creator like GadTools, but
- that's just an idea...
-
-
-
- ... and, again, thanks to Rupert Henson!!! ...
-
-
-
-
-