15 #include "gtkStatsLabelStack.h"
16 #include "gtkStatsLabel.h"
25 GtkStatsLabelStack() {
26 _widget = gtk_vbox_new(FALSE, 0);
27 _highlight_label = -1;
36 ~GtkStatsLabelStack() {
57 get_label_y(
int label_index, GtkWidget *target_widget)
const {
58 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
61 int height = _labels[0]->get_height();
62 int start_y = _widget->allocation.height - height * label_index;
65 gtk_widget_translate_coordinates(_widget, target_widget,
77 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
78 return _labels[label_index]->get_height();
89 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), -1);
90 return _labels[label_index]->get_collector_index();
101 for (li = _labels.begin(); li != _labels.end(); ++li) {
103 if (delete_widgets) {
104 gtk_container_remove(GTK_CONTAINER(_widget), label->
get_widget());
119 int thread_index,
int collector_index,
bool use_fullname) {
121 new GtkStatsLabel(monitor, graph, thread_index, collector_index, use_fullname);
123 gtk_box_pack_end(GTK_BOX(_widget), label->
get_widget(),
126 int label_index = (int)_labels.size();
127 _labels.push_back(label);
139 return _labels.size();
152 if (_highlight_label != collector_index) {
153 _highlight_label = collector_index;
155 for (li = _labels.begin(); li != _labels.end(); ++li) {
int add_label(GtkStatsMonitor *monitor, GtkStatsGraph *graph, int thread_index, int collector_index, bool use_fullname)
Adds a new label to the top of the stack; returns the new label index.
void clear_labels(bool delete_widgets=true)
Removes the set of labels and starts a new set.
int get_label_height(int label_index) const
Returns the height of the indicated label.
void highlight_label(int collector_index)
Draws a highlight around the label representing the indicated collector, and removes the highlight fr...
int get_num_labels() const
Returns the number of labels in the stack.
int get_label_y(int label_index, GtkWidget *target_widget) const
Returns the y position of the indicated label's bottom edge, relative to the indicated target widget...
int get_collector_index() const
Returns the collector this label represents.
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
GtkWidget * get_widget() const
Returns the widget for this stack.
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_label_collector_index(int label_index) const
Returns the collector index associated with the indicated label.
GtkWidget * get_widget() const
Returns the widget for this label.
A text label that will draw in color appropriate for a particular collector.