? kdevelop/setup/wizardkdedocpage.loT
Index: kdevelop/ckdevelop.cpp
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/ckdevelop.cpp,v
retrieving revision 1.158.2.114.2.140.2.40
diff -r1.158.2.114.2.140.2.40 ckdevelop.cpp
273c273,274
<   KPrinter printer;
---
>   m_docViewManager->currentEditView()->print();
> /*  KPrinter printer;
282a284
> */
287c289,295
< 
---
> // BACK to the roots
> //   printing will be almost done like kwrite and kate does!
> //   This is because the font isn't set correct in this way of printing.
> //   Even on default QPrinter::fullPage is FALSE, so no margin subtraction should be necessarry
> //   (greetings Walter 15.05.2002)
> //   
> //
Index: kdevelop/kwrite/kwdoc.cpp
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/kwrite/Attic/kwdoc.cpp,v
retrieving revision 1.5.2.14.2.40.2.14
diff -r1.5.2.14.2.40.2.14 kwdoc.cpp
23a24,29
> // set this to 0, if you want color printing
> //   (take care the background on printing is always set to white)
> #ifndef BW_PRINTING
> #define BW_PRINTING      1
> #endif
> 
2144,2159c2150,2155
< /*
< void KWriteDoc::paintTextLine(QPainter &paint, int line,
<                               int xPos, int xStart, int xEnd, int yPos) {
<   int y;
<   TextLine *textLine;
<   int z, x;
<   char ch;
<   Attribute *a = 0;
<   int attr, nextAttr;
<   int xs;
<   int xc, zc;
< 
<   y = line*fontHeight - yPos;
<   if (line >= (int) contents.count()) {
<     paint.fillRect(xStart - xPos,y,xEnd - xStart,fontHeight,colors[4]);
<     return;
---
> void KWriteDoc::paintSetFont(Attribute *a, QPainter &paint)
> {
>   if (a)
>   {
>      paint.setFont(a->font);
>      a->fm=paint.fontMetrics();
2161,2178c2157
< //printf("xStart = %d, xEnd = %d, line = %d\n",xStart,xEnd,line);
< //printf("text = ");
<   textLine = contents.at(line);
< 
<   z = 0;
<   x = 0;
<   do {
<     xc = x;
<     ch = textLine->getChar(z);
<     if (ch == '\t') {
<       x += tabWidth - (x % tabWidth);
<     } else {
<       a = attribs[textLine->getAttr(z)];
<       x += a->fm.width(&ch,1);
<     }
<     z++;
<   } while (x <= xStart);
<   zc = z - 1;
---
> }
2180,2218c2159,2164
<   xs = xStart;
<   attr = textLine->getRawAttr(zc);
<   while (x < xEnd) {
<     nextAttr = textLine->getRawAttr(z);
<     if ((nextAttr ^ attr) & taSelectMask) {
<       paint.fillRect(xs - xPos,y,x - xs,fontHeight,colors[attr >> taShift]);
<       xs = x;
<       attr = nextAttr;
<     }
<     ch = textLine->getChar(z);
<     if (ch == '\t') {
<       x += tabWidth - (x % tabWidth);
<     } else {
<       a = attribs[attr & taAttrMask];
<       x += a->fm.width(&ch,1);
<     }
<     z++;
<   }
<   paint.fillRect(xs - xPos,y,xEnd - xs,fontHeight,colors[attr >> taShift]);
< //int len = textLine->length();
<   y += fontAscent -1;
<   attr = -1;
<   while (xc < xEnd) {
<     ch = textLine->getChar(zc);
<     if (ch == '\t') {
<       xc += tabWidth - (xc % tabWidth);
<     } else {
<       nextAttr = textLine->getRawAttr(zc);
<       if (nextAttr != attr) {
<         attr = nextAttr;
<         a = attribs[attr & taAttrMask];
<         if (attr & taSelectMask) paint.setPen(a->selCol); else paint.setPen(a->col);
<         paint.setFont(a->font);
<       }
<       paint.drawText(xc - xPos,y,&ch,1);
<       xc += a->fm.width(&ch,1);
< //if (zc < len) printf("%c",ch);
<     }
<     zc++;
---
> int KWriteDoc::paintIncWidth(Attribute *a, QChar ch) const
> {
>   int x=0;
>   if (a)
>   {
>     x=a->fm.width(ch);
2219a2166,2167
>   return x;
> }
2221c2169,2176
< //printf("\n");
---
> int KWriteDoc::paintIncWidth(Attribute *a, QString s) const
> {
>   int x=0;
>   if (a)
>   {
>      x=a->fm.width(s);
>   }
>   return x;
2223d2177
< */
2225,2299c2179,2182
< // void KWriteDoc::paintTextLine(QPainter &paint, int line,
< //                               int xStart, int xEnd) {
< //   int y;
< //   TextLine *textLine;
< //   int z, x;
< //   char ch;
< //   Attribute *a = 0L;
< //   int attr, nextAttr;
< //   int xs;
< //   int xc, zc;
< 
< //   y = 0;//line*fontHeight - yPos;
< //   if (line >= (int) contents.count()) {
< //     paint.fillRect(0,y,xEnd - xStart,fontHeight,colors[4]);
< //     return;
< //   }
< // //printf("xStart = %d, xEnd = %d, line = %d\n",xStart,xEnd,line);
< // //printf("text = ");
< //   textLine = contents.at(line);
< 
< //   z = 0;
< //   x = 0;
< //   do {
< //     xc = x;
< //     ch = textLine->getChar(z);
< //     if (ch == '\t') {
< //       x += tabWidth - (x % tabWidth);
< //     } else {
< //       a = &attribs[textLine->getAttr(z)];
< //       x += a->fm.width(&ch,1);
< //     }
< //     z++;
< //   } while (x <= xStart);
< //   zc = z - 1;
< 
< //   xs = xStart;
< //   attr = textLine->getRawAttr(zc);
< //   while (x < xEnd) {
< //     nextAttr = textLine->getRawAttr(z);
< //     if ((nextAttr ^ attr) & (taSelectMask | 256)) {
< //       paint.fillRect(xs - xStart,y,x - xs,fontHeight,colors[attr >> taShift]);
< //       xs = x;
< //       attr = nextAttr;
< //     }
< //     ch = textLine->getChar(z);
< //     if (ch == '\t') {
< //       x += tabWidth - (x % tabWidth);
< //     } else {
< //       a = &attribs[attr & taAttrMask];
< //       x += a->fm.width(&ch,1);
< //     }
< //     z++;
< //   }
< //   paint.fillRect(xs - xStart,y,xEnd - xs,fontHeight,colors[attr >> taShift]);
< // //int len = textLine->length();
< //   y += fontAscent -1;
< //   attr = -1;
< //   while (xc < xEnd) {
< //     ch = textLine->getChar(zc);
< //     if (ch == '\t') {
< //       xc += tabWidth - (xc % tabWidth);
< //     } else {
< //       nextAttr = textLine->getRawAttr(zc);
< //       if (nextAttr != attr) {
< //         attr = nextAttr;
< //         a = &attribs[attr & taAttrMask];
< //         if (attr & taSelectMask) paint.setPen(a->selCol); else paint.setPen(a->col);
< //         paint.setFont(a->font);
< //       }
< //       paint.drawText(xc - xStart,y,&ch,1);
< //       xc += a->fm.width(&ch,1);
< // //if (zc < len) printf("%c",ch);
< //     }
< //     zc++;
< //   }
---
> void KWriteDoc::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs, bool printing)
> {
>   paintTextLine(paint, line, 0, xStart, xEnd, showTabs, printing);
> }
2301,2302d2183
< // //printf("\n");
< // }
2304c2185
< void KWriteDoc::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs)
---
> void KWriteDoc::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs, bool printing)
2306,2307c2187
<   int y;
<   TextLine* textLine;
---
>   TextLine *textLine;
2309a2190
>   QBrush whiteBrush(white);
2317,2320d2197
< //  struct timeval tv1, tv2, tv3; //for profiling
< //  struct timezone tz;
< 
<   y = 0;//line*fontHeight - yPos;
2322c2199
<     paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[4]);
---
>     paint.fillRect(0, y, xEnd - xStart,fontHeight, (printing) ? whiteBrush : colors[4]);
2343c2220,2221
<       x += a->fm.width(ch);//a->width(ch);
---
>       paintSetFont(a, paint);
>       x+=paintIncWidth(a, ch);
2348d2225
< //gettimeofday(&tv1, &tz);
2355,2356c2232,2237
<     if ((nextAttr ^ attr) & (taSelectMask | 256)) {
<       paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[attr >> taShift]);
---
>     if ((nextAttr ^ attr) & (taSelectMask | 256))
>     {
>       if (printing)
>         paint.fillRect(xs - xStart, y, x - xs, fontHeight, whiteBrush);
>       else
>         paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[attr >> taShift]);
2366c2247,2248
<       x += a->fm.width(ch);//a->width(ch);
---
>       paintSetFont(a, paint);
>       x+=paintIncWidth(a, ch);
2370,2371c2252,2255
<   paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[attr >> taShift]);
<   len = z; //reduce length to visible length
---
>   if (printing)
>     paint.fillRect(xs - xStart, y, x - xs, fontHeight, whiteBrush);
>   else
>     paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[attr >> taShift]);
2373c2257
< //gettimeofday(&tv2, &tz);
---
>   len = z; //reduce length to visible length
2386c2270
<         x += a->fm.width(str); //a->width(s);//&s[zc], z - zc);
---
>         x+=paintIncWidth(a, s);
2396,2398c2280,2287
<           if (attr & taSelectMask) paint.setPen(a->selCol);
<             else paint.setPen(a->col);
<           paint.setFont(a->font);
---
>           if (printing && BW_PRINTING)
>              paint.setPen(black);
>           else
>           {
>             if (attr & taSelected) paint.setPen(a->selCol);
>               else paint.setPen(a->col);
>           }
>           paintSetFont(a, paint);
2401,2402d2289
< //        paint.drawLine(x - xStart, y -2, x - xStart, y);
< //        paint.drawLine(x - xStart, y, x - xStart + 2, y);
2414c2301,2302
<           x += a->fm.width(str);//a->width(s);//&s[zc], z - zc);
---
>           x+=paintIncWidth(a, str);
> 
2420,2422c2308,2315
<         if (attr & taSelectMask) paint.setPen(a->selCol);
<           else paint.setPen(a->col);
<         paint.setFont(a->font);
---
>         if (printing && BW_PRINTING)
>            paint.setPen(black);
>         else
>         {
>           if (attr & taSelected) paint.setPen(a->selCol);
>             else paint.setPen(a->col);
>         }
>         paintSetFont(a, paint);
2430,2682d2322
<   }
< //gettimeofday(&tv3, &tz);
< //printf(" %d %d\n", tv2.tv_usec - tv1.tv_usec, tv3.tv_usec - tv2.tv_usec);
< }
< 
< 
< 
< //void
< //KWriteDoc::paintTextLine(QPainter &paint, int line, int xStart, int xEnd)
< //{
< //  int y;
< //  TextLine *textLine;
< //  int z, x;
< //  char ch;
< //  Attribute *a = 0L;
< //  int attr, nextAttr;
< //  int xs;
< //  int xc, zc;
< //  static char aLB[256];
< //  int aCnt, xcp;
< //
< //  y = 0;//line*fontHeight - yPos;
< //  if (line >= (int) contents.count()) {
< //      paint.fillRect(0,y,xEnd - xStart,fontHeight,colors[4]);
< //      return;
< //  }
< ////printf("xStart = %d, xEnd = %d, line = %d\n",xStart,xEnd,line);
< ////printf("text = ");
< //  textLine = contents.at(line);
< //
< //  z = 0;
< //  x = 0;
< //  do {
< //      xc = x;
< //      ch = textLine->getChar(z);
< //      if (ch==127)
< //      {
< //       ch='?';
< //      }
< //      else
< //       if (ch !='\t' && (ch & 0x7f)< 0x20)
< //       {
< //         ch|=0x40;
< //       }
< //
< //      if (ch == '\t') {
< //          x += tabWidth - (x % tabWidth);
< //      } else {
< //          a = &attribs[textLine->getAttr(z)];
< //#ifdef QT_I18N
< //      if (iseucchar(ch)) {
< //	char buf[3];
< //	buf[0] = ch;
< //	buf[1] = textLine->getChar(++z);
< //	buf[2] = '\0';
< //	x += a->fm.width(buf);
< //      } else {
< //	x += a->fm.width(&ch,1);
< //      }
< //#else
< //          x += a->fm.width(&ch,1);
< //#endif
< //      }
< //      z++;
< //  } while (x <= xStart);
< //  zc = z - 1;
< //#ifdef QT_I18N
< //  if (iseucchar(textLine->getChar(zc))) {
< //    zc--;
< //  }
< //#endif
< //
< //  xs = xStart;
< //  attr = textLine->getRawAttr(zc);
< //  ch = textLine->getChar(zc);
< //  if (ch==127 || (ch !='\t' && ((ch & 0x7f)< 0x20)))
< //  {
< //        attr|=taSelected;
< //  }
< //
< //  while (x < xEnd) {
< //      nextAttr = textLine->getRawAttr(z);
< //      ch = textLine->getChar(z);
< //      /* non printable char handling */
< //      if (ch==127)
< //      {
< //        ch='?';
< //        nextAttr|=taSelected;
< //      }
< //      else
< //        if (ch !='\t' && ((ch & 0x7f)< 0x20))
< //        {
< //          ch|=0x40;
< //          nextAttr|=taSelected;
< //        }
< //
< //      if ((nextAttr ^ attr) & (taSelectMask | 256)) {
< //          paint.fillRect(xs - xStart,y,x - xs,fontHeight,colors[attr >> taShift]);
< //          xs = x;
< //          attr = nextAttr;
< //      }
< //      ch = textLine->getChar(z);
< //      if (ch == '\t') {
< //          x += tabWidth - (x % tabWidth);
< //      } else {
< //          a = &attribs[attr & taAttrMask];
< //#ifdef QT_I18N
< //      if (iseucchar(ch)) {
< // 	char buf[3];
< // 	buf[0] = ch;
< // 	buf[1] = textLine->getChar(++z);
< //	buf[2] = '\0';
< //	x += a->fm.width(buf);
< //      } else {
< //	x += a->fm.width(&ch,1);
< //      }
< //#else
< //          x += a->fm.width(&ch,1);
< //#endif
< //      }
< //      z++;
< //  }
< //
< //  paint.fillRect(xs - xStart,y,xEnd - xs,fontHeight,colors[attr >> taShift]);
< //
< //  y += fontAscent -1;
< //  attr = -1;
< //  aCnt = 0;
< //  xcp  = xc;
< //
< //  while (xc < xEnd) {
< //      ch = textLine->getChar(zc);
< //
< //      if (ch == '\t') {
< //          xc += tabWidth - (xc % tabWidth);
< //          if(aCnt!=0) {
< //              paint.drawText(xcp - xStart,y,aLB,aCnt);
< //              aCnt = 0;
< //          }
< //          xcp  = xc;
< //      }
< //
< //      else {
< //          nextAttr = textLine->getRawAttr(zc);
< //          /* non printable char handling */
< //          if (ch==127)
< //          {
< //            ch='?';
< //            nextAttr|=taSelected;
< //          }
< //          else
< //            if ((ch & 0x7f)< 0x20)
< //            {
< //              ch|=0x40;
< //              nextAttr|=taSelected;
< //            }
< //          if (nextAttr != attr) {
< //
< //              if(aCnt!=0) {
< //                  paint.drawText(xcp - xStart,y,aLB,aCnt);
< //                  aCnt = 0;
< //                  xcp  = xc;
< //              }
< //
< //              attr = nextAttr;
< //              a = &attribs[attr & taAttrMask];
< //              if (attr & taSelectMask) paint.setPen(a->selCol); else paint.setPen(a->col);
< //              paint.setFont(a->font);
< //          }
< //#ifdef QT_I18N
< //      if (iseucchar(ch)) {
< //         char buf[3];
< // 	buf[0] = ch;
< // 	buf[1] = textLine->getChar(++zc);
< // 	buf[2] = '\0';
< // 	paint.drawText(xc - xStart,y+1,buf);
< //	xc += a->fm.width(buf);
< //      } else {
< //        paint.drawText(xc - xStart,y,&ch,1);
< //	xc += a->fm.width(&ch,1);
< //      }
< //#else
< //          aLB[aCnt++] = ch;
< //          xc += a->fm.width(&ch,1);
< //
< //          if(aCnt == 256) {
< //              paint.drawText(xcp - xStart,y,aLB,aCnt);
< //              aCnt = 0;
< //              xcp  = xc;
< //          }
< //#endif
< //      }
< //      zc++;
< //  }
< //
< //  if(aCnt!=0) {
< //      paint.drawText(xcp - xStart,y,aLB,aCnt);
< //      aCnt = 0;
< //      xcp  = xc;
< //  }
< ////printf("\n");
< //}
< 
< //////////////////////////////////////////////////////////////////////////
< 
< void KWriteDoc::printTextLine(QPainter &paint, int line, int xEnd, int y) {
<   TextLine *textLine;
<   int z, x;
<   Attribute *a = 0L;
<   int attr, nextAttr;
<   char ch;
<   char buf[256];
<   int bufp;
< 
<   if (line >= (int) contents.count()) return;
<   textLine = contents.at(line);
< 
<   z = 0;
<   x = 0;
<   y += fontAscent -1;
<   attr = -1;
<   bufp = 0;
<   while (x < xEnd && z < textLine->length()) {
<     ch = textLine->getChar(z);
<     if (ch == '\t') {
<       if (bufp > 0) {
<         QString str = QString::fromLocal8Bit(buf, bufp);
<         paint.drawText(x, y, str);
<         x += a->fm.width(str);
<         bufp = 0;
<       }
<       x += tabWidth - (x % tabWidth);
<     } else {
<       nextAttr = textLine->getAttr(z);
<       if (nextAttr != attr || bufp >= 256) {
<         if (bufp > 0) {
< 	  QString str = QString::fromLocal8Bit(buf, bufp);
< 	  paint.drawText(x, y, str);
< 	  x += a->fm.width(str);
<           bufp = 0;
<         }
<         attr = nextAttr;
<         a = &attribs[attr];
<         paint.setFont(a->font);
<       }
<       buf[bufp] = ch;
<       bufp++;
<     }
<     z++;
<   }
<   if (bufp > 0) {
<     QString str = QString::fromLocal8Bit(buf, bufp);
<     paint.drawText(x, y, str);
Index: kdevelop/kwrite/kwdoc.h
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/kwrite/Attic/kwdoc.h,v
retrieving revision 1.5.2.6.2.16.2.2
diff -r1.5.2.6.2.16.2.2 kwdoc.h
268,269c268,273
<     void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs);
<     void printTextLine(QPainter &, int line, int xEnd, int y);
---
>     int paintIncWidth(Attribute *a, QChar ch) const;
>     int paintIncWidth(Attribute *a, QString s) const;
>     void paintSetFont(Attribute *a, QPainter &paint);
> 
>     void paintTextLine(QPainter &, int line, int y, int xStart, int xEnd, bool showTabs, bool printing=false);
>     void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs, bool printing=false);
Index: kdevelop/kwrite/kwview.cpp
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/kwrite/Attic/kwview.cpp,v
retrieving revision 1.9.2.19.2.46.2.11
diff -r1.9.2.19.2.46.2.11 kwview.cpp
23a24
> #include <kprinter.h>
2513c2514
<   QPrinter prt;
---
>   KPrinter prt;
2514a2516,2517
>   prt.setFullPage(false);
>   
2516d2518
<     QPaintDeviceMetrics pdm(&prt);
2518,2519c2520
< 
<     paint.begin(&prt);
---
>     QPaintDeviceMetrics pdm(&prt);
2522a2524,2525
>     
>     paint.begin(&prt);
2525c2528,2529
<       for (p = 0; p <= pages; p++) {
---
>       
>       for (p =  0 ; p <= pages; p++) {
2527c2531,2533
<         if (prt.pageOrder() == QPrinter::LastPageFirst) line = (pages - p)*lines;
---
>         if (prt.pageOrder() == KPrinter::LastPageFirst) 
>           line = (pages - p)*lines;
>         
2529c2535
<           kWriteDoc->printTextLine(paint, line, pdm.width(), y);
---
>           kWriteDoc->paintTextLine(paint, line, y, 0, pdm.width(), flags() & cfShowTabs, true);
