author | Radek Brich <radek.brich@devl.cz> |
Sun, 30 Dec 2012 13:03:29 +0100 | |
changeset 42 | 0224ce40792f |
parent 41 | 37b7dfc3eae6 |
child 45 | 43b2279b06e1 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
2 |
||
18
e6c3a5ee91aa
Eliminate relative imports.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
3 |
from tuikit.widget import Widget |
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
4 |
from tuikit.common import Borders, Coords |
0 | 5 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
6 |
|
0 | 7 |
class Container(Widget): |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
23
diff
changeset
|
8 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
9 |
'''Container widget. Base for any widget which can contain other widgets.''' |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
23
diff
changeset
|
10 |
|
0 | 11 |
def __init__(self, width = 10, height = 10): |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
12 |
'''Create container of requested size.''' |
0 | 13 |
Widget.__init__(self, width, height) |
14 |
||
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
15 |
#: List of child widgets. |
0 | 16 |
self.children = [] |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
23
diff
changeset
|
17 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
18 |
#: Offset for child widgets |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
19 |
self.offset = Coords() |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
20 |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
21 |
self.focuschild = None |
0 | 22 |
self.mousechild = None |
23 |
||
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
24 |
self.allow_focus = True |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
25 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
26 |
#: Width of borders (left, top, right, bottom). |
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
27 |
#: Child widgets are placed within borders. |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
28 |
self.borders = Borders() |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
23
diff
changeset
|
29 |
|
15 | 30 |
self._layout = None |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
23
diff
changeset
|
31 |
|
0 | 32 |
self.widthrequest = (None, None) |
33 |
self.heightrequest = (None, None) |
|
34 |
||
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
35 |
self.colorprefix = None |
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
36 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
37 |
self.trap_focus = False # if True, tab cycles inside container |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
38 |
|
0 | 39 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
40 |
def add(self, widget, **kwargs): |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
41 |
'''Add widget into this container.''' |
0 | 42 |
self.children.append(widget) |
43 |
widget.parent = self |
|
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
44 |
widget.top = self.top |
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
45 |
widget.hints.update(kwargs) |
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
46 |
if self.focuschild is None and widget.can_focus(): |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
47 |
self.focuschild = widget |
0 | 48 |
|
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
49 |
@property |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
50 |
def layout(self): |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
51 |
return self._layout |
0 | 52 |
|
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
53 |
@layout.setter |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
54 |
def layout(self, value): |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
55 |
"""Layout manager for placing child widgets.""" |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
56 |
self._layout = value |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
57 |
self._layout.container = self |
0 | 58 |
|
59 |
||
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
60 |
def _set_top(self, value): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
61 |
self._top = value |
0 | 62 |
for child in self.children: |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
63 |
child.top = value |
0 | 64 |
|
65 |
||
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
66 |
def focus_next(self): |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
67 |
"""Focus next child. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
68 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
69 |
Sets focus to next child, if there is one |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
70 |
which can be focused. Cycles from last child |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
71 |
to first when needed. Return value depends on |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
72 |
this cycling: |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
73 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
74 |
* False means there wasn't any child to focus |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
75 |
before end of list, so first child was focused. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
76 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
77 |
* True when focus is set to next child in normal |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
78 |
way or when self.trap_focus is set. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
79 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
80 |
Return value is supposed to be returned from keypress |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
81 |
event - in that case, True stops event propagation. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
82 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
83 |
""" |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
84 |
idx_current = self.children.index(self.focuschild) |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
85 |
idx_new = idx_current + 1 |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
86 |
cycled = False |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
87 |
while idx_current != idx_new: |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
88 |
if idx_new >= len(self.children): |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
89 |
idx_new = 0 |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
90 |
cycled = True |
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
91 |
if self.children[idx_new].can_focus(): |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
92 |
self.children[idx_new].set_focus() |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
93 |
return self.trap_focus or not cycled |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
94 |
idx_new += 1 |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
95 |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
96 |
def draw(self, driver, x, y): |
36 | 97 |
"""Draw the container and its children. |
98 |
||
99 |
This method should not be overriden by subclasses, |
|
100 |
use on_draw instead. |
|
101 |
||
102 |
""" |
|
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
103 |
if self.hidden: |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
104 |
return True |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
105 |
|
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
106 |
driver.clipstack.push(x, y, self.width, self.height) |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
107 |
if self.colorprefix: |
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
108 |
driver.pushcolorprefix(self.colorprefix) |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
109 |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
110 |
super().draw(driver, x, y) |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
111 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
112 |
for child in [x for x in self.children if not x.allow_layout]: |
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
113 |
child.draw(driver, x + child.x, y + child.y) |
0 | 114 |
|
115 |
l, t, r, b = self.borders |
|
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
116 |
driver.clipstack.push(x+l, y+t, self.width-l-r, self.height-t-b) |
0 | 117 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
118 |
for child in [x for x in self.children if x.allow_layout]: |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
119 |
child.draw(driver, |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
120 |
x + self.offset.x + child.x, |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
121 |
y + self.offset.y + child.y) |
0 | 122 |
|
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
123 |
driver.clipstack.pop() |
0 | 124 |
|
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
125 |
if self.colorprefix: |
23
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
126 |
driver.popcolorprefix() |
4e72fd2a0e14
Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
127 |
driver.clipstack.pop() |
0 | 128 |
|
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
129 |
def _handle_resize(self, ev): |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
130 |
super()._handle_resize(ev) |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
131 |
for child in self.children: |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
132 |
child.emit('resize') |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
133 |
|
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
134 |
def _handle_keypress(self, ev): |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
135 |
super()._handle_keypress(ev) |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
136 |
if self.focuschild is not None: |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
137 |
handled = self.focuschild.emit('keypress', ev) |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
138 |
if handled: |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
139 |
return True |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
140 |
if ev.keyname == 'tab': |
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
141 |
return self.focus_next() |
0 | 142 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
143 |
def _handle_mousedown(self, ev): |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
144 |
super()._handle_mousedown(ev) |
0 | 145 |
handled = False |
146 |
for child in reversed(self.children): |
|
147 |
if child.enclose(ev.wx, ev.wy): |
|
148 |
childev = ev.childevent(child) |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
149 |
child.emit('mousedown', childev) |
0 | 150 |
self.mousechild = child |
151 |
handled = True |
|
152 |
break |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
153 |
return handled |
0 | 154 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
155 |
def _handle_mouseup(self, ev): |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
156 |
super()._handle_mouseup(ev) |
0 | 157 |
if self.mousechild: |
158 |
childev = ev.childevent(self.mousechild) |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
159 |
self.mousechild.emit('mouseup', childev) |
0 | 160 |
self.mousechild = None |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
161 |
return True |
0 | 162 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
163 |
def _handle_mousemove(self, ev): |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
164 |
super()._handle_mousemove(ev) |
0 | 165 |
if self.mousechild: |
166 |
childev = ev.childevent(self.mousechild) |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
167 |
self.mousechild.emit('mousemove', childev) |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
168 |
return True |
0 | 169 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
170 |
def _handle_mousewheel(self, ev): |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
171 |
super()._handle_mousewheel(ev) |
0 | 172 |
handled = False |
173 |
for child in reversed(self.children): |
|
174 |
if child.enclose(ev.wx, ev.wy): |
|
175 |
childev = ev.childevent(child) |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
176 |
child.emit('mousewheel', childev) |
0 | 177 |
handled = True |
178 |
break |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
179 |
return handled |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
32
diff
changeset
|
180 |