Improve some sieve-related translations
[claws.git] / src / plugins / litehtml_viewer / container_linux.h
bloba9937e328b7ca48b465f887f4aa813341d45387f
1 /*
2 * Claws Mail -- A GTK based, lightweight, and fast e-mail client
3 * Copyright(C) 2019 the Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write tothe Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #pragma once
20 #include <vector>
21 #include <list>
22 #include <string>
23 #include <sys/time.h>
25 #include <cairo.h>
26 #include <gtk/gtk.h>
27 #include <fontconfig/fontconfig.h>
29 #include "litehtml/litehtml.h"
31 struct cairo_clip_box
33 typedef std::vector<cairo_clip_box> vector;
34 litehtml::position box;
35 litehtml::border_radiuses radius;
37 cairo_clip_box(const litehtml::position& vBox, litehtml::border_radiuses vRad)
39 box = vBox;
40 radius = vRad;
43 cairo_clip_box(const cairo_clip_box& val)
45 box = val.box;
46 radius = val.radius;
48 cairo_clip_box& operator=(const cairo_clip_box& val)
50 box = val.box;
51 radius = val.radius;
52 return *this;
56 class container_linux : public litehtml::document_container
58 typedef std::pair<GdkPixbuf*, struct timeval> img_cache_entry;
59 typedef std::map<litehtml::tstring, img_cache_entry> images_map;
61 protected:
62 cairo_surface_t* m_temp_surface;
63 cairo_t* m_temp_cr;
64 images_map m_images;
65 GRecMutex m_images_lock;
66 cairo_clip_box::vector m_clips;
68 public:
69 container_linux(void);
70 virtual ~container_linux(void);
72 virtual int pt_to_px(int pt) override;
73 virtual void load_image(const litehtml::tchar_t* src, const litehtml::tchar_t* baseurl, bool redraw_on_ready) override;
74 virtual void get_image_size(const litehtml::tchar_t* src, const litehtml::tchar_t* baseurl, litehtml::size& sz) override;
75 virtual void draw_background(litehtml::uint_ptr hdc, const litehtml::background_paint& bg) override;
76 virtual void draw_borders(litehtml::uint_ptr hdc, const litehtml::borders& borders, const litehtml::position& draw_pos, bool root) override;
77 virtual void draw_list_marker(litehtml::uint_ptr hdc, const litehtml::list_marker& marker) override;
78 virtual std::shared_ptr<litehtml::element> create_element(const litehtml::tchar_t *tag_name,
79 const litehtml::string_map &attributes,
80 const std::shared_ptr<litehtml::document> &doc) override;
81 virtual void get_media_features(litehtml::media_features& media) const override;
82 virtual void get_language(litehtml::tstring& language, litehtml::tstring & culture) const override;
83 virtual void link(const std::shared_ptr<litehtml::document> &ptr, const litehtml::element::ptr& el) override;
86 virtual void transform_text(litehtml::tstring& text, litehtml::text_transform tt) override;
87 virtual void set_clip(const litehtml::position& pos, const litehtml::border_radiuses& bdr_radius, bool valid_x, bool valid_y) override;
88 virtual void del_clip() override;
90 virtual void make_url( const litehtml::tchar_t* url, const litehtml::tchar_t* basepath, litehtml::tstring& out );
92 void clear_images();
94 /* Trim down images cache to less than desired_size [bytes],
95 * starting from oldest stored. */
96 gint clear_images(gsize desired_size);
98 void update_image_cache(const gchar *url, GdkPixbuf *image);
99 virtual void rerender() = 0;
100 virtual GdkPixbuf *get_local_image(const litehtml::tstring url) const = 0;
102 protected:
103 virtual void draw_ellipse(cairo_t* cr, int x, int y, int width, int height, const litehtml::web_color& color, int line_width);
104 virtual void fill_ellipse(cairo_t* cr, int x, int y, int width, int height, const litehtml::web_color& color);
105 virtual void rounded_rectangle( cairo_t* cr, const litehtml::position &pos, const litehtml::border_radiuses &radius );
106 void apply_clip(cairo_t* cr);
107 void set_color(cairo_t* cr, litehtml::web_color color) { cairo_set_source_rgba(cr, color.red / 255.0, color.green / 255.0, color.blue / 255.0, color.alpha / 255.0); }
109 private:
110 void add_path_arc(cairo_t* cr, double x, double y, double rx, double ry, double a1, double a2, bool neg);
111 void draw_pixbuf(cairo_t* cr, const GdkPixbuf *bmp, int x, int y, int cx, int cy);
112 cairo_surface_t* surface_from_pixbuf(const GdkPixbuf *bmp);
113 void lock_images_cache(void);
114 void unlock_images_cache(void);