home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / desklib / examples / DeskLib / Examples / !Pane2test / c / PaneTests < prev   
Encoding:
Text File  |  1995-05-12  |  7.2 KB  |  217 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *        File: PaneTests.c                                             *
  4.  *                                                                      *
  5.  *     Purpose: Tests Pane2 library                                     *
  6.  *                                                                      *
  7.  ************************************************************************/
  8.  
  9. #include "DeskLib:WimpSWIs.h"          /* Low-level WIMP commands         */
  10. #include "DeskLib:Window.h"            /* Window handling automation      */
  11. #include "DeskLib:Core.h"              /* usefull core functions          */
  12. #include "DeskLib:Dialog.h"            /* High-level dialogue windows     */
  13. #include "DeskLib:Error.h"             /* Error despatcher                */
  14. #include "DeskLib:Event.h"             /* Event despatcher                */
  15. #include "DeskLib:EventMsg.h"          /* Wimp Message event dispatcher   */
  16. #include "DeskLib:File.h"              /* Low level file handling         */
  17. #include "DeskLib:GFX.h"               /* Graphics routines (GFX_Wait)    */
  18. #include "DeskLib:Handler.h"           /* Default/example event handlers  */
  19. #include "DeskLib:Hourglass.h"         /* Hourglass module interfaces     */
  20. #include "DeskLib:Icon.h"              /* Icon handling automation        */
  21. #include "DeskLib:Menu.h"              /* Menu create & show support      */
  22. #include "DeskLib:Msgs.h"              /* Message translation code        */
  23. #include "DeskLib:Resource.h"          /* Handles finding resource files  */
  24. #include "DeskLib:Screen.h"            /* Getting screen size info, etc   */
  25. #include "DeskLib:Sound.h"             /* Sound System control            */
  26. #include "DeskLib:Template.h"          /* Template loading and caching    */
  27. #include "DeskLib:Slider.h"            /* "Easy" slider handling          */
  28. #include "DeskLib:Kbd.h"               /* Read hotkeys                    */
  29. #include "DeskLib:Time.h"              /* "TIME"                          */
  30. #include "DeskLib:KernelSWIs.h"        /* OS_Byte                         */
  31.  
  32. #include "DeskLib:Pane2.h"
  33.  
  34. #include "kernel.h"
  35. #include "MySwis.h"
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <string.h>
  39.  
  40. /******************************************************************************/
  41.  
  42. static BOOL CloseEventHandler(event_pollblock *event, void *reference)
  43. {
  44.   
  45.   Pane2_Delete(event->data.words[0]);
  46.  
  47.   return(TRUE);
  48. }
  49.  
  50. /******************************************************************************/
  51.  
  52. static BOOL ClickEventHandler(event_pollblock *event, void *reference)
  53. {
  54.  
  55.   switch(event->data.mouse.icon)
  56.   {
  57.     case 1: case 2:
  58.       Pane2_Delete(event->data.mouse.window);
  59.       break;
  60.   }
  61.  
  62.   return(TRUE);
  63. }
  64.  
  65. /******************************************************************************/
  66.  
  67. static BOOL ClickMain1EventHandler(event_pollblock *event, void *reference)
  68. {
  69.   int flags;
  70.  
  71.   switch(event->data.mouse.icon)
  72.   {
  73.     case 1:
  74.       flags = Pane2_SetFlags(event->data.mouse.window, 1, -1); /* read flags */
  75.  
  76.       if(Icon_GetSelect(event->data.mouse.window, 1))/* turnonresize */
  77.          flags = flags | pane2_VRESIZE;
  78.  
  79.       else{ /* turn off resize */
  80.          flags = flags | pane2_VRESIZE;
  81.          flags = flags ^ pane2_VRESIZE;
  82.       }
  83.  
  84.       Pane2_SetFlags(event->data.mouse.window, 1, flags); /* set new flags */
  85.  
  86.       Pane2_Show(event->data.mouse.window, open_WHEREVER); /* refresh size etc... */
  87.       break;
  88.   }
  89.  
  90.   return(TRUE);
  91. }
  92.  
  93. /******************************************************************************/
  94.  
  95. static BOOL ClickPane4bEventHandler(event_pollblock *event, void *reference)
  96. {
  97.  
  98.   switch(event->data.mouse.icon)
  99.   {
  100.     case 2:
  101.       Pane2_DeletePane((window_handle) reference, 2);
  102.       break;
  103.   }
  104.  
  105.   return(TRUE);
  106. }
  107.  
  108. /******************************************************************************/
  109.  
  110. extern void PaneTests_Init(void)
  111. {
  112.  
  113.  
  114. }
  115.  
  116. /******************************************************************************/
  117.  
  118. extern void PaneTests_MenuSelection(int selection)
  119. {
  120.   window_handle main;
  121.   window_handle pane;
  122.   wimp_point zerooffset = {0, 0};
  123.   wimp_point paneoffset;
  124.   wimp_point panesize;
  125.  
  126.   switch(selection)
  127.   {
  128.      case 1:
  129.        /*
  130.         * Test 1
  131.         * Top left of pane is attached to top left of main window usings
  132.         * offsets in template file
  133.         */
  134.         main = Window_Create("Main1", template_TITLEMIN);
  135.  
  136.         Pane2_AddMain(main);
  137.  
  138.         pane = Window_Create("Pane1", template_TITLEMIN);
  139.  
  140.         Pane2_AddPane(main, pane, NULL, NULL,
  141.                       pane2_FIXED|pane2_MAINTOP|pane2_PANETOP);
  142.  
  143.         Event_Claim(event_CLICK, main, event_ANY, ClickMain1EventHandler, NULL); 
  144.  
  145.         Event_Claim(event_CLOSE, main, event_ANY, CloseEventHandler, NULL);
  146.  
  147.         Pane2_Show(main, open_WHEREVER);
  148.  
  149.         break;
  150.  
  151.      case 2:
  152.        /*
  153.         * Test 2
  154.         * Top left of first pane is attached to top left of main window using a supplied
  155.         * offset of 0,0 and the pane is resized when the main window is resized.
  156.         * Bottom left of second pane is attached to bottom left of main window using a
  157.         * supplied offset of 0,0 and the pane is resized and scrolled horizontally with
  158.         * the main window.
  159.         */
  160.         main = Pane2_CreateAndAddMain("Main2", template_TITLEMIN);
  161.  
  162.         Pane2_CreateAndAddPane("Pane2a", template_TITLEMIN, main, &zerooffset, NULL,
  163.                     pane2_FIXED|pane2_MAINTOP|pane2_PANETOP|pane2_HRESIZE|pane2_HSTRETCH);
  164.  
  165.         Pane2_CreateAndAddPane("Pane2b", template_TITLEMIN, main, &zerooffset, NULL,
  166.                                pane2_FIXED|pane2_HRESIZE|pane2_HSCROLL|pane2_HSTRETCH);
  167.  
  168.         Event_Claim(event_CLOSE, main, event_ANY, CloseEventHandler, NULL);
  169.  
  170.         Pane2_Show(main, open_WHEREVER);
  171.  
  172.         break;
  173.  
  174.      case 3:
  175.        /*
  176.         * Test 3
  177.         * Pane is sized and positioned according to icon 0 on the main window
  178.         * The pane is linked to the main window forming a commonly used options
  179.         * type window
  180.         */
  181.         main = Pane2_CreateAndAddMain("Main3", template_TITLEMIN);
  182.  
  183.         Pane2_ReadIcon(main, 0, "Pane3", &paneoffset, &panesize);
  184.         Pane2_CreateAndAddPane("Pane3", template_TITLEMIN, main, &paneoffset, &panesize,
  185.                                pane2_FIXED|pane2_MAINTOP|pane2_PANETOP);
  186.  
  187.         Event_Claim(event_CLICK, main, event_ANY, ClickEventHandler, NULL);
  188.         Event_Claim(event_CLOSE, main, event_ANY, CloseEventHandler, NULL);
  189.  
  190.         Pane2_Show(main, open_WHEREVER);
  191.         
  192.         break;
  193.  
  194.      case 4:
  195.        /*
  196.         * Test 4
  197.         * !ArtWork style movable panes
  198.         */
  199.         main = Pane2_CreateAndAddMain("Main4", template_TITLEMIN);
  200.  
  201.         Pane2_CreateAndAddPane("Pane4a", template_TITLEMIN, main, NULL, NULL,
  202.                                pane2_MAINTOP|pane2_PANETOP);
  203.  
  204.         pane = Pane2_CreateAndAddPane("Pane4b", template_TITLEMIN, main, NULL, NULL,
  205.                                       pane2_PANETOP);
  206.  
  207.         Event_Claim(event_CLICK, pane, event_ANY, ClickPane4bEventHandler, (void *)main); 
  208.  
  209.         Event_Claim(event_CLOSE, main, event_ANY, CloseEventHandler, NULL);
  210.  
  211.         Pane2_Show(main, open_WHEREVER);
  212.         
  213.         break;
  214.  
  215.   }
  216. }
  217.