예제 #1
0
void calendarBack(int x, int y)
{
	freeCalendar();	
	initDayView();	
	setMode(DAYVIEW);
}
예제 #2
0
void CalendarDatePrivate::updateDayView(gboolean isForceLoad, GTimeSpan changed) {
    if (NULL == m_swipeBox[VIEWTYPE_DAY]) {
        initDayView();
    }

    ComputeDays();
    gint rowCount = 7;
    gint offsetCols = (m_isShowWeekNum ? 1 : 0);
    gint colCount = 7 + offsetCols;
    int row = 0;
    int col = 0;

    m_viewType = VIEWTYPE_DAY;

    GDateTime* selectedDate = g_date_time_new_local(m_selectedYear, m_selectedMonth, m_selectedDayOfMonth, 1, 1, 1);
    gchar* dateLabelText = g_date_time_format(selectedDate, C_("calendar heading", "%Y, %b"));
    gtk_button_set_label(GTK_BUTTON(m_viewTypeSwitch), dateLabelText);
    g_date_time_unref(selectedDate);
    g_free(dateLabelText);

    for (col = 0; col < colCount; ++col) {
        for (row = 0; row < rowCount; ++row) {
            if (m_isShowWeekNum && (0 == col)) {
                if (0 == row) {
                    // do nothing
                } else {
                    // do nothing
                } // end: if (0 == row)
            } else {
                if (0 == row) {
                } else {
                    if (NULL != m_dayItem[row - 1][col - offsetCols]) {
                        GDateTime* nowDate = g_date_time_new_now_local();
                        m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-day-base");
                        m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-day");
                        if (isWorkDay(col - offsetCols + m_weekStart)) {
                            m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-work-day");
                        } else {
                            m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-nonwork-day");
                        }


                        switch (m_dayMonth[row - 1][col - offsetCols]) {
                        case MONTH_CURRENT: {
                            GDateTime * currentDate = g_date_time_new_local(m_selectedYear, m_selectedMonth, m_day[row - 1][col - offsetCols],
                                                                            0, 0, 0);
                            if (isTheSameDate(nowDate, currentDate)) {
                                m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-today");
                            } else {
                                m_dayItem[row - 1][col - offsetCols]->removeStyleClass("calendar-today");
                            }
                            g_date_time_unref(currentDate);
                        }
                            break;
                        case MONTH_PREV:
                        case MONTH_NEXT:
                             m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-other-month-day");
                            break;
                        default:
                            break;
                        }
                        m_dayItem[row - 1][col - offsetCols]->setValue(m_day[row - 1][col - offsetCols]);
                    }
                }
            } // end: if (priv->show_week_num && (0 == col))
        } // end: for row
    } // end: for col

    if (NULL != m_swipeBox[VIEWTYPE_MONTH]) {
        gtk_widget_hide(m_swipeBox[VIEWTYPE_MONTH]);
    }

    if (NULL != m_swipeBox[VIEWTYPE_YEAR]) {
        gtk_widget_hide(m_swipeBox[VIEWTYPE_YEAR]);
    }

    if (NULL != m_swipeBox[VIEWTYPE_DAY]) {
        gtk_widget_show_all(m_swipeBox[VIEWTYPE_DAY]);
    }

    apply_css(GTK_WIDGET(m_actor), m_provider);
}