home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / tlktbeta / samples / textfldr / textfldr.csc < prev    next >
Encoding:
Text File  |  1993-07-12  |  8.9 KB  |  255 lines

  1. /******************************************************************************
  2. *
  3. *  Module Name: TEXTFLDR
  4. *
  5. *  OS/2 Work Place Shell Sample Program
  6. *
  7. *  Copyright (C) 1993 IBM Corporation
  8. *
  9. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  10. *      sample code created by IBM Corporation. This sample code is not
  11. *      part of any standard or IBM product and is provided to you solely
  12. *      for  the purpose of assisting you in the development of your
  13. *      applications.  The code is provided "AS IS", without
  14. *      warranty of any kind.  IBM shall not be liable for any damages
  15. *      arising out of your use of the sample code, even if they have been
  16. *      advised of the possibility of such damages.
  17. *
  18. ******************************************************************************/
  19.  
  20. ###   Note: The header preceding this comment will be emitted in all files.
  21. ###
  22. ###         Any comments to go public should be preceded with '--'
  23. ###         Any comments to remain private should be preceded with '#'
  24.  
  25. #******************************************************************************
  26. #   Include the class definition file for the parent class
  27. #******************************************************************************
  28. include <wpfolder.sc>
  29.  
  30. #******************************************************************************
  31. #   Define the new class
  32. #******************************************************************************
  33. class:  TextFolder,
  34.         external stem   = TextFolderwps,
  35.         local,
  36.         external prefix = TextFolderwps_,
  37.         classprefix     = TextFolderM_,
  38.         major version   = 1,
  39.         minor version   = 2;
  40.  
  41. --
  42. -- CLASS: TextFolder
  43. --
  44. -- CLASS HIERARCHY:
  45. --
  46. --     SOMObject
  47. --       └── WPObject
  48. --             └── WPFileSystem
  49. --                   └── WPFolder
  50. --                         └──  TextFolder
  51. --
  52. -- DESCRIPTION:
  53. --
  54. --    This is the TextFolder object class. This object is similar to
  55. --    normal folders. The text folder rejects any object that isn't
  56. --    a file system object that only contains text. The TextFolder accepts
  57. --    file system objects that have a type of 'Plain Text' or have no type
  58. --    and contain text characters only.
  59. --
  60. --    An instance of this class can be created as a Workplace object.
  61. --
  62.  
  63. #******************************************************************************
  64. #   Specify the parent class
  65. #******************************************************************************
  66. parent: WPFolder;
  67.  
  68. #******************************************************************************
  69. #   Specify the release order of new methods.  This ensures binary
  70. #   compatability if we change the order of our methods in .c and .csc files.
  71. #******************************************************************************
  72. release order:
  73.         IsTextFile,
  74.         ValidateDragAndDrop;
  75.  
  76. #******************************************************************************
  77. #   Passthru PRIVATE definitions to the .ph file
  78. #******************************************************************************
  79. passthru: C.ph;
  80. endpassthru;
  81.  
  82. #******************************************************************************
  83. #   Passthru IMPLEMENTATION definitions to the .ih file
  84. #******************************************************************************
  85. passthru: C.ih;
  86.  
  87.         #define   INCL_WIN
  88.         #define   INCL_DOSERRORS
  89.         #define   INCL_DOSMODULEMGR
  90.         #include  <os2.h>
  91.  
  92.         #define   INCL_WPCLASS
  93.         #include  <pmwp.h>
  94.  
  95.         #include "string.h"
  96.  
  97.         #define ID_ICON 100
  98.  
  99.         #define FIRST_TEXT_CHAR         0x20
  100.         #define LAST_TEXT_CHAR          0x7e
  101.         #define CHAR_CARRIAGE_RETURN    '\r'
  102.         #define CHAR_LINE_FEED          '\n'
  103.         #define CHAR_TAB                '\t'
  104.         #define CHAR_END_OF_FILE        0x1a
  105.  
  106. endpassthru;
  107.  
  108. #******************************************************************************
  109. #   Passthru PUBLIC definitions to the .h file
  110. #******************************************************************************
  111. passthru: C.h, after;
  112. endpassthru;
  113.  
  114. #******************************************************************************
  115. #   Define instance data
  116. #******************************************************************************
  117. data:
  118.  
  119. #******************************************************************************
  120. #   Define methods
  121. #******************************************************************************
  122. methods:
  123.  
  124. BOOL     IsTextFile( PSZ pszFileName), private;
  125. --
  126. -- METHOD: IsTextFile                                     (X) PRIVATE
  127. --                                                        ( ) PUBLIC
  128. -- DESCRIPTION:
  129. --
  130. --   This method checks the first 'n' characters of a file to determine
  131. --   if it is or is not text. This method is invoked by the
  132. --   ValidateDragAndDrop method. It is invoked only if no type is specified
  133. --   for the object being manipulated.  A file is considered to be text if
  134. --   the first 'n' bytes are in the range of ASCII 32 (20 Hex) to ASCII 126
  135. --   (7E Hex), or is a carriage return (ASCII 10, Hex 0A), line feed
  136. --   (ASCII 13, Hex 0D), tab (ASCII 8, HEX 08), or end of file marker
  137. --   (ASCII 26, Hex 1A).
  138. --
  139. --   NOTE: The value used for 'n' is stored in the variable ulSampleSize
  140. --   which is local to the IsTextFile method.
  141. --
  142. -- RETURN:
  143. --
  144. --   TRUE  - the object is a text file.
  145. --   FALSE - the object is not a text file.
  146. --
  147. -- HOW TO OVERRIDE:
  148. --
  149. --   n/a
  150. --
  151.  
  152. BOOL     ValidateDragAndDrop( PDRAGINFO pdrgInfo), private;
  153. --
  154. -- METHOD: ValidateDragAndDrop                            (X) PRIVATE
  155. --                                                        ( ) PUBLIC
  156. -- DESCRIPTION:
  157. --
  158. --   This method determines if an object can be dragged/dropped on the
  159. --   TextFolder. It is invoked by the wpDrag and wpDragOver methods.
  160. --
  161. --   The ValidateDragAndDrop method first checks the type of the object
  162. --   being manipulated. If a type is specified, and it is Plain Text,
  163. --   the operation is considered to be valid. If a type is specified and
  164. --   it is not Plain Text the operation is considered invalid. If no
  165. --   type is specified the IsTextFile() method is invoked to determine
  166. --   if the object is or is not a text object.
  167. --
  168. -- RETURN:
  169. --
  170. --   TRUE  - The object can be dragged/dropped on the TextFolder.
  171. --   FALSE - The object can not be dragged/dropped on the TextFolder.
  172. --
  173. -- HOW TO OVERRIDE:
  174. --
  175. --   n/a
  176. --
  177.  
  178. #******************************************************************************
  179. #   Specify methods being overridden
  180. #******************************************************************************
  181.  
  182. -----------------------------------------------------------------------------
  183. --   Methods from the WPFileSystem class
  184. -----------------------------------------------------------------------------
  185. override wpFilterPopupMenu;
  186. --
  187. --  METHOD: wpFilterPopupMenu                              ( ) PRIVATE
  188. --                                                         (X) PUBLIC
  189. --  DESCRIPTION:
  190. --
  191. --    Removes the Tree view option from the Open popup menu.
  192. --
  193.  
  194.  
  195. -----------------------------------------------------------------------------
  196. --   Methods from the WPFolder class
  197. -----------------------------------------------------------------------------
  198. override wpAddFolderView2Page;
  199. --
  200. --  METHOD: wpAddFolderView2Page                           ( ) PRIVATE
  201. --                                                         (X) PUBLIC
  202. --  DESCRIPTION:
  203. --
  204. --    Removes the tree view settings page for the TextFolder.
  205. --
  206.  
  207. override wpAddFolderIncludePage;
  208. --
  209. --  METHOD: wpAddFolderIncludePage                         ( ) PRIVATE
  210. --                                                         (X) PUBLIC
  211. --  DESCRIPTION:
  212. --
  213. --    Removes the Include Page from the TextFolder's settings.
  214. --
  215.  
  216. override wpDragOver;
  217. --
  218. --  METHOD: wpDragOver                                     ( ) PRIVATE
  219. --                                                         (X) PUBLIC
  220. --  DESCRIPTION:
  221. --
  222. --    Allows or disallows an object to be dragged over the TextFolder.
  223. --
  224.  
  225. override wpDrop;
  226. --
  227. --  METHOD: wpDrop                                         ( ) PRIVATE
  228. --                                                         (X) PUBLIC
  229. --  DESCRIPTION:
  230. --
  231. --    Allows or disallows an object to be dropped on the TextFolder.
  232. --
  233.  
  234.  
  235. #******************************************************************************
  236. #   Specify class methods being overridden
  237. #******************************************************************************
  238. override wpclsQueryTitle, class;
  239. --
  240. -- METHOD: wpclsQueryTitle
  241. --
  242. -- DESCRIPTION:
  243. --
  244. --   Provides a default name of Text Folder for TextFolder.
  245. --
  246.  
  247. override wpclsQueryIconData, class;
  248. --
  249. -- METHOD: wpclsQueryIconData
  250. --
  251. -- DESCRIPTION:
  252. --
  253. --   Provides an icon for the TextFolder.
  254. --
  255.