📄 guicallback.c
字号:
#ifdef __PLXBROW_DEBUG_
if(NULL != poldStyle)
PlxTrace("[%d] PWBCBSetTextStyle-----> SetNewColor oldcolor = %x, newcolor = %x, \r\n", __LINE__, *((unsigned long *)poldStyle), *((unsigned long *)pnewStyle));
else
PlxTrace("[%d] PWBCBSetTextStyle-----> RestoreColor oldcolor = %x\r\n", __LINE__, *((unsigned long *)pnewStyle));
#endif //__PLXBROW_DEBUG_
/* if(NULL != poldStyle) //save the color last setting
{
TextStyleInfo.clSavedSetColor = TextStyleInfo.clColor;
}
*/ break;
}
return 0;
#else // __PLXBROW_FONT_SUPPORT_
switch(option) {
case WBTS_FONT:
if (0 != poldStyle) {
*((WB_FONT *)poldStyle) = curFont;
}
curFont = *((WB_FONT *)pnewStyle);
break;
case WBTS_COLOR:
if (0 != poldStyle) {
*((unsigned long *)poldStyle) = curColor;
}
curColor = *((unsigned long *)pnewStyle);
break;
}
return 0;
#endif //__PLXBROW_FONT_SUPPORT_
}
/****************************************************************************
* Function PWBCBGetTextInfo
* Purpose get the given string's info
* Params
* Return
* Remarks
\****************************************************************************/
int PWBCBGetTextInfo(void* pUIData, WB_FONT* pFont, char* pStr, int len, int* w, int* h){
char * pTmp;
#ifdef __PLXBROW_FONT_SUPPORT_
UI_font_type pSaveFont = UI_font;
UI_font_type pSetFont;
stFontAttribute stFont;
if(NULL == pFont)
{
pixtel_UI_set_font(&(TextStyleInfo.stFont));
}
else
{
if(GUICB_LARGE_FONT_SIZE_UP_LIMIT <= pFont->size)
pSetFont = &wgui_dialer_box_f1;
else if(GUICB_MEDIUM_FONT_SIZE_UP_LIMIT <= pFont->size)
pSetFont = &MMI_large_font;
else if (GUICB_MEDIUM_FONT_SIZE_LOW_LIMIT <= pFont->size)
pSetFont = & MMI_medium_font;
else
pSetFont = &MMI_small_font;
stFont = *pSetFont;
if(TRUE ==( BOOL)pFont->italic)
stFont.italic = (U8)TRUE;
else
stFont.italic = (U8)FALSE;
if(WBFW_BOLD <= pFont->weight)
stFont.bold = (U8)TRUE;
else
stFont.bold = (U8)FALSE;
pixtel_UI_set_font(&stFont);
}
#endif
pTmp = PlxAppMalloc(len * 2 + 2);
if (0 == pTmp) {
return -1;
}
PlxUTF82UCS2(pTmp, pStr, len, len * 2 + 2);
/* if (0 != w) {
*w = pixtel_UI_get_string_width((UI_string_type)pTmp);
}
if (0 != h) {
*h = pixtel_UI_get_string_height((UI_string_type)pTmp);
}
*/
if(NULL != w && NULL != h)
{
pixtel_UI_measure_string((UI_string_type)pTmp, (S32*)w, (S32*)h);
}
PlxAppFree(pTmp);
#ifdef __PLXBROW_FONT_SUPPORT_
// if(NULL != pFont)
pixtel_UI_set_font(pSaveFont);
#endif //__PLXBROW_FONT_SUPPORT_
return 0;
}
/****************************************************************************
* Function PWBCBDrawText
* Purpose draw text function
* Params
* Return
* Remarks
\****************************************************************************/
int PWBCBDrawText(void* pUIData, WB_RECT *lprc, char* pText, int len, unsigned long fgcolor, unsigned long bkcolor){
char *txt;
WB_RECT rcTxt;
unsigned long usingColor;
color clSavedColor = UI_current_text_color;
if (!plxBrowInfo.bInBrowsing) {
return 0;
}
if(NULL == pText || 0 >= len)
return -1;
if(NULL == (txt = PlxAppMalloc((len + 1) * 2)))
return -1;
#ifdef __PLXBROW_DEBUG_
PlxTrace("\n\n---------- PWBCBDrawText[pText]----------");
if(COLOR_INVALID != fgcolor)
PlxTrace("[%d] PWBCBDrawText-----> bkcolor= %x, fgcolor = %x\r\n",__LINE__, bkcolor, fgcolor);
else
PlxTrace("[%d] PWBCBDrawText-----> bkcolor= %x, fgcolor = %x, GETCOLOR =%x\r\n",__LINE__, bkcolor, fgcolor,
PLXRGB(TextStyleInfo.clColor.r, TextStyleInfo.clColor.g, TextStyleInfo.clColor.b));
WAP_DataOut((const unsigned char *)pText, (unsigned short)len, (const unsigned char *) " PWBCBDrawText");
PlxTrace("--------------------------------------\n\n\n");
#endif
PlxUTF82UCS2(txt, pText, len, len * 2 + 2);
rcTxt.left = lprc->left;
rcTxt.top = lprc->top;
rcTxt.right = lprc->right;
rcTxt.bottom = lprc->bottom;
if (COLOR_INVALID != bkcolor) {
PWBCBDrawRect(pUIData, &rcTxt, bkcolor, 1);
}
rcTxt.left += plxBrowInfo.rcInScreen.left;
rcTxt.top += plxBrowInfo.rcInScreen.top;
rcTxt.right += plxBrowInfo.rcInScreen.left;
rcTxt.bottom += plxBrowInfo.rcInScreen.top;
pixtel_UI_move_text_cursor(rcTxt.left, rcTxt.top);
if(COLOR_INVALID == fgcolor)
{
#ifdef __PLXBROW_FONT_SUPPORT_
pixtel_UI_set_text_color(TextStyleInfo.clColor);
#else
usingColor = curColor;
pixtel_UI_set_text_color(pixtel_UI_color(GETRVALUE(usingColor),
GETGVALUE(usingColor), GETBVALUE(usingColor)));
#endif
}
else
{
usingColor = fgcolor;
pixtel_UI_set_text_color(pixtel_UI_color(GETRVALUE(usingColor),
GETGVALUE(usingColor), GETBVALUE(usingColor)));
}
pixtel_UI_set_line_height(lprc->bottom - lprc->top + 1);
pixtel_UI_push_text_clip();
pixtel_UI_set_text_clip(plxBrowInfo.rcPaint.left, plxBrowInfo.rcPaint.top,
plxBrowInfo.rcPaint.right, plxBrowInfo.rcPaint.bottom);
pixtel_UI_print_text((UI_string_type)txt);
pixtel_UI_set_text_color(clSavedColor);
pixtel_UI_pop_text_clip();
// UnitPaintRect(rcTxt.left, rcTxt.top, rcTxt.right, rcTxt.bottom, &plxBrowInfo.rcPaint);
PlxAppFree(txt);
return 0;
}
/****************************************************************************
* Function PWBCBGetImageInfo
* Purpose get image info
* Params
* Return
* Remarks
\****************************************************************************/
#ifdef __PLXBROW_DEBUG_
static char *strImageType[6] = { "WBMP", "BMP", "JPG", "GIF", "PNG", "UNKNOWN"};
#endif
int PWBCBGetImageInfo(int imagetype, char* pData, int len, int* w, int* h){
/*
#ifndef MMI_ON_WIN32
S32 fitX, fitY;
S32 fitW, fitH;
#endif
*/
if (0 == len) {
return -1;
}
switch(imagetype) {
case WBIMG_BMP:
gdi_image_bmp_get_dimension((U8*)pData, w, h);
break;
case WBIMG_WBMP:
gdi_image_wbmp_get_dimension((U8 *)pData, w, h);
return 0;
break;
case WBIMG_JPG:
#ifdef MMI_ON_WIN32
*w = *h = 0;
#else
gdi_image_jpeg_get_dimension((U8*)pData, len, w, h);
while((*w) * (*h) > (int)((GDI_LCD_WIDTH)*(GDI_LCD_HEIGHT)))
{
*w = (int)((float)(*w) * 0.9);
*h = (int)((float)(*h) * 0.9);
}
/* if(*w > plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left ||
*h > plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top)
{
// fitX = 0;
// fitY = 0;
// fitW = (S32) (plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left) -2;
// fitH = (S32)(plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top) - 2;
// PlxMakeImageSizeForMTK((long*)&fitX, (long*)&fitY, (long)w,(long)h,
// (long*)&fitW, (long*)&fitH);
gdi_image_util_fit_bbox((S32)( plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left) +4,
(S32)((plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top) - 2)*2,
*w, *h, &fitX, &fitY,
&fitW, &fitH);
*w = fitW;
*h = fitH;
#ifdef __PLXBROW_DEBUG_
PlxTrace("%s, %d : GetImageInfo JPG : fitW=%d fitH=%d", __FILE__, __LINE__,fitW, fitH);
#endif
}
*/
#endif
break;
case WBIMG_GIF:
gdi_image_gif_get_dimension((U8*)pData, w, h);
break;
case WBIMG_PNG:
#if defined(GDI_USING_HW_PNG) || defined(GDI_USING_W32_PNG)
gdi_image_png_get_dimension((U8*)pData, len, w, h);
#else
*w = 0;
*h = 0;
#endif
break;
default:
return -2;
}
#ifdef __PLXBROW_DEBUG_
PlxTrace("[%d] : PWBCBGetImageInfo-----> imageType : %s width= %d heigth=%d", __LINE__,strImageType[imagetype < 6 ? imagetype : 5], *w , * h);
#endif
return 0;
}
/****************************************************************************
* Function PWBCBDrawImage
* Purpose draw image function
* Params
* Return
* Remarks
\****************************************************************************/
typedef struct tag_WB_IMG_OBJ{
gdi_handle handler; //image handler
char * pBuffer; //buffer to save image data and it's header
unsigned int szHeader; //the header size
}WBIMGOBJ, *PWBIMGOBJ;
extern GDI_RESULT gdi_image_jpeg_get_dimension(U8 *jpeg_src, U32 size, S32 *width, S32 *height);
#ifndef gdi_image_jpeg_draw_resized
extern GDI_RESULT gdi_image_jpeg_draw_resized(S32 ox, S32 oy, S32 resized_width, S32 resized_height, U8 *jpeg_src, U32 size);
#endif //
int PWBCBDrawImage(void* pUIData, int x, int y, int width, int height,
int src_x, int src_y, int src_width, int src_height,
WB_IMGTYPE imgtype, char* pData, long len, void** hImage, void* Param1){
int drawW, drawH; //the width and the height of the src at the drawing time
int drawX, drawY; //the true x and y of destination
WBIMGOBJ imgObj, *pImgObj;
int i;
int picW, picH;
/*#ifndef MMI_ON_WIN32
S32 fitX, fitY;
S32 fitW, fitH;
#endif */
#ifdef __PLXBROW_DEBUG_
PlxTrace("[%d] PWBCBDrawImage -----> imgType : %s ",__LINE__, strImageType[imgtype < 6 ? imgtype : 5]);
PlxTrace("[%d] PWBCBDrawImage -----> x=%d y=%d w=%d h=%d", __LINE__,x,y, width,height);
PlxTrace("[%d] PWBCBDrawImage -----> src_x=%d src_y=%d src_w=%d src_h=%d", __LINE__,src_x,src_y, src_width,src_height);
#endif
if (!plxBrowInfo.bInBrowsing) {
return 0;
}
if(x > plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left || x + width < 0 ||
y > plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top || y + height < 0 ){
if (*hImage != 0) {
PWBCBEndImageDraw(*hImage, WBIMG_GIF, 0);
*hImage = 0;
}
return 0;
}
drawX = x + plxBrowInfo.rcInScreen.left;
drawY = y + plxBrowInfo.rcInScreen.top;
if (0 == pData) {
return -1;
}
imgObj.handler = 0;
imgObj.pBuffer = 0;
imgObj.szHeader = 6;
pImgObj = &imgObj;
switch(imgtype) {
case WBIMG_BMP:
if (-1 == src_width && -1 == src_height && 0 == src_x && 0 == src_y)
{
gdi_image_bmp_get_dimension((U8*)pData, (S32*)&picW, (S32*)&picH); //get the true width and height
}
else
{
picW = src_width;
picH = src_height;
}
drawW = width;
drawH = height;
if(0 != picW && 0 != picH)
PlxMakeImageSizeForMTK((long*)&drawX, (long*)&drawY,(long)picW, (long)picH,(long*)&drawW, (long*)&drawH);
gdi_image_bmp_draw_resized((S32)drawX, (S32)drawY, (S32)drawW, (S32)drawH, (U8*)pData, len);
break;
case WBIMG_WBMP:
if (-1 == src_width && -1 == src_height && 0 == src_x && 0 == src_y)
{
gdi_image_wbmp_get_dimension((U8*)pData, (S32*)&picW, (S32*)&picH); //get the true width and height
}
else
{
picW = src_width;
picH = src_height;
}
drawW = width;
drawH = height;
if(0 != picW && 0 != picH)
PlxMakeImageSizeForMTK((long*)&drawX, (long*)&drawY, (long)picW, (long)picH, (long*)&drawW, (long*)&drawH);
gdi_image_wbmp_draw_resized((S32)drawX, (S32)drawY, (S32)drawW, (S32)drawH, (U8*)pData, len);
break;
case WBIMG_JPG:
#ifndef MMI_ON_WIN32
if (-1 == src_width && -1 == src_height && 0 == src_x && 0 == src_y)
{
gdi_image_jpeg_get_dimension((U8*)pData,len, (S32*)&picW, (S32*)&picH); //get the true width and height
}
else
{
picW = src_width;
picH = src_height;
}
drawW = width;
drawH = height;
#ifdef __PLXBROW_DEBUG_
PlxTrace("[L%d] DrawJpeg: picW=%d picH=%d drawW=%d drawH=%d",__LINE__,picW, picH, drawW, drawH);
#endif
while((picW) * (picH) > (int)((GDI_LCD_WIDTH)*(GDI_LCD_HEIGHT)))
{
picW = (int)((float)picW * 0.9);
picH = (int)((float)picH * 0.9);
}
/* if(picW> (S32)(plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left) ||
picH > (S32)(plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top))
{
// fitX = 0;
// fitY = 0;
// fitW = (S32) (plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left) -2;
// fitH = (S32)(plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top) - 2;
// PlxMakeImageSizeForMTK((long*)&fitX, (long*)&fitY, (long)picW,(long)picH,
// (long*)&fitW, (long*)&fitH);
gdi_image_util_fit_bbox((S32) (plxBrowInfo.rcInScreen.right - plxBrowInfo.rcInScreen.left) +4,
(S32)((plxBrowInfo.rcInScreen.bottom - plxBrowInfo.rcInScreen.top) - 2)*2,
picW,picH , &fitX, &fitY,
&fitW, &fitH);
picW = fitW;
picH = fitH;
}
*/
if(0 != picW && 0 != picH)
PlxMakeImageSizeForMTK((long*)&drawX, (long*)&drawY,(long) picW, (long)picH,(long*) &drawW, (long*)&drawH);
gdi_image_jpeg_draw_resized((S32)drawX, (S32)drawY, (S32)drawW, (S32)drawH, (U8*)pData, len);
#ifdef __PLXBROW_DEBUG_
PlxTrace("[L%d] DrawJpeg drawX=%d drawY=%d drawW=%d drawH=%d", __LINE__,drawX, drawY, drawW, drawH);
#endif
#else
drawW = drawH = 0;
#endif
break;
case WBIMG_GIF:
if(0 <= (int)Param1){
if (0 != *hImage){
pImgObj = *hImage;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -