home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / PAINT.CPP < prev    next >
C/C++ Source or Header  |  1993-09-23  |  1KB  |  62 lines

  1. // ---------- paint.cpp
  2.  
  3. #include "desktop.h"
  4. #include "dfwindow.h"
  5.  
  6. void DFWindow::ClearWindow()
  7. {
  8.     String ln(ClientWidth(), clearch);
  9.  
  10.     int h = ClientHeight();
  11.     for (int y = 0; y < h; y++)
  12.         WriteClientString(ln, 0, y, colors.fg, colors.bg);
  13. }
  14.  
  15. void DFWindow::Paint(Rect rc)
  16. {
  17.     if (visible)    {
  18.         String ln(rc.Width(), clearch);
  19.         int x = rc.Left()-ClientLeft();
  20.         int y = rc.Top()-ClientTop();
  21.         for (int i = 0; i < rc.Height(); i++)
  22.             WriteClientString(ln, x, y+i, colors.fg, colors.bg);
  23.     }
  24. }
  25.  
  26. void DFWindow::Paint()
  27. {
  28.     if (visible)
  29.         ClearWindow();
  30. }
  31.  
  32. void DFWindow::WriteString(String &ln, int x, int y, int fg, int bg)
  33. {
  34.     int xx = x - Left();
  35.     if (ln.Strlen()+xx > Width())
  36.         ln.ChangeLength(Width()-xx);
  37.     if (this->isDescendedFrom(desktop.InFocus()))
  38.         desktop.screen().WriteVideoString(ln, x, y, fg, bg);
  39.     else     {
  40.         const char *cp = ln;
  41.         while (*cp)
  42.             WriteChar(*cp++, x++, y, fg, bg);
  43.     }
  44. }
  45.  
  46. void DFWindow::WriteChar(int ch, int x, int y, int fg, int bg)
  47. {
  48.     if (ShadowedRect().Inside(x, y))    {
  49.         // --- coordinates are inside target window
  50.         // --- see if overlapped by sibling
  51.         DFWindow *sibl = Next();
  52.         while (sibl != 0)    {
  53.             if (sibl->isVisible() && sibl->ShadowedRect().Inside(x, y))
  54.                 return;
  55.             sibl = sibl->Next();
  56.         }
  57.            desktop.screen().PutVideoChar(x, y, (ch & 255) | (clr(fg,bg) << 8));
  58.     }
  59. }
  60.  
  61.  
  62.