MTK中模拟时钟的绘制

gui_clock.h

typedef struct
{
    gui_clock_type_enum type;   /*clock type*/
    gui_clock_digital_align_enum align_type; /* align type */
    S32 x,y;
    S32 width,height;
    void (*hide_callback) (S32 x1, S32 y1, S32 x2, S32 y2);/*hide function*/
    GDI_HANDLE target_layer;    /*target layer to display*/
    GDI_HANDLE abm_layer;    /* alpha blending layer of clock */
    GDI_HANDLE target_lcd;      /*target lcd to display*/
    applib_time_struct diff; /*record the difference between set-time and phone-time*/????????
    S32 time_compare;   /*difference between set-time and cur-time*/???????
    MMI_BOOL active;      /*clock is active or not*/
    UI_font_type date_text_font;    /*font of date text*/
    UI_font_type time_text_font;    /*font of time text*/
    color date_text_color;              /*color of date text*/
    color date_text_border_color;/*border color of date text*/
    color time_text_color;             /*color of time text*/
    color time_text_border_color;/*border color of time text*/

    color analog_hand_hour_color;           /*color of hour hand*/
    color analog_hand_min_color;            /*color of minute hand*/
    color analog_axis_color;                    /*color of axis (not used)*/

    S32  gap_between_two_lines;         /*gap between date text and time text*/
    S32  gap_between_time_date_one_line;    /*gap between time and date in one line*/
    MMI_BOOL    border_enable;
    MMI_BOOL    on_idle;
    MMI_BOOL enable_update;
} gui_clock_struct; //这个结构体很重要,以后所有的操作都围绕着它来。

-------------------------------------------------------------------------------------------------------------------------

结构体里???问号处的成员的使用举例

在gui_clock_analog_clock_initialize(gui_clock_struct *c)函数里有这么段代码

if (c->time_compare == DT_TIME_LESS)//先判断time_compare这个标识符的值
    {
        applib_time_struct  temp;//定义一个临时的结构体变量
        temp = c->diff;     //把C->diff中设置了的值传给temp变量
        applib_dt_increase_time(&t, &temp, time_to_show); //把&t+&temp传给time_to_show
    }

-------------------------------------------------------------------------------------------------------------------------

gui_clock.c

static const float32 g_gui_clock_acm_sine_table[] =
{
    (float32) - 0.99999820, (float32) - 0.99431727, (float32) - 0.97773360, (float32) - 0.95042917,
        (float32) - 0.91270313,
        (float32)-0.86496924, (float32)-0.80775119, (float32)-0.74167587,
    (float32) - 0.66746803, (float32) - 0.58594175, (float32) - 0.49799022, (float32) - 0.40457821,
        (float32) - 0.30673042,
        (float32)-0.20551889, (float32)-0.10205382, (float32)0.00000000,
    (float32) 0.10457040, (float32) 0.20799418, (float32) 0.30913729, (float32) 0.40689072, (float32) 0.50018258,
        (float32) 0.58798990,
        (float32)0.66934994, (float32)0.74337050,
    (float32) 0.80923998, (float32) 0.86623616, (float32) 0.91373403, (float32) 0.95121274, (float32) 0.97826142,
        (float32) 0.99458343,
        (float32)0.99999980, (float32)0.99445115,
    (float32) 0.97799831, (float32) 0.95082172, (float32) 0.91321931, (float32) 0.86560342, (float32) 0.80849624,
        (float32) 0.74252372,
        (float32)0.66840956, (float32)0.58696629,
    (float32) 0.49908672, (float32) 0.40573486, (float32) 0.30793410, (float32) 0.20675662, (float32) 0.10331227,
        (float32) - 0.00126490,
        (float32)-0.10582843, (float32)-0.20923132,
    (float32) - 0.31033998, (float32) - 0.40804598, (float32) - 0.50127753, (float32) - 0.58901256,
        (float32) - 0.67028925,
        (float32)-0.74421601, (float32)-0.80998244, (float32)-0.86686752,
    (float32)-0.91424734, (float32)-0.95160225, (float32)-0.97852297, (float32)-0.99471414,
};

static const float32 g_gui_clock_acm_cosine_table[] =
{
    (float32) 0.00189735, (float32) 0.10645731, (float32) 0.20984996, (float32) 0.31094114, (float32) 0.40862330,
        (float32) 0.50182489,
        (float32)0.58952354, (float32)0.67075845,
    (float32) 0.74463846, (float32) 0.81035318, (float32) 0.86718264, (float32) 0.91450340, (float32) 0.95179643,
        (float32) 0.97865315,
        (float32)0.99477888, (float32)1.00000000,
    (float32) 0.99451749, (float32) 0.97813006, (float32) 0.95101742, (float32) 0.91347684, (float32) 0.86591997,
        (float32) 0.80886827,
        (float32)0.74294728, (float32)0.66887989,
    (float32) 0.58747821, (float32) 0.49963478, (float32) 0.40631283, (float32) 0.30853576, (float32) 0.20737548,
        (float32) 0.10394131,
        (float32)-0.00063245, (float32)-0.10519940,
    (float32) - 0.20861283, (float32) - 0.30973870, (float32) - 0.40746839, (float32) - 0.50073018,
        (float32) - 0.58850135,
        (float32)-0.66981977, (float32)-0.74379342, (float32)-0.80961137,
    (float32) - 0.86655204, (float32) - 0.91399082, (float32) - 0.95140769, (float32) - 0.97839241,
        (float32) - 0.99464897,
        (float32)-0.99999920, (float32)-0.99438440, (float32)-0.97786617,
    (float32) - 0.95062563, (float32) - 0.91296138, (float32) - 0.86528656, (float32) - 0.80812388,
        (float32) - 0.74209994,
        (float32)-0.66793902, (float32)-0.58645414, (float32)-0.49853857,
    (float32)-0.40515651, (float32)-0.30733233, (float32)-0.20613779, (float32)-0.10268295,
};//正好六十个。

#if(GUI_CLOCK_ANALOG_CLOCK_DRAW_POLYGON_HANDS)
extern void flat_triangle_fill(polygon_vertex vertices[], color c);//填充表针???
extern void polygon_draw(polygon_vertex vertices[], S32 n_vertices, color c);//画表针??
#elif(GUI_CLOCK_ANALOG_CLOCK_SMOOTHEN_LINES)
extern void UI_antialiased_line(S32 x1, S32 y1, S32 x2, S32 y2, color c);//平滑
#endif

--------------------------------------------------------------------------------------------------------------

意外收获,在阅读代码时发现这么一个函数,它根据输入的年月日,可以自动计算出星期几,在VC上试验了不错。哈哈

/*****************************************************************************
 * FUNCTION
 *  applib_dt_dow
 * DESCRIPTION
 *  Function to compute current day of week.
 * PARAMETERS
 *  y       [IN]        Year of the date to be computed. (example, 2004)
 *  m       [IN]        Month of the date to be computed
 *  d       [IN]        Day of the date to be computed
 * RETURNS
 *  kal_uint8   index of day of week
 *****************************************************************************/
kal_uint8 applib_dt_dow(kal_uint16 y, kal_uint8 m, kal_uint8 d)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (m < 3)
    {
        m += 13;
        y--;
    }
    else
    {
        m++;
    }

    return (d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + 6) % 7;
}

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/toonny1985/archive/2009/10/30/4747041.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值