summary refs log tree commit diff stats
path: root/code/widget.py
blob: e95e6a9d11530dccd34755a1769314bdb3abfc0c (plain) (blame)
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
33
34
35
36
37
38
39
import curses

class OutOfBoundsException(Exception): pass

class Widget():
	def __init__(self, win):
		self.win = win
		self.setdim(0, 0, 0, 0)

	def setdim(self, y, x, hei=None, wid=None):
		maxy, maxx = self.win.getmaxyx()
		wid = wid or maxx - x
		hei = hei or maxy - y
		if x + wid > maxx or y + hei > maxy:
			raise OutOfBoundsException()

		self.x = x
		self.y = y
		self.wid = wid
		self.hei = hei
	
	def contains_point(self, y, x):
		return (x >= self.x and x < self.x + self.wid) and \
				(y >= self.y and y < self.y + self.hei)

	def feed_env(self):
		pass

	def feed(self):
		pass

	def click(self):
		pass
	
	def draw(self):
		pass

	def destroy(self):
		pass