/* * datesel.h - Date selector * Copyright (C) 2024 Alexander Rosenberg * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. See the LICENSE file for more information. */ #ifndef INCLUDED_DATESEL_H #define INCLUDED_DATESEL_H #include "../util.h" #include "screen.h" typedef enum { DATE_SEL_YEAR, DATE_SEL_MONTH, DATE_SEL_DAY, } DateSelectionStage; typedef struct { int year; int month; int day; DateSelectionStage stage; DateSelectionStage max_stage; UtilPeriod limit_period; UtilDate start_time; UtilDate end_time; } DateSelection; typedef enum { DATE_SEL_BACK, DATE_SEL_CONTINUE, DATE_SEL_DONE, DATE_SEL_ERROR } DateSelectionState; /* * Initialize a DateSelection. LIMIT_PERIOD is the most specific field * to select and the period by which to select. */ void date_sel_init(DateSelection *ds, UtilPeriod limit_period); /* * Reset the date on DS. */ void date_sel_reset(DateSelection *ds); /* * Set the LIMIT_PERIOD for DS. */ void date_sel_set_period(DateSelection *ds, UtilPeriod limit_period); /* * Dispatch a DateSelection by processing STATE to continue the selection. * Return: weather the user backed out, is still working, or is done */ DateSelectionState date_sel_dispatch(DateSelection *ds, SensorState *state, const char *label); #endif