home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / dtobject.hpp < prev    next >
C/C++ Source or Header  |  1996-12-07  |  19KB  |  544 lines

  1. #ifndef _DTOBJECT_HPP
  2. #define _DTOBJECT_HPP
  3.  
  4. #include "dtobase.hpp"
  5.  
  6. //
  7. // MMFileGenerationParms
  8. //
  9. //    Parameters to accompany the GenFileFragment call.  Avoid
  10. //    modifying this structure, instead declare a derived version.
  11.  
  12. struct MMFileGenerationParms {
  13.     WFilePath   path;
  14. };
  15.  
  16. class METAEXPORTCLASSDEF DTObjectBase : public DTObject
  17. {
  18.     public:
  19.         virtual                 ~DTObjectBase() = 0;
  20.         VEXPORT WBool           operator== ( const DTObject & ) const;
  21.  
  22.     public:
  23.  
  24.         /*************************************************************
  25.          * WClass / Awt specific behaviour
  26.          *************************************************************/
  27.  
  28.         //
  29.         // GenFileFragment
  30.         //
  31.         //    Generate a file-level fragment of code.
  32.  
  33.         virtual void GenFileFragment( MMFileFragment fg, WStringList &,
  34.                                         MMFileGenerationParms * parms ) const;
  35.  
  36.  
  37.         /*************************************************************
  38.          * Common Behaviour
  39.          *************************************************************/
  40.  
  41.         //
  42.         // Meta
  43.         //
  44.         //    The Meta- object instance that is associated
  45.         //    with this DT- object
  46.  
  47.         VEXPORT const MetaObject *GetMeta() const;
  48.  
  49.  
  50.         //
  51.         // Reference Card Meta
  52.         //    The Meta-object that is used to provide reference
  53.         //    card information.  The default implentation returns GetMeta()
  54.  
  55.         VEXPORT const MetaObject *  GetRefCardMeta() const;
  56.  
  57.         //
  58.         // Name
  59.         //
  60.         //    The variable used in the user's code to represent this
  61.         //    object (eg. cb_1).  Although there is a default implementation,
  62.         //    you may wish to override this to perform an action when the
  63.         //    name changes (eg. change names of all child objects).
  64.  
  65.         virtual void            DTSetName( const WString & name );
  66.         virtual WString         DTGetName() const ;
  67.  
  68.         //
  69.         // ClassDefinition
  70.         //
  71.         //    The class name used to implement a component in code.
  72.         //    This lets the user specify a different class than the
  73.         //    default.
  74.  
  75.         virtual void            SetClassDefinition( const WString & );
  76.         virtual WString         GetClassDefinition() const;
  77.  
  78.         //
  79.         // ClassIncludes
  80.         //
  81.         //    Extra header files this compnonent requires (specified
  82.         //    by the user.  For use with ClassDefinition.
  83.  
  84.         virtual void            SetClassIncludes( const WString & );
  85.         virtual WString         GetClassIncludes() const;
  86.  
  87.         //
  88.         // WImplementation
  89.         //
  90.         //    Each DT- object must have an associated WObject that
  91.         //    represents it on the design-time form.  This is not
  92.         //    required to be a WWindow-derived class, but that is the
  93.         //    case that has been tested most -- only WOleObjects are
  94.         //    an exception.
  95.  
  96.         VEXPORT WObject *       GetWImplementation() const;
  97.         VEXPORT void            SetWImplementation( WObject * wobj );
  98.  
  99.         //
  100.         // Window
  101.         //
  102.         //    If there is a WWindow implementing the design-time
  103.         //    behaviour of the object, get and return it.  Otherwise,
  104.         //    NULL (as for WOleObject).
  105.  
  106.         VEXPORT WWindow *       GetWindow() const;
  107.  
  108.  
  109.         //
  110.         // DTGetParent
  111.         //
  112.         //    The parent window if there is a window.
  113.  
  114.         VEXPORT WWindow *       DTGetParent() const;
  115.  
  116.         //
  117.         // ResourceID
  118.         //
  119.         //    The id of the control in the .res file
  120.  
  121.         VEXPORT void            SetResourceID( long id );
  122.         VEXPORT long            GetResourceID() const;
  123.  
  124.         //
  125.         // TabIndex
  126.         //
  127.         //    Tabbing order of control.  Controls are emitted into
  128.         //    the resource file in tab index order.
  129.  
  130.         VEXPORT void            SetTabIndex( long idx );
  131.         VEXPORT long            GetTabIndex() const;
  132.  
  133.  
  134.         //
  135.         // CodeBlockList
  136.         //
  137.         //    A list of code block's (functions) associated with the
  138.         //    object.
  139.         //
  140.  
  141.         VEXPORT const DTCodeBlockList & GetCodeBlockList() const;
  142.         VEXPORT DTCodeBlockList &       GetCodeBlockList();
  143.  
  144.         VEXPORT WInt                    GetAllCodeBlockLists( DTCodeBlockListList & );
  145.  
  146.         //
  147.         // RemoveEvent
  148.         //
  149.         //    Remove a code block from the list and remove any
  150.         //    other pointers to it (ie. from object inspector).
  151.  
  152.         VEXPORT DTCodeBlockBase *       RemoveEvent( DTCodeBlockBase * );
  153.  
  154.         //
  155.         // FindEvent
  156.         //
  157.         //    Find a code block that has already been added to
  158.         //    this object.
  159.  
  160.         VEXPORT DTCodeBlockBase *       FindEvent( const char * ) const;
  161.  
  162.         //
  163.         // Form, DTForm
  164.         //
  165.         //    The FormEdit associated with this object; the first
  166.         //    form is only useful from within Optima code; the second,
  167.         //    mainly from CompDLL.  SetForm is called by Optima when
  168.         //    it instantiates the object.
  169.  
  170.         VEXPORT FormEdit *      GetForm() const;
  171.         VEXPORT DTFormEditBase *GetDTForm() const;
  172.         VEXPORT void            SetForm( DTFormEditBase * );
  173.  
  174.         //
  175.         // Child
  176.         //
  177.         //    The DTObject Children for this DTObject.  DTObjects
  178.         //    may now own other DTObjects.
  179.  
  180.         VEXPORT int             GetChildCount() const;
  181.         VEXPORT DTObject *      GetChild( int index ) const;
  182.         VEXPORT WBool           AddChild( DTObject *, int after = -1 );
  183.         VEXPORT WBool           RemoveChild( DTObject * );
  184.         VEXPORT DTObject *      GetParent() const;
  185.  
  186.         //
  187.         // Style
  188.         //
  189.         //    The Windows style property of the associated Window.
  190.         //    This doesn't necessarily match GetWindow()->GetStyle()
  191.         //    because some styles are deferred until run-time (such
  192.         //    as WSVisible).
  193.  
  194.         VEXPORT WStyle          GetStyle() const;
  195.         VEXPORT WBool           SetStyle( WStyle stl, WBool clone=FALSE );
  196.  
  197.         //
  198.         // DefaultStyle
  199.         //
  200.         //    The style with which new instances are created.  Default
  201.         //    implementation returns GetWindow()->GetDefaultStyle().
  202.  
  203.         virtual WStyle          GetDefaultStyle() const;
  204.  
  205.         //
  206.         // ExtendedStyle
  207.         //
  208.         //    The ExtendedStyle property of the window nature.
  209.  
  210.         virtual WStyle          GetExtendedStyle() const;
  211.         virtual WBool           SetExtendedStyle( WStyle style, WBool clone=FALSE );
  212.  
  213.         //
  214.         // DefaultExtendedStyle
  215.         //
  216.         //    See DefaultStyle
  217.  
  218.         virtual WStyle          GetDefaultExtendedStyle() const;
  219.  
  220.         //
  221.         // Create
  222.         //
  223.         //    Call Create on the windowed object.
  224.         //
  225.         virtual WBool           Create( WWindow * parent, const WRect & r,
  226.                                         const WChar * text, WStyle style,
  227.                                         WStyle exStyle, void * data = NULL,
  228.                                         WBool isLoading = FALSE );
  229.  
  230.         //
  231.         // NonVisual
  232.         //
  233.         //    NonVisual objects are represented by a picture box at
  234.         //    design time -- eg. WTimer, WMessageBox, WFileDialog.
  235.  
  236.         VEXPORT WBool           GetNonVisual() const;
  237.  
  238.         // DTInfo
  239.         //
  240.         //    Each object can have information that is not handled by
  241.         //    the general framework.  For instance, listboxes store their
  242.         //    lines separately.  HasDTInfo should return true if you want
  243.         //    to store object-specific information, then the SaveDTInfo
  244.         //    and LoadDTInfo functions will be called.
  245.  
  246.         virtual WBool           HasDTInfo();
  247.         virtual WBool           SaveDTInfo( SaveSource & );
  248.         virtual WBool           LoadDTInfo( SaveBlock *, WBool beforeCreate );
  249.  
  250.         //
  251.         // CreateEventPopupMenu
  252.         //
  253.         //    Popupulate a popup menu with the events that are deemed
  254.         //    useful ("hot" events) as well as events with code.  There
  255.         //    is a default behaviour which is overriden for Ole objects.
  256.  
  257.         virtual WBool           CreateEventPopupMenu( WPopupMenu * popup );
  258.  
  259.         //
  260.         // IsResizeable
  261.         //
  262.         //    IsResizeable allows non-visual objects and Ole objects to
  263.         //    deny resizing (can change after created
  264.  
  265.         virtual WBool           GetIsResizeable();
  266.  
  267.  
  268.         //
  269.         // Hollow
  270.         //
  271.         //    GroupBoxes are treated as "Hollow" controls in that when
  272.         //    they are moved, contained controls are also moved.  Also,
  273.         //    hollow controls are not active except for a border around
  274.         //    the outside.  HollowRect is the rectangle in the center
  275.         //    that doesn't activate the object.
  276.  
  277.         virtual WBool           GetIsHollow();          // groupbox
  278.         virtual WRect           GetHollowRect();        // interior of groupbox
  279.  
  280.         //
  281.         // DTPopupMenu
  282.         //    The popup menu associated with a WWindow.  NOT the
  283.         //    popup menu that shows up at design-time.
  284.         //    [ITB:06/4] expect this will move to DTW.
  285.  
  286.         VEXPORT WBool           SetDTPopupMenu( DTObject * );
  287.         VEXPORT DTObject *      GetDTPopupMenu() const;
  288.  
  289.         //
  290.         // AmendPopup 
  291.         //
  292.         //    Override this function to modify the design-time context
  293.         //    popup.  "before" is true before the popup is displayed,
  294.         //    false afterwards.  Make sure you clean up any menu items
  295.         //    you add or they will remain for other objects as well.
  296.         //
  297.         virtual void            AmendPopup( WPopupMenu *, WBool before );
  298.  
  299.         //
  300.         // IsValidChild
  301.         //
  302.         //    Returns true if obj is allowed as a child of this
  303.         //    DTObject.  errMsg is filled in with details about
  304.         //    why it isn't allowed.
  305.         virtual WBool           IsValidChild(
  306.                                         const MetaObject *obj,
  307.                                         WString &errMsg ) const;
  308.  
  309.         //
  310.         // IsValidContainer
  311.         //
  312.         //    Returns true if obj is allowed as a container for this
  313.         //    DTObject.  errMsg is filled in with details about
  314.         //    about why it isn't allowed.
  315.         virtual WBool           IsValidContainer(
  316.                                         const DTObject *obj,
  317.                                         WString &errMsg ) const;
  318.  
  319.         //
  320.         // SetEventHandler
  321.         //
  322.         //    Set an event handler on the W-Implementation object.
  323.  
  324.         virtual WBool           DTSetEventHandler( WEventID id,
  325.                                                  WObject * object,
  326.                                                  WEventHandler handler,
  327.                                                  void *userdata=NULL );
  328.  
  329.         //
  330.         // DTIInterface
  331.         //
  332.         //    Get DTInterface with a particular name. This virtual
  333.         //    function is overridden once by derived classes that use
  334.         //    DTInterfaces
  335.  
  336.         virtual DTIInterface *  GetDTIInterface( const WChar * ifname );
  337.  
  338.         //
  339.         // Protected
  340.         //
  341.         //    This property controls the behaviour of a design time
  342.         //    object.  Protected objects are:
  343.         //              -  not saved or loaded
  344.         //              -  cannot be deleted directly by the user
  345.  
  346.         virtual WBool GetProtected() const;
  347.  
  348.  
  349.         /*************************************************************
  350.          * Property Editting
  351.          *************************************************************/
  352.  
  353.         //
  354.         // EditProperties
  355.         //
  356.         //    Display a property sheet window.  Depending on "child",
  357.         //    the property sheet may be a child (as in object view) or
  358.         //    a popup dialog (normal property sheets).
  359.  
  360.         VEXPORT WBool                   EditProperties( WWindow *,
  361.                                                         WBool child = FALSE );
  362.         //
  363.         // ClearPropertyEditor
  364.         //
  365.         //    Remove and destroy any open property editor for this object.
  366.  
  367.         VEXPORT void                    ClearPropertyEditor( WBool deleteNow = FALSE );
  368.  
  369.         //
  370.         // UpdatePropertyRect
  371.         //
  372.         //    Inform any open property editors to update the position
  373.         //    property since this object has been moved
  374.  
  375.         virtual WBool                   UpdatePropertyRect();
  376.  
  377.         //
  378.         // PropDialog
  379.         //
  380.         //    Get a pointer to the open property editor or return NULL.
  381.  
  382.         VEXPORT MTPropertyDialog *      GetPropDialog();
  383.  
  384.         //
  385.         // HasProperty
  386.         //
  387.         //    Return TRUE if this object has a property named "name".
  388.  
  389.         VEXPORT WBool                   HasProperty( const WString & name ) const;
  390.  
  391.         //
  392.         // Property
  393.         //
  394.         //    Get or set a property with various formats.  
  395.         //    The additional formats are provided for convenience only.
  396.  
  397.         VEXPORT WString                 GetProperty( const WString & name, DT_TextifyV t = 1 ) const;
  398.         VEXPORT WBool                   GetPropertyBool( const WString & name ) const;
  399.         VEXPORT WLong                   GetPropertyEnum( const WString & name ) const;
  400.         VEXPORT WRect                   GetPropertyRect( const WString & name ) const;
  401.         VEXPORT WLong                   GetPropertyLong( const WString & name ) const;
  402.         VEXPORT WBool                   SetProperty( const WString & name, const WString & val, DT_TextifyV t = 1 );
  403.         VEXPORT WBool                   SetPropertyBool( const WString & name, WBool val );
  404.         VEXPORT void                    SetPropertyEnum( const WString & name, WLong val );
  405.         VEXPORT void                    SetPropertyRect( const WString & name, const WRect & r );
  406.         VEXPORT void                    SetPropertyLong( const WString & name, WLong r );
  407.  
  408.         virtual void                    PropertyChanged( const WString & name );
  409.  
  410.         //
  411.         // DetachEditor
  412.         //
  413.         //    Virtual call to detach an editor mini application if necessary.
  414.  
  415.         virtual void                    DetachEditor();
  416.  
  417.  
  418.  
  419.         /*************************************************************
  420.          * Code Generation
  421.          *************************************************************/
  422.  
  423.         //
  424.         // ObjectPrefix
  425.         //
  426.         //    Get the prefix used when accessing member functions of the
  427.         //    object -- eg. "cb_1->"
  428.  
  429.         VEXPORT WString GetObjectPrefix() const;
  430.  
  431.         //
  432.         // GenName
  433.         //    Generate a variable name by number, eg. cb_1 if id == 1
  434.         //    The string is an out parameter.
  435.  
  436.         VEXPORT void GenName( WUInt id, WString & ) const;
  437.  
  438.         //
  439.         // GenClassName
  440.         //
  441.         //    Generate the name of the C++ or Java class that implements
  442.         //    this object.
  443.  
  444.         VEXPORT void GenClassName( WString & ) const;
  445.  
  446.         //
  447.         // GenResourceName
  448.         //
  449.         //    Generate the resource ID from the object name.  This is
  450.         //    usually of the form ID_name.
  451.  
  452.         VEXPORT void GenResourceName( WString & ) const;
  453.  
  454.         //
  455.         // GenResourceStyles
  456.         //
  457.         //     Generate the .rc file styles that will be used; the first
  458.         //     parameter is a string list filled with styles, the second
  459.         //     is filled with extended styles
  460.  
  461.         VEXPORT void GenResourceStyles( WStringList &, WStringList & ) const;
  462.  
  463.         //
  464.         // GenEventObjectName
  465.         //
  466.         //     Generate the object name for an event. The name is built
  467.         // by recursing the DTObject hierarchy and prepending the names
  468.         // of the DTObjects
  469.  
  470.         VEXPORT void GenEventObjectName( WString & ) const;
  471.  
  472.         //
  473.         // FindStyle
  474.         //
  475.         //     Find a style of a given name within the object
  476.  
  477.         VEXPORT const MMStyle *     FindStyle( const char * ) const;
  478.  
  479.         //
  480.         // FindProperty
  481.         //
  482.         //     Find a property of a given name within an object
  483.  
  484.         VEXPORT const MMProperty *  FindProperty( const char * ) const;
  485.  
  486.         virtual WString         GetMappedValue( WUInt i ) const;
  487.         virtual void            SetMappedValue( WUInt i, const WString & s );
  488.  
  489.         /*************************************************************
  490.          * Form Data Exchange [move to DTWObject]
  491.          *************************************************************/
  492.     public:
  493.         virtual WBool           GetDDXEnabled() const;
  494.         virtual void            SetDDXEnabled( WBool e );
  495.  
  496.         virtual WString         GetDDXFieldName() const;
  497.         virtual void            SetDDXFieldName( const WString & );
  498.  
  499.         virtual WString         GetDDXFieldType() const;
  500.         virtual void            SetDDXFieldType( const WString & );
  501.  
  502.         virtual WString         GetDDXModifiedFieldName() const;
  503.         virtual void            SetDDXModifiedFieldName( const WString & );
  504.  
  505.         virtual WString         GetDDXAdditional( unsigned i ) const;
  506.         virtual void            SetDDXAdditional( unsigned i, const WString & );
  507.         virtual void            EscapeCString( WString &, const WString & ) const;
  508.  
  509.         /*************************************************************
  510.          * Implementation
  511.          *************************************************************/
  512.  
  513.     public:
  514.         void                    FillInspectProperties( MTIPropertyList & ) const;
  515.         void                    FillInspectEvents( MTIEventList & ) const;
  516.         WBool                   HandleEventClick( WMenuItem *, WEventData * );
  517.         WBool                   HandleWizardMenuClick( WMenuItem *, WEventData * );
  518.         virtual DTObjectImp *   GetImplementation();
  519.  
  520.  
  521.  
  522.     protected:
  523.         DTObjectBase();
  524.  
  525.         void                    SetWindow( WWindow * );
  526.         void                    SetMeta( const MetaObject * );
  527.  
  528.         WString                 TabTo( const WString & str, unsigned col ) const;
  529.  
  530.         /*************************************************************
  531.          * Un-Implemented functions
  532.          *************************************************************/
  533.  
  534.     private:
  535.         DTObjectBase( const DTObjectImp & );
  536.         DTObjectBase &          operator=( const DTObjectBase & );
  537.  
  538.  
  539.     protected:
  540.         DTObjectImp *           _imp;
  541. };
  542.  
  543. #endif // _DTOBJECT_HPP
  544.