www.pudn.com > 1.rar > I2Control.h


// I2Control.h: interface for the CI2WBControl class. 
#ifndef _IASP2WHITEBOARDWHITEBOARDCONTROLINCLUDEFILE_H_ 
#define _IASP2WHITEBOARDWHITEBOARDCONTROLINCLUDEFILE_H_ 
 
class CI2WBBaseWB; 
class CI2WBControl; 
 
#include "I2BaseWB.h" 
#include "I2BaseCtrl.h" 
#include "I2ControlSet.h" 
#include "I2BaseCSet.h" 
 
//extern I2HeapAllocate _g_i2wbheapallocate; 
 
typedef enum tagDrawTypes 
{ 
dtPen, 
dtLine, 
dtHRect, 
dtRect,	 
dtHCirc, 
dtCirc, 
dtHPoly, 
dtPoly, 
dtText, 
dtImage, 
dtImageGif, 
dtImageJpeg, 
dtImageMeta 
}DrawTypes; 
 
//-----CPointList-----// 
//template class  I2List; 
class CPointList:public I2List 
{ 
public: 
/*CPointList():I2List(&_g_i2wbheapallocate) 
{ 
}*/ 
VOID setItems(VOID* p,INT c,INT cap) 
{ 
m_count=c; 
if(cap>m_capacity) 
{ 
  void* ptr=m_allocate->alloc(sizeof(POINT)*cap); 
  if(!ptr) 
    throw new I2BaseException(I2E_OUTOFMEMORY); 
  memcpy(ptr,p,sizeof(POINT)*cap); 
  m_allocate->free(m_items); 
  m_items=(POINT*)ptr; 
} 
else 
  memcpy(m_items,p,c*sizeof(POINT)); 
 
/* 
m_count=c; 
if(cap>m_capacity) 
	m_items=(POINT*)m_allocate->realloc(m_items,sizeof(POINT)*cap); 
 
m_capacity=cap; 
memcpy(m_items,p,c*sizeof(POINT));*/ 
} 
 
}; 
 
//property dialod box -- display control attributes 
class CPropertyDlg : public I2Dialog 
{ 
public: 
  BOOL           m_pressok; 
  CI2WBControl*  m_pawc; 
  CPropertyDlg(CI2WBControl*); 
protected: 
  void onInitliaze(const I2Dialog& dlg); 
  virtual void onCommand(const I2Dialog& dlg,WORD wID,WORD wNotifyCode); 
}; 
 
//-----CI2WBControl-----// 
class CI2WBControl : public CI2WBBaseCtrl   
{ 
#define CLASSNAME_CI2WBCONTROL "CI2WBControl" 
 
public: 
	VOID readFromStream(I2MemoryFileStream *stm,INT len,const I2Rect& r); 
	VOID writeToStream(I2MemoryFileStream *stm,BOOL fdata); 
	VOID OnRButtonUp(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend); 
	VOID OnRButtonDown(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend); 
	BOOL OnLButtonUp(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend); 
	VOID OnMouseMove(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend); 
	VOID OnLButtonDown(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend); 
  BOOL OnLButtonDBLCLK(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd); 
	VOID moveControl(INT xoffset,INT yoffset); 
	VOID paintControl(HDC hdc); 
	VOID getControlRect(I2Rect& r); 
	VOID OnAttribChange(INT type,INT mask,BOOL flocal); 
	VOID OnInplaceEditorNeedText(LPWB32FONT pfont,LPSTR* ptext); 
	VOID OnInplaceEditorReturnText(POINT pos,LPSTR text); 
	VOID set_Font(WB32FONT* pfont,INT mask); 
  BOOL OnDragFile(LPSTR filename,POINT p,CHAR* ptr,HWND hwnd); 
  VOID OnChangeData(RECT& rect); 
 
	CI2WBControl(); 
	CI2WBControl(INT cid,VOID* wb,HWND hwnd); 
	~CI2WBControl(); 
 
  //inherit from i2Object 
  EMPTY_I2OBJECT_IMPLEMENT(CI2WBControl,CLASSNAME_CI2WBCONTROL,CI2WBBaseCtrl) 
 
  char* toString(void) 
  { 
    return strdup("iasp2 white board control object"); 
  } 
 
protected: 
	DrawTypes m_type; 
	POINT m_pttrackstart; 
	POINT m_prev; 
	INT     tracktype; 
 
	VOID beginTrack(INT* tracktype); 
	VOID trackPoint(HDC hdc,POINT p); 
	VOID endTrackPoint(HDC hdc,POINT p); 
	VOID trackRect(HDC hdc,const I2Rect& r); 
	VOID endTrackRect(HDC hdc,const I2Rect& r); 
	VOID trackClick(HDC hdc,POINT p,BOOL fclick); 
	VOID endTrackClick(HDC hdc,POINT p); 
 
	VOID paintPen(HDC hdc); 
	VOID paintLine(HDC hdc); 
	VOID paintHRect(HDC hdc); 
	VOID paintRect(HDC hdc); 
	VOID paintHCirc(HDC hdc); 
	VOID paintCirc(HDC hdc); 
	VOID paintHPoly(HDC hdc); 
	VOID paintPoly(HDC hdc); 
	VOID paintText(HDC hdc); 
	VOID paintImage(HDC hdc); 
 
	VOID rectFromPointList(I2Rect& rect); 
	VOID rectFromPoly(I2Rect& rect); 
	VOID moveTo(INT xoffset,INT yoffset); 
	VOID movePointList(INT xoffset,INT yoffset); 
	VOID moveRect(INT xoffset,INT yoffset); 
	VOID movePoly(INT xoffset,INT yoffset); 
	LPSTR SysAllocAnsiString(LPSTR sz); 
 
	CPointList    m_ptlist; 
	CPointList    m_poly; 
	RECT		      m_rect; 
	POINT		      m_pos; 
	CHAR*		      m_text; 
	I2Image       m_img; 
  I2MemoryFileStream *m_imgfile; 
  HDC           m_hdc; 
  HWND          m_hwnd; 
//  FILE         *m_file; 
 
	CI2WBBaseWB*  m_wb; 
}; 
 
#endif