home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xwplascr.zip / XWPL0208.ZIP / idl / __sample_dataf.idl next >
Text File  |  2001-10-13  |  9KB  |  238 lines

  1.  
  2. /*
  3.  * __sample.idl:
  4.  *      Sample IDL file for adding a new class to XWorkplace.
  5.  *      This is for a WPDataFile subclass called SampleDataFile.
  6.  *
  7.  *      To adjust this to your needs, do the following:
  8.  *
  9.  *      -- Modify all the sections marked with "&&&".
  10.  *
  11.  *      -- Search and replace "SampleDataFile" with your class
  12.  *         name. For a PDF subclass, replace with "XWPPdf", for example.
  13.  *
  14.  *      -- Search and replace "WPDataFile" with the class which
  15.  *         should be the parent class of your class. Take WPFolder
  16.  *         if you're creating a WPFolder subclass, for example.
  17.  *
  18.  *      To add this class into the XWorkplace makefile system to have
  19.  *      all necessary source files produced, see PROGREF.INF, "Adding
  20.  *      Features to XWorkplace", which gives you instructions.
  21.  */
  22.  
  23. /*
  24.  *      Copyright (C) 2000 Ulrich Möller.
  25.  *      This file is part of the XWorkplace source package.
  26.  *      XWorkplace is free software; you can redistribute it and/or modify
  27.  *      it under the terms of the GNU General Public License as published
  28.  *      by the Free Software Foundation, in version 2 as it comes in the
  29.  *      "COPYING" file of the XWorkplace main distribution.
  30.  *      This program is distributed in the hope that it will be useful,
  31.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  32.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  33.  *      GNU General Public License for more details.
  34.  */
  35.  
  36. #include <wpdataf.idl>
  37.             // this is SOM for WPDataFile from the Toolkit headers;
  38.             // &&& you must include the IDL file of the parent class
  39.             // of your class here. The IDL file name is specified in
  40.             // "WPS Object Classes" in the WPS Programming Reference.
  41.  
  42. /*
  43.    CLASS: SampleDataFile
  44.  
  45.    CLASS HIERARCHY:
  46.  
  47.        SOMObject
  48.          └── WPObject
  49.                └── WPFileSystem
  50.                      └── WPDataFile
  51.                            └── SampleDataFile
  52. */
  53.  
  54. interface M_SampleDataFile;             //# forward reference to metaclass
  55.  
  56. interface SampleDataFile : WPDataFile   //# &&& SampleDataFile is a WPDataFile subclass
  57. {
  58.  
  59.     /*
  60.      * New instance methods for SampleDataFile:
  61.      *      none presently. If you wish to add methods,
  62.      *      specify them here. See xfldr.idl for examples.
  63.      */
  64.  
  65. #ifdef __SOMIDL__
  66.   implementation {
  67.  
  68.     //# Class modifiers:
  69.     //#     these are special SOM compiler keywords which are
  70.     //#     somewhat magic. These must be specified, or the
  71.     //#     SOM compiler will produce garbage.
  72.  
  73.     externalprefix = sdf_;              //# &&& prefix for all the function names generated
  74.                                         //# by the SOM compiler; this must be unique among
  75.                                         //# all XWorkplace classes!
  76.     externalstem = sdf;                 //# &&& same as above, without "_"
  77.     majorversion = 1;
  78.     minorversion = 1;
  79.     filestem = spldataf;                //# &&& specifies the filestem for files generated
  80.                                         //# by the SOM compiler (e.g. spldataf.h, spldataf.ih,
  81.                                         //# spldataf.c)
  82.     metaclass = M_SampleDataFile;
  83.     dllname = "xfldr.dll";              //# target DLL, do not modify
  84.     callstyle = oidl;                   //# forget CORBA stuff (*ev and such)
  85.  
  86.     /*
  87.      * Internal instance variables for SampleDataFile:
  88.      *      every instance of this class will have variables
  89.      *      (same as member variables in C++). These can be
  90.      *      accessed using the variable name here prefixed
  91.      *      with an underscore. For example, use "_fSampleBOOL"
  92.      *      in your C code.
  93.      *
  94.      *      If your class defines instance variables, you need to
  95.      *      override the following methods:
  96.      *
  97.      *      -- wpInitData must initialize the variable to something,
  98.      *         or its value will be undefined. This method can be
  99.      *         considered a constructor.
  100.      *
  101.      *      -- If you allocated memory, wpUnInitData must clean up.
  102.      *         This is the equivalent of a destructor.
  103.      *
  104.      *      -- If you want a WPS setup string for this instance
  105.      *         variable, wpSetup must parse the setup string, set
  106.      *         the variable, and update open views of the object.
  107.      *
  108.      *      -- If the value of the variable is to be persistent
  109.      *         between Desktop restarts, wpSaveState and wpRestoreState
  110.      *         must save and restore the value to the object's
  111.      *         persistent data. Where this data is stored depends
  112.      *         on the class's descendant; subclasses of WPAbstract
  113.      *         will use OS2.INI, subclasses of WPFileSystem will
  114.      *         use the .CLASSINFO extended attribute.
  115.      */
  116.  
  117.     BOOL    fSampleBOOL;
  118.  
  119.     /*
  120.      * WPDataFile methods overridden by SampleDataFile
  121.      *      (typical methods listed here):
  122.      *
  123.      *      for each of these methods, the SOM compiler will
  124.      *      generate an empty function stub in the C source
  125.      *      file which you must then fill in to make it do
  126.      *      anything meaningful.
  127.      */
  128.  
  129.     wpInitData: override;
  130.     wpSetup: override;
  131.     wpUnInitData: override;
  132.  
  133.     wpSaveState: override;
  134.     wpRestoreState: override;
  135.  
  136.     wpFilterPopupMenu: override;
  137.     wpModifyPopupMenu: override;
  138.     wpMenuItemSelected: override;
  139.     wpMenuItemHelpSelected: override;
  140.  
  141. #ifdef __PRIVATE__
  142.  
  143. #endif
  144.  
  145.   }; // implementation
  146. #endif /* __SOMIDL__ */
  147. };
  148.  
  149. //#
  150. //#
  151. //# Now define Metaclass.
  152. //# ---------------------
  153. //#
  154. //#     This is a bit difficult. With SOM, classes are objects
  155. //#     too. This is what allows the WPS to work on classes at
  156. //#     runtime in the first place. As a result, every class
  157. //#     must have a metaclass. As opposed to C++, where you have
  158. //#     a static class (which doesn't "exist" an runtime) and
  159. //#     objects (which "exist" at runtime), in SOM you get this:
  160. //#
  161. //#         object
  162. //#                 is instance of
  163. //#         class ("class object")
  164. //#                 is instance of
  165. //#         metaclass
  166. //#
  167. //#     With WPDataFile, this looks like the following:
  168. //#
  169. //#         sample.txt
  170. //#                 is instance of
  171. //#         WPDataFile (class object)
  172. //#                 is instance of
  173. //#         M_WPDataFile (metaclass)
  174. //#
  175. //#     When the WPS is initialized, all classes on the WPS class
  176. //#     list are created as "class objects". Every time the WPS
  177. //#     instantiates an object (e.g. during folder population),
  178. //#     it creates it according to its class object, by invoking
  179. //#     the wpclsNew or wpclsMakeAwake class methods.
  180. //#
  181. //#     Both classes and metaclasses have methods:
  182. //#
  183. //#     --  Instance methods belong to a class and operate on a
  184. //#         Desktop object. For example, wpQueryTitle gets the title
  185. //#         of a Desktop object. The WPS prefixes all instance methods
  186. //#         with "wp".
  187. //#
  188. //#     --  Class methods belong to a metaclass and operate on a
  189. //#         class object. For example, wpclsQueryTitle gets the
  190. //#         default title for objects of a class. The WPS prefixes
  191. //#         all class methods with "wpcls".
  192.  
  193. interface M_SampleDataFile : M_WPDataFile
  194. {
  195.  
  196.     /*
  197.      * New class methods  for M_SampleDataFile:
  198.      *
  199.      */
  200.  
  201. #ifdef __SOMIDL__
  202.   implementation {
  203.  
  204.     //# Class Modifiers
  205.     externalprefix = sdfM_;         //# &&& same prefix as above, but add "M" for the metaclass
  206.     externalstem = sdfM;            //# &&&
  207.     functionprefix = sdfM_;         //# &&&
  208.     majorversion = 1;
  209.     minorversion = 1;
  210.     filestem = spldataf;            //# must be same as above
  211.     dllname = "xfldr.dll";          //# target DLL, do not modify
  212.     callstyle = oidl;
  213.  
  214.     /*
  215.      * Internal class variables for M_SampleDataFile:
  216.      *      similar to objects (as defined by the class),
  217.      *      classes can have member variables also (defined
  218.      *      by the metaclass). List them here as with the
  219.      *      class definition (above).
  220.      */
  221.  
  222.     /*
  223.      * M_WPDataFile methods overridden by M_SampleDataFile:
  224.      *
  225.      */
  226.  
  227.     wpclsInitData: override;
  228.     wpclsQueryTitle: override;
  229.  
  230.     wpclsQueryInstanceFilter: override;
  231.     wpclsQueryInstanceType: override;
  232.  
  233.   };
  234. #endif /* __SOMIDL__ */
  235. };
  236.  
  237.  
  238.