示例#1
0
char Proc_Paint(char *NC)
{
  unsigned int pos[2]                                ;             
  Color     = Black                                  ;
  Color_BK  = 0xEF9F                                 ;
  Clear_LCD(Color_BK)                                ;
  DrawRectFill(0,0,240,25,Blue)                      ;
  DrawRectFill(0,295,240,25,Blue)                    ;
  ShowIcon24(217,0,24,23,ICON_CLOSE)                 ;
  Color    = 0xFFFF                                  ;
  Color_BK = Blue                                    ;
  PutStringCN16(4,4,"画笔")                          ;
  PutStringCN16(4,300,"清空")                        ;
  PutStringCN16(200,300,"退出")                      ;
  Color    = Black                                   ;
  Color_BK = WINDOW_BK_COLOR                         ;
  for(;;)
  {
    if(Read_TP_Twice(&pos[0],&pos[1]))
    {
      Convert_Pos(pos[0],pos[1], &pos[0],&pos[1] )   ;
      
      if(pos[0]<50&&pos[1]>295)
        DrawRectFill(0,25,240,270,WINDOW_BK_COLOR)   ;
      else 
      if(  (pos[0]<230&&pos[0]>200&&pos[1]>295)
         ||(pos[0]>220&&pos[1]<20             ))
        break                                        ;
      else if(pos[1]<280&&pos[1]>30)
        DrawRectFill(pos[0],pos[1],4,4,Red)          ;
    }
  }
  return 0x00                                        ;
}
示例#2
0
void Update_ScrollBar(unsigned int x,unsigned int y,unsigned char height,
                      unsigned char position,unsigned char total         )
{
  unsigned int temp                                       ;
  DrawRectFill(x,y,8,height,WINDOW_BK_COLOR)              ; // 外框
  DrawRect(x,y,8,height,WINDOW_COLOR)                     ; // 外框
  temp = y+(unsigned int)(height-44)*position/(total-1)   ;
  DrawRectFill(x,temp,8,44,WINDOW_COLOR)                  ; // 滑块
}
void TBRendererBatcher::DrawRect(const TBRect &dst_rect, const TBColor &color)
{
	if (dst_rect.IsEmpty())
		return;
	// Top
	DrawRectFill(TBRect(dst_rect.x, dst_rect.y, dst_rect.w, 1), color);
	// Bottom
	DrawRectFill(TBRect(dst_rect.x, dst_rect.y + dst_rect.h - 1, dst_rect.w, 1), color);
	// Left
	DrawRectFill(TBRect(dst_rect.x, dst_rect.y + 1, 1, dst_rect.h - 2), color);
	// Right
	DrawRectFill(TBRect(dst_rect.x + dst_rect.w - 1, dst_rect.y + 1, 1, dst_rect.h - 2), color);
}
示例#4
0
char Proc_TP_Adj(char *NC)
{
  unsigned int temp[8]                               ;
  Color     = Green                                  ;
  Color_BK  = Black                                  ;
  TP_Init()                                          ;
  Clear_LCD(Color_BK)                                ; 
  PutStringCN24(58,120,"触摸屏校正")                 ;
  Color     = Cyan                                   ;
  PutStringCN16(30,165,"请用触控笔点测试点中心")     ;
  for(;;)
  {
    Draw_Test_Point(20,20,Yellow)                    ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[0],&temp[1]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,0,40,40,Color_BK)                 ;
    Wait_Pen_Up()                                    ;
  
    Draw_Test_Point(220,20,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[2],&temp[3]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,0,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(20,300,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[4],&temp[5]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,280,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(220,300,Yellow)                  ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[6],&temp[7]))  break    ;       
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,280,40,40,Color_BK)             ;
    Wait_Pen_Up()                                    ;
    if(TP_Adjust(temp))         break                ;
  }
  return 0x00                                        ;
}
示例#5
0
///////////////////
// Draw the scrollbar
void CScrollbar::Draw(SDL_Surface * bmpDest)
{
	int x=0;
	int length;
    
	// Top arrow
	if(bTopButton)
		x=15;
	DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,0, iX,iY, 15,14);

	// Bottom arrow
	x=0;
	if(bBotButton)
		x=15;
	DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,14, iX,iY+iHeight-14, 15,14);

	// Main bit
	DrawRectFill(bmpDest, iX,iY+14, iX+iWidth, iY+iHeight-14, tLX->clScrollbarBack);
	DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX,tLX->clScrollbarBackLight);
	DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX+iWidth,tLX->clScrollbarBackLight);

	// Slider
	if(iMax > iItemsperbox && iMax > 0) {
		length = (int)((float)iItemsperbox/(float)iMax * iHeight-30);
        length = MAX(length, 12);
        
		int pos = iScrollPos;
		if(pos+length > iHeight-30)
			pos=iHeight-30-length;
		if (pos < 0)  
			pos = 0;

		DrawRectFill(bmpDest, iX+2, iY+15+pos, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarFront);

        // Shine
        DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+1, tLX->clScrollbarHighlight);
        DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos, tLX->clScrollbarHighlight);
        // Dark
        DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+iWidth-1, tLX->clScrollbarShadow);
        DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarShadow);
	}

	// Slight hack
	if( !GetMouse()->Button ) {
		bTopButton=false;
		bBotButton=false;
	}
		
}
示例#6
0
//***************************************************************************************
//																	                    *
// 		void ActiveEditDig(): 设置数字编辑控件活动状态                     		        *
//																	                    *
//***************************************************************************************
void RedrawEditDig(unsigned char Index)                    
{
  unsigned char  i,j                                                    ;
  char* p                                                               ;
  unsigned char string[20]                                              ;
  i      = Index                                                        ;
  p      = Edit_Dig[i].string                                           ;
  DrawRectFill(Edit_Dig[i].x,Edit_Dig[i].y,
	       Edit_Dig[i].width, Edit_Dig[i].height+1,Color_BK)        ; // 清除显示 
  if(Edit_Dig[i].property&EDIT_FRAME)                                     // 需绘制边框
    DrawRect(Edit_Dig[i].x,Edit_Dig[i].y,
	     Edit_Dig[i].width,
	     Edit_Dig[i].height,Color    )                              ; 
  if(DISP_MODE==0x00)
    PutString24(Edit_Dig[i].x+Edit_Dig[i].width/2-strlen(p)*6-4,            // 居中显示
	        Edit_Dig[i].y+Edit_Dig[i].height/2-12,(unsigned char*)p);
  else
  {
    for(j=0;j<strlen(p);j++)
      string[j]  = '*'                                                  ;
    string[j]    = 0x00                                                 ;
    PutString24(Edit_Dig[i].x+Edit_Dig[i].width/2-strlen(p)*6-4,            // 居中显示
	        Edit_Dig[i].y+Edit_Dig[i].height/2-12,string    )       ;
  }
  Event         |= SHOULD_FLICKER                                       ;
  flicker_status = 0x00                                                 ;
}
示例#7
0
//=====================================================================//
//函数:void Initial_Menu(UINT** Menu_List)
//功能:刷新整屏菜单显示函数
//参数:Menu_List - 菜单资源链表指针
//=====================================================================//
void Initial_Menu(void)
{
  First_Index_old   = 0xFF                                ;
  y_Index_old       = 0xFF                                ;
//  Font_GB           = *(Menu_Config+1)                    ; // 中文字体大小
//  Font_String       = *(Menu_Config+2)                    ; // 西文字体大小
//  Y_WIDTH_MENU      = *(Menu_Config+3)                    ; // 菜单项占用纵轴点数
//  X_SPACE_FRONT     = *(Menu_Config+4)                    ; // 菜单项横轴缩进点数
  Dis_Menu_Num      = (Dis_Y_MAX+1-Y_OFFSET)/Y_WIDTH_MENU ;       
//  FontSet_cn(Font_GB)                                     ;
//  FontSet_en(Font_String)                                 ;
//  Active_Index = Menu.MenuConfig[6]                       ;
  Active_Index = 0x00                                     ;
  First_Index  = Active_Index                             ;
  if(First_Index<Dis_Menu_Num)
    First_Index    = 0x00                                 ;
  while(First_Index>Dis_Menu_Num)
    First_Index   -= (Dis_Menu_Num-1)                     ;
  UpDate_Menu(First_Index,Active_Index)                   ;
  Color_BK = STATUS_BK_COLOR                              ;
  Color    = STATUS_COLOR                                 ;
  PutStringCN24(10,294,"确认")                            ; // 底栏
  if(Menu.MenuIndex>0)
    PutStringCN24(185,294,"返回")                         ; 
  else
    DrawRectFill(185,294,54,25,STATUS_BK_COLOR)           ;
}
示例#8
0
///////////////////
// Draw the scrollbar
void CScrollbar::DoRepaint()
{
	CHECK_BUFFER;

	CWidget::DoRepaint();

	// Background
	if (bmpBackground.get().get())  {
		int sx = 0;
		if (bBackgroundOver)
			sx = bmpBackground->w / 3;
		if (bBackgroundDown)
			sx = bmpBackground->w * 2 / 3;
		DrawImageTiled(bmpBuffer.get(), bmpBackground, sx, 0, bmpBackground->w/3, bmpBackground->h, 0, 0, getWidth(), getHeight());
	} else {
		DrawRectFill(bmpBuffer.get(), 0, 0, getWidth(), getHeight(), iBackgroundColor);
	}

	switch (iDirection)  {
	case scrVertical:  {
			DoRepaintVertical();
		}
		break;
	case scrHorizontal:  {
			DoRepaintHorizontal();
		}
		break;
	default:
		warnings << "CScrollbar::Draw, unknown scrollbar type" << endl;
	}

}
示例#9
0
//***************************************************************************************
//																	                    *
// 		void DeleteEditDig(): 设置数字编辑控件活动状态                     		        *
//																	                    *
//***************************************************************************************
void DeleteEditDig(unsigned char ID)
{
  unsigned char i                                                           ;
  for(i=0;i<6;i++)
  {
    if(Edit_Dig[i].id != ID) 
	  continue                                                          ;
	else
	{	  
	  if(!(Edit_Dig[i].status&EDIT_VALID))
	    break                                                           ;
	  else
	  {	
	    Edit_Dig[i].status   &=~EDIT_VALID                              ; // 清除有效状态
	    if(Edit_Dig[i].status&EDIT_ACTIVE)		  
	      Active_Edit_Dig = 0xFF                                        ; // 消隐光标
	    Edit_Dig[i].status   &=~EDIT_ACTIVE                             ; // 清除活动状态		
	    DrawRectFill(Edit_Dig[i].x,Edit_Dig[i].y,
	                 Edit_Dig[i].width, Edit_Dig[i].height+1,Color_BK)  ; // 清除显示 		
	  }
	}
  }
}
示例#10
0
void Menu_Net_NETAddServer()
{
	CGuiLayout	cAddSvr;
	gui_event_t *ev = NULL;
	bool		addServerMsg = true;


	// Create the background
	cInternet.Draw( tMenu->bmpBuffer.get() );
	Menu_DrawBox(tMenu->bmpBuffer.get(), 200, 220, 440, 340);
	//DrawImageAdv(tMenu->bmpBuffer, tMenu->bmpMainBack, 202,222, 202,222, 237,117);
    DrawRectFill(tMenu->bmpBuffer.get(), 202,222,439,339,tLX->clDialogBackground);
	for(int i=0;i<6;i++)
		cNetButtons[i].Draw(tMenu->bmpBuffer.get());
	Menu_RedrawMouse(true);


	cAddSvr.Initialize();
	cAddSvr.Add( new CButton(BUT_ADD, tMenu->bmpButtons),	na_Add, 220, 320, 40,15);
	cAddSvr.Add( new CButton(BUT_CANCEL, tMenu->bmpButtons),na_Cancel, 350, 320, 70,15);
	cAddSvr.Add( new CLabel("Add a server", tLX->clNormalLabel),		-1,275, 225, 0, 0);
	cAddSvr.Add( new CLabel("Address", tLX->clNormalLabel),				-1,215, 267, 0, 0);
	cAddSvr.Add( new CTextbox(),							na_Address, 280, 265, 140, tLX->cFont.GetHeight());

	ProcessEvents();
	while(!WasKeyboardEventHappening(SDLK_ESCAPE,false) && addServerMsg && tMenu->bMenuRunning) {
		Menu_RedrawMouse(true);
		DrawImageAdv(VideoPostProcessor::videoSurface(),tMenu->bmpBuffer, 200,220, 200,220, 240, 240);

		ProcessEvents();

		// Process the server list
		if( SvrList_Process() ) {
			// Add the servers to the listview
			Menu_Net_NET_ServerList_Refresher();
		}

		cAddSvr.Draw( VideoPostProcessor::videoSurface() );
		ev = cAddSvr.Process();

		// Process any events
		if(ev) {

			switch(ev->iControlID) {

				// Add
				case na_Add:
					if(ev->iEventMsg == BTN_CLICKED) {

						std::string addr;
						cAddSvr.SendMessage(na_Address, TXS_GETTEXT, &addr, 0);

						SvrList_AddServer(addr, true);
						Menu_Net_NET_ServerList_Refresher();

						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;

				// Cancel
				case na_Cancel:
					if(ev->iEventMsg == BTN_CLICKED) {
						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;
			}
		}


		DrawCursor(VideoPostProcessor::videoSurface());
		doVideoFrameInMainThread();
		CapFPS();
	}


	cAddSvr.Shutdown();

	// Re-draw the background
	DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	if (tMenu->tFrontendInfo.bPageBoxes)
		Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_RedrawMouse(true);
}
示例#11
0
void UpDate_Menu(unsigned char First_Index,unsigned char Menu_Index)
{
  unsigned int  y_Index                                                                ;
  unsigned char i                                                                      ;
  _DINT()                                                                              ;
  if(Dis_Menu_Num+First_Index> Menu.MenuConfig[0])
    Dis_Menu_Num =  Menu.MenuConfig[0] - First_Index                                   ; 
  y_Index  = 0                                                                         ; // 
  if(First_Index_old!=First_Index)                                                       // window内首条菜单项改变 
  {
    if(y_Index_old==0xFF)                                                                // 初始绘制菜单
    {
      DrawRectFill(0,60,240,230,WINDOW_BK_COLOR)                                       ; // 清空窗口 
      Color    = TITLE_COLOR                                                           ; // 显示标题条
      Color_BK = TITLE_BK_COLOR                                                        ;
      DrawRectFill(0,30,240,30,Color_BK)                                               ;
      PutString24M(120-25*strlen((char*)Menu.MenuTitle)/4,33,Menu.MenuTitle)          ;
      y_Index = Y_OFFSET-1                                                             ; // 由上而下显示各菜单项
      for(i=First_Index;i<Dis_Menu_Num+First_Index;i++)
      {
        if(i==Menu_Index)
		{
          DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,MENU_SELE_COLOR)           ; // 显示选择条		
          ShowMenu_Item(y_Index,i+1,1)                                               ;
		}
	    else
          ShowMenu_Item(y_Index,i+1,0)                                               ; // 显示非被选菜单项
	    y_Index += Y_WIDTH_MENU                                                      ;
      }        

      y_Index_old     = 0                                                              ;
      First_Index_old = 0                                                              ;
    }
    else                                                                                 // 首菜单项改变 
    {
      Color_BK = WINDOW_BK_COLOR                                                       ;            
      if(First_Index_old<First_Index)                                                    // 菜单向上滚动
      {
        y_Index = Y_OFFSET-1+Y_WIDTH_MENU*(Dis_Menu_Num-1)                             ;
        DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,MENU_SELE_COLOR)               ; // 清选中菜单项内容
        DrawRectFill(0,Y_OFFSET-1,Dis_X_MAX,Y_WIDTH_MENU*(Dis_Menu_Num-1),
		             WINDOW_BK_COLOR                                      )    ; // 清空被选菜单项上部内容
      	y_Index = Y_OFFSET-1 + Y_WIDTH_MENU*(Dis_Menu_Num-1)                           ; // 自下而上显示被选菜单项
        for(i=0;i<Dis_Menu_Num;i++)
        {
		  if(i==0)
            ShowMenu_Item(y_Index,Menu_Index-i+1,1)                                    ;
	      else
            ShowMenu_Item(y_Index,Menu_Index-i+1,0)                                    ; // 显示非被选菜单项
	      y_Index -= Y_WIDTH_MENU                                                  ;
        }        
      }
      else
      {
	y_Index = Y_OFFSET-1                                                           ;
        DrawRectFill(0,Y_WIDTH_MENU+Y_OFFSET-1,Dis_X_MAX,Y_WIDTH_MENU*(Dis_Menu_Num-1),
		             WINDOW_BK_COLOR                                          ); // 清空被选菜单项下部内容
        DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,MENU_SELE_COLOR)               ; // 清选中菜单项内容
        for(i=First_Index;i<Dis_Menu_Num+First_Index;i++)
        {
          if(i==Menu_Index)
            ShowMenu_Item(y_Index,i+1,1)                                               ;
	      else
            ShowMenu_Item(y_Index,i+1,0)                                               ; // 显示非被选菜单项
	      y_Index += Y_WIDTH_MENU                                                      ;
        }        
      }
    }
    First_Index_old = First_Index                                                      ;
  }
  else                                                                                   // 首菜单项无变化
  {
    y_Index = y_Index_old-First_Index_old                                              ;
    y_Index = y_Index*Y_WIDTH_MENU+Y_OFFSET-1                                          ;
    DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,WINDOW_BK_COLOR)                   ;            
    ShowMenu_Item(y_Index,y_Index_old+1,0)                                             ;
    y_Index = Menu_Index-First_Index                                                   ;
    y_Index = y_Index*Y_WIDTH_MENU+Y_OFFSET-1                                          ;
//    DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,WINDOW_COLOR)                      ;
    DrawRectFill(0,y_Index-1,Dis_X_MAX,Y_WIDTH_MENU,MENU_SELE_COLOR)                   ;
    ShowMenu_Item(y_Index,Menu_Index+1,1)                                              ;
  }
  y_Index_old = Menu_Index                                                             ;
  Update_ScrollBar(Dis_X_MAX+2,Y_OFFSET-5,289-Y_OFFSET,Menu_Index,Menu.MenuConfig[0])  ;
  _EINT()                                                                              ;
}
示例#12
0
void RunMenu(unsigned char Menu_Index)
{
  unsigned char key = 0xFF , menu_index  , SubMenuIndex                   ;
  unsigned char First_Item , Active_Item , Active_Item_Index              ;
  unsigned char CallBackIndex                                             ;

  Clear_LCD(Color_BK)                                                     ;
  DrawRectFill(0,0,240,25,Blue)                                           ;
  DrawRectFill(0,295,240,25,Blue)                                         ;
  Color    = 0xFFFF                                                       ;
  Color_BK = Blue                                                         ;
  PutStringCN16(4,4,Menus[Menu_Index].MenuTitle)                          ;
  Color    = Black                                                        ;
  Color_BK = WINDOW_BK_COLOR                                              ;  
  
  Clear_LCD(STATUS_BK_COLOR)                                              ;
  Color_BK = STATUS_BK_COLOR                                              ;
  PutStringCN24(10,294,"确认")                                            ; // 底栏
  PutStringCN24(185,294,"取消")                                           ; 
  LoadMenu(MAIN_MENU,PERMISSION)                                          ;
  Initial_Menu()                                                          ;
  for(;;)
  {
    key = GetKeyPress()                                                   ;
    switch(key)
    {
    case Up: case Down: case Left: case Right:
      MenuMessage(key)                                                    ;
      break                                                               ;
    case  8:
      MenuMessage(Up)                                                     ;
      break                                                               ;
    case  0:
      MenuMessage(Down)                                                   ;
      break                                                               ;
    case Esc:
      {
//        if(Current_Menu[0][6]!=EMPTY)
//          Item_OP[Current_Menu[0][6]](0,0)                                ; // 菜单执行函数
        menu_index = GetMenuIndex()                                       ;
        if(Menus[menu_index].MasterMenu!=EMPTY)
//          return Menus[menu_index].MasterMenu                             ;
        {
          LoadMenu(Menus[menu_index].MasterMenu,PERMISSION)               ;
          Initial_Menu()                                                  ;
        }
        break                                                             ;
      }
    case OK: case Enter:
      {
        First_Item          = GetFirstItem()                              ;
        Active_Item         = GetActiveItem()                             ;
        Active_Item_Index   = GetActiveItemIndex()                        ;        
        if(MENU_ITEM[Active_Item_Index].CallBackFuncIndex!=EMPTY)           // 有操作函数
        {
          CallBackIndex= MENU_ITEM[Active_Item_Index].CallBackFuncIndex   ;
          SubMenuIndex = MENU_ITEM[Active_Item_Index].SubMenuIndex        ;
          if(SubMenuIndex!=EMPTY)                                           // 有操作函数且有动态子菜单
          {
            SubMenuIndex = MENU_ITEM[Active_Item_Index].SubMenuIndex      ; 
            if(Item_OP[CallBackIndex](0,Active_Item_Index  )==0x00)         // 生成子菜单成功
              Initial_Menu()                                              ; // 初始化动态子菜单
            else
              Redraw_Menu(First_Item,Active_Item)                         ; // 未生成子菜单,重画原菜单
          }
          else
          {
            Item_OP[CallBackIndex](0,Active_Item_Index  )                 ; // 无动态子菜单
            Redraw_Menu(First_Item,Active_Item)                           ; // 重画菜单
          }
        }
        
/*        
        if(MENU_ITEM[Item_Index].CallBackFuncIndex!=EMPTY)
        {
          Item_OP[MENU_ITEM[Item_Index].CallBackFuncIndex](0,Active_Index);
          if(  (MENU_ITEM[Item_Index].SubMenuIndex!=EMPTY)
             &&(Master_Or_Sub==GOTO_SUB                  ))
            return MENU_ITEM[Item_Index].SubMenuIndex                     ;
          Redraw_Menu(First_Index,Active_Index,(UCHAR**)P_Current_Menu)   ;          
        }
        else
*/      
        else  
        if(MENU_ITEM[Active_Item_Index].SubMenuIndex!=EMPTY)
//          return MENU_ITEM[Item_Index].SubMenuIndex                       ;
        {
          LoadMenu(MENU_ITEM[Active_Item_Index].SubMenuIndex,PERMISSION)  ;
          Initial_Menu()                                                  ;
        }
        break                                                             ;          
      }
    case Power:
      return                                                              ;
    default:
      break                                                               ;
    }
  }
}  
示例#13
0
//---------------------------------------------------------------------------//
//                                                                           //
//函数:void ShowMenu_Item(unsigned char ,unsigned char,unsigned char)       //
//描述:显示菜单项子函数                                                     //
//参数:index ——菜单项索引                                                 //
//      no    ——显示位置序号                                               //
//      mode  ——显示模式                                                   //
//		                                                             //
//---------------------------------------------------------------------------//
void RunMenu(unsigned char index)
{
  char key,i,Active_Item  = 0x00                                         ;
  OS_U8 Event                                                            ;
  union
  {
    unsigned int  pos[2]                                                 ;
    char byte[4]                                                         ;
  }TPoint                                                                ;
Ini_Background:  
  Color     = Black                                                      ;
  Color_BK  = 0xEF9F                                                     ;
  Clear_LCD(Color_BK)                                                    ;
  DrawRectFill(0,0,240,25,Blue)                                          ;
  DrawRectFill(0,295,240,25,Blue)                                        ;
  Color    = 0xFFFF                                                      ;
  Color_BK = Blue                                                        ;
  PutStringCN16(4,4,(unsigned char *)Menus[index].MenuTitle)             ;
  Color    = Black                                                       ;
  Color_BK = WINDOW_BK_COLOR                                             ;
  for(i=0;i<Menus[index].MenuConfig[0];i++)
  {
    if(i==Active_Item)
      ShowMenu_Item(Menus[index].ItemIndex[i],i,1)                       ;
    else
      ShowMenu_Item(Menus[index].ItemIndex[i],i,0)                       ;      
  }
  for(;;)
  {
//    Event = OS_WaitEvent(EVENT_KEY_PRESSED+EVENT_TP_PRESSED)             ; 
    OS_WaitMail(&MBKey)                                                  ;
//    if(Event&EVENT_KEY_PRESSED)
    {
      OS_GetMail1(&MBKey, &key)                                          ;  
      switch(key)
      {
      case Right:
        InactivateItem(Active_Item)                                      ;
        if(++Active_Item>=Menus[index].MenuConfig[0])
          Active_Item = 0x00                                             ;
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case Left:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==0) 
          Active_Item = 0x08                                             ;
        else
          Active_Item--                                                  ;
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case 8:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==0) 
          Active_Item = 0x08                                             ;
        else if(Active_Item==1||Active_Item==2)
          Active_Item = Active_Item+5                                    ;
        else 
          Active_Item = Active_Item-3                                    ;          
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case 0:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==8) 
          Active_Item = 0x00                                             ;
        else if(Active_Item==6||Active_Item==7)
          Active_Item = Active_Item-5                                    ;
        else 
          Active_Item = Active_Item+3                                    ;          
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case Enter:
        OS_PutMail1(&MBFunc, &Active_Item)                               ;
        OS_SignalEvent(EVENT_OP_STARTED,&MENU_OP_TASK_TCB)               ;
        OS_Suspend(&LCD_TASK_TCB)                                        ;
        goto Ini_Background                                              ;
      default:
        break                                                            ;
      }
    }
/*    else
    {
      OS_GetMail(&MBTouch, TPoint.byte)                                  ; 
      for(i=0;i<Menus[index].MenuConfig[0];i++)
      {        
        if(  (TPoint.pos[0]<(60+i%3*80)&&TPoint.pos[0]>(20+i%3*80))
           &&(TPoint.pos[1]<(95+i/3*84)&&TPoint.pos[1]>(55+i/3*82)))
        {
          Active_Item = i                                                ;
          OS_PutMail1(&MBFunc, &Active_Item)                             ;
          OS_SignalEvent(EVENT_OP_STARTED,&MENU_OP_TASK_TCB)             ;
          OS_Suspend(&LCD_TASK_TCB)                                      ;
          goto Ini_Background                                            ;
        }
      }
    }
*/    
  }
}
示例#14
0
char Proc_Display(char *NC)
{
  CHECK_BOX Disp_Check[3]                            ;
  char key,Event,temp[1],active_digit,rx_char        ;
  char index,down_id=0xFF,i,flicker = 0              ;
  union
  {
    unsigned int  pos[2]                             ;
    char byte[4]                                     ;
  }TPoint                                            ;
  Color     = Black                                  ;
  Color_BK  = 0xEF9F                                 ;
  Clear_LCD(Color_BK)                                ;
  DrawRectFill(0,0,240,25,Blue)                      ;
  DrawRectFill(0,295,240,25,Blue)                    ;
  ShowIcon24(217,0,24,23,ICON_CLOSE)                 ;
  Color    = 0xFFFF                                  ;
  Color_BK = Blue                                    ;
  PutStringCN16(4,4,"数码管控制")                    ;
  PutStringCN16(200,300,"退出")                      ;
  Color    = Black                                   ;
  Color_BK = WINDOW_BK_COLOR                         ;
  DrawFrame(3,80,232,48)                             ;
  DrawRectFill(4,81,232,46,Black)                    ;
  DrawPanel(6,160,228,72,"")                         ;
  CreateButton(1,"<",15, 175,45,20)                 ;
  CreateButton(2,">",70, 175,45,20)                 ;
  CreateButton(3,"+",125,175,45,20)                 ;
  CreateButton(4,"-",180,175,45,20)                 ;  
  for(active_digit=1;active_digit<9;active_digit++)
  {
    temp[0] = Find_Data(LED[active_digit-1].data)    ;
    if(!(LED[active_digit-1].mode&DIGIT_OFF))
      Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                   87,Red,Black                  )   ; 
    if(!(LED[active_digit-1].data&SEGDP))
      DrawRectFill((active_digit-1)*29+30,120,
                  3,3,Red)                           ;
  }
  for(active_digit=1;active_digit<9;active_digit++)
  {
    DrawFrame((active_digit-1)*29+14,139,11,11)      ;    
    DrawRectFill((active_digit-1)*29+15,140,10,10,Dark_Grey); 
  }
  DrawRectFill(15,140,10,10,Green)                   ; 
  active_digit = 1                                   ;
  CreateCheck(&Disp_Check[0],25 ,210,12,12,"闪烁")   ;
  CreateCheck(&Disp_Check[1],90 ,210,12,12,"消隐")   ;
  CreateCheck(&Disp_Check[2],150,210,12,12,"小数点") ;
  if(LED[active_digit-1].mode&DIGIT_FLICKER)
    CheckCheck(&Disp_Check[0])                       ;
  if(LED[active_digit-1].mode&DIGIT_OFF)
    CheckCheck(&Disp_Check[1])                       ;
  if(!(LED[active_digit-1].data&SEGDP))
    CheckCheck(&Disp_Check[2])                       ;   
  temp[0]      = 0x00                                ;
  for(;;)
  {
    OS_WaitMail(&MBKeyTP)                            ;
    OS_GetMail1(&MBKeyTP, &Event)                    ;
    OS_GetMail1(&MBKeyTP, &key)                      ; 
    OS_GetMail1(&MBKeyTP, &rx_char)                  ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[0])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[1])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[2])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[3])           ;     
    if(Event&EVENT_TP_TOUCHED)
    {
      index = InScopeButton(TPoint.pos[0],
                            TPoint.pos[1] )          ;
      if(index==0xFF)
      {
        OS_Use(&SemaLCD)                             ; 
        SetButtonUp(down_id)                         ;
        down_id = index                              ;
        OS_Unuse(&SemaLCD)                           ;            
      }
      else if(index!=down_id)
      {
        OS_Use(&SemaLCD)                             ; 
        SetButtonUp(down_id)                         ;
        down_id = index                              ;
        SetButtonDown(down_id)                       ;
        OS_Unuse(&SemaLCD)                           ;            
      }
    }
    else if(Event&EVENT_TP_PRESSED)  
    {  
      index = InScopeButton(TPoint.pos[0],
                            TPoint.pos[1] )          ;
      OS_Use(&SemaLCD)                               ; 
      SetButtonUp(index)                             ;
      down_id  = 0xFF                                ;
      OS_Unuse(&SemaLCD)                             ; 
      switch(index)
      {
      case 1:
        if(active_digit>1)
        {
          active_digit--                              ;
          DrawRectFill((active_digit)*29+15,140,10,10,Dark_Grey); 
          DrawRectFill((active_digit-1)*29+15,140,10,10,Green); 
          if(LED[active_digit-1].mode&DIGIT_FLICKER)
            CheckCheck(&Disp_Check[0])               ;
          else
            unCheckCheck(&Disp_Check[0])             ;
          if(LED[active_digit-1].mode&DIGIT_OFF)
            CheckCheck(&Disp_Check[1])               ;
          else
            unCheckCheck(&Disp_Check[1])             ;
          if(!(LED[active_digit-1].data&SEGDP))
            CheckCheck(&Disp_Check[2])               ;
          else
            unCheckCheck(&Disp_Check[2])             ;
        }
        break                                        ;
      case 2:
        if(active_digit<8)
        {
          active_digit++                              ;
          DrawRectFill((active_digit-2)*29+15,140,10,10,Dark_Grey); 
          DrawRectFill((active_digit-1)*29+15,140,10,10,Green); 
          if(LED[active_digit-1].mode&DIGIT_FLICKER)
            CheckCheck(&Disp_Check[0])               ;
          else
            unCheckCheck(&Disp_Check[0])             ;
          if(LED[active_digit-1].mode&DIGIT_OFF)
            CheckCheck(&Disp_Check[1])               ;
          else
            unCheckCheck(&Disp_Check[1])             ;
          if(!(LED[active_digit-1].data&SEGDP))
            CheckCheck(&Disp_Check[2])               ;
          else
            unCheckCheck(&Disp_Check[2])             ;
        }
        break                                        ;
      case 3:        
        temp[0] = Find_Data(LED[active_digit-1].data);
        if(++temp[0]>9)   temp[0] = 0                ;
        LED[active_digit-1].data |= 0x7F             ;
        LED[active_digit-1].data &= SMG[temp[0]]     ;
        Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                     87,Red,Black                 )  ;        
        break                                        ;
      case 4:        
        temp[0] = Find_Data(LED[active_digit-1].data);
        if(--temp[0]>250)   temp[0] = 9              ;
        LED[active_digit-1].data |= 0x7F             ;
        LED[active_digit-1].data &= SMG[temp[0]]     ;
        Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                     87,Red,Black                 )  ;        
        break                                        ;
      }
      for(i=0;i<3;i++)
      {
        if(!InCheckScope(TPoint.pos[0],
                         TPoint.pos[1],
                         &Disp_Check[i]))
        {
          if(Disp_Check[i].status&CHECK_CHECKED)
          {
            unCheckCheck(&Disp_Check[i])             ;
            switch(i)
            {
            case 0:
              LED_Flicker_Digit(active_digit,0)      ; 
              temp[0] = Find_Data(LED[active_digit-1].data)                ;
              if(!(LED[active_digit-1].mode&DIGIT_OFF))
              {
                Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                             87,Red,Black                  )     ; 
                if(!(LED[active_digit-1].data&SEGDP))
                  DrawRectFill((active_digit-1)*29+30,120,3,3,Red)          ;
              }
              break                                  ;
            case 1:
              temp[0] = Find_Data(LED[active_digit-1].data)  ;
              Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                           87,Red,Black                  )   ; 
              if(!(LED[active_digit-1].data&SEGDP))
                  DrawRectFill((active_digit-1)*29+30,120,3,3,Red)    ;
              LED[active_digit-1].mode  &=~DIGIT_OFF ;
              break                                  ;
            case 2:
              LED[active_digit-1].data  |= SEGDP     ;
              DrawRectFill((active_digit-1)*29+30,120,
                            3,3,Black)               ;
              break                                  ;
            }
          }
          else
          {
            CheckCheck(&Disp_Check[i])               ;
            switch(i)
            {
            case 0:
              LED_Flicker_Digit(active_digit,1)      ; 
              break                                  ;
            case 1:
              temp[0] = Find_Data(LED[active_digit-1].data)  ;
              Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                           87,Black,Black                )   ; 
              DrawRectFill((active_digit-1)*29+30,120,
                            3,3,Black)               ;
              LED[active_digit-1].mode  |= DIGIT_OFF ;
              break                                  ;
            case 2:
              LED[active_digit-1].data  &=~SEGDP     ;
              DrawRectFill((active_digit-1)*29+30,120,
                           3,3,Red)                  ;
              break                                  ;
            }
          }
          break                                      ;
        }
      }
      if(  (TPoint.pos[0]<230&&TPoint.pos[0]>200&&TPoint.pos[1]>295)
         ||(TPoint.pos[0]>220&&TPoint.pos[1]<20             ))
          break                                      ;      
    }
    else if(Event&EVENT_FLICKER)
    {
      if(flicker++>0)
      {
        for(i=1;i<9;i++)
        {
          temp[0] = Find_Data(LED[i-1].data)                ;
          if(  !(LED[i-1].mode&DIGIT_OFF)
             && (LED[i-1].mode&DIGIT_FLICKER))
          {
            Draw7Seg2436(temp[0],(i-1)*29+5,
                         87,Red,Black                  )     ; 
            if(!(LED[i-1].data&SEGDP))
              DrawRectFill((i-1)*29+30,120,3,3,Red)          ;
          }
        }
        flicker  = 0x00                                    ;
      }
      else
      {
        for(i=1;i<9;i++)
        {
          temp[0] = Find_Data(LED[i-1].data)                ;
          if(  !(LED[i-1].mode&DIGIT_OFF)
             && (LED[i-1].mode&DIGIT_FLICKER))
          {
            Draw7Seg2436(temp[0],(i-1)*29+5,
                         87,Black,Black                 )   ; 
            if(!(LED[i-1].data&SEGDP))
              DrawRectFill((i-1)*29+30,120,3,3,Black)      ;
          }
        }
      }                  
    }
  } 
  DeleteButton(1)                                    ;
  DeleteButton(2)                                    ;
  DeleteButton(3)                                    ;
  DeleteButton(4)                                    ;
  return 0x00                                        ;
}