18 bool WinStatsLabelStack::_window_class_registered =
false;
19 const char *
const WinStatsLabelStack::_window_class_name =
"stack";
25 WinStatsLabelStack() {
32 _highlight_label = -1;
39 ~WinStatsLabelStack() {
42 DestroyWindow(_window);
51 setup(HWND parent_window) {
53 DestroyWindow(_window);
57 create_window(parent_window);
61 for (li = _labels.begin(); li != _labels.end(); ++li) {
63 label->
setup(_window);
73 return (_window != 0);
80 set_pos(
int x,
int y,
int width,
int height) {
85 SetWindowPos(_window, 0, x, y, _width, _height,
86 SWP_NOZORDER | SWP_SHOWWINDOW);
90 for (li = _labels.begin(); li != _labels.end(); ++li) {
143 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
144 return _labels[label_index]->get_y() +
get_y();
152 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
153 return _labels[label_index]->get_height();
161 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), -1);
162 return _labels[label_index]->get_collector_index();
171 for (li = _labels.begin(); li != _labels.end(); ++li) {
183 int thread_index,
int collector_index,
bool use_fullname) {
185 if (!_labels.empty()) {
190 new WinStatsLabel(monitor, graph, thread_index, collector_index, use_fullname);
192 label->
setup(_window);
197 int label_index = (int)_labels.size();
198 _labels.push_back(label);
208 return _labels.size();
218 if (_highlight_label != collector_index) {
219 _highlight_label = collector_index;
221 for (li = _labels.begin(); li != _labels.end(); ++li) {
232 void WinStatsLabelStack::
233 create_window(HWND parent_window) {
238 HINSTANCE application = GetModuleHandle(
nullptr);
239 register_window_class(application);
242 CreateWindow(_window_class_name,
"label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
244 parent_window,
nullptr, application, 0);
246 nout <<
"Could not create Label Stack window!\n";
250 SetWindowLongPtr(_window, 0, (LONG_PTR)
this);
257 void WinStatsLabelStack::
258 register_window_class(HINSTANCE application) {
259 if (_window_class_registered) {
265 ZeroMemory(&wc,
sizeof(WNDCLASS));
267 wc.lpfnWndProc = (WNDPROC)static_window_proc;
268 wc.hInstance = application;
269 wc.hCursor = LoadCursor(
nullptr, IDC_ARROW);
270 wc.lpszMenuName =
nullptr;
271 wc.lpszClassName = _window_class_name;
276 if (!RegisterClass(&wc)) {
277 nout <<
"Could not register Label Stack window class!\n";
281 _window_class_registered =
true;
287 LONG WINAPI WinStatsLabelStack::
288 static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
290 if (
self !=
nullptr && self->_window == hwnd) {
291 return self->window_proc(hwnd, msg, wparam, lparam);
293 return DefWindowProc(hwnd, msg, wparam, lparam);
300 LONG WinStatsLabelStack::
301 window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
306 HDC hdc = BeginPaint(hwnd, &ps);
308 RECT rect = { 0, 0, _width, _height };
309 FillRect(hdc, &rect, (HBRUSH)COLOR_BACKGROUND);
318 return DefWindowProc(hwnd, msg, wparam, lparam);
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
A window that contains a stack of labels from bottom to top.
int get_label_collector_index(int label_index) const
Returns the collector index associated with 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_ideal_width() const
Returns the width the stack would really prefer to be.
bool is_setup() const
Returns true if the label stack has been set up, false otherwise.
void setup(HWND parent_window)
Creates the actual window object.
int get_width() const
Returns the width of the stack as we requested it.
int get_y() const
Returns the y position of the stack on its parent.
void clear_labels()
Removes the set of labels and starts a new set.
void set_pos(int x, int y, int width, int height)
Sets the position and size of the label stack on its parent.
int get_x() const
Returns the x position of the stack on its parent.
int get_label_height(int label_index) const
Returns the height of the indicated label.
int get_num_labels() const
Returns the number of labels in the stack.
int get_label_y(int label_index) const
Returns the y position of the indicated label's bottom edge, relative to the label stack's parent win...
int add_label(WinStatsMonitor *monitor, WinStatsGraph *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.
int get_height() const
Returns the height of the stack as we requested it.
A text label that will draw in color appropriate for a particular collector.
void setup(HWND parent_window)
Creates the actual window.
int get_y() const
Returns the y position of the label on its parent.
int get_ideal_width() const
Returns the width the label would really prefer to be.
int get_collector_index() const
Returns the collector this label represents.
int get_height() const
Returns the height of the label as we requested it.
void set_pos(int x, int y, int width)
Sets the position of the label on its parent.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.