98 |
98 |
99 self.__addrDigits = 0 |
99 self.__addrDigits = 0 |
100 self.__blink = True |
100 self.__blink = True |
101 self.__bData = QBuffer() |
101 self.__bData = QBuffer() |
102 self.__cursorRect = QRect() |
102 self.__cursorRect = QRect() |
|
103 self.__cursorRectAscii = QRect() |
103 self.__dataShown = bytearray() |
104 self.__dataShown = bytearray() |
104 self.__hexDataShown = bytearray() |
105 self.__hexDataShown = bytearray() |
105 self.__lastEventSize = 0 |
106 self.__lastEventSize = 0 |
106 self.__markedShown = bytearray() |
107 self.__markedShown = bytearray() |
107 self.__modified = False |
108 self.__modified = False |
326 @type int |
327 @type int |
327 """ |
328 """ |
328 # step 1: delete old cursor |
329 # step 1: delete old cursor |
329 self.__blink = False |
330 self.__blink = False |
330 self.viewport().update(self.__cursorRect) |
331 self.viewport().update(self.__cursorRect) |
|
332 if self.__asciiArea: |
|
333 self.viewport().update(self.__cursorRectAscii) |
331 |
334 |
332 # step 2: check, if cursor is in range |
335 # step 2: check, if cursor is in range |
333 if self.__overwriteMode and pos > (self.__chunks.size() * 2 - 1): |
336 if self.__overwriteMode and pos > (self.__chunks.size() * 2 - 1): |
334 pos = self.__chunks.size() * 2 - 1 |
337 pos = self.__chunks.size() * 2 - 1 |
335 if (not self.__overwriteMode) and pos > (self.__chunks.size() * 2): |
338 if (not self.__overwriteMode) and pos > (self.__chunks.size() * 2): |
354 else: |
357 else: |
355 self.__cursorRect = QRect( |
358 self.__cursorRect = QRect( |
356 self.__pxCursorX, self.__pxCursorY - self.__pxCharHeight + 4, |
359 self.__pxCursorX, self.__pxCursorY - self.__pxCharHeight + 4, |
357 self.__pxCursorWidth, self.__pxCharHeight) |
360 self.__pxCursorWidth, self.__pxCharHeight) |
358 |
361 |
359 # step 4: draw new cursor |
362 # step 4: calculate position of ASCII cursor |
|
363 x = self.__bPosCurrent % self.BYTES_PER_LINE |
|
364 self.__cursorRectAscii = QRect( |
|
365 self.__pxPosAsciiX + x * self.__pxCharWidth - 1, |
|
366 self.__pxCursorY - self.__pxCharHeight + 4, |
|
367 self.__pxCharWidth + 1, self.__pxCharHeight + 1) |
|
368 |
|
369 # step 5: draw new cursors |
360 self.__blink = True |
370 self.__blink = True |
361 self.viewport().update(self.__cursorRect) |
371 self.viewport().update(self.__cursorRect) |
|
372 if self.__asciiArea: |
|
373 self.viewport().update(self.__cursorRectAscii) |
362 self.currentAddressChanged.emit(self.__bPosCurrent) |
374 self.currentAddressChanged.emit(self.__bPosCurrent) |
363 |
375 |
364 def data(self): |
376 def data(self): |
365 """ |
377 """ |
366 Public method to get the binary data. |
378 Public method to get the binary data. |
524 self.__pxCharHeight = self.fontMetrics().height() |
536 self.__pxCharHeight = self.fontMetrics().height() |
525 self.__pxGapAdr = self.__pxCharWidth // 2 |
537 self.__pxGapAdr = self.__pxCharWidth // 2 |
526 self.__pxGapAdrHex = self.__pxCharWidth |
538 self.__pxGapAdrHex = self.__pxCharWidth |
527 self.__pxGapHexAscii = 2 * self.__pxCharWidth |
539 self.__pxGapHexAscii = 2 * self.__pxCharWidth |
528 self.__pxCursorWidth = self.__pxCharHeight // 7 |
540 self.__pxCursorWidth = self.__pxCharHeight // 7 |
529 self.__pxSelectionSub = self.__pxCharHeight // 5 |
541 self.__pxSelectionSub = self.fontMetrics().descent() |
530 self.viewport().update() |
542 self.viewport().update() |
531 |
543 |
532 def dataAt(self, pos, count=-1): |
544 def dataAt(self, pos, count=-1): |
533 """ |
545 """ |
534 Public method to get data from a given position. |
546 Public method to get data from a given position. |
1290 @param evt reference to the paint event |
1302 @param evt reference to the paint event |
1291 @type QPaintEvent |
1303 @type QPaintEvent |
1292 """ |
1304 """ |
1293 painter = QPainter(self.viewport()) |
1305 painter = QPainter(self.viewport()) |
1294 |
1306 |
1295 if evt.rect() != self.__cursorRect: |
1307 if evt.rect() != self.__cursorRect and \ |
|
1308 evt.rect() != self.__cursorRectAscii: |
1296 pxOfsX = self.horizontalScrollBar().value() |
1309 pxOfsX = self.horizontalScrollBar().value() |
1297 pxPosStartY = self.__pxCharHeight |
1310 pxPosStartY = self.__pxCharHeight |
1298 |
1311 |
1299 # draw some patterns if needed |
1312 # draw some patterns if needed |
1300 painter.fillRect( |
1313 painter.fillRect( |
1422 c = "" |
1435 c = "" |
1423 else: |
1436 else: |
1424 c = "" |
1437 c = "" |
1425 painter.drawText(self.__pxCursorX, self.__pxCursorY, c) |
1438 painter.drawText(self.__pxCursorX, self.__pxCursorY, c) |
1426 |
1439 |
|
1440 if self.__asciiArea: |
|
1441 painter.drawRect(self.__cursorRectAscii) |
|
1442 |
1427 # emit event, if size has changed |
1443 # emit event, if size has changed |
1428 if self.__lastEventSize != self.__chunks.size(): |
1444 if self.__lastEventSize != self.__chunks.size(): |
1429 self.__lastEventSize = self.__chunks.size() |
1445 self.__lastEventSize = self.__chunks.size() |
1430 self.currentSizeChanged.emit(self.__lastEventSize) |
1446 self.currentSizeChanged.emit(self.__lastEventSize) |
1431 |
1447 |