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

📄 phoneshow.c

📁 国家ASIC工程中心使用的嵌入式操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* asix window 头文件*/
#include "asixwin.h"
#include "asix_lb.h"

#include "asixapp.h"
//#include "asixwin\asix_mn.h"
//#include "asixwin\select.h"
//#include "asixwin\asix_sb.h"
#include "asix_ed.h"
#include "disp.h"

#include "phone.h"
/////////////////////////////////////////////////////////////////
U8	list_to_display[MAX_LIST_NUM] = {0};
U8  small_list[MAX_SHOW_BUTTON_NUM];
PHONE_RAM_FLASH	phone;

static void ShowPhone( STATUS (*ReadLastPhone)(void), STATUS (*GetNum)(U8 ,char* ), U32 button[], U8 firstnum ); 
static void ShowMsgButton( STATUS (*ReadLastMsg)(void), U32 button[], U8 firstnum ); 
static void  ShowShortMsg( U32	pGC, STATUS (*GetNewsContent)(U8 ,char *), U8 no );
static STATUS  CreatePhone(char *phone_num);
static STATUS  CreateMsg(void);

/////////////////////////////////////////////////////////////////
void   PhoneMsg_App( void )
{
	MSG 	msg;
	U8      i, flag = 0, del_flag = 0;
 	U32		frame, recentphone, recentshortmsg, scroll, button[MAX_SHOW_BUTTON_NUM], bt1, bt2, bt3;
 	U32		pGC;
 	U32		quit = 0;
    char    *phone_num, *news_content; 
	short   count;
	U8		pos = 0;
    SHORT   scrl = 0;
    
	struct LBOX_ITEM	recntphone[] =
	{
		ICON_ENABLE,	UNDERLINE,	"电话",
		ICON_ENABLE,	UNDERLINE,	"已拨",
		ICON_ENABLE,	UNDERLINE,	"已接",
		ICON_ENABLE,	UNDERLINE,	"未接",
		ICON_END,		UNDERLINE,	NULL
	};

	struct LBOX_ITEM	recnteshortmsg[] =
	{
		ICON_ENABLE,	UNDERLINE,	"短信",
		ICON_ENABLE,	UNDERLINE,	"已发",
		ICON_ENABLE,	UNDERLINE,	"已接",
		ICON_ENABLE,	UNDERLINE,	"未接",
		ICON_END,		UNDERLINE,	NULL
	};

 	pGC = GetGC();
 	ClearScreen( pGC, GPC_CADETBLUE );
	
    frame = CreateWindow(WNDCLASS_WIN, "电话和短信", WS_OVERLAPPEDWINDOW|WS_CLOSEBOX, 0,0, PHY_LCD_W, PHY_LCD_H, 0,0,NULL);

	
    recentphone = CreateWindow(WNDCLASS_LIST, "近期电话", WS_CHILD|LBS_POPUP, 0,17,59,16,frame,0,recntphone);
    recentshortmsg = CreateWindow(WNDCLASS_LIST, "近期短信", WS_CHILD|LBS_POPUP, 60,17,60,16,frame,0,recnteshortmsg);
    
    scroll = CreateWindow(WNDCLASS_SCROLL, "Scroll", WS_CHILD|SBS_VERT, 100,35,20,110,frame,MAKELONG(1, 10), NULL);

	for( count = 0; count < MAX_SHOW_BUTTON_NUM; count++ )
		button[count] = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_ICON, 3,(U16)( 35 + count * 18 ), 94, 12, frame,0,NULL);

	bt1 = CreateWindow(WNDCLASS_BUTTON, "拨电话", WS_CHILD|BS_REGULAR, 0,143,40,16,frame,0, NULL); 
	bt2 = CreateWindow(WNDCLASS_BUTTON, "发短信", WS_CHILD|BS_REGULAR, 39,143,40,16,frame,0, NULL); 
	bt3 = CreateWindow(WNDCLASS_BUTTON, "删除", WS_CHILD|BS_REGULAR, 79,143,40,16,frame,0, NULL); 
    
    
    phone_num = (char *)Lmalloc(MAX_PHONE_NUM_LEN);
    if( phone_num == NULL)
        return;
    
    news_content = (char *)Lmalloc(MAX_NEWS_LEN);    
    if( phone_num == NULL)
        return;

    DataInitialPhone();      
	
	//SaveNewReceivedPhone("1234567", 0); // longn_qi 2001/12/26 added
										// only for test

	while(!quit) 
	{
		ASIXGetMessage(&msg,NULL,0,0);
		
		switch ( msg.message )
		{
			case WM_COMMAND:
				for( i = 0; i < MAX_SHOW_BUTTON_NUM; i++ )
				{
				    if( msg.lparam == button[i] )
				    {
	             
			            if( del_flag == 1 && list_to_display[i] == 0 )//MAX_LIST_NUM )
		                {
		                    MessageBox(0,"已删空!","提示",MB_ICONEXCLAMATION|MB_OK);
			                del_flag = 0;
			            }

			            if( flag == 1 )
			            {
                            if( del_flag == 1 )
			                {
			                    DelDialPhone(small_list[i]);
			                    ReadLastDialPhone();
			                    small_list[i] = list_to_display[i+scrl];
			                }
    		                else
    		                {
    			                //切入指定电话号码的打电话窗口
			                    GetDialPhoneNum( small_list[i], phone_num );
  							    CreatePhone(phone_num);
			                }
			            }
			            else if( flag == 2 )
			            {
			                if( del_flag == 1 )
			                {
    		                    DelReceivedPhone(small_list[i]);
			                    ReadLastReceivedPhone();
			                    small_list[i] = list_to_display[i+scrl];
			                }
			                else
			                {
				                //切入指定电话号码的打电话窗口
			                    GetReceivedPhoneNum( small_list[i], phone_num );
			                    CreatePhone(phone_num);
			                }    
			            }
				        else if( flag == 3 )
			            {
			                if( del_flag == 1 )
			                {
			                    DelSendNews(small_list[i]);
			                    ReadLastSendNews();
			                    small_list[i] = list_to_display[i+scrl];
			                }
			                //显示发出的短消息内容
                             else
                                ShowShortMsg(  pGC, GetSendNewsContent, i);		
			            }
			            else if( flag == 4 )
			            {
			                if( del_flag == 1 )
			                {
			                    DelReceivedNews(small_list[i]);
			                    ReadLastReceivedNews();
			                    small_list[i] = list_to_display[i+scrl];
			                }
			                //显示接受的短消息内容
                            else
                                ShowShortMsg(  pGC, GetReceivedNewsContent, i);
				        }
				     }
				    //break;
				}
				if( msg.lparam == bt1 )			
				{
				    //切入打电话窗口
				    //CreatePhone(NULL);
				    CreatePhone("37932638508");
				} 
				else if( msg.lparam == bt2 )  
				{
				    //切入发短信的窗口
				    CreateMsg();
				}
				else if( msg.lparam == bt3 )
                {
					if( MessageBox( 0, "请点击要删除条目", "提示", MB_OKCANCEL ) == IDOK )
				    del_flag = 1;
				}
    			break;    			
			case WM_LISTBOX:
				if ( msg.lparam == recentphone )
				{
				    switch( msg.wparam )
				    {   case 1 :
				            flag = 1;
				            scrl = 0;
                            SetScrollPos( scroll, 1, 0, 0 );    		                 
                            ShowPhone( ReadLastDialPhone, GetDialPhoneNum, button, 0 ) ;
				            break;
				        case 2 :
				            flag = 2;
				            scrl = 0;
                            SetScrollPos( scroll, 1, 0, 0 );    		                 
                            ShowPhone( ReadLastReceivedPhone, GetReceivedPhoneNum, button, 0 ) ;
				            break;
/*				        case 3 :
				            flag = 5;
				            scrl = 0;
                            SetScrollPos( scroll, 1, 0, 0 );    		                 
				            //pPhone = (char *)&Phone.last_No_receive_phone[0];
				            if( pPhone == NULL )
				        	{
				        	    MessageBox(0,"没有未接听的电话!!","提示",MB_ICONEXCLAMATION|MB_OK);
                                for( i = 0; i < MAX_SHOW_BUTTON_NUM; i++)
				                    SetWindowText(button[i], "空", 0);
				            }                                
                            else
                            {
				                for( i = 0; i < MAX_SHOW_BUTTON_NUM i++)
				                    SetWindowText(button[i], pPhone[i], 0);
				            }
				            break;*/
                    }				            
			    }
				else if (msg.lparam == recentshortmsg) 
				{
				    switch( msg.wparam )
				    {
				        case 1 :
				            flag = 3;
				            scrl = 0;
                            SetScrollPos( scroll, 1, 0, 0 );    		                 
                            ShowMsgButton( ReadLastSendNews, button, 0 );//"发出的短信"
				            break;
				        case 2 :
				            flag = 4;
                            ShowMsgButton( ReadLastSendNews, button, 0 );//"接收的短信"
				            break;
/*				        case 3 :
				            flag = 6;
				            scrl = 0;
                            SetScrollPos( scroll, 1, 0, 0 );    		                 
				            if( pPhone == NULL )
				        	{
				        	    MessageBox(0,"没有未接收的短信!!","提示",MB_ICONEXCLAMATION|MB_OK);
                                for( i = 0; i < MAX_SHOW_BUTTON_NUM; i++)
				                    SetWindowText(button[i], "空", 0);
				             }
                             else
                             {
				                 for( i = 0; i < MAX_SHOW_BUTTON_NUM i++)
				                     SetWindowText(button[i], pPhone[i], 0);
				             }
				             break;*/
			        }
                }
			    
				break;

			case WM_VSCROLL:
                switch(msg.wparam)
                {
					case   SB_LINEDOWN :
						scrl++;
		                if( scrl > 4 ) 
		                    scrl = 4;
				        break;
					case    SB_LINEUP :
     					scrl--;
		                if( scrl < 0 ) 
		                    scrl = 0;
						break;
				}
   				switch(scrl)
				{
				    case 0:
				        pos = 1;
				        break;
				    case 1:
					    pos = 3;
					    break;
				    case 2:
					    pos = 5;
					    break;
				    case 3:
					    pos = 8;
					    break;
				    case 4:
					    pos = 10;
				        break;
				}						    
                SetScrollPos( scroll, pos, 0, 0 );    		                 
    		                 

⌨️ 快捷键说明

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