home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
dtobject.hpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-21
|
21KB
|
592 lines
#ifndef _DTOBJECT_HPP
#define _DTOBJECT_HPP
#include "dtobase.hpp"
#pragma warning 849 9
//
// MMFileGenerationParms
//
// Parameters to accompany the GenFileFragment call. Avoid
// modifying this structure, instead declare a derived version.
struct MMFileGenerationParms {
WFilePath path;
};
struct MMCodeGenerationParms {
MMCodeGeneration tag; // redundancy
WString owning_form;
WString form_res_name;
WBool isDialog;
};
struct MMFDXPropertyData {
WString property;
WString fieldName;
WString onValue;
};
class MMFDXPropertyVect : public WArray< MMFDXPropertyData > {
public:
};
class METAEXPORTCLASSDEF DTObjectBase : public DTObject
{
public:
virtual ~DTObjectBase() = 0;
VEXPORT WBool operator== ( const DTObject & ) const;
public:
/*************************************************************
* WClass / Awt specific behaviour
*************************************************************/
//
// GenFileFragment
//
// Generate a file-level fragment of code.
virtual void GenFileFragment( MMFileFragment fg, WStringList &,
MMFileGenerationParms * parms ) const;
/*************************************************************
* Common Behaviour
*************************************************************/
//
// Meta
//
// The Meta- object instance that is associated
// with this DT- object
VEXPORT const MetaObject *GetMeta() const;
//
// Reference Card Meta
// The Meta-object that is used to provide reference
// card information. The default implentation returns GetMeta()
VEXPORT const MetaObject * GetRefCardMeta() const;
//
// Name
//
// The variable used in the user's code to represent this
// object (eg. cb_1). Although there is a default implementation,
// you may wish to override this to perform an action when the
// name changes (eg. change names of all child objects).
virtual void DTSetName( const WString & name );
virtual WString DTGetName() const ;
//
// ClassDefinition
//
// The class name used to implement a component in code.
// This lets the user specify a different class than the
// default.
virtual void SetClassDefinition( const WString & );
virtual WString GetClassDefinition() const;
//
// ClassIncludes
//
// Extra header files this compnonent requires (specified
// by the user. For use with ClassDefinition.
virtual void SetClassIncludes( const WString & );
virtual WString GetClassIncludes() const;
//
// WImplementation
//
// Each DT- object must have an associated WObject that
// represents it on the design-time form. This is not
// required to be a WWindow-derived class, but that is the
// case that has been tested most -- only WOleObjects are
// an exception.
VEXPORT WObject * GetWImplementation() const;
VEXPORT void SetWImplementation( WObject * wobj );
//
// ConcreteInstance
//
// Return the concrete instance (the aggregated object)
virtual DTObject * GetConcreteImplementation();
//
// Window
//
// If there is a WWindow implementing the design-time
// behaviour of the object, get and return it. Otherwise,
// NULL (as for WOleObject).
VEXPORT WWindow * GetWindow() const;
//
// DTGetParent
//
// The parent window if there is a window.
VEXPORT WWindow * DTGetParent() const;
//
// ResourceID
//
// The id of the control in the .res file
VEXPORT void SetResourceID( long id );
VEXPORT long GetResourceID() const;
//
// TabIndex
//
// Tabbing order of control. Controls are emitted into
// the resource file in tab index order.
VEXPORT void SetTabIndex( long idx );
VEXPORT long GetTabIndex() const;
//
// CodeBlockList
//
// A list of code block's (functions) associated with the
// object.
//
VEXPORT const DTCodeBlockList & GetCodeBlockList() const;
VEXPORT DTCodeBlockList & GetCodeBlockList();
VEXPORT WInt GetAllCodeBlockLists( DTCodeBlockListList & );
//
// RemoveEvent
//
// Remove a code block from the list and remove any
// other pointers to it (ie. from object inspector).
VEXPORT DTCodeBlockBase * RemoveEvent( DTCodeBlockBase * );
//
// FindEvent
//
// Find a code block that has already been added to
// this object.
VEXPORT DTCodeBlockBase * FindEvent( const char * ) const;
//
// Form, DTForm
//
// The FormEdit associated with this object; the first
// form is only useful from within Optima code; the second,
// mainly from CompDLL. SetForm is called by Optima when
// it instantiates the object.
VEXPORT FormEdit * GetForm() const;
VEXPORT DTFormEditBase *GetDTForm() const;
VEXPORT void SetForm( DTFormEditBase * );
//
// Child
//
// The DTObject Children for this DTObject. DTObjects
// may now own other DTObjects.
VEXPORT int GetChildCount() const;
VEXPORT DTObject * GetChild( int index ) const;
VEXPORT WBool AddChild( DTObject *, int after = -1 );
VEXPORT WBool RemoveChild( DTObject * );
VEXPORT DTObject * GetParent() const;
//
// Style
//
// The Windows style property of the associated Window.
// This doesn't necessarily match GetWindow()->GetStyle()
// because some styles are deferred until run-time (such
// as WSVisible).
VEXPORT WStyle GetStyle() const;
VEXPORT WBool SetStyle( WStyle stl, WBool clone=FALSE );
//
// DefaultStyle
//
// The style with which new instances are created. Default
// implementation returns GetWindow()->GetDefaultStyle().
virtual WStyle GetDefaultStyle() const;
//
// ExtendedStyle
//
// The ExtendedStyle property of the window nature.
virtual WStyle GetExtendedStyle() const;
virtual WBool SetExtendedStyle( WStyle style, WBool clone=FALSE );
//
// DefaultExtendedStyle
//
// See DefaultStyle
virtual WStyle GetDefaultExtendedStyle() const;
//
// Create
//
// Call Create on the windowed object.
//
virtual WBool Create( WWindow * parent, const WRect & r,
const WChar * text, WStyle style,
WStyle exStyle, void * data = NULL,
WBool isLoading = FALSE );
//
// NonVisual
//
// NonVisual objects are represented by a picture box at
// design time -- eg. WTimer, WMessageBox, WFileDialog.
VEXPORT WBool GetNonVisual() const;
// DTInfo
//
// Each object can have information that is not handled by
// the general framework. For instance, listboxes store their
// lines separately. HasDTInfo should return true if you want
// to store object-specific information, then the SaveDTInfo
// and LoadDTInfo functions will be called.
virtual WBool HasDTInfo();
virtual WBool SaveDTInfo( SaveSource & );
virtual WBool LoadDTInfo( SaveBlock *, WBool beforeCreate );
//
// CreateEventPopupMenu
//
// Popupulate a popup menu with the events that are deemed
// useful ("hot" events) as well as events with code. There
// is a default behaviour which is overriden for Ole objects.
virtual WBool CreateEventPopupMenu( WPopupMenu * popup );
//
// IsResizeable
//
// IsResizeable allows non-visual objects and Ole objects to
// deny resizing (can change after created
virtual WBool GetIsResizeable();
//
// Hollow
//
// GroupBoxes are treated as "Hollow" controls in that when
// they are moved, contained controls are also moved. Also,
// hollow controls are not active except for a border around
// the outside. HollowRect is the rectangle in the center
// that doesn't activate the object.
virtual WBool GetIsHollow(); // groupbox
virtual WRect GetHollowRect(); // interior of groupbox
//
// DTPopupMenu
// The popup menu associated with a WWindow. NOT the
// popup menu that shows up at design-time.
// [ITB:06/4] expect this will move to DTW.
VEXPORT WBool SetDTPopupMenu( DTObject * );
VEXPORT DTObject * GetDTPopupMenu() const;
//
// AmendPopup
//
// Override this function to modify the design-time context
// popup. "before" is true before the popup is displayed,
// false afterwards. Make sure you clean up any menu items
// you add or they will remain for other objects as well.
//
virtual void AmendPopup( WPopupMenu *, WBool before );
//
// IsValidChild
//
// Returns true if obj is allowed as a child of this
// DTObject. errMsg is filled in with details about
// why it isn't allowed.
virtual WBool IsValidChild(
const MetaObject *obj,
WString &errMsg ) const;
//
// IsValidContainer
//
// Returns true if obj is allowed as a container for this
// DTObject. errMsg is filled in with details about
// about why it isn't allowed.
virtual WBool IsValidContainer(
const DTObject *obj,
WString &errMsg ) const;
//
// SetEventHandler
//
// Set an event handler on the W-Implementation object.
virtual WBool DTSetEventHandler( WEventID id,
WObject * object,
WEventHandler handler,
void *userdata=NULL );
//
// DTIInterface
//
// Get DTInterface with a particular name. This virtual
// function is overridden once by derived classes that use
// DTInterfaces
virtual DTIInterface * GetDTIInterface( const WChar * ifname );
//
// Protected
//
// This property controls the behaviour of a design time
// object. Protected objects are:
// - not saved or loaded
// - cannot be deleted directly by the user
virtual WBool GetProtected() const;
/*************************************************************
* Property Editting
*************************************************************/
//
// EditProperties
//
// Display a property sheet window. Depending on "child",
// the property sheet may be a child (as in object view) or
// a popup dialog (normal property sheets).
VEXPORT WBool EditProperties( WWindow *,
WBool child = FALSE );
//
// ClearPropertyEditor
//
// Remove and destroy any open property editor for this object.
VEXPORT void ClearPropertyEditor( WBool deleteNow = FALSE );
//
// UpdatePropertyRect
//
// Inform any open property editors to update the position
// property since this object has been moved
virtual WBool UpdatePropertyRect();
//
// PropDialog
//
// Get a pointer to the open property editor or return NULL.
VEXPORT MTPropertyDialog * GetPropDialog();
//
// HasProperty
//
// Return TRUE if this object has a property named "name".
VEXPORT WBool HasProperty( const WString & name ) const;
//
// Property
//
// Get or set a property with various formats.
// The additional formats are provided for convenience only.
VEXPORT WString GetProperty( const WString & name, DT_TextifyV t = 1 ) const;
VEXPORT WBool GetPropertyBool( const WString & name ) const;
VEXPORT WLong GetPropertyEnum( const WString & name ) const;
VEXPORT WRect GetPropertyRect( const WString & name ) const;
VEXPORT WLong GetPropertyLong( const WString & name ) const;
VEXPORT WBool SetProperty( const WString & name, const WString & val, DT_TextifyV t = 1 );
VEXPORT WBool SetPropertyBool( const WString & name, WBool val );
VEXPORT void SetPropertyEnum( const WString & name, WLong val );
VEXPORT void SetPropertyRect( const WString & name, const WRect & r );
VEXPORT void SetPropertyLong( const WString & name, WLong r );
virtual void PropertyChanged( const WString & name );
//
// DetachEditor
//
// Virtual call to detach an editor mini application if necessary.
virtual void DetachEditor();
/*************************************************************
* Code Generation
*************************************************************/
//
// ObjectPrefix
//
// Get the prefix used when accessing member functions of the
// object -- eg. "cb_1->"
VEXPORT WString GetObjectPrefix() const;
//
// GenName
// Generate a variable name by number, eg. cb_1 if id == 1
// The string is an out parameter.
VEXPORT void GenName( WUInt id, WString & ) const;
//
// GenClassName
//
// Generate the name of the C++ or Java class that implements
// this object.
VEXPORT void GenClassName( WString & ) const;
//
// GenResourceName
//
// Generate the resource ID from the object name. This is
// usually of the form ID_name.
VEXPORT void GenResourceName( WString & ) const;
//
// GenResourceStyles
//
// Generate the .rc file styles that will be used; the first
// parameter is a string list filled with styles, the second
// is filled with extended styles
VEXPORT void GenResourceStyles( WStringList &, WStringList & ) const;
//
// GenEventObjectName
//
// Generate the object name for an event. The name is built
// by recursing the DTObject hierarchy and prepending the names
// of the DTObjects
VEXPORT void GenEventObjectName( WString & ) const;
//
// RequiredIncludes
//
// Fill in a list of required include files.
virtual void GetRequiredIncludes( WStringList & includes ) const;
//
// RequiredBaseClasses
//
// Fill in a list of required base classes to add to the form
virtual void GetRequiredBaseClasses( WStringList & bases ) const;
//
// GenerateCode [new]
//
// Generate a fragment of code for a component.
// The "cg" parameter indicates which scrap of code to generate.
void GenerateCode( MMCodeGeneration, ostream &, MMCodeGenerationParms & );
//
// FindStyle
//
// Find a style of a given name within the object
VEXPORT const MMStyle * FindStyle( const char * ) const;
//
// FindProperty
//
// Find a property of a given name within an object
VEXPORT const MMProperty * FindProperty( const char * ) const;
virtual WString GetMappedValue( WUInt i ) const;
virtual void SetMappedValue( WUInt i, const WString & s );
/*************************************************************
* Form Data Exchange [move to DTWObject]
*************************************************************/
public:
virtual WBool GetDDXEnabled() const;
virtual void SetDDXEnabled( WBool e );
virtual WString GetDDXFieldName() const;
virtual void SetDDXFieldName( const WString & );
virtual WString GetDDXFieldType() const;
virtual void SetDDXFieldType( const WString & );
virtual WString GetDDXModifiedFieldName() const;
virtual void SetDDXModifiedFieldName( const WString & );
virtual void EscapeCString( WString &, const WString & ) const;
/*************************************************************
* Implementation
*************************************************************/
public:
void FillInspectProperties( MTIPropertyList & ) const;
void FillInspectEvents( MTIEventList & ) const;
WBool HandleEventClick( WMenuItem *, WEventData * );
WBool HandleWizardMenuClick( WMenuItem *, WEventData * );
virtual DTObjectImp * GetImplementation();
MMFDXPropertyVect GetFDXProperties() const;
void SetFDXProperties( const MMFDXPropertyVect & );
WString GetFDXFieldName( const MMProperty * prop ) const;
protected:
DTObjectBase();
void SetWindow( WWindow * );
void SetMeta( const MetaObject * );
WString TabTo( const WString & str, unsigned col ) const;
/*************************************************************
* Un-Implemented functions
*************************************************************/
private:
DTObjectBase( const DTObjectImp & );
DTObjectBase & operator=( const DTObjectBase & );
protected:
DTObjectImp * _imp;
};
#endif // _DTOBJECT_HPP