2018-10-10 16:49:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Color.h"
|
2018-10-10 20:06:58 +02:00
|
|
|
#include "Point.h"
|
2018-10-10 16:49:36 +02:00
|
|
|
#include "Rect.h"
|
2018-10-12 12:29:58 +02:00
|
|
|
#include "Size.h"
|
2018-12-21 02:18:16 +01:00
|
|
|
#include <AK/AKString.h>
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2019-01-10 05:41:49 +01:00
|
|
|
class CharacterBitmap;
|
2019-01-09 02:06:04 +01:00
|
|
|
class GraphicsBitmap;
|
2018-10-11 23:45:57 +02:00
|
|
|
class Font;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2019-01-31 16:37:43 +01:00
|
|
|
#ifndef KERNEL
|
2019-01-20 04:49:48 +01:00
|
|
|
class GWidget;
|
|
|
|
class GWindow;
|
|
|
|
#endif
|
2018-10-10 16:49:36 +02:00
|
|
|
|
|
|
|
class Painter {
|
|
|
|
public:
|
2019-01-31 16:37:43 +01:00
|
|
|
#ifndef KERNEL
|
2019-01-20 04:49:48 +01:00
|
|
|
explicit Painter(GWidget&);
|
|
|
|
#endif
|
2019-01-12 03:42:50 +01:00
|
|
|
explicit Painter(GraphicsBitmap&);
|
2018-10-10 16:49:36 +02:00
|
|
|
~Painter();
|
2019-01-12 17:02:54 +01:00
|
|
|
void fill_rect(const Rect&, Color);
|
2019-01-25 05:01:27 +01:00
|
|
|
void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end);
|
2019-01-12 17:02:54 +01:00
|
|
|
void draw_rect(const Rect&, Color);
|
|
|
|
void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color());
|
|
|
|
void set_pixel(const Point&, Color);
|
|
|
|
void draw_line(const Point&, const Point&, Color);
|
|
|
|
void draw_focus_rect(const Rect&);
|
2019-01-20 23:42:36 +01:00
|
|
|
void blit(const Point&, const GraphicsBitmap&, const Rect& src_rect);
|
2018-10-12 02:24:05 +02:00
|
|
|
|
2019-01-21 02:42:29 +01:00
|
|
|
enum class TextAlignment { TopLeft, CenterLeft, Center, CenterRight };
|
2019-01-12 17:02:54 +01:00
|
|
|
void draw_text(const Rect&, const String&, TextAlignment = TextAlignment::TopLeft, Color = Color());
|
2019-01-15 04:44:47 +01:00
|
|
|
void draw_glyph(const Point&, char, Color);
|
2019-01-12 17:02:54 +01:00
|
|
|
|
2018-10-14 13:06:05 +02:00
|
|
|
const Font& font() const { return *m_font; }
|
2019-02-02 08:05:14 +01:00
|
|
|
void set_font(Font& font) { m_font = &font; }
|
2018-10-11 23:45:57 +02:00
|
|
|
|
2019-01-11 03:52:09 +01:00
|
|
|
enum class DrawOp { Copy, Xor };
|
|
|
|
void set_draw_op(DrawOp op) { m_draw_op = op; }
|
|
|
|
DrawOp draw_op() const { return m_draw_op; }
|
|
|
|
|
2019-01-24 23:40:12 +01:00
|
|
|
void set_clip_rect(const Rect& rect);
|
|
|
|
void clear_clip_rect();
|
2019-01-20 23:42:36 +01:00
|
|
|
Rect clip_rect() const { return m_clip_rect; }
|
|
|
|
|
2018-10-10 16:49:36 +02:00
|
|
|
private:
|
2019-01-11 03:52:09 +01:00
|
|
|
void set_pixel_with_draw_op(dword& pixel, const Color&);
|
2019-02-01 05:23:05 +01:00
|
|
|
void fill_rect_with_draw_op(const Rect&, Color);
|
2019-01-11 03:52:09 +01:00
|
|
|
|
2018-10-14 13:06:05 +02:00
|
|
|
const Font* m_font;
|
2018-10-12 02:41:27 +02:00
|
|
|
Point m_translation;
|
2019-01-12 17:02:54 +01:00
|
|
|
Rect m_clip_rect;
|
2019-01-09 02:06:04 +01:00
|
|
|
RetainPtr<GraphicsBitmap> m_target;
|
2019-01-31 16:37:43 +01:00
|
|
|
#ifndef KERNEL
|
2019-01-20 04:49:48 +01:00
|
|
|
GWindow* m_window { nullptr };
|
2019-01-24 23:40:12 +01:00
|
|
|
void* m_backing_store_id { nullptr };
|
2019-01-20 04:49:48 +01:00
|
|
|
#endif
|
2019-01-11 03:52:09 +01:00
|
|
|
DrawOp m_draw_op { DrawOp::Copy };
|
2018-10-10 16:49:36 +02:00
|
|
|
};
|