home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / SAMPLES / WPS / BROWSE / BROWSE.IDL < prev    next >
Text File  |  1995-08-24  |  15KB  |  461 lines

  1.  
  2. //# This file was generated by the SOM Compiler.
  3. //# FileName: browse.id2.
  4. //# Generated using:
  5. //#     SOM Precompiler somopc: 2.7
  6. //#     SOM Emitter emitidl: 2.22
  7.  
  8. //
  9. //
  10. //   Module Name: BROWSE
  11. //
  12. //   OS/2 Work Place Shell Sample Program
  13. //
  14. //   Copyright (C) 1993 IBM Corporation
  15. //
  16. //       DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  17. //       sample code created by IBM Corporation. This sample code is not
  18. //       part of any standard or IBM product and is provided to you solely
  19. //       for  the purpose of assisting you in the development of your
  20. //       applications.  The code is provided "AS IS", without
  21. //       warranty of any kind.  IBM shall not be liable for any damages
  22. //       arising out of your use of the sample code, even if they have been
  23. //       advised of the possibility of such damages.
  24. //
  25.  
  26. #ifndef browse_idl
  27. #define browse_idl
  28.  
  29. #include <wpdataf.idl>
  30. #include <browcls.idl>
  31. #include <somcls.idl>
  32.  
  33. interface M_Browse_O_Matic;
  34.  
  35. interface Browse_O_Matic : WPDataFile
  36.  
  37. //
  38. // CLASS: Browse_O_Matic
  39. //
  40. // CLASS HIERARCHY:
  41. //
  42. //     SOMObject
  43. //       └── WPObject
  44. //             └── WPFileSystem
  45. //                   └── WPDataFile
  46. //                         └──  Browse_O_Matic
  47. //
  48. // DESCRIPTION:
  49. //
  50. //    This is the sample Browse_O_Matic object class. This object provides
  51. //    a hex and text dump view for file system objects that are dropped on
  52. //    instances of it.
  53. //
  54. //    An instance of this class can be created as a Workplace object.
  55. //
  56.  
  57. {
  58.   VOID BrowseOMatic(in BOOL bMode,
  59.                     in PSZ pszName);
  60.  
  61.   //
  62.   // METHOD: BrowseOMatic                                   ( ) PRIVATE
  63.   //                                                        (X) PUBLIC
  64.   // DESCRIPTION:
  65.   //
  66.   //   Displays a file in the specified format.
  67.   //
  68.   //      BOOL bMode   - Specifies the format of the view. Supported values:
  69.   //                     PMBROWSE_HEX_DISPLAY_MODE
  70.   //                     PMBROWSE_TEXT_DISPLAY_MODE
  71.   //
  72.   //      PSZ  pszName - The name of the file to display. Can't be NULL.
  73.   //
  74.   // RETURN:
  75.   //
  76.   //      N/A
  77.   //
  78.  
  79.   PSZ DuplicateString(in PSZ pszString);
  80.  
  81.   //
  82.   // METHOD: DuplicateString                                ( ) PRIVATE
  83.   //                                                        (X) PUBLIC
  84.   // DESCRIPTION:
  85.   //
  86.   //   Duplicates a null terminated string. The buffer is allocated using
  87.   //   wpAllocMem() and must be freed using wpFreeMem().
  88.   //
  89.   //      PSZ  pszString - A NULL terminated string.
  90.   //
  91.   // RETURN:
  92.   //
  93.   //      A pointer to the copy of pszString.
  94.   //
  95.  
  96.   VOID ErrorHandler(in PSZ pszInfo,
  97.                     in APIRET rc);
  98.  
  99.   //
  100.   // METHOD: ErrorHandler                                   ( ) PRIVATE
  101.   //                                                        (X) PUBLIC
  102.   // DESCRIPTION:
  103.   //
  104.   //   Displays error information in a PM window.
  105.   //
  106.   //      PSZ    pszInfo - A description of the error condition.
  107.   //      APIRET rc      - The error code from the failing method.
  108.   //
  109.   // RETURN:
  110.   //
  111.   //      N/A
  112.   //
  113.  
  114.   BOOL FileExists(in PSZ pszFileName);
  115.  
  116.   //
  117.   // METHOD: FileExists                                     ( ) PRIVATE
  118.   //                                                        (X) PUBLIC
  119.   // DESCRIPTION:
  120.   //
  121.   //   Determines if a file exists.
  122.   //
  123.   //      PSZ    pszFileName - A fully qualified path and file name.
  124.   //
  125.   // RETURN:
  126.   //
  127.   //      TRUE  - The file exists.
  128.   //      FALSE - The file does not exist.
  129.   //
  130.  
  131.   UINT GetHexLine(in USHORT usLine,
  132.                   in PBYTE pBuffer,
  133.                   in ULONG ulFileLength,
  134.                   in PSZ pszText);
  135.  
  136.   //
  137.   // METHOD: GetHexLine                                     ( ) PRIVATE
  138.   //                                                        (X) PUBLIC
  139.   // DESCRIPTION:
  140.   //
  141.   //   Formats 16 bytes of the object for display.
  142.   //
  143.   //      USHORT usLine       - The number of the line to get.
  144.   //      PBYTE  pBuffer      - Pointer to the buffer where the file is loaded in
  145.   //      ULONG  ulFileLength - The size of the file.
  146.   //      PSZ    pszText      - Buffer to store the formated line in.
  147.   //
  148.   // RETURN:
  149.   //
  150.   //      The length of the formated display line.
  151.   //
  152.  
  153.   VOID GetLinesAndColumns(in BOOL bDisplay,
  154.                           in PSHORT psTotalLines,
  155.                           in PSHORT psTotalColumns,
  156.                           in USHORT usNumberOfTextLines,
  157.                           in USHORT usNumberOfTextColumns,
  158.                           in ULONG ulFileLength);
  159.  
  160.   //
  161.   // METHOD: GetLinesAndColumns                             ( ) PRIVATE
  162.   //                                                        (X) PUBLIC
  163.   // DESCRIPTION:
  164.   //
  165.   //   Determines the maximum number of lines and columns based on the current
  166.   //   view mode.
  167.   //
  168.   //      BOOL   bDisplay       - The display mode. Supported values:
  169.   //                              PMBROWSE_TEXT_DISPLAY_MODE
  170.   //                              PMBROWSE_HEX_DISPLAY_MODE
  171.   //      PSHORT psTotalLines   - Return total number of lines.
  172.   //      PSHORT psTotalColumns - Return maximum number of columns.
  173.   //      USHORT usNumberOfTextLines - The total number of text lines.
  174.   //      USHORT usNumberOfTextColumns - The maximum number of text columns.
  175.   //      ULONG  ulFileLength   - The length of file.
  176.   //
  177.   // RETURN:
  178.   //
  179.   //      N/A
  180.   //
  181.  
  182.   BOOL GetObjectName(in HWND hwnd,
  183.                      inout PSZ ppszObjectName);
  184.  
  185.   //
  186.   // METHOD: GetObjectName                                  ( ) PRIVATE
  187.   //                                                        (X) PUBLIC
  188.   // DESCRIPTION:
  189.   //
  190.   //   Prompts the user to enter the name of the object.
  191.   //
  192.   //      HWND   hwnd           - Handle to frame window.
  193.   //      PSZ*   ppszObjectName - Address of pointer for object name.
  194.   //
  195.   // RETURN:
  196.   //
  197.   //      TRUE  - The user selected an valid file.
  198.   //      FALSE - The user selected cancel.
  199.   //
  200.  
  201.   UINT GetTextLine(in USHORT usLine,
  202.                    inout LINERECORD pLines,
  203.                    in PSZ pszText);
  204.  
  205.   //
  206.   // METHOD: GetTextLine                                    ( ) PRIVATE
  207.   //                                                        (X) PUBLIC
  208.   // DESCRIPTION:
  209.   //
  210.   //   Copies a line of text from the object to a buffer.
  211.   //
  212.   //      USHORT      usLine  - The number of the line to get.
  213.   //      LINERECORD* pLines  - Pointer to the line record array.
  214.   //      PSZ         pszText - Buffer to store the text in.
  215.   //
  216.   // RETURN:
  217.   //
  218.   //      The length of the line to display.
  219.   //
  220.  
  221.   BOOL LoadObject(in PSZ pszObjectName,
  222.                   in PULONG pulLength,
  223.                   inout PBYTE ppBuffer,
  224.                   inout LINERECORD *ppLines,
  225.                   in PUSHORT pusNumberOfTextLines,
  226.                   in PUSHORT pusNumberOfTextColumns);
  227.  
  228.   //
  229.   // METHOD: LoadObject                                     ( ) PRIVATE
  230.   //                                                        (X) PUBLIC
  231.   // DESCRIPTION:
  232.   //
  233.   //   Loads a file into memory and determines the number of text line and
  234.   //   maximum number of text columns.
  235.   //
  236.   //      PSZ     pszObjectName  - Name of the file to load.
  237.   //      PULONG  pulLength      - returns the length of the file.
  238.   //      PBYTE*  ppBuffer       - returns a pointer to the file in memory.
  239.   //      LINERECORD** pLines    - returns a pointer to a line record array.
  240.   //      PUSHORT pusNumberOfTextLines   - returns the number of text lines.
  241.   //      PUSHORT pusNumberOfTextColumns - returns the maximum number of text
  242.   //                                                                     columns.
  243.   //
  244.   // RETURN:
  245.   //
  246.   //      N/A
  247.   //
  248.  
  249.   VOID ProductInformationView();
  250.  
  251.   //
  252.   // METHOD: ProductInformationView                         ( ) PRIVATE
  253.   //                                                        (X) PUBLIC
  254.   // DESCRIPTION:
  255.   //
  256.   //   Displays the product information view.
  257.   //
  258.   // RETURN:
  259.   //
  260.   //      N/A
  261.   //
  262.  
  263.   VOID UnloadObject(in PBYTE pBuffer,
  264.                     inout LINERECORD pLines);
  265.  
  266.   //
  267.   // METHOD: UnloadObject                                   ( ) PRIVATE
  268.   //                                                        (X) PUBLIC
  269.   // DESCRIPTION:
  270.   //
  271.   //   Unloads a file that was loaded. The buffer file and the LINERECORD array
  272.   //   are freed.
  273.   //
  274.   //      PBYTE      ppBuffer - a pointer to the file in memory.
  275.   //      LINERECORD pLines   - a pointer to a line record array.
  276.   //
  277.   // RETURN:
  278.   //
  279.   //      N/A
  280.   //
  281.  
  282.  
  283.  
  284. #ifdef __SOMIDL__
  285.   implementation {
  286.  
  287.     releaseorder: BrowseOMatic,DuplicateString,ErrorHandler,FileExists,
  288.                   GetHexLine,GetLinesAndColumns,GetObjectName,GetTextLine,
  289.                   LoadObject,UnloadObject,ProductInformationView;
  290.  
  291.     //# Class Modifiers
  292.     externalstem   = Browse_O_Maticwps;
  293.     externalprefix = Browse_O_Maticwps_;
  294.     majorversion = 1;
  295.     minorversion = 2;
  296.     filestem = browse;
  297.     metaclass = M_Browse_O_Matic;
  298.     callstyle = oidl;
  299.  
  300.     passthru C_ih =     ""
  301. "        #define   INCL_WIN"
  302. "        #define   INCL_DOS"
  303. "        #define   INCL_DOSERRORS"
  304. "        #define   INCL_DOSMODULEMGR"
  305. "        #define   INCL_WINSTDDRG"
  306. "        #define   INCL_WPCLASS"
  307. "        #include  <os2.h>"
  308. ""
  309. "        #include  <stdio.h>"
  310. "        #include  <stdlib.h>"
  311. "        #include  <string.h>"
  312. ""
  313. "        #define   HELP_FILE     \"browse.hlp\""
  314. ""
  315. "        /* The number of bytes to display and the length of each line  */"
  316. "        /* (text format) displayed for Hex display format.             */"
  317. "        #define  HEX_LINE_LENGTH      69"
  318. "        #define  HEX_BYTES_PER_LINE   (4 * sizeof( LONG))"
  319. ""
  320. "        #define  MAX_LINE_LENGTH      255  /* Maximum length of a text line. */"
  321. "                                           /* Lines longer than this value   */"
  322. "                                           /* only display the first         */"
  323. "                                           /* MAX_LINE_LENGTH characters.    */"
  324. ""
  325. "        /*****************************/"
  326. "        /* Text object record format */"
  327. "        /*****************************/"
  328. "        typedef  struct   _LINERECORD"
  329. "        {"
  330. "           PSZ   pszLine;       /* Pointer to beginning of each line of text */"
  331. "           UINT  unLength;      /* The length of each line of text */"
  332. ""
  333. "        } LINERECORD;"
  334. "        typedef LINERECORD     *PLINERECORD; /* AMC 050494 */"
  335. "";
  336.  
  337. #ifdef __PRIVATE__
  338.     passthru C_h_after =      ""
  339. "        /*************************/"
  340. "        /* Main View window data */"
  341. "        /*************************/"
  342. ""
  343. "        typedef struct _BROWSEDATA"
  344. "        {"
  345. "                USHORT          cb;            /* Size of _BROWSEDATA struct */"
  346. ""
  347. "                Browse_O_Matic* somSelf;       /* Pointer to instance */"
  348. "                USEITEM         UseItem;       /* Use Item structure */"
  349. "                VIEWITEM        ViewItem;      /* Open view structure */"
  350. ""
  351. "                BOOL            bDisplay;      /* Display mode (Text/Hex) */"
  352. "                PSZ             pszObjectName; /* Name of object displayed */"
  353. "                PSZ             pszApplKey;    /* Key used to save window  */"
  354. "                                               /* coordinates */"
  355. ""
  356. "                SHORT           sCurrentLine;  /* Current line displayed */"
  357. "                SHORT           sPageHeight;   /* Height of window in lines */"
  358. "                SHORT           sTotalLines;   /* Total lines of object */"
  359. "                SHORT           sCurrentColumn;/* The left most column being */"
  360. "                                               /* displayed */"
  361. "                SHORT           sPageWidth;    /* Width of window in columns */"
  362. "                SHORT           sTotalColumns; /* Total columns of object */"
  363. "                SHORT           sCharWidth;    /* Width from FONTMETRICS */"
  364. "                SHORT           sCharHeight;   /* Height from FONTMETRICS */"
  365. "                SHORT           sCharDescender;/* Descender from FONTMETRICS */"
  366. "                SHORT           sClientHeight; /* Height of client window */"
  367. "                SHORT           sClientWidth;  /* Width of client window */"
  368. ""
  369. "                HWND            hwndVscroll;   /* Verticle Scroll Bar */"
  370. "                HWND            hwndHscroll;   /* Horizontal Scroll Bar */"
  371. ""
  372. "                LINERECORD*     pLines;        /* Text line array structure */"
  373. "                PBYTE           pBuffer;       /* Pointer to object in memory*/"
  374. "                USHORT          usNumberOfTextColumns; /* Maximum number of *"
  375. "                                               /* text columns in single line*/"
  376. "                USHORT          usNumberOfTextLines; /* Maximum number of lines"
  377. "                                               /* of object displayed as text*/"
  378. "                ULONG           ulFileLength;  /* Length of file system object*/"
  379. ""
  380. "        } BROWSEDATA;"
  381. ""
  382. "        typedef BROWSEDATA *PBROWSEDATA;"
  383. ""
  384. "        /****************************************/"
  385. "        /* Product Information View window data */"
  386. "        /****************************************/"
  387. "        typedef struct _PRODINFODATA"
  388. "        {"
  389. "                USHORT          cb;          /* Size of _PRODINFODATA struct */"
  390. ""
  391. "                Browse_O_Matic* somSelf;     /* Pointer to instance */"
  392. "                USEITEM         UseItem;     /* Use Item structure */"
  393. "                VIEWITEM        ViewItem;    /* Open view structure */"
  394. ""
  395. "        } PRODINFODATA;"
  396. ""
  397. "        typedef PRODINFODATA *PPRODINFODATA;"
  398. "";
  399. #endif /*__PRIVATE__ */
  400.  
  401.  
  402.     //# Method Modifiers
  403.     wpDragOver: override;
  404.     wpDrop: override;
  405.     wpMenuItemHelpSelected: override;
  406.     wpMenuItemSelected: override;
  407.     wpModifyPopupMenu: override;
  408.     wpOpen: override;
  409.     wpSetup: override;
  410.  
  411.   };
  412. #endif /* __SOMIDL__ */
  413. };
  414.  
  415. interface M_Browse_O_Matic
  416. {
  417.   HMODULE clsQueryModuleHandle();
  418.  
  419.   //
  420.   // METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  421.   //                                                        (X) PUBLIC
  422.   // DESCRIPTION:
  423.   //
  424.   //   Gets the module handle.
  425.   //
  426.   // RETURN:
  427.   //      NULLHANDLE     - an error occured.
  428.   //      Not NULLHANDLE - The handle for DLL containing the Browse_O_Matic
  429.   //                       class.
  430.   //
  431.  
  432.  
  433.  
  434. #ifdef __SOMIDL__
  435.   implementation {
  436.  
  437.     releaseorder: clsQueryModuleHandle;
  438.  
  439.     //# Class Modifiers
  440.     externalstem   = Browse_O_Maticwps;
  441.     externalprefix = Browse_O_MaticM_;
  442.     functionprefix = Browse_O_MaticM_;
  443.     majorversion = 1;
  444.     minorversion = 2;
  445.     filestem = browse;
  446.     callstyle = oidl;
  447.  
  448.     //# Method Modifiers
  449.     wpclsInitData: override;
  450.     wpclsQueryDefaultHelp: override;
  451.     wpclsQueryDefaultView: override;
  452.     wpclsQueryIconData: override;
  453.     wpclsQueryStyle: override;
  454.     wpclsQueryTitle: override;
  455.  
  456.   };
  457. #endif /* __SOMIDL__ */
  458. };
  459.  
  460. #endif  /* browse_idl */
  461.