home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / SAMPLES / WPS / CARPP / CARPP.IDL < prev    next >
Text File  |  1995-08-24  |  13KB  |  394 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. ""
  139. "   /*"
  140. "    *   The following user-defined Popup menu items (ID_xxx) should be higher"
  141. "    *   than WPMENUID_USER."
  142. "    *"
  143. "    *   The ID_OPENMENU will become a submenu of the system's popup open menu"
  144. "    *   id, WPMENUID_OPEN."
  145. "    */"
  146. "   #define ID_BEEPMENU          (WPMENUID_USER+1)  /* menus added to popup menu */"
  147. "   #define ID_OPENMENU          (WPMENUID_USER+2) "
  148. "   #define ID_TRAPMENU          (WPMENUID_USER+3) "
  149. ""
  150. "   #define IDM_OPENCAR          (WPMENUID_USER+4)  /* submenus of added menus */"
  151. "   #define IDM_BEEPHORN         (WPMENUID_USER+5) "
  152. "   #define IDM_TRAPCAR          (WPMENUID_USER+6) "
  153. ""
  154. "   #define IDMSG_ACCESS_VIOLATION    100 "
  155. "   #define IDM_MSGBOX                999"
  156. ""
  157. "   #define ID_FRAME                  3000                        /* client window id */"
  158. "   #define ID_CLIENT                 3001                        /* client window id */"
  159. ""
  160. "   /*"
  161. "    *   Set unique view ids."
  162. "    */"
  163. "   #define OPEN_CAR             IDM_OPENCAR "
  164. ""
  165. "   #define CAR_TIMER            1001                               /* timer id */ "
  166. ""
  167. "   /*"
  168. "    *   IDs of dialog items in CARPP.RC"
  169. "    */"
  170. "   #define ID_UNDO                  801 "
  171. "   #define ID_DEFAULT               802 "
  172. "   #define ID_HELP                  803 "
  173. "   #define ID_HITONE                804 "
  174. "   #define ID_LOTONE                805"
  175. "   #define ID_SPEEDSLIDER           806"
  176. "   #define ID_STOP                  807"
  177. "   #define ID_SPEEDDATA             808"
  178. "   #define ID_GO                    809 "
  179. ""
  180. "   /*"
  181. "    *  Keys for save-restore methods"
  182. "    */"
  183. "   #define IDKEY_HITONE            1 "
  184. "   #define IDKEY_LOTONE            2 "
  185. "   #define IDKEY_DURATION          3"
  186. "   #define IDKEY_RPM               4"
  187. "   #define IDKEY_BRAKEFLAG         5"
  188. ""
  189. "   /*"
  190. "    *   Default values of instance data items"
  191. "    */"
  192. "   #define DEFAULT_DURATION          300"
  193. "   #define DEFAULT_HITONE            400 "
  194. "   #define DEFAULT_LOTONE            400 "
  195. "   #define DEFAULT_RPM               50"
  196. "   #define DEFAULT_BRAKEFLAG         FALSE"
  197. ""
  198. "   /*"
  199. "    *   Help IDs"
  200. "    */"
  201. "   #define ID_HELP_DEFAULT        256 "
  202. "   #define ID_HELP_DASHBOARD      257 "
  203. "   #define ID_HELP_OPENCAR        258 "
  204. "   #define ID_HELP_HORNBEEP       259 "
  205. "   #define ID_HELP_BEEPHORN       260 "
  206. "   #define ID_HELP_TRAPCAR        261 "
  207. ""
  208. "   /*"
  209. "    *   Indexes into CARDETAILS information. (arrays)"
  210. "    */"
  211. "   #define  INDEX_MAKE               0 "
  212. "   #define  INDEX_MODEL              1 "
  213. "   #define  INDEX_COLOR              2 "
  214. "   #define  INDEX_SALE_DATE          3"
  215. "   #define  INDEX_PRICE              4 "
  216. ""
  217. "   /*"
  218. "    *   These defines are used as directional multipliers against x,y position."
  219. "    */"
  220. "   #define CAR_LEFT       -1 "
  221. "   #define CAR_RIGHT       1 "
  222. "   #define CAR_DOWN       -1"
  223. "   #define CAR_UP          1 "
  224. ""
  225. "   #define ICON_WIDTH     32      /* pels */"
  226. "   #define ICON_HEIGHT    32      /* pels */"
  227. "";
  228.  
  229.       passthru C_xih_after =  ""
  230. "   /*********************************************************************/"
  231. "   /* Include the header files for the components of the car                                    */"
  232. "   /*********************************************************************/"
  233. ""
  234. "   #include \"horn.h\""
  235. "   #include \"brake.h\""
  236. "   #include \"rpm.h\""
  237. ""
  238. "   /*"
  239. "    *   CARDETAILS:  Structure used for details view"
  240. "    */"
  241. "   typedef struct _CARDETAILS"
  242. "   {"
  243. "      PSZ     pszMake;     /* Manufacturer      */"
  244. "      PSZ     pszModel;    /* Model             */"
  245. "      PSZ     pszColor;    /* Color of car      */"
  246. "      CDATE   cdateSale;   /* Date of sale      */"
  247. "      ULONG   ulPrice;     /* Price in dollars  */"
  248. "   } CARDETAILS;"
  249. "   typedef CARDETAILS *PCARDETAILS;"
  250. ""
  251. "   /*"
  252. "    *   The following structures will be used to store window specific data"
  253. "    *   and a pointer to the object that created the window/dialog."
  254. "    *"
  255. "    *   They're allocated when the Client window is created.  This"
  256. "    *   allows us to pass the *somSelf pointer and use it in our"
  257. "    *   window and dialog procedures (the system only passes this"
  258. "    *   pointer to methods)."
  259. "    */"
  260. "   typedef struct _WINDOWDATA"
  261. "   {"
  262. "      USHORT   cb;            /* size of this structure */"
  263. "      Carpp     *somSelf;       /* pointer to this instance */"
  264. "      USEITEM  UseItem;       /* global class usage information */"
  265. "      VIEWITEM ViewItem;      /* global class view information */"
  266. "      LONG     x;             /* x position of car in open view */"
  267. "      LONG     y;             /* y position of car in open view */"
  268. "      LONG     xDir;          /* x direction (CAR_LEFT or CAR_RIGHT) */"
  269. "      LONG     yDir;          /* y direction (CAR_UP or CAR_DOWN) */"
  270. "   } WINDOWDATA;"
  271. "   typedef WINDOWDATA *PWINDOWDATA;"
  272. ""
  273. "   /*"
  274. "    *   Window data for the Dashboard dialog (settings page)"
  275. "    */"
  276. "   typedef struct _DASHDLGDATA"
  277. "   {"
  278. "      USHORT   cb;            /* size of this structure */"
  279. "      Carpp    *somSelf;        /* pointer to this instance         */"
  280. "      BOOL    PrevBrakes;     /* indicates if car is stopped      */"
  281. "      ULONG   PrevSpeed;      /* Speed car moves across screen    */"
  282. "   } DASHDLGDATA;"
  283. "   typedef DASHDLGDATA *PDASHDLGDATA;"
  284. ""
  285. "   /*"
  286. "    *   Window data for the Horn dialog (settings page)"
  287. "    */"
  288. "   typedef struct _HORNDLGDATA"
  289. "   {"
  290. "      USHORT   cb;            /* size of this structure */"
  291. "      Carpp    *somSelf;        /* pointer to this instance         */"
  292. "      ULONG   PrevDuration;   /* Duration of the car's horn beep  */"
  293. "      ULONG   PrevHighTone;   /* The high note of the car beep    */"
  294. "      ULONG   PrevLowTone;    /* The low note of the car beep     */"
  295. "   } HORNDLGDATA;"
  296. "   typedef HORNDLGDATA *PHORNDLGDATA;"
  297. ""
  298. "   /*"
  299. "    *   Private Debug helpers go here.  They can be enabled/disabled by"
  300. "    *   defining DEBUG as a compiler directive."
  301. "    */"
  302. "   #if defined(DEBUG)"
  303. ""
  304. "      #define DebugBox(title, text) \"
  305. "                                    \"
  306. "                 WinMessageBox(     \"
  307. "                    HWND_DESKTOP,   \"
  308. "                    HWND_DESKTOP,   \"
  309. "                    (PSZ) text,     \"
  310. "                    (PSZ) title,    \"
  311. "                    20,             \"
  312. "                    MB_OK | MB_INFORMATION | MB_MOVEABLE)"
  313. "   #else"
  314. "      #define DebugBox(title, text)   /* do nothing if not debugging */"
  315. "   #endif"
  316. "";
  317.  
  318.       /*
  319.        * Internal Instance Variables
  320.        */
  321.       Brake carBrake;
  322.       Horn  carHorn;
  323.       RPM   carRPM;
  324.  
  325.       /*
  326.        * Method Modifiers
  327.        */
  328.       wpInitData:                      override;
  329.       wpUnInitData:                    override;
  330.       wpSaveState:                     override;
  331.       wpRestoreState:                  override;
  332.       wpAddSettingsPages:              override;
  333.       wpFilterPopupMenu:               override;
  334.       wpModifyPopupMenu:               override;
  335.       wpMenuItemSelected:              override;
  336.       wpMenuItemHelpSelected:          override;
  337.       wpQueryDetailsData:              override;
  338.       wpOpen:                          override;
  339.       wpSetup:                         override;
  340.    };
  341.    #endif /* __SOMIDL__ */
  342. };
  343.  
  344. interface M_Carpp
  345. {
  346.    HMODULE clsQueryModuleHandle();
  347.    // METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  348.    //                                                        (X) PUBLIC
  349.    // DESCRIPTION:
  350.    //
  351.    //   This method returns the module handle of this class.  If this is the
  352.    //   first invocation, DosQueryModuleHandle is called to save the handle
  353.    //   for future invocations.
  354.    //
  355.    // RETURN:
  356.    //
  357.    //   0              Unsuccessful
  358.    //   non-zero       module handle
  359.  
  360.    #ifdef __SOMIDL__
  361.    implementation
  362.    {
  363.       releaseorder: clsQueryModuleHandle;
  364.  
  365.       /*
  366.        * Class Modifiers
  367.        */
  368.       externalstem   = carpp;
  369.       externalprefix = carppM_;
  370.       functionprefix = carppM_;
  371.       majorversion   = 1;
  372.       minorversion   = 2;
  373.       filestem       = carpp;
  374.       callstyle      = oidl;
  375.  
  376.       /*
  377.        * Method Modifiers
  378.        */
  379.       wpclsInitData:                   override;
  380.       wpclsUnInitData:                 override;
  381.       wpclsQueryTitle:                 override;
  382.       wpclsQueryIconData:              override;
  383.       wpclsQueryDefaultHelp:           override;
  384.       wpclsQueryDefaultView:           override;
  385.       wpclsQueryDetailsInfo:           override;
  386.       wpclsQueryDetails:               override;
  387.       wpclsQueryInstanceFilter:        override;
  388.       wpclsQueryStyle:                 override;
  389.    };
  390.    #endif /* __SOMIDL__ */
  391. };
  392.  
  393. #endif  /* carpp_idl */
  394.