Package Gnumed :: Package timelinelib :: Package wxgui :: Package components :: Package searchbar :: Module view
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.components.searchbar.view

 1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline 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  # Timeline 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 Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  """ 
20  The search bar is a gui component displayed in the status bar whenever  
21  the user presses Ctrl+F. It consists of the following visual components. 
22      * A close button 
23      * A search button 
24      * A text field 
25      * A backward navigation button 
26      * A forward navigation button 
27      * A 'display list' button 
28      * Report labels for 'no event found' and 'one event found' 
29   
30  The parent of the component is the TimelinePanel. 
31      
32  As with all gui components all business logic is handles by a controller. 
33  Actions on the components are directly delegated to the controller. 
34   
35  The component (or actually the controller) needs a Canvas object in order  
36  to find events containing the given text. The Canvas object is injected  
37  with the SetTimelineCanvas() function. 
38           
39  """ 
40   
41  import wx 
42   
43  from timelinelib.wxgui.components.searchbar.controller import SearchBarController 
44  from timelinelib.wxgui.components.searchbar.guicreator.guicreator import GuiCreator 
45   
46   
47 -class SearchBar(wx.ToolBar, GuiCreator):
48
49 - def __init__(self, parent):
50 wx.ToolBar.__init__(self, parent, style=wx.TB_HORIZONTAL | wx.TB_BOTTOM) 51 self._controller = SearchBarController(self) 52 self._create_gui() 53 self.UpdateButtons()
54 55 # 56 # Parent API 57 # 58
59 - def SetTimelineCanvas(self, timeline_canvas):
60 self._controller.set_timeline_canvas(timeline_canvas)
61 62 # 63 # Controller APIs 64 # 65
66 - def GetValue(self):
67 return self._search.GetValue()
68
69 - def GetPeriod(self):
70 return self._period.GetString()
71
72 - def UpdateNbrOfMatchesLabel(self, label):
73 self._result_label.SetLabel(label) 74 self._result_label.Show(True)
75
76 - def UpdateButtons(self):
77 self.EnableTool(wx.ID_BACKWARD, self._controller.enable_backward()) 78 self.EnableTool(wx.ID_FORWARD, self._controller.enable_forward()) 79 self.EnableTool(wx.ID_MORE, self._controller.enable_list())
80
81 - def SetPeriodChoices(self, choices):
82 self._period.SetPeriodChoices(choices)
83
84 - def Close(self):
85 self._result_label.Show(False) 86 self.Show(False) 87 self.GetParent().Layout()
88