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

#ifndef _ABASEEVENT_H
#include "abaseEvent.h"
#endif

#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);              //    
void ShowError();                           //      HRESULT 

/*
  
  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                  flagMode;         //    -
  IProcessParamPtr     procParam;        //            
  IPropertyTabsPtr     propTabs;         // 
  IPropertyControlsPtr curentCollection; //      
  _DVCHatchPtr         hatchCtrl;        //  -  
  IPropertyGridPtr     paramGrid;        //       
  IPropertySlideBoxPtr slideBox;         //   
  long                 rowIndex;         //  
  IProcessParamPtr     posLiaderParam;   //     
public:
          
           PropertyManagerObject();
  virtual ~PropertyManagerObject();
//   ##################################################################
    //      
    // prButtonClick -  .
  virtual bool OnButtonClick( long buttonID ) { return true; }
    
    //prChangeControlValue -   
  virtual bool OnChangeControlValue( /*IPropertyControl* cntrl,*/ 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; }
  //   ActiveX Control-a
  virtual void OnCreateOCX( long ctrlID, LPDISPATCH control ) {}

  //   ActiveX Control-a 
  virtual void OnDestroyOCX( long ctrlID/*, LPDISPATCH control*/ );
          //    
  /*virtual*/ bool InitProcessParam( long toolBarID, SpecPropertyToolBarEnum toolBarType, long firstTabID = 0 );
          //       
  /*virtual*/ bool InitPosLeaderParam();

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

  //     
  IPropertyListPtr               CreateList       ( double minVal = 0, double maxVal = 0 );
  //   
  IPropertySeparatorPtr          CreateSeparator  ( SeparatorTypeEnum type );
  //  CheckBox- 
  IPropertyCheckBoxPtr           CreateCheckBox   ( bool checked );
  //    
  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  SetTabVisible( long tabID, bool visible );
  //             
  //        void  AddBSTRToGrig(   long paramID, _bstr_t& value ); //   
  //       void  AddStringToGrig( long paramID, CString& value ); //   
          void  AddStringToGrig( long paramID, LPCTSTR  value   ); //   
          void  AddDoubleToGrig( long paramID, double   value   ); //    
 
  //             
  virtual  bool IsHatchObject() { return false; }

  //              
  virtual  void ShowHatchControl() { }
  
  //   
          void  EndProcess();
//   ##################################################################
          virtual reference  GetPreviewGroup() { return 0; }

};


////////////////////////////////////////////////////////////////////////////////
//
// PropertyManagerEvent -      
//
////////////////////////////////////////////////////////////////////////////////
class PropertyManagerEvent : public ABaseEvent
{

protected:
  PropertyManagerObject&  obj;           //    
  // Attributes
public:
	PropertyManagerEvent( LPDISPATCH manager, PropertyManagerObject& _obj );           
  virtual ~PropertyManagerEvent();

// Operations
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()

};


/*
////////////////////////////////////////////////////////////////////////////////
//
// PropertyManagerEvent -      
//
////////////////////////////////////////////////////////////////////////////////
class PropertyManagerEvent : public cBaseEvent
{
protected:
  PropertyManagerObject&  obj;           //    
  // Attributes
public:
	PropertyManagerEvent( LPUNKNOWN I, PropertyManagerObject& _obj );           
  virtual ~PropertyManagerEvent();

// Operations
public:
  PropertyManagerObject& GetObj() { return obj; }
  virtual   LPUNKNOWN GetUnknown();

	BEGIN_INTERFACE_PART(PropertyManagerNotify, IPropertyManagerNotify)
		INIT_INTERFACE_PART(PropertyManagerEvent, PropertyManagerNotify)

    //      notifyType
    STDMETHOD_(VARIANT_BOOL, IsNotifyProcess)( THIS_ int notifyType );

    //prButtonClick -  .
    STDMETHOD_(VARIANT_BOOL, ButtonClick)( THIS_ long buttonID);
    
    //prChangeControlValue -   
    STDMETHOD_(VARIANT_BOOL, ChangeControlValue)( THIS_ LPUNKNOWN  ctrl);

    //prControlCommand   
    STDMETHOD_(VARIANT_BOOL, ControlCommand)( THIS_ LPUNKNOWN  ctrl, long buttonID );
    
    //prButtonUpdate        -    .
    STDMETHOD_(VARIANT_BOOL, ButtonUpdate)( THIS_ long buttonID, long* check, long* _enable);
    
    // prProcessActivate    -  	
    STDMETHOD_(VARIANT_BOOL, ProcessActivate) ( THIS_ );
    
    // prProcessActivate    -  
    STDMETHOD_(VARIANT_BOOL, ProcessDeactivate) ( THIS_ );
        
  END_INTERFACE_PART(PropertyManagerNotify)
	
};
*/
//  
void App7NULL();

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

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

#endif 
