18 int GtkStatsLabel::_left_margin = 2;
19 int GtkStatsLabel::_right_margin = 2;
20 int GtkStatsLabel::_top_margin = 2;
21 int GtkStatsLabel::_bottom_margin = 2;
28 int thread_index,
int collector_index,
bool use_fullname) :
31 _thread_index(thread_index),
32 _collector_index(collector_index)
41 _widget = gtk_drawing_area_new();
42 gtk_widget_add_events(_widget,
43 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
44 GDK_BUTTON_PRESS_MASK);
45 g_signal_connect(G_OBJECT(_widget),
"expose_event",
46 G_CALLBACK(expose_event_callback),
this);
47 g_signal_connect(G_OBJECT(_widget),
"enter_notify_event",
48 G_CALLBACK(enter_notify_event_callback),
this);
49 g_signal_connect(G_OBJECT(_widget),
"leave_notify_event",
50 G_CALLBACK(leave_notify_event_callback),
this);
51 g_signal_connect(G_OBJECT(_widget),
"button_press_event",
52 G_CALLBACK(button_press_event_callback),
this);
54 gtk_widget_show(_widget);
57 _layout = gtk_widget_create_pango_layout(_widget, _text.c_str());
61 _bg_color.red = (int)(rgb[0] * 65535.0f);
62 _bg_color.green = (int)(rgb[1] * 65535.0f);
63 _bg_color.blue = (int)(rgb[2] * 65535.0f);
72 _fg_color.red = _fg_color.green = _fg_color.blue = 0;
74 _fg_color.red = _fg_color.green = _fg_color.blue = 0xffff;
80 pango_layout_get_pixel_size(_layout, &width, &height);
81 gtk_widget_set_size_request(_widget, width + 8, height);
84 _mouse_within =
false;
117 return _collector_index;
125 return _thread_index;
133 if (_highlight != highlight) {
134 _highlight = highlight;
135 gtk_widget_queue_draw(_widget);
151 set_mouse_within(
bool mouse_within) {
152 if (_mouse_within != mouse_within) {
153 _mouse_within = mouse_within;
154 gtk_widget_queue_draw(_widget);
161 gboolean GtkStatsLabel::
162 expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
165 GdkGC *gc = gdk_gc_new(widget->window);
166 gdk_gc_set_rgb_fg_color(gc, &self->_bg_color);
168 gdk_draw_rectangle(widget->window, gc, TRUE, 0, 0,
169 widget->allocation.width, widget->allocation.height);
173 pango_layout_get_pixel_size(self->_layout, &width, &height);
175 gdk_gc_set_rgb_fg_color(gc, &self->_fg_color);
176 gdk_draw_layout(widget->window, gc,
177 (widget->allocation.width - width) / 2, 0,
181 if (self->_highlight || self->_mouse_within) {
182 gdk_draw_rectangle(widget->window, gc, FALSE, 0, 0,
183 widget->allocation.width - 1, widget->allocation.height - 1);
193 gboolean GtkStatsLabel::
194 enter_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event,
197 self->set_mouse_within(
true);
204 gboolean GtkStatsLabel::
205 leave_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event,
208 self->set_mouse_within(
false);
215 gboolean GtkStatsLabel::
216 button_press_event_callback(GtkWidget *widget, GdkEventButton *event,
219 bool double_click = (
event->type == GDK_2BUTTON_PRESS);
int get_height() const
Returns the height of the label as we requested it.
bool get_highlight() const
Returns true if the visual highlight for this label is enabled.
const LRGBColor & get_collector_color(int collector_index)
Returns the color associated with the indicated collector.
std::string get_collector_fullname(int index) const
Returns the "full name" of the indicated collector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void clicked_label(int collector_index)
Called when the user single-clicks on a label.
std::string get_collector_name(int index) const
Returns the name of the indicated collector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_thread_index() const
Returns the thread index.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
void set_highlight(bool highlight)
Enables or disables the visual highlight for this label.
This class represents a connection to a PStatsClient and manages the data exchange with the client.
int get_collector_index() const
Returns the collector this label represents.
GtkWidget * get_widget() const
Returns the widget for this label.
A text label that will draw in color appropriate for a particular collector.
const PStatClientData * get_client_data() const
Returns the client data associated with this monitor.