~ubuntu-branches/ubuntu/utopic/taskcoach/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/official_squaremap.diff/taskcoachlib/widgets/squaremap.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-08-15 14:54:44 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140815145444-qm2ya2zvy1pyrcl5
Tags: 1.4.0-1ubuntu1
* Merge with Debian; remaining changes:
  - Let the autopkg test depend on language-pack-en.
  - Build-depend on language-pack-en.
* Build using python-wxgtk3.0.
* Don't use /usr/share/pyshared anymore, it's gone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''
 
2
Task Coach - Your friendly task manager
 
3
Copyright (C) 2004-2014 Task Coach developers <developers@taskcoach.org>
 
4
 
 
5
Task Coach is free software: you can redistribute it and/or modify
 
6
it under the terms of the GNU General Public License as published by
 
7
the Free Software Foundation, either version 3 of the License, or
 
8
(at your option) any later version.
 
9
 
 
10
Task Coach is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
'''
 
18
 
 
19
import wx, operator
 
20
from taskcoachlib.thirdparty.squaremap import squaremap
 
21
import tooltip
 
22
 
 
23
 
 
24
class SquareMap(tooltip.ToolTipMixin, squaremap.SquareMap):
 
25
    def __init__(self, parent, rootNode, onSelect, onEdit, popupMenu):
 
26
        self.__selection = []
 
27
        self.getItemTooltipData = parent.getItemTooltipData
 
28
        super(SquareMap, self).__init__(parent, model=rootNode, adapter=parent, 
 
29
                                        highlight=False)
 
30
        
 
31
        self.__tip = tooltip.SimpleToolTip(self)
 
32
        self.selectCommand = onSelect
 
33
        self.Bind(squaremap.EVT_SQUARE_SELECTED, self.onSelect)
 
34
        self.editCommand = onEdit
 
35
        self.Bind(squaremap.EVT_SQUARE_ACTIVATED, self.onEdit)
 
36
        self.popupMenu = popupMenu
 
37
        self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup)
 
38
        
 
39
    def RefreshAllItems(self, count): # pylint: disable=W0613
 
40
        self.UpdateDrawing()
 
41
        
 
42
    def RefreshItems(self, *args): # pylint: disable=W0613
 
43
        self.UpdateDrawing()
 
44
        
 
45
    def onSelect(self, event):
 
46
        if event.node == self.model:
 
47
            self.__selection = []
 
48
        else:
 
49
            self.__selection = [event.node]
 
50
        wx.CallAfter(self.selectCommand)
 
51
        event.Skip()
 
52
        
 
53
    def select(self, items):
 
54
        pass
 
55
    
 
56
    def onEdit(self, event):
 
57
        self.editCommand(event)
 
58
        event.Skip()
 
59
        
 
60
    def OnBeforeShowToolTip(self, x, y):
 
61
        item = squaremap.HotMapNavigator.findNodeAtPosition(self.hot_map, (x,y))
 
62
        if item is None or item == self.model:
 
63
            return None
 
64
        tooltipData = self.getItemTooltipData(item)
 
65
        doShow = reduce(operator.__or__,
 
66
                        map(bool, [data[1] for data in tooltipData]),
 
67
                        False)
 
68
        if doShow:
 
69
            self.__tip.SetData(tooltipData)
 
70
            return self.__tip
 
71
        else:
 
72
            return None
 
73
        
 
74
    def onPopup(self, event):
 
75
        self.OnClickRelease(event) # Make sure the node is selected
 
76
        self.SetFocus()
 
77
        self.PopupMenu(self.popupMenu)
 
78
    
 
79
    def curselection(self):
 
80
        return self.__selection
 
81
 
 
82
    def GetItemCount(self):
 
83
        return 0
 
84
 
 
85
    def isAnyItemExpandable(self):
 
86
        return False
 
87
 
 
88
    isAnyItemCollapsable = isAnyItemExpandable
 
89
 
 
90
    def GetMainWindow(self):
 
91
        return self
 
92
    
 
93
    MainWindow = property(GetMainWindow)