Calzone-UI/inc/ui/calendar.h

67 lines
1.1 KiB
C
Raw Normal View History

2024-02-21 01:11:59 +00:00
#pragma once
2024-02-23 04:45:19 +00:00
#include <cstdint>
2024-02-21 01:11:59 +00:00
#include <stdint.h>
#include <lvgl.h>
#include "events.h"
#define DAYS_IN_WEEK 7
#define CALENDAR_ROWS 5
2024-02-23 04:45:19 +00:00
struct CalendarBox {
public:
CalendarBox(lv_obj_t* parent);
~CalendarBox();
void Style(uint32_t width, uint32_t height, int day, int wday, bool today, int days_in_month);
public:
2024-02-21 01:11:59 +00:00
lv_obj_t* box;
2024-02-23 04:45:19 +00:00
private:
static void DrawEvents_cb(lv_event_t* event);
private:
2024-02-21 01:11:59 +00:00
lv_obj_t* label;
2024-02-23 04:45:19 +00:00
lv_obj_t* event_count_labels[Events::EVENTS_COUNT];
};
struct CalendarRow {
public:
CalendarRow(lv_obj_t* parent);
~CalendarRow();
int Style(lv_obj_t* last_row, uint32_t box_width, uint32_t box_height, int day, int current_day, int days_in_month);
2024-02-21 01:11:59 +00:00
2024-02-23 04:45:19 +00:00
public:
CalendarBox* boxes[DAYS_IN_WEEK];
};
2024-02-21 01:11:59 +00:00
2024-02-23 04:45:19 +00:00
class Calendar {
public:
Calendar(lv_obj_t* parent, uint32_t width);
~Calendar();
void Style(const struct tm* const ct);
public:
2024-02-21 01:11:59 +00:00
lv_obj_t* calendar;
2024-02-23 04:45:19 +00:00
private:
2024-02-21 01:11:59 +00:00
lv_obj_t* title_bar;
lv_obj_t* title_label;
2024-02-23 04:45:19 +00:00
CalendarRow* rows[CALENDAR_ROWS];
2024-02-21 01:11:59 +00:00
uint32_t width;
uint32_t box_width;
uint32_t box_height;
2024-02-23 04:45:19 +00:00
};
2024-02-21 01:11:59 +00:00