tuikit/container.py
author Radek Brich <radek.brich@devl.cz>
Sun, 02 Oct 2011 23:32:35 +0200
changeset 15 c55b4749e562
parent 13 19ebde2fd594
child 16 8791a7da6835
permissions -rw-r--r--
Add Pager.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
from .widget import Widget
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
     4
import logging
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     6
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
class Container(Widget):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     8
    
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.'''
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    10
    
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    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
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
        Widget.__init__(self, width, height)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    15
        #: List of child widgets.
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
        self.children = []
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    17
        
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
        self.mousechild = None
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    20
        #: Width of borders (left, top, right, bottom).
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    21
        #: Child widgets are placed within borders.
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    22
        self.borders = (0, 0, 0, 0)
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    23
        
15
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    24
        self._layout = None
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    25
        
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
        self.widthrequest = (None, None)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
        self.heightrequest = (None, None)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
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
    29
        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
    30
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
    31
        self.trapfocus = False  # if True, tab cycles inside container
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
    32
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
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
    34
    def add(self, widget, **kw):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    35
        '''Add widget into this container.'''
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
        self.children.append(widget)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
        widget.parent = self
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
        widget.settop(self.top)
15
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    39
        widget.hints.update(kw)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
    def layout(self, layout):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    43
        '''Set layout manager for placing child widgets.'''
15
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    44
        self._layout = layout
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
        layout.container = self
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
        self.connect('resize', layout.resize)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
    def settop(self, top):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    50
        '''Set top widget.'''
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
        self.top = top
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
        for child in self.children:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
            child.settop(top)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    55
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
    56
    def focusnext(self):
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
    57
        i = self.children.index(self.top.focuswidget)
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
    58
        while True:
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
    59
            i += 1
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
    60
            if i >= len(self.children):
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
    61
                i = 0
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
    62
            if self.children[i].canfocus():
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
    63
                self.children[i].setfocus()
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
    64
                break
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
    65
        log = logging.getLogger('tuikit')
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
    66
        log.debug(str(self.top.focuswidget.__class__))
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
    67
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
    68
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
    69
    def keypress(self, keyname, char):
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
    70
        if keyname == 'tab':
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
    71
            self.focusnext()
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
    72
            return
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
    73
        Widget.keypress(self, keyname, char)
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
    74
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
    75
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
    76
    def resize(self):
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
    77
        Widget.resize(self)
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
    78
        for child in self.children:
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
    79
            child.emit('resize')
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
    80
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
    81
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    82
    def draw(self, screen, x=0, y=0):
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents: 1
diff changeset
    83
        if self.hidden:
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents: 1
diff changeset
    84
            return
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
    85
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
    86
        screen.pushclip(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
    87
        if self.colorprefix:
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
    88
            screen.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
    89
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
    90
        Widget.draw(self, screen, x, y)
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
    91
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
    92
        for child in [x for x in self.children if not x.allowlayout]:
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
    93
            child.draw(screen, x + child.x, y + child.y)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    94
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    95
        l, t, r, b = self.borders
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
    96
        screen.pushclip(x+l, y+t, self.width-l-r, self.height-t-b)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    97
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
    98
        for child in [x for x in self.children if x.allowlayout]:
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    99
            child.draw(screen, x + child.x, y + child.y)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   100
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   101
        screen.popclip()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   102
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
   103
        if self.colorprefix:
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
   104
            screen.popcolorprefix()
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
        screen.popclip()
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   106
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   107
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   108
    def mousedown(self, ev):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   109
        handled = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   110
        for child in reversed(self.children):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   111
            if child.enclose(ev.wx, ev.wy):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   112
                childev = ev.childevent(child)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   113
                child.mousedown(childev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   114
                self.mousechild = child
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   115
                handled = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   116
                break
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   117
        if not handled:
1
69318aba22bf Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents: 0
diff changeset
   118
            self.setfocus()
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   119
            self.handle('mousedown', ev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   120
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   121
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   122
    def mouseup(self, ev):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   123
        if self.mousechild:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   124
            childev = ev.childevent(self.mousechild)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   125
            self.mousechild.mouseup(childev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   126
            self.mousechild = None
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   127
        else:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   128
            self.handle('mouseup', ev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   129
        #handled = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   130
        #for child in self.children:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   131
            #if child.enclose(ev.wx, ev.wy):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   132
                #childev = ev.childevent(child)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   133
                #child.mouseup(childev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   134
                #self.mousechild = child
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   135
                #handled = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   136
        #if not handled:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   137
            #self.handle('mouseup', ev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   138
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   139
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   140
    def mousemove(self, ev):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   141
        if self.mousechild:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   142
            childev = ev.childevent(self.mousechild)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   143
            self.mousechild.mousemove(childev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   144
        else:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   145
            self.handle('mousemove', ev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   146
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   147
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   148
    def mousewheel(self, ev):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   149
        handled = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   150
        for child in reversed(self.children):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   151
            if child.enclose(ev.wx, ev.wy):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   152
                childev = ev.childevent(child)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   153
                child.mousewheel(childev)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   154
                handled = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   155
                break
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   156
        if not handled:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   157
            self.handle('mousewheel', ev)