/* * Copyright (c) 2019-2020, Ryan Grieb * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include "Calendar.h" #include #include #include class CalendarWidget final : public GUI::Widget { C_OBJECT(CalendarWidget) public: CalendarWidget(); virtual ~CalendarWidget() override; void show_add_event_window(); private: virtual void resize_event(GUI::ResizeEvent&) override; void update_calendar_tiles(int target_year, int target_month); OwnPtr m_calendar; RefPtr m_top_container; RefPtr m_bottom_container; RefPtr m_selected_date_label; RefPtr m_prev_month_button; RefPtr m_next_month_button; RefPtr m_add_event_button; class CalendarTile final : public GUI::Frame { C_OBJECT(CalendarTile) public: CalendarTile(Calendar& calendar, int index, Core::DateTime m_date_time); void update_values(Calendar& calendar, int index, Core::DateTime date_time); virtual ~CalendarTile() override; private: virtual void doubleclick_event(GUI::MouseEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; int m_index { 0 }; bool m_display_weekday_name { false }; String m_weekday_name; String m_display_date; Core::DateTime m_date_time; Calendar& m_calendar; }; RefPtr m_calendar_tiles[35]; int m_tile_width { 85 }; int m_tile_height { 85 }; };