Exemplo n.º 1
0
 def __get_columns_mouse_data(self, event, move_check=False):
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     save_x, save_y = 0, 0
     if self.__in_columns_check(offset_y, event):
         # 获取行item,列的sub_items.
         x_padding = 0
         col_index = 0
         for column in self.columns:
             if move_check:
                 padding_width = x_padding + column.width
                 # 判断是否在移动区域内.
                 if (padding_width -
                         self.__press_columns_area_width) <= int(
                             event.x) <= padding_width:
                     return col_index, True
             else:
                 if x_padding <= int(event.x) <= x_padding + column.width:
                     save_x = int(event.x - x_padding)
                     save_y = int(event.y)
                     return col_index, save_x, save_y
             col_index += 1
             x_padding += column.width
     # 返回空数据.
     if move_check:
         return None, False
     else:
         return None, None, None
 def __get_columns_mouse_data(self, event, move_check=False):
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     save_x, save_y = 0, 0
     if self.__in_columns_check(offset_y, event):
         # 获取行item,列的sub_items.
         x_padding = 0
         col_index = 0
         for column in self.columns:
             if move_check:
                 padding_width = x_padding + column.width
                 # 判断是否在移动区域内.
                 if (padding_width - self.__press_columns_area_width) <= int(event.x) <= padding_width:
                     return col_index, True
             else:
                 if x_padding <= int(event.x) <= x_padding + column.width:
                     save_x = int(event.x - x_padding)
                     save_y = int(event.y)
                     return col_index, save_x, save_y
             col_index += 1
             x_padding += column.width
     # 返回空数据.
     if move_check:
         return None, False
     else:
         return None, None, None
Exemplo n.º 3
0
 def __get_items_mouse_data(self, event, move_check=False):
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     save_x, save_y = 0, 0
     if self.__in_items_check(offset_y, event):
         event_x = event.x  # 获取鼠标x.
         # 获取行号.
         event_y_padding = int(event.y - self.__columns_padding_height)
         row_index = event_y_padding / self.__items_padding_height
         x_padding = 0
         col_index = 0
         # 获取行item,列的sub_items.
         if not move_check:
             for column in self.columns:
                 if x_padding <= int(event.x) <= x_padding + column.width:
                     save_x = int(event.x - x_padding)
                     save_y = int(event_y_padding - row_index * self.__items_padding_height)
                     break
                 x_padding += column.width
                 col_index += 1
         # 判断是否在可显示的列内.
         if (row_index < len(self.items)) and (col_index < len(self.items[row_index].sub_items)):
             if move_check:  # 判断是否移动items.
                 return row_index, True
             else:
                 return row_index, col_index, save_x, save_y
         else:
             if move_check:  # 判断是否移动items.
                 return row_index, True
             else:
                 return row_index, None, save_x, save_y
     else:  # 鼠标点击不在区域内.
         if move_check:  # 判断是否移动items.
             return None, False
         else:
             return None, None, None, None
 def __get_start_end_index(self):
     rect = self.allocation
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     #
     # 获取滚动窗口.
     scroll_win = get_match_parent(self, "ScrolledWindow")
     scroll_rect_h = rect.height
     if scroll_win: # 如果没有滚动窗口,直接获取listview的高度.
         scroll_rect_h = scroll_win.allocation.height
     start_y = offset_y - self.__columns_padding_height
     end_y   = offset_y + viewport.allocation.height - self.__columns_padding_height
     start_index  = max(int(scroll_win.get_vadjustment().get_value() / self.__items_padding_height), 0)
     end_index    = (start_index + (scroll_rect_h - self.__columns_padding_height)/ self.__items_padding_height) + 1
     return start_index, end_index
 def on_queue_draw_area(self):
     # 重绘区域.
     if self.__expose_check:
         scroll_win = get_match_parent(self, "ScrolledWindow")
         offset_x, offset_y , viewport = get_offset_coordinate(self)
         rect = self.allocation
         if scroll_win:
             rect = scroll_win.allocation
             x      = 0  + offset_x #rect.x + offset_x
             y      = 0  + offset_y #rect.y + offset_y
             w      = rect.width
             h      = rect.height
         else:
             x      = rect.x + offset_x
             y      = rect.y + offset_y
             w      = rect.width
             h      = rect.height
         self.queue_draw_area(x, y, w, h)
Exemplo n.º 6
0
 def __get_start_end_index(self):
     rect = self.allocation
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     #
     # 获取滚动窗口.
     scroll_win = get_match_parent(self, "ScrolledWindow")
     scroll_rect_h = rect.height
     if scroll_win:  # 如果没有滚动窗口,直接获取listview的高度.
         scroll_rect_h = scroll_win.allocation.height
     start_y = offset_y - self.__columns_padding_height
     end_y = offset_y + viewport.allocation.height - self.__columns_padding_height
     start_index = max(
         int(scroll_win.get_vadjustment().get_value() /
             self.__items_padding_height), 0)
     end_index = (start_index +
                  (scroll_rect_h - self.__columns_padding_height) /
                  self.__items_padding_height) + 1
     return start_index, end_index
Exemplo n.º 7
0
 def __draw_view_details(self, cr, rect, widget):
     #
     offset_x, offset_y, viewport = get_offset_coordinate(widget)
     #
     e = ItemEventArgs()
     save_rect = rect
     e.cr = cr
     e.rect = (rect.x, rect.y + offset_y + self.__columns_padding_height,
               rect.width, rect.height)
     e.drag_rect = self.__drag_rect
     self.on_draw_item(e)
     # 画标题头.
     if self.__columns_show_check:
         self.__draw_view_details_column(offset_y, cr, rect)
     # 优化listview.
     # 获取滚动窗口.
     scroll_win = get_match_parent(self, "ScrolledWindow")
     scroll_rect_h = rect.height
     if scroll_win:  # 如果没有滚动窗口,直接获取listview的高度.
         scroll_rect_h = scroll_win.allocation.height
     # dtk.ui.listview ===>>>
     start_y = offset_y - self.__columns_padding_height
     end_y = offset_y + viewport.allocation.height - self.__columns_padding_height
     #start_index  = max(start_y / self.__items_padding_height, 0)
     start_index = max(
         int(scroll_win.get_vadjustment().get_value() /
             self.__items_padding_height), 0)
     end_index = (start_index +
                  (scroll_rect_h - self.__columns_padding_height) /
                  self.__items_padding_height) + 2
     #
     # 剪切出绘制items的区域,防止绘制到标题头上.
     cr.save()
     cr.rectangle(rect.x + offset_x,
                  rect.y + offset_y + self.__columns_padding_height,
                  scroll_win.allocation.width, scroll_win.allocation.height)
     cr.clip()
     # 画 items.
     self.__draw_view_details_items(start_index, end_index, cr, rect)
     cr.restore()
     #
     # 画上面和下面的效果.
     self.on_draw_item_fg(cr, rect)
Exemplo n.º 8
0
 def __draw_view_details(self, cr, rect, widget):
     #
     offset_x, offset_y, viewport = get_offset_coordinate(widget)
     #
     e = ItemEventArgs()
     save_rect = rect
     e.cr = cr
     e.rect = (rect.x, rect.y + offset_y + self.__columns_padding_height, rect.width, rect.height)
     e.drag_rect = self.__drag_rect
     self.on_draw_item(e)
     # 画标题头.
     if self.__columns_show_check:
         self.__draw_view_details_column(offset_y, cr, rect)
     # 优化listview.
     # 获取滚动窗口.
     scroll_win = get_match_parent(self, "ScrolledWindow")
     scroll_rect_h = rect.height
     if scroll_win:  # 如果没有滚动窗口,直接获取listview的高度.
         scroll_rect_h = scroll_win.allocation.height
     # dtk.ui.listview ===>>>
     start_y = offset_y - self.__columns_padding_height
     end_y = offset_y + viewport.allocation.height - self.__columns_padding_height
     # start_index  = max(start_y / self.__items_padding_height, 0)
     start_index = max(int(scroll_win.get_vadjustment().get_value() / self.__items_padding_height), 0)
     end_index = (start_index + (scroll_rect_h - self.__columns_padding_height) / self.__items_padding_height) + 2
     #
     # 剪切出绘制items的区域,防止绘制到标题头上.
     cr.save()
     cr.rectangle(
         rect.x + offset_x,
         rect.y + offset_y + self.__columns_padding_height,
         scroll_win.allocation.width,
         scroll_win.allocation.height,
     )
     cr.clip()
     # 画 items.
     self.__draw_view_details_items(start_index, end_index, cr, rect)
     cr.restore()
     #
     #  画上面和下面的效果.
     self.on_draw_item_fg(cr, rect)
Exemplo n.º 9
0
 def __get_items_mouse_data(self, event, move_check=False):
     offset_x, offset_y, viewport = get_offset_coordinate(self)
     save_x, save_y = 0, 0
     if self.__in_items_check(offset_y, event):
         event_x = event.x  # 获取鼠标x.
         # 获取行号.
         event_y_padding = int(event.y - self.__columns_padding_height)
         row_index = event_y_padding / self.__items_padding_height
         x_padding = 0
         col_index = 0
         # 获取行item,列的sub_items.
         if not move_check:
             for column in self.columns:
                 if x_padding <= int(event.x) <= x_padding + column.width:
                     save_x = int(event.x - x_padding)
                     save_y = int(event_y_padding -
                                  row_index * self.__items_padding_height)
                     break
                 x_padding += column.width
                 col_index += 1
         # 判断是否在可显示的列内.
         if ((row_index < len(self.items))
                 and (col_index < len(self.items[row_index].sub_items))):
             if move_check:  # 判断是否移动items.
                 return row_index, True
             else:
                 return row_index, col_index, save_x, save_y
         else:
             if move_check:  # 判断是否移动items.
                 return row_index, True
             else:
                 return row_index, None, save_x, save_y
     else:  # 鼠标点击不在区域内.
         if move_check:  # 判断是否移动items.
             return None, False
         else:
             return None, None, None, None