Example #1
0
static void CalcPositions( FRAMEWIN_Handle hObj) {
  if (hObj) {
    FRAMEWIN_Obj * pObj = FRAMEWIN_H2P(hObj);
    int TitleHeight;
    int FontSize = GUI_GetYSizeOfFont(pObj->pFont);
    int xsize = WM_GetWindowSizeX(hObj);
    int ysize = WM_GetWindowSizeY(hObj);
    TitleHeight = _DefaultCaptionSize;
    /* Make sure defaults are o.k. for us */
    if (FontSize + 2 >= TitleHeight)
      TitleHeight = FontSize + 2;
    /* Set object properties accordingly */
    pObj->rClient.x0  =         _DefaultBorderSize;
    pObj->rClient.x1  = xsize - _DefaultBorderSize - 1;
    pObj->rClient.y0  =         _DefaultBorderSize + FRAMEWIN_IBORDER_DEFAULT + TitleHeight;
    pObj->rClient.y1  = ysize - _DefaultBorderSize - 1;
    pObj->FrameSize   =         _DefaultBorderSize;
    pObj->TitleHeight = TitleHeight;
    if (pObj->hClient) {
      WM_MoveTo (pObj->hClient, 
                 pObj->rClient.x0 + pObj->Widget.Win.Rect.x0, 
                 pObj->rClient.y0 + pObj->Widget.Win.Rect.y0);
      WM_SetSize(pObj->hClient, 
                 pObj->rClient.x1 - pObj->rClient.x0 + 1, 
                 pObj->rClient.y1 - pObj->rClient.y0 + 1);
    }
  }  
}
Example #2
0
/*********************************************************************
*
*       DROPDOWN__AdjustHeight
*/
void DROPDOWN__AdjustHeight(DROPDOWN_Handle hObj, DROPDOWN_Obj* pObj) {
  int Height;
  Height = pObj->TextHeight;
  if (!Height) {
    Height = GUI_GetYDistOfFont(pObj->Props.pFont);
  }
  Height += pObj->Widget.pEffect->EffectSize + 2 *  pObj->Props.TextBorderSize;
  WM_SetSize(hObj, WM__GetWindowSizeX(&pObj->Widget.Win), Height);
}
/*********************************************************************
*
*       _RestoreMaximized
*/
static void _RestoreMaximized(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) {
  /* When window was maximized, restore it */
  if (pObj->Flags & FRAMEWIN_SF_MAXIMIZED) {
    GUI_RECT r = pObj->rRestore;
    WM_MoveTo(hObj, r.x0, r.y0);
    WM_SetSize(hObj, r.x1 - r.x0 + 1, r.y1 - r.y0 + 1);
    FRAMEWIN__UpdatePositions(pObj);
    pObj->Flags &= ~FRAMEWIN_SF_MAXIMIZED;
    _InvalidateButton(pObj, GUI_ID_MAXIMIZE);
  }
}
Example #4
0
/*********************************************************************
*
*       _AddScrollbar
*/
static void _AddScrollbar(MULTIPAGE_Handle hObj, MULTIPAGE_Obj* pObj, int x, int y, int w, int h) {
  SCROLLBAR_Handle hScroll;
  if ((hScroll = WM_GetScrollbarH(hObj)) == 0) {
    hScroll = SCROLLBAR_Create(x, y, w, h, hObj, GUI_ID_HSCROLL, WM_CF_SHOW, 0);
    WIDGET_SetEffect(hScroll, pObj->Widget.pEffect);
  } else {
    WM_MoveChildTo(hScroll, x, y);
    WM_SetSize(hScroll, w, h);
  }
  pObj->Widget.State |= MULTIPAGE_STATE_SCROLLMODE;
}
/*********************************************************************
*
*       _MaximizeFramewin
*/
static void _MaximizeFramewin(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) {
  _RestoreMinimized(hObj, pObj);
  /* When window is not maximized, maximize it */
  if ((pObj->Flags & FRAMEWIN_SF_MAXIMIZED) == 0) {
    WM_HWIN hParent = pObj->Widget.Win.hParent;
    WM_Obj* pParent = WM_H2P(hParent);
    GUI_RECT r = pParent->Rect;
    if (pParent->hParent == 0) {
      r.x1 = LCD_GetXSize();
      r.y1 = LCD_GetYSize();
    }
    pObj->rRestore = pObj->Widget.Win.Rect;
    WM_MoveTo(hObj, r.x0, r.y0);
    WM_SetSize(hObj, r.x1 - r.x0 + 1, r.y1 - r.y0 + 1);
    FRAMEWIN__UpdatePositions(pObj);
    pObj->Flags |= FRAMEWIN_SF_MAXIMIZED;
    _InvalidateButton(pObj, GUI_ID_MAXIMIZE);
  }
}
/**
  * @brief  Callback function of the image frame
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbImageWindow(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem;
  GUI_RECT r;
  int Id;
  const GUI_PID_STATE * pState;

  switch (pMsg->MsgId)
  {
  case  WM_TOUCH:
    pState = (const GUI_PID_STATE *)pMsg->Data.p;

    if(pImageList->ptr > 0)
    {
      if (pState) {
        if (pState->Pressed == 1)
        {
          IMAGE_Enlarge ^= 1;
          if (IMAGE_Enlarge)
          {
            WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 6, 6);
            WM_SetSize(pMsg->hWin, 220, 134);
          }
          WM_InvalidateWindow(pMsg->hWin);
        }
      }
    }
    break;


  case WM_PAINT:
    WM_GetInsideRect(&r);
    GUI_ClearRectEx(&r);
    if (pImageList->ptr > 0)
    {
      if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0)
      {
        f_close(&Image_File);

        GUI_ClearRectEx(&r);
        GUI_DispStringAt("Error : Image cannot be displayed", 20,  80);
        if(hTimerTime != 0)
        {
          slideshow_state = OFF;

          hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);

          WM_DeleteTimer(hTimerTime);
          hTimerTime = 0;

        }
      }
    }
    break;

  case WM_TIMER:

   Id = WM_GetTimerId(pMsg->Data.v);

   if(Id == ID_SLIDER_TIMER)
   {
     if(pImageList->ptr > 1)
     {
       if (file_pos < (pImageList->ptr - 1))
       {
         file_pos++;
       }
       else if (file_pos == (pImageList->ptr - 1))
       {
         file_pos=0;
       }

       if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
       {
         IMAGE_Type = IMAGE_TYPE_BMP;
       }
       else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
       {
         IMAGE_Type = IMAGE_TYPE_JPG;
       }

       f_close(&Image_File);
       f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
       WM_InvalidateWindow(imFrame);
       hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
       LISTBOX_SetSel(hItem, file_pos);
     }

     WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000));
   }
   else if (Id == ID_PLAYLIST_TIMER)
   {
     playlist_select = 0;
   }
   break;

  case WM_DELETE:
    if(hTimerTime != 0)
    {
      WM_DeleteTimer(hTimerTime);
      hTimerTime = 0;
    }
    break;

  default:
    WM_DefaultProc(pMsg);
  }

}
/**
  * @brief  Callback function of the MJPEG frame
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbVideoWindow(WM_MESSAGE * pMsg) 
{
  char temp[20];
  static WM_HTIMER hTimerTime;
  WM_HWIN hItem;  
  const GUI_PID_STATE * pState;
  
  GUI_RECT r;
  WM_GetInsideRect(&r);
  
  switch (pMsg->MsgId) 
  {
    
  case  WM_TOUCH:
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      pState = (const GUI_PID_STATE *)pMsg->Data.p;
      if (pState) {
        if (pState->Pressed == 1) {
          VIDEO_Enlarge ^= 1;
          if(VIDEO_Enlarge)
          {
            GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y);
            TS_Orientation = 1;
            WM_AttachWindowAt(pMsg->hWin, WM_GetDesktopWindowEx(1), 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindow(pMsg->hWin, bkparent);
            GUI_SetOrientation(0);
            TS_Orientation = 0;
            WM_InvalidateWindow(bkparent);    
            
            WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16);
            WM_SetSize(pMsg->hWin,230, 170);
            do_clear = 1;
          }
        }
      }
    }
    break;
    
    
  case WM_CREATE:
    /* Create timer */
    hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0);        
    break;
    
  case WM_TIMER:
    WM_InvalidateWindow(pMsg->hWin);
    WM_RestartTimer(pMsg->Data.v, 0);
    
    break; 
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    break;

    
  case WM_PAINT:
    
    if(do_clear)
    {
      GUI_ClearRectEx(&r);
      do_clear = 0;
    } 
    
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      if(_PlayMJPEG(&Video_File) < 0)
      {
        VideoPlayer_State = VIDEO_PLAY;
        ImageOffset = 0; 
        time_start = GUI_GetTime();    
        f_close(&Video_File);
        goto_next_file();      
        hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE);
        TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);        
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS);
      
      if (progress_bar == 0)
      {
        SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize);
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION);
      
      duration = (GUI_GetTime() - time_start )/1000;
      if(duration < 0) duration = 0;
      sprintf(temp,"%02d:%02d", duration/60, duration%60); 
      TEXT_SetText(hItem, temp);  
    }
    else if(VideoPlayer_State == VIDEO_IDLE)
    {
      GUI_ClearRectEx(&r);
    }
    
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
Example #8
0
static void _cbDialog(WM_MESSAGE * pMsg) {
    int i;
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    gui_msg_t msg;
    msg.exec = RT_NULL;
    
    switch (pMsg->MsgId)
    {
        case WM_INIT_DIALOG:
        hItem = pMsg->hWin;
        WM_EnableMemdev(hItem);
        //WM_MoveTo(hItem, 0, -30);
        //WM_MOTION_SetMoveable(hItem, WM_CF_MOTION_Y, 1);
        WINDOW_SetBkColor(hItem, GUI_WHITE);
        int fd;
        

        /* load APP */
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            hItem = BUTTON_CreateAsChild(10, 10, 50, 50, pMsg->hWin, UIApp[i].GUID, WM_CF_SHOW);
            BUTTON_SetText(hItem, UIApp[i].text);
            WM_EnableMemdev(hItem);
            struct stat s;
            stat(UIApp[i].logoPath, &s);
            
            UIApp[i].plogo = rt_malloc(s.st_size);
            if(UIApp[i].plogo)
            {
                fd = open(UIApp[i].logoPath, O_RDONLY , 0);
                if(fd >=0)
                {
                    rt_kprintf("%s", UIApp[i].logoPath);
                    read(fd, UIApp[i].plogo, s.st_size);

                    
                    //WM_MoveTo(hItem, 0+(i%2)*120, (i/2)*120 + 0);
                    
                    WM_SetSize(hItem, GUI_BMP_GetXSize(UIApp[i].plogo), GUI_BMP_GetYSize(UIApp[i].plogo));
                    //xPos+= xSize;
                    //yPos+= ySize;
                    
                    
                    BUTTON_SetBMPEx(hItem, BUTTON_BI_UNPRESSED, UIApp[i].plogo ,0, 0);
                    BUTTON_SetBMPEx(hItem, BUTTON_BI_PRESSED, UIApp[i].plogo ,1, 1);
                    BUTTON_SetTextOffset(hItem, 0, 50);
                    close(fd);
                }
            }
            else
            {
                rt_kprintf("no mem!\r\n");
            }
        }
        
        /* algin Apps */
        int xPos, yPos, xSize, ySize;
        xPos = 0; xSize = 0;
        yPos = 0; ySize = 0;
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            hItem = WM_GetDialogItem(pMsg->hWin, UIApp[i].GUID);
            xSize = GUI_BMP_GetXSize(UIApp[i].plogo);
            ySize = GUI_BMP_GetYSize(UIApp[i].plogo);
            
            if(xSize == 0 || xSize > 9999)
            {
                xSize = 60;
            }
            if(ySize == 0 || ySize > 9999)
            {
                ySize = 60;
            }
            
            if(abs(LCD_GetXSize() - xPos) >= xSize)
            {
                WM_MoveTo(hItem, xPos, yPos);
                xPos+=xSize;
            }
            else
            {
                xPos = 0;
                yPos+=ySize;
                WM_MoveTo(hItem, xPos, yPos);
                xPos+=xSize; 
            }
        }
    
//        char *p;
//        p = rt_malloc(38399);
//        fd = open("/SD/DESKTOP.JPG",O_RDONLY , 0);
//        read(fd, p, 38399);
//        hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
//        WM_EnableMemdev(hItem);
      //  IMAGE_SetJPEG(hItem, p, 38399);
        break;
    case WM_NOTIFY_PARENT:
        Id = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
    if(NCode == WM_NOTIFICATION_RELEASED)
    {
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            if(Id == UIApp[i].GUID)
            {
                msg.exec = UIApp[i].exec;
                break;
            }
        }
        if(msg.exec != RT_NULL)
        {
            rt_mq_send(guimq, &msg, sizeof(msg));
        }
    }
    break;
    default:
        WM_DefaultProc(pMsg);
        break;
    }
}