Example #1
0
	def _create_toolbar(self):
		toolbar = self.wnd.CreateToolBar()
		tbi = toolbar.AddLabelTool(-1, _('New Note'),
				iconprovider.get_image("task_new"),
				shortHelp=_('Add new notebook page'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_new_page, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Edit Note'),
				iconprovider.get_image('task_edit'),
				shortHelp=_('Edit selected notebook page'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_edit_page,
				id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Delete Note'),
				iconprovider.get_image('task_delete'),
				shortHelp=_('Delete selected notebook page'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_delete_page,
				id=tbi.GetId())

		toolbar.AddSeparator()

		tbi = toolbar.AddLabelTool(-1, _('Exit'),
			iconprovider.get_image("exit"),
			shortHelp=_('Close window'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_close, id=tbi.GetId())

		toolbar.Realize()
Example #2
0
def draw_info(mdc, task, overdue, cache):
	""" Draw information about task on given DC.

	Args:
		mdc: DC canvas
		task: task to render
		overdue: is task overdue
	"""
	main_icon_y_offset = (SETTINGS['line_height'] - 32) / 2
	icon_name = _TYPE_ICON_NAMES.get(task.type)
	if icon_name:
		mdc.DrawBitmap(iconprovider.get_image(icon_name), 0, main_icon_y_offset,
				False)
	if task.completed:
		mdc.SetTextForeground(wx.Colour(150, 150, 150))
	elif overdue:
		mdc.SetTextForeground(wx.RED)
	else:
		mdc.SetTextForeground(wx.BLACK)
	mdc.SetFont(SETTINGS['font_task'])
	mdc.DrawText(task.title, 35, 5)
	mdc.SetFont(SETTINGS['font_info'])
	y_off = mdc.GetTextExtent("Agw")[1] + 10
	x_off = 35

	x_off = _draw_info_task_status(mdc, cache, task, x_off, y_off)
	x_off = _draw_info_task_context(mdc, cache, task, x_off, y_off)
	x_off = _draw_info_task_parent(mdc, cache, task, x_off, y_off)
	x_off = _draw_info_task_goal(mdc, cache, task, x_off, y_off)
	x_off = _draw_info_task_folder(mdc, cache, task, x_off, y_off)
	x_off = _draw_info_task_tags(mdc, cache, task, x_off, y_off)
Example #3
0
def _draw_info_task_status(mdc, cache, task, x_off, y_off):
	task_status = cache.get('task_status')
	if task_status is None and task.status:
		cache['task_status'] = task_status = enums.STATUSES[task.status]
		cache['task_status_x_off'] = mdc.GetTextExtent(task_status)[0] + 10
	if task_status:
		mdc.DrawBitmap(iconprovider.get_image('status_small'), x_off,
				y_off, False)
		x_off += 15  # 12=icon
		mdc.DrawText(task_status, x_off, y_off)
		x_off += cache['task_status_x_off']
	return x_off
Example #4
0
def _draw_info_task_tags(mdc, cache, task, x_off, y_off):
	task_tags = cache.get('task_tags')
	if task_tags is None and task.tags:
		cache['task_tags'] = task_tags = ",".join(
				tag.title for tag in task.tags)
	if task_tags:
		mdc.DrawBitmap(iconprovider.get_image('tag_small'), x_off,
				y_off, False)
		x_off += 15  # 12=icon
		mdc.DrawText(task_tags, x_off, y_off)
		#x_off += mdc.GetTextExtent(task_tags)[0] + 10
	return x_off
Example #5
0
def _draw_info_task_folder(mdc, cache, task, x_off, y_off):
	task_folder = cache.get('task_folder')
	if task_folder is None and task.folder:
		cache['task_folder'] = task_folder = task.folder.title
		cache['task_folder_x_off'] = mdc.GetTextExtent(task_folder)[0] + 10
	if task_folder:
		mdc.DrawBitmap(iconprovider.get_image('folder_small'), x_off,
				y_off, False)
		x_off += 15  # 12=icon
		mdc.DrawText(task_folder, x_off, y_off)
		x_off += cache['task_folder_x_off']
	return x_off
Example #6
0
def _draw_info_task_goal(mdc, cache, task, x_off, y_off):
	task_goal = cache.get('task_goal')
	if task_goal is None and task.goal:
		cache['task_goal'] = task_goal = task.goal.title
		cache['task_goal_x_off'] = mdc.GetTextExtent(task_goal)[0] + 10
	if task_goal:
		mdc.DrawBitmap(iconprovider.get_image('goal_small'), x_off,
				y_off, False)
		x_off += 15  # 12=icon
		mdc.DrawText(task_goal, x_off, y_off)
		x_off += cache['task_goal_x_off']
	return x_off
Example #7
0
	def __init__(self, parent_frame):
		wx.TaskBarIcon.__init__(self)
		self._frame = parent_frame
		# icon
		img = wx.ImageFromBitmap(iconprovider.get_image('wxgtd'))
		if "wxMSW" in wx.PlatformInfo:
			img = img.Scale(16, 16)
		elif "wxGTK" in wx.PlatformInfo:
			img = img.Scale(22, 22)
		icon = wx.IconFromBitmap(img.ConvertToBitmap())
		self.SetIcon(icon, _("wxGTD"))

		self._create_bindings()
Example #8
0
def draw_icons(mdc, task, overdue, active_only, cache):
	""" Draw information icons about task on given DC.

	Args:
		mdc: DC canvas
		task: task to render
		overdue: is task overdue
		active_only: showing information only active subtask.
	"""
	mdc.SetFont(SETTINGS['font_info'])
	y_off = mdc.GetTextExtent("Agw")[1] + 10
	if task.starred:
		mdc.DrawBitmap(iconprovider.get_image('starred_small'), 0, 7, False)

	child_count = cache.get('child_count')
	if child_count is None:
		child_count = task.active_child_count if active_only else \
				task.child_count
		cache['child_count'] = child_count
	if child_count > 0:
		info = cache.get('info')
		if info is None:
			info = ''
			overdue = cache.get('overdue')
			if overdue > 0:
				info += "%d / " % overdue
			info += "%d" % child_count
			cache['info'] = info
		mdc.DrawText(info, 16, 7)
	if task.alarm:
		mdc.DrawBitmap(iconprovider.get_image('alarm_small'), 0, y_off,
				False)
	if task.repeat_pattern and task.repeat_pattern != 'Norepeat':
		mdc.DrawBitmap(iconprovider.get_image('repeat_small'), 16, y_off,
				False)
	if task.note:
		mdc.DrawBitmap(iconprovider.get_image('note_small'), 32, y_off,
				False)
Example #9
0
def _draw_info_task_parent(mdc, cache, task, x_off, y_off):
	task_parent = cache.get('task_parent')
	if task_parent is None and task.parent:
		task_parents = []
		while task.parent:
			task_parents.insert(0, task.parent.title)
			task = task.parent
		task_parent = '/'.join(task_parents)
		cache['task_parent'] = task_parent
		cache['task_parent_x_off'] = mdc.GetTextExtent(task_parent)[0] + 10
	if task_parent:
		mdc.DrawBitmap(iconprovider.get_image('project_small'), x_off,
				y_off, False)
		x_off += 15  # 12=icon
		mdc.DrawText(task_parent, x_off, y_off)
		x_off += cache['task_parent_x_off']
	return x_off
Example #10
0
	def _create_toolbar(self):
		toolbar = self.wnd.CreateToolBar()
		tbi = toolbar.AddLabelTool(-1, _('New Task'),
				iconprovider.get_image("task_new"),
				shortHelp=_('Add new task'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_new_task, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Quick Task'),
				iconprovider.get_image("task_quick"),
				shortHelp=_('Add quick new task'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_quick_task, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Edit Task'),
				iconprovider.get_image('task_edit'),
				shortHelp=_('Edit selected task'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_edit_selected_task,
				id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Delete Task'),
				iconprovider.get_image('task_delete'),
				shortHelp=_('Delete selected task'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_delete_selected_task,
				id=tbi.GetId())

		toolbar.AddSeparator()

		tbi = toolbar.AddLabelTool(-1, _('Toggle Task Completed'),
				iconprovider.get_image('task_done'),
				shortHelp=_('Toggle selected task completed'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_complete_task, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Toggle Task Starred'),
				iconprovider.get_image('task_starred'),
				shortHelp=_('Toggle selected task starred'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_starred_task, id=tbi.GetId())

		toolbar.AddSeparator()

		appconfig = self._appconfig

		# show subtask
		self._btn_show_subtasks = wx.ToggleButton(toolbar,  # pylint: disable=W0201
				-1, _(" Show subtasks "))
		toolbar.AddControl(self._btn_show_subtasks)
		self.wnd.Bind(wx.EVT_TOGGLEBUTTON, self._on_btn_show_subtasks,
				self._btn_show_subtasks)
		self._btn_show_subtasks.SetValue(appconfig.get('main', 'show_subtask', True))

		toolbar.AddControl(wx.StaticText(toolbar, -1, " "))

		# show completed
		self._btn_show_finished = wx.ToggleButton(toolbar,  # pylint: disable=W0201
				-1, _(" Show finished "))
		toolbar.AddControl(self._btn_show_finished)
		self.wnd.Bind(wx.EVT_TOGGLEBUTTON, self._on_btn_show_finished,
				self._btn_show_finished)
		self._btn_show_finished.SetValue(appconfig.get('main', 'show_finished',
				False))

		toolbar.AddControl(wx.StaticText(toolbar, -1, " "))

		# hide until due
		self._btn_hide_until = wx.ToggleButton(toolbar,  # pylint: disable=W0201
				-1, _(" Hide until "))
		toolbar.AddControl(self._btn_hide_until)
		self.wnd.Bind(wx.EVT_TOGGLEBUTTON, self._on_btn_hide_due,
				self._btn_hide_until)
		self._btn_hide_until.SetValue(appconfig.get('main', 'show_hide_until', True))

		toolbar.AddSeparator()

		tbi = toolbar.AddLabelTool(-1, _('Synchronize tasks'),
				iconprovider.get_image('sync'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_menu_file_sync, id=tbi.GetId())

		toolbar.AddSeparator()

		# search box
		self._searchbox = wx.SearchCtrl(toolbar, -1,  # pylint: disable=W0201
				size=(150, -1), style=wx.TE_PROCESS_ENTER)
		self._searchbox.SetDescriptiveText(_('Search'))
		self._searchbox.ShowCancelButton(True)
		toolbar.AddControl(self._searchbox)
		#self.wnd.Bind(wx.EVT_TEXT, self._on_search, self._searchbox)
		self.wnd.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self._on_search,
				self._searchbox)
		self.wnd.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self._on_search_cancel,
				self._searchbox)
		self.wnd.Bind(wx.EVT_TEXT_ENTER, self._on_search, self._searchbox)

		toolbar.AddSeparator()

		tbi = toolbar.AddLabelTool(-1, _('Reminders'),
				iconprovider.get_image('reminders'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_btn_reminders, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Notebook'),
				iconprovider.get_image('notebook'))
		self.wnd.Bind(wx.EVT_TOOL, self._on_menu_notebook_open, id=tbi.GetId())

		tbi = toolbar.AddLabelTool(-1, _('Search'),
				iconprovider.get_image(wx.ART_FIND))
		self.wnd.Bind(wx.EVT_TOOL, self._on_menu_search_task, id=tbi.GetId())

		toolbar.Realize()