OSDN Git Service

fixing draw
authorsuma <devnull@localhost>
Thu, 4 Dec 2008 13:24:29 +0000 (22:24 +0900)
committersuma <devnull@localhost>
Thu, 4 Dec 2008 13:24:29 +0000 (22:24 +0900)
src/control/standard/hexview.cpp
src/control/standard/hexview.h
src/control/view.cpp

index c20c600..eb65d4e 100644 (file)
@@ -41,6 +41,12 @@ void HexConfig::calculate()
                x_[i] = x_[i-1] + byteWidth() + Spaces[i];
        }
 
+       // Pos of end
+       for (int i = 0; i < Num; i++) {
+               X_[i] = x_[i] + (FontMetrics.maxWidth() * 2);
+               printf("i:%d x: %d X: %d\n", i, x_[i], X_[i]);
+       }
+
        // Area
        xarea_[0] = Margin.left();
        for (int i = 1; i < Num; i++) {
@@ -138,7 +144,6 @@ void HexView::refreshPixmap(int)
        getDrawColors(di, dcolors_, config_.Colors);
 
        // draw
-       printf("y: %d , yt:%d\n", y, yt);
        DCIList::iterator itr = dcolors_.begin(), end = dcolors_.end();
        QBrush br;
        for (int i = 0, j = 0, m = 0, cont = 0; itr != end;) {
@@ -156,21 +161,20 @@ void HexView::refreshPixmap(int)
                printf("m:%d j:%d cont:%d\n", m, j, cont);
                if (2 <= cont) {
                        // Draw background
-                       Q_ASSERT(0 <= j && j < HexConfig::Num);
-                       Q_ASSERT(0 <= j+cont-1 && j+cont-1 < HexConfig::Num);
-                       painter.fillRect(config_.x(j), yt, config_.byteEnd(j+cont-1), yt + config_.byteHeight(), br);
-               } else if (j < 15) { //(j < HexConfig::Num - 1) {
-                       Q_ASSERT(0 <= j && j < HexConfig::Num);
-                       Q_ASSERT(0 <= j+1 && j+1 < HexConfig::Num);
+                       painter.fillRect(config_.x(j), yt, config_.X(j+cont-1) - config_.x(j), config_.byteHeight(), br);
+                       printf("x:%d, x2:%d\n", config_.x(j), config_.X(j+cont-1));
+               } else if (j < HexConfig::Num - 1) {
                        painter.fillRect(config_.x(j), yt, config_.X(j+1), yt + config_.byteHeight(), br);
+                       printf("#x:%d, x2:%d\n", config_.x(j), config_.X(j+1));
                }
 
                // Draw
                for (int k = 0; k < cont; k++, i++, j++) {
                        QString hex;
                        byteToHex(buff_[i], hex);
-                       painter.drawText(config_.x(j), y, hex);
+                       painter.drawText(config_.x(j), y, config_.byteWidth(), config_.byteHeight(), Qt::AlignTop | Qt::AlignLeft, hex);
                }
+               printf("y: %d, yt:%d\n", y, yt);
 
                m -= cont;
                j = j & 0xF;
index 63408c1..44babb6 100644 (file)
@@ -26,6 +26,7 @@ namespace Standard {
                QFontMetrics FontMetrics;
                int top_;
                int x_[Num];    // pos of value
+               int X_[Num];    // pos of end
                int xarea_[Num];
        
        public:
@@ -67,7 +68,7 @@ namespace Standard {
                inline int X(int i) const
                {
                        Q_ASSERT(0 <= i && i < Num);
-                       return x_[i] - ByteMargin.left();
+                       return X_[i];
                }
                int toPos(int x);       // -1, 0..31, 32:: 32 + 2 = 34
                int toLine(int y);      // [0, N]
index e6f5c0b..8e1ab65 100644 (file)
@@ -81,7 +81,6 @@ void View::getDrawColors(const DrawInfo &di, DCIList &ci, QColor *defColors)
                                bool sel = sb <= index && index <= se;
                                int x = sel ? 2 : 0;
                                if (itr == end || i < itr->Index || itr->Index + itr->Length < i) {
-                                       printf("i: %d sel: %d\n", i, sel);
                                        // out of itr
                                        if (last == defColors + x) {
                                                // continues same color