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

#include "..\aBaseEvent.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    ( LPUNKNOWN  ctrl )                             { return true; }
  //prButtonUpdate        -    .
  virtual bool OnButtonUpdate      ( long buttonID, long * check, 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  ();
  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()
};

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

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

#endif 
