home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / FOXPRO / GUI / GUIDEMO.PRG < prev    next >
Text File  |  1992-06-25  |  14KB  |  384 lines

  1. #include sf_gui.hdr
  2. #include system.hdr
  3. #include fileio.hdr
  4. #include iif.hdr
  5. #include io.hdr
  6. #include string.hdr
  7. #include pick.hdr
  8.  
  9. dbfdef cpcsusp
  10.   char( 15 ) lastname
  11. enddef
  12.  
  13. indexdef
  14.   char( 15 ) idnum  cpcsusp->lastname
  15. enddef
  16.  
  17. vardef extern
  18.   byte    __class_max_lr
  19.   byte    __class_max_lc
  20.   byte    __class_max_rr
  21.   byte    __class_max_rc
  22.   byte    __class_min_lr
  23.   byte    __class_min_lc
  24.   byte    __class_min_rr
  25.   byte   __class_min_rc
  26.   logical    __xms_used[ 10 ]
  27.   char( 12 ) __xms_title[ 10 ]
  28.   byte       __xms_max
  29.   int        __xms_handle[ 10 ]
  30. enddef
  31.  
  32. procedure general_info
  33.   clear
  34.   ? ""
  35.   ? " Welcome to the Special Forces GUI Library demo!!!"
  36.   ? ""
  37.   ? " The following demonstration requires a VGA card and monitor."
  38.   ? " A mouse, XMS memory and a disk cache are optional but greatly"
  39.   ? " increase the preformance of the system.  Ordering information"
  40.   ? " is contained in the README.DOC file within this demo, which is"
  41.   ? " also viewable during this demo under the file menu."
  42.   ? ""
  43.   ? " Note: The browse, picklist, image browse etc. windows are movable"
  44.   ? "       and resizable.  To move a window, click and hold a mouse button"
  45.   ? "       with the mouse cursor on the window heading, then move it to"
  46.   ? "       the new locatiion.  To resize a window, click and hold a mouse"
  47.   ? "       button on the bottom right blank button of a window, then move"
  48.   ? "       your mouse.  If you do not have a mouse, use TAB, SHIFT-TAB and"
  49.   ? "       the arrow keys to move around."
  50.   ? ""
  51.   ? " Hope you enjoy this!"
  52.   ? " Mark N. Witten"
  53.   ? ""
  54.   wait
  55. endpro
  56.  
  57. procedure order_lib
  58.   gui_validate( "To place an order for the Special Forces GUI;" +;
  59.                 "Library, issue your check or M/O to:;" +;
  60.                 ";" + "Special Forces;" + "404 Dove Court;" +;
  61.                 "Mt. Holly, NJ 08060;" + ";" +;
  62.                 "Questions? Voice or Fax: (609) 265-0921;" + ";" +;
  63.                 "Be sure to specify 5 1/4 or 3 1/2 diskettes!;",;
  64.                 -1, -1, 0, 15, "Order Information", 15, 1, .t.,;
  65.                 .t., &BMP_INFORMATION, 3 )
  66. endpro
  67.  
  68. procedure browse_dbf
  69.   vardef
  70.     char( 30 ) field_array[ 8 ]
  71.     char( 10 ) include_array[ 8 ]
  72.   enddef
  73.   open "suspd000.dbf" alias cpcsusp
  74.   index "idnui000.fdx" alias idnum
  75.   set index to idnum
  76.   field_array[ 0 ] = "Id Number"
  77.   field_array[ 1 ] = "First Name"
  78.   field_array[ 2 ] = "Last Name"
  79.   field_array[ 3 ] = "Date of Birth"
  80.   field_array[ 4 ] = "Notation"
  81.   field_array[ 5 ] = "Occupation/Trade"
  82.   field_array[ 6 ] = "Current Employment"
  83.   field_array[ 7 ] = "S.S. Number"
  84.   include_array[ 0 ] = "IDNUMBER"
  85.   include_array[ 1 ] = "FIRSTNAME"
  86.   include_array[ 2 ] = "LASTNAME"
  87.   include_array[ 3 ] = "BIRTHDATE"
  88.   include_array[ 4 ] = "NOTES"
  89.   include_array[ 5 ] = "OCCUPATION"
  90.   include_array[ 6 ] = "EMPLOY1"
  91.   include_array[ 7 ] = "SSNUMBER"
  92.   *\ Set the min and max
  93.   __class_max_lr = 3
  94.   __class_max_lc = 2
  95.   __class_max_rr = 27
  96.   __class_max_rc = 77
  97.   __class_min_lr = 22
  98.   __class_min_lc = 2
  99.   __class_min_rr = 27
  100.   __class_min_rc = 9
  101.   gui_browse( cpcsusp, 3, 4, 22, 75, 0, 7, 1, 15, "Gui_Browse()",;
  102.               15, 1, 0, 14, field_array[], include_array[], 8, .t., .t. )
  103.   close( cpcsusp )
  104. endpro
  105.  
  106. *\procedure animate
  107. *\  vardef
  108. *\    int cnt
  109. *\  enddef
  110. *\    gui_savescrn( "animate.vga", 4, 16, 16, 43 )
  111. *\    gui_window( 5, 17, 15, 42, 0, "Movie", 15, 1, .t., .t., .t., .t. )
  112. *\    do while is_key() <> 27
  113. *\      gui_restdisk( "c1.vga", 6, 19, 14, 40, .f. )
  114. *\      gui_restdisk( "c2.vga", 6, 19, 14, 40, .f.  )
  115. *\      gui_restdisk( "c3.vga", 6, 19, 14, 40, .f.  )
  116. *\      gui_restdisk( "c4.vga", 6, 19, 14, 40, .f.  )
  117. *\      gui_restdisk( "c5.vga", 6, 19, 14, 40, .f.  )
  118. *\      gui_restdisk( "c6.vga", 6, 19, 14, 40, .f.  )
  119. *\      gui_restdisk( "c7.vga", 6, 19, 14, 40, .f.  )
  120. *\      gui_restdisk( "c8.vga", 6, 19, 14, 40, .f.  )
  121. *\      gui_restdisk( "c9.vga", 6, 19, 14, 40, .f.  )
  122. *\      gui_restdisk( "c10.vga", 6, 19, 14, 40, .f.  )
  123. *\      gui_restdisk( "c11.vga", 6, 19, 14, 40, .f.  )
  124. *\      gui_restdisk( "c12.vga", 6, 19, 14, 40, .f.  )
  125. *\    enddo
  126. *\    gui_restscrn( "animate.vga", 4, 16, 16, 43, .t. )
  127. *\endpro
  128.  
  129. procedure picklist
  130.   parameters const char filename
  131.   vardef
  132.     long plist
  133.     file handle
  134.     char buffer
  135.   enddef
  136.   plist = pick_init()
  137.   f_open( handle, filename, &F_READ )
  138.   do while .not. f_eof( handle )
  139.     f_getln( handle, buffer )
  140.     pick_add( plist, buffer )
  141.   enddo
  142.   f_close( handle )
  143.   *\ Set the min and max
  144.   __class_max_lr = 3
  145.   __class_max_lc = 2
  146.   __class_max_rr = 27
  147.   __class_max_rc = 77
  148.   __class_min_lr = 22
  149.   __class_min_lc = 2
  150.   __class_min_rr = 27
  151.   __class_min_rc = 9
  152.   gui_pick_list( plist, 3, 30, 27, 71, .f., .f., 0, 7, 15,;
  153.                  "Gui_Pick_List()", 15, 1, 1, .t., .t. )
  154.   pick_clear( plist )
  155. endpro
  156.  
  157. procedure force_main
  158.   vardef
  159.     long       object, l_sub1, l_sub2, l_sub3
  160.     int        object_selected, menu_level, cnt, xcnt
  161.     uint       selected_list, headof_list
  162.     logical    lvar1, lvar2, lvar3, lvar4, really_exit
  163.     char( 15 ) get_variable1, get_variable2
  164.     char       arr[ 10 ], xarr[ 5 ]
  165.   enddef
  166.  
  167.   general_info()
  168.  
  169.   *\ General setup...
  170.   really_exit = .f.
  171.   scrn_dos()
  172.   gui_init()
  173.   gui_mouse_init()
  174.   gui_xms_init( &XMS_MAX )
  175.   on error do gui_error_system
  176.  
  177.   *\ Define pulldown menus
  178.   l_sub1 = gui_menu_init()
  179.   l_sub2 = gui_menu_init()
  180.   l_sub3 = gui_menu_init()
  181.   gui_menu_add( l_sub1, " DBF ^Browse demo       ", 3, 6 )
  182.   gui_menu_add( l_sub1, " Picklist ^demo         ", 4, 6 )
  183.   gui_menu_add( l_sub1, " ^Validate dialog       ", 5, 6 )
  184.   gui_menu_add( l_sub1, " ^Image browse demo     ", 7, 6 )
  185.   gui_menu_add( l_sub1, " ^Menu prompt 1, 5      ", 8, 6 )
  186.   gui_menu_add( l_sub1, " M^enu prompt 1, 6      ", 9, 6 )
  187.   gui_menu_add( l_sub1, " Me^nu prompt 1, 7      ", 10, 6 )
  188.   gui_menu_add( l_sub1, " Men^u prompt 1, 8      ", 11, 6 )
  189.   gui_menu_add( l_sub1, " Menu p^rompt 1, 9      ", 13, 6 )
  190.   gui_menu_add( l_sub1, " Menu pr^ompt 1, 10     ", 14, 6 )
  191.   gui_menu_add( l_sub1, " Menu promp^t 1, 11     ", 15, 6 )
  192.   gui_menu_add( l_sub1, " View ^README.DOC file  ", 17, 6 )
  193.   gui_menu_add( l_sub1, " View ^GUIDEMO.PRG file ", 18, 6 )
  194.   gui_menu_add( l_sub2, " Display ^Squares Wallpaper ", 3, 21 )
  195.   gui_menu_add( l_sub2, " Display ^Castle Wallpaper  ", 4, 21 )
  196.   gui_menu_add( l_sub2, " Display ^Rivets Wallpaper  ", 5, 21 )
  197.   gui_menu_add( l_sub2, " Display ^Boxes Wallpaper   ", 6, 21 )
  198.   gui_menu_add( l_sub2, " Display ^Egypt Wallpaper   ", 7, 21 )
  199.   gui_menu_add( l_sub3, " ^Yes, exit the system    ", 3, 37 )
  200.   gui_menu_add( l_sub3, " ^No, do not exit system  ", 4, 37 )
  201.   *\ End menu creation
  202.  
  203.   *\ Set up some variables
  204.   *- for radio buttons
  205.   lvar1 = .t.
  206.   lvar2 = .f.
  207.   lvar3 = .t.
  208.   lvar4 = .f.
  209.   *- for gets
  210.   get_variable1 = space( 15 )
  211.   get_variable2 = space( 15 )
  212.   *- for list box
  213.   selected_list = 0
  214.   headof_list   = 0
  215.   xarr[ 0 ] = "squares.$$$"
  216.   xarr[ 1 ] = "castle.$$$"
  217.   xarr[ 2 ] = "rivets.$$$"
  218.   xarr[ 3 ] = "boxes.$$$"
  219.   xarr[ 4 ] = "egypt.$$$"
  220.   arr[ 0 ] = " Squares Wallpaper "
  221.   arr[ 1 ] = " Castle Wallpaper  "
  222.   arr[ 2 ] = " Rivets Wallpaper  "
  223.   arr[ 3 ] = " Boxes Wallpaper   "
  224.   arr[ 4 ] = " Egypt Wallpaper   "
  225.   arr[ 5 ] = " N/A Wallpaper     "
  226.   arr[ 6 ] = " N/A Wallpaper     "
  227.   arr[ 7 ] = " N/A Wallpaper     "
  228.   arr[ 8 ] = " N/A Wallpaper     "
  229.   arr[ 9 ] = " N/A Wallpaper     "
  230.  
  231.   gui_wallpaper( "squares.$$$", 0, .f. )
  232.   *\ Do while to allow screen redraw
  233.   do while .t.
  234.  
  235.     *\ Draw the screen stuff
  236.     gui_say_string( space( 80 ), 0, 0, 0, 1 )
  237.     gui_say_string( "Object Test/Demo program", 0, 29, 15, 1 )
  238.     gui_say_string( space( 80 ), 1, 0, 0, 15 )
  239.     gui_raised_tile( 3, 8, 11, 71, 7, 4 )
  240.     gui_raised_tile( 25, 1, 27, 78, 7, 3 )
  241.     gui_raised_tile( 14, 1, 22, 30, 7, 3 )
  242.     gui_raised_tile( 14, 49, 22, 78, 7, 3 )
  243.     gui_sunken_box( glr( 15 ) - 8, glc( 2 ), grr( 21 ) + 8, grc( 29 ) )
  244.     gui_say_string( "Printer setting 1: ", 15, 6, 15, 7 )
  245.     gui_say_string( "Printer setting 2: ", 16, 6, 15, 7 )
  246.     gui_say_string( "Printer setting 3: ", 17, 6, 15, 7 )
  247.     gui_say_string( "Printer setting 4: ", 18, 6, 15, 7 )
  248.     gui_rest_internal_bmp( "logo.vga", 4, 10, 9, 70 )
  249.     gui_indented_box( glr( 4 ) - 6, glc( 9 ) + 2, grr( 10 ) + 4, grc( 70 ) - 4 )
  250.  
  251.     *\ Create screen objects
  252.     object = object_create()
  253.  
  254.     *\ Create button objects
  255.     object_button( object, " DBF ^Browse ", 26, 3, 98 )
  256.     object_button( object, " ^Pick List ", 26, 17, 112 )
  257.     object_button( object, " ^Validate Dialogs ", 26, 30, 115 )
  258.     object_button( object, " ^Image Browse ", 26, 50, 105 )
  259.     object_button( object, " E^xit Demo ", 26, 66, 120 )
  260.  
  261.     *\ Create radio button objects
  262.     object_radio_button( object, 15, 25, lvar1, -1 )
  263.     object_radio_button( object, 16, 25, lvar2, -1 )
  264.     object_radio_button( object, 17, 25, lvar3, -1 )
  265.     object_radio_button( object, 18, 25, lvar4, -1 )
  266.  
  267.     *\ Create picture button objects
  268.     object_picture_button( object, "ok.$$$", 20, 3, 21, 10, -1 )
  269.     object_picture_button( object, "cancel.$$$", 20, 12, 21, 19, -1 )
  270.     object_picture_button( object, "help.$$$", 20, 21, 21, 28, -1 )
  271.  
  272.     *\ Create menu objects
  273.     object_menu( object, 1, 5, "^File", 0, 15, 32801 )
  274.     object_menu( object, 1, 20, "^Edit", 0, 15, 32786 )
  275.     object_menu( object, 1, 36, "^Quit", 0, 15, 32784 )
  276.  
  277. *\    *\ Create get objects
  278. *\    object_get( object, 11, 22, get_variable1, 15, "!!!!!!!!!!!!!!!", 15, 8, -1 )
  279. *\    object_get( object, 11, 40, get_variable2, 15, "!!!!!!!!!!!!!!!", 15, 8, -1 )
  280.  
  281.     *\ Create list box object
  282.     object_list_box( object, arr[], &LIST_SUNKEN, 10, selected_list, headof_list, 15, 51, 21, 76, 0, 7, 3, -1 )
  283.  
  284.     do while .t.
  285.       object_selected = object_getevent( object )
  286.       do case
  287.         case object_selected = 1
  288.           event_button( " DBF ^Browse ", 26, 3 )
  289.           browse_dbf()
  290.         case object_selected = 2
  291.           event_button( " ^Pick List ", 26, 17 )
  292.           picklist( "guidemo.prg" )
  293.         case object_selected = 3
  294.           event_button( " ^Validate Dialogs ", 26, 30 )
  295. *\        gui_palette_setter( -1, -1, 0, 7, "Gui_palette_setter()", 15, 1, .t., .t., .t. )
  296.           order_lib()
  297.         case object_selected = 4
  298.           event_button( " ^Image Browse ", 26, 50 )
  299.           gui_image_browse( "demo2.vga", 3, 4, 22, 75,;
  300.                             "Your header goes here!!!", 15, 1, .t., .t. )
  301.         case object_selected = 5
  302.           event_button( " E^xit Demo ", 26, 66 )
  303.           really_exit = .t.
  304.           exit
  305.         case object_selected = 6
  306.           event_radio_button( 15, 25, lvar1 )
  307.         case object_selected = 7
  308.           event_radio_button( 16, 25, lvar2 )
  309.         case object_selected = 8
  310.           event_radio_button( 17, 25, lvar3 )
  311.         case object_selected = 9
  312.           event_radio_button( 18, 25, lvar4 )
  313.         case object_selected = 10
  314.           event_picture_button( "ok.$$$", 20, 3, 21, 10 )
  315.         case object_selected = 11
  316.           event_picture_button( "cancel.$$$", 20, 12, 21, 19 )
  317.         case object_selected = 12
  318.           event_picture_button( "help.$$$", 20, 21, 21, 28 )
  319.         case object_selected = 13
  320.           event_menu( l_sub1, 0, 15, 7, 0, menu_level, 2, 5, 19, 29, .t. )
  321.           do case
  322.             case menu_level = 1
  323.               browse_dbf()
  324.             case menu_level = 2
  325.               picklist( "guidemo.prg" )
  326.             case menu_level = 3
  327. *\            gui_palette_setter( -1, -1, 0, 7, "Gui_palette_setter()", 15, 1, .t., .t., .t. )
  328.               order_lib()
  329.             case menu_level = 4
  330.               gui_image_browse( "demo2.vga", 3, 4, 22, 75,;
  331.                                 "Your header goes here!!!", 15, 1, .t., .t. )
  332.             case menu_level = 5
  333. *\              animate()
  334.             case menu_level = 12
  335.               picklist( "readme.doc" )
  336.             case menu_level = 13
  337.               picklist( "guidemo.prg" )
  338.           endcase
  339.         case object_selected = 14
  340.           event_menu( l_sub2, 0, 15, 7, 0, menu_level, 2, 20, 8, 48, .t. )
  341.           if menu_level <> 0
  342.             gui_wallpaper( xarr[ menu_level - 1 ], -1, .f. )
  343.             really_exit = .f.
  344.             exit
  345.           endif
  346.         case object_selected = 15
  347.           event_menu( l_sub3, 0, 15, 7, 0, menu_level, 2, 36, 5, 62, .t. )
  348.           if menu_level = 1
  349.             really_exit = .t.
  350.             exit
  351.           endif
  352. *\        case object_selected = 16
  353. *\          get_variable1 = event_get( 11, 22, get_variable1, 15, "!!!!!!!!!!!!!!!", 15, 8 )
  354. *\        case object_selected = 17
  355. *\          get_variable2 = event_get( 11, 40, get_variable2, 15, "!!!!!!!!!!!!!!!", 15, 8 )
  356.         case object_selected = 16
  357.           event_list_box( arr[], &LIST_SUNKEN, 10, selected_list, headof_list, 15, 51, 21, 76, 0, 7, 3, .f. )
  358.           if lastkey() = 0 .or. lastkey() = 1 .or. lastkey() = 2 .or. lastkey() = 13
  359.             if selected_list >=0 .and. selected_list <= 4
  360.               gui_wallpaper( xarr[ selected_list ], -1, .f. )
  361.               really_exit = .f.
  362.               exit
  363.             endif
  364.           endif
  365.       endcase
  366.     enddo
  367.     *\ Kill the objects since this will rebuild them
  368.     object_destroy( object )
  369.     if really_exit
  370.       if gui_validate( "Are you sure you wish to exit the;" +;
  371.                        "Special Forces GUI demonstration?;",;
  372.                        -1, -1, 0, 15, "Exit Query", 15, 1,;
  373.                        .t., .t., &BMP_QUESTION, 3 ) = &VALID_OK
  374.         exit
  375.       endif
  376.     endif
  377.   enddo
  378.   gui_menu_clear( l_sub1 )
  379.   gui_menu_clear( l_sub2 )
  380.   gui_menu_clear( l_sub3 )
  381.   gui_close()
  382.   xms_close()
  383. endpro
  384.