home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / toolkit / wps / carpp / carpp.idl < prev    next >
Text File  |  1996-11-19  |  13KB  |  396 lines

  1. /*
  2.  *   Module Name: CARPP
  3.  *
  4.  *   OS/2 WorkPlace Shell Sample Program - SOM 2.0 / IDL Version
  5.  *
  6.  *   Copyright (C) 1992-1995 IBM Corporation
  7.  *
  8.  *       DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  9.  *       sample code created by IBM Corporation. This sample code is not
  10.  *       part of any standard or IBM product and is provided to you solely
  11.  *       for  the purpose of assisting you in the development of your
  12.  *       applications.  The code is provided "AS IS", without
  13.  *       warranty of any kind.  IBM shall not be liable for any damages
  14.  *       arising out of your use of the sample code, even if they have been
  15.  *       advised of the possibility of such damages.
  16.  */
  17.  
  18. #ifndef carpp_idl
  19. #define carpp_idl
  20.  
  21. #include <wpdataf.idl>
  22. #include <somcls.idl>
  23.  
  24. interface Brake;
  25. interface Horn;
  26. interface RPM;
  27.  
  28. interface M_Carpp;
  29.  
  30. // CLASS: Carpp
  31. //
  32. // CLASS HIERARCHY:
  33. //
  34. //     SOMObject
  35. //       └── WPObject
  36. //             └── WPFileSystem
  37. //                   └── WPDataFile
  38. //                         └──  Carpp
  39. //
  40. // DESCRIPTION:
  41. //
  42. //    This is the sample Carpp object class.
  43. //
  44. //    An instance of this class can be created as a Workplace object.
  45. //
  46. interface Carpp : WPDataFile
  47. {
  48.    ULONG AddDashboardPage(in HWND hwndNotebook);
  49.    //
  50.    // METHOD: AddDashboardPage                               ( ) PRIVATE
  51.    //                                                        (X) PUBLIC
  52.    // DESCRIPTION:
  53.    //
  54.    //   This method adds the dashboard page to the settings notebook.
  55.    //
  56.    // RETURN:
  57.    //
  58.    //   0              Unsuccessful
  59.    //   ulPageId       Identifier for the inserted page
  60.    //
  61.    // HOW TO OVERRIDE:
  62.    //
  63.    //   Method should always be overridden in order to replace or remove
  64.    //   the dashboard page from an object which is a descendant of Car.
  65.    //   In most cases, an override of this method will not call the parent.
  66.  
  67.    ULONG AddHornBeepPage(in HWND hwndNotebook);
  68.    //
  69.    // METHOD: AddHornBeepPage                                ( ) PRIVATE
  70.    //                                                        (X) PUBLIC
  71.    // DESCRIPTION:
  72.    //
  73.    //   This method adds the horn beep page to the settings
  74.    //   notebook.
  75.    //
  76.    // RETURN:
  77.    //
  78.    //   0              Unsuccessful
  79.    //   ulPageId       Identifier for the inserted page
  80.    //
  81.    // HOW TO OVERRIDE:
  82.    //
  83.    //   Method should always be overridden in order to replace or remove
  84.    //   the horn beep page from an object which is a descendant of Car.
  85.    //   In most cases, an override of this method will not call the parent.
  86.  
  87.    VOID TrapTest();
  88.    //
  89.    // METHOD: TrapTest                                       ( ) PRIVATE
  90.    //                                                        (X) PUBLIC
  91.    // DESCRIPTION:
  92.    //
  93.    //   This method tests the exception handling in this sample.
  94.    //
  95.    // RETURN:
  96.    //
  97.    //   nothing
  98.    //
  99.    // HOW TO OVERRIDE:
  100.    //
  101.    //   n/a
  102.    //
  103.    //
  104.    //   Methods from the WPObject class
  105.  
  106.    #ifdef __SOMIDL__
  107.    implementation
  108.    {
  109.       releaseorder: AddDashboardPage,AddHornBeepPage,TrapTest;
  110.  
  111.       /*
  112.        * Class Modifiers
  113.        */
  114.       externalstem   = carpp;
  115.       externalprefix = carpp_;
  116.       majorversion   = 1;
  117.       minorversion   = 2;
  118.       filestem       = carpp;
  119.       metaclass      = M_Carpp;
  120.       callstyle      = oidl;
  121.  
  122.       passthru C_xih_before =  ""
  123. "   #define INCL_WIN"
  124. "   #define INCL_DOS"
  125. "   #define INCL_GPIBITMAPS"
  126. "   #define INCL_DOSERRORS"
  127. "   #include <os2.h>"
  128. ""
  129. "   #define INCL_WPCLASS"
  130. "   #define INCL_WPFOLDER"
  131. "   #include <pmwp.h>"
  132. ""
  133. "   #define ID_TITLE              100"
  134. "   #define ID_ICON               101 "
  135. ""
  136. "   #define IDD_DASHBOARD         200                   /* settings page (dialog) */"
  137. "   #define IDD_HORNBEEP          202 "
  138. "   #define IDD_DASHBOARD2       1200                   /* settings page (dialog) */"
  139. "   #define IDD_HORNBEEP2        1202 "
  140. ""
  141. "   /*"
  142. "    *   The following user-defined Popup menu items (ID_xxx) should be higher"
  143. "    *   than WPMENUID_USER."
  144. "    *"
  145. "    *   The ID_OPENMENU will become a submenu of the system's popup open menu"
  146. "    *   id, WPMENUID_OPEN."
  147. "    */"
  148. "   #define ID_BEEPMENU          (WPMENUID_USER+1)  /* menus added to popup menu */"
  149. "   #define ID_OPENMENU          (WPMENUID_USER+2) "
  150. "   #define ID_TRAPMENU          (WPMENUID_USER+3) "
  151. ""
  152. "   #define IDM_OPENCAR          (WPMENUID_USER+4)  /* submenus of added menus */"
  153. "   #define IDM_BEEPHORN         (WPMENUID_USER+5) "
  154. "   #define IDM_TRAPCAR          (WPMENUID_USER+6) "
  155. ""
  156. "   #define IDMSG_ACCESS_VIOLATION    100 "
  157. "   #define IDM_MSGBOX                999"
  158. ""
  159. "   #define ID_FRAME                  3000                        /* client window id */"
  160. "   #define ID_CLIENT                 3001                        /* client window id */"
  161. ""
  162. "   /*"
  163. "    *   Set unique view ids."
  164. "    */"
  165. "   #define OPEN_CAR             IDM_OPENCAR "
  166. ""
  167. "   #define CAR_TIMER            1001                               /* timer id */ "
  168. ""
  169. "   /*"
  170. "    *   IDs of dialog items in CARPP.RC"
  171. "    */"
  172. "   #define ID_UNDO                  801 "
  173. "   #define ID_DEFAULT               802 "
  174. "   #define ID_HELP                  803 "
  175. "   #define ID_HITONE                804 "
  176. "   #define ID_LOTONE                805"
  177. "   #define ID_SPEEDSLIDER           806"
  178. "   #define ID_STOP                  807"
  179. "   #define ID_SPEEDDATA             808"
  180. "   #define ID_GO                    809 "
  181. ""
  182. "   /*"
  183. "    *  Keys for save-restore methods"
  184. "    */"
  185. "   #define IDKEY_HITONE            1 "
  186. "   #define IDKEY_LOTONE            2 "
  187. "   #define IDKEY_DURATION          3"
  188. "   #define IDKEY_RPM               4"
  189. "   #define IDKEY_BRAKEFLAG         5"
  190. ""
  191. "   /*"
  192. "    *   Default values of instance data items"
  193. "    */"
  194. "   #define DEFAULT_DURATION          300"
  195. "   #define DEFAULT_HITONE            400 "
  196. "   #define DEFAULT_LOTONE            400 "
  197. "   #define DEFAULT_RPM               50"
  198. "   #define DEFAULT_BRAKEFLAG         FALSE"
  199. ""
  200. "   /*"
  201. "    *   Help IDs"
  202. "    */"
  203. "   #define ID_HELP_DEFAULT        256 "
  204. "   #define ID_HELP_DASHBOARD      257 "
  205. "   #define ID_HELP_OPENCAR        258 "
  206. "   #define ID_HELP_HORNBEEP       259 "
  207. "   #define ID_HELP_BEEPHORN       260 "
  208. "   #define ID_HELP_TRAPCAR        261 "
  209. ""
  210. "   /*"
  211. "    *   Indexes into CARDETAILS information. (arrays)"
  212. "    */"
  213. "   #define  INDEX_MAKE               0 "
  214. "   #define  INDEX_MODEL              1 "
  215. "   #define  INDEX_COLOR              2 "
  216. "   #define  INDEX_SALE_DATE          3"
  217. "   #define  INDEX_PRICE              4 "
  218. ""
  219. "   /*"
  220. "    *   These defines are used as directional multipliers against x,y position."
  221. "    */"
  222. "   #define CAR_LEFT       -1 "
  223. "   #define CAR_RIGHT       1 "
  224. "   #define CAR_DOWN       -1"
  225. "   #define CAR_UP          1 "
  226. ""
  227. "   #define ICON_WIDTH     32      /* pels */"
  228. "   #define ICON_HEIGHT    32      /* pels */"
  229. "";
  230.  
  231.       passthru C_xih_after =  ""
  232. "   /*********************************************************************/"
  233. "   /* Include the header files for the components of the car                                    */"
  234. "   /*********************************************************************/"
  235. ""
  236. "   #include \"horn.h\""
  237. "   #include \"brake.h\""
  238. "   #include \"rpm.h\""
  239. ""
  240. "   /*"
  241. "    *   CARDETAILS:  Structure used for details view"
  242. "    */"
  243. "   typedef struct _CARDETAILS"
  244. "   {"
  245. "      PSZ     pszMake;     /* Manufacturer      */"
  246. "      PSZ     pszModel;    /* Model             */"
  247. "      PSZ     pszColor;    /* Color of car      */"
  248. "      CDATE   cdateSale;   /* Date of sale      */"
  249. "      ULONG   ulPrice;     /* Price in dollars  */"
  250. "   } CARDETAILS;"
  251. "   typedef CARDETAILS *PCARDETAILS;"
  252. ""
  253. "   /*"
  254. "    *   The following structures will be used to store window specific data"
  255. "    *   and a pointer to the object that created the window/dialog."
  256. "    *"
  257. "    *   They're allocated when the Client window is created.  This"
  258. "    *   allows us to pass the *somSelf pointer and use it in our"
  259. "    *   window and dialog procedures (the system only passes this"
  260. "    *   pointer to methods)."
  261. "    */"
  262. "   typedef struct _WINDOWDATA"
  263. "   {"
  264. "      USHORT   cb;            /* size of this structure */"
  265. "      Carpp     *somSelf;       /* pointer to this instance */"
  266. "      USEITEM  UseItem;       /* global class usage information */"
  267. "      VIEWITEM ViewItem;      /* global class view information */"
  268. "      LONG     x;             /* x position of car in open view */"
  269. "      LONG     y;             /* y position of car in open view */"
  270. "      LONG     xDir;          /* x direction (CAR_LEFT or CAR_RIGHT) */"
  271. "      LONG     yDir;          /* y direction (CAR_UP or CAR_DOWN) */"
  272. "   } WINDOWDATA;"
  273. "   typedef WINDOWDATA *PWINDOWDATA;"
  274. ""
  275. "   /*"
  276. "    *   Window data for the Dashboard dialog (settings page)"
  277. "    */"
  278. "   typedef struct _DASHDLGDATA"
  279. "   {"
  280. "      USHORT   cb;            /* size of this structure */"
  281. "      Carpp    *somSelf;        /* pointer to this instance         */"
  282. "      BOOL    PrevBrakes;     /* indicates if car is stopped      */"
  283. "      ULONG   PrevSpeed;      /* Speed car moves across screen    */"
  284. "   } DASHDLGDATA;"
  285. "   typedef DASHDLGDATA *PDASHDLGDATA;"
  286. ""
  287. "   /*"
  288. "    *   Window data for the Horn dialog (settings page)"
  289. "    */"
  290. "   typedef struct _HORNDLGDATA"
  291. "   {"
  292. "      USHORT   cb;            /* size of this structure */"
  293. "      Carpp    *somSelf;        /* pointer to this instance         */"
  294. "      ULONG   PrevDuration;   /* Duration of the car's horn beep  */"
  295. "      ULONG   PrevHighTone;   /* The high note of the car beep    */"
  296. "      ULONG   PrevLowTone;    /* The low note of the car beep     */"
  297. "   } HORNDLGDATA;"
  298. "   typedef HORNDLGDATA *PHORNDLGDATA;"
  299. ""
  300. "   /*"
  301. "    *   Private Debug helpers go here.  They can be enabled/disabled by"
  302. "    *   defining DEBUG as a compiler directive."
  303. "    */"
  304. "   #if defined(DEBUG)"
  305. ""
  306. "      #define DebugBox(title, text) \"
  307. "                                    \"
  308. "                 WinMessageBox(     \"
  309. "                    HWND_DESKTOP,   \"
  310. "                    HWND_DESKTOP,   \"
  311. "                    (PSZ) text,     \"
  312. "                    (PSZ) title,    \"
  313. "                    20,             \"
  314. "                    MB_OK | MB_INFORMATION | MB_MOVEABLE)"
  315. "   #else"
  316. "      #define DebugBox(title, text)   /* do nothing if not debugging */"
  317. "   #endif"
  318. "";
  319.  
  320.       /*
  321.        * Internal Instance Variables
  322.        */
  323.       Brake carBrake;
  324.       Horn  carHorn;
  325.       RPM   carRPM;
  326.  
  327.       /*
  328.        * Method Modifiers
  329.        */
  330.       wpInitData:                      override;
  331.       wpUnInitData:                    override;
  332.       wpSaveState:                     override;
  333.       wpRestoreState:                  override;
  334.       wpAddSettingsPages:              override;
  335.       wpFilterPopupMenu:               override;
  336.       wpModifyPopupMenu:               override;
  337.       wpMenuItemSelected:              override;
  338.       wpMenuItemHelpSelected:          override;
  339.       wpQueryDetailsData:              override;
  340.       wpOpen:                          override;
  341.       wpSetup:                         override;
  342.    };
  343.    #endif /* __SOMIDL__ */
  344. };
  345.  
  346. interface M_Carpp
  347. {
  348.    HMODULE clsQueryModuleHandle();
  349.    // METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  350.    //                                                        (X) PUBLIC
  351.    // DESCRIPTION:
  352.    //
  353.    //   This method returns the module handle of this class.  If this is the
  354.    //   first invocation, DosQueryModuleHandle is called to save the handle
  355.    //   for future invocations.
  356.    //
  357.    // RETURN:
  358.    //
  359.    //   0              Unsuccessful
  360.    //   non-zero       module handle
  361.  
  362.    #ifdef __SOMIDL__
  363.    implementation
  364.    {
  365.       releaseorder: clsQueryModuleHandle;
  366.  
  367.       /*
  368.        * Class Modifiers
  369.        */
  370.       externalstem   = carpp;
  371.       externalprefix = carppM_;
  372.       functionprefix = carppM_;
  373.       majorversion   = 1;
  374.       minorversion   = 2;
  375.       filestem       = carpp;
  376.       callstyle      = oidl;
  377.  
  378.       /*
  379.        * Method Modifiers
  380.        */
  381.       wpclsInitData:                   override;
  382.       wpclsUnInitData:                 override;
  383.       wpclsQueryTitle:                 override;
  384.       wpclsQueryIconData:              override;
  385.       wpclsQueryDefaultHelp:           override;
  386.       wpclsQueryDefaultView:           override;
  387.       wpclsQueryDetailsInfo:           override;
  388.       wpclsQueryDetails:               override;
  389.       wpclsQueryInstanceFilter:        override;
  390.       wpclsQueryStyle:                 override;
  391.    };
  392.    #endif /* __SOMIDL__ */
  393. };
  394.  
  395. #endif  /* carpp_idl */
  396.