home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / dtobject.hpp < prev    next >
C/C++ Source or Header  |  1997-01-21  |  21KB  |  592 lines

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