www.pudn.com > cguitest7.15.rar > Guilib.h


//////////////////////////////////////Guilib.h/////////////////////////////////////////////////// 
#include"define.h" 
 
//data type define 
 
//CData define 
/*typedef struct data{ 
	int wintype; 
	void* pobj; 
//	CNode* phomeNode; 
}CData;*/ 
 
// node struct 
typedef struct node{ 
	void* pdata; 
	struct node* next; 
	 
}CNode; 
 
//vector struct 
typedef struct vector{ 
    int size; 
	CNode* head; 
	CNode* tail; 
    CNode* (*push_back)(void* pdata, struct vector* self); 
    void (*eraseByIndex)(int nindex, struct vector* self); 
	void (*eraseByKey)(const void* pdata, struct vector* self); 
	void* (*getByIndex)(int nindex, struct vector* self); 
	int (*getIndex)(const void* pdata, struct vector* self); 
	void (*clear)(struct vector* self); 
}CVector; 
 
 
 
//CRec define 
typedef struct rec{ 
	int x; 
	int y; 
	int w; 
	int l;	 
}CRect1; 
 
//CMssg define 
typedef struct mssg{ 
	void* pdata; 
	int type; 
	int lparam; 
	int wparam; 
}CMssg; 
typedef void(*EVENT_PROC)(CMssg*); // event function pointer 
 
//CWin define 
typedef struct win{ 
	CRect1* prec; 
	char* caption; 
	EVENT_PROC winproc[MSSG_NUM]; 
	CVector* pchild_vec; 
	void* pExtra; 
//	void (*addComponent)( void* pobj, int wintype, struct win* pwin); 
//	void (*drawWin)(struct win* self); 
 
}CWin; 
 
//CButtn define 
typedef struct buttn{ 
	CRect1* prec; 
	char* caption; 
	CWin* parentWin; 
	EVENT_PROC winproc[MSSG_NUM]; 
	void* pExtra; 
//	void (*drawButtn)(struct buttn* self); 
}CButtn; 
 
//CText define 
typedef struct ctext{ 
	CRect1* prec; 
	char* caption; 
	CWin* parentWin; 
	EVENT_PROC winproc[MSSG_NUM]; 
	int font_x; 
	int font_y; 
	int curPos; 
	int endPos; 
	int dspLnBgn; 
    int dspChBgn; 
	int dspChEnd; 
	char text[TEXT_BUFF_SIZE]; 
	CVector* pformatVec; 
	int format_x[TEXT_BUFF_SIZE]; 
	int format_y[TEXT_BUFF_SIZE]; 
	void* pExtra; 
}CText; 
 
//////////////////////////////////////////////////////////////function////////////////////////////////////////////////////// 
void collectPointer(void* pointer, int ptrType); 
void iniGui(CWin* pstartWindow); 
void freeAll(); 
void freeOne(void* pointer); 
 
CVector* newCVector(); 
CNode* newCNode(); 
CNode* push_back(void* pdata, CVector* self); 
void push_back_hook(CNode* pnewNode, void* pdata); 
void eraseByIndex(int nindex, CVector* self); 
void eraseByKey(const void* pdata, CVector* self); 
void* getByIndex(int nindex, CVector* self); 
int getIndex(const void* pdata, CVector* self); 
void clear(CVector* self); 
 
//CData* newCData(void* pobj, int wintype ); 
 
CRect1* newCRect(int x, int y, int w, int l); 
 
CMssg* newCMssg(void* pdata, int type, int lparam, int wparam); 
	 
CWin* newCWin(CRect1* prec, char* caption); 
void OnChangeFocus(CMssg* pmssg); 
void OnClose(CMssg* pmssg); 
void OnShow(CMssg* pmssg); 
void addComponent(struct win* pwin, void* pobj);//, int wintype); 
void drawWin(CWin* self); 
 
void changeFocus(); 
void close(CWin* pwin); 
void paint(void* pobj);//, int wintype); 
void show(CWin* pwin); 
 
 
CButtn* newCButtn(CWin* parentWin, CRect* prec, char* caption); 
void drawButtn(CButtn* self); 
 
CText* newCText(CWin* parentWin, CRect* prec, char* caption, int font_x, int font_y); 
void drawText(CText* self); 
void append(char c, CText* self); 
void delet(CText* self); 
void format(CText* self); 
void textOut(CText* self); 
void OnKeyDown(CMssg* pmssg); 
void OnDbKeyDown(CMssg* pmssg); 
 
 
void tagFocus(); 
void eraseFocus(); 
void setFocus(void* p); 
 
void sendMessage(CMssg* pmssg); 
CMssg* waitMessage(); 
int dispatchMessage(CMssg* pmssg); 
 
int getPtrType(void* ptr); 
void main(); 
void OnButtnClick(CMssg* pmssg);//for test 
//void sendKeyMssg(UINT nChar);//for test