////////////////////////////////////////////////////////////////////////////////
//
// PropertyManagerObject -      
// PropertyManagerEvent  -     
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _CPROPMEN_H
#define _CPROPMEN_H

#include "..\events\ABaseEvent.h"
#include "..\OneWindow.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//-------------------------------------------------------------------------------
//     
// ---
int LibMessage( int     strId, int flags ); //    
int LibMessage( LPCTSTR str,   int flags ); //    
 
//   COM 
void DumpError(_com_error& e);              //    

/*
  
  IApplicationPtr kompasNewApp;
  HRESULT _hr = get_Application( &kompasNewApp );
  if (FAILED(_hr)) 
    ShowError();
*/

/*  2

     kAPI7.tli:
inline IKompasDocumentPtr IDocuments::GetItem ( const _variant_t & Index ) {
  struct IKompasDocument * _result;
  HRESULT _hr = get_Item(Index, &_result);
  if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
  return IKompasDocumentPtr(_result, false);
}
....
IKompasDocumentPtr kompasDocument;
....
try { 
  kompasDocument = documents->Item[100000]; //  
}
catch(_com_error &e)
{
  DumpError(e);
  return;
}
....
*/

//----------------------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
//
//      
//
// ctrlID          
//  
//
////////////////////////////////////////////////////////////////////////////////
class PropertyManagerObject {
protected:
  int                  m_flagMode;         //    -
  IProcessParamPtr     m_procParam;        //            
  IPropertyTabsPtr     m_propTabs;         // 
  IPropertyControlsPtr m_curentCollection; //      
  IPropertyGridPtr     m_paramGrid;        //       
  IPropertySlideBoxPtr m_slideBox;         //   
  long                 m_rowIndex;         //  
  IProcessParamPtr     m_posLiaderParam;   //     
public:
          
           PropertyManagerObject();
  virtual ~PropertyManagerObject();
//   ##################################################################
  //      
  // prButtonClick -  .
  virtual bool OnButtonClick       ( long buttonID )                               { return true; }
  //prChangeControlValue -   
  virtual bool OnChangeControlValue( long ctrlID, const VARIANT & newVal )         { return true; }
  //prControlCommand   
  virtual bool OnControlCommand    ( long ctrlID, long buttonID )                  { return true; }
  //prButtonUpdate        -    .
  virtual bool OnButtonUpdate      ( long buttonID, long * check, VARIANT_BOOL * _enable ) { return true; }
  // prCommandHelp -  
  virtual bool OnCommandHelp       ( long ID )                                     { return false; }
  //   ActiveX Control-a
  virtual void OnCreateOCX         ( long ctrlID, LPDISPATCH control )             {}
  //   ActiveX Control-a 
  virtual void OnDestroyOCX        ( long ctrlID );

  //    
  virtual bool                    InitProcessParam  ( long toolBarID, SpecPropertyToolBarEnum toolBarType, long firstTabID );
  virtual long                    GetFirstTabID     () { return 0; }
  virtual SpecPropertyToolBarEnum GetSpecToolBarType() { return pnEnterEscHelp; }
          void                    EndProcess        (); //   

  //  
          bool CreateTab( long tabID, BOOL visible = TRUE, BOOL active = FALSE ); 

  //     
  IPropertyEditPtr        CreateEditReal   ( double minVal = 0, double maxVal = 0 );
  //     
  IPropertyListPtr        CreateList       ( double minVal = 0, double maxVal = 0 );
  //     
  IPropertyListPtr        CreateStringList ( CString matVal = "" );
  //   
  IPropertySeparatorPtr   CreateSeparator  ( SeparatorTypeEnum type );
  //  CheckBox- 
  IPropertyCheckBoxPtr    CreateCheckBox   ( bool checked );
  //  SpinEdit 
  IPropertySpinEditPtr    CreateSpinList   ( double minVal = 0, double maxVal = 0 ); //  
  //    
  IPropertyMultiButtonPtr CreateMultiButton( ButtonTypeEnum type );
  //  ActiveX Control 
  IPropertyUserControlPtr CreateUserControl( long ctrlID, long height, long width );

  //    Control    (   )
  IPropertyControlPtr GetPropertyControl( int ctrlID ); 

  //    
          void AddButton ( IPropertyMultiButtonPtr & buttons, long btnID, 
                           bool cheched = false,  bool enable = true );
  //    
          void AddButton2( IPropertyMultiButtonPtr & buttons, long btnID, 
                           long bmpID, bool cheched = false,  bool enable = true );

  //   
          void SetControlEnable( long ctrlID, bool enabled = true ); 

  //    
  void InitPropertyControl( IPropertyControl * control, long ctrlID, UINT hint = 0, 
                            UINT tips = 0, BOOL enable = TRUE, 
                            PropertyControlNameVisibility nameVisibility = ksNameAlwaysVisible, 
                            BOOL visible = TRUE );

  virtual void  ShowControls () {}  //     
  virtual void  RedrawPhantom() {}  //  

  virtual int   ParamCount() { return 0; }  //      
  virtual void  ShowParam () {}             //    

           void  AddStringToGrig( long paramID, LPCTSTR  value   ); //   
          void  AddDoubleToGrig( long paramID, double   value   ); //    
 
//   ##################################################################

  virtual reference GetPreviewGroup() { return 0; }
};


////////////////////////////////////////////////////////////////////////////////
//
// PropertyManagerEvent -      
//
////////////////////////////////////////////////////////////////////////////////
class PropertyManagerEvent : public ABaseEvent
{
protected:
  PropertyManagerObject & m_obj; //    

public:
	PropertyManagerEvent( LPDISPATCH manager, PropertyManagerObject & obj );
  virtual ~PropertyManagerEvent();

public:
  // prButtonClick        -  .  " OCX ."
  afx_msg BOOL ButtonClick       ( long buttonID );
  // prChangeControlValue - " OCX ."
  afx_msg BOOL ChangeControlValue( LPDISPATCH ctrl );
  // prControlCommand     -   
  afx_msg BOOL ControlCommand    ( LPDISPATCH  ctrl, long buttonID );
  // prButtonUpdate        -    .
  afx_msg BOOL ButtonUpdate      ( long buttonID, long * check, VARIANT_BOOL * _enable );
  // prProcessActivate    -  	
  afx_msg BOOL ProcessActivate   ();
  // prProcessDeactivate  -  
  afx_msg BOOL ProcessDeactivate ();
  // prCommandHelp        -    .
  afx_msg BOOL CommandHelp       ( long buttonID );

  DECLARE_EVENTSINK_MAP()
};


//-----------------------------------------------------------------------------
//
// ---
class ATreeViewEventCallBack
{

public:
//  11   virtual void BeforeLabelEdit ( short * Cancel );
//  11   virtual void AfterLabelEdit  ( short * Cancel, BSTR * NewString );
  virtual void OnExpandOrCollapse( struct INode * Node, bool collapse ) {}
  virtual void OnNodeClick       ( struct INode * Node )                {}
//  11   virtual void NodeCheck       ( struct INode * Node );

};

//-----------------------------------------------------------------------------
// ATreeViewEvent  -    ocx 
// ---
class ATreeViewEvent : public ABaseEvent
{
  ATreeViewEventCallBack & m_obj;
public:
  ATreeViewEvent( ITreeViewPtr & tree, ATreeViewEventCallBack & obj );           
  virtual ~ATreeViewEvent();
  
protected:
//  11   afx_msg void BeforeLabelEdit ( short * Cancel );
//  11   afx_msg void AfterLabelEdit  ( short * Cancel, BSTR * NewString );
  afx_msg void Collapse        ( struct INode * Node );
  afx_msg void Expand          ( struct INode * Node );
  afx_msg void NodeClick       ( struct INode * Node );
//  11   afx_msg void NodeCheck       ( struct INode * Node );
  
  DECLARE_EVENTSINK_MAP()
};


//-----------------------------------------------------------------------------
//
// ---
class ADVCTreeEventsCallBack
{
  
public:
  virtual void OnMenuCommand ( long Id ) {}
  
};


//-----------------------------------------------------------------------------
// ADVCTreeEvents  -    ocx 
// ---
class ADVCTreeEvents : public ABaseEvent
{
  ADVCTreeEventsCallBack & m_obj;
public:
  ADVCTreeEvents( _DVCTree * ctrl, ADVCTreeEventsCallBack & obj );           
  virtual ~ADVCTreeEvents();
  
protected:
  afx_msg void MenuCommand ( long Id );
  
  DECLARE_EVENTSINK_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif 
