home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / TOOLKIT / WPS / CAR / CAR.IDL < prev    next >
Text File  |  1994-11-17  |  16KB  |  492 lines

  1. /*
  2.  *   Module Name: CAR
  3.  *
  4.  *   OS/2 Work Place Shell Sample Program - SOM 2.0 / IDL Version
  5.  *
  6.  *   Copyright (C) 1992, 1993, 1994 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 car_idl
  19. #define car_idl
  20.  
  21. #include <wpdataf.idl>
  22. #include <somcls.idl>
  23.  
  24. interface M_Car;
  25.  
  26. // CLASS: Car
  27. //
  28. // CLASS HIERARCHY:
  29. //
  30. //     SOMObject
  31. //       └── WPObject
  32. //             └── WPFileSystem
  33. //                   └── WPDataFile
  34. //                         └──  Car
  35. //
  36. // DESCRIPTION:
  37. //
  38. //    This is the sample car object class.
  39. //
  40. //    An instance of this class can be created as a Workplace object.
  41. //
  42. interface Car : WPDataFile
  43. {
  44.    BOOL QueryBrakes();
  45.    // METHOD: QueryBrakes                                    ( ) PRIVATE
  46.    //                                                        (X) PUBLIC
  47.    // DESCRIPTION:
  48.    //
  49.    //   Query state of car's brakes
  50.    //
  51.    // RETURN:
  52.    //
  53.    //   TRUE           Brake is on
  54.    //   FALSE          Brake is off
  55.  
  56.    VOID SetBrakes(in BOOL fBrake);
  57.    // METHOD: SetBrakes                                      ( ) PRIVATE
  58.    //                                                        (X) PUBLIC
  59.    // DESCRIPTION:
  60.    //
  61.    //   Put on the brakes
  62.  
  63.    ULONG QueryDuration();
  64.    // METHOD: QueryDuration                                  ( ) PRIVATE
  65.    //                                                        (X) PUBLIC
  66.    // DESCRIPTION:
  67.    //
  68.    //   Query Duration of horn beep
  69.    //
  70.    // RETURN:
  71.    //
  72.    //   ULONG          Duration of beep
  73.  
  74.    VOID SetDuration(in ULONG ulDuration);
  75.    // METHOD: SetDuration                                    ( ) PRIVATE
  76.    //                                                        (X) PUBLIC
  77.    // DESCRIPTION:
  78.    //
  79.    //   Set Duration of horn beep
  80.  
  81.    ULONG QueryHighTone();
  82.    // METHOD: QueryHighTone                                  ( ) PRIVATE
  83.    //                                                        (X) PUBLIC
  84.    // DESCRIPTION:
  85.    //
  86.    //   Query HighTone of horn
  87.    //
  88.    // RETURN:
  89.    //
  90.    //   ULONG          High frequency of horn
  91.  
  92.    VOID SetHighTone(in ULONG ulTone);
  93.    // METHOD: SetHighTone                                    ( ) PRIVATE
  94.    //                                                        (X) PUBLIC
  95.    // DESCRIPTION:
  96.    //
  97.    //   Set HighTone of horn
  98.  
  99.    ULONG QueryLowTone();
  100.    // METHOD: QueryLowTone                                   ( ) PRIVATE
  101.    //                                                        (X) PUBLIC
  102.    // DESCRIPTION:
  103.    //
  104.    //   Query LowTone of horn
  105.    //
  106.    // RETURN:
  107.    //
  108.    //   ULONG          High frequency of horn
  109.  
  110.    VOID SetLowTone(in ULONG ulTone);
  111.    // METHOD: SetLowTone                                     ( ) PRIVATE
  112.    //                                                        (X) PUBLIC
  113.    // DESCRIPTION:
  114.    //
  115.    //   Set LowTone of horn
  116.  
  117.    ULONG QuerySpeed();
  118.    // METHOD: QuerySpeed                                     ( ) PRIVATE
  119.    //                                                        (X) PUBLIC
  120.    // DESCRIPTION:
  121.    //
  122.    //   Query Speed of car
  123.    //
  124.    // RETURN:
  125.    //
  126.    //   ULONG          car speed
  127.  
  128.    VOID SetSpeed(in ULONG ulSpeed);
  129.    // METHOD: SetSpeed                                       ( ) PRIVATE
  130.    //                                                        (X) PUBLIC
  131.    // DESCRIPTION:
  132.    //
  133.    //   Set Speed of car
  134.  
  135.    BOOL BeepHorn();
  136.    // METHOD: BeepHorn                                       ( ) PRIVATE
  137.    //                                                        (X) PUBLIC
  138.    // DESCRIPTION:
  139.    //
  140.    //   Beep the car's horn.
  141.    //
  142.    // RETURN:
  143.    //
  144.    //   TRUE           Successful
  145.    //   FALSE          Unsuccessful
  146.  
  147.    ULONG AddDashboardPage(in HWND hwndNotebook);
  148.    // METHOD: AddDashboardPage                               ( ) PRIVATE
  149.    //                                                        (X) PUBLIC
  150.    // DESCRIPTION:
  151.    //
  152.    //   This method adds the dashboard page to the settings notebook.
  153.    //
  154.    // RETURN:
  155.    //
  156.    //   0              Unsuccessful
  157.    //   ulPageId       Identifier for the inserted page
  158.    //
  159.    // HOW TO OVERRIDE:
  160.    //
  161.    //   Method should always be overridden in order to replace or remove
  162.    //   the dashboard page from an object which is a descendent of Car.
  163.    //   In most cases, an override of this method will not call the parent.
  164.  
  165.    ULONG AddHornBeepPage(in HWND hwndNotebook);
  166.    // METHOD: AddHornBeepPage                                ( ) PRIVATE
  167.    //                                                        (X) PUBLIC
  168.    // DESCRIPTION:
  169.    //
  170.    //   This method adds the horn beep page to the settings
  171.    //   notebook.
  172.    //
  173.    // RETURN:
  174.    //
  175.    //   0              Unsuccessful
  176.    //   ulPageId       Identifier for the inserted page
  177.    //
  178.    // HOW TO OVERRIDE:
  179.    //
  180.    //   Method should always be overridden in order to replace or remove
  181.    //   the horn beep page from an object which is a descendent of Car.
  182.    //   In most cases, an override of this method will not call the parent.
  183.  
  184.    VOID TrapTest();
  185.    // METHOD: AddHornBeepPage                                ( ) PRIVATE
  186.    //                                                        (X) PUBLIC
  187.    // DESCRIPTION:
  188.    //
  189.    //   This method tests the exception handling in this sample.
  190.    //
  191.    // RETURN:
  192.    //
  193.    //   nothing
  194.    //
  195.    // HOW TO OVERRIDE:
  196.    //
  197.    //   n/a
  198.    //
  199.    //
  200.    //   Methods from the WPObject class
  201.  
  202.    #ifdef __SOMIDL__
  203.    implementation
  204.    {
  205.       releaseorder: QueryBrakes,SetBrakes,QueryDuration,SetDuration,QueryHighTone,
  206.                     SetHighTone,QueryLowTone,SetLowTone,QuerySpeed,SetSpeed,
  207.                     BeepHorn,AddDashboardPage,AddHornBeepPage,TrapTest;
  208.  
  209.       /*
  210.        * Class Modifiers
  211.        */
  212.       externalstem   = car;
  213.       externalprefix = car_;
  214.       majorversion   = 1;
  215.       minorversion   = 2;
  216.       filestem       = car;
  217.       metaclass      = M_Car;
  218.       callstyle      = oidl;
  219.  
  220. /* som2 The continuation mark '\' must have a space before the " in the
  221.    passthru section i.e., \" -> \ " */
  222.  
  223.     passthru C_ih =     ""
  224. "   #define INCL_WIN"
  225. "   #define INCL_DOS"
  226. "   #define INCL_GPIBITMAPS"
  227. "   #define INCL_DOSERRORS"
  228. "   #include <os2.h>"
  229. ""
  230. "   #define INCL_WPCLASS"
  231. "   #define INCL_WPFOLDER"
  232. ""
  233. "   #include <pmwp.h>"
  234. ""
  235. "   #define ID_TITLE           100"
  236. "   #define ID_ICON            101"
  237. ""
  238. "   #define IDD_DASHBOARD      200                  /* settings page (dialog) */"
  239. "   #define IDD_HORNBEEP       202"
  240. ""
  241. "   /*"
  242. "    *   The following user-defined Popup menu items (ID_xxx) should be higher"
  243. "    *   than WPMENUID_USER."
  244. "    *"
  245. "    *   The ID_OPENMENU will become a submenu of the system's popup open menu"
  246. "    *   id, WPMENUID_OPEN."
  247. "    */"
  248. "   #define ID_BEEPMENU        (WPMENUID_USER+1) /* menus added to popup menu */"
  249. "   #define ID_OPENMENU        (WPMENUID_USER+2)"
  250. "   #define ID_TRAPMENU        (WPMENUID_USER+3)"
  251. ""
  252. "   #define IDM_OPENCAR        (WPMENUID_USER+4) /* submenus of added menus */"
  253. "   #define IDM_BEEPHORN       (WPMENUID_USER+5)"
  254. "   #define IDM_TRAPCAR        (WPMENUID_USER+6)"
  255. ""
  256. "   #define IDMSG_ACCESS_VIOLATION  100"
  257. "   #define IDM_MSGBOX              999"
  258. ""
  259. "   #define ID_FRAME           3000                       /* client window id */"
  260. "   #define ID_CLIENT          3001                       /* client window id */"
  261. ""
  262. "   /*"
  263. "    *   Set unique view ids."
  264. "    */"
  265. "   #define OPEN_CAR           IDM_OPENCAR"
  266. ""
  267. "   #define CAR_TIMER          1001                               /* timer id */"
  268. ""
  269. "   /*"
  270. "    *   IDs of dialog items in CAR.RC"
  271. "    */"
  272. "   #define ID_UNDO            801"
  273. "   #define ID_DEFAULT         802"
  274. "   #define ID_HELP            803"
  275. "   #define ID_HITONE          804"
  276. "   #define ID_LOTONE          805"
  277. "   #define ID_SPEEDSLIDER     806"
  278. "   #define ID_STOP            807"
  279. "   #define ID_SPEEDDATA       808"
  280. "   #define ID_GO              809"
  281. ""
  282. "   /*"
  283. "    *  Keys for save-restore methods"
  284. "    */"
  285. "   #define IDKEY_HITONE       1"
  286. "   #define IDKEY_LOTONE       2"
  287. "   #define IDKEY_DURATION     3"
  288. "   #define IDKEY_SPEED        4"
  289. "   #define IDKEY_BRAKEFLAG    5"
  290. ""
  291. "   /*"
  292. "    *   Default values of instance data items"
  293. "    */"
  294. "   #define DEFAULT_DURATION   300"
  295. "   #define DEFAULT_HITONE     400"
  296. "   #define DEFAULT_LOTONE     400"
  297. "   #define DEFAULT_SPEED      50"
  298. "   #define DEFAULT_BRAKEFLAG  FALSE"
  299. ""
  300. "   /*"
  301. "    *   Help IDs"
  302. "    *"
  303. "    *   NOTE:  At this time, no source file is provided to build help for this"
  304. "    *   sample.  A pre-built help file, CAR.HLP, is provided containing the"
  305. "    *   following help ids."
  306. "    */"
  307. "   #define ID_HELP_DEFAULT    256"
  308. "   #define ID_HELP_DASHBOARD  257"
  309. "   #define ID_HELP_OPENCAR    258"
  310. "   #define ID_HELP_HORNBEEP   259"
  311. "   #define ID_HELP_BEEPHORN   260"
  312. ""
  313. "   /*"
  314. "    *   Indexes into CARDETAILS information. (arrays)"
  315. "    */"
  316. "   #define  INDEX_MAKE         0"
  317. "   #define  INDEX_MODEL        1"
  318. "   #define  INDEX_COLOR        2"
  319. "   #define  INDEX_SALE_DATE    3"
  320. "   #define  INDEX_PRICE        4"
  321. ""
  322. "   /*"
  323. "    *   CARDETAILS:  Structure used for details view"
  324. "    */"
  325. "   typedef struct _CARDETAILS"
  326. "   {"
  327. "      PSZ     pszMake;     /* Manufacturer      */"
  328. "      PSZ     pszModel;    /* Model             */"
  329. "      PSZ     pszColor;    /* Color of car      */"
  330. "      CDATE   cdateSale;   /* Date of sale      */"
  331. "      ULONG   ulPrice;     /* Price in dollars  */"
  332. "   } CARDETAILS;"
  333. "   typedef CARDETAILS *PCARDETAILS;"
  334. "";
  335.  
  336.     passthru C_h_after =  ""
  337. "   /*"
  338. "    *   The following structures will be used to store window specific data"
  339. "    *   and a pointer to the object that created the window/dialog."
  340. "    *"
  341. "    *   They're allocated when the Client window is created.  This"
  342. "    *   allows us to pass the *somSelf pointer and use it in our"
  343. "    *   window and dialog procedures (the system only passes this"
  344. "    *   pointer to methods)."
  345. "    */"
  346. "   typedef struct _WINDOWDATA"
  347. "   {"
  348. "      USHORT   cb;            /* size of this structure */"
  349. "      Car     *somSelf;       /* pointer to this instance */"
  350. "      USEITEM  UseItem;       /* global class usage information */"
  351. "      VIEWITEM ViewItem;      /* global class view information */"
  352. "      LONG     x;             /* x position of car in open view */"
  353. "      LONG     y;             /* y position of car in open view */"
  354. "      LONG     xDir;          /* x direction (CAR_LEFT or CAR_RIGHT) */"
  355. "      LONG     yDir;          /* y direction (CAR_UP or CAR_DOWN) */"
  356. "   } WINDOWDATA;"
  357. "   typedef WINDOWDATA *PWINDOWDATA;"
  358. ""
  359. "   /*"
  360. "    *   Window data for the Dashboard dialog (settings page)"
  361. "    */"
  362. "   typedef struct _DASHDLGDATA"
  363. "   {"
  364. "      USHORT   cb;            /* size of this structure */"
  365. "      Car    *somSelf;        /* pointer to this instance         */"
  366. "      BOOL    PrevBrakes;     /* indicates if car is stopped      */"
  367. "      ULONG   PrevSpeed;      /* Speed car moves across screen    */"
  368. "   } DASHDLGDATA;"
  369. "   typedef DASHDLGDATA *PDASHDLGDATA;"
  370. ""
  371. "   /*"
  372. "    *   Window data for the Horn dialog (settings page)"
  373. "    */"
  374. "   typedef struct _HORNDLGDATA"
  375. "   {"
  376. "      USHORT   cb;            /* size of this structure */"
  377. "      Car    *somSelf;        /* pointer to this instance         */"
  378. "      ULONG   PrevDuration;   /* Duration of the car's horn beep  */"
  379. "      ULONG   PrevHighTone;   /* The high note of the car beep    */"
  380. "      ULONG   PrevLowTone;    /* The low note of the car beep     */"
  381. "   } HORNDLGDATA;"
  382. "   typedef HORNDLGDATA *PHORNDLGDATA;"
  383. ""
  384. "   /*"
  385. "    *   These defines are used as directional multipliers against x,y position."
  386. "    */"
  387. "   #define CAR_LEFT  -1"
  388. "   #define CAR_RIGHT  1"
  389. "   #define CAR_DOWN  -1"
  390. "   #define CAR_UP     1"
  391. ""
  392. "   #define ICON_WIDTH   32     /* pels */"
  393. "   #define ICON_HEIGHT  32     /* pels */"
  394. ""
  395. "   /*"
  396. "    *   Private Debug helpers go here.  They can be enabled/disabled by"
  397. "    *   defining DEBUG as a compiler directive."
  398. "    */"
  399. "   #if defined(DEBUG)"
  400. ""
  401. "      #define DebugBox(title, text) \ "
  402. "                                    \ "
  403. "                 WinMessageBox(     \ "
  404. "                    HWND_DESKTOP,   \ "
  405. "                    HWND_DESKTOP,   \ "
  406. "                    (PSZ) text,     \ "
  407. "                    (PSZ) title,    \ "
  408. "                    20,             \ "
  409. "                    MB_OK | MB_INFORMATION | MB_MOVEABLE)"
  410. "   #else"
  411. "      #define DebugBox(title, text)   /* do nothing if not debugging */"
  412. "   #endif"
  413. "";
  414.  
  415.       /*
  416.        * Internal Instance Variables
  417.        */
  418.       BOOL  BrakeFlag;              // indicates if car is stopped
  419.       ULONG duration;               // Duration of the car's horn
  420.       ULONG HighTone;               // The high note of the beep
  421.       ULONG LowTone;                // The low note of the beep
  422.       ULONG speed;                  // Speed car moves across screen
  423.  
  424.       /*
  425.        * Method Modifiers
  426.        */
  427.       wpInitData:                      override;
  428.       wpUnInitData:                    override;
  429.       wpSaveState:                     override;
  430.       wpRestoreState:                  override;
  431.       wpAddSettingsPages:              override;
  432.       wpFilterPopupMenu:               override;
  433.       wpModifyPopupMenu:               override;
  434.       wpMenuItemSelected:              override;
  435.       wpMenuItemHelpSelected:          override;
  436.       wpQueryDetailsData:              override;
  437.       wpOpen:                          override;
  438.       wpSetup:                         override;
  439.    };
  440.    #endif /* __SOMIDL__ */
  441. };
  442.  
  443. interface M_Car
  444. {
  445.    HMODULE clsQueryModuleHandle();
  446.    // METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  447.    //                                                        (X) PUBLIC
  448.    // DESCRIPTION:
  449.    //
  450.    //   This method returns the module handle of this class.  If this is the
  451.    //   first invocation, DosQueryModuleHandle is called to save the handle
  452.    //   for future invocations.
  453.    //
  454.    // RETURN:
  455.    //
  456.    //   0              Unsuccessful
  457.    //   non-zero       module handle
  458.  
  459.    #ifdef __SOMIDL__
  460.    implementation
  461.    {
  462.       releaseorder: clsQueryModuleHandle;
  463.  
  464.       /*
  465.        * Class Modifiers
  466.        */
  467.       externalstem   = car;
  468.       externalprefix = carM_;              // som2 changed car_ to carM_
  469.       functionprefix = carM_;
  470.       majorversion   = 1;
  471.       minorversion   = 2;
  472.       filestem       = car;
  473.       callstyle      = oidl;
  474.  
  475.       /*
  476.        * Method Modifiers
  477.        */
  478.       wpclsInitData:                   override;
  479.       wpclsUnInitData:                 override;
  480.       wpclsQueryTitle:                 override;
  481.       wpclsQueryIconData:              override;
  482.       wpclsQueryDefaultHelp:           override;
  483.       wpclsQueryDefaultView:           override;
  484.       wpclsQueryDetailsInfo:           override;
  485.       wpclsQueryDetails:               override;
  486.       wpclsQueryInstanceFilter:        override;
  487.       wpclsQueryStyle:                 override;
  488.    };
  489.    #endif /* __SOMIDL__ */
  490. };
  491. #endif  /* car_idl */
  492.