1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#pragma once
10#include "../../../Helpers/TextDrawer.h"
11#include "../../MenuBar.h"
12#include "../BaseWidget.h"
13#include <ctime>
14#include <libfoundation/Logger.h>
15#include <libg/Font.h>
16#include <libg/ImageLoaders/PNGLoader.h>
17
18#define DATA_BUF 32
19
20namespace WinServer {
21
22class ControlPanelToggle : public BaseWidget {
23public:
24 ControlPanelToggle()
25 {
26 LG::PNG::PNGLoader loader;
27 m_icon = loader.load_from_file("/res/system/contol_center.png");
28 }
29
30 ~ControlPanelToggle() = default;
31
32 constexpr size_t width() override { return 20; }
33 constexpr size_t height() { return 12; }
34 void draw(LG::Context& ctx) override
35 {
36 ctx.draw({ 4, 4 }, m_icon);
37 }
38
39 MenuItemAnswer mouse_down(int x, int y) override
40 {
41 m_clicked = true;
42 return MenuItemAnswer::InvalidateMe;
43 }
44
45 MenuItemAnswer mouse_up() override
46 {
47 m_clicked = false;
48 return MenuItemAnswer::InvalidateMe;
49 }
50
51 void popup_rect(LG::Rect& r) override { }
52
53private:
54 LG::PixelBitmap m_icon;
55 bool m_clicked { false };
56};
57
58} // namespace WinServer