winStatsLabelStack.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 winStatsLabelStack.h
  10. * @author drose
  11. * @date 2004-01-07
  12. */
  13. #ifndef WINSTATSLABELSTACK_H
  14. #define WINSTATSLABELSTACK_H
  15. #include "pandatoolbase.h"
  16. #include "pvector.h"
  17. #include "vector_int.h"
  18. #ifndef WIN32_LEAN_AND_MEAN
  19. #define WIN32_LEAN_AND_MEAN 1
  20. #endif
  21. #include <windows.h>
  22. class WinStatsLabel;
  23. class WinStatsMonitor;
  24. class WinStatsGraph;
  25. /**
  26. * A window that contains a stack of labels from bottom to top.
  27. */
  28. class WinStatsLabelStack {
  29. public:
  30. WinStatsLabelStack();
  31. ~WinStatsLabelStack();
  32. void setup(HWND parent_window);
  33. bool is_setup() const;
  34. void set_pos(int x, int y, int width, int height,
  35. int top_margin, int bottom_margin);
  36. int get_x() const;
  37. int get_y() const;
  38. int get_width() const;
  39. int get_height() const;
  40. int get_ideal_width() const;
  41. int get_label_y(int label_index) const;
  42. int get_label_height(int label_index) const;
  43. int get_label_collector_index(int label_index) const;
  44. void clear_labels();
  45. int add_label(WinStatsMonitor *monitor, WinStatsGraph *graph,
  46. int thread_index, int collector_index, bool use_fullname);
  47. void replace_labels(WinStatsMonitor *monitor, WinStatsGraph *graph,
  48. int thread_index, const vector_int &collector_indices,
  49. bool use_fullname);
  50. int get_num_labels() const;
  51. void highlight_label(int collector_index);
  52. void update_label_color(int collector_index);
  53. private:
  54. void recalculate_label_positions();
  55. void create_window(HWND parent_window);
  56. static void register_window_class(HINSTANCE application);
  57. static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  58. LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  59. HWND _window;
  60. int _x;
  61. int _y;
  62. int _width;
  63. int _height;
  64. int _ideal_width;
  65. int _highlight_label;
  66. int _top_margin = 0;
  67. int _bottom_margin = 0;
  68. int _scroll = 0;
  69. typedef pvector<WinStatsLabel *> Labels;
  70. Labels _labels;
  71. static bool _window_class_registered;
  72. static const char * const _window_class_name;
  73. };
  74. #endif