home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / SAMPLES / OPENDOC / PARTS / PUSHBTN / PUSHBTN.CPP < prev    next >
Text File  |  1995-12-15  |  56KB  |  1,271 lines

  1. /***************************************************************************
  2. *
  3. *  File Name   : PUSHBTN.CPP
  4. *
  5. *  Description : Contains the implementation of the OpenDoc class
  6. *                PushButtonPart
  7. *
  8. *  Notes       : N/A
  9. *
  10. *  Entry Points: PushButtonCommonInitPart
  11. *                PushButtonDisplayMsgBox
  12. *                PushButtonsomInit
  13. *                PushButtonsomUninit
  14. *                PushButtonInitPart
  15. *                PushButtonInitPartFromStorage
  16. *                PushButtonExternalize
  17. *                PushButtonCloneInto
  18. *                PushButtonCheckAndAddProperties
  19. *                PushButtonExternalizeContent
  20. *                PushButtonHandleEvent
  21. *                PushButtonFacetAdded
  22. *                PushButtonFacetRemoved
  23. *                PushButtonGeometryChanged
  24. *                PushButtonDraw
  25. *                PushButtonViewTypeChanged
  26. *                PushButtonDrawIconView
  27. *                PushButtonDrawThumbnailView
  28. *                M_PushButtonPartclsGetODPartHandlerName
  29. *                M_PushButtonPartclsGetODPartHandlerDisplayName
  30. *                M_PushButtonPartclsGetODPartKinds
  31. *                M_PushButtonPartclsGetOLE2ClassId
  32. *                M_PushButtonPartclsGetWindowsIconFileName
  33. *
  34. *       (C) COPYRIGHT International Business Machines Corp. 1995
  35. *       All Rights Reserved
  36. *       Licensed Materials - Property of IBM
  37. *
  38. *       US Government Users Restricted Rights - Use, duplication or
  39. *       disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  40. *
  41. *       DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  42. *       sample code created by IBM Corporation. This sample code is not
  43. *       part of any standard or IBM product and is provided to you solely
  44. *       for the purpose of assisting you in the development of your
  45. *       applications.  The code is provided "AS IS", without
  46. *       warranty of any kind.  IBM shall not be liable for any damages
  47. *       arising out of your use of the sample code, even if they have been
  48. *       advised of the possibility of such damages.
  49. *
  50. ***************************************************************************/
  51.  
  52. #ifndef SOM_Module_pushbtn_Source
  53. #define SOM_Module_pushbtn_Source
  54. #endif
  55.  
  56. #define PushButtonPart_Class_Source
  57.  
  58. #ifndef SOM_PushButtonPart_xih
  59. #include "pushbtn.xih"
  60. #endif
  61.  
  62. #ifndef _PUSHBTN_HPP_
  63. #include "pushbtn.hpp"
  64. #endif
  65.  
  66. /****************************************************************************
  67. *
  68. *    Method(s) : PushButtonCommonInitPart()
  69. *
  70. *  Description : This method contains the initialization code that is
  71. *                common to both situations, whether the part is newly
  72. *                created or is to be read in from persistent storage.
  73. *
  74. *   Parameters : PushButtonPart *somSelf - References the object
  75. *                Environment *ev         - References SOM environment
  76. *                                          information
  77. *
  78. *      Returns : void
  79. *
  80. *        Notes : N/A
  81. *
  82. ****************************************************************************/
  83. SOM_Scope void  SOMLINK PushButtonCommonInitPart(PushButtonPart *somSelf,
  84.                                                   Environment *ev)
  85. {
  86.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  87.     PushButtonPartMethodDebug("PushButtonPart","PushButtonCommonInitPart");
  88.  
  89.     // Allocate memory for Push Button text.
  90.     _fBuffer = new CHAR[TEXTBUFFERSIZE];
  91.  
  92.     // In order to load the resources (strings, icon or bitmap), the module
  93.     // handle for the part DLL and the anchor block must be obtained.
  94.     DosQueryModuleHandle(MODULENAME, &_ModuleHandle);
  95.     _habDeskTop = WinQueryAnchorBlock( HWND_DESKTOP );
  96.  
  97.     // Get tokens representing the frame, large icon, small icon and
  98.     // thumbnail views, respectively, so a new unique token is generated
  99.     // if the type has not yet been tokenized.
  100.     _Session = somSelf->GetStorageUnit(ev)->GetSession(ev);
  101.     _FrameView     = _Session->Tokenize(ev, kODViewAsFrame);
  102.     _LargeIconView = _Session->Tokenize(ev, kODViewAsLargeIcon);
  103.     _SmallIconView = _Session->Tokenize(ev, kODViewAsSmallIcon);
  104.     _ThumbnailView = _Session->Tokenize(ev, kODViewAsThumbnail);
  105. }
  106.  
  107. /****************************************************************************
  108. *
  109. *    Method(s) : PushButtonDisplayMsgBox()
  110. *
  111. *  Description : This method displays a message window when Push Button
  112. *                is depressed.
  113. *
  114. *   Parameters : PushButtonPart *somSelf - References the object
  115. *                Environment *ev         - References SOM environment
  116. *                                          information
  117. *                ODFacet* facet          - References the facet for this object
  118. *
  119. *      Returns : void
  120. *
  121. *        Notes : N/A
  122. *
  123. ****************************************************************************/
  124. SOM_Scope void  SOMLINK PushButtonDisplayMsgBox(PushButtonPart *somSelf,
  125.                                                  Environment *ev,
  126.                                                 ODFacet* facet)
  127. {
  128.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  129.     PushButtonPartMethodDebug("PushButtonPart","PushButtonDisplayMsgBox");
  130.  
  131.     CHAR szMsg[MSGBUFFERSIZE];      // buffer for message test
  132.  
  133.     // Load the message text from the resource (DLL file in this case).
  134.     WinLoadString( _habDeskTop, _ModuleHandle, IDS_PUSHBUTTONMSG, sizeof(szMsg),
  135.                    (PSZ)szMsg );
  136.  
  137.     // Create and display the message window.
  138.     WinMessageBox( HWND_DESKTOP, _hwndPushButton,
  139.                    szMsg, kTitleBarText,
  140.                    0, MB_OK | MB_INFORMATION | MB_MOVEABLE );
  141. }
  142.  
  143. /****************************************************************************
  144. *
  145. *    Method(s) : PushButtonsomInit()
  146. *
  147. *  Description : This method initializes instance variables or attributes
  148. *                in a newly created object.  It is similar to constructor
  149. *                method in C++.
  150. *
  151. *   Parameters : PushButtonPart *somSelf - References the object to be
  152. *                                          initialized
  153. *
  154. *      Returns : void
  155. *
  156. *        Notes : N/A
  157. *
  158. ****************************************************************************/
  159. SOM_Scope void  SOMLINK PushButtonsomInit(PushButtonPart *somSelf)
  160. {
  161.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  162.     PushButtonPartMethodDebug("PushButtonPart","PushButtonsomInit");
  163.  
  164.     // Call the superclass (parent) somInit method.
  165.     PushButtonPart_parent_ContainerPart_somInit(somSelf);
  166.  
  167.     // Set initial values for the instance variables
  168.     _fIsInitFromStorage = kODFalse;
  169.     _fShowDefaultFrameSize = kODTrue;
  170. }
  171.  
  172. /****************************************************************************
  173. *
  174. *    Method(s) : PushButtonsomUninit()
  175. *
  176. *  Description : This method is the SOM equivalent of a C++ destructor
  177. *                in that it is called by the run-time system when its
  178. *                object (PushButtonPart in this case) is deleted.
  179. *
  180. *   Parameters : PushButtonPart *somSelf - References the object to be
  181. *                                          uninitialized
  182. *      Returns : void
  183. *
  184. *        Notes : N/A
  185. *
  186. ****************************************************************************/
  187. SOM_Scope void  SOMLINK PushButtonsomUninit(PushButtonPart *somSelf)
  188. {
  189.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  190.     PushButtonPartMethodDebug("PushButtonPart","PushButtonsomUninit");
  191.  
  192.     // Deallocate the memory which used by the instance variable in run-time
  193.     delete[] _fBuffer;
  194.  
  195.     // Call the superclass (parent) somUninit method.
  196.     PushButtonPart_parent_ContainerPart_somUninit(somSelf);
  197. }
  198.  
  199. /****************************************************************************
  200. *
  201. *    Method(s) : PushButtonInitPart()
  202. *
  203. *  Description : OpenDoc calls the InitPart method of the part object,
  204. *                if the part is newly created from stationery.  This method
  205. *                prepares the part properties and values that will allow
  206. *                the part editor to run.
  207. *
  208. *   Parameters : PushButtonPart *somSelf    - References the object
  209. *                                             (part) to be initialized
  210. *                Environment *ev            - References SOM environment
  211. *                                             information
  212. *                ODStorageUnit* storageUnit - References the storage unit
  213. *                                             for the part
  214. *
  215. *      Returns : void
  216. *
  217. *        Notes : N/A
  218. *
  219. ****************************************************************************/
  220. SOM_Scope void  SOMLINK PushButtonInitPart(PushButtonPart *somSelf,
  221.                                             Environment *ev,
  222.                                            ODStorageUnit* storageUnit,
  223.                                            ODPart* partWrapper)
  224. {
  225.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  226.     PushButtonPartMethodDebug("PushButtonPart","PushButtonInitPart");
  227.  
  228.     // Call the superclass (parent) InitPart method.
  229.     PushButtonPart_parent_ContainerPart_InitPart(somSelf, ev,
  230.                                                  storageUnit, partWrapper);
  231.  
  232.     // Call the common initialization code in the PushButtonPart object.
  233.     somSelf->CommonInitPart(ev);
  234.  
  235.     // Initialize instance variable by loading the message text from
  236.     // the resource (DLL file in this case).
  237.     WinLoadString( _habDeskTop, _ModuleHandle, PB_INITTEXT, TEXTBUFFERSIZE,
  238.                    _fBuffer );
  239. }
  240.  
  241. /****************************************************************************
  242. *
  243. *    Method(s) : PushButtonInitPartFromStorage()
  244. *
  245. *  Description : OpenDoc calls the part's InitPartFromStorage method of
  246. *                the part object, if the part was previously created,
  247. *                either as the root part or embedded in a document.
  248. *
  249. *                This method should do many of the same things as InitPart,
  250. *                but which must also handle reading content information
  251. *                from the storage unit into memory.
  252. *
  253. *   Parameters : PushButtonPart *somSelf    - References the object
  254. *                                             (part) to be initialized
  255. *                Environment *ev            - References SOM environment
  256. *                                             information
  257. *                ODStorageUnit* storageUnit - References the storage unit
  258. *                                             for the part
  259. *
  260. *      Returns : void
  261. *
  262. *        Notes : N/A
  263. *
  264. ****************************************************************************/
  265. SOM_Scope void  SOMLINK PushButtonInitPartFromStorage(PushButtonPart *somSelf,
  266.                                                        Environment *ev,
  267.                                                       ODStorageUnit* storageUnit,
  268.                                                       ODPart* partWrapper)
  269. {
  270.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  271.     PushButtonPartMethodDebug("PushButtonPart","PushButtonInitPartFromStorage");
  272.  
  273.     // Call the superclass (parent) InitPartFromStorage method.
  274.     PushButtonPart_parent_ContainerPart_InitPartFromStorage(somSelf,
  275.                                                             ev,
  276.                                                             storageUnit,
  277.                                                             partWrapper);
  278.  
  279.     // Set the flag to true
  280.     _fIsInitFromStorage = kODTrue;
  281.  
  282.     // Call the common initialization code in the PushButtonPart object.
  283.     somSelf->CommonInitPart(ev);
  284.  
  285.     // Focus and read in the part's content value from the storage unit.
  286.     ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  287.     su->Focus(ev, kODPropContents, kODPosUndefined,
  288.                   kPushButtonTextType, 0, kODPosUndefined);
  289.     StorageUnitGetValue(su, ev, TEXTBUFFERSIZE, _fBuffer);
  290.  
  291.     // Focus the part's storage unit on the kODPropPushButtonAttr
  292.     // Property and the kPushButtonAttrType value type.
  293.     su->Focus(ev, kODPropPushButtonAttr, kODPosUndefined,
  294.                   kPushButtonAttrType, 0, kODPosUndefined);
  295.     StorageUnitGetValue(su, ev, sizeof(_fShowDefaultFrameSize),
  296.                         (ODValue)&_fShowDefaultFrameSize);
  297. }
  298.  
  299. /****************************************************************************
  300. *
  301. *    Method(s) : PushButtonExternalize()
  302. *
  303. *  Description : OpenDoc calls the Externalize method of your part editor
  304. *                object whenever it is necessary to write the part to
  305. *                persistent storage.  The most common circumstance is
  306. *                when the user saves the document.
  307. *
  308. *   Parameters : PushButtonPart *somSelf - References the object which should
  309. *                                          externalize its data
  310. *                Environment *ev         - References SOM environment
  311. *                                          information
  312. *
  313. *      Returns : void
  314. *
  315. *        Notes : N/A
  316. *
  317. ****************************************************************************/
  318. SOM_Scope void  SOMLINK PushButtonExternalize(PushButtonPart *somSelf,
  319.                                                Environment *ev)
  320. {
  321.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  322.     PushButtonPartMethodDebug("PushButtonPart","PushButtonExternalize");
  323.  
  324.     // Call the superclass (parent) Externalize method.
  325.     PushButtonPart_parent_ContainerPart_Externalize(somSelf,
  326.                                                     ev);
  327.  
  328.     // Retrieve a pointer to the part's storage unit.
  329.     ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  330.  
  331.     // Verify that the storage unit has the appropriate properties
  332.     // and values to allow us to run.  If not, add them.
  333.     somSelf->CheckAndAddProperties(ev, su);
  334.  
  335.     // Write out the part's content.
  336.     somSelf->ExternalizeContent(ev, su);
  337. }
  338.  
  339. /****************************************************************************
  340. *
  341. *    Method(s) : PushButtonCloneInto()
  342. *
  343. *  Description : Deep-copy all properties and values of this storage
  344. *                unit to the specified toSU.
  345. *
  346. *   Parameters : PushButtonPart *somSelf - References the object which should
  347. *                                          externalize its data
  348. *                Environment *ev         - References SOM environment
  349. *                                          information
  350. *                ODDraftKey key          - Identifying the clone transaction.
  351. *                ODStorageUnit* toSU     - All storage units cloned from
  352. *                                          this point on should be within
  353. *                                          the scope of this ODFrame.
  354. *                ODFrame* scope          - All storage units cloned from
  355. *                                          this point on should be within
  356. *                                          the scope of this ODFrame.
  357. *
  358. *      Returns : void
  359. *
  360. *        Notes : N/A
  361. *
  362. ****************************************************************************/
  363. SOM_Scope void  SOMLINK PushButtonCloneInto(PushButtonPart *somSelf,
  364.                                              Environment *ev,
  365.                                             ODDraftKey key, ODStorageUnit* toSU,
  366.                                             ODFrame* scope)
  367. {
  368.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  369.     PushButtonPartMethodDebug("PushButtonPart","PushButtonCloneInto");
  370.  
  371.     // Call the superclass (parent) CloneInto method.
  372.     PushButtonPart_parent_ContainerPart_CloneInto(somSelf, ev, key,
  373.                                                   toSU, scope);
  374.  
  375.     // We must first verify that we've never written to this storage unit.
  376.     // If we have, we should do nothing, otherwise we need to write out
  377.     // the current state of the part content.
  378.     if ( !toSU->Exists(ev, kODPropContents, kPushButtonTextType, 0) ) {
  379.        // Add the properties we need to successfully externalize
  380.        // ourselves into the destination storage unit.
  381.        somSelf->CheckAndAddProperties(ev, toSU);
  382.  
  383.        // Write out the part's content.
  384.        somSelf->ExternalizeContent(ev, toSU);
  385.     }
  386. }
  387.  
  388. /****************************************************************************
  389. *
  390. *    Method(s) : PushButtonCheckAndAddProperties()
  391. *
  392. *  Description : This method is called during externalization of the part to
  393. *                verify all the properties needed to persistently represent
  394. *                the current running state of the part.
  395. *
  396. *   Parameters : PushButtonPart *somSelf - References the object which should
  397. *                                          externalize its data
  398. *                Environment *ev         - References SOM environment
  399. *                                          information
  400. *                ODStorageUnit* storageUnit - Reference the storage unit to
  401. *                                             save the data
  402. *
  403. *      Returns : void
  404. *
  405. *        Notes : N/A
  406. *
  407. ****************************************************************************/
  408. SOM_Scope void  SOMLINK PushButtonCheckAndAddProperties(PushButtonPart *somSelf,
  409.                                                          Environment *ev,
  410.                                                         ODStorageUnit* storageUnit)
  411. {
  412.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  413.     PushButtonPartMethodDebug("PushButtonPart","PushButtonCheckAndAddProperties");
  414.  
  415.     // Add the Contents Property (kODPropContents) to the storage unit.
  416.     // The Push Button part's contents is the text which is displayed
  417.     // on the Push Button.
  418.     if ( !storageUnit->Exists(ev, kODPropContents, kODNULL, 0) )
  419.        storageUnit->AddProperty(ev, kODPropContents);
  420.     if ( !storageUnit->Exists(ev, kODPropContents, kPushButtonTextType, 0) )
  421.        storageUnit->AddValue(ev, kPushButtonTextType);
  422.  
  423.     // The Push Button part's attribute data includes:
  424.     // 1. the frame negotiation flag - whether an initial frame size has
  425.     //    been negotiated with its containing part.
  426.     if ( !storageUnit->Exists(ev, kODPropPushButtonAttr, kODNULL, 0) )
  427.        storageUnit->AddProperty(ev, kODPropPushButtonAttr);
  428.     if ( !storageUnit->Exists(ev, kODPropPushButtonAttr, kPushButtonAttrType, 0) )
  429.        storageUnit->AddValue(ev, kPushButtonAttrType);
  430. }
  431.  
  432. /****************************************************************************
  433. *
  434. *    Method(s) : PushButtonExternalizeContent()
  435. *
  436. *  Description : This method is called during externalization of the part. The
  437. *                content of the part should be written out.
  438. *
  439. *   Parameters : PushButtonPart *somSelf - References the object which should
  440. *                                          externalize its data
  441. *                Environment *ev         - References SOM environment
  442. *                                          information
  443. *                ODStorageUnit* storageUnit - Reference the storage unit to
  444. *                                             save the data
  445. *
  446. *      Returns : void
  447. *
  448. *        Notes : N/A
  449. *
  450. ****************************************************************************/
  451. SOM_Scope void  SOMLINK PushButtonExternalizeContent(PushButtonPart *somSelf,
  452.                                                       Environment *ev,
  453.                                                      ODStorageUnit* storageUnit)
  454. {
  455.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  456.     PushButtonPartMethodDebug("PushButtonPart","PushButtonExternalizeContent");
  457.  
  458.     // Focus the storage unit to the value of preferred representation
  459.     // of its contents property and write out the value.
  460.  
  461.     // Focus the storage unit on the kODPropContents contents
  462.     // property and the kPushButtonTextType property value.
  463.     storageUnit->Focus(ev, kODPropContents, kODPosUndefined,
  464.                        kPushButtonTextType, 0, kODPosUndefined);
  465.  
  466.     // Write the Push Button text to its location in the part's storage unit.
  467.     StorageUnitSetValue(storageUnit, ev, TEXTBUFFERSIZE, (ODValue) _fBuffer);
  468.  
  469.     // Focus the storage unit on the kODPropPushButtonAttr attributes
  470.     // property and the kPushButtonAttrType property value.
  471.     storageUnit->Focus(ev, kODPropPushButtonAttr, kODPosUndefined,
  472.                        kPushButtonAttrType, 0, kODPosUndefined);
  473.  
  474.     // Write the contents of the fShowDefaultFrameSize flag (true or false,
  475.     // true will show the default frame size).
  476.     StorageUnitSetValue(storageUnit, ev, sizeof(_fShowDefaultFrameSize),
  477.                         (ODValue) &_fShowDefaultFrameSize);
  478. }
  479.  
  480. /****************************************************************************
  481. *
  482. *    Method(s) : PushButtonHandleEvent()
  483. *
  484. *  Description : The implementation of a part editor's HandleEvent method
  485. *                works in much the same way as event-handling code in a
  486. *                standard PM application.  This method is overridden
  487. *                in order to recognize the event of button ID when user
  488. *                clicks mouse button 1 in the content area of the part.
  489. *
  490. *   Parameters : PushButtonPart *somSelf - Pointer to the object which
  491. *                                          should handle the event
  492. *                Environment *ev         - References SOM environment
  493. *                                          information
  494. *                ODEventData* event      - References event data that indicates
  495. *                                          what type of event has occurred
  496. *                ODFrame* frame          - References the display frame for
  497. *                                          the part
  498. *                ODFacet* facet          - References the facet for this object
  499. *
  500. *      Returns : ODBoolean value describing if the event was processed or
  501. *                not
  502. *                   kODFalse = event was not processed by this method
  503. *                   kODTrue  = event was processed by this method
  504. *
  505. *
  506. *        Notes : N/A
  507. *
  508. ****************************************************************************/
  509. SOM_Scope ODBoolean  SOMLINK PushButtonHandleEvent(PushButtonPart *somSelf,
  510.                                                     Environment *ev,
  511.                                                    ODEventData* event,
  512.                                                    ODFrame* frame,
  513.                                                    ODFacet* facet,
  514.                                                    ODEventInfo* eventInfo)
  515. {
  516.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  517.     PushButtonPartMethodDebug("PushButtonPart","PushButtonHandleEvent");
  518.  
  519.     ODBoolean fHandled = kODFalse;  // Initialize the result flag to indicate
  520.                                     // that no event was processed by this
  521.                                     // method
  522.  
  523.     // Make sure we have a facet and the facet's window handle is same as
  524.     // the event's window handle.
  525.     if (facet && event->hwnd == facet->GetFacetHWND(ev)) {
  526.  
  527.        // A switch statement is used to determine if the event passed to the
  528.        // method can be handled by the method.  Note that a switch statement
  529.        // is used, rather than an if statement, to allow for expansion.  This
  530.        // style also mimics that of a PM window procedure.
  531.        switch (event->msg) {
  532.           case WM_COMMAND:
  533.  
  534.              // Verify the value of mp1 and handle the event if it matches
  535.              // the button ID.
  536.              switch (SHORT1FROMMP(event->mp1)) {
  537.                 case PB_ID:
  538.                    // Just beep and display a message box
  539.                    DosBeep(2000,100);
  540.                    DosBeep(1500,50);
  541.                    somSelf->DisplayMsgBox(ev, facet);
  542.                    break;
  543.  
  544.                 default:
  545.                    break;
  546.              }
  547.              fHandled = kODTrue;
  548.              break;
  549.  
  550.           default:
  551.              break;
  552.        }
  553.     }
  554.  
  555.     // Call and return the superclass (parent) HandleEvent method.
  556.     // (if the event was not handled by this push button part).
  557.     if (fHandled == kODFalse) {
  558.        return (PushButtonPart_parent_ContainerPart_HandleEvent(somSelf,
  559.                                                                ev,
  560.                                                                event,
  561.                                                                frame,
  562.                                                                facet,
  563.                                                                eventInfo));
  564.     }
  565.     else {
  566.        return fHandled;
  567.     }
  568. }
  569.  
  570. /****************************************************************************
  571. *
  572. *    Method(s) : PushButtonFacetAdded()
  573. *
  574. *  Description : This method notifies this frame that a facet has been
  575. *                added to it.
  576. *
  577. *                The facet being added calls this method on its frame.
  578. *                The frame in turn calls the parent's FacetAdded method
  579. *                to notify its part that a facet has been added to one
  580. *                of its frames.
  581. *
  582. *   Parameters : PushButtonPart *somSelf - References the object
  583. *                Environment *ev         - References SOM environment
  584. *                                          information
  585. *                ODFacet* facet          - A reference to the facet to be added
  586. *
  587. *      Returns : void
  588. *
  589. *        Notes : N/A
  590. *
  591. ****************************************************************************/
  592. SOM_Scope void  SOMLINK PushButtonFacetAdded(PushButtonPart *somSelf,
  593.                                               Environment *ev,
  594.                                              ODFacet* facet)
  595. {
  596.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  597.     PushButtonPartMethodDebug("PushButtonPart","PushButtonFacetAdded");
  598.  
  599.     // Call the superclass (parent) FacetAdded method.
  600.     // If you don't call the parent method then your embedded part(s) will
  601.     // not show up when you drag and drop the push button to a container part
  602.     PushButtonPart_parent_ContainerPart_FacetAdded(somSelf, ev,
  603.                                                    facet);
  604.  
  605.     HWND hwndFacet = facet->GetFacetHWND(ev);   // Window handle of facet.
  606.  
  607.     // If find facet's window handle
  608.     if ( hwndFacet ) {
  609.  
  610.        // Use PM control to create this push button
  611.        // We will give the position and size information of the window
  612.        // in GeometryChanged method
  613.  
  614.        _hwndPushButton = WinCreateWindow(hwndFacet, WC_BUTTON, _fBuffer,
  615.                                          BS_PUSHBUTTON | BS_DEFAULT | BS_TEXT,
  616.                                          0, 0, 0, 0,
  617.                                          hwndFacet, HWND_TOP, PB_ID, 0, 0);
  618.  
  619.        ULONG ulStyle = WinQueryWindowULong(_hwndPushButton, QWL_STYLE);
  620.        WinSetWindowULong(_hwndPushButton,
  621.                          QWL_STYLE,
  622.                          ulStyle & ~WS_PARENTCLIP);
  623.  
  624.        ODFrame* frame = facet->GetFrame(ev);
  625.  
  626.        if ( _fShowDefaultFrameSize == kODFalse ) {
  627.           // No frame negotiation.  The part is initialized from the
  628.           // storage unit.
  629.  
  630.           ODTypeToken view = frame->GetViewType(ev);
  631.  
  632.           // Make sure we display our part in correct view type.
  633.           // Force to setup a correct used shape for different view types and
  634.           // only frame view and thumbnail view need to call GeometryChanged
  635.           // method to display the Button.
  636.           if ( view == _FrameView ) {
  637.              // Size and repaint the window.
  638.              somSelf->GeometryChanged(ev, facet, kODFalse, kODFalse);
  639.           }
  640.           else {
  641.              somSelf->ViewTypeChanged(ev, frame);
  642.              if ( view == _ThumbnailView )
  643.                 // Size and repaint the window.
  644.                 somSelf->GeometryChanged(ev, facet, kODFalse, kODFalse);
  645.           }
  646.        }
  647.        else {
  648.           // Do the frame negotiation
  649.  
  650.           // Setup Push Button size in OpenDoc coordinate
  651.           // The MAKEFIXED macro creates a fixed value from an
  652.           // integer and a faction.
  653.           ODRect newRect = { 0, MAKEFIXED(PB_HEIGHT,0),
  654.                              MAKEFIXED(PB_WIDTH,0), 0 };
  655.           ODShape* newShape = frame->CreateShape(ev);
  656.           newShape->SetRectangle(ev, &newRect);
  657.  
  658.           // Negotiate the display frame size with its containing part.
  659.           // There is no need to argue with containing part, so just accept
  660.           // the shape.
  661.           frame->RequestFrameShape(ev, newShape, kODNULL);
  662.           ODReleaseObject(ev, newShape);
  663.  
  664.           _fShowDefaultFrameSize = kODFalse;
  665.  
  666.           // Size and repaint the window.
  667.           somSelf->GeometryChanged(ev, facet, kODFalse, kODFalse);
  668.        }
  669.  
  670.        // Make sure we act on the drag and drop event.
  671.        facet->SetHandleMouseEvents(ev, kODPartHandlesDragDropEvents);
  672.     }
  673. }
  674.  
  675. /****************************************************************************
  676. *
  677. *    Method(s) : PushButtonFacetRemoved()
  678. *
  679. *  Description : This method notifies this frame that a facet has been
  680. *                removed from it.
  681. *
  682. *                The facet being removed calls this method on its frame.
  683. *                The frame in turn calls the ODPart::FacetRemoved method
  684. *                to notify its part that a facet has been removed from one
  685. *                of its frames.
  686. *
  687. *   Parameters : PushButtonPart *somSelf - References the object
  688. *                Environment *ev         - References SOM environment
  689. *                                          information
  690. *                ODFacet* facet          - A reference to the facet to be
  691. *                                          removed
  692. *
  693. *      Returns : void
  694. *
  695. *        Notes : N/A
  696. *
  697. ****************************************************************************/
  698. SOM_Scope void  SOMLINK PushButtonFacetRemoved(PushButtonPart *somSelf,
  699.                                                 Environment *ev,
  700.                                                ODFacet* facet)
  701. {
  702.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  703.     PushButtonPartMethodDebug("PushButtonPart","PushButtonFacetRemoved");
  704.  
  705.     // Destroy the push button window handle if find any
  706.     if ( _hwndPushButton != kODNULL )
  707.        WinDestroyWindow(_hwndPushButton);
  708.  
  709.     // Call the superclass (parent) FacetRemoved method.
  710.     PushButtonPart_parent_ContainerPart_FacetRemoved(somSelf, ev,
  711.                                                      facet);
  712. }
  713.  
  714. /****************************************************************************
  715. *
  716. *    Method(s) : PushButtonGeometryChanged()
  717. *
  718. *  Description : This method is called to inform your part that the clipping
  719. *                shape and/or external transform of one of its facets has
  720. *                changed.
  721. *
  722. *   Parameters : PushButtonPart *somSelf - References the object
  723. *                Environment *ev         - References SOM environment
  724. *                                          information
  725. *                ODFacet* facet          - A refernece to the facet where
  726. *                                          the clip shape has changed
  727. *
  728. *      Returns : void
  729. *
  730. *        Notes : N/A
  731. *
  732. ****************************************************************************/
  733. SOM_Scope void  SOMLINK PushButtonGeometryChanged(PushButtonPart *somSelf,
  734.                                                    Environment *ev,
  735.                                                   ODFacet* facet,
  736.                                                   ODBoolean clipShapeChanged,
  737.                                                   ODBoolean externalTransformChanged)
  738. {
  739.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  740.     PushButtonPartMethodDebug("PushButtonPart","PushButtonGeometryChanged");
  741.  
  742.     // Push Button has been created
  743.     if (_hwndPushButton) {
  744.        MATRIXLF mtx;    // Transformation matrix-elements structure.
  745.        ODRect rect;     // Rectangle whose sides are aligned with the axes
  746.                         // of the OpenDoc coordinate system.
  747.  
  748.        ODTransform* transform = facet->AcquireFrameTransform(ev, kODNULL);
  749.  
  750.        // We want to display the PushButton if our frame transform specifies
  751.        // only translation and scale (no reflection, rotation or shear).
  752.        transform->GetMATRIXLF(ev, &mtx);
  753.        if (mtx.fxM12 == 0 && mtx.fxM21 == 0 && mtx.fxM11 > 0 && mtx.fxM22  > 0 ) {
  754.  
  755.           // Hide the push button window first before we do any updates
  756.           WinShowWindow(_hwndPushButton, FALSE);
  757.  
  758.           ODTypeToken view = facet->GetFrame(ev)->GetViewType(ev);
  759.  
  760.           // Get the smallest retangle that contains this shape and use it
  761.           // to set the position and size of push button window.
  762.           // Use used shape when in thumbnail view and use frame shape when
  763.           // in other types of view.
  764.           if ( view == _ThumbnailView ) {
  765.              ODShape* usedShape = facet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL);
  766.              usedShape->GetBoundingBox(ev, &rect);
  767.              ODReleaseObject(ev, usedShape);
  768.           }
  769.           else {
  770.              ODShape* frameShape= facet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
  771.              frameShape->GetBoundingBox(ev, &rect);
  772.              ODReleaseObject(ev, frameShape);
  773.           }
  774.           ODPoint botLeft  = {rect.left, rect.bottom};
  775.           ODPoint topRight = {rect.right, rect.top};
  776.           transform->TransformPoint(ev, &botLeft);
  777.           transform->TransformPoint(ev, &topRight);
  778.           WinSetWindowPos(_hwndPushButton, 0,
  779.                           FIXED2LONG(botLeft.x),
  780.                           FIXED2LONG(botLeft.y),
  781.                           FIXED2LONG(topRight.x - botLeft.x),
  782.                           FIXED2LONG(topRight.y - botLeft.y),
  783.                           SWP_MOVE | SWP_SIZE);
  784.  
  785.           // Make a local copy of the aggregate clip shape and use it
  786.           // to get the transform object that represents the window
  787.           // frame transform associated with this facet.
  788.           ODShape* tempShape = facet->AcquireAggregateClipShape(ev, kODNULL);
  789.           ODShape* clipShape = tempShape->Copy(ev);
  790.           ODReleaseObject(ev, tempShape);
  791.           ODTransform* windowFrameTransform = facet->AcquireWindowFrameTransform(ev, kODNULL);
  792.           clipShape->Transform(ev, windowFrameTransform);
  793.           ODReleaseObject(ev, windowFrameTransform);
  794.  
  795.           // Clip shape is in window coords of my facet window.
  796.           // Move to window coords of the PushButton window.
  797.           ODTransform* offset = new ODTransform;
  798.           botLeft.x = -botLeft.x;
  799.           botLeft.y = -botLeft.y;
  800.           offset->SetOffset(ev, &botLeft);
  801.           clipShape->Transform(ev, offset);
  802.  
  803.           // Set window clipping
  804.           // This API will support of proper clipping of non-OpenDoc aware
  805.           // windows (PM controls) within OpenDoc.  Since OpenDoc parts
  806.           // may have arbitrary (non-rectangular) clip shapes, any PM control
  807.           // windows within an OpenDoc part may need to be clipped to a
  808.           // shape which is determined by the clip shape of it's
  809.           // containing part and/or the clip shapes of overlapping parts.
  810.           WinSetClipRegion(_hwndPushButton, clipShape->GetRegion(ev));
  811.  
  812.           delete clipShape;
  813.  
  814.           // Set the window to visible state when in frame and thumbnail view.
  815.           if ( view == _FrameView || view == _ThumbnailView )
  816.              WinShowWindow(_hwndPushButton, TRUE);
  817.           else
  818.              WinShowWindow(_hwndPushButton, FALSE);
  819.        }
  820.        else {
  821.           // We can't properly display the PushButton in this frame with
  822.           // the given transform.  Hide the window and we'll draw the text
  823.           // into the frame in our Draw method.
  824.           WinShowWindow(_hwndPushButton, FALSE);
  825.        }
  826.        ODReleaseObject(ev, transform);
  827.     }
  828.  
  829.     // Call the superclass (parent) GeometryChanged method.
  830.     // If you don't call the parent method then your embedded part(s) will
  831.     // not move together with push button part.
  832.     PushButtonPart_parent_ContainerPart_GeometryChanged(somSelf,
  833.                                                         ev, facet,
  834.                                                         clipShapeChanged,
  835.                                                         externalTransformChanged);
  836. }
  837.  
  838. /****************************************************************************
  839. *
  840. *    Method(s) : PushButtonDraw()
  841. *
  842. *  Description : This method tells the part associated with this facet to
  843. *                draw itself within the portion of the PushButton part
  844. *                that needs updating in this facet.
  845. *
  846. *   Parameters : PushButtonPart *somSelf - A pointer to the object to be drawn
  847. *                Environment *ev         - References the SOM environment
  848. *                                          information
  849. *                ODFacet* facet          - References the facet for this object
  850. *                ODShape* invalidShape   - References the update shape,
  851. *                                          expressed in the coordinate
  852. *                                          system of the facet's frame
  853. *
  854. *      Returns : void
  855. *
  856. *        Notes : N/A
  857. *
  858. ****************************************************************************/
  859. SOM_Scope void  SOMLINK PushButtonDraw(PushButtonPart *somSelf,
  860.                                         Environment *ev, ODFacet* facet,
  861.                                        ODShape* invalidShape)
  862. {
  863.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  864.     PushButtonPartMethodDebug("PushButtonPart","PushButtonDraw");
  865.  
  866.     // Get the current view type - how the part is currently display.
  867.     ODTypeToken view = facet->GetFrame(ev)->GetViewType(ev);
  868.  
  869.     if ( view == _FrameView ) {
  870.        // Don't need to do anything here since we ask PM to draw this
  871.        // push button.
  872.     }
  873.     else if ( view == _LargeIconView ) {
  874.        // Set Push Button window to invisible state and invoke
  875.        // DrawIconView with size (length of one side) set to LARGEICONSIZE.
  876.        WinShowWindow(_hwndPushButton, FALSE);
  877.        somSelf->DrawIconView(ev, facet, LARGEICONSIZE);
  878.     }
  879.     else if ( view == _SmallIconView ) {
  880.        // Set Push Button window to invisible state and invoke
  881.        // DrawIconView with size (length of one side) set to SMALLICONSIZE.
  882.        WinShowWindow(_hwndPushButton, FALSE);
  883.        somSelf->DrawIconView(ev, facet, SMALLICONSIZE);
  884.     }
  885.     else if ( view == _ThumbnailView )
  886.        // Invoke DrawThumbnailView.
  887.        somSelf->DrawThumbnailView(ev, facet);
  888. }
  889.  
  890. /****************************************************************************
  891. *
  892. *  Standard View Types
  893. *
  894. ****************************************************************************/
  895.  
  896. /****************************************************************************
  897. *
  898. *    Method(s) : PushButtonViewTypeChanged()
  899. *
  900. *  Description : This method is called to notify Push Button part that the
  901. *                view type of one of its embedded frames has been changed.
  902. *
  903. *   Parameters : PushButtonPart *somSelf - A pointer to the object to be drawn
  904. *                Environment *ev         - References the SOM environment
  905. *                                          information
  906. *                ODFrame frame           - A reference to a display frame of
  907. *                                          push button part
  908. *
  909. *      Returns : void
  910. *
  911. *        Notes : N/A
  912. *
  913. ****************************************************************************/
  914. SOM_Scope void  SOMLINK PushButtonViewTypeChanged(PushButtonPart *somSelf,
  915.                                                    Environment *ev,
  916.                                                   ODFrame* frame)
  917. {
  918.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  919.     PushButtonPartMethodDebug("PushButtonPart","PushButtonViewTypeChanged");
  920.  
  921.     // Call the superclass (parent) ViewTypeChanged method.
  922.     PushButtonPart_parent_ContainerPart_ViewTypeChanged(somSelf,
  923.                                                         ev, frame);
  924.  
  925.     // Obtain the current view type
  926.     ODTypeToken view = frame->GetViewType(ev);
  927.  
  928.     // The view field may be null, if so, we prefer to be displayed
  929.     // in a frame view.
  930.     if ( view == kODNullTypeToken )
  931.        frame->SetViewType(ev, _FrameView);
  932.  
  933.     ODRect usedShapeRect;                 // Used shape rectangle.
  934.     ODShape* newUsedShape = new ODShape();
  935.  
  936.     // Obtain a copy of used shape from frame shape.
  937.     ODShape* frameShape = frame->AcquireFrameShape(ev, kODNULL);
  938.     newUsedShape->CopyFrom(ev, frameShape);
  939.     ODReleaseObject(ev, frameShape);
  940.  
  941.     // Obtain the used shape's bounding box
  942.     newUsedShape->GetBoundingBox(ev, &usedShapeRect);
  943.  
  944.     CHAR szFontNameSize[TEXTBUFFERSIZE];  // Buffer to store font name and size.
  945.  
  946.     if ( view == _FrameView ) {
  947.        // Reset used shape to frame shape
  948.        frame->ChangeUsedShape(ev, kODNULL, kODNULL);
  949.  
  950.        // Set the text on button to default font and size
  951.        strcpy( szFontNameSize, "10.System Proportional Non-ISO" );
  952.        WinSetPresParam( _hwndPushButton,
  953.                         PP_FONTNAMESIZE,
  954.                         strlen( szFontNameSize ) + 1,
  955.                         (PVOID)szFontNameSize );
  956.     }
  957.     else if ( view == _LargeIconView ) {
  958.        // Change the new used shape rectangle dimensions to the LARGEICONSIZE.
  959.        ODRect Rect = { 0, MAKEFIXED(LARGEICONSIZE,0), MAKEFIXED(LARGEICONSIZE,0), 0};
  960.        newUsedShape->SetRectangle(ev, &Rect);
  961.        frame->ChangeUsedShape(ev, newUsedShape, kODNULL);
  962.     }
  963.     else if ( view == _SmallIconView ) {
  964.        // Change the new used shape rectangle dimensions to the SMALLICONSIZE.
  965.        ODRect Rect = { 0, MAKEFIXED(SMALLICONSIZE,0), MAKEFIXED(SMALLICONSIZE,0), 0};
  966.        newUsedShape->SetRectangle(ev, &Rect);
  967.        frame->ChangeUsedShape(ev, newUsedShape, kODNULL);
  968.     }
  969.     else if ( view == _ThumbnailView ) {
  970.        // Change the new used shape rectangle dimensions to the THUMBNAILSIZE.
  971.        ODRect Rect = { 0, MAKEFIXED(THUMBNAILSIZE,0), MAKEFIXED(THUMBNAILSIZE,0), 0};
  972.        newUsedShape->SetRectangle(ev, &Rect);
  973.        frame->ChangeUsedShape(ev, newUsedShape, kODNULL);
  974.  
  975.        // Set the text on button to a different font and smaller size than
  976.        // frame view.
  977.        strcpy( szFontNameSize, "4.System VIO" );
  978.        WinSetPresParam( _hwndPushButton,
  979.                         PP_FONTNAMESIZE,
  980.                         strlen( szFontNameSize ) + 1,
  981.                         (PVOID)szFontNameSize );
  982.     }
  983.  
  984.     // If Push Button part is the root part then force a redraw of the
  985.     // Push Button part else force a redraw of the containing part.
  986.     ODFrame* parentFrame = frame->AcquireContainingFrame(ev);
  987.     if ( parentFrame != kODNULL )
  988.        parentFrame->Invalidate(ev, kODNULL, kODNULL);
  989.     ODReleaseObject(ev, parentFrame);
  990. }
  991.  
  992. /****************************************************************************
  993. *
  994. *    Method(s) : PushButtonDrawIconView()
  995. *
  996. *  Description : Draw Push Button part as a large or small icon.
  997. *
  998. *   Parameters : PushButtonPart *somSelf - A pointer to the object to be drawn
  999. *                Environment *ev         - References the SOM environment
  1000. *                                          information
  1001. *                ODFacet* facet          - References the facet for this object
  1002. *                ODULong size            - The icon size in pixels. Size is
  1003. *                                          actually the length of one side,
  1004. *                                          either 32 (large) or 16 (small).
  1005. *
  1006. *      Returns : void
  1007. *
  1008. *        Notes : N/A
  1009. *
  1010. ****************************************************************************/
  1011. SOM_Scope void  SOMLINK PushButtonDrawIconView(PushButtonPart *somSelf,
  1012.                                                 Environment *ev,
  1013.                                                ODFacet* facet,
  1014.                                                ODULong size)
  1015. {
  1016.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  1017.     PushButtonPartMethodDebug("PushButtonPart","PushButtonDrawIconView");
  1018.  
  1019.     BITMAPINFOHEADER2 bmp;       // Bitmap information header structure.
  1020.  
  1021.     ODFrame* displayFrame = facet->GetFrame(ev);
  1022.  
  1023.     // Get the icon's dimensions in terms of OpenDoc's coordinate system.
  1024.     ODRect rect;
  1025.     ODShape* usedShape = displayFrame->AcquireUsedShape(ev, kODNULL);
  1026.     usedShape->GetBoundingBox(ev, &rect);
  1027.     ODReleaseObject(ev, usedShape);
  1028.     ODRECTL frameRect(rect);
  1029.  
  1030.     HBITMAP hbm,     // Bitmap handle associated with load from resource.
  1031.             hbmNew,  // New bitmap handle associated with bitmap created in memory.
  1032.             hbmOld;  // Old bitmap handle associated with selected bitmap.
  1033.     POINTL aptl[4];  // Target/source coordinate pair array.
  1034.  
  1035.     // Get PM Presentation Space from the facet.
  1036.     HPS hps = facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->GetPS(ev, facet);
  1037.  
  1038.     // Set the transformation matrix from content transform.
  1039.     MATRIXLF mtx;
  1040.     ODTransform* contentTransform = facet->AcquireContentTransform(ev, kODNULL);
  1041.     contentTransform->GetMATRIXLF(ev, &mtx);
  1042.     ODReleaseObject(ev, contentTransform);
  1043.     GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
  1044.  
  1045.     // Load the bitmap as resource identified by IDB_BMP.
  1046.     hbm = GpiLoadBitmap(hps, _ModuleHandle,
  1047.                         IDB_BMP,
  1048.                         size, size );
  1049.  
  1050.     // Query the contents of the bitmap information header and,
  1051.     // if successful, perform a BitBlt to the target PS.
  1052.     bmp.cbFix = sizeof(bmp);
  1053.     if (GpiQueryBitmapInfoHeader( hbm, &bmp ) == GPI_OK) {
  1054.  
  1055.        aptl[0].x = frameRect.xLeft;    // target rectangle left in worrld coordinate
  1056.        aptl[0].y = frameRect.yBottom;  // target rectangle bottom in worrld coordinate
  1057.        aptl[1].x = frameRect.xRight;   // target rectangle right in worrld coordinate
  1058.        aptl[1].y = frameRect.yTop;     // target rectangle top in worrld coordinate
  1059.        aptl[2].x = aptl[2].y = 0;      // source rectangle left and bottom
  1060.        aptl[3].x = bmp.cx;             // source rectangle right in worrld coordinate
  1061.        aptl[3].y = bmp.cy;             // source rectangle top in worrld coordinate
  1062.  
  1063.        // Perform a BitBlt of the bitmap to the target PS.
  1064.        if (GpiWCBitBlt(hps, hbm, 4, aptl, ROP_SRCCOPY, BBO_IGNORE) == GPI_ERROR) {
  1065.           DosBeep(700UL, 500UL);
  1066.        }
  1067.     }
  1068.  
  1069.     // Release access to the platform-specific drawing structure
  1070.     // (i.e., the Presentation Manager Presentation Space).
  1071.     facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->ReleasePS(ev, facet);
  1072. }
  1073.  
  1074. /****************************************************************************
  1075. *
  1076. *    Method(s) : PushButtonDrawThumbnailView()
  1077. *
  1078. *  Description : Draw the Push Button part as a thumbnail.
  1079. *
  1080. *   Parameters : PushButtonPart *somSelf - A pointer to the object to be drawn
  1081. *                Environment *ev         - References the SOM environment
  1082. *                                          information
  1083. *                ODFacet* facet          - References the facet for this object
  1084. *
  1085. *      Returns : void
  1086. *
  1087. *        Notes : N/A
  1088. *
  1089. ****************************************************************************/
  1090. SOM_Scope void  SOMLINK PushButtonDrawThumbnailView(PushButtonPart *somSelf,
  1091.                                                      Environment *ev,
  1092.                                                     ODFacet* facet)
  1093. {
  1094.     PushButtonPartData *somThis = PushButtonPartGetData(somSelf);
  1095.     PushButtonPartMethodDebug("PushButtonPart","PushButtonDrawThumbnailView");
  1096.  
  1097.     // Size and repaint the window.
  1098.     somSelf->GeometryChanged(ev, facet, kODFalse, kODFalse);
  1099. }
  1100.  
  1101. /****************************************************************************
  1102. *
  1103. *  Part Registration
  1104. *
  1105. ****************************************************************************/
  1106.  
  1107. /****************************************************************************
  1108. *
  1109. *    Method(s) : M_PushButtonPartclsGetODPartHandlerName()
  1110. *
  1111. *  Description : Return the SOM class name (PushButtonPart) to the
  1112. *                registration process.
  1113. *
  1114. *   Parameters : M_PushButtonPart *somSelf - References the SOM object
  1115. *                Environment *ev           - References the SOM environment
  1116. *                                            information
  1117. *
  1118. *      Returns : ISOString    - SOM class name of Push Button part
  1119. *
  1120. *        Notes : N/A
  1121. *
  1122. ****************************************************************************/
  1123. SOM_Scope ISOString  SOMLINK M_PushButtonPartclsGetODPartHandlerName(M_PushButtonPart *somSelf,
  1124.                                                                       Environment *ev)
  1125. {
  1126.     /* M_PushButtonPartData *somThis = M_PushButtonPartGetData(somSelf); */
  1127.     M_PushButtonPartMethodDebug("M_PushButtonPart","M_PushButtonPartclsGetODPartHandlerName");
  1128.  
  1129.     // Set string to the Part Handler, or SOM class ("PushButtonPart")
  1130.     ISOString partHandlerName = kPartHandlerName;
  1131.     return partHandlerName;
  1132. }
  1133.  
  1134. /****************************************************************************
  1135. *
  1136. *    Method(s) : M_PushButtonPartclsGetODPartHandlerDisplayName()
  1137. *
  1138. *  Description : Return the part handler name OpenDoc will associate with
  1139. *                its template to the registration.
  1140. *
  1141. *   Parameters : M_PushButtonPart *somSelf - References the SOM object
  1142. *                Environment *ev           - References the SOM environment
  1143. *                                            information
  1144. *
  1145. *      Returns : string    - Part handler display name
  1146. *
  1147. *        Notes : N/A
  1148. *
  1149. ****************************************************************************/
  1150. SOM_Scope string  SOMLINK M_PushButtonPartclsGetODPartHandlerDisplayName(M_PushButtonPart *somSelf,
  1151.                                                                           Environment *ev)
  1152. {
  1153.     /* M_PushButtonPartData *somThis = M_PushButtonPartGetData(somSelf); */
  1154.     M_PushButtonPartMethodDebug("M_PushButtonPart","M_PushButtonPartclsGetODPartHandlerDisplayName");
  1155.  
  1156.     // Set string to the Part Handler Display name ("Push Button Part")
  1157.     string partHandlerDisplayName = kPartHandlerDisplayName;
  1158.     return partHandlerDisplayName;
  1159. }
  1160.  
  1161. /****************************************************************************
  1162. *
  1163. *    Method(s) : M_PushButtonPartclsGetODPartKinds()
  1164. *
  1165. *  Description : Return the Push Button part handler's Part Kind data to
  1166. *                the registration process.  Place the data in a record
  1167. *                structure and return it.
  1168. *
  1169. *   Parameters : M_PushButtonPart *somSelf - References the SOM object
  1170. *                Environment *ev           - References the SOM environment
  1171. *                                            information
  1172. *
  1173. *      Returns : _IDL_SEQUENCE_PartKindInfo  - Part Kind record structure
  1174. *
  1175. *        Notes : N/A
  1176. *
  1177. ****************************************************************************/
  1178. SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_PushButtonPartclsGetODPartKinds(M_PushButtonPart *somSelf,
  1179.                                                                                  Environment *ev)
  1180. {
  1181.     /* M_PushButtonPartData *somThis = M_PushButtonPartGetData(somSelf); */
  1182.     M_PushButtonPartMethodDebug("M_PushButtonPart","M_PushButtonPartclsGetODPartKinds");
  1183.  
  1184.     // Structure which contains tha part's part kind information.  This is
  1185.     // information about the data types the part supports.
  1186.     _IDL_SEQUENCE_PartKindInfo PushButtonPartInfo;
  1187.  
  1188.     // Create structure PartKindInfo and allocate memory for variable
  1189.     PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
  1190.     info->partKindName = (ISOString) SOMMalloc(strlen(kKindPushButtonPart) + 1);
  1191.     info->partKindDisplayName = (string)SOMMalloc(strlen(kKindDisplayName)+1);
  1192.     info->filenameFilters =  (string)SOMMalloc(strlen("")+1);
  1193.     info->filenameTypes =  (string)SOMMalloc(strlen("")+1);
  1194.     info->categories =  (string)SOMMalloc(strlen(kODCategoryControl)+1);
  1195.     info->categoryDisplayName =  (string)SOMMalloc(strlen(kCategory)+1);
  1196.     info->objectID =  (string)SOMMalloc(strlen("")+1);
  1197.  
  1198.     // Copy the information into the structure
  1199.     strcpy(info->partKindName , kKindPushButtonPart);
  1200.     strcpy(info->partKindDisplayName, kKindDisplayName);
  1201.     strcpy(info->filenameFilters, "");
  1202.     strcpy(info->filenameTypes, "");
  1203.     strcpy(info->categories, kODCategoryControl);
  1204.     strcpy(info->categoryDisplayName, kCategory);
  1205.     strcpy(info->objectID, "");
  1206.  
  1207.     PushButtonPartInfo._maximum = 1;
  1208.     PushButtonPartInfo._length = 1;
  1209.     PushButtonPartInfo._buffer = info;
  1210.  
  1211.     return PushButtonPartInfo;
  1212. }
  1213.  
  1214. /****************************************************************************
  1215. *
  1216. *    Method(s) : M_PushButtonPartclsGetOLE2ClassId()
  1217. *
  1218. *  Description : Return the OLE 2 identifier to the registration process.
  1219. *
  1220. *   Parameters : M_PushButtonPart *somSelf - References the SOM object
  1221. *                Environment *ev           - References the SOM environment
  1222. *                                            information
  1223. *
  1224. *      Returns : string    - OLE2 class id
  1225. *
  1226. *        Notes : N/A
  1227. *
  1228. ****************************************************************************/
  1229. SOM_Scope string  SOMLINK M_PushButtonPartclsGetOLE2ClassId(M_PushButtonPart *somSelf,
  1230.                                                              Environment *ev)
  1231. {
  1232.     /* M_PushButtonPartData *somThis = M_PushButtonPartGetData(somSelf); */
  1233.     M_PushButtonPartMethodDebug("M_PushButtonPart","M_PushButtonPartclsGetOLE2ClassId");
  1234.  
  1235.     // The OLE2 class identifier is current empty.
  1236.     string classID = "";
  1237.     return classID;        // Return the empty string.
  1238. }
  1239.  
  1240. /****************************************************************************
  1241. *
  1242. *    Method(s) : M_PushButtonPartclsGetWindowsIconFileName()
  1243. *
  1244. *  Description : Return the file name of the icon to be associated with
  1245. *                the Push Button part handler's template to the
  1246. *                registration process.
  1247. *
  1248. *   Parameters : M_PushButtonPart *somSelf - References the SOM object
  1249. *                Environment *ev           - References the SOM environment
  1250. *                                            information
  1251. *
  1252. *      Returns : string    - Icon file name
  1253. *
  1254. *        Notes : N/A
  1255. *
  1256. ****************************************************************************/
  1257. SOM_Scope string  SOMLINK M_PushButtonPartclsGetWindowsIconFileName(M_PushButtonPart *somSelf,
  1258.                                                                      Environment *ev)
  1259. {
  1260.     /* M_PushButtonPartData *somThis = M_PushButtonPartGetData(somSelf); */
  1261.     M_PushButtonPartMethodDebug("M_PushButtonPart","M_PushButtonPartclsGetWindowsIconFileName");
  1262.  
  1263.     // There is no icon associated with the Push Button part handler.
  1264.     string iconFileName = "";
  1265.     return iconFileName;   // Return the empty string.
  1266. }
  1267.  
  1268. /****************************************************************************
  1269. *                                End of File
  1270. ****************************************************************************/
  1271.