AeBinEditor.h 5.1 KB
// AeBinEditor.h
//
// This class contains the abstract and concrete definitions
// for editor clients of the database.  Editors have both read
// and write access into the database.
//
// The AeBinEditor abstract class represents an editor for assets
// according to their type or bin.  It could also be called a list
// editor since the assets are viewed in a list.  This editor has
// lots of routines to support the list widget callbacks and must
// handle all the user input for each cell in the list.
//
// The AeAssetEditor, which edits all assets, and the AeBankEditor,
// which edits only bank assets, are implemented as AeBinEditors.
//

#ifndef __AeBinEditor__
#define __AeBinEditor__

#include <Xm/Xm.h>

#include "AeTypes.h"
#include "AeAsset.h"
#include "AeEditor.h"


typedef enum
{
    kModNone	= 0,
    kModShift,
    kModAlt,
    kModDown,
    kModMotion,
    kModUp
} TEditModifier;


struct _XbaeMatrixEnterCellCallbackStruct;
struct _XbaeMatrixLeaveCellCallbackStruct;
struct _XbaeMatrixModifyVerifyCallbackStruct;
struct _XbaeMatrixDrawCellCallbackStruct;
struct _XbaeMatrixWriteCellCallbackStruct;
struct _XbaeMatrixSelectCellCallbackStruct;
struct _XbaeMatrixTraverseCellCallbackStruct;
struct _XbaeMatrixDefaultActionCallbackStruct;


template<class T> class GList;
class AeAssetBase;
class AeAssetBinUI;
class AeAssetBin;
class AeAsset;
class AeAssetUI;
class AeFieldUI;
class AeBinView;

class AeBinEditor : public AeEditor
{
public:
                        AeBinEditor (void);
    virtual	       	~AeBinEditor (void);

    virtual void       	SetAssetBase (AeAssetBase *);
    
    virtual void	CreateAsset (AeAsset *, Boolean);
    virtual void       	UpdateAsset (AeAsset *, Boolean);
    virtual void	DeleteAsset (AeAsset *, Boolean);
    virtual void	SelectAsset (AeAsset *, Boolean);
    virtual void	OnlineAsset (AeAsset *, Boolean);

    virtual void	UpdateResume (void);
    void		UpdateHierarchy (void);

    virtual void	OpenEditor (AeAsset *) { }
    void		InsertAsset (void);
    void		DeleteAssetUI (void);
    void		InsertChildAsset (void);
    void		RemoveChildAsset (void);

    void		SelectOrphans (void);
    void		SelectParents (void);
    void		DeselectAllAssets (void);
    void		DeleteAllBankAssets (void);

    void	       	SetIndexedBinUI (int index);
    void		SelectTypedBinUI (TAssetType);
    void		SetBinListUserData (Widget list);
    void		SetAssetFieldValue (AeAssetUI *, AeFieldUI *, void *);

    AeBinView *		GetView (void) { return fView; }
    AeAssetBinUI *	GetBinUI (void) { return fBinUI; }
    int		       	GetNumBins (void);
    int		       	GetNumBinAssets (void);
    int		       	GetNumBinFields (void);
    void	       	GetBinNames (String *);
    void	       	GetBinFieldLabels (String *);
    void	       	GetBinFieldWidths (short *);
    void	       	GetBinFieldMaxLens (int *);
    void	       	GetBinFieldAligns (unsigned char *);
    
    Boolean		FindTypedBinUI (TAssetType, AeAssetBinUI * &);

    void		ClickEdit (Widget, XEvent *, Boolean *);
    void	       	EnterCell (Widget, _XbaeMatrixEnterCellCallbackStruct * );
    void       		LeaveCell (Widget, _XbaeMatrixLeaveCellCallbackStruct * );
    void	       	ModifyVerify (Widget, _XbaeMatrixModifyVerifyCallbackStruct *  );
    void	       	DrawCell (Widget, _XbaeMatrixDrawCellCallbackStruct * );
    void	       	WriteCell (Widget, _XbaeMatrixWriteCellCallbackStruct * );
    void	       	SelectCell (Widget, _XbaeMatrixSelectCellCallbackStruct * );
    void		TraverseCell (Widget, _XbaeMatrixTraverseCellCallbackStruct *);
    void	       	DefaultAction (Widget, _XbaeMatrixDefaultActionCallbackStruct * );

    void	       	SelectAssetUI (AeAssetUI *, TEditModifier);

    static XrmQuark	qLeft;
    static XrmQuark	qRight;
    static XrmQuark	qUp;
    static XrmQuark	qDown;

    // menu editing support
    static void	       		MenuCallback (Widget, XtPointer, XtPointer);
    static AeBinEditor *	fMenuEditor;
    static AeAssetUI *		fMenuAssetUI;
    static AeFieldUI *		fMenuFieldUI;


protected:
    virtual Boolean		binHasUI (AeAssetBin *);
    void			createBinUIs (void);
    void			initBinUIs (void);
    void	       		initChildBinUIs (void);
    AeAssetUI *			createAssetUI (AeAsset *);

    int		      		getNumAssetUIs (GList<AeAsset *> *);
    void			setListAssetData (GList<AeAsset *> *, int level, 
						  int & row, Widget list);

    void			initName (AeAssetBinUI *);
    void			initFieldUIList (AeAssetBinUI *);
    void			initFieldUIs (void);
    void			initBankFileFieldUI (AeAssetBinUI *);
    void			initBankFieldUI (AeAssetBinUI *);
    void 			initInstFieldUI (AeAssetBinUI *);
    void			initSoundFieldUI (AeAssetBinUI *);
    void			initEnvFieldUI (AeAssetBinUI *);
    void			initKeymapFieldUI (AeAssetBinUI *);
    void			initWaveFieldUI (AeAssetBinUI *);
    void			initFxFieldUI (AeAssetBinUI *);
    void			initFxSxnFieldUI (AeAssetBinUI *);

    void			updateAsset (AeAsset * asset);
    void			updateWidths (void);

    TEditModifier		params2modifier (int, String *);

    AeAssetBinUI *		fBinUI;
    GList<AeAssetBinUI *> *	fBinUIList;
    GList<AeAssetUI *> *       	fSelectionList;
    AeBinView *	       		fView;
};


#endif // __AeBinEditor__