2
0

gtkStatsLabel.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file gtkStatsLabel.h
  10. * @author drose
  11. * @date 2006-01-16
  12. */
  13. #ifndef GTKSTATSLABEL_H
  14. #define GTKSTATSLABEL_H
  15. #include "pandatoolbase.h"
  16. #include <gtk/gtk.h>
  17. class GtkStatsMonitor;
  18. class GtkStatsGraph;
  19. /**
  20. * A text label that will draw in color appropriate for a particular
  21. * collector. It also responds when the user double-clicks on it. This is
  22. * handy for putting colored labels on strip charts.
  23. */
  24. class GtkStatsLabel {
  25. public:
  26. GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph,
  27. int thread_index, int collector_index, bool use_fullname);
  28. ~GtkStatsLabel();
  29. GtkWidget *get_widget() const;
  30. int get_height() const;
  31. int get_collector_index() const;
  32. int get_thread_index() const;
  33. void set_highlight(bool highlight);
  34. bool get_highlight() const;
  35. private:
  36. void set_mouse_within(bool mouse_within);
  37. static gboolean expose_event_callback(GtkWidget *widget,
  38. GdkEventExpose *event, gpointer data);
  39. static gboolean enter_notify_event_callback(GtkWidget *widget,
  40. GdkEventCrossing *event,
  41. gpointer data);
  42. static gboolean leave_notify_event_callback(GtkWidget *widget,
  43. GdkEventCrossing *event,
  44. gpointer data);
  45. static gboolean button_press_event_callback(GtkWidget *widget,
  46. GdkEventButton *event,
  47. gpointer data);
  48. GtkStatsMonitor *_monitor;
  49. GtkStatsGraph *_graph;
  50. int _thread_index;
  51. int _collector_index;
  52. std::string _text;
  53. GtkWidget *_widget;
  54. LRGBColor _fg_color;
  55. LRGBColor _bg_color;
  56. PangoLayout *_layout;
  57. /*
  58. COLORREF _bg_color;
  59. COLORREF _fg_color;
  60. HBRUSH _bg_brush;
  61. HBRUSH _highlight_brush;
  62. */
  63. bool _highlight;
  64. bool _mouse_within;
  65. int _height;
  66. static int _left_margin, _right_margin;
  67. static int _top_margin, _bottom_margin;
  68. };
  69. #endif