MENU__listMenu.c File Reference


Detailed Description

This module manages the list menu.

REVISION

Definition in file MENU__listMenu.c.

#include "menu.h"
#include "menu_assert.h"
#include "../TIMER/timer.h"
#include "../SYSTEM/sys_main.h"

Include dependency graph for MENU__listMenu.c:

Include dependency graph

Go to the source code of this file.

Functions

void MENU__createListMenu (HMENU menu)
 Function creates a standard list text display.
void MENU__listMenuAction (HMENU menu, MENUACTION actID)
 Function serves as the list MENU action handle.


Function Documentation

void MENU__createListMenu HMENU  menu  ) 
 

Function creates a standard list text display.

Parameters:
menu Menu handle.

Definition at line 49 of file MENU__listMenu.c.

References st_LISTMENU::actvItem, st_FIELD::attr, st_RECT::br, st_LISTMENU::btmItem, st_BRUSH::clr, st_FIELD::dptr, st_MENUTMPLT::fld, GEN_strUnpack(), st_LISTMENU::getDptr, st_LISTMENU::getDptrCtl, st_LISTMENU::itemicon, st_LISTMENU::itemNum, LCD_drawRect(), LCD_graphSize(), LCD_invRect(), LCD_printFld(), LCD_setBrush(), LCD_setFrame(), MENU__sbarInit(), st_LCDINFO::num, st_LISTMENU::pValue, st_FIELD::rc, st_MENUTMPLT::rect, st_LISTMENU::rect, st_MENUTMPLT::sbar, st_LISTMENU::scrollCount, st_MENUTMPLT::share, st_MENU_REGIST::tmplt, TMR_create(), TMR_delete(), TMR_TXTSCROLL, st_LISTMENU::topItem, st_FIELD::txtattr, st_RECT::ul, st_POINT::x, and st_POINT::y.

Referenced by MENU__listMenuAction().

00050 {
00051     st_MENUTMPLT *  pTmplt;
00052     st_LISTMENU *   pList;
00053     st_RECT *       pRect;
00054     st_FIELD *      pFld;
00055     st_BRUSH        brush;
00056     HSBAR           sbar;
00057     st_SIZE         size;
00058     st_POINT        point;
00059     ULONG           dptr;
00060     UINT            ii;
00061     UINT            jj; 
00062     unsigned char * pC;
00063     st_RECT         rect = {{MENU_DLMT_LEFTx,   MENU_DLMT_LEFTy},
00064                             {MENU_DLMT_RIGHTx,  MENU_DLMT_RIGHTy}};
00065     unsigned char   title[32];  // Title name buffer.
00066     
00067     /* Load display pattern template. ----------------------------------------*/
00068     pTmplt = &MENU_regist[menu].tmplt;
00069     pList = (st_LISTMENU*)&pTmplt->share;
00070     
00071     /* Display title. ---------------------------------------------------------*/
00072     pFld = &pTmplt->fld[0];
00073     pFld->txtattr = ALIGN_HCENT | WRAP_OFF | ALIGN_VCENT | TXT_ATTR_PARTDSP;
00074     pFld->attr = FLD_ATTR_TXTFLD | FONT_MAIN14;     
00075         
00076     pRect = &pFld->rc;
00077     pRect->ul.x = 0;        
00078     pRect->ul.y = 0;        
00079     pRect->br.x = 127;      
00080     pRect->br.y = 13;   
00081     
00082     ii = GEN_readXstr(pList->getDptr(0, pList->getDptrCtl), (USHORT*)title, 32);
00083     ii = GEN_strUnpack((UINT16*)title, ii);
00084     
00085     pC = &title[0];
00086     while(ii--)
00087     {   
00088         *pC = toupper(*pC);
00089         pC++;
00090     }
00091         
00092     pFld->dptr = (long)title;   
00093     LCD_printFld(pFld, NULL);
00094     
00095 
00096     /* Draw delimiter line. ---------------------------------------------------*/
00097     brush.clr = MENU_DLMT_BRUSHCLR;
00098     LCD_setBrush(&brush);
00099     LCD_drawRect(&rect);
00100     
00101     
00102     /* Create list display template. ------------------------------------------*/       
00103     pRect = &pList->rect;
00104     for(ii = 0; ii < MENU_MAXITEMPERSCREEN; ii++)
00105     {
00106         pFld->txtattr = ALIGN_LEFT | WRAP_OFF | ALIGN_VCENT;        
00107         pFld->attr = FLD_ATTR_TXTFLD | FONT_MAIN14;     
00108         
00109         if(pList->itemicon != ITEM_NO_ICON)
00110         {
00111             pFld->rc.ul.x = pRect->ul.x + 1;        
00112         }
00113         else
00114         {
00115             pFld->rc.ul.x = pRect->ul.x + 11;
00116         }
00117         
00118         pFld->rc.ul.y = pRect->ul.y + ii*16;
00119         pFld->rc.br.x = pRect->br.x;
00120         pFld->rc.br.y = pFld->rc.ul.y + 16; 
00121         
00122         pFld++;     
00123     }
00124     
00125     /* Check to display icon and modify field size. ---------------------------*/
00126     if( pList->itemicon != ITEM_NO_ICON )
00127     {   
00128         dptr = ( pList->itemicon == ITEM_DIR_ICON)?
00129                 (ULONG)graf_icon_dir: (ULONG)graf_icon_xim_small;
00130         
00131         LCD_graphSize(dptr, &size);
00132         
00133         pFld = &pTmplt->fld[0];
00134         pFld += pList->actvItem;
00135         
00136         pFld->rc.br.x -= ( size.x + 3 );        
00137 
00138         point.x = pFld->rc.br.x + 2;            
00139         point.y = ((pFld->rc.br.y + pFld->rc.ul.y)/2) - (size.y/2);
00140         
00141         LCD_setFrame(&pTmplt->rect);
00142         LCD_loadGraph(&point, dptr);    
00143     } 
00144     else 
00145     {   
00146         /*find out current setting item, and add checkbox*/
00147         if(*(pList->pValue) >= (pList->topItem))
00148         {
00149             ii = *(pList->pValue)-(pList->topItem);
00150         
00151             //MENU_assert(ii<=5, MENU__CREATELISTMENU);
00152             if(ii < MENU_MAXITEMPERSCREEN)
00153             {           
00154                 pFld = &pTmplt->fld[ii];
00155                 
00156                 dptr = (ULONG)graf_icon_dir;
00157                 LCD_graphSize(dptr, &size);
00158     
00159                 point.x = 2;
00160                 point.y = ((pFld->rc.br.y + pFld->rc.ul.y)/2) - (size.y/2);
00161                 
00162                 LCD_setFrame(&pTmplt->rect);
00163                 LCD_loadGraph(&point, dptr);    
00164             }
00165         }
00166     }   
00167     
00168     /* Start to display items. ------------------------------------------------*/
00169     pFld = &pTmplt->fld[0];
00170     jj = (pList->btmItem - pList->topItem);
00171     for(ii = 0; ii <= jj; ii++)
00172     {       
00173         pFld->dptr = pList->getDptr((UINT)(pList->topItem + ii ), pList->getDptrCtl);
00174         LCD_printFld(pFld++, NULL);
00175     }
00176     
00177     // Set up scrolling control.
00178     #ifndef NO_TEXT_SCROLLING
00179     pFld = &pTmplt->fld[pList->actvItem];
00180     pFld->dptr = 
00181     #endif
00182     
00183     // Get the active item data pointer again, this is to set up the data buffer
00184     // thus it always contains the display data of active item.
00185     pList->getDptr((UINT)(pList->topItem+pList->actvItem ), pList->getDptrCtl );
00186     
00187     #ifndef NO_TEXT_SCROLLING
00188     {
00189         st_LCDINFO      info;
00190         
00191         LCD_printFld(pFld, &info);
00192         if(info.num + 2 < LCD__dataLen(pFld->dptr) )
00193         {
00194             // Scroll needed.
00195             pList->scrollCount = 7;
00196             TMR_create(TMR_TXTSCROLL, 20, TTXTSCROLL, 0, AUTO_RELOAD);
00197         }
00198         else
00199         {
00200             pList->scrollCount = -1;
00201             TMR_delete(TMR_TXTSCROLL);
00202         }
00203     }
00204     #endif
00205     
00206     /* Highlight selected item. -----------------------------------------------*/
00207     rect.ul.x = pRect->ul.x;
00208     rect.br.x = pRect->br.x;
00209     rect.ul.y = pRect->ul.y + pList->actvItem*16;
00210     rect.br.y = rect.ul.y + 16;
00211     LCD_invRect(&rect);
00212     
00213     /* Check to create scroll bar ---------------------------------------------*/
00214     if( (pList->itemNum-1) > MENU_MAXITEMPERSCREEN )
00215     {   
00216         /* A scroll bar is needed. Let's set up SBAR controls. */
00217         point.x = pRect->br.x + 1;
00218         point.y = pRect->ul.y - 2;
00219 
00220         rect.ul.x = 0;
00221         rect.ul.y = 0;
00222         rect.br.x = SB_DEFAULTWIDTH;
00223         rect.br.y = pRect->br.y - pRect->ul.y + 4;
00224 
00225         sbar = MENU__sbarInit(  
00226                     menu, 
00227                     &point, 
00228                     &rect, 
00229                     1, 
00230                     (UINT)(pList->actvItem+pList->topItem), 
00231                     (UINT)(pList->itemNum - 1), 
00232                     (UINT)(MENU_MAXITEMPERSCREEN), 
00233                     VERT_SBAR);
00234 
00235         pTmplt->sbar = sbar;  
00236     }
00237     else pTmplt->sbar = INVALID_SBAR_HDL;
00238 }

Here is the call graph for this function:

void MENU__listMenuAction HMENU  menu,
MENUACTION  actID
 

Function serves as the list MENU action handle.

Parameters:
menu Menu handle.
actID List menu action ID.

Definition at line 249 of file MENU__listMenu.c.

References st_LISTMENU::actvItem, st_RECT::br, st_LISTMENU::btmItem, st_FIELD::dptr, st_MENUTMPLT::fld, st_LISTMENU::getDptr, st_LISTMENU::getDptrCtl, st_LISTMENU::itemicon, st_LISTMENU::itemNum, LCD__loadData(), LCD_drawRect(), LCD_graphSize(), LCD_invRect(), LCD_printFld(), LCD_scroll(), LCD_setBrush(), LCD_setFrame(), LCD_setPen(), MENU_2NEXT, MENU_2PREV, MENU__createListMenu(), MENU__sbarDelete(), MENU__sbarReposition(), MENU_JUMPUP, MENU_SELECT, MENU_TNEXT, MENU_TPREV, MENU_TSELECT, MENU_TXTSCROLL, MENUACTION, st_LCDINFO::num, st_LISTMENU::pActvItem, st_LISTMENU::pValue, st_FIELD::rc, st_LISTMENU::rect, st_MENUTMPLT::rect, st_MENUTMPLT::sbar, SC_VERT, st_LISTMENU::scrollCount, st_MENUTMPLT::share, st_MENU_REGIST::tmplt, st_LISTMENU::topItem, st_RECT::ul, st_POINT::x, st_SYSPARAM::x_scrollwrap, and st_POINT::y.

00250 {
00251     st_MENUTMPLT *  pTmplt;
00252     st_LISTMENU *   pList;
00253     MENUACTION      jumpID = (MENUACTION)(actID&0xC000);
00254     st_FIELD *      pFld;
00255     st_RECT         rect;
00256     st_POINT        point;
00257     UINT            step;
00258     ULONG           dptr;
00259     st_SIZE         size;
00260     USHORT          ii;
00261     BOOL            bRefresh = TRUE;
00262     
00263     /* Load display pattern template. ----------------------------------------*/
00264     pTmplt = &MENU_regist[menu].tmplt;
00265     pList  = (st_LISTMENU *)&pTmplt->share;
00266     
00267     #ifndef NO_TEXT_SCROLLING
00268     if(MENU_TXTSCROLL == actID)
00269     {
00270         if(-1 != pList->scrollCount)
00271         {
00272             if(++pList->scrollCount >= 8)
00273             {
00274                 st_LCDINFO      info;
00275                 unsigned short  buf[LCD_STR_DATABUF_SZ];
00276                 unsigned short  offset;
00277                 
00278                 if(pList->scrollCount >= 0x7fff)
00279                 {
00280                     pList->scrollCount = 0;
00281                     offset = 0;
00282                 }
00283                 else offset = pList->scrollCount-8;
00284 
00285                 pFld = &pTmplt->fld[pList->actvItem];
00286                 pFld->dptr = pList->getDptr((UINT)(pList->topItem+pList->actvItem ), 
00287                             pList->getDptrCtl);
00288 
00289                 LCD__loadData(buf, LCD_STR_DATABUF_SZ, pFld->dptr+offset/2);
00290                 pFld->dptr = (unsigned long)buf+(offset&0x01);
00291 
00292                 LCD_setPen(NULL);
00293                 LCD_setBrush(NULL);
00294                 LCD_drawRect(&pFld->rc);
00295                 LCD_printFld(pFld, &info);
00296                 LCD_invRect(&pFld->rc);
00297                 if(info.num + 12 >= LCD__dataLen(pFld->dptr) )
00298                 {
00299                     pList->scrollCount = 0x7fff;
00300                 }
00301             }
00302         }
00303         return;
00304     }   
00305     #endif
00306     
00307     if( MENU_TPREV == actID)
00308     {
00309         actID = MENU_2PREV;
00310         bRefresh = FALSE;   
00311     }
00312     else if(MENU_TNEXT == actID)
00313     {
00314         actID = MENU_2NEXT;
00315         bRefresh = FALSE;
00316     }
00317     else if(MENU_TSELECT == actID)
00318     {
00319         actID = MENU_SELECT;
00320         bRefresh = FALSE;
00321     }
00322     
00323     if( jumpID )
00324     {
00325         /* Fetch step. */
00326         step = actID & 0x3FF;
00327 
00328         /* Clear the entrire MENU display area. */
00329         LCD_setBrush(NULL); 
00330         LCD_setPen(NULL);   
00331         LCD_drawRect(&pTmplt->rect);
00332         
00333         /* If scroll bar present, release it. */
00334         if(pTmplt->sbar != INVALID_SBAR_HDL)
00335         {
00336             MENU__sbarDelete(pTmplt->sbar);
00337         }
00338 
00339         if(MENU_JUMPUP == jumpID)
00340         {
00341             while(step--)
00342             {
00343                 if(pList->actvItem == 0)
00344                 {
00345                     if(pList->topItem == 1) 
00346                     {
00347                         if (sysParam.x_scrollwrap == XTRA_ON)
00348                         {
00349                             pList->btmItem = pList->itemNum - 1;
00350                             pList->topItem = (pList->itemNum > MENU_MAXITEMPERSCREEN )?
00351                                                 pList->itemNum - MENU_MAXITEMPERSCREEN : 1;
00352                             pList->actvItem = pList->btmItem - pList->topItem;
00353                         }
00354                         continue;   
00355                     }
00356     
00357                     pList->btmItem--;
00358                     pList->topItem--;
00359                 }
00360                 else pList->actvItem--;
00361             }   
00362         }
00363         else
00364         {           
00365             while(step--)
00366             {
00367                 if( ++pList->actvItem > (pList->btmItem - pList->topItem)) 
00368                 {   
00369                     pList->actvItem--;  
00370                     if(pList->btmItem == (pList->itemNum - 1)) 
00371                     {   
00372                         if (sysParam.x_scrollwrap == XTRA_ON)
00373                         {
00374                             pList->topItem = 1; 
00375                             pList->btmItem = (pList->itemNum > MENU_MAXITEMPERSCREEN )?
00376                                                 MENU_MAXITEMPERSCREEN : pList->itemNum - 1;
00377                             pList->actvItem = 0;
00378                         }
00379                         continue;                       
00380                     }
00381     
00382                     pList->topItem++;                   
00383                     pList->btmItem++;
00384                 }           
00385             }       
00386         }   
00387         
00388         *(pList->pActvItem) = pList->actvItem + pList->topItem;
00389         MENU__createListMenu(menu);     
00390         return;
00391     }
00392     
00393     switch ( actID ) 
00394     {       
00395         case MENU_2PREV:
00396             if(pList->actvItem == 0)
00397             {
00398                 if(pList->topItem == 1) 
00399                 {
00400                     pList->btmItem = pList->itemNum - 1;
00401                     pList->topItem = (pList->itemNum > MENU_MAXITEMPERSCREEN )?
00402                                         pList->itemNum - MENU_MAXITEMPERSCREEN : 1;
00403                     pList->actvItem = pList->btmItem - pList->topItem;
00404 
00405                     /* If scroll bar present, release it. */
00406                     if(pTmplt->sbar != INVALID_SBAR_HDL)
00407                     {           
00408                         MENU__sbarDelete(pTmplt->sbar);
00409                     }
00410                     
00411                     /* Clear the entrire MENU display area. */
00412                     LCD_setBrush(NULL);
00413                     LCD_setPen(NULL);
00414                     LCD_drawRect(&pTmplt->rect);
00415 
00416                     *(pList->pActvItem) = pList->actvItem + pList->topItem;
00417                     MENU__createListMenu(menu);                 
00418                     
00419                     return;
00420                 }
00421 
00422                 pList->btmItem--;
00423                 pList->topItem--;
00424                 
00425                 if(TRUE == bRefresh)
00426                 {
00427                     /* Scroll down. */
00428                     LCD_setBrush(NULL);
00429                     LCD_scroll( &pList->rect, NULL, SC_VERT, -16);
00430                 
00431                     /* Reposition scroll bar. -------------------------------------*/
00432                     MENU__sbarReposition(pTmplt->sbar, (short)( pList->topItem - 1));   
00433                 }
00434             }
00435             else pList->actvItem--;
00436             
00437             if(TRUE == bRefresh) _displayActiveListItem(pTmplt, -1);
00438             else pList->getDptr((UINT)(pList->topItem + pList->actvItem), pList->getDptrCtl );
00439             break;
00440             
00441         case MENU_2NEXT:            
00442             if( ++pList->actvItem > (pList->btmItem - pList->topItem)) 
00443             {
00444                 pList->actvItem--;
00445                 if(pList->btmItem == (pList->itemNum - 1)) 
00446                 {
00447                     pList->topItem = 1;
00448                     pList->btmItem = (pList->itemNum > MENU_MAXITEMPERSCREEN )?
00449                                         MENU_MAXITEMPERSCREEN : pList->itemNum - 1;                 
00450                     pList->actvItem = 0;
00451 
00452                     /* If scroll bar present, release it. */
00453                     if(pTmplt->sbar != INVALID_SBAR_HDL)
00454                     {           
00455                         MENU__sbarDelete(pTmplt->sbar);
00456                     }
00457                     
00458                     /* Clear the entrire MENU display area. */
00459                     LCD_setBrush(NULL);
00460                     LCD_setPen(NULL);
00461                     LCD_drawRect(&pTmplt->rect);
00462                     
00463                     *(pList->pActvItem) = pList->actvItem + pList->topItem;
00464                     MENU__createListMenu(menu);                 
00465                     return;
00466                 }
00467 
00468                 pList->topItem++;               
00469                 pList->btmItem++;
00470                 
00471                 if(TRUE == bRefresh)
00472                 {
00473                     /* Scroll up. */
00474                     LCD_setBrush(NULL);
00475                     LCD_scroll( &pList->rect, NULL, SC_VERT,    16);
00476                     
00477                     /* Reposition scroll bar. -------------------------------------*/
00478                     MENU__sbarReposition(pTmplt->sbar, (short)(pList->actvItem + pList->topItem ));                 
00479                 }
00480             }           
00481             
00482             if(TRUE == bRefresh) _displayActiveListItem(pTmplt, 1);
00483             else pList->getDptr((UINT)(pList->topItem + pList->actvItem), pList->getDptrCtl );
00484             break;  
00485 
00486         case MENU_SELECT:
00487 
00488             /* Refresh current menu */
00489             if( (pList->itemicon == ITEM_NO_ICON)&&(TRUE == bRefresh) )
00490             {       
00491                 // remove previous seted item's check box. 
00492                 if(pList->actvItem != (*pList->pValue - pList->topItem))
00493                 {               
00494                     if( *(pList->pValue) >= pList->topItem )
00495                     {
00496                         ii = (*pList->pValue) - (pList->topItem);
00497                         //MENU_assert(ii<=5, MENU__LISTMENUACTION);
00498                         //if(ii >= 0 && ii <= 5)
00499                         {                   
00500                             pFld = &pTmplt->fld[ii];
00501                             
00502                             dptr = (ULONG)graf_icon_dir;            
00503                             LCD_graphSize(dptr, &size);
00504                             
00505                             rect.ul.x = 2;
00506                             rect.ul.y = ((pFld->rc.br.y + pFld->rc.ul.y)/2) - (size.y/2);
00507                             rect.br.x = rect.ul.x + size.x - 1;  
00508                             rect.br.y = rect.ul.y + size.y - 1;
00509                             
00510                             LCD_setBrush(NULL);
00511                             LCD_setPen(NULL);
00512                             LCD_drawRect(&rect);
00513                         }
00514                     }
00515                 }
00516         
00517                 // add check box ahead of current item,and invert it.
00518                 pFld = &pTmplt->fld[pList->actvItem];//Points to the active item. 
00519                 
00520                 dptr = (ULONG)graf_icon_dir;
00521                 LCD_graphSize(dptr, &size);
00522                 
00523                 point.x = 2;
00524                 point.y = ((pFld->rc.br.y + pFld->rc.ul.y)/2) - (size.y/2);
00525                 LCD_setFrame(&pTmplt->rect);
00526                 LCD_loadGraph(&point, dptr);
00527         
00528                 // invert check box
00529                 rect.ul.x = point.x;
00530                 rect.ul.y = point.y;
00531                 rect.br.x = rect.ul.x + size.x - 1;  
00532                 rect.br.y = rect.ul.y + size.y - 1;
00533                 LCD_invRect(&rect);
00534             }
00535             
00536             /* Set value. */
00537             *pList->pValue = pList->actvItem + pList->topItem;
00538             break;   
00539     }   
00540     
00541     *(pList->pActvItem) = pList->actvItem + pList->topItem;
00542 }

Here is the call graph for this function:


Generated on Wed Jan 19 01:13:09 2005 for neuros-firmware by  doxygen 1.3.9.1