Beispiel #1
0
/************************************************************************
 Function: BYTE ShowNextSlide(void)
                                                                       
 Overview: Display the next image when slide show is enabled.
 		                                          
 Input: none
                                                                       
 Output: Returns the status if at the end of the list.
************************************************************************/
BYTE ShowNextSlide(void)
{
    BYTE        temp = NextSlide;
    IMG_FILE    *pImgFile;

    if(NextSlide == 0xFF || NextSlide >= bNumElementsInFolder)
    {
        return (0);
    }

    while(aFolderElement[NextSlide].blFolder == 1 || aFolderElement[NextSlide].blText == 1)
    {
        NextSlide = (NextSlide + 1) % bNumElementsInFolder;
        if(NextSlide == temp)
        {
            return (0);
        }
    }

    pImgFile = IMG_FOPEN(aFolderElement[NextSlide].Name, "rb");
    if(pImgFile != NULL)
    {
        if
        (
            ImageDecode
                (
                    pImgFile,
                    aFolderElement[NextSlide].ImgType,
                    0,
                    0,
                    IMG_SCREEN_WIDTH,
                    IMG_SCREEN_HEIGHT,
                    (IMG_DOWN_SCALE | IMG_ALIGN_CENTER),
                    NULL,
                    NULL
                )
        )
        {
            DisplayErrorInfo();
        }

        IMG_FCLOSE(pImgFile);
        NextSlide = (NextSlide + 1) % bNumElementsInFolder;
        return (1);
    }

    return (0);
}
Beispiel #2
0
/************************************************************************
 Function: WORD JPEGMsgCallback(WORD objMsg, OBJ_HEADER* pObj, 
 								GOL_MSG* pMsg)

 Overview: This function is called by GOLMsg() function when in this 
 		   particular demo each time the valid message is received for the 
  		   objects in the demo.
           
 Input: objMsg - translated message for the object,
        pObj - pointer to the object,
        pMsg - pointer to the non-translated, raw GOL message 

 Output: If the function returns non-zero the message will 
 		 be processed by the object directly affected by the message.
 		 Default action on the object based on the message will be 
 		 performed.
************************************************************************/
WORD JPEGMsgCallback(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
{
    LISTITEM    *pItemSel;

    // check if an image is being shown
    if((blImageOnScreen == 1) || (blSlideShowOn == 1))
    {

        // this is the routine to go back and show the list when an
        // image is being shown on the screen or the slide show is
        // currently ongoing
        if(pMsg->uiEvent == EVENT_RELEASE)
        {
            blImageOnScreen = 0;
            blSlideShowOn = 0;
            GOLRedrawRec(0, 0, GetMaxX(), GetMaxY());
        }

        return (0);
    }

    switch(GetObjID(pObj))
    {
        case ID_BUTTON_A:
            if(objMsg == BTN_MSG_RELEASED)
            {   // check if button is pressed
                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);
                screenState = CREATE_DEMOSELECTION;
            }

            return (1);

        case ID_BUTTON_D:
            if(objMsg == BTN_MSG_RELEASED)
            {   // check if button is pressed
                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);

                // enable the slide show
                blSlideShowOn = 1;
				// initialize the screen	
				SetColor(BLACK);
    			ClearDevice();

                ClrState(pObj, BTN_PRESSED);            // clear the pressed state, will be shown only when redrawn
                blSlideShowDelay = 0;                   // force slide show to immediately start
                return (0);
            }

            return (1);

        case ID_JPGLISTBOX:
            if(pMsg->uiEvent == EVENT_MOVE)
            {
                pMsg->uiEvent = EVENT_PRESS;            // change event for listbox

                // Process message by default
                LbMsgDefault(objMsg, (LISTBOX *)pObj, pMsg);

                // Set new list box position
                SldSetPos(pSlider, LbGetCount(pListBox) - LbGetFocusedItem(pListBox) - 1);
                SetState(pSlider, SLD_DRAW_THUMB);
                pMsg->uiEvent = EVENT_MOVE;             // restore event for listbox
            }
            else if(pMsg->uiEvent == EVENT_PRESS)
            {

                // call the message default processing of the list box to select the item
                LbMsgDefault(objMsg, (LISTBOX *)pObj, pMsg);
            }
            else if(pMsg->uiEvent == EVENT_RELEASE)
            {

                // check which item was selected and display appropriate screen
                pItemSel = LbGetSel(pListBox, NULL);    // get the selected item
                if(aFolderElement[pItemSel->data].blFolder == 1)
                {
                    if(FSchdir(aFolderElement[pItemSel->data].Name) == 0)
                    {
                        FillNewElements();
                        return (1);
                    }
                }
                else if(aFolderElement[pItemSel->data].blText == 0)
                {
                    IMG_FILE    *pImgFile = IMG_FOPEN(aFolderElement[pItemSel->data].Name, "rb");
                    if(pImgFile != NULL)
                    {
                        blImageOnScreen = 1;
                        // initialize the screen	
					    SetColor(BLACK);
    					ClearDevice();

                        if
                        (
                            ImageDecode
                                (
                                    pImgFile,
                                    aFolderElement[pItemSel->data].ImgType,
                                    0,
                                    0,
                                    IMG_SCREEN_WIDTH,
                                    IMG_SCREEN_HEIGHT,
                                    (IMG_DOWN_SCALE | IMG_ALIGN_CENTER),
                                    NULL,
                                    NULL
                                )
                        )
                        {
                            DisplayErrorInfo();
                        }

                        IMG_FCLOSE(pImgFile);
                    }
                }
            }

            // The message was processed. To avoid other objects processing the 
            // processed message reset the message.
            pMsg->uiEvent = EVENT_INVALID;
            return (0);

        case ID_SLD4LB:
        	
        	if((objMsg == SLD_MSG_INC) || (objMsg == SLD_MSG_DEC)) 
            {   // check slider was touched.

	            // Process message by default
	            SldMsgDefault(objMsg, (SLIDER *)pObj, pMsg);
	
	            // Set new list box position
	            if(LbGetFocusedItem(pListBox) != LbGetCount(pListBox) - SldGetPos(pSlider))
	            {
	                LbSetFocusedItem(pListBox, LbGetCount(pListBox) - SldGetPos(pSlider));
	                SetState(pListBox, LB_DRAW_ITEMS);
	            }
	            
	        }

            // The message was processed
            return (0);

        case ID_BTNUP4LB:                               // slider up button was pressed
            if(objMsg == BTN_MSG_RELEASED)
            {
				// check if we have reached the very first then stay there.
	            if (LbGetFocusedItem(pListBox) == 0)
	                LbSetFocusedItem(pListBox,0);
	            else    
                	LbSetFocusedItem(pListBox,LbGetFocusedItem(pListBox)-1);                
                SetState(pListBox, LB_DRAW_ITEMS);
                SldSetPos(pSlider, SldGetPos(pSlider) + 1);
                SetState(pSlider, SLD_DRAW_THUMB);
            }

            return (1);

        case ID_BTNDN4LB:                               // slider down button was pressed
            if(objMsg == BTN_MSG_RELEASED)
            {
	            // set all items to be not displayed
                pItemSel = pListBox->pItemList;
                while(pItemSel != NULL) {
                	pItemSel->status = 0;
                	pItemSel = pItemSel->pNextItem;
                }	
                LbSetFocusedItem(pListBox, LbGetFocusedItem(pListBox) + 1);
                SetState(pListBox, LB_DRAW_ITEMS);
                SldSetPos(pSlider, SldGetPos(pSlider) - 1);
                SetState(pSlider, SLD_DRAW_THUMB);
            }

            return (1);
    }

    return (1);
}
Beispiel #3
0
void PagingDemo(void)
{

  int        x,y;
  GFX_XCHAR      Scroll[] = {'C','o','l','o','r','s',' ','C','h','a','n','g','e',' ','w',' ','T','e','m','p','s',0};
  GFX_XCHAR      Cloud[] = {'C','l','o','u','d','y',0};
  GFX_XCHAR      Temper[] = {'T','e','m','p','e','r','a','t','u','r','e',0};
  GFX_XCHAR      SetTemp[] = {'S','e','t',' ','T','e','m','p',0};
  GFX_XCHAR      Time[] = {'8',':','2','0',' ','P','M',0};
  GFX_XCHAR      Date[] = {'J','u','n','e',' ','1','1',',',' ','2','0','1','2',0};
  GFX_XCHAR      Room[] = {'7','4',0};

              while(GFX_PageSet(ACTIVE_PAGE,PIP_BUFFER) == GFX_STATUS_FAILURE);
              GFX_GradientColorSet(GFX_RGBConvert(55,0,0),BLACK);
              GFX_GradientTypeSet(GFX_FILL_STYLE_GRADIENT_DOWN);
              while(GFX_BarGradientDraw(0,0,GFX_MaxXGet(),55) == GFX_STATUS_FAILURE);
              GFX_ColorSet(WHITE);

              GFX_FontSet((void *) &Monospaced_plain_36);
              while(GFX_TextStringBoxDraw(0,0,0,0,(GFX_XCHAR*)Scroll,0,GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);

  GFX_XCHAR Temp[] ={'7','3',0};

for(x=0;x<2;x++)        
{  

  while(GFX_PageSet(ACTIVE_PAGE,x) == GFX_STATUS_FAILURE);

  if(x==0)
  {
     GFX_GradientColorSet(BRIGHTRED,BLACK);
     while(GFX_BarGradientDraw(0,0,GFX_MaxXGet(),GFX_MaxYGet())== GFX_STATUS_FAILURE);
  }
  else
  {
      GFX_GradientColorSet(BRIGHTBLUE,BLACK);
      while(GFX_BarGradientDraw(0,0,GFX_MaxXGet(),GFX_MaxYGet()) == GFX_STATUS_FAILURE);
  }

  GFX_GradientColorSet(WHITE,BLACK);
  while(GFX_BevelGradientDraw(340,120,370,140,10) == GFX_STATUS_FAILURE);
  while(GFX_BevelGradientDraw(340,165,370,185,10) == GFX_STATUS_FAILURE);
  GFX_ColorSet(WHITE);
  GFX_FontSet((void *) &Gentium_16);
  while(GFX_TextStringBoxDraw(50,75,0,0,(GFX_XCHAR*)Cloud,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
  while(GFX_TextStringBoxDraw(190,75,0,0,(GFX_XCHAR*)Temper,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
  while(GFX_TextStringBoxDraw(380,75,0,0,(GFX_XCHAR*)SetTemp,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);

   GFX_ColorSet(WHITE);
   while(GFX_TextStringBoxDraw(GFX_MaxXGet()-80,0,0,0,(GFX_XCHAR*)Time,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
   while(GFX_TextStringBoxDraw(10,0,0,0,(GFX_XCHAR*)Date,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);

   GFX_FontSet((void *) &Monospaced_plain_36);
   while(GFX_TextStringBoxDraw(345,100,0,0,(GFX_XCHAR*)"+",0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
   while(GFX_TextStringBoxDraw(345,145,0,0,(GFX_XCHAR*)"-",0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);

   GFX_FontSet((void *) &Monospaced_bold_Bold_72);

  if(x==0)
  { 
    while(GFX_TextStringBoxDraw(210,100,0,0,(GFX_XCHAR*)Temp,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);   //Room Temp
  }

  while(GFX_TextStringBoxDraw(385,100,0,0,(GFX_XCHAR*)Room,0, GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);

        while(ImageDecode
        (                                              
            (void *)&clouds,
            IMG_JPEG,                          
            10,                              
            100,
            10 + clouds_WIDTH,
            100 + clouds_HEIGHT,
            0,                                 
            &_jpegFileApi,                     
            NULL                   
        ) == 0xff);

}

  while(GFX_PageSet(ACTIVE_PAGE,0) == GFX_STATUS_FAILURE);
  while(GFX_PageSet(VISUAL_PAGE,0) == GFX_STATUS_FAILURE);

  while(GFX_Layer(0, SET_PAGE, PIP_BUFFER, 0) == GFX_STATUS_FAILURE);
  while(GFX_Layer(0, SET_SIZE, GFX_MaxXGet()-10, 55) == GFX_STATUS_FAILURE);
  while(GFX_Layer(0, SET_PAGE_START, 0, GFX_MaxYGet()-56) == GFX_STATUS_FAILURE);
  while(GFX_Layer(0, SET_LAYER_START, 0, 0) == GFX_STATUS_FAILURE);

  SYS_TMR_DelayMS(1000);
  x=0;

  while(x++ < 3)
  {
       while(GFX_Layer(0, DISABLE, 0, 0) == GFX_STATUS_FAILURE);
       SYS_TMR_DelayMS(500);
       while(GFX_Layer(0, ENABLE, 0, 0) == GFX_STATUS_FAILURE);
       SYS_TMR_DelayMS(500);
  }

  x = 0;

  while(x++ < 465)
  {
     while(GFX_Layer(0, SET_LAYER_START, x, 0) == GFX_STATUS_FAILURE);
     while(GFX_Layer(0, SET_SIZE, GFX_MaxXGet()-10-x, 55) == GFX_STATUS_FAILURE);
     while(GFX_Layer(0, UPDATE, 0, 0) == GFX_STATUS_FAILURE);
     SYS_TMR_DelayMS(10);
  }

  while(GFX_Layer(0, DISABLE, 0, 0) == GFX_STATUS_FAILURE);
  GFX_ColorSet(WHITE);

 for(x=0;x<1;x++)
 {
  Temp[1] += 1; SYS_TMR_DelayMS(1000);
  GFX_GradientColorSet(GFX_RGBConvert(148,0,0),BLACK);
  GFX_GradientTypeSet(GFX_FILL_STYLE_GRADIENT_DOWN);
  while(GFX_BarGradientDraw(250,116,300,GFX_MaxYGet()) == GFX_STATUS_FAILURE);
  GFX_ColorSet(WHITE);
  GFX_FontSet((void *) &Gentium_16);
  while(GFX_TextStringBoxDraw(190,75,0,0,(GFX_XCHAR*)Temper,0,GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
  GFX_FontSet((void *) &Monospaced_bold_Bold_72);
  while(GFX_TextStringBoxDraw(210,100,0,0,(GFX_XCHAR*)Temp,0,GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
  } 

  while(GFX_PageSet(ACTIVE_PAGE,1) == GFX_STATUS_FAILURE);
  while(GFX_TextStringBoxDraw(210,100,0,0,(GFX_XCHAR*)Temp,0,GFX_ALIGN_LEFT) == GFX_STATUS_FAILURE);
  while(GFX_PageSet(VISUAL_PAGE,1) == GFX_STATUS_FAILURE);

  SYS_TMR_DelayMS(2000);
  while(GFX_PageSet(ACTIVE_PAGE, 0) == GFX_STATUS_FAILURE);
  while(GFX_PageSet(VISUAL_PAGE, 0) == GFX_STATUS_FAILURE);
  GFX_ColorSet(WHITE);
  while(GFX_ScreenClear() == GFX_STATUS_FAILURE);

}