home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WOLEOBJ.HPP < prev    next >
C/C++ Source or Header  |  1996-12-06  |  19KB  |  543 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WOleObject -- Ole Object class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *      Click                   -- the user clicked on the object
  19.  *
  20.  *      ContextMenu             -- the context menu event
  21.  *
  22.  *      LeftButtonDown          -- the left mouse button has been depressed
  23.  *
  24.  *      LeftButtonDouble        -- the left mouse button double clicked
  25.  *
  26.  *      LeftButtonUp            -- the left mouse button has been released
  27.  *
  28.  *      MiddleButtonDown        -- the middle mouse button has been depressed
  29.  *
  30.  *      MiddleButtonDouble      -- the middle mouse button double clicked
  31.  *
  32.  *      MiddleButtonUp          -- the middle mouse button has been released
  33.  *
  34.  *      RightButtonDown         -- the right mouse button has been depressed
  35.  *
  36.  *      RightButtonDouble       -- the right mouse button double clicked
  37.  *
  38.  *      RightButtonUp           -- the right mouse button has been released
  39.  *
  40.  *      PropertyRequestEdit     -- a property is asking if it may be changed
  41.  *
  42.  *      PropertyChanged         -- a property has changed
  43.  *
  44.  *      InplaceActivate         -- the object has been inplace activated
  45.  *
  46.  *      InplaceDeactivate       -- the object has been inplace deactivated
  47.  *
  48.  *      UIActivate              -- the object has been UI activated
  49.  *
  50.  *      UIDeactivate            -- the object has been UI deactivated
  51.  *
  52.  *      PosRectChange           -- the position of the inplace window is
  53.  *                                 changing
  54.  *
  55.  *      ViewChange              -- the visible representation of the object
  56.  *                                 has changed
  57.  *
  58.  *      UpdateExtents           -- the objects extents ( size ) have changed
  59.  *
  60.  *      DragStart               -- a drag drop operation has been initiated
  61.  *                                 on this object
  62.  *
  63.  *      DragEnd                 -- a drag drop operation has ended
  64.  *                                 on this object
  65.  *
  66.  *      DragContinue            -- drag continue notification
  67.  *
  68.  *      DragFeedback            -- drag feedback notification
  69.  *
  70.  *      SimpleFramePreMessageFilter -- OLE simple frame pre-message filter
  71.  *
  72.  *      SimpleFramePostMessageFilter -- OLE simple frame post-message filter
  73.  *
  74.  *      DataClose               -- Data source event
  75.  *
  76.  *      DataOpen                -- Data source event
  77.  *
  78.  *      DataAvailable           -- Data source event
  79.  *
  80.  *      DataRequest             -- Data source event
  81.  *
  82.  *      ShowWindow              -- the object is showing/hiding its
  83.  *                                 application window
  84.  *
  85.  *************************************************************************/
  86.  
  87. #ifndef _WOLEOBJ_HPP_INCLUDED
  88. #define _WOLEOBJ_HPP_INCLUDED
  89.  
  90. #ifndef _WNO_PRAGMA_PUSH
  91. #pragma pack(push,8);
  92. #pragma enum int;
  93. #endif
  94.  
  95. #ifndef _WOLEAUTO_HPP_INCLUDED
  96. #   include "woleauto.hpp"
  97. #endif
  98.  
  99. #ifndef _WDEF_HPP_INCLUDED
  100. #   include "wdef.hpp"
  101. #endif
  102. #ifndef _WWINDOW_HPP_INCLUDED
  103. #   include "wwindow.hpp"
  104. #endif
  105. #ifndef _WOLEDEF_HPP_INCLUDED
  106. #   include "woledef.hpp"
  107. #endif
  108. #ifndef _WDSPHLPR_HPP_INCLUDED
  109. #   include "wdsphlpr.hpp"
  110. #endif
  111. #ifndef _WOLEPARM_HPP_INCLUDED
  112. #   include "woleparm.hpp"
  113. #endif
  114. #ifndef _WPOINT_HPP_INCLUDED
  115. #   include "wpoint.hpp"
  116. #endif
  117. #ifndef _WRECT_HPP_INCLUDED
  118. #   include "wrect.hpp"
  119. #endif
  120. #ifndef _WSTRING_HPP_INCLUDED
  121. #   include "wstring.hpp"
  122. #endif
  123. #ifndef _WDRAG_HPP_INCLUDED
  124. #   include "wdrag.hpp"
  125. #endif
  126. #ifndef _WDATATRG_HPP_INCLUDED
  127. #  include "wdatatrg.hpp"
  128. #endif
  129.  
  130. // forward class declarations
  131. class WDataSource;
  132. class WCMCLASS wllist_header;
  133.  
  134. class WCMCLASS WOleEmbeddedObject;
  135. class WCMCLASS WOleContainer;
  136. class WCMCLASS WMenu;
  137.  
  138. // property notification event data structure
  139. struct WPropertyEventData : public WEventData {
  140.     WDispID     property;
  141. };
  142.  
  143. struct WPosRectChangeEventData : public WEventData {
  144.     WRect       newPosition;
  145. };
  146.  
  147. struct WExtentsEventData : public WEventData {
  148.     WLong       cx;
  149.     WLong       cy;
  150. };
  151.  
  152. struct WSimpleFrameSiteEventData : public WMessageEventData {
  153.     WULong      cookie;
  154. };
  155.  
  156. struct WShowWindowEventData : public WMessageEventData {
  157.     WBool       open;
  158. };
  159.  
  160. // event notification callback type
  161.  
  162. typedef void WCMDEF (WObject::*WControlEventHandler)( WDispIndex, WDispID, WVariant *, WInt );
  163.  
  164. /* Draw Modes */
  165. enum WOleDrawMode {
  166.     WOleDrawMode_Stretch        = 0,
  167.     WOleDrawMode_Clip           = 1,
  168. };
  169.  
  170. /* Predefined Activation Verbs */
  171. enum WOleObjectVerb {
  172.     WOleVerb_PRIMARY            = (0),
  173.     WOleVerb_SHOW               = (-1),
  174.     WOleVerb_OPEN               = (-2),
  175.     WOleVerb_HIDE               = (-3),
  176.     WOleVerb_UIACTIVATE         = (-4),
  177.     WOleVerb_INPLACEACTIVATE    = (-5),
  178.     WOleVerb_DISCARDUNDOSTATE   = (-6),
  179.     WOleVerb_PROPERTIES         = (-7)
  180. };
  181.  
  182. /* Predefined User Types */
  183. enum WOleUserType {
  184.     WUserType_FULL              = 1,
  185.     WUserType_SHORT             = 2,
  186.     WUserType_APPNAME           = 3
  187. };
  188.  
  189. /* Predefined Automatic Activation Actions */
  190. enum WOleAutoActivateAction {
  191.     WOleAutoActivate_Manual             = 0,
  192.     WOleAutoActivate_Click              = 1,
  193.     WOleAutoActivate_DoubleClick        = 2,
  194. };
  195.  
  196. // **** to be removed
  197. #define WOleObjectVerb_PRIMARY          ((WOleObjectVerb)0L)
  198. #define WOleObjectVerb_SHOW             ((WOleObjectVerb)-1L)
  199. #define WOleObjectVerb_OPEN             ((WOleObjectVerb)-2L)
  200. #define WOleObjectVerb_HIDE             ((WOleObjectVerb)-3L)
  201. #define WOleObjectVerb_UIACTIVATE       ((WOleObjectVerb)-4L)
  202. #define WOleObjectVerb_INPLACEACTIVATE  ((WOleObjectVerb)-5L)
  203. #define WOleObjectVerb_DISCARDUNDOSTATE ((WOleObjectVerb)-6L)
  204. #define WOleObjectVerb_PROPERTIES       ((WOleObjectVerb)-7L)
  205.  
  206. #define WOLEDEF_FIRSTVERBID     20000
  207. #define WOLEDEF_LASTVERBID      20099
  208.  
  209. // the following is definitions of WOleObject
  210.  
  211. class WCMCLASS WOleObject : public WEventGenerator {
  212.     WDeclareSubclass( WOleObject, WEventGenerator );
  213.  
  214.     public:
  215.  
  216.         /**********************************************************
  217.          * Constructors and Destructors
  218.          *********************************************************/
  219.  
  220.         WOleObject();
  221.  
  222.         virtual ~WOleObject();
  223.  
  224.     public:
  225.  
  226.         /**************************************************************
  227.          * Properties
  228.          **************************************************************/
  229.  
  230.         // Class
  231.         WBool SetClass( const WString & cls, WOleContainer *parent=NULL );
  232.         WString GetClass() const;
  233.  
  234.         // Display Name
  235.         WBool SetDisplayName( const WString & displayName );
  236.         WString GetDisplayName() const;
  237.  
  238.         // Display As Default
  239.         WBool SetDisplayAsDefault( WBool set );
  240.         WBool GetDisplayAsDefault() const;
  241.  
  242.         // Inplace Active
  243.         WBool SetAllowInplaceActive( WBool inplaceActive );
  244.         WBool GetAllowInplaceActive() const;
  245.  
  246.         // Use Iconic Aspect
  247.         WBool SetUseIconicAspect( WBool use );
  248.         WBool GetUseIconicAspect() const;
  249.  
  250.         // Iconic Aspect
  251.         WBool SetIconicAspect( const WIcon icon );
  252.         WIcon GetIconicAspect() const;
  253.  
  254.         // Draw Select Handles
  255.         WBool SetDrawSelectHandles( WBool set );
  256.         WBool GetDrawSelectHandles() const;
  257.  
  258.         // Draggable
  259.         WBool SetDraggable( WBool set );
  260.         WBool GetDraggable() const;
  261.  
  262.         // Clippable
  263.         WBool SetClippable( WBool set );
  264.         WBool GetClippable() const;
  265.  
  266.         // Visible
  267.         WBool SetVisible( WBool set );
  268.         WBool GetVisible() const;
  269.  
  270.         // Use Object Extents
  271.         WBool SetUseObjectExtents( WBool set );
  272.         WBool GetUseObjectExtents() const;
  273.  
  274.         // AutoVerbMenu
  275.         WBool SetAutoVerbMenu( WBool set );
  276.         WBool GetAutoVerbMenu() const;
  277.  
  278.         // Rectangle
  279.         WBool SetRectangle( const WRect & r );
  280.         WRect GetRectangle( WBool absolute=FALSE ) const;
  281.  
  282.         // Size
  283.         WBool SetSize( const WPoint & p );
  284.         WPoint GetSize() const;
  285.  
  286.         // Hot Link
  287.         WBool SetHotLink( WBool set );
  288.         WBool GetHotLink() const;
  289.  
  290.         // Active
  291.         WBool SetActive( WBool set );
  292.         WBool GetActive() const;
  293.  
  294.         // Auto Activate Action
  295.         WBool SetAutoActivateAction( WOleAutoActivateAction action );
  296.         WOleAutoActivateAction GetAutoActivateAction() const;
  297.  
  298.         // Auto Activate Verb
  299.         WBool SetAutoActivateVerb( WOleObjectVerb verb );
  300.         WOleObjectVerb GetAutoActivateVerb() const;
  301.  
  302.         // Default bound property
  303.         WBool SetDefaultBoundProperty( const WString & prop );
  304.         WString GetDefaultBoundProperty( void ) const;
  305.  
  306.         // DataColumns
  307.         WString GetDataColumns() const;
  308.         WBool   SetDataColumns( const WString & cols );
  309.  
  310.         // DataSource
  311.         WDataSource *GetDataSource() const;
  312.         WBool        SetDataSource( WDataSource *source );
  313.  
  314.         // ResizePercentages
  315.         WRect GetResizePercentages() const;
  316.         WBool SetResizePercentages( const WRect & resizePercentages );
  317.  
  318.         // DrawMode
  319.         WBool SetDrawMode( WOleDrawMode mode );
  320.         WOleDrawMode GetDrawMode() const;
  321.  
  322.         // TabGroup
  323.         WBool SetTabGroup( WBool tabGroup );
  324.         WBool GetTabGroup() const;
  325.  
  326.         // TabStop
  327.         WBool SetTabStop( WBool tabStop );
  328.         WBool GetTabStop() const;
  329.  
  330.         // Focus
  331.         WBool SetFocus( WBool focus );
  332.         WBool GetFocus() const;
  333.  
  334.         // Remote Host
  335.         WBool SetRemoteHost( const WString & remoteHost );
  336.         WString GetRemoteHost() const;
  337.  
  338.         // read-only properties
  339.         WOleContainer *GetOleContainer() const;
  340.         WWindowHandle GetInplaceWindowHandle() const;
  341.         WBool GetSelected() const;
  342.         WBool GetOleControl() const;
  343.         WBool GetInsideOut() const;
  344.         WBool GetActivateWhenVisible() const;
  345.         WBool GetUsingAutomation() const;
  346.  
  347.         WPICursor GetICursor( void ) const;
  348.         WBool GetHasICursor( void ) const;
  349.  
  350.         WBool GetOpened() const;
  351.         WBool GetModified() const;
  352.         WBool GetLinked() const;
  353.         WBool GetInvisibleAtRuntime() const;
  354.         WBool GetActsLikeButton() const;
  355.         WBool GetActsLikeLabel() const;
  356.         WBool GetNoUIActivate() const;
  357.         WBool GetAlignable() const;
  358.         WBool GetSimpleFrame() const;
  359.         WBool GetIMEMode() const;
  360.  
  361.         WPIUnknown GetObjectInterface() const;
  362.         WPoint GetObjectExtent() const;
  363.         WString GetObjectClassID() const;
  364.         WULong GetObjectID();
  365.         WString GetUserType( WOleUserType type = WUserType_SHORT ) const;
  366.  
  367.         // read-only Licensing properties
  368.         WBool GetLicenseVerified() const;
  369.         WBool GetRuntimeKeyAvailable() const;
  370.         WBString GetRuntimeLicenseKey() const;
  371.  
  372.         // read-only Automation properties
  373.         WOleAutomationErrorInfo GetErrorInfo( void ) const;
  374.         WVariant GetLastResult( void ) const;
  375.         WVarType GetLastResultType( void ) const;
  376.  
  377.         // complex bound control properties
  378.         WBool SetBoundProperty( WDispID dispID, WObject *object );
  379.         WObject * GetBoundProperty( WDispID dispID );
  380.  
  381.         // event notification method
  382.         WBool SetOleEventHandler( WObject *source, WDispIndex disp_index,
  383.                                   WDispID disp_id,
  384.                                   WControlEventHandler handler );
  385.  
  386.         /**************************************************************
  387.          * Methods
  388.          **************************************************************/
  389.  
  390.         // creation, initialization and destruction functions
  391.         WBool Create( WOleContainer *parent, WString const & clsid,
  392.                       const WRect * r = NULL, const WBString *license=NULL );
  393.         WBool Create( WOleContainer *parent, const WRect * r = NULL,
  394.                       const WBString *license=NULL );
  395.         WBool CreateLink( WOleContainer *parent, WString const & linkSrc,
  396.                           const WRect * r = NULL,
  397.                           const WBString *license=NULL );
  398.         WBool CreateFromFile( WOleContainer *parent, WString const & filename,
  399.                               const WRect * r = NULL,
  400.                               const WBString *license=NULL );
  401.  
  402.         WBool Save( const WString *object_file=NULL );
  403.         WBool Load( WOleContainer *parent, const WString & object_file,
  404.                     WBool restoreProperties=TRUE );
  405.         WBool Load( WOleContainer *parent, const WResourceID & id,
  406.                     const WModule *module=NULL,
  407.                     WBool restoreProperties=TRUE );
  408.  
  409.         WBool Load( WOleContainer *parent, WPIStorage stg,
  410.                     const WString & stgName );
  411.         WBool Save( WPIStorage stg, WString & stgName );
  412.  
  413.         WBool Destroy();
  414.  
  415.         // Automation methods
  416.  
  417.         // the following will not cause ITypeInfo lookups
  418.         WBool Invoke( WMemberID memberID,
  419.                       WDispatchFlag flag, WUInt cvtParms,
  420.                       WVarType *vtParms, WVarType vtRet,
  421.                       void *result, ... );
  422.  
  423.         WBool Method( WMemberID memberID,
  424.                       WUInt cvtParms, WVarType *vtParms,
  425.                       WVarType vtRet, void *result, ... );
  426.  
  427.         WBool PropertyGet( WMemberID memberID, WVarType vtRet, void *result );
  428.         WBool PropertyPut( WMemberID memberID, WVarType vt, ... );
  429.         WBool PropertyPutRef( WMemberID memberID, WVarType vt, ... );
  430.  
  431.         WBool IDofName( const WString & name, WMemberID & id );
  432.  
  433.         WBool ClearDefaultBoundProperty( void );
  434.         WBool DefaultBoundPropertyPut( const WVariant & val );
  435.         WVariant DefaultBoundPropertyGet( void );
  436.         WBool DataSourceChanged( WDispID dispID );
  437.         WBool AllDataSourcesChanged( void );
  438.  
  439.         // the following may cause ITypeInfo lookups
  440.         WBool Invoke( WMemberID memberID,
  441.                       WDispatchFlag flag, WVarType vtRet,
  442.                       void *result, const WOleParmList & parmlist );
  443.  
  444.         // object linking methods
  445.         WBool BreakLink( void );
  446.         WBool UpdateLink( void );
  447.  
  448.         // drag drop methods
  449.         WBool StartDrag( WULong whichButton=WMK_LBUTTON,
  450.                          WDragInfo *draginfo=0, WBool sourceDragOver=FALSE,
  451.                          WBool targetDragOver=TRUE );
  452.  
  453.         // other methods
  454.         WBool AppendVerbMenu( WMenu *menu,
  455.                               WUShort firstVerbID=WOLEDEF_FIRSTVERBID,
  456.                               WUShort lastVerbID=WOLEDEF_LASTVERBID,
  457.                               WBool selfDelete=TRUE,
  458.                               WBool addConvertMenu=TRUE );
  459.  
  460.         WBool FreezeControlEvents( WBool freeze );
  461.  
  462.         WBool ConvertObject( void );
  463.  
  464.         WBool Select( WBool select );
  465.         WBool Repaint();
  466.         WBool Invalidate( WBool erasebk = TRUE );
  467.         WBool DoVerb( WOleObjectVerb verb );
  468.         WBool DeactivateInplaceObject( WBool ignoreActivateWhenVisible=FALSE );
  469.         WBool Move( const WPoint & p );
  470.  
  471.         WBool DoAutoActivate( WMouseEventData *ev=NULL );
  472.         WBool DoContextMenu( WContextMenuEventData & ev );
  473.  
  474.         WBool Clip( WBool cut );
  475.  
  476.         /**************************************************************
  477.          * Operators
  478.          **************************************************************/
  479.  
  480.         operator WPIUnknown() const;
  481.         operator WPIDispatch() const;
  482.  
  483.         /**************************************************************
  484.          * Internal Methods
  485.          **************************************************************/
  486.  
  487.         WBool DataOpenHandler( WOleObject *, WDataOpenEventData *ev );
  488.         WBool DataCloseHandler( WOleObject *, WDataCloseEventData *ev );
  489.         WBool DataAvailableHandler( WOleObject *, WDataAvailableEventData *ev );
  490.         WBool DataRequestHandler( WOleObject *, WDataRequestEventData *ev );
  491.         WBool OnPropertyChanged( WOleObject *, WPropertyEventData *ev );
  492.         WBool OnPropertyRequestEdit( WObject *, WPropertyEventData *ev );
  493.  
  494.         WOleEmbeddedObject *EObject();
  495.  
  496.         WRect GetPendingResizePercentages() const;
  497.         WBool SetPendingResizePercentages( const WRect & pendingResizePercentages );
  498.  
  499.         WBool SetLicenseVerified( WBool set );
  500.         WBool SetRuntimeKeyAvailable( WBool set );
  501.         WBool SetRuntimeLicenseKey( WBStr license );
  502.  
  503.     private:
  504.  
  505.         virtual const WChar * GetRegisteredClass();
  506.  
  507.     protected:
  508.  
  509.         WBool AllocDTCell();
  510.  
  511.     /**********************************************************
  512.      * Data Members
  513.      *********************************************************/
  514.     
  515.     protected:
  516.         WOleContainer           *_oleContainer;
  517.         WOleEmbeddedObject      *_eobject;      // embedded object
  518.         WDataTargetCell         *_dataTarget;
  519.         WBool                   _dataTargetRO;
  520.         WBool                   _eatOnProp;
  521.         WBool                   _displayAsDefault;
  522.         WString                 _displayName;
  523.         wllist_header           *_boundPropList;
  524.         WRect                   _resizePercentages;
  525.         WRect                   _pendingResizePercentages;
  526.         WBool                   _runTimeKeyAvail;
  527.         WBool                   _licVerified;
  528.         WBStr                   _licenseKey;
  529.         WOleDrawMode            _drawMode;
  530.         WBool                   _tabGroup;
  531.         WBool                   _tabStop;
  532.         WString                 _remoteHost;
  533.  
  534. };
  535.  
  536. #ifndef _WNO_PRAGMA_PUSH
  537. #pragma enum pop;
  538. #pragma pack(pop);
  539. #endif
  540.  
  541. #endif // _WOLEOBJ_HPP_INCLUDED
  542.  
  543.