home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / wps / car / car.idl < prev    next >
Text File  |  1999-05-11  |  16KB  |  494 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. "   #define IDD_DASHBOARD2    1200                  /* settings page (dialog) */"
  241. "   #define IDD_HORNBEEP2     1202"
  242. ""
  243. "   /*"
  244. "    *   The following user-defined Popup menu items (ID_xxx) should be higher"
  245. "    *   than WPMENUID_USER."
  246. "    *"
  247. "    *   The ID_OPENMENU will become a submenu of the system's popup open menu"
  248. "    *   id, WPMENUID_OPEN."
  249. "    */"
  250. "   #define ID_BEEPMENU        (WPMENUID_USER+1) /* menus added to popup menu */"
  251. "   #define ID_OPENMENU        (WPMENUID_USER+2)"
  252. "   #define ID_TRAPMENU        (WPMENUID_USER+3)"
  253. ""
  254. "   #define IDM_OPENCAR        (WPMENUID_USER+4) /* submenus of added menus */"
  255. "   #define IDM_BEEPHORN       (WPMENUID_USER+5)"
  256. "   #define IDM_TRAPCAR        (WPMENUID_USER+6)"
  257. ""
  258. "   #define IDMSG_ACCESS_VIOLATION  100"
  259. "   #define IDM_MSGBOX              999"
  260. ""
  261. "   #define ID_FRAME           3000                       /* client window id */"
  262. "   #define ID_CLIENT          3001                       /* client window id */"
  263. ""
  264. "   /*"
  265. "    *   Set unique view ids."
  266. "    */"
  267. "   #define OPEN_CAR           IDM_OPENCAR"
  268. ""
  269. "   #define CAR_TIMER          1001                               /* timer id */"
  270. ""
  271. "   /*"
  272. "    *   IDs of dialog items in CAR.RC"
  273. "    */"
  274. "   #define ID_UNDO            801"
  275. "   #define ID_DEFAULT         802"
  276. "   #define ID_HELP            803"
  277. "   #define ID_HITONE          804"
  278. "   #define ID_LOTONE          805"
  279. "   #define ID_SPEEDSLIDER     806"
  280. "   #define ID_STOP            807"
  281. "   #define ID_SPEEDDATA       808"
  282. "   #define ID_GO              809"
  283. ""
  284. "   /*"
  285. "    *  Keys for save-restore methods"
  286. "    */"
  287. "   #define IDKEY_HITONE       1"
  288. "   #define IDKEY_LOTONE       2"
  289. "   #define IDKEY_DURATION     3"
  290. "   #define IDKEY_SPEED        4"
  291. "   #define IDKEY_BRAKEFLAG    5"
  292. ""
  293. "   /*"
  294. "    *   Default values of instance data items"
  295. "    */"
  296. "   #define DEFAULT_DURATION   300"
  297. "   #define DEFAULT_HITONE     400"
  298. "   #define DEFAULT_LOTONE     400"
  299. "   #define DEFAULT_SPEED      50"
  300. "   #define DEFAULT_BRAKEFLAG  FALSE"
  301. ""
  302. "   /*"
  303. "    *   Help IDs"
  304. "    *"
  305. "    *   NOTE:  At this time, no source file is provided to build help for this"
  306. "    *   sample.  A pre-built help file, CAR.HLP, is provided containing the"
  307. "    *   following help ids."
  308. "    */"
  309. "   #define ID_HELP_DEFAULT    256"
  310. "   #define ID_HELP_DASHBOARD  257"
  311. "   #define ID_HELP_OPENCAR    258"
  312. "   #define ID_HELP_HORNBEEP   259"
  313. "   #define ID_HELP_BEEPHORN   260"
  314. ""
  315. "   /*"
  316. "    *   Indexes into CARDETAILS information. (arrays)"
  317. "    */"
  318. "   #define  INDEX_MAKE         0"
  319. "   #define  INDEX_MODEL        1"
  320. "   #define  INDEX_COLOR        2"
  321. "   #define  INDEX_SALE_DATE    3"
  322. "   #define  INDEX_PRICE        4"
  323. ""
  324. "   /*"
  325. "    *   CARDETAILS:  Structure used for details view"
  326. "    */"
  327. "   typedef struct _CARDETAILS"
  328. "   {"
  329. "      PSZ     pszMake;     /* Manufacturer      */"
  330. "      PSZ     pszModel;    /* Model             */"
  331. "      PSZ     pszColor;    /* Color of car      */"
  332. "      CDATE   cdateSale;   /* Date of sale      */"
  333. "      ULONG   ulPrice;     /* Price in dollars  */"
  334. "   } CARDETAILS;"
  335. "   typedef CARDETAILS *PCARDETAILS;"
  336. "";
  337.  
  338.     passthru C_h_after =  ""
  339. "   /*"
  340. "    *   The following structures will be used to store window specific data"
  341. "    *   and a pointer to the object that created the window/dialog."
  342. "    *"
  343. "    *   They're allocated when the Client window is created.  This"
  344. "    *   allows us to pass the *somSelf pointer and use it in our"
  345. "    *   window and dialog procedures (the system only passes this"
  346. "    *   pointer to methods)."
  347. "    */"
  348. "   typedef struct _WINDOWDATA"
  349. "   {"
  350. "      USHORT   cb;            /* size of this structure */"
  351. "      Car     *somSelf;       /* pointer to this instance */"
  352. "      USEITEM  UseItem;       /* global class usage information */"
  353. "      VIEWITEM ViewItem;      /* global class view information */"
  354. "      LONG     x;             /* x position of car in open view */"
  355. "      LONG     y;             /* y position of car in open view */"
  356. "      LONG     xDir;          /* x direction (CAR_LEFT or CAR_RIGHT) */"
  357. "      LONG     yDir;          /* y direction (CAR_UP or CAR_DOWN) */"
  358. "   } WINDOWDATA;"
  359. "   typedef WINDOWDATA *PWINDOWDATA;"
  360. ""
  361. "   /*"
  362. "    *   Window data for the Dashboard dialog (settings page)"
  363. "    */"
  364. "   typedef struct _DASHDLGDATA"
  365. "   {"
  366. "      USHORT   cb;            /* size of this structure */"
  367. "      Car    *somSelf;        /* pointer to this instance         */"
  368. "      BOOL    PrevBrakes;     /* indicates if car is stopped      */"
  369. "      ULONG   PrevSpeed;      /* Speed car moves across screen    */"
  370. "   } DASHDLGDATA;"
  371. "   typedef DASHDLGDATA *PDASHDLGDATA;"
  372. ""
  373. "   /*"
  374. "    *   Window data for the Horn dialog (settings page)"
  375. "    */"
  376. "   typedef struct _HORNDLGDATA"
  377. "   {"
  378. "      USHORT   cb;            /* size of this structure */"
  379. "      Car    *somSelf;        /* pointer to this instance         */"
  380. "      ULONG   PrevDuration;   /* Duration of the car's horn beep  */"
  381. "      ULONG   PrevHighTone;   /* The high note of the car beep    */"
  382. "      ULONG   PrevLowTone;    /* The low note of the car beep     */"
  383. "   } HORNDLGDATA;"
  384. "   typedef HORNDLGDATA *PHORNDLGDATA;"
  385. ""
  386. "   /*"
  387. "    *   These defines are used as directional multipliers against x,y position."
  388. "    */"
  389. "   #define CAR_LEFT  -1"
  390. "   #define CAR_RIGHT  1"
  391. "   #define CAR_DOWN  -1"
  392. "   #define CAR_UP     1"
  393. ""
  394. "   #define ICON_WIDTH   32     /* pels */"
  395. "   #define ICON_HEIGHT  32     /* pels */"
  396. ""
  397. "   /*"
  398. "    *   Private Debug helpers go here.  They can be enabled/disabled by"
  399. "    *   defining DEBUG as a compiler directive."
  400. "    */"
  401. "   #if defined(DEBUG)"
  402. ""
  403. "      #define DebugBox(title, text) \ "
  404. "                                    \ "
  405. "                 WinMessageBox(     \ "
  406. "                    HWND_DESKTOP,   \ "
  407. "                    HWND_DESKTOP,   \ "
  408. "                    (PSZ) text,     \ "
  409. "                    (PSZ) title,    \ "
  410. "                    20,             \ "
  411. "                    MB_OK | MB_INFORMATION | MB_MOVEABLE)"
  412. "   #else"
  413. "      #define DebugBox(title, text)   /* do nothing if not debugging */"
  414. "   #endif"
  415. "";
  416.  
  417.       /*
  418.        * Internal Instance Variables
  419.        */
  420.       BOOL  BrakeFlag;              // indicates if car is stopped
  421.       ULONG duration;               // Duration of the car's horn
  422.       ULONG HighTone;               // The high note of the beep
  423.       ULONG LowTone;                // The low note of the beep
  424.       ULONG speed;                  // Speed car moves across screen
  425.  
  426.       /*
  427.        * Method Modifiers
  428.        */
  429.       wpInitData:                      override;
  430.       wpUnInitData:                    override;
  431.       wpSaveState:                     override;
  432.       wpRestoreState:                  override;
  433.       wpAddSettingsPages:              override;
  434.       wpFilterPopupMenu:               override;
  435.       wpModifyPopupMenu:               override;
  436.       wpMenuItemSelected:              override;
  437.       wpMenuItemHelpSelected:          override;
  438.       wpQueryDetailsData:              override;
  439.       wpOpen:                          override;
  440.       wpSetup:                         override;
  441.    };
  442.    #endif /* __SOMIDL__ */
  443. };
  444.  
  445. interface M_Car
  446. {
  447.    HMODULE clsQueryModuleHandle();
  448.    // METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  449.    //                                                        (X) PUBLIC
  450.    // DESCRIPTION:
  451.    //
  452.    //   This method returns the module handle of this class.  If this is the
  453.    //   first invocation, DosQueryModuleHandle is called to save the handle
  454.    //   for future invocations.
  455.    //
  456.    // RETURN:
  457.    //
  458.    //   0              Unsuccessful
  459.    //   non-zero       module handle
  460.  
  461.    #ifdef __SOMIDL__
  462.    implementation
  463.    {
  464.       releaseorder: clsQueryModuleHandle;
  465.  
  466.       /*
  467.        * Class Modifiers
  468.        */
  469.       externalstem   = car;
  470.       externalprefix = carM_;              // som2 changed car_ to carM_
  471.       functionprefix = carM_;
  472.       majorversion   = 1;
  473.       minorversion   = 2;
  474.       filestem       = car;
  475.       callstyle      = oidl;
  476.  
  477.       /*
  478.        * Method Modifiers
  479.        */
  480.       wpclsInitData:                   override;
  481.       wpclsUnInitData:                 override;
  482.       wpclsQueryTitle:                 override;
  483.       wpclsQueryIconData:              override;
  484.       wpclsQueryDefaultHelp:           override;
  485.       wpclsQueryDefaultView:           override;
  486.       wpclsQueryDetailsInfo:           override;
  487.       wpclsQueryDetails:               override;
  488.       wpclsQueryInstanceFilter:        override;
  489.       wpclsQueryStyle:                 override;
  490.    };
  491.    #endif /* __SOMIDL__ */
  492. };
  493. #endif  /* car_idl */
  494.