home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WOLEFORM.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  9KB  |  283 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.  * WOleContainer -- Ole Object Container class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *      NewObject               -- a new object has been created
  19.  *
  20.  *      SetStatusText           -- a request to set the app's status bar
  21.  *
  22.  *      GetBorder               -- object is requesting the rect in which
  23.  *                                 it will perform border negotiation
  24.  *
  25.  *      RequestBorderSpace      -- the object is asking for border space
  26.  *
  27.  *      SetBorderSpace          -- the object is informing you how much
  28.  *                                 border space it is actually using
  29.  *
  30.  *      DragEnter               -- an Ole drag enter event
  31.  *
  32.  *      DragLeave               -- an Ole drag leave event
  33.  *
  34.  *      DragOver                -- an Ole drag over event
  35.  *
  36.  *      DragDrop                -- an Ole drag drop event
  37.  *
  38.  *
  39.  *************************************************************************/
  40.  
  41. #ifndef _WOLEFORM_HPP_INCLUDED
  42. #define _WOLEFORM_HPP_INCLUDED
  43.  
  44. #ifndef _WNO_PRAGMA_PUSH
  45. #pragma pack(push,8);
  46. #pragma enum int;
  47. #endif
  48.  
  49. #ifndef _WOLEAUTO_HPP_INCLUDED
  50. #  include "woleauto.hpp"
  51. #endif
  52. #ifndef _WSTRING_HPP_INCLUDED
  53. #  include "wstring.hpp"
  54. #endif
  55. #ifndef _WCOLOR_HPP_INCLUDED
  56. #  include "wcolor.hpp"
  57. #endif
  58. #ifndef _WFONT_HPP_INCLUDED
  59. #  include "wfont.hpp"
  60. #endif
  61. #ifndef _WOLEDEF_HPP_INCLUDED
  62. #   include "woledef.hpp"
  63. #endif
  64. #ifndef _WWINDOW_HPP_INCLUDED
  65. #   include "wwindow.hpp"
  66. #endif
  67. #ifndef _WTHREAD_HPP_INCLUDED
  68. #   include "wthread.hpp"
  69. #endif
  70.  
  71. // forward declarations
  72. class WCMCLASS WOleObject;
  73. class WCMCLASS WOleIContainer;
  74. class WCMCLASS WForm;
  75. class WCMCLASS WFont;
  76. class WCMCLASS WCanvas;
  77. class WCMCLASS WDisplayCanvas;
  78. class WCMCLASS WString;
  79.  
  80. // new object event data structure
  81. struct WNewObjectEventData : public WEventData {
  82.     WOleObject  *newObject;
  83. };
  84.  
  85. // set status text event data structure
  86. struct WSetStatusTextEventData : public WEventData {
  87.     WChar       *statusText;
  88. };
  89.  
  90. // border negotiation event data structures
  91. typedef struct WBorderWidths {
  92.     WLong       left;
  93.     WLong       top;
  94.     WLong       right;
  95.     WLong       bottom;
  96. } WBorderWidths;
  97.  
  98. struct WBorderWidthsEventData : public WEventData {
  99.     WBorderWidths       widths;
  100. };
  101.  
  102. struct WBorderEventData : public WEventData {
  103.     WRect       rect;
  104. };
  105.  
  106. class WCMCLASS WOleContainer {
  107.  
  108.     public:
  109.  
  110.         /**********************************************************
  111.          * Constructors and Destructors
  112.          *********************************************************/
  113.  
  114.         WOleContainer( WForm *form );
  115.  
  116.         virtual ~WOleContainer();
  117.  
  118.     public:
  119.         /**************************************************************
  120.          * Properties
  121.          **************************************************************/
  122.  
  123.         // Show Object Type
  124.         WBool SetShowObjectType( WBool show );
  125.         WBool GetShowObjectType( void ) const;
  126.  
  127.         // Inplace Active
  128.         WBool SetAllowInplaceActive( WBool inplaceActive );
  129.         WBool GetAllowInplaceActive( void ) const;
  130.  
  131.         // Negotiate Menus
  132.         WBool SetNegotiateMenus( WBool negotiate );
  133.         WBool GetNegotiateMenus( void ) const;
  134.     
  135.         // Ambient properties for the container
  136.  
  137.         // Locale ID
  138.         WBool SetLocaleID( WULong lcid );
  139.         WULong GetLocaleID( void ) const;
  140.  
  141.         // Design Mode
  142.         WBool SetDesignMode( WBool set );
  143.         WBool GetDesignMode( void ) const;
  144.  
  145.         // User Mode
  146.         WBool SetUserMode( WBool set );
  147.         WBool GetUserMode( void ) const;
  148.  
  149.         // UI dead
  150.         WBool SetUIDead( WBool set );
  151.         WBool GetUIDead( void ) const;
  152.  
  153.         // Show Grab Handles
  154.         WBool SetShowGrabHandles( WBool set );
  155.         WBool GetShowGrabHandles( void ) const;
  156.  
  157.         // Show Hatching
  158.         WBool SetShowHatching( WBool set );
  159.         WBool GetShowHatching( void ) const;
  160.  
  161.         // Document Name
  162.         WBool SetDocumentTitle( const WString & title );
  163.         WString GetDocumentTitle( void ) const;
  164.  
  165.         // Disable Ole Drag Drop
  166.         WBool SetDisableOleDragDrop( WBool disable );
  167.         WBool GetDisableOleDragDrop( void ) const;
  168.  
  169.         // Inplace Frame
  170.         WBool SetInplaceFrame( WOleContainer *frame );
  171.         WOleContainer *GetInplaceFrame( void ) const;
  172.  
  173.         // read-only properties
  174.         WBool GetHasLinks( void ) const;
  175.         WBool GetDirty( void ) const;
  176.         WString GetDocFile( void ) const;
  177.         WString GetActiveObjectName( void ) const;
  178.         WOleObject *GetFirstObject( void );
  179.         WOleObject *GetNextObject( WOleObject * );
  180.         WOleObject *GetCurrentObject( void );
  181.         WBool GetPasteValid( void );
  182.         WBool GetPasteLinkValid( void );
  183.         unsigned int GetOleObjectCount( void ) const;
  184.         WOleObject *GetOleObject( unsigned int index ) const;
  185.  
  186.         WForm *GetForm( void ) const { return( _form ); };
  187.  
  188.         /**************************************************************
  189.          * Methods
  190.          **************************************************************/
  191.  
  192.         // creation and initialization functions
  193.         WBool InitializeContainer( const WString * file=NULL );
  194.         WBool UninitializeContainer( void );
  195.         WBool LoadContainer( const WString & file );
  196.         WBool SaveContainer( const WString * file=NULL );
  197.  
  198.         // ambient properties notifications
  199.         void AmbientsChanged( WAmbientID *ambientIDs, WInt num );
  200.         void AmbientChanged( WAmbientID ambientID );
  201.  
  202.         void DestroyObjects( WBool deleteObjects=FALSE );
  203.         WBool Paste( void );
  204.         WBool PasteLink( void );
  205.         WBool EditLinks( void );
  206.         WBool UpdateLinks( void );
  207.         WBool PasteSpecial( WBool allowLinks=TRUE );
  208.         void RenegotiateBorder( void );
  209.     
  210.     /**********************************************************
  211.      * Internal Members
  212.      *********************************************************/
  213.     
  214.         WOleIContainer *IContainer( void ) const;
  215.  
  216.         // mouse and paint events
  217.         WBool OlePaint( WDisplayCanvas & port );
  218.         WBool OleMouseEvent( WMouseEventData *ev );
  219.         WBool OleContextMenu( WContextMenuEventData *ev );
  220.         WBool OleCharPressEvent( WCharacterPressEventData *ev );
  221.  
  222.         // event handlers
  223.         WBool FormResizeEventHandler( WResizeEventData *ev );
  224.         WBool MessageHookEventHandler( WMessageFilterData *ev );
  225.         WBool InstallMsgFilter( void );
  226.         void UninstallMsgFilter( WBool force = FALSE );
  227.  
  228.         WBool ResizePercentageHandler( WResizeEventData * event );
  229.  
  230.     /**********************************************************
  231.      * Data Members
  232.      *********************************************************/
  233.     
  234.     protected:
  235.  
  236.         WRect                           _lastResizeRect;
  237.  
  238.     protected:
  239.         class WOleContainerEventHandler : public WObject {
  240.     
  241.             public:
  242.                 WOleContainerEventHandler( WOleContainer *container );
  243.                 ~WOleContainerEventHandler( void );
  244.         
  245.                 // event handlers
  246.                 WBool Paint( WObject *, WPaintEventData *ev );
  247.                 WBool MouseEvent( WObject *, WMouseEventData *ev );
  248.                 WBool ContextMenuEvent( WObject *, WContextMenuEventData *ev );
  249.                 WBool CharPressEvent( WObject *,WCharacterPressEventData *ev );
  250.                 WBool FormResizeEventHandler( WObject *, WResizeEventData *ev );
  251.                 WBool MessageHookEventHandler( WMessageFilterData *ev );
  252.  
  253.                 WBool InstallMsgFilter( void );
  254.                 void UninstallMsgFilter( WBool force );
  255.         
  256.                 WOleContainer   *_container;
  257.  
  258.             private:
  259.                 WUInt           _filterInstalled;
  260.         };
  261.  
  262.     protected:
  263.         WForm           *_form;
  264.         WOleIContainer  *_iform;
  265.  
  266.         WOleContainerEventHandler       _eventHandler;
  267.  
  268.         // ambient properties for this object
  269.         WULong          _localeID;      // locale ID
  270.         WBool           _designMode;    // design mode?
  271.         WBool           _UIDead;        // UI dead?
  272.         WBool           _showGrabHandles;// show grab handles?
  273.         WBool           _showHatching;  // show hatching?
  274.  
  275. };
  276.  
  277. #ifndef _WNO_PRAGMA_PUSH
  278. #pragma enum pop;
  279. #pragma pack(pop);
  280. #endif
  281.  
  282. #endif // _WOLEFORM_HPP_INCLUDED
  283.