home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / dataflex / trnsclnt.pkg < prev    next >
Encoding:
Text File  |  1993-08-10  |  6.6 KB  |  211 lines

  1. //************************************************************************
  2. //
  3. // Copyright 1987-1992 Data Access Corporation, Miami FL, USA
  4. // All Rights reserved
  5. // DataFlex is a registered trademark of Data Access Corporation.
  6. //
  7. //
  8. //     $Source: /u3/source.30/product/pkg/RCS/trnsclnt.pkg,v $
  9. //     $Revision: 1.1 $
  10. //     $State: Exp $
  11. //     $Author: james $
  12. //     $Date: 1992/09/08 14:43:10 $
  13. //     $Locker:  $
  14. //
  15. //     $Log: trnsclnt.pkg,v $
  16. //Revision 1.1  1992/09/08  14:43:10  james
  17. //Initial revision
  18. //
  19. //Revision 1.3  92/05/14  17:08:24  SWM
  20. //Updated Copyright slug.
  21. //
  22. //Revision 1.2  92/03/09  19:05:35  james
  23. //Added #CHKSUB directive to insure source
  24. //only compiled with correct revision of 
  25. //compiler.
  26. //
  27. //Revision 1.1  91/10/23  10:23:05  elsa
  28. //Initial revision
  29. //
  30. //************************************************************************/
  31.  
  32. //************************************************************************
  33. //     File Name: TrnsClnt.Pkg
  34. // Creation Date: January 1, 1991
  35. // Modified Date: May 23, 1991
  36. //     Author(s): Steven A. Lowe
  37. //
  38. // This module contains the Translate-Text pop-up object for the Text_Editor
  39. // class.
  40. //
  41. // This package implements a pop-up object for text searching and replacement
  42. // within a text-editor object
  43. //************************************************************************/
  44.  
  45. #CHKSUB 1 1 // Verify the UI subsystem.
  46.  
  47. Use UI
  48.  
  49.  
  50. /transClientImg 
  51. ╔═══════════════════════════════════════════════════════════╗
  52. ║                                                           ║
  53. ║                ┌───────────────────────────────────────┐  ║
  54. ║   Find what:   │ ____________________________________  │  ║
  55. ║                └───────────────────────────────────────┘  ║
  56. ║                                                           ║
  57. ║                ┌───────────────────────────────────────┐  ║
  58. ║   Change to:   │ ____________________________________  │  ║
  59. ║                └───────────────────────────────────────┘  ║
  60. ║                                                           ║
  61. ║   ┌───────────────────────────────────────────────────┐   ║
  62. ║   │ <_________>         <______>         <__________> │   ║
  63. ║   └───────────────────────────────────────────────────┘   ║
  64. ║                                                           ║
  65. ║                           <__>                            ║
  66. ╚═══════════════════════════════════════════════════════════╝
  67. /*
  68. Sub_Page transFromImg  FROM transClientImg 1
  69. Sub_Page transToImg    FROM transClientImg 2
  70. Sub_Page transBtnsImg  FROM transClientImg 3 4 5
  71. Sub_Page transOKImg    FROM transClientImg 6
  72.  
  73.  
  74. //
  75. //Attribute: Translate_Area
  76. //
  77. //Description: search/translate pop-up object
  78. //
  79. //Representation: modified CLIENT instance
  80. //
  81. object Translate_Area is a CLIENT transClientImg
  82.   set location to 3 5 absolute
  83.   set BLOCK_MOUSE_STATE to true
  84.   set DELEGATION_MODE to DELEGATE_PRIOR_LEVEL
  85.   set SCOPE_STATE to TRUE
  86.   set Exit_Msg to cancel_Scope
  87.   on_key kCancel        SEND cancel_scope
  88.   on_key kExit_Function SEND cancel_scope
  89.   procedure cancel_scope
  90.     send deactivate 3
  91.   end_procedure
  92.   //
  93.   //Attribute: Translate_From_Area
  94.   //
  95.   //Description: form for entry of translation target pattern
  96.   //
  97.   //Representation: FORM with one item sending NEXT message to self
  98.   //
  99.   object Translate_From_Area is a FORM transFromImg
  100.     item_list 
  101.       on_item "" SEND next
  102.     end_item_list 
  103.   end_object 
  104.   //
  105.   //Attribute: Translate_To_Area
  106.   //
  107.   //Description: form for entry of translate-to pattern
  108.   //
  109.   //Representation: FORM with one item sending NEXT message to self
  110.   //
  111.   object Translate_To_Area is a FORM transToImg
  112.     item_list 
  113.       on_item "" SEND next
  114.     end_item_list 
  115.   end_object 
  116.   //
  117.   //Attribute: Button_Area
  118.   //
  119.   //Description: panel of three buttons for translation options
  120.   //
  121.   //Representation: BUTTON with three items sending messages to self
  122.   //
  123.   object Button_Area is a BUTTON transBtnsImg
  124.     item_list 
  125.       on_item "Find Next"  SEND Find_Next
  126.       on_item "Change"     SEND Translate
  127.       on_item "Change All" SEND Translate_All
  128.     end_item_list 
  129.   end_object 
  130.   //
  131.   //Attribute: OK_Button_Area
  132.   //
  133.   //Description: panel of two buttons for OK and CANCEL
  134.   //
  135.   //Representation: BUTTON with two items sending messages to self
  136.   //
  137.   object OK_Button_Area is a BUTTON transOKImg
  138.     item_list 
  139.       on_item "OK" SEND Cancel_Scope
  140.     end_item_list 
  141.   end_object 
  142.   //
  143.   //Operation: FIND_NEXT
  144.   //
  145.   //Assumption(s): none
  146.   //
  147.   //Goal(s): locate next ocurrance of search pattern in last focus object,
  148.   //  ringing the bell if no match was found
  149.   //
  150.   //Algorithm: sends find to last focus object, ringing bell if no match,
  151.   //           else sends REFRESH_SCREEN
  152.   //
  153.   //Usage: invoked by "Find Next" item of Button_Area
  154.   //
  155.   procedure Find_Next
  156.     local integer itemp
  157.     send find (value(Translate_From_Area(current_object),0)) itemp
  158.     if itemp eq 0 send bell to desktop
  159.     else send Refresh_Screen to desktop
  160.   end_procedure
  161.   //
  162.   //Operation: TRANSLATE
  163.   //
  164.   //Assumption(s): none
  165.   //
  166.   //Goal(s): to replace the next ocurrance of the search pattern with the
  167.   //  target pattern, or ring the bell if no match found
  168.   //
  169.   //Algorithm: sends kLEFTARROW to last focus object, then sends REPLACE to it
  170.   //           if match found, sends REFRESH_SCREEN, else sends BELL
  171.   //
  172.   //Usage: invoked by "Change" item of Button_Area
  173.   //
  174.   procedure Translate
  175.     local integer itemp
  176.     send key to (prior_level(current_object)) kLeftArrow 
  177.     send replace (value(Translate_From_Area(current_object),0)) ;
  178.         (value(Translate_To_Area(current_object),0)) itemp
  179.     if itemp eq 0 send bell to desktop
  180.     else send Refresh_Screen to desktop
  181.   end_procedure
  182.   //
  183.   //Operation: TRANSLATE_ALL
  184.   //
  185.   //Assumption(s): none
  186.   //
  187.   //Goal(s): to replace all ocurrances of search pattern with target pattern
  188.   //
  189.   //Algorithm: repeatedly sends REPLACE to last focus object until no match,
  190.   //           then sends REFRESH_SCREEN
  191.   //
  192.   //Usage: invoked by "Change All" item of Button_Area
  193.   //
  194.   procedure Translate_All
  195.     local string  stemp xtemp
  196.     local integer itemp counter
  197.     move (value(Translate_From_Area(current_object),0)) to stemp
  198.     move (value(Translate_To_Area(current_object),0)) to xtemp
  199.     send key to (prior_level(current_object)) kLeftArrow 
  200.     move 0 to counter
  201.     repeat        
  202.       send replace stemp xtemp itemp
  203.       if (itemp + counter) eq 0 send bell to desktop
  204.       else calc (counter + 1) to counter
  205.     until itemp eq 0
  206.     send Refresh_Screen to desktop
  207.   end_procedure
  208. end_object
  209.  
  210.  
  211.