2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-03-28 15:30:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Widget.h>
|
2020-09-18 09:49:51 +02:00
|
|
|
#include <LibGfx/StylePainter.h>
|
2019-03-28 15:30:29 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
class Frame : public Widget {
|
|
|
|
|
C_OBJECT(Frame)
|
2019-03-28 15:30:29 +01:00
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~Frame() override = default;
|
2019-03-28 15:30:29 +01:00
|
|
|
|
2023-04-29 16:47:52 -04:00
|
|
|
int frame_thickness() const;
|
2019-03-28 15:30:29 +01:00
|
|
|
|
2021-09-15 23:12:28 +02:00
|
|
|
virtual Margins content_margins() const override { return { frame_thickness() }; }
|
|
|
|
|
|
2023-04-29 16:47:52 -04:00
|
|
|
Gfx::FrameStyle frame_style() const { return m_style; }
|
|
|
|
|
void set_frame_style(Gfx::FrameStyle);
|
2019-03-28 15:30:29 +01:00
|
|
|
|
2023-04-29 16:47:52 -04:00
|
|
|
Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize size) const { return { frame_thickness(), frame_thickness(), size.width() - frame_thickness() * 2, size.height() - frame_thickness() * 2 }; }
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
2019-03-28 15:30:29 +01:00
|
|
|
|
2020-08-25 21:25:35 +02:00
|
|
|
virtual Gfx::IntRect children_clip_rect() const override;
|
|
|
|
|
|
2019-03-28 15:30:29 +01:00
|
|
|
protected:
|
2020-02-23 12:07:13 +01:00
|
|
|
Frame();
|
2020-02-02 15:07:41 +01:00
|
|
|
void paint_event(PaintEvent&) override;
|
2019-03-28 15:30:29 +01:00
|
|
|
|
|
|
|
|
private:
|
2023-04-29 16:47:52 -04:00
|
|
|
Gfx::FrameStyle m_style { Gfx::FrameStyle::NoFrame };
|
2019-03-28 15:30:29 +01:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
|
}
|