void TCluster::drawBox( const char *icon, char marker)
{
    TDrawBuffer b;
    ushort color;

    ushort cNorm = getColor( 0x0301 );
    ushort cSel = getColor( 0x0402 );
    for( int i = 0; i <= size.y; i++ )
        {
        for( int j = 0; j <= (strings->getCount()-1)/size.y + 1; j++ )
            {
            int cur = j * size.y + i;
            if( cur < strings->getCount() )
                {
                int col = column( cur );
                if( (cur == sel) && (state & sfSelected) != 0 )
                    color = cSel;
                else
                    color = cNorm;
                b.moveChar( col, ' ', color, size.x - col );
                b.moveCStr( col, icon, color );
                if( mark(cur) )
                    b.putChar( col+2, marker );
                b.moveCStr( col+5, (char *)(strings->at(cur)), color );
                if( showMarkers && (state & sfSelected) != 0 && cur == sel )
                    {
                    b.putChar( col, specialChars[0] );
                    b.putChar( column(cur+size.y)-1, specialChars[1] );
                    }
                }
            }
        writeBuf( 0, i, size.x, 1, b );
        }
    setCursor( column(sel)+2, row(sel) );
}
void TFrame::draw()
{
    ushort cFrame, cTitle;
    short  f, i, l, width;
    TDrawBuffer b;

    if( (state & sfActive) == 0 )
        {
        cFrame = 0x0101;
        cTitle = 0x0002;
        f = 0;
        }
    else
        if( (state & sfDragging) != 0 )
            {
            cFrame = 0x0505;
            cTitle = 0x0005;
            f = 0;
            }
        else
            {
            cFrame = 0x0503;
            cTitle = 0x0004;
            f = 9;
            }

    cFrame = getColor(cFrame);
    cTitle = getColor(cTitle);

    width = size.x;
    l = width - 10;

    if( ( ((TWindow *)owner)->flags & (wfClose | wfZoom) ) != 0 )
        l -= 6;
    frameLine( b, 0, f, uchar(cFrame) );
    if( ((TWindow *)owner)->number != wnNoNumber &&
        ((TWindow *)owner)->number < 10
      )
        {
        l -= 4;
        if( ( ((TWindow *)owner)->flags & wfZoom ) != 0 )
            i = 7;
        else
            i = 3;
        b.putChar( width-i, ((TWindow *)owner)->number + '0' );
        }

    if( owner != 0 )
        {
        const char *title = ((TWindow *)owner)->getTitle(l);
        if( title != 0 )
            {
            l = min( cstrlen(title), width - 10 );
            l = max( l, 0 );
            i = (width - l) >> 1;
            b.putChar( i-1, ' ' );
            b.moveBuf( i, title, cTitle, l );
            b.putChar( i+l, ' ' );
            }
        }
Пример #3
0
void TButton::drawTitle( TDrawBuffer &b,
                         int s,
                         int i,
                         ushort cButton,
                         Boolean down
                       )
{
    int l, scOff;
    if( (flags & bfLeftJust) != 0 )
        l = 1;
    else
        {
        l = (s - cstrlen(title) - 1)/2;
        if( l < 1 )
            l = 1;
        }
    b.moveCStr( i+l, title, cButton );

    if( showMarkers == True && !down )
        {
        if( (state & sfSelected) != 0 )
            scOff = 0;
        else if( amDefault )
            scOff = 2;
        else
            scOff = 4;
        b.putChar( 0, specialChars[scOff] );
        b.putChar( s, specialChars[scOff+1] );
        }
}
Пример #4
0
void TIndicator::draw()
{
    uchar color, frame;
    TDrawBuffer b;
    char s[15];

    if( (state & sfDragging) == 0 )
        {
        color = getColor(1);
        frame = dragFrame;
        }
    else
        {
        color = getColor(2);
        frame = normalFrame;
        }

    b.moveChar( 0, frame, color, size.x );
    if( modified )
        b.putChar( 0, 15 );
    ostrstream os( s, 15 );

    os << ' ' << (location.y+1)
       << ':' << (location.x+1) << ' ' << ends;

    b.moveCStr( 8-int(strchr(s, ':')-s), s, color);
    writeBuf(0, 0, size.x, 1, b);
}
Пример #5
0
void TCluster::drawMultiBox(const char *icon, const char *marker) {
   TDrawBuffer b;
   ushort color;
   int i, j, cur;

   ushort cNorm = getColor(0x0301);
   ushort cSel = getColor(0x0402);
   ushort cDis = getColor(0x0505);
   for (i = 0; i <= size.y; i++) {
      b.moveChar(0, ' ', (uchar)cNorm, size.x);
      for (j = 0; j <= (strings->getCount() - 1) / size.y + 1; j++) {
         cur = j * size.y + i;
         if (cur < strings->getCount()) {
            int col = column(cur);

            if (((col + strlen((const char *)strings->at(cur)) + 5) <
                  (sizeof(b) / sizeof(ushort))) && (col < size.x)) {
               if (!buttonState(cur))
                  color = cDis;
               else if ((cur == sel) && (state & sfSelected) != 0)
                  color = cSel;
               else
                  color = cNorm;
               b.moveChar(col, ' ', color, size.x - col);
               b.moveCStr(col, icon, color);

               b.putChar(col + 2, marker[multiMark(cur)]);
               b.moveCStr(col + 5, (char *)(strings->at(cur)), color);
               if (showMarkers && ((state & sfSelected) != 0) && cur == sel) {
                  b.putChar(col, specialChars[0]);
                  b.putChar(column(cur + size.y) - 1, specialChars[1]);
               }

            }
         }
      }
      writeBuf(0, i, size.x, 1, b);
   }
   setCursor(column(sel) + 2, row(sel));
}
Пример #6
0
void TColorSelector::draw() {
   TDrawBuffer b;
   b.moveChar(0, ' ', 0x70, size.x);
   for (int i = 0; i <= size.y; i++) {
      if (i < 4) {
         for (int j = 0; j < 4; j++) {
            int c = i * 4 + j;
            b.moveChar(j * 3, icon, c, 3);
            if (c == color) {
               b.putChar(j * 3 + 1, 8);
               if (c == 0)
                  b.putAttribute(j * 3 + 1, 0x70);
            }
         }
      }
      writeLine(0, i, size.x, 1, b);
   }
}
Пример #7
0
void TLabel::draw()
{
    ushort color;
    TDrawBuffer b;
    uchar scOff;

    if( light )
        {
        color = getColor(0x0402);
        scOff = 0;
        }
    else
        {
        color = getColor(0x0301);
        scOff = 4;
        }

    b.moveChar( 0, ' ', color, size.x );
    if( text != 0 )
        b.moveCStr( 1, text, color );
    if( showMarkers )
        b.putChar( 0, specialChars[scOff] );
    writeLine( 0, 0, size.x, 1, b );
}
Пример #8
0
void TListViewer::draw() {
   int i, j, item;
   ushort normalColor, selectedColor, focusedColor, color;
   short colWidth, curCol, indent;
   TDrawBuffer b;
   uchar scOff;

   if ((state&(sfSelected | sfActive)) == (sfSelected | sfActive)) {
      normalColor = getColor(1);
      focusedColor = getColor(3);
      selectedColor = getColor(4);
   } else {
      normalColor = getColor(2);
      selectedColor = getColor(4);
   }

   if (hScrollBar != 0)
      indent = hScrollBar->value;
   else
      indent = 0;

   colWidth = size.x / numCols + 1;
   for (i = 0; i < size.y; i++) {
      for (j = 0; j < numCols; j++) {
         item =  j * size.y + i + topItem;
         curCol = j * colWidth;
         if ((state & (sfSelected | sfActive)) == (sfSelected | sfActive) &&
             focused == item &&
             range > 0) {
            color = focusedColor;
            setCursor(curCol + 1, i);
            scOff = 0;
         } else if (item < range && isSelected(item)) {
            color = selectedColor;
            scOff = 2;
         } else {
            color = normalColor;
            scOff = 4;
         }

         b.moveChar(curCol, ' ', color, colWidth);
         if (item < range) {
            char text[MAXSTR];
            getText(text, item, colWidth + indent);
            char buf[MAXSTR];
            buf[0] = '\0';
            if (strlen(text) > indent) {
               memcpy(buf, text+indent, colWidth);
               buf[colWidth] = EOS;
            }
            b.moveStr(curCol+1, buf, color);
            if (showMarkers) {
               b.putChar(curCol, specialChars[scOff]);
               b.putChar(curCol+colWidth-2, specialChars[scOff+1]);
            }
         } else if (i == 0 && j == 0)
            b.moveStr(curCol+1, emptyText, getColor(1));

         b.moveChar(curCol+colWidth-1, 179, getColor(5), 1);
      }
      writeLine(0, i, size.x, 1, b);
   }
}
Пример #9
0
void TButton::drawState(Boolean down)
{
    ushort cButton, cShadow;
    char   ch;
    int    i;
    TDrawBuffer b;

    if( (state & sfDisabled) != 0 )
        cButton = getColor(0x0404);
    else
        {
        cButton = getColor(0x0501);
        if( (state & sfActive) != 0 )
            if( (state & sfSelected) != 0 )
                cButton = getColor(0x0703);
            else if( amDefault )
                cButton = getColor(0x0602);
        }
    cShadow = getColor(8);
    int s = size.x-1;
    int T = size.y / 2 - 1;

    for( int y = 0; y <= size.y-2; y++ )
        {
        b.moveChar( 0, ' ', cButton, size.x );
        b.putAttribute( 0, cShadow );
        if( down )
            {
            b.putAttribute( 1, cShadow );
            ch =  ' ';
            i = 2;
            }
        else
            {
            b.putAttribute( s, cShadow );
            if( showMarkers == True )
                ch = ' ';
            else
                {
                if( y == 0 )
                    b.putChar( s, shadows[0] );
                else
                    b.putChar( s, shadows[1] );
                ch = shadows[2];
                }
            i =  1;
            }

        if( y == T && title != 0 )
            drawTitle( b, s, i, cButton, down );

        if( showMarkers && !down )
            {
            b.putChar( 1, markers[0] );
            b.putChar( s-1, markers[1] );
            }
        writeLine( 0, y, size.x, 1, b );
        }
    b.moveChar( 0, ' ', cShadow, 2 );
    b.moveChar( 2, ch, cShadow, s-1 );
    writeLine( 0, size.y-1, size.x, 1, b );
}