File: network_status.cpp

package info (click to toggle)
btanks 0.9.8083-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 43,616 kB
  • sloc: cpp: 46,425; ansic: 12,005; xml: 4,262; python: 313; sh: 13; makefile: 13
file content (32 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "network_status.h"
#include "resource_manager.h"

NetworkStatusControl::NetworkStatusControl() : 
	Tooltip("menu", "network-status", true), _bclose(NULL) {
}

void NetworkStatusControl::render(sdlx::Surface &surface, const int x, const int y) const {
	AUTOLOAD_SURFACE(_bclose, "menu/disconnect.png");

	Tooltip::render(surface, x, y);
	int mx, my, w, h;
	_background.getMargins(mx, my);
	_background.get_size(w, h);

	_close_area.w = _bclose->get_width();
	_close_area.h = _bclose->get_height();
	_close_area.x = w - mx - _close_area.w;
	_close_area.y = h - my - _close_area.h;

	surface.blit(*_bclose, _close_area.x, _close_area.y);
}

bool NetworkStatusControl::onMouse(const int button, const bool pressed, const int x, const int y) {
	if (_close_area.in(x, y)) {
		//LOG_DEBUG(("%d %d", x, y));
		if (!pressed)
			invalidate();
		return true;
	}
	return false;
}