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

📄 mmidialogs.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
}
void dlg_initDisplayData_TextStr( T_DISPLAY_DATA *displayInfo, int lsk, int rsk,char *str1, char *str2, int colId)
{
	if (displayInfo == NULL)
		return;
	dlg_zeroDisplayData(displayInfo);
	displayInfo->LeftSoftKey 	= (USHORT)lsk;
	displayInfo->RightSoftKey 	= (USHORT)rsk;
	displayInfo->TextString 	= str1;
	displayInfo->TextString2 	= str2;
	displayInfo->displayCol 	= colId ;
}

void dlg_initDisplayData_events( T_DISPLAY_DATA *displayInfo, T_VOID_FUNC callback, int timer, T_MFW_EVENT keyEvents)
{
	displayInfo->Callback 		= callback;
	displayInfo->Time			= timer;
	displayInfo->KeyEvents		= keyEvents;
}

void dlg_initDisplayData_type( T_DISPLAY_DATA *displayInfo, U32 displayCol, int dlgType, T_BITMAP* dlgBitmap, int dlgSkFormat )
{
	displayInfo->displayCol	= displayCol;
	displayInfo->dlgType	= dlgType;
	displayInfo->bgdBitmap	= dlgBitmap;
}

/*******************************************************************************

 $Function:    	dialog_info

 $Description:	Dialog function for information dialog
 
 $Returns:		void

 $Arguments:	win, window handle event, value, parameter

*******************************************************************************/
void dialog_info (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
  T_MFW_WIN      * win_data     = ((T_MFW_HDR *)win)->data;
  T_dialog_info  * data         = (T_dialog_info *)win_data->user;
  T_DISPLAY_DATA * display_info = (T_DISPLAY_DATA *)parameter;

  TRACE_FUNCTION ("dialog_info()");

  switch (event)
  {
    case DIALOG_INIT:
      /*
       * Initialize dialog
       */
#if defined (WIN32)
      {
        char buf[40];
        sprintf (buf, "Identifier %d", display_info->Identifier);
        TRACE_EVENT (buf);
      }
#endif
      /*
       * Create timer and keyboard handler
       */
    data->info_tim             = tim_create (win, display_info->Time, (T_MFW_CB)dialog_info_tim_cb);
	data->info_kbd             = kbd_create (win, KEY_ALL, (T_MFW_CB)dialog_info_kbd_cb);
    data->info_kbd_long		   = kbd_create(win,KEY_ALL|KEY_LONG,(MfwCb)dialog_info_kbd_long_cb);

      /*
       * Store any other data
       */
      data->KeyEvents			 = display_info->KeyEvents;
	  data->TextString           = display_info->TextString;
      data->LeftSoftKey          = display_info->LeftSoftKey;
      data->RightSoftKey         = display_info->RightSoftKey;
      data->SoftKeyStrings		= display_info->SoftKeyStrings;	// SH - TRUE if using strings rather than IDs
      data->LSKString			= display_info->LSKString;		// Text for left soft key
      data->RSKString			= display_info->RSKString;		// Text for right soft key
      data->TextId               = display_info->TextId;
      data->Identifier           = display_info->Identifier;
      data->Callback             = display_info->Callback;
      data->TextString2          = display_info->TextString2;
      data->TextId2              = display_info->TextId2;
	  data->WrapStrings			= display_info->WrapStrings;	//GW-SPR#762

	  data->dlgCol				= display_info->displayCol;
	  data->dlgType				= display_info->dlgType;
	  data->dlgBgdBitmap		= display_info->bgdBitmap;
	  data->dlgSkFormat			= 0;
	  data->current_frame		= display_info->current_frame;
	  data->number_of_frames	= display_info->number_of_frames;
	  data->icon_array			= (MfwIcnAttr*)display_info->icon_array;
	  data->animation_timer		= 0;

	  TRACE_EVENT_P1("anim_time = %d", display_info->anim_time);
	  TRACE_EVENT_P1("data->anim_time = %d", data->anim_time);
	  
	  if(display_info->anim_time != 0)
	  {
	  	data->animation_timer = timCreate(win,display_info->anim_time,(MfwCb)mmi_dialogs_animation_new_CB);
		timStart(data->animation_timer);
	  }

      if (display_info->Time NEQ FOREVER)
        tim_start (data->info_tim);
      win_show (win);
      break;
    case DIALOG_DESTROY:
		dialog_info_destroy(win);
	break;
  }
}

/*******************************************************************************

 $Function:    	dialog_info_win_cb

 $Description:	Callback function for information dialog
 
 $Returns:		void

 $Arguments:	window handle event, win
*******************************************************************************/
//GW-SPR#762-Added code to wraps txtString2 if there is room on the display to allow 
//very long numbers to be displayed.
#define MAX_LINE_CHAR MAX_LINE
static int dialog_info_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
    T_dialog_info * data = (T_dialog_info *)win->user;
	char buffer[MAX_LINE_CHAR+1];
	int yPos,bufPos,nLines;

    TRACE_FUNCTION ("dialog_info_win_cb()");


    if (data EQ 0)
	return 1;

    switch (event)
	{
	case E_WIN_VISIBLE:
	    if (win->flags & E_WIN_VISIBLE)
		{
		    /*
		     * Print the information dialog
		     */

		    /*
		     * Clear Screen
		     */
		    dspl_ClearAll();

		    /*
		     * Print softkeys
		     */
			icnShow(data->icon);
		    if (data->SoftKeyStrings)
		    	displayCustSoftKeys(data->LSKString, data->RSKString);	// SH - display text softkeys
		    else
				displaySoftKeys(data->LeftSoftKey, data->RightSoftKey);	// display ID softkeys
		    
		    /*
		     * Print information
		     */

		    /*MC SPR 1257, having to shift everything up 1 line as string wrapping for second
		    string causes softkey overwrite when in Chinese*/
		    if (data->TextId NEQ 0)
			{
			    ALIGNED_PROMPT(LEFT,0,DSPL_TXTATTR_CURRENT_MODE, data->TextId);
			}
		    else if (data->TextString NEQ NULL)
			{
#ifdef EASY_TEXT_ENABLED			
			    if (data->TextString[0] == 0x80) //MC if this is a unicode string
					displayAlignedText(LEFT, 0, DSPL_TXTATTR_UNICODE, &data->TextString[2]);
			    else
#endif
			    	displayAlignedText(LEFT, 0, DSPL_TXTATTR_NORMAL, data->TextString);
			}

		    if (data->TextId2 NEQ 0)
			{
			    ALIGNED_PROMPT(LEFT,Mmi_layout_first_line()/*MC*/,DSPL_TXTATTR_CURRENT_MODE, data->TextId2);
			}
		    else if (data->TextString2 NEQ NULL)
			{	
#ifdef EASY_TEXT_ENABLED	
				if (data->TextString2[0] == 0x80 ) //MC if this is a unicode string
					displayAlignedText(LEFT, Mmi_layout_first_line()/*MC*/, DSPL_TXTATTR_UNICODE, &data->TextString2[2]);
			    else
#endif
			{
				if ((data->WrapStrings & WRAP_STRING_2) && (strlen(data->TextString2) > MAX_LINE_CHAR))
				{	//Display text over a number of lines
					yPos = Mmi_layout_first_line();/*MC*/
					bufPos = 0;
					nLines = Mmi_number_of_lines_without_icons_on_top()-2;//starting on 2nd line
					while ((bufPos <strlen(data->TextString2)) && (nLines >=0))
					{
						memcpy(buffer,&data->TextString2[bufPos],MAX_LINE_CHAR);						
						bufPos = bufPos + MAX_LINE_CHAR;
						buffer[MAX_LINE_CHAR] = 0x00;
				    	displayAlignedText(LEFT, yPos, 0, buffer);
				    	yPos = yPos + Mmi_layout_line_height();
				    	nLines--;
					}
				}
				else
				{
			    	displayAlignedText(LEFT, Mmi_layout_second_line(),DSPL_TXTATTR_NORMAL, data->TextString2);
				}
			}
		}
	  }
	    break;

	default:
	    return 0;
	}
    return 1;
}

static int dialog_info_win_resize_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
    T_dialog_info * data = (T_dialog_info *)win->user;
    T_DISPLAY_DATA * display_info;
	int xPos1,xPos2,yPos1,yPos2;
	int l1,l2;
	char* str1=NULL;
	char* str2= NULL;
	char* lskStr,*rskStr;
	int wx,wy,sx,sy;
	int fullScreen;
	int yOfs;
	MfwRect skArea;

    MfwRect area;

	/*MC, SPR 1319, display modes for lines1 and 2 of dialogue (not necessarily the same*/
	UBYTE  display_mode1 = DSPL_TXTATTR_CURRENT_MODE;
	UBYTE  display_mode2 = DSPL_TXTATTR_CURRENT_MODE;
	UBYTE original_display_type= dspl_get_char_type();

	
	char strx[32];
	int drawWinType;

    TRACE_FUNCTION ("dialog_info_win_cb()");
	
    if (data EQ 0)
	return 1;

    switch (event)
	{
	case E_WIN_VISIBLE:
	    if (win->flags & E_WIN_VISIBLE)
		{
		    /*
		     * Print the information dialog
		     */
		    xPos1 = 0;
		    xPos2 = 0;
		    yPos1 = Mmi_layout_line_height();
		    yPos2 = Mmi_layout_line_height()*2;

		    yOfs = Mmi_layout_line_height()/4; // 2 or 3 depending on scr size 
			if (data->TextId != 0)
			{
			    str1 = MmiRsrcGetText(  data->TextId);
			}
		    else 
			{
/*MC SPR 1319*/
#ifdef NO_ASCIIZ
// EF test for null string in windows simulation
#ifdef WIN32
				if (data->TextString NEQ NULL)
#endif
				if (data->TextString[0] ==0x80)
				{	display_mode1 = DSPL_TXTATTR_UNICODE; 
					str1 = data->TextString;	/* SPR#1983 - SH - Don't cut off unicode tag */
					}
				else
#endif			
				{	display_mode1 = DSPL_TXTATTR_NORMAL; 
			    str1 = data->TextString;
			    	
				}
			}
		    
			if (data->TextId2 != 0)
			{
			    str2 = MmiRsrcGetText(  data->TextId2);
			}
		    else 
			{
/*MC SPR 1319*/
#ifdef NO_ASCIIZ
// EF test for null string in windows simulation
#ifdef WIN32
				if (data->TextString NEQ NULL)
#endif
#ifdef WIN32
// EF test for null string in windows simulation
				if (data->TextString2 NEQ NULL)
#endif
					if (data->TextString2[0] ==0x80)
				{	 
					display_mode2 = DSPL_TXTATTR_UNICODE; 
					str2 = data->TextString2;		/* SPR#1983 - SH - Don't cut off unicode tag */
				}
				else
#endif			
				{	display_mode2 = DSPL_TXTATTR_NORMAL; 
			    str2 = data->TextString2;
			    	
				}
			}

		    fullScreen = 1;
		    if (data->SoftKeyStrings!=0)
		    {
		     	lskStr = data->LSKString;
		     	rskStr = data->RSKString;
		    }
		    else
		    {
		    	if (data->LeftSoftKey != TxtNull)
					lskStr = MmiRsrcGetText(data->LeftSoftKey);
				else
					lskStr = NULL; 
				
		    	if (data->RightSoftKey != TxtNull)
					rskStr = MmiRsrcGetText(data->RightSoftKey);
				else
					rskStr = NULL; 	
		    }

		    if ((str1!= NULL) || (str2!=NULL))
		    {	//Draw a window for status info
		    	if (str2 == NULL)
		     	{
		     		sy = Mmi_layout_line_height()+yOfs*2; // 18 or 12
		     		
		     	}
		     	else
		     	{
		     		sy = Mmi_layout_line_height()*2+yOfs*3; // 33 or 22
		     	}

		     	wx = 5;
		     	xPos1 = wx+5;
		     	xPos2 = wx+5;
		     	
		     	//MC, if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)	 
		     	{	//calculate longest string - use this to calc width of window
			     	sx = 0;
			     	if ((lskStr!=NULL) || (rskStr!=NULL))
			     	{
			     		sy = sy+Mmi_layout_softkeyHeight()+yOfs*2; 
			     		sx = sx + 10;
				     	if (lskStr != NULL) 
				     	{
	    					sx = sx + dspl_GetTextExtent(lskStr, 0);
				     	}
				     	if (rskStr != NULL) 
				     	{
	    					sx = sx + dspl_GetTextExtent(rskStr,0);
				     	}
				     	
			     	}
		     		if (str1 != NULL) 
		     		{	
						/*MC SPR 1319*/
						/*when in chinese need to set display mode to ASCII for ASCII strings*/
		     			if(display_mode1 == DSPL_TXTATTR_NORMAL)
							dspl_set_char_type(DSPL_TYPE_ASCII);
		     			/*mc, end*/
		     			l1 = dspl_GetTextExtent(str1,0);
		     			/*MC SPR 1319, restore char type*/
						dspl_set_char_type(original_display_type);
						TRACE_EVENT_P1("L1 = %d", l1);
		     		}
		     		else 
		     			l1 = 0;
		     		if (str2 != NULL) 
		     		{	/*MC SPR 1319*/
						/*when in chinese need to set display mode to ASCII for ASCII strings*/
						if(display_mode2 == DSPL_TXTATTR_NORMAL)
							dspl_set_char_type(DSPL_TYPE_ASCII);
						/*mc, end*/
		     			l2 = dspl_GetTextExtent(str2,0);
		     			/*MC SPR 1319, restore char type*/
						dspl_set_char_type(original_display_type);
						TRACE_EVENT_P1("L2 = %d", l2);

		     		}
		     		else
		     			l2 =0;
		     		
		     		if (l1>sx) 
		     			sx = l1;
		     		if (l2>sx)
		     			sx = l2;
		     		
		     		if (sx > SCREEN_SIZE_X-8)
		     			sx = SCREEN_SIZE_X;
		     		else
		     		{
		     			if (sx > SCREEN_SIZE_X/2)
			     			sx = sx + 8;
		     			else
			     			sx = sx + 16;
		     		}
		     		if (sy> sx) 
		     			sx = sy;
		     		wx = (SCREEN_SIZE_X-sx)/2;
		     		//centre text
			     	xPos1 = wx+(sx-l1)/2;
			     	xPos2 = wx+(sx-l2)/2;

		     	}
		     	

		     	if (sy > SCREEN_SIZE_Y)
		     		wy = 0;
		     	else if (SCREEN_SIZE_Y > 2*sy) //sy = 
		     		wy = (SCREEN_SIZE_Y*2/3-sy)/2; //display in middle of top 2/3 of screen
		     	else 
		     		wy = (SCREEN_SIZE_Y-sy)/2; //display in middle of screen
				if (wy < 10)

⌨️ 快捷键说明

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