home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / screen / sdark15c.lha / docs / programmers.doc next >
Text File  |  1993-04-11  |  16KB  |  429 lines

  1. @AUTHOR   "Thomas Landspurg"
  2.  
  3. ## $VER: SuperDark.guide v1.1 (12.2.93)
  4.  
  5. ----------------------------------------------------------------------------------
  6. Main "SuperDark prog"
  7. ----------------------------------------------------------------------------------
  8.  
  9.     Writing your own modules for superdark:
  10.  
  11.     'Overview'
  12.     'Info'
  13.     'Dark function'
  14.     'MyGadg'
  15.     'Debug'
  16.     'The info text'
  17.     'Problems'
  18.  
  19. ----------------------------------------------------------------------------------
  20. Overview "Overview"
  21. ----------------------------------------------------------------------------------
  22. @Toc    "Main"
  23. I Overview:
  24.  
  25.     How to add modules to SuperDark.
  26.  
  27. - It is not very difficult to add your own module to Superdark, but
  28. you have to read carefuly this doc, because there is some important 
  29. things to understand!
  30.  
  31. You have to do   four things to add a new module in SuperDark:
  32.  
  33. * Create your own 'dark()' procedure, that's the procedure called at
  34.   screen blanking. That's the biggest part of the job.
  35. * Add the 'proc_init()','proc_save()','proc_end()' function. Usually, these
  36.   function are empty. But for special purpose, you could fill them, look
  37.   at the doc.
  38. * Add a 'my_gadg[]' array. This array is used to create the param window,
  39.   but also to read and save parameters. Very powerful, and easy to use
  40.   after you've read the doc!
  41. * Create an 'info' text. This should be easy,no?
  42.  
  43. Notes:
  44.     * YOU MUST link your module with the proc_main.o object. Proc_main
  45. will make some important initialisation, contain important function for
  46. you!
  47.     * I use some special keyword of the Lattice compile, like __saveds.
  48. If you don't have them, check your compiler's documentation.But if you
  49. don't use callback procedure with button, you don't need this.
  50.  
  51. The simplest way to add a new module is to take a look at the module named
  52. "rien.dark.c", this module does aboslutly nothing, but you can use it
  53. at a skeletton program.
  54.  
  55. ----------------------------------------------------------------------------------
  56. Info "Info"
  57. ----------------------------------------------------------------------------------
  58.  
  59. II What is a module for SuperDark ?
  60.  
  61. - It's an executable program, loaded by SuperDark.
  62. - You have link it with proc_main.o.
  63. - Proc_main.o will make initialisation and wait for a signal from
  64.   superdark, and then will call your 'dark' function.
  65.  
  66. But:
  67.  
  68. - You can't do ANY printf
  69. - You can't run it alone
  70. Except:
  71.    If you link it with 'proc_main_debug.o' instead of proc_main.o
  72.  
  73. ----------------------------------------------------------------------------------
  74. dark "Dark function"
  75. ----------------------------------------------------------------------------------
  76. III
  77.     The dark() function:
  78.  
  79. This function is called by proc_main when the screen should be blanked.
  80. You can ask for a copy of the frontmost screen. To do this, look at the
  81. 'proc_init()' function.
  82. So you can put what you want here, but remeber these limitations:
  83.  
  84. - Don't use any printf in your program
  85. - Don't make any global auto-initalised variable. This may be cause some
  86.   problems if you don't see exactly what happens. Because when your dark()
  87.   function is called two time, the global are not reset to her initial value.
  88.   So if you use global var and change their value, be careful.
  89. - Try to don't use the whole CPU time. Use WaitTOF(), Delay(), Wait()... But
  90.   you are a good programmer, so you know what to do!
  91.  
  92.  To test if your function have to exit, you have the tst_end() function.
  93. This function will return TRUE if you have to exit, or FALSE if you have to
  94. continue. 
  95.     Example:
  96.         while(tst_end()==FALSE){
  97.             do what you want...
  98.         }
  99.   The other function is wait_end(). This function will only return at the end of the
  100. blanking time.
  101.  
  102. ----------------------------------------------------------------------------------
  103. proc_init() "proc_init()"
  104. ----------------------------------------------------------------------------------
  105. IV proc_init(),proc_save() and proc_end()
  106.  
  107. proc_init() is called after your module have been loaded. You can do
  108. special initialisation here, but don't use too much memory.
  109. That's here that you told if you want a copy of the current frontmost screen
  110. be opened for you. To do this, you have to do this:
  111.  
  112.     p_data_proc->type_screen=SCR_GIVEN;
  113.  
  114. You can also tell to superdark that your module should only run with
  115. superdark for WB2.0 or higher.
  116.  
  117.     p_data_proc->code_ret=DARK_WB_20;
  118.  
  119. proc_save() is no more used, but is still here for compatibility...
  120.  
  121. proc_end() is called when the module have to be removed from memory. You can
  122. free what you've allocated in proc_init().
  123.  
  124. ----------------------------------------------------------------------------------
  125. MyGadg "MyGadg"
  126. ----------------------------------------------------------------------------------
  127.  
  128. V The my_gadg array....
  129.  
  130. This one of the most powerful of superdark. Each module can have a parameter
  131. window. To do this, you have to define this window, but in a special manner.
  132. This array is an array of type tom_gadget. This is the definition of the
  133. type tom_gadget (from includes/tom_gadget.h) :
  134.  
  135. typedef    struct    tom_gadget{
  136.     char    *GadgetText;        /* Text of the gadget on screen. */                
  137.     type_gadget    type_gadg;    /* The type of the gadget, see later */
  138.     short    int    LeftEdge,TopEdge;/* position            */
  139.     short    int    Width,Height;    /* size                */
  140.     short    int    value;        /* value !            */
  141.     short    int    d1,d2,d3;    /* Used for special purpose.... */
  142.     char    *p_data;        /* Used for special purpose.... */
  143.     struct    Gadget    *p_gadg;    /* Internal use only        */
  144.  
  145. };
  146.  
  147. Note that the four standart gadget "ok","test","cancel","help" are
  148. automaticly added!
  149.  
  150. Let's see these field:
  151.  
  152. char    *GadgetText:
  153.     So it's the text of your gadget in the configuration window, but also
  154. of the corrseponding value in the TOOL TYPE list. Yes, because SuperDark
  155. se these informations to save the configuration as ToolTypes in the .info of
  156. the module.
  157.     You can use shorcut, by using '_'. Example, a gadget named TEST can
  158. have the shortcut T if his name is:
  159.     "_TEST"
  160.  
  161. type_gadget type_gadg:
  162.     Define the type of the gadget. These type are availaible:
  163. (note that they are also availble on WB1.3 for the most of them)
  164.  
  165.     The following type are available(and look at the 'exemple':
  166.  
  167.     'END_LISTE'
  168.     'BUTTON'
  169.     'SLIDER'
  170.     'CHECKBOX'
  171.     'MX'
  172.     'CYCLE'
  173.     'LISTVIEW'
  174.     'OWN_GADGET'
  175.     'STRING'
  176.     'INTEGER'
  177.     'SCREEN'
  178.     'FONT'
  179.     'DATA_STRING'
  180.     'IMAGE'
  181.  
  182. LeftEdge,TopEdge,Width,Height:
  183.     Position and size of the gadget...nothing else to say!
  184. ----------------------------------------------------------------------------------
  185. END_LISTE 
  186. ----------------------------------------------------------------------------------
  187.     END_LISTE:
  188.  
  189.         This is not really a type, but each tom_gadget array should
  190.         end with this value! Remember it!!!
  191. ----------------------------------------------------------------------------------
  192. BUTTON
  193. ----------------------------------------------------------------------------------
  194.     BUTTON:
  195.         A simple button. You can define a function called when the 
  196.         button is pressed, by giving a pointer to this function
  197.         in the p_data field.
  198. ----------------------------------------------------------------------------------
  199. SLIDER
  200. ----------------------------------------------------------------------------------
  201.     SLIDER:
  202.         A normal slider. The direction of the slizer (horiz/vertical)
  203.         is defined by the ratio Width/Height. If Width is > Height,
  204.         this will be an horizontal slider, otherwhise it's an vertical
  205.         one.
  206.  
  207.         * value must contain the initial value of the slider,
  208.  
  209.         * d1 and d2 must contain the range of the slider
  210.  
  211.         * if p_data is not nul, it must contain a pointer to the
  212.         variable wich will receive a copy of the current value
  213.         of the slider.
  214. ----------------------------------------------------------------------------------
  215. CHECKBOX
  216. ----------------------------------------------------------------------------------
  217.  
  218.     CHECKBOX:
  219.         Checkbock gadget.
  220.  
  221.         * value contain the initial value, and will be re-actualised,
  222. ----------------------------------------------------------------------------------
  223. MX
  224. ----------------------------------------------------------------------------------
  225.     MX:
  226.         Multiple choice gadget.
  227.  
  228.         * p_data must contain a pointer to an array of char
  229.             example: p_data={"Choice1","Choice2","Choice3",NULL}
  230.  
  231.         * value contain the initial value, and will be re-actualised,
  232.  
  233. ----------------------------------------------------------------------------------
  234. CYCLE
  235. ----------------------------------------------------------------------------------
  236.     CYCLE:
  237.         Cycle gadget.
  238.         Same kind of configuration than the MX gadget.
  239.  
  240. ----------------------------------------------------------------------------------
  241. LISTVIEW
  242. ----------------------------------------------------------------------------------
  243.     LISTVIEW:
  244.         Listview gadget.
  245.  
  246.         * p_data must containt a pointer to a List structure. the
  247.         name of each node of the list will be be show on screen.
  248.  
  249.         * value contain the position of the initial selected value,
  250.         and will be re-actulised.
  251. ----------------------------------------------------------------------------------
  252. OWN_GADGET
  253. ----------------------------------------------------------------------------------
  254.     OWN_GADGET:
  255.         Very special purpose gadget!!!!
  256.         No time to describe it now...sorry.
  257.  
  258.         I just can say that it's used to create other type of
  259.         gadget than the current available.
  260. ----------------------------------------------------------------------------------
  261. STRING
  262. ----------------------------------------------------------------------------------
  263.     STRING:
  264.         String gadget
  265.  
  266.         * p_data must contain a pointer to a buffer of char. This buffer
  267.         will containt the value of the string gadget.
  268.  
  269.         * d1 MUST CONTAINT the size of the buffer.
  270. ----------------------------------------------------------------------------------
  271. INTEGER
  272. ----------------------------------------------------------------------------------
  273.     INTEGER:
  274.         Integer gadgt.
  275.  
  276.         *value contain the initial value, and will be re-actualised,
  277.  
  278.         *d1 contain the max number of digits for the number.
  279. ----------------------------------------------------------------------------------
  280. SCREEN
  281. ----------------------------------------------------------------------------------
  282.     SCREEN:
  283.         High level gadget....
  284.         This gadget will only be active if reqtools.library v38 or
  285.         higher is present on your system.
  286.         It allow you to choose a screen resolution, size, and overscan
  287.         value, by using the screen requester from the reqtools lib.
  288.  
  289.         * value contain the initial Overscan mode of the screen,
  290.         and will be re-actualised. Look at intuition/screens.h
  291.         * d1 contain the initial Width of the screen, and will be
  292.         re-actualised
  293.         * d2 contain the initial Height of the screen, and will be
  294.         re-actualised
  295.         * d2 contain the initial Depth of the screen, and will be
  296.         re-actualised
  297.         * p_data contain the initial Mode ID of the screen, and will be
  298.         re-actualised
  299.         Note:
  300.         If d3 (depth) is null, this mean that none of the value is
  301.         significative.
  302.  
  303. ----------------------------------------------------------------------------------
  304. FONT
  305. ----------------------------------------------------------------------------------
  306.     FONT:
  307.         The second high level gadget....
  308.         This gadget will only be active if reqtools.library  is
  309.         present on your system.
  310.         It allow you to choose a font, include size and attributes.
  311.  
  312.         * p_data is a pointer to a TextAttr structure.
  313.           IMPORTANT NOTE: This text attr must have the field ta_Name
  314.           initialized with a pointer to a string buffer, with enough
  315.           space to put the biggest name of the available font
  316.  
  317.  
  318. ----------------------------------------------------------------------------------
  319. DATA_STRING 
  320. ----------------------------------------------------------------------------------
  321.     DATA_STRING:
  322.         This data type is only used for configuration. I mean than
  323.         you won't see anything on configuration window, but a string
  324.         will be saved and loaded in the configuration file.
  325. ----------------------------------------------------------------------------------
  326. IMAGE
  327. ----------------------------------------------------------------------------------
  328.     IMAGE
  329.         With this data, you can include an image in your parameter
  330.         window. Just put a pointer to an image structure in the 
  331.         p_data field
  332. ----------------------------------------------------------------------------------
  333. EXEMPLE
  334. ----------------------------------------------------------------------------------
  335.  
  336.     Example: we want to make a parameter window, with three things:
  337.     - a checbox,
  338.     - a slider , wich can have value from -10 to 50
  339.     - a "screen" button.
  340.  
  341. struct    tom_gadget    my_gadg[]={
  342.     {"_Check it"    ,CHECKBOX  , 100, 10, 10,10,0,0,0,0,0},
  343.     {"_slide it"    ,SLIDER  ,   100, 25, 10,10,10,-10,50,0,0},
  344.     {"s_creen"      ,SCREEN  ,   200, 10, 50,10,0,0,0,0,0}};
  345.  
  346.     The parameter window will look like this:
  347.  
  348.     -------------------------------------------------
  349.     |                        |
  350.     |           _     ________        |
  351.     |   Check it  | |        |screen|        |
  352.     |           -         --------        |
  353.     |          ___________________        |
  354.     |   slide it  |          #      |        |
  355.     |             -------------------        |
  356.     |                        |
  357.     |        Ok      Test      Cancel      Info    |
  358.     |                        |
  359.     -------------------------------------------------
  360.  
  361. and when you press OK, you'll see in the tooltype of your module:
  362.  
  363.     CHECK IT=FALSE
  364.     SLIDE IT=20
  365.     SCREEN  =320 x 256 x 3 ID=21000 OVSCN=0
  366. Nice no?
  367.  
  368.  
  369. ----------------------------------------------------------------------------------
  370. Info_text "Info_text"
  371. ----------------------------------------------------------------------------------
  372.     The information text:
  373.  
  374.     It's the text show when you press the "Info" button. It's just an
  375. ascii string, named p_text_info. Example:
  376.  
  377. char *p_text_info=
  378. "   Hi evrybody\n"
  379. "now I can do my\n"
  380. "own module for\n"
  381. "    SUPERDARK!\n";
  382.  
  383.     Note the \n at the end of each line
  384. ----------------------------------------------------------------------------------
  385. DEBUG
  386. ----------------------------------------------------------------------------------
  387.     Now, a little help to debug your module....
  388.  
  389. - First, try to make your 'effect' alone, without using superdark. Then,
  390.   put it as a blanker.
  391. - Use proc_main_debug instead of proc_main.
  392.   With proc_main_debug, you can run your module exactly like running with
  393.   superdark. But now you can put printf, you can use a source level debugger,
  394.   etc....very useful! The only problem is that you can't have the saved
  395.   configuration for this module! And one more thing: don't try to run
  396.   this module FROM superdark!!! If you do this....CRASH (you must now what
  397.   you want!) You have to link it with proc_main to do so.
  398. - To stop a module linked with proc_main_debug, just click the close button of
  399.   the window opened in the Workbench screen.
  400. ----------------------------------------------------------------------------------
  401. Problems "Problems"
  402. ----------------------------------------------------------------------------------
  403.  
  404. VI If it doesn't work....
  405.  
  406. Hum....take a look at the other sourcecodes in the disk 
  407.  
  408. If this still doesn't work, you can send me you module and I'll try to
  409. make it work....
  410.  
  411. my  adress
  412.  
  413.     Thomas LANDSPURG
  414.     9, Place Alexandre 1er
  415.     78000 VERSAILLES
  416.     FRANCE
  417.  
  418.     FidoNet: 2:320/104.18
  419.     AMyNet:    39:180/1.18
  420.     UseNet:    Thomas_Landpsurg@ramses.gna.org
  421.  
  422.  SuperDark may not be included with any commercial product nor may it be
  423.  sold for profit either separately or as part of a compilation without
  424.  my permission. It may be included in non-profit disk collections such as the
  425.  Fred Fish collection. It may be archived & uploaded to electronic bulletin
  426.  board systems as long as all files remain together & unaltered.
  427.  
  428.  
  429.