⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmlviewer.cpp

📁 联通手机的宝典画面.用brew 平台编辑而成.
💻 CPP
字号:

/*

  htmlviewer.cpp

  */

#include "AEEHtmlViewer.h"
#include "htmlviewer.h"

const int CHtmlViewer::TXT_SEEKSIZE = 32;

//
//
//

char *CHtmlViewer::SeekTXT(char *buf,int *move)
{
	char *p = (char*)buf;
	while((char*)buf - p <= TXT_SEEKSIZE){
		if(0 == MEMCMP(p,"<!--TXT-->",STRLEN("<!--TXT-->"))){
			*move = p - (char*)buf;
			return p;
		}else{
			p++;
		}
	}
	return NULL;
}

boolean	CHtmlViewer::Create(AEEApplet *applet)
{
	m_applet	= applet;

	if(IsEnable()){
		SetEnable(FALSE);
		return FALSE;
	}

	DisableClass();

	if(AEE_SUCCESS != ISHELL_CreateInstance(m_applet->m_pIShell, AEECLSID_HTML, (void **)&m_htmlv)){
		SetEnable(FALSE);
		return FALSE;
	}

	SetRect(NULL);
	SetEnable(TRUE);

	return TRUE;
}

boolean CHtmlViewer::Release(void)
{
	
	if(!IsEnable()){
		return FALSE;
	}

	SetEnable(FALSE);

	ReleaseNotifyFn();
	UnLoadResString();

	if(AEE_SUCCESS != IHTMLVIEWER_Release(m_htmlv)){
		return FALSE;
	}

	return TRUE;
	
}

boolean CHtmlViewer::LoadResStringAndParseBuffer(const char *resfile,short resid)
{
	char errmsg[32];
	char *txt;
	int move;
	uint32 size;

	SPRINTF(errmsg,"Cannot load \"%d\"<br />",resid);		

	if(m_resstring != NULL){
		UnLoadResString();
	}

	m_resstring = ISHELL_LoadResDataEx(m_applet->m_pIShell,resfile,resid,RESTYPE_IMAGE,NULL,&size);
	if(m_resstring == NULL){
		ParseBuffer(errmsg);
		return FALSE;
	}

	txt = SeekTXT((char*)m_resstring,&move);
	if(txt == NULL){
		ISHELL_FreeResData(m_applet->m_pIShell,m_resstring);
		m_resstring = NULL;
		ParseBuffer(errmsg);
		return FALSE;
	}

	m_resstringbuf = (char*)MALLOC(size - move + 1);
	if(m_resstringbuf == NULL){
		ISHELL_FreeResData(m_applet->m_pIShell,m_resstring);
		m_resstring = NULL;
		ParseBuffer(errmsg);
		return FALSE;
	}

	MEMCPY(m_resstringbuf,txt,size - move);
	m_resstringbuf[size - move] = '\0';

	ParseBuffer(m_resstringbuf);

	return TRUE;
}

boolean CHtmlViewer::UnLoadResString(void)
{
	if(m_resstring != NULL){
		ISHELL_FreeResData(m_applet->m_pIShell,m_resstring);
		m_resstring = NULL;

		FREE(m_resstringbuf);
		m_resstringbuf = NULL;

		return TRUE;
	}else{
		return FALSE;
	}
}

void CHtmlViewer::SetRect(const AEERect *rc)
{
	IHTMLVIEWER_SetRect(m_htmlv,rc);
}

void CHtmlViewer::ParseBuffer(const char *str)
{
	IHTMLVIEWER_ParseBuffer(m_htmlv,str);
}

void CHtmlViewer::Redraw(void)
{
	IHTMLVIEWER_Redraw(m_htmlv);
}

void CHtmlViewer::HandleEvent(AEEEvent evt,uint16 wp,uint32 dwp)
{	
	IHTMLVIEWER_HandleEvent(m_htmlv,evt,wp,dwp);
}

void CHtmlViewer::SetNotifyFn(PFNHVIEWNOTIFY notify,void *param)
{
	IHTMLVIEWER_SetNotifyFn(m_htmlv,notify,param);
}

void CHtmlViewer::ReleaseNotifyFn(void)
{
	IHTMLVIEWER_SetNotifyFn(m_htmlv,NULL,NULL);
}

void CHtmlViewer::SetProperties(uint32 flag)
{
	IHTMLVIEWER_SetProperties(m_htmlv,flag);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -