home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / appendices / examples.doc < prev    next >
Text File  |  1991-01-27  |  20KB  |  593 lines

  1. A.1  SCREENS
  2.  
  3. Example1
  4.   This program will open a low-resolution, non-Interlaced,
  5.   eight colour Custom Screen. It will display it for 30
  6.   seconds, and then close it.
  7.  
  8. Example2
  9.   Same as Example1 except that the screen will be a high-
  10.   resolution, Interlaced, 4 colour Custom Screen.
  11.  
  12. Example3
  13.   Same as Example1 except that we will use the TOPAZ_SIXTY
  14.   Italic style as default font. (See chapter 3 GRAPHICS for
  15.   more information about text styles.)
  16.  
  17. Example4
  18.   This program will open two screens, one (low-resolution 32
  19.   colours) at the top of the display, and one (high-resolution
  20.   16 colours) a bit down.
  21.  
  22. Example5
  23.   Same as Example4 except that after 10 seconds the low-
  24.   resolution screen will move down 75 lines. After another 10
  25.   seconds it will be put in front of all other screens. 10
  26.   seconds later it will move down another 75 lines. The program
  27.   will wait 10 seconds before the screens are closed and the
  28.   program exits.
  29.  
  30. Example6
  31.   This program will open a low-resolution, non-Interlaced, 4
  32.   colour Custom Screen. It will after 5 seconds start to change
  33.   the screens colours, and will after a while close the screen
  34.   and exit.
  35.  
  36.  
  37.  
  38. A.2  WINDOWS
  39.  
  40. Example1
  41.   This program will open a normal window which is connected to
  42.   the Workbench Screen. It will display it for 30 seconds, and
  43.   then close it.
  44.  
  45. Example2
  46.   This program will open a high resolution 16 colour Custom
  47.   Screen and a normal window which is connected to it. It will
  48.   display it for 30 seconds, and then close the Custom Screen
  49.   and the window.
  50.  
  51. Example3
  52.   This program will open a normal window which is connected to
  53.   the Workbench Screen. The window will use all System Gadgets,
  54.   and will automatically Activate the window. It will display
  55.   it for 30 seconds, and then close it. (Remember that the
  56.   Close Gadget does NOT close the window by itself, it will
  57.   only inform you that the user wants to close it. But in
  58.   this example we will not listen to what the user wants.)
  59.  
  60. Example4
  61.   This program will open two normal windows which are connected
  62.   to the Workbench Screen. The windows will use all System
  63.   Gadgets. It will display them for 30 seconds, and then close
  64.   them.
  65.  
  66. Example5
  67.   This program will open a Borderless window which is connected
  68.   to the Workbench Screen. It will display it for 30 seconds,
  69.   and then quit.
  70.  
  71. Example6
  72.   Same as Example5 except that the window will also use all
  73.   System Gadgets.
  74.  
  75. Example7
  76.   This program will open three windows, two are normal and the
  77.   third is a Backdrop window. The windows will use all System
  78.   Gadgets, except the Backdrop window, which only can use the
  79.   close-window gadget. After 30 seconds the program quits. (Try
  80.   to push either window 1 or 2 behind the Backdrop window.)
  81.  
  82. Example8
  83.   This program will open a SuperBitMap window which is
  84.   connected to the Workbench Screen. Since it is a SuperBitMap
  85.   we also make the window into a Gimmezerozero window. The
  86.   window will use all System Gadgets, and some boxes will be
  87.   drawn. It will display the window for 30 seconds, and then
  88.   close it. (Shrink the window, and then enlarge it again, and
  89.   you will noticed that the lines are still there!)
  90.  
  91. Example9
  92.   This program will open a normal window with all system
  93.   gadgets connected to it. If you activate the window, the
  94.   pointer will change shapes into a "nice" arrow.
  95.  
  96. Example10
  97.   This program will open a two normal windows with all system
  98.   gadgets connected to them. If the first window is Activated,
  99.   the pointer will change shapes into a Zzz symbol, if the
  100.   second window is activated, the pointer will look like a
  101.   pistol.
  102.  
  103.  
  104.  
  105. A.3  GRAPHICS
  106.  
  107. Example1
  108.   This program will open a normal window which is connected to
  109.   the Workbench Screen. We will then draw a strange line with
  110.   help of Intuition's Border structure.
  111.  
  112. Example2
  113.   This program will open a normal window which is connected to
  114.   the Workbench Screen. We will then draw two rectangles with
  115.   different colours. This shows how you can link Border
  116.   structures to each other in order to get the desired effects.
  117.  
  118. Example3
  119.   This program will open a normal window which is connected to
  120.   the Workbench Screen. We will then print a text string with
  121.   help of Intuition's IntuiText structure.
  122.  
  123. Example4
  124.   Same as Example3 except that the text will be printed with
  125.   underlined italic characters.
  126.  
  127. Example5
  128.   This program will open a normal window which is connected to
  129.   the Workbench Screen. We will then draw the little nice arrow
  130.   we talked so much about.
  131.  
  132. Example6
  133.   Same as Example5 except that we will draw it several times in
  134.   different colours. This shows how PlanePick/PlaneOnOff works.
  135.  
  136. Example7
  137.   This program will open a normal window which is connected to
  138.   the Workbench Screen. We will then draw the nice 4 colour
  139.   face that was described in chapter 3.5 IMAGES.
  140.  
  141. Example8
  142.   This program will open a normal window which is connected to
  143.   a 16-colour Custom screen. In the window we will draw the
  144.   famous AMIGA-logo.
  145.  
  146.  
  147.  
  148. A.4  GADGETS
  149.  
  150. Example1
  151.   This program will open a normal window which is connected to
  152.   the Workbench Screen. The window will use all System
  153.   Gadgets, and will close first when the user has selected the
  154.   System gadget Close window. (Same as Example3 in chapter 2
  155.   WINDOWS, except that we have added an IDCMP check on the
  156.   Close window gadget.)
  157.  
  158. Example2
  159.   Same as Example1 except that we have added a Boolean gadget
  160.   with the text "PRESS ME".
  161.  
  162. Example3
  163.   Same as Example2 except that the on/off state of the gadget
  164.   is toggled each time the user hits the gadget.
  165.  
  166. Example4
  167.   This program will open a normal window which is connected to
  168.   the Workbench Screen. The window will use all System
  169.   Gadgets, and will close first when the user has selected
  170.   the System gadget Close window. Inside the window we have put
  171.   two Boolean gadgets with the text "GADGET 1" and "GADGET 2".
  172.  
  173. Example5
  174.   This program will open a normal window which is connected to
  175.   the Workbench Screen. The window will use all System Gadgets,
  176.   and will close first when the user has selected the System
  177.   gadget Close window. Inside the window we have put a Boolean
  178.   gadget with two Image structures connected to it. Each time
  179.   the user clicks on the gadget it will change images, lamp
  180.   on/lamp off.
  181.  
  182. Example6
  183.   This program will open a normal window which is connected
  184.   to the Workbench Screen. The window will use all System
  185.   Gadgets, and will close first when the user has selected the
  186.   System gadget Close window. Inside the window we have put a
  187.   Boolean gadget with a connecting mask. The gadget will only
  188.   be highlighted when the user selects this gadget while
  189.   pointing inside the specified (masked) area.
  190.  
  191. Example7
  192.   This program will open a normal window which is connected to
  193.   the Workbench Screen. The window will use all System
  194.   Gadgets, and will close first when the user has selected the
  195.   System gadget Close window. Inside the window we have put a
  196.   String gadget.
  197.  
  198. Example8
  199.   Same as Example7 except that it is an Integer gadget.
  200.  
  201. Example9
  202.   Same as Example7 except that it is a Proportional gadget.
  203.  
  204. Example10
  205.   Same as Example9 except that the Proportional gadget uses a
  206.   custom image knob.
  207.  
  208. Example11
  209.   This program will open a normal window which is connected to
  210.   the Workbench Screen. The window will use all System
  211.   Gadgets, and will close first when the user has selected the
  212.   System gadget Close window. Inside the window we have put a
  213.   Proportional gadget where the knob can be moved both
  214.   horizontally and vertically.
  215.  
  216. Example12
  217.   This program will open a SuperBitmap window which is
  218.   connected to the Workbench Screen. The window will use all
  219.   System Gadgets, and will close first when the user has
  220.   selected the System gadget Close window. Inside the window we
  221.   have put two Proportional gadgets, one on the right side, and
  222.   one at the bottom. With help of these two gadgets, the user
  223.   can move around the BitMap.
  224.  
  225.   This example is for experienced programmers only, since it
  226.   uses some functions etc which we have not discussed yet. I
  227.   have, however, included it here since it is a good example on
  228.   how you can combine Proportional gadgets with SuperBitmap
  229.   windows.
  230.  
  231.  
  232.  
  233. A.5  REQUESTERS
  234.  
  235. Example1
  236.   This example opens a Simple requester by calling the function
  237.   AutoRequest. It displays a message "This is a very simple
  238.   requester!", and has only one gadget connected to it (on the
  239.   right side of the requester) with the text "OK".
  240.  
  241. Example2
  242.   Same as Example1, except that the requester displays a
  243.   message "Do you really want to quit?", and allows the user to
  244.   choose between "Yes" and "No". The program  will continue to
  245.   reopen the requester until the user has chosen "Yes".
  246.  
  247. Example3
  248.   Same as Example1, except that this requester displays a
  249.   message "Insert a disk in any drive!", and allows the user to
  250.   choose between "Yes" and "No". The program will continue to
  251.   reopen the requester until the user has chosen "Yes" or
  252.   inserted a disk.
  253.  
  254. Example4
  255.   This program will open a normal window which is connected to
  256.   the Workbench Screen. The window will use all System Gadgets,
  257.   and will close first when the user has selected the System
  258.   gadget Close window. Inside the window we have activated an
  259.   Application requester with a connecting gadget. The requester
  260.   will first be satisfied when the user has selected the
  261.   gadget, and will then be deactivated. The window can now be
  262.   closed.
  263.  
  264. Example5
  265.   Same as Example4, except that the requester is first
  266.   activated when the user double-clicks on the right mouse
  267.   button. This example shows how to create a Double-menu
  268.   requester, and how to monitor the IDCMP flags REQSET and
  269.   REQCLEAR.
  270.  
  271. Example6
  272.   Same as Example5, except that whenever the user double-
  273.   clicks on the right mouse button, we will receive a REQVERIFY
  274.   message, and first when we have replied, will the requester
  275.   be activated. This example shows how to use the REQVERIFY
  276.   flag.
  277.  
  278. Example7
  279.   This program will open a normal window which is connected to
  280.   the Workbench Screen. The window will use all System Gadgets,
  281.   and will close first when the user has selected the System
  282.   gadget Close window. Inside the window we have activated an
  283.   Application requester with three connecting gadgets. Two are
  284.   Boolean gadgets ("OK and "CANCEL"), and one is a String
  285.   gadget.
  286.  
  287. Example8
  288.   Same as Example7, except that it is an Integer gadget.
  289.  
  290. Example9
  291.   Same as Example8, except that it is a Proportional gadget.
  292.  
  293.  
  294.  
  295. A.6  ALERTS
  296.  
  297. Example1
  298.   This example displays an Alert message at the top of the
  299.   display.
  300.  
  301.  
  302.  
  303. A.7  MENUS
  304.  
  305. Example1
  306.   This program opens a normal window to which we connect a menu
  307.   strip. The menu consists of four items: Plain, Bold,
  308.   Underlined and Italic. The user can select either Plain or a
  309.   combination of the other styles. (If the user selects Plain
  310.   all other modes will be mutual excluded, but if the user on
  311.   the other hand selects Bold, Underlined or Italic, only the
  312.   Plain option will be mutual excluded.
  313.   
  314.   This example also shows how a program should handle the IDCMP
  315.   flags, and how to collect several messages from one single
  316.   menu event.
  317.  
  318. Example2
  319.   This example is very similar to Example1, but we have this
  320.   time put the edit styles in a subitem box which is connected
  321.   to the one and only item box called "Style".
  322.  
  323. Example3
  324.   This example is very similar to Example2, but the user can
  325.   this time also access the subitems from the keyboard. For
  326.   example, to select Bold the user only needs to press the
  327.   right Amiga key [A] together with the "B" key.
  328.  
  329. Example4
  330.   This program opens a normal window to which we connect a menu
  331.   strip. The menu consists of two items: Readmode and Editmode.
  332.   The readmode item is selected and ghosted, and when the user
  333.   selects the editmode item, it will become disabled (ghosted)
  334.   while the readmode item will be enabled (not ghosted). This
  335.   means that if the program is in "readmode", the user should
  336.   only be able to chose the "editmode", and v.v. The purpose
  337.   with this program is to show how you can use the OnMenu and
  338.   OffMenu functions in order to make an "user-friendly
  339.   interface".
  340.  
  341. Example5
  342.   Exactly as Example1 except that we have changed Intuition's
  343.   checkmark to our own customized "arrow".
  344.  
  345. Example6
  346.   This program opens a normal window to which we connect a menu
  347.   strip. The menu consists of six small dices which are all
  348.   action items. This example shows how you can use Images
  349.   inside a menu.
  350.  
  351. Example7
  352.   This program opens a normal window to which we connect a menu
  353.   strip. The menu consists of one small action item with two
  354.   images.
  355.  
  356. Example8
  357.   Same as Example1 except that we this time will verify any
  358.   menu operations. If the user tries to activate this program's
  359.   menu we check if the position of the pointer is somewhere at
  360.   the top of the window (less than 10 lines down). In that case
  361.   the menu operation will continue as normal, otherwise we
  362.   cancel the menu operation.
  363.  
  364.  
  365.  
  366. A.8  IDCMP
  367.  
  368. Example1
  369.   This program explains how to use the IDCMP flag MOUSEBUTTONS.
  370.  
  371. Example2
  372.   This program explains how to use the IDCMP flag MOUSEMOVE.
  373.  
  374. Example3
  375.   This program explains how to use the IDCMP flags: NEWSIZE,
  376.   ACTIVEWINDOW and INACTIVEWINDOW.
  377.  
  378. Example4
  379.   This program explains how to use the IDCMP flag SIZEVERIFY.
  380.  
  381. Example5
  382.   This program explains how to use the IDCMP flag RAWKEY.
  383.  
  384. Example6
  385.   This program explains how to use the IDCMP flag VANILLAKEY.
  386.  
  387. Example7
  388.   This program explains how to use the IDCMP flags:
  389.   DISKINSERTED and DISKREMOVED.
  390.  
  391. Example8
  392.   This program explains how to use the IDCMP flag INTUITICKS.
  393.  
  394. Example9
  395.   This program explains how to use the IDCMP flag
  396.   REFRESHWINDOW, and how to optimize the redrawing of the
  397.   window.
  398.  
  399.  
  400.  
  401. A.9  MISCELLANEOUS
  402.  
  403. Example1
  404.   This example shows how to allocate, and deallocate memory.
  405.  
  406. Example2
  407.   This example shows how to allocate and deallocate memory with
  408.   help of the functions AllocRemember(), and FreeRemember().
  409.  
  410. Example3
  411.   This example shows how to get a copy of the preferences.
  412.  
  413. Example4
  414.   This example shows how to handle double mouse button events.
  415.  
  416. Example5
  417.   This example prints out the current time.
  418.  
  419.  
  420.  
  421. A.10  SPRITES
  422.  
  423. Example1
  424.   This program shows how to declare and initialize some sprite
  425.   data and a SimpleSprite structure. It also shows how to
  426.   reserve a sprite (sprite 2), and how to move it around. The
  427.   user moves the sprite by pressing the arrow keys.
  428.  
  429. Example2
  430.   This program shows how to declare and initialize some sprite
  431.   data and a SimpleSprite structure. It also shows how to
  432.   reserve a sprite (sprite 2), and how to move it around. The
  433.   user moves the sprite by pressing the arrow keys. In this
  434.   example we animate the sprite (6 frames, taken from
  435.   the arcade game Miniblast).
  436.  
  437. Example3
  438.   This program shows how to set up a 15 coloured sprite, and
  439.   how to move it around.
  440.  
  441.  
  442.  
  443. A.11  AMIGADOS
  444.  
  445. Example1
  446.   This program collects ten integer values from the user, and
  447.   saves them in a file ("HighScore.dat") on the RAM disk. The
  448.   memory is then cleared, and the file cursor is moved to the
  449.   beginning of the file. The file is then loaded into the
  450.   memory again, and printed out.
  451.  
  452. Example2
  453.   This example demonstrates how to create a directory called
  454.   "MyDirectory" on the RAM disk.
  455.  
  456. Example3
  457.   This example demonstrates how to rename files and directories.
  458.   It will rename the file Example 1 created (called
  459.   "HighScore.dat") to "Numbers.dat". It will also rename the
  460.   directory Example 2 created ("MyDirectory") to "NewDirectory".
  461.  
  462. Example4
  463.   This example demonstrates how to delete files and directories.
  464.   It will delete the file Example 1 and directory Example 2
  465.   created. (The file and directory are supposed to have been
  466.   renamed by Example 3.)
  467.  
  468. Example5
  469.   This example demonstrates how to attach a short comment to a
  470.   file. A short file called "Letter.doc" will be created, and a
  471.   short comment will be attached. To see the comment use the
  472.   CLI command "List".
  473.  
  474. Example6
  475.   This example demonstrates how to protect and unprotect files.
  476.   The file Example 5 created ("Letter.doc") will be protected,
  477.   and we will then try to delete it (unsuccessfully). We will
  478.   then unprotect the file and then try to delete it
  479.   (successfully).
  480.  
  481. Example7
  482.   This program takes a file/directory/device name as
  483.   parameter, and prints out some interesting information about
  484.   it.
  485.  
  486. Example8
  487.   This program takes a directory/device name as parameter,
  488.   and prints out all the file/directory-names inside it. This
  489.   example describes how to use Examine() and ExNext().
  490.  
  491.  
  492.  
  493. A.12  LOW LEVEL GRAPHICS ROUTINES
  494.  
  495. Example1
  496.   This example shows how to create your own display, and fill
  497.   it with a lot of pixels in seven different colours.
  498.  
  499. Example2
  500.   This example shows how to create a large Raster and a smaller
  501.   display. We fill the Raster with a lot of pixels in seven
  502.   different colours and by altering the RxOffset and RyOffset
  503.   values in the RasInfo structure, the Raster is scrolled in
  504.   all directions. This method to scroll a large drawing in full
  505.   speed is used in many games and was even used in my own
  506.   racing game "Car".
  507.  
  508. Example3
  509.   This example shows how to create a display that covers the
  510.   entire display. This method is called "Overscan", and is
  511.   primarily used in video and graphics programs, but can also
  512.   be used in games etc to make the display more interesting.
  513.  
  514. Example4
  515.   This example demonstrates how to open two different ViewPorts
  516.   on the same display. The first ViewPort is in low resolution
  517.   and use 32 colours, while the second ViewPort is in high
  518.   resolution and only use 2 colours.
  519.  
  520. Example5
  521.   This example demonstrates how to open a ViewPort in interlace
  522.   mode.
  523.  
  524. Example6
  525.   This example demonstrates how to create a ViewPort in dual
  526.   playfield mode. Playfield 1 use four colours and is placed
  527.   behind playfield 2 which only use two colours (transparent
  528.   and grey). Playfield 1 is filled with a lot of dots and is
  529.   scrolled around while playfield 2 is is not moved and is
  530.   filled with only five grey rectangles.
  531.  
  532. Example7
  533.   This example demonstrates how to create a ViewPort with the
  534.   special display mode "Hold and Modify".
  535.  
  536. Example8
  537.   This example shows how to use the functions: SetAPen(),
  538.   SetBPen(), SetOPen(), SetDrMd(), SetDrPt(), WritePixel(),
  539.   ReadPixel(), Move(), Draw(), Text() and finally PolyDraw().
  540.  
  541. Example9
  542.   This example shows how to flood fill a figure, and how to
  543.   draw filled rectangles (both solid as well as filled with
  544.   single and multi coloured patterns).
  545.  
  546. Example10
  547.   This example demonstrate how to use the Area Fill functions.
  548.   [ AreaMove(), AreaDraw() and AreaEnd(). ]
  549.  
  550. Example11
  551.   This example demonstrate how to copy rectangular memory areas
  552.   with help of the blitter. 
  553.  
  554.  
  555.  
  556. A.13  VSPRITES
  557.  
  558. Example1
  559.   This example demonstrates how to get and use a VSprite.
  560.   The VSprite can be moved around by the user by pressing
  561.   the arrow keys.
  562.  
  563. Example2
  564.   This example demonstrates how to use several VSprites each
  565.   with its own colour table.
  566.  
  567. Example3
  568.   This program demonstrates how to animate several (!) VSprites.
  569.  
  570.  
  571.  
  572. A.14  HINTS AND TIPS
  573.  
  574. Example1
  575.   This example tell you if you have an American (NTSC) or
  576.   European (PAL) system.
  577.  
  578. Example2
  579.   This program will print "Hello!" in the CLI window if
  580.   started from CLI, or the text will be printed in a special
  581.   window that is automatically opened if run from workbench.
  582.  
  583. Example3
  584.   This program will not open any console window if run from
  585.   workbench. The disadvantage is of course that you can not
  586.   use any "console functions" such as printf().
  587.  
  588. Example4
  589.   This program tells you if it was run from workbench or
  590.   from a CLI window.
  591.  
  592.  
  593.