1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 00:45:07 +00:00
serenity/Applications/Calendar/CalendarWidget.h
2020-04-10 11:28:34 +02:00

79 lines
2.8 KiB
C++

/*
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
* 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 <LibGUI/Frame.h>
#include <LibGUI/Label.h>
#include <LibGUI/Widget.h>
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<Calendar> m_calendar;
RefPtr<GUI::Widget> m_top_container;
RefPtr<GUI::Widget> m_bottom_container;
RefPtr<GUI::Label> m_selected_date_label;
RefPtr<GUI::Button> m_prev_month_button;
RefPtr<GUI::Button> m_next_month_button;
RefPtr<GUI::Button> 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<CalendarTile> m_calendar_tiles[35];
int m_tile_width { 85 };
int m_tile_height { 85 };
};