|
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef _PROPERTIESSET_H
#define _PROPERTIESSET_H
#ifndef _VECTOR_
#include <vector>
#endif
//#include <xml.h>
//These messages are view local so I'll leave them as they are for now.
#define PV_FIRSTMSG 0x4500
#define PV_LASTMSG 0x451f
#define LVC_SUSPENDCTRL 0x4501
#define LVC_RESTORECTRL 0x4502
#define LVC_ITEMCHANGED 0x4503
extern unsigned int ID_REG_PVM_CONNECT;
//CStringVector ............................................................
class CStringVector
{
public:
CStringVector( ) { }
CStringVector( LPCTSTR inList ) { AppendList( inList ); }
private:
CString hold;
std::vector<CString> list;
typedef std::vector<CString>::iterator CSV_IT;
public:
void AppendList( LPCTSTR inList )
{
int i= 0, j;
CString at( inList );
while( ( j= at.Find( '\n', i ) ) != -1 )
{
list.push_back( at.Mid( i, j - i ) );
i= j + 1;
}
}
LPCTSTR GetListStr( )
{
hold.Empty( ); for( CSV_IT it= list.begin( ); it != list.end( ); ++it ) hold+= *it + '\n'; return hold;
}
long GetSize( ) { return (long)list.size( ); }
void SetList( LPCTSTR inList ) { list.clear( ); AppendList( inList ); }
LPCTSTR operator [] ( long index ) { ASSERT( index >= 0 && index < GetSize( ) ); return list[index]; }
};
struct CToolBarData
{
WORD wVersion;
WORD wWidth;
WORD wHeight;
WORD wItemCount;
//WORD aItems[wItemCount]
WORD* items()
{ return (WORD*)(this+1); }
};
class CPropertiesViewToolbar
{
public:
WORD bmId;
WORD* btnSet;
int btnCount;
};
//CPropertiesViewItem ......................................................
class CPropertiesViewItem : public CObject
{
public:
enum Type {
evNull= 0x0000,
evBool= 0x0001,
evEdit= 0x0002,
evDropDown= 0x0004,
evUser= 0x0010,
evUserNE= 0x0020,
evEventMask= 0x00ff,
//more stuff ?...........
};
private:
Type type;
CString strLabel;
CString strDescription;
CString strEdit;
long siIndex;
CStringVector siSet;
public:
CPropertiesViewItem::CPropertiesViewItem( ): siIndex( 0 ), type( evNull ) { }
CPropertiesViewItem( const CPropertiesViewItem &s )
{ type= s.type; strLabel= s.strLabel; strEdit= s.strEdit;
strDescription= s.strDescription; siSet= s.siSet; siIndex= s.siIndex; }
CPropertiesViewItem& operator= ( const CPropertiesViewItem &s )
{ type= s.type; strLabel= s.strLabel; strEdit= s.strEdit;
strDescription= s.strDescription; siSet= s.siSet; siIndex= s.siIndex; return *this; }
Type GetType( ) { return type; }
void SetType( Type t ) { type= t; if( type == evBool ) SetList( _T("true\nfalse\n") ); }
LPCTSTR GetLabel( ) { return strLabel; }
void SetLabel( LPCTSTR newLable ) { strLabel= newLable; }
LPCTSTR GetDescription( ) { return strDescription; }
void SetDescription( LPCTSTR newDescription ) { strDescription= newDescription; }
LPCTSTR GetItemText( );
//Case of input list is \n delimited
void SetList( LPCTSTR inList ) { siSet.SetList( inList ); }
void SetIndex( long i ) { ASSERT( siIndex < siSet.GetSize( ) ); siIndex= i; }
long GetIndex( ) { return siIndex; }
LPCTSTR GetListStr( ) { return siSet.GetListStr( ); }
void SetStr( LPCTSTR edit ) { strEdit= edit; }
LPCTSTR GetStr( ) { return strEdit; }
};
typedef CPropertiesViewItem PROPERTIESVIEW_ITEM, *LPPROPERTIESVIEW_ITEM;
typedef std::vector<CPropertiesViewItem> PROPERTIESVIEW_LIST;
typedef std::vector<CPropertiesViewItem>::iterator PROPERTY_IT;
// CPropertiesViewSet ................................................................
//for pvCallback
#define CPVS_RELOAD 0x0001
#define CPVS_DISCONECT 0x0002
//for EventCallback
#define CPVS_CHANGED 0x0004
#define CPVS_OWNNERDO 0x0008
class CPropertiesView;
class CPropertiesDoc;
class CPropertiesViewSet;
typedef bool (CALLBACK *PVEVENTCALLBACK)( LPVOID, int, int, int );
typedef bool (CALLBACK *PVIEWCALLBACK)( CPropertiesViewSet*, CPropertiesView*, int );
class CPropertiesViewSet : private PROPERTIESVIEW_LIST
{
private:
friend CPropertiesView;
friend CPropertiesDoc;
long id;
long group;
long toolPos;
INT_PTR bmId;
CString tip;
CString title;
CPropertiesViewToolbar* pTool;
//client callback
CObject* owner;
PVEVENTCALLBACK EventCallback;
//CPropertiesView connection
CPropertiesView* propView;
PVIEWCALLBACK pvCallback;
bool Callback( int action, int item )
{ if( EventCallback != NULL ) return (*EventCallback)( owner, action, item, id ); else return true; }
public:
CPropertiesViewSet( long nId= 0, long nGrp= 0 )
:EventCallback( NULL ), owner( NULL ), pvCallback( NULL )
, id( nId ), group( nGrp ), toolPos( -1 ), pTool( NULL ) { }
~CPropertiesViewSet( ) { if( pvCallback != NULL ) (*pvCallback)( this, propView, CPVS_DISCONECT ); }
public:
PROPERTIESVIEW_ITEM& operator [] ( long i ) { ASSERT( i >= 0 && i < (int)size( ) ); return at( i ); }
CPropertiesViewItem& GetItem( long item ) { return at( item ); }
void ReloadProperies( ) { if( pvCallback != NULL ) (*pvCallback)( this, propView, CPVS_RELOAD ); }
void AppendSet( PROPERTIESVIEW_ITEM& item ) { push_back( item ); }
void ClearSet( ) { clear( ); ReloadProperies( ); }
long GetCount( ) { return (long)size( ); }
LPCTSTR GetDescription( long item ) { return at( item ).GetDescription( ); }
void SetTitle( LPCTSTR t ) { if( t != NULL ) title= t; }
LPCTSTR GetTitle( ) { return title; }
void SetEventCallback( PVEVENTCALLBACK event, CObject* object ) { EventCallback= event; owner= object; }
void ClearEventCallback( ) { EventCallback= NULL; }
bool IsConnected( ) { return /*EventCallback != NULL &&*/ pvCallback != NULL; }
long GetID( ) { return id; }
void SetID( long nId ) { id= nId; }
long GetGroup( ) { return group; }
void SetGroup( long nGrp ) { group= nGrp; }
void SetToolTip( LPCTSTR sTip ) { tip= sTip; }
void SetToolbar( long pos, CPropertiesViewToolbar* ipTool ) { toolPos= pos; pTool= ipTool; bmId= ipTool->bmId; }
void SetToolbar( long pos, INT_PTR ibmId ) { toolPos= pos; bmId= ibmId; }
};
typedef CPropertiesViewSet PROPERTIESVIEW_SET, *LPPROPERTIESVIEW_SET;
//typedef std::vector<CPropertiesViewSet> PROPERTIESVIEW_SET_SET;
//typedef std::vector<CPropertiesViewSet>::iterator PROPERTY_SET_IT;
// CPropertiesViewGroup ............................................
class CPropertiesViewGroup
{
WORD bmID;
std::vector<LPPROPERTIESVIEW_SET> buttonSet;
};
// CPropertiesDoc ..................................................
class CPropertiesDoc : public CDocument//, public PROPERTIESVIEW_SET_SET
{
};
#endif //_PROPERTIESSET_H
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.