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

📄 calenui.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 3 页
字号:
#define CALENDAR_MAIN_FILE

#include "winav.h"
#include "menu.h"
#include "calenui.h"
#include "osdnd.h"
#include "setup.h"
#include "fontindex.h"
#include "cc.h"
#include "poweronmenu.h"
#include "disp.h"
#include "rtcdrv.h"
#include "clock.h"
#include "osd.h"

#ifdef SUPPORT_STB
#include "dvb_sys.h"
#include "ui_lmp.h"
#include "nvram.h"
#endif

#include "OSDString\\strextrn.h"

BYTE _bCALENDARMode;
WORD _wCALENDARUpdateTimePosX;
WORD _wCALENDARUpdateTimePosY;
RTC_TM _CALENDARCurrnetRTCTime;
DWORD _dwCALENDARTriggerTime;

WORD _wCurrentYear;
BYTE _bCurrentMonth, _bCurrentDate;
BYTE _bLastDay;
BYTE _bCalX, _bCalY;
WORD *_pwBuffer=NULL;
WORD _wStartX, _wStartY, _wTotalH, _wTotalW;

WORD _wFocusYear ;
BYTE _bFocusMonth;

BYTE        _bBodyBackColor, _bBodyFront1Color, _bBodyBorderColor;
BYTE        _bHeadBackColor, _bHeadFront1Color, _bHeadFront2Color,_bHeadBorderColor;
BYTE        _bTailBackColor, _bTailFront1Color;  

WIN_PARAMETER stFullScreen;

typedef struct calendaInfo_
{    WORD		u16CalenderYear;    /** : solar year for calender */    
    BYTE         u8CalenderMonth;    /**: solar month for calender */
    BYTE         u8CalenderDate;	    /** : solar date for calender */    
} CALENDAINFO;
CALENDAINFO Calenda_Info;
BYTE  __bCalSelectMenuID;
BYTE  __bCalselectdata=0;
/////////////////////////////////////////////////////////////////////////////////////
#ifdef SUPPORT_SET_DATE_BY_MENU
HMENU _hCALENDARDateMenu = MENU_HANDLE_INVALID;
SETDATE_DATE _CALENDARSetDate;
HDIALOG _hCALENDARDlg = DIALOG_HANDLE_INVALID;
HSETDATE _hCALENDARSetDate = SETDATE_HANDLE_INVALID;
BYTE _bCALENDARExitKey[] = {KEY_LEFT};
#endif //SUPPORT_SET_DATE_BY_MENU
/////////////////////////////////////////////////////////////////////////////////////

WORD aCALENDARColon[] = {1, CHAR_COLON};
//#ifdef NL_SOLUTION
WORD aCALENDARDistance[] = {3, CHAR_SPACE, CHAR_HYPHEN_MINUS, CHAR_SPACE};
//#endif //NL_SOLUTION

WORD aCalenda_Solidus[2] = {1, CHAR_SOLIDUS}; //fhfeng 1012
WORD *aWeeklyDay[7] = 
{
    aWeeklyDay_Sun,
    aWeeklyDay_Mon,
    aWeeklyDay_Tue,
    aWeeklyDay_Wed,
    aWeeklyDay_Thu,
    aWeeklyDay_Fri,
    aWeeklyDay_Sat,     
};

void Calendar_InitialPalEntry(void)
{
    // set entries used by Menu, Setup, Equalizer and AV System
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_TITLE_BG_COLOR, CALENDAR_MENU_VALUE_TITLE_BG_COLOR, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_LARGEFORM_BG_COLOR, CALENDAR_MENU_VALUE_LARGEFORM_BG_COLOR, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_COLOR_DARK, CALENDAR_MENU_VALUE_COLOR_DARK, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_COLOR_HIGHLIGHT, CALENDAR_MENU_VALUE_COLOR_HIGHLIGHT, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_TETRIS_BODY_COLOR, CALENDAR_MENU_VALUE_TETRIS_BODY_COLOR, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_TITLE_BODY_HIGHLIGHT_COLOR, CALENDAR_MENU_VALUE_TITLE_BODY_HIGHLIGHT_COLOR, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_SUNDAY_COLOR, CALENDAR_MENU_VALUE_SUNDAY_COLOR, FALSE);
    GDI_ChangePALEntry(CALENDAR_MENU_ENTRY_SATURDAY_COLOR, CALENDAR_MENU_VALUE_SATURDAY_COLOR, FALSE);
}
void Calendar_DrawString(PPARM_DRAW_STRING pStrAttr, WORD wStartX, WORD wStartY, WORD * pwString)
{
    pStrAttr->wX = wStartX;
    pStrAttr->wY = wStartY;
    GDI_DrawString_909(0, pStrAttr, pwString);
}

void Calendar_OutputNumber(WORD wPosX, WORD wPosY, WORD wNumber, PPARM_DRAW_STRING GmMsg)
{
    OSDUTL_PrepareOutputString();
    OSDUTL_OutputNumFromIndex(wNumber ); 
    Calendar_DrawString(GmMsg,wPosX, wPosY, __wOSDUTLStringBuf);
}

void Calendar_ShowBoxWithArc(WORD wPosX, WORD wPosY, WORD wWidth, WORD wHeight, BYTE bBackCIdx)
{
    PARM_RECT rectArcBox;
    rectArcBox.rect.wLeft = wPosX;
    rectArcBox.rect.wTop = wPosY;
    rectArcBox.rect.wRight = wPosX+wWidth;
    rectArcBox.rect.wBottom = wPosY+wHeight;
    rectArcBox.bColor = bBackCIdx;
    GDI_FillRoundRect(0, 13, &rectArcBox);
}


void Calendar_DrawRect(WORD wPosX, WORD wPosY, WORD wWidth, WORD wHeight, BYTE bColor)
{
    PARM_RECT rectGMRect;
    rectGMRect.bColor = bColor;
    rectGMRect.rect.wLeft = wPosX;
    rectGMRect.rect.wRight = rectGMRect.rect.wLeft + wWidth-1;
    rectGMRect.rect.wTop = wPosY;
    rectGMRect.rect.wBottom = rectGMRect.rect.wTop + wHeight-1;
    GDI_FillRect(0, &rectGMRect);
}

//  ***************************************************************************
//  Function    :   _Calendar_ConfigOSDRegion
//  Description :   
//  Arguments   :   None.
//  Return      :   None.
//  Side Effect :
//  ***************************************************************************
void _Calendar_ConfigOSDRegion(void)
{
    GDI_REGION_INFO RegionInfo;
#ifdef  BORROW_FRAME_BUFFER
    DWORD dwBufferAddr;
#endif //

    GDI_ClearRegion(0);

#ifdef  BORROW_FRAME_BUFFER

    if ((POWERPNMENU_WIDTH == __RegionList[0].wWidth) && (POWERPNMENU_HEIGHT <= __RegionList[0].wHeight) &&
        (GDI_OSD_8B_MODE == __RegionList[0].bColorMode)) 
    {
        return;
    }
    else if (__RegionList[0].bColorMode != GDI_OSD_8B_MODE)   // Thumbnail mode & preview mode
    {
        // Use Frame buffer 1 or 2
        dwBufferAddr = DISP_QueryAvailableBuffer();
        if (0 == dwBufferAddr)
        {
            RegionInfo.dwTAddr = DS_OSDFRAME_ST;
        }
        else
        {
            RegionInfo.dwTAddr = dwBufferAddr;
        }
    } 
    else
    {
        // Use OSD buffer and Frame buffer 0
        RegionInfo.dwTAddr = DS_OSDFRAME_ST;   // Use OSD buffer and Frame buffer 0 
    }

#else
    RegionInfo.dwTAddr = DS_OSDFRAME_ST;
#endif // #ifdef  BORROW_FRAME_BUFFER

    RegionInfo.wWidth = POWERPNMENU_WIDTH;
    RegionInfo.wHeight = POWERPNMENU_HEIGHT;
    RegionInfo.bColorMode = GDI_OSD_8B_MODE;

#ifdef  BORROW_FRAME_BUFFER
    OSD_SetRegion(0, TRUE, &RegionInfo);
#else
    OSD_SetRegion(0, FALSE, &RegionInfo);
#endif
}

void Calendar_GetVisibleScreen(PWIN_PARAMETER pScreenSize)
{
    extern BYTE __bTVType;
    
    if( __bTVType==SETUP_SCREEN_TV_SYSTEM_PAL )
    {
        pScreenSize->sHStart = 8;// must be multiple of 4
        pScreenSize->sVStart= 24;
        //pScreenSize->sVStart= 0;
    }
    else
    {
        pScreenSize->sHStart = 8;// must be multiple of 4
        pScreenSize->sVStart= 0; // 24;
    }
    
    //CoCo1.10, fix the bug about the OSD region exceeds the GDI region.
    pScreenSize->wHWidth = GDI_REGION_WIDTH; //624;// must be multiple of 4
    pScreenSize->wVWidth = GDI_REGION_HEIGHT;//78L
    
    return ;
}
static BYTE Calendar_GetLeap( WORD year )
{
    if ( year % 400 == 0 )
    {
        return 1;
    }
    else if ( year % 100 == 0 )
    {
        return 0;
    }
    else if ( year % 4 == 0 )
    {
        return 1;
    }
    return 0;
}

static BYTE SolarCal[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
BYTE Calendar_GetDaysofMonth(WORD u16SolarYear, WORD u8SolarMonth)
{
    
    if ( Calendar_GetLeap(u16SolarYear)!=0 && u8SolarMonth==2)
    {
        return SolarCal[u8SolarMonth-1]+1;
    }
    if ( u8SolarMonth>12 )
    {
        return 0;
    }
    
    return SolarCal[u8SolarMonth-1];
}

BYTE Calendar_SolarCalendar(WORD u16Year, BYTE u8Month,BYTE u8Day)
{
    BYTE u8Week, u8idx;
    WORD u16TheDayInYear, u16TheDayInPeriod;
    
    u16TheDayInYear = u8Day;
    for(u8idx=0; u8idx<u8Month-1; u8idx++)
    {
        if(u8idx==1)
        {
            if ( Calendar_GetLeap(u16Year)==1)
                u16TheDayInYear++;
        }
        u16TheDayInYear += SolarCal[u8idx];
    }
    
    u16TheDayInPeriod=u16Year-1+(u16Year-1)/4-(u16Year-1)/100+(u16Year-1)/400+u16TheDayInYear;
    
    u8Week = u16TheDayInPeriod%7;
    
    return (u8Week);
}



//color = 'true',highlight
//false. normal
void calendar_draw_title(BYTE flag)
{
    WORD wYearX, wYearY;
    PARM_DRAW_STRING strTitle;
    
    if ((_bCALENDARMode == CALENDAR_MODE_SETTING) || (_bCALENDARMode == CALENDAR_MODE_DISPLAY_PERPETUAL_CALENDAR))
    {
        wYearX = _wStartX + CALENDER_ITEM_X_OFFSET+150; //fhfeng 1012
    }
    else //Display mode
    {
        wYearX = _wStartX + CALENDER_ITEM_X_OFFSET+80;
    }

    wYearY = _wStartY + 8;
    
    Calendar_DrawRect(_wStartX, _wStartY , _wTotalW, CALENDER_HEAD_HEIGHT_OF_YEAR, _bHeadBackColor); //clear the title region
    strTitle.bBackground = _bHeadBackColor;
    strTitle.bColorKey = 0;
    if(flag==TRUE) //fhfeng 1012
        strTitle.bTextColor =CALENDAR_MENU_ENTRY_TITLE_BODY_HIGHLIGHT_COLOR;
    else
        strTitle.bTextColor =_bHeadFront2Color;
    
    strTitle.bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT;
    strTitle.bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT;

//#ifdef NL_SOLUTION
    switch (_bCurrentMonth)
    {
    case 1:
        __pOSDUTLOutputString = aMonthJanuary;
        //GDI_DrawString(0, &strTitle, aMonthJanuary);
        break;
    case 2:
        __pOSDUTLOutputString = aMonthFebruary;
        //GDI_DrawString(0, &strTitle, aMonthFebruary);
        break;
    case 3:
        __pOSDUTLOutputString = aMonthMarch;
        //GDI_DrawString(0, &strTitle, aMonthMarch);
        break;
    case 4:
        __pOSDUTLOutputString = aMonthApril;
        //GDI_DrawString(0, &strTitle, aMonthApril);
        break;
    case 5:
        __pOSDUTLOutputString = aMonthMay;
        //GDI_DrawString(0, &strTitle, aMonthMay);
        break;
    case 6:
        __pOSDUTLOutputString = aMonthJune;
        //GDI_DrawString(0, &strTitle, aMonthJune);
        break;
    case 7:
        __pOSDUTLOutputString = aMonthJuly;
        //GDI_DrawString(0, &strTitle, aMonthJuly);
        break;
    case 8:
        __pOSDUTLOutputString = aMonthAugust;
        //GDI_DrawString(0, &strTitle, aMonthAugust);
        break;
    case 9:
        __pOSDUTLOutputString = aMonthSeptember;
        //GDI_DrawString(0, &strTitle, aMonthSeptember);
        break;
    case 10:
        __pOSDUTLOutputString = aMonthOctober;
        //GDI_DrawString(0, &strTitle, aMonthOctober);
        break;
    case 11:
        __pOSDUTLOutputString = aMonthNovember;
        //GDI_DrawString(0, &strTitle, aMonthNovember);
        break;
    case 12:
        __pOSDUTLOutputString = aMonthDecember;
        //GDI_DrawString(0, &strTitle, aMonthDecember);
        break;
    default:
        break;
    }

    strTitle.wX = wYearX;
    strTitle.wY = wYearY;
    GDI_DrawString(0, &strTitle, __pOSDUTLOutputString);
    strTitle.wX += GDI_GetStringWidth(__pOSDUTLOutputString);

    GDI_DrawString(0, &strTitle, aCALENDARDistance);
    strTitle.wX += GDI_GetStringWidth(aCALENDARDistance);

    wYearX = strTitle.wX;
    Calendar_OutputNumber(wYearX, wYearY, _bCurrentDate, &strTitle);
    wYearX += GDI_GetStringWidth(&__wOSDUTLStringBuf[0]);

    strTitle.wX = wYearX;
    GDI_DrawString(0, &strTitle, aCALENDARDistance);
    wYearX += GDI_GetStringWidth(aCALENDARDistance);

    Calendar_OutputNumber(wYearX, wYearY, _wCurrentYear, &strTitle);
//#else    
    /*
    Calendar_OutputNumber(wYearX, wYearY, _wCurrentYear, &strTitle);
    wYearX += GDI_GetStringWidth(&__wOSDUTLStringBuf[0]);

    wYearX +=2;  //draw "/"
    Calendar_DrawString(&strTitle,wYearX, wYearY,&aCalenda_Solidus[0]);
    wYearX += GDI_GetStringWidth(&aCalenda_Solidus[0])+2;

    Calendar_OutputNumber(wYearX, wYearY, _bCurrentMonth, &strTitle);
    wYearX += GDI_GetStringWidth(&__wOSDUTLStringBuf[0]);
    
    wYearX +=2; //draw "/"
    Calendar_DrawString(&strTitle,wYearX, wYearY,&aCalenda_Solidus[0]);
    wYearX += GDI_GetStringWidth(&aCalenda_Solidus[0])+2;

    Calendar_OutputNumber(wYearX, wYearY, _bCurrentDate, &strTitle);
    */
//#endif //NL_SOLUTION

⌨️ 快捷键说明

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