home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / DTOBJECT.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-07  |  11.9 KB  |  277 lines

  1. #ifndef _DTOBJECT_HPP
  2. #define _DTOBJECT_HPP
  3.  
  4. #include "mtdef.hpp"
  5. #if 0
  6. #  include "dtcodebk.hpp"
  7. #  include "mmdata.hpp"
  8. #  include "dttype.hpp"
  9. #endif
  10.  
  11. class MetaObject;
  12. class FormEdit;
  13. class DTFormEditBase;
  14. class WStringList;
  15. class MMStyle;
  16. class MMProperty;
  17. class MMEvent;
  18. class MTPropertyDialog;
  19. class DTWPopupMenu;
  20. class OleEventDialog;
  21. class MTIPropertyList;
  22. class MTIEventList;
  23. class DTCodeBlockList;
  24. class SaveSource;
  25. class SaveBlock;
  26. class DTCodeBlockBase;
  27. struct DTObjectImp;
  28.  
  29. typedef WInt DT_TextifyV;
  30.  
  31. enum MMCodeGeneration {
  32.     MM_CG_AppInit,                      // "WRichTextBox::GetRegistered.."
  33.     MM_CB_HPP,                          // form1.hpp
  34.     MM_CB_CPP,                          // form1.cpp
  35.     MM_CB_RC,                           // form1.rc
  36.  
  37.     MM_CG_FORM_BaseClasses,             // base classes needed by this component
  38.     MM_CG_FORM_CreateDecl,              // "WBool Create( WWindow * );"
  39.     MM_CG_FORM_CreateDefn,              // "WBool Form1::Create( WWindow * )"
  40.     MM_CG_FORM_CallCreate,              // "ok = WWindow::Create( parent, ... )"
  41.  
  42.     MM_CG_HPP_EnumeratorID,             // "CB_1 = 101,"
  43.     MM_CG_HPP_EventDecl,                // "WBool cb_1_Clicked( ... );"
  44.     MM_CG_HPP_MemberDecl,               // "WCommandButton *  cb_1;"
  45.  
  46.     MM_CG_IncludeFiles,                 // "spindial.hpp"
  47.     MM_CG_IncludePaths,                 // "f:\mystuff\mycontrol\hpp"
  48.     MM_CG_Libraries,                    // "mycontrol.lib"
  49.     MM_CG_LibraryPaths,                 // "f:\mystuff\mycontrol\lib"
  50.  
  51.     MM_CG_ConstructorInitializer,       // "    , cb_1( NULL )"
  52.     MM_CG_ConstructorCode,              // "// any constructor code"
  53.  
  54.     MM_CG_InitNew,                      // "cb_1 = new WCommandButton;"
  55.     MM_CG_InitEventHandlerList,         // "WEventHandlerList cb_1_Event..."
  56.     MM_CG_InitEventHandlers,            // "cb_1->SetEventHandlerList( ... );"
  57.     MM_CG_RemoveEventHandlers,          // "cb_1->RemoveEventHandlerList( ... );"
  58.     MM_CG_InitDDXDataSource,            // "cb_1->SetDDXDataSource( ... );"
  59.     MM_CG_InitCreate,                   // "cb_1->Create( ... );"
  60.     MM_CG_InitProperties,               // "cb_1->SetFont( ... );"
  61.     MM_CG_CallCreateEventHandler,       // "cb_1->CallEventHandler( ... );"
  62.     MM_CG_CallDestroyEventHandler,      // "cb_1->CallEventHandler( ... );"
  63.     MM_CG_InitTransaction,              // "trans_1->Connect( ... );"
  64.     MM_CG_InitQuery,                    // "query_1->Open( ... );"
  65.     MM_CG_AutoOpenQuery,                // "WOptima::AuotOpen...;"
  66.     MM_CG_InitTabControl,               // "_TabForm1->Create( this, ...);"
  67.  
  68.     MM_CG_FiniTransaction,              // "trans_1->Disconnect();"
  69.     MM_CG_FiniQuery,                    // "query_1->Close();"
  70.     MM_CG_FiniDelete,                   // "delete cb_1;"
  71.     MM_CG_FiniReset,                    // "cb_1 = NULL;"
  72.  
  73.     MM_CG_MemberFunctions,              // "WBool Form1::..."
  74.  
  75.     MM_CG_DDXMember,                    // "WString     ddxNum;"
  76.     MM_CG_DDXGetDefault,                // "ddx->gender = 'M';"
  77.  
  78.     MM_CG_RC_Defines,                   // "#define CB_1 101"
  79.     MM_CG_RC_MainLevel,                 // "SPINDIAL_1_DATA RCDATA"
  80.     MM_CG_RC_Control,                   // "CB_1 CONTROL ..."
  81. };
  82.  
  83. #undef GetForm
  84. #if defined( _UNICODE )
  85.     #define GetForm GetFormW
  86.     #define SetForm SetFormW
  87. #else
  88.     #define GetForm GetFormA
  89.     #define SetForm SetFormA
  90. #endif
  91.  
  92. class METAEXPORTCLASSDEF DTObject : public WObject {
  93.     public:
  94.         virtual                 ~DTObject();
  95.  
  96.         virtual WBool           operator== ( const DTObject & ) const;
  97.         virtual const MetaObject *GetMeta() const;
  98.  
  99.  
  100.         virtual void            DTGetRectangle( WRect & r,
  101.                                                 WBool abs = FALSE ) const;
  102.         virtual void            DTGetClientRectangle( WRect & r ) const;
  103.         virtual void            DTSetRectangle( const WRect & r );
  104.         virtual void            DTGetRCRectangle( WRect & r ) const;
  105.  
  106.         virtual WRect           DTMapPixelsToDLU( const WRect & pix ) const;
  107.         virtual WRect           DTMapDLUToPixels( const WRect & dlu ) const;
  108.  
  109.         virtual void            DTBringToTop();
  110.         virtual void            DTRepaint();
  111.         virtual void            DTWindowMoved();
  112.         virtual WWindow *       DTGetParent() const;
  113.         virtual WBool           DTSetEventHandler( WEventID id,
  114.                                                  WObject * object,
  115.                                                  WEventHandler handler,
  116.                                                  void *userdata=NULL );
  117.  
  118.         virtual void            DTSetName( const WString & name );
  119.         virtual WString         DTGetName() const;
  120.  
  121.         virtual void            SetClassDefinition( const WString & );
  122.         virtual WString         GetClassDefinition() const;
  123.  
  124.         virtual void            SetClassIncludes( const WString & );
  125.         virtual WString         GetClassIncludes() const;
  126.  
  127.         virtual WObject *       GetWImplementation() const;
  128.         virtual void            SetWImplementation( WObject * wobj );
  129.  
  130.         virtual WWindow *       GetWindow() const;
  131.  
  132.         // ResourceID: the id of the control in the .res file
  133.         virtual void            SetResourceID( long id );
  134.         virtual long            GetResourceID() const;
  135.  
  136.         // TabIndex: tabbing order of control
  137.         virtual void            SetTabIndex( long idx );
  138.         virtual long            GetTabIndex() const;
  139.  
  140.         // AmendPopup: modify the context popup.  Before is true before
  141.         //             the popup is displayed
  142.         virtual void            AmendPopup( WPopupMenu *popup, WBool before );
  143.  
  144.         // CodeBlockList: list of Event's associated with object
  145.         virtual const DTCodeBlockList & GetCodeBlockList() const;
  146.         virtual DTCodeBlockList &       GetCodeBlockList();
  147.         virtual DTCodeBlockBase *       RemoveEvent( DTCodeBlockBase * );
  148.  
  149.         // Form, DTForm: interface to the stored form editor
  150.         virtual FormEdit *      GetForm() const;
  151.         virtual DTFormEditBase *GetDTForm() const;
  152.         virtual void            SetForm( DTFormEditBase * );
  153.  
  154.         // DTPopupMenu for window natured objects.
  155.         virtual WBool           SetDTPopupMenu( DTWPopupMenu * );
  156.         virtual DTWPopupMenu *  GetDTPopupMenu() const;
  157.  
  158.         // Style: the style property of the window nature (if applicable)
  159.         virtual WStyle          GetStyle() const;
  160.         virtual WBool           SetStyle( WStyle stl, WBool clone=FALSE );
  161.         virtual WStyle          GetDefaultStyle() const;
  162.  
  163.         // ExtendedStyle: the ExtendedStyle property of the window nature 
  164.         virtual WStyle          GetExtendedStyle() const;
  165.         virtual WBool           SetExtendedStyle( WStyle style, WBool clone=FALSE );
  166.         virtual WStyle          GetDefaultExtendedStyle() const;
  167.  
  168.         // Create: create the windowed object
  169.         virtual WBool           Create( WWindow * parent, const WRect & r,
  170.                                         const WChar * text, WStyle style,
  171.                                         WStyle exStyle, void * data = NULL,
  172.                                         WBool isLoading = FALSE );
  173.  
  174.         virtual WBool           GetNonVisual() const;
  175.  
  176.         // Save and Load DTInfo
  177.         virtual WBool           HasDTInfo();
  178.         virtual WBool           SaveDTInfo( SaveSource & );
  179.         virtual WBool           LoadDTInfo( SaveBlock *, WBool beforeCreate );
  180.  
  181.         virtual WBool           CreateEventPopupMenu( WPopupMenu * popup );
  182.         virtual WBool           HandleEventClick( WMenuItem *, WEventData * );
  183.         virtual WBool           HandleOleEventClick( WMenuItem *, WEventData * );
  184.         virtual void            RemoveOleEventDialog();
  185.  
  186.         virtual WBool           GetIsResizeable();
  187.         virtual WBool           GetIsMoveable();
  188.  
  189.         virtual WBool           GetIsHollow();          // groupbox
  190.         virtual WRect           GetHollowRect();        // interior of groupbox
  191.  
  192.         // Property Editting
  193.     public:
  194.         virtual WBool                   EditProperties( WWindow *,
  195.                                                         WBool child = FALSE );
  196.         virtual void                    ClearPropertyEditor( WBool deleteNow = FALSE );
  197.         virtual WBool                   UpdatePropertyRect();
  198.         virtual MTPropertyDialog *      GetPropDialog();
  199.         virtual void                    FillInspectProperties( MTIPropertyList & ) const;
  200.         virtual void                    FillInspectEvents( MTIEventList & ) const;
  201.  
  202.         virtual WBool                   HasProperty( const WString & name ) const;
  203.         virtual WString                 GetProperty( const WString & name, DT_TextifyV t = 1 ) const;
  204.         virtual WBool                   GetPropertyBool( const WString & name ) const;
  205.         virtual WLong                   GetPropertyEnum( const WString & name ) const;
  206.         virtual WRect                   GetPropertyRect( const WString & name ) const;
  207.         virtual WLong                   GetPropertyLong( const WString & name ) const;
  208.         virtual WBool                   SetProperty( const WString & name, const WString & val, DT_TextifyV t = 1 );
  209.         virtual WBool                   SetPropertyBool( const WString & name, WBool val );
  210.         virtual void                    SetPropertyEnum( const WString & name, WLong val );
  211.         virtual void                    SetPropertyRect( const WString & name, const WRect & r );
  212.         virtual void                    SetPropertyLong( const WString & name, WLong r );
  213.         virtual void                    PropertyChanged( const WString & name );
  214.  
  215.  
  216.         // mapped properties
  217.     public:
  218.         virtual WString                 GetMappedValue( WUInt i ) const;
  219.         virtual void                    SetMappedValue( WUInt i, const WString & s );
  220.  
  221.  
  222.         /* Code Generation
  223.         */
  224.     public:
  225.         virtual WString GetObjectPrefix() const;
  226.  
  227.         virtual void GenName( WUInt id, WString & ) const;
  228.         virtual void GenClassName( WString & ) const;
  229.         virtual void GenResourceName( WString & ) const;
  230.         virtual void GenResourceStyles( WStringList &, WStringList & ) const;
  231.         virtual void GenCode( MMCodeGeneration, WStringList & ) const;
  232.  
  233.         /* Searching
  234.         */
  235.     public:
  236.         virtual const MMStyle *     FindStyle( const char * ) const;
  237.         virtual const MMProperty *  FindProperty( const char * ) const;
  238.         virtual DTCodeBlockBase *   FindEvent( const char * ) const;
  239.  
  240.  
  241.         /* Dialog Data Exchange
  242.         */
  243.     public:
  244.         virtual WBool           GetDDXEnabled() const;
  245.         virtual void            SetDDXEnabled( WBool e );
  246.  
  247.         virtual WString         GetDDXFieldName() const;
  248.         virtual void            SetDDXFieldName( const WString & );
  249.  
  250.         virtual WString         GetDDXFieldType() const;
  251.         virtual void            SetDDXFieldType( const WString & );
  252.  
  253.         virtual WString         GetDDXModifiedFieldName() const;
  254.         virtual void            SetDDXModifiedFieldName( const WString & );
  255.  
  256.         virtual WString         GetDDXAdditional( unsigned i ) const;
  257.         virtual void            SetDDXAdditional( unsigned i, const WString & );
  258.         virtual void            EscapeCString( WString &, const WString & ) const;
  259.  
  260.         virtual void            InitializeFromObject();
  261.  
  262.     protected:
  263.         DTObject( const MetaObject * meta = NULL );
  264.         virtual void            SetWindow( WWindow * );
  265.         virtual void            SetMeta( const MetaObject * );
  266.  
  267.         virtual WString         TabTo( const WString & str, unsigned col ) const;
  268.  
  269.  
  270.     private:
  271.         DTObjectImp *           _imp;
  272. };
  273.  
  274. typedef DTObject DTWObject;
  275.  
  276. #endif // _DTOBJECT_HPP
  277.