Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Gtk4DrawArea.h
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 12/08/2026
2
3/*************************************************************************
4 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_Gtk4DrawArea_H
12#define ROOT_Gtk4DrawArea_H
13
14#include <gtkmm.h>
15#include <cairomm/context.h>
16
17class TCanvas;
18
19class Gtk4DrawArea : public Gtk::DrawingArea {
20public:
22 virtual ~Gtk4DrawArea() = default;
23
24 void SetCanvas(TCanvas *c) { fCanvas = c; }
25 TCanvas *GetCanvas() const { return fCanvas; }
26
27 Cairo::Context *GetContext() const { return fContext; }
28
29 Cairo::ImageSurface *GetCache() const { return fDrawingCache.get(); }
30
31 void ShowContextMenu(Glib::RefPtr<Gio::Menu> menu_model, const char *title, int x, int y);
32
33 sigc::signal<void(const char *)> status_changed();
34
35
36
37protected:
38 // The render function for gtkmm 4
39 void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
40
41 TCanvas *fCanvas = nullptr;
42 Cairo::Context *fContext = nullptr;
43 double fLastMouseX = 0;
44 double fLastMouseY = 0;
45 bool fShowEventStatus = true;
46 Cairo::RefPtr<Cairo::ImageSurface> fDrawingCache;
47
48 void on_mouse_click(int n_press, double x, double y);
49 void on_mouse_released(int n_press, double x, double y);
50 void on_mouse_enter(double x, double y);
51 void on_mouse_move(double x, double y);
52 void on_mouse_leave();
53 bool on_mouse_scroll(double dx, double dy);
54 bool on_my_query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
55
56 sigc::signal<void(const char *)> m_status_changed;
57
58 Glib::RefPtr<Gtk::GestureClick> m_click_gesture;
59 Glib::RefPtr<Gtk::EventControllerMotion> m_motion_controller;
60 Glib::RefPtr<Gtk::EventControllerScroll> m_scroll_controller;
61};
62
63#endif
#define c(i)
Definition RSha256.hxx:101
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
bool on_mouse_scroll(double dx, double dy)
Cairo::RefPtr< Cairo::ImageSurface > fDrawingCache
void on_mouse_move(double x, double y)
Glib::RefPtr< Gtk::GestureClick > m_click_gesture
sigc::signal< void(const char *) status_changed)()
void on_mouse_enter(double x, double y)
Cairo::Context * GetContext() const
virtual ~Gtk4DrawArea()=default
Glib::RefPtr< Gtk::EventControllerMotion > m_motion_controller
TCanvas * GetCanvas() const
Glib::RefPtr< Gtk::EventControllerScroll > m_scroll_controller
sigc::signal< void(const char *) m_status_changed)
Cairo::ImageSurface * GetCache() const
void on_mouse_leave()
void on_mouse_released(int n_press, double x, double y)
double fLastMouseY
void ShowContextMenu(Glib::RefPtr< Gio::Menu > menu_model, const char *title, int x, int y)
Shows context menu with provided items and title at specified position.
void on_draw(const Cairo::RefPtr< Cairo::Context > &cr, int width, int height)
void on_mouse_click(int n_press, double x, double y)
bool on_my_query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr< Gtk::Tooltip > &tooltip)
void SetCanvas(TCanvas *c)
double fLastMouseX
TCanvas * fCanvas
Cairo::Context * fContext
bool fShowEventStatus
The Canvas class.
Definition TCanvas.h:23
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17