Beispiel #1
0
 def display_cursor(self):
     painter = QPainter(self)
     col = self.cur_pos
     y = self.fixed_font_metrics.ascent() + ((self.height - 1) * self.fixed_font_height)
     x = 1 + ((col - 1) * self.fixed_font_width)
     painter.setPen(self.ztoq_color(self.cur_fg))
     painter.setBackground(QBrush(self.ztoq_color(self.cur_bg)))
     painter.drawText(x,y,unichr(0x2581))
Beispiel #2
0
 def paintEvent(self,e):
     painter = QPainter(self)
     painter.fillRect(0, 0, self.width * self.fixed_font_width + 2, self.height * self.fixed_font_height, Qt.black)
     painter.setPen(Qt.gray)
     painter.setRenderHint(QPainter.TextAntialiasing)
     painter.setFont(self.fixed_font)
     painter.setBackgroundMode(Qt.OpaqueMode)
     # Print main window
     l = self.height
     while (l > 0):
         c = 1
         while (c <= self.width):
             y = self.fixed_font_metrics.ascent() + (l - 1) * self.fixed_font_height
             x = 1 + ((c - 1) * self.fixed_font_width)
             #print "**",l,"**",c
             if self.buf[(((self.height - l) * self.width) + c - 1) * 4] == 0:
                 painter.setPen(self.ztoq_color(self.cur_fg))
             else:
                 painter.setPen(self.ztoq_color(self.buf[(((self.height - l) * self.width) + c - 1) * 4]))
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 1] == 0:
                 painter.setBackground(QBrush(self.ztoq_color(self.cur_bg)))
             else:
                 painter.setBackground(QBrush(self.ztoq_color(self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 1])))
             # Set appropriate font style
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 2] == 0:
                 f = painter.font()
                 f.setBold(False)
                 f.setItalic(False)
                 painter.setFont(f)
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 2] & 1: # Reverse video
                 painter.setPen(self.ztoq_color(self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 1]))
                 painter.setBackground(QBrush(self.ztoq_color(self.buf[(((self.height - l) * self.width) + c - 1) * 4])))
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 2] & 2: # Bold
                 f = painter.font()
                 f.setBold(True)
                 painter.setFont(f)
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 2] & 4: # Italic
                 f = painter.font()
                 f.setItalic(True)
                 painter.setFont(f)
             if self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 3] <> 0:
                 painter.drawText(x,y,self.buf[((((self.height - l) * self.width) + c - 1) * 4) + 3])
             c += 1
         l -= 1
         c = 1
     # Print upper window
     if self.upper_buf <> []:
         l = 1
         while (l <= self.upper_buf_height):
             c = 1
             while (c <= self.width):
                 y = self.fixed_font_metrics.ascent() + (l - 1) * self.fixed_font_height
                 x = 1 + ((c - 1) * self.fixed_font_width)
                 #print "**",l,"**",c
                 if self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 3] <> 0:
                     painter.setPen(self.ztoq_color(self.upper_buf[(((l - 1) * self.width) + c - 1) * 4]))
                     painter.setBackground(QBrush(self.ztoq_color(self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 1])))
                     # Set appropriate font style
                     if self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 2] == 0:
                         f = painter.font()
                         f.setBold(False)
                         f.setItalic(False)
                         painter.setFont(f)
                     if self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 2] & 1: # Reverse video
                         painter.setPen(self.ztoq_color(self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 1]))
                         painter.setBackground(QBrush(self.ztoq_color(self.upper_buf[(((l - 1) * self.width) + c - 1) * 4])))
                     if self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 2] & 2: # Bold
                         f = painter.font()
                         f.setBold(True)
                         painter.setFont(f)
                     if self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 2] & 4: # Italic
                         f = painter.font()
                         f.setItalic(True)
                         painter.setFont(f)
                     painter.drawText(x,y,self.upper_buf[((((l - 1) * self.width) + c - 1) * 4) + 3])
                 c += 1
             l += 1
     # Print cursor if visible
     if self._cursor_visible:
         self.display_cursor()