Exemple #1
0
short TSystemError::sysErr( short errorCode, uchar drive )
{
    ushort c = ( (TScreen::screenMode & 0x00FF) != TDisplay::smMono  ) ?
                                        sysColorAttr : sysMonoAttr;
    char s[ 63 ];
    TDrawBuffer b;

//  bug-fix TV2B-31 ---------------------------------------
    /* There are 22 documented device errors, all of which have their
     * own strings in errorString[].  However, just in case we run into
     * something weird this will prevent a crash.
     */
//  end of bug-fix. ---------------------------------------
    if( errorCode < (sizeof(errorString) / sizeof(errorString[0])) )
        sprintf( s, errorString[ errorCode ], drive + 'A' );
    else
        sprintf( s, "Unknown critical error %d on drive %c", errorCode, drive + 'A' );

// modification #TV2N-04 ----------------------------------
    // EFW - Modified to be screen size aware.
    b.moveChar( 0, ' ', c, TScreen::screenWidth);
    b.moveCStr( 1, s, c);
    b.moveCStr( TScreen::screenWidth - cstrlen(sRetryOrCancel) - 1,
        sRetryOrCancel, c);
// end of modification ------------------------------------
    swapStatusLine(b);
    int res = selectKey();
    swapStatusLine(b);
    return res;
}
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] );
        }
}
Exemple #3
0
void TInterior::draw()       // modified for scroller
{
    ushort color = getColor(0x0301);
    for( int i = 0; i < size.y; i++ )
        // for each line:
    {
        TDrawBuffer b;
        b.moveChar( 0, ' ', color, size.x );
        // fill line buffer with spaces
        int j = delta.y + i;       // delta is scroller offset
        if( j < lineCount && lines[j] != 0 )
        {
            char s[maxLineLength];
            if( delta.x > strlen(lines[j] ) )
                s[0] = EOS;
            else
            {
                strncpy( s, lines[j]+delta.x, size.x );
                s[size.x] = EOS;
            }
            b.moveCStr( 0, s, color );
        }
        writeLine( 0, i, size.x, 1, b);
    }

}
Exemple #4
0
void TPercentageText::draw()
{
	ushort color = getColor(1);

	char *string = new char[size.x + 1];
	itoa( Round( percentage * pow10( precisionDigits ) ), string, 10 );

	if( precisionDigits > 0 )
		{
		memmove( &string[strlen( string ) - precisionDigits + 1],
			    &string[strlen( string ) - precisionDigits],
			    precisionDigits + 1 );
		string[strlen( string ) - 1 - precisionDigits] = point;
		}
	strcat( string, percentageString );
	if( string[0] == point )
		{
		memmove( &string[1], string, strlen( string ) + 1 );
		string[0] = '0';
		}

	TDrawBuffer b;
	b.moveChar( 0, ' ', color, size.x );
	b.moveStr( size.x - 1 - strlen( string ), string, color );
	writeLine( 0, 0, size.x, 1, b );

	delete[] string;
}
Exemple #5
0
void TBackground::draw()
{
    TDrawBuffer b;

    b.moveChar( 0, pattern, getColor(0x01), size.x );
    writeLine( 0, 0, size.x, size.y, b );
}
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);
}
Exemple #7
0
void TProgressBar::draw() {
   char string[4];
   sprintf(string,"%d",curPercent);
   string[3] = '\0';
   if(curPercent<10) {
      string[2] = string[0];
      string[1] = string[0] = ' ';
      }
   else if(curPercent<100 && curPercent>9) {
      string[2] = string[1];
      string[1] = string[0];
      string[0] = ' ';
      }
   TDrawBuffer nbuf;
   uchar colorNormal, colorHiLite;
   colorNormal = getColor(1);
   uchar fore = colorNormal >>4;                    // >>4 is same as /16
   colorHiLite = fore+((colorNormal-(fore<<4))<<4); // <<4 is same as *16
   nbuf.moveChar(0,backChar,colorNormal,size.x);
   nbuf.moveStr(numOffset,string,colorNormal);
   nbuf.moveStr(numOffset+3," %",colorNormal);
   unsigned i;
   for(i=0;i<curWidth;i++)
      nbuf.putAttribute(i,colorHiLite);
   writeLine(0, 0, size.x, 1, nbuf);
}
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, ' ' );
            }
        }
Exemple #9
0
/*
 * Deseneaza textul pe ecran.
 */
void TInterior::draw()
{
	setLimit(maxLineLength, lineCount);
	ushort color = getColor(0x0301);
	for (int i = 0; i < size.y; i++)
	{
		TDrawBuffer b;
		b.moveChar(0, ' ', color, size.x);	// umplu cu spatii

		int j = delta.y + i;

		if (j < lineCount && lines[j] != 0)
		{
			char s[maxLineLength];
			if (delta.x > strlen(lines[j]))
				s[0] = EOS;
			else
			{
				strncpy(s, lines[j] + delta.x, size.x);
				s[size.x] = EOS;
			}

			b.moveCStr(0, s, color);
		}

		writeLine(0, i, size.x, 1, b);
	}
}
void TFileViewer::draw()
{
    char *p;

    ushort c =  getColor(0x0301);
    for( int i = 0; i < size.y; i++ )
        {
        TDrawBuffer b;
	b.moveChar( 0, ' ', c, size.x );

        if( delta.y + i < fileLines->getCount() )
            {
            char s[maxLineLength+1];
            p = (char *)( fileLines->at(delta.y+i) );
            if( p == 0 || strlen(p) < delta.x )
                s[0] = EOS;
            else
		{
		strncpy( s, p+delta.x, size.x );
		if( strlen( p + delta.x ) > size.x )
                    s[size.x] = EOS;
                }
            b.moveStr( 0, s, c );
            }
        writeBuf( 0, i, size.x, 1, b );
        }
}
Exemple #11
0
void TInterior::draw() {
    const char *hstr = "Hello World!";
    ushort color = getColor(0x0301);
    TView::draw();
    TDrawBuffer b;
    b.moveStr(0, hstr, color);
    writeLine(0, 0, 12, 1, b);
}
Exemple #12
0
void DynamicText::draw()
{
  TDrawBuffer b;
  uchar color = getColor(1);
  int offset = ( rightJustify ) ? size.x-strlen(text) : 0;

  b.moveChar( 0, ' ', color, size.x );
  b.moveStr( offset, text, color );
  writeBuf( 0, 0, size.x, 1, b );
}
Exemple #13
0
void TStaticText::draw()
{
    uchar color;
    Boolean center;
    int i, j, l, p, y;
    TDrawBuffer b;
    char s[256];

    color = getColor(1);
    getText(s);
    l = strlen(s);
    p = 0;
    y = 0;
    center = False;
    while (y < size.y)
        {
        b.moveChar(0, ' ', color, size.x);
        if (p < l)
            {
            if (s[p] == 3)
                {
                center = True;
                ++p;
                }
            i = p;
            do {
               j = p;
               while ((p < l) && (s[p] == ' '))
                   ++p;
               while ((p < l) && (s[p] != ' ') && (s[p] != '\n'))
                   ++p;
               } while ((p < l) && (p < i + size.x) && (s[p] != '\n'));
            if (p > i + size.x)
                if (j > i)
                    p = j;
                else
                    p = i + size.x;
            if (center == True)
               j = (size.x - p + i) / 2 ;
            else
               j = 0;
            b.moveBuf(j, &s[i], color, (p - i));
            while ((p < l) && (s[p] == ' '))
                p++;
            if ((p < l) && (s[p] == '\n'))
                {
                center = False;
                p++;
                if ((p < l) && (s[p] == 10))
                    p++;
                }
            }
        writeLine(0, y++, size.x, 1, b);
        }
}
Exemple #14
0
void TProgressBar::draw()
{
    char color = getColor(1);
    TDrawBuffer nbuf;

	 nbuf.moveChar(0,' ',color,size.x);

	 nbuf.moveStr( 0, bar, color ) ;

    writeLine(0, 0, size.x, 1, nbuf);
}
Exemple #15
0
void TTable::draw() {
    TDrawBuffer buf;
    char color = getColor(6);

    for (ushort y = 0; y <= size.y - 1; y++) {
        buf.moveChar(0, ' ', color, (short) size.x);
        for (ushort x = 0; x <= size.x - 1; x++)
            buf.moveChar(x, (ushort)(32 * y + x), color, (ushort) 1);
        writeLine(0, y, (short) size.x, (ushort) 1, buf);
    }
    showCursor();
}
void TCalcDisplay::draw()
{
    char color = getColor(1);
    int i;
    TDrawBuffer buf;

    i = size.x - strlen(number) - 2;
    buf.moveChar(0, ' ', color, size.x);
    buf.moveChar(i, sign, color, 1);
    buf.moveStr(i+1, number, color);
    writeLine(0, 0, size.x, 1, buf);
}
void TCalcDisplay::draw()
{
    char color = getColor(1);
    short i;
    TDrawBuffer buf;

    i = (short)(size.x - strlen(number) - 2);
    buf.moveChar(0, ' ', color, (short)size.x);
    buf.moveChar(i, sign, color, (short)1 );
    buf.moveStr((short)(i+1), number, color);
    writeLine(0, 0, (short)size.x, 1, buf);
}
Exemple #18
0
void TReport::draw() {
    TDrawBuffer buf;
    char color = getColor(6);
    char str[80];

    sprintf(str,
            "%s%c%s%3d%s%2X  ", //wsz: to print 32 characters
            "  Char: ", (asciiChar == 0) ? (char) 0x20 : (char) asciiChar, " Decimal: ",
            (int) asciiChar, " Hex: ", (int) asciiChar); //wsz: :-)

    buf.moveStr(0, str, color);
    writeLine(0, 0, 32, 1, buf);
}
Exemple #19
0
void EnhancedStatusLine::draw()
{
    TStatusLine::draw();
    ushort cNormal = getColor(0x0301);
    for (int i=0; i < count; i++)
    {
        TDrawBuffer b;
        if (i != 0)
            b.moveChar(0, '\263', cNormal, 1);
        b.moveCStr(i ? 1 : 0, items[i].text, cNormal);
        writeBuf(items[i].offset - (i ? 1 : 0), 0, (i ? 1 : 0) + strlen(items[i].text), 1, b);
    }
}
void TClickTester::draw()
{
    TDrawBuffer buf;
    char c;

    if (clicked)
        c = getColor(2);
    else
        c = getColor(1);

    buf.moveChar(0, ' ', c, size.x);
    buf.moveStr(0, text, c);
    writeLine(0, 0, size.x, 1, buf);
}
void TOutlineViewer::draw() {
   ushort nrmColor = getColor(0x0401);

   firstThat(drawTree);
   dBuf.moveChar(0, ' ', nrmColor, size.x);
   writeLine(0, auxPos + 1, size.x, size.y - (auxPos - delta.y), dBuf);
}
short TSystemError::sysErr( short errorCode, uchar drive )
{
    ushort c = ( (TScreen::screenMode & 0x00fF) != TDisplay::smMono  ) ?
                                        sysColorAttr : sysMonoAttr;
    char s[ 63 ];
    TDrawBuffer b;

    sprintf( s, errorString[ errorCode ], drive + 'a' );

    b.moveChar( 0, ' ', c, 80);
    b.moveCStr( 1, s, c);
    b.moveCStr( 79-cstrlen(sRetryOrCancel), sRetryOrCancel, c);
    swapStatusLine(b);
    int res = selectKey();
    swapStatusLine(b);
    return res;
}
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 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);
   }
}
Exemple #25
0
void TBrightnessIndicator::draw()
{
	ushort color = getColor(1);

	TDrawBuffer b;
	b.moveChar( 0, ' ', color, size.x );
	for( int i = 0; i < numberOfShades; i++ )
		b.moveChar( size.x * i / numberOfShades,
				  fillString[i], color,
				  size.x / numberOfShades );

	writeLine( 0, 0, size.x, 1, b );

	b.moveChar( 0, ' ', color, size.x );
	b.moveChar( size.x - 1 - Round(
		((double)position / (double)range) * (double)(size.x - 1) ),
		arrowChar, color, 1 );

	writeLine( 0, 1, size.x, 1, b );
}
void TCalendarView::draw()
{
    char str[23];
    char current = 1 - dayOfWeek(1, month, year);
    char days = daysInMonth[month] + ((year % 4 == 0 && month == 2) ? 1 : 0);
    char color, boldColor;
    int  i, j;
    TDrawBuffer buf;

    color = getColor(6);
    boldColor = getColor(7);

    buf.moveChar(0, ' ', color, 22);

    ostrstream( str, sizeof str)
      << setw(9) << monthNames[month] << " " << setw(4) << year
      << " " << (char) 30 << "  " << (char) 31 << " " << ends;

    buf.moveStr(0, str, color);
    writeLine(0, 0, 22, 1, buf);

    buf.moveChar(0, ' ', color, 22);
    buf.moveStr(0, "Su Mo Tu We Th Fr Sa", color);
    writeLine(0, 1, 22, 1, buf);

    for(i = 1; i <= 6; i++)
        {
        buf.moveChar(0, ' ', color, 22);
        for(j = 0; j <= 6; j++)
            {
            if(current < 1 || current > days)
                buf.moveStr(j*3, "   ", color);
            else
                {
                ostrstream( str, sizeof str )
                  << setw(2) << (int) current << ends;
                if(year == curYear && month == curMonth && current == curDay)
                    buf.moveStr(j*3, str, boldColor);
                else
                    buf.moveStr(j*3, str, color);
                }
            current++;
            }
        writeLine(0, i+1, 22, 1, buf);
        }
}
void TCalendarView::draw() {
   char str[28];
   char current = 1 - dayOfWeek(1, month, year);
   char    days = daysInMonth[month] + (year%4==0 && month==2?1:0);
   char   color = getColor(6),
         hcolor = (color&0xF0)+0x09,
         tcolor = 0x2F,
        ticolor = (color&0xF0)>>4|(tcolor&0xF0),
        odcolor = (color&0xF0)+0x01,
        wdcolor = (color&0xF0)+0x04;
   int  ii, jj;
   TDrawBuffer buf;

   buf.moveChar(0, ' ', color, 24);
   snprintf(str, 28,"%12s %4d \x1E \x1F", monthNames[month], year);
   buf.moveStr(0, str, hcolor);
   writeLine(0, 0, 24, 1, buf);

   buf.moveChar(0, ' ', color, 22);
   buf.moveStr(0, " Mo Tu We Th Fr Sa Su", hcolor);
   writeLine(0, 1, 24, 1, buf);

   for (ii=1; ii<=6; ii++) {
      buf.moveChar(0, ' ', color, 24);
      for (jj=0; jj<=6; jj++) {
         if (current<1 || current>days) buf.moveStr(1+jj*3, "   ", color);
         else {
            int today = year==curYear&&month==curMonth&&current==curDay,
              onechar = current<10?1:0;
            snprintf(str, 24, "%d", current);
            buf.moveStr(1+jj*3+onechar, str, today?tcolor:(jj<5?odcolor:wdcolor));
            if (today) {
               buf.moveChar(1+jj*3-1+onechar,0xDD,ticolor,1);
               buf.moveChar(1+jj*3+2,0xDE,ticolor,1);
            }
         }
         current++;
      }
      writeLine(0, ii+1, 24, 1, buf);
   }
}
Exemple #28
0
void TPuzzleView::draw() {
    char tmp[8];
    char color[2], colorBack;
    TDrawBuffer buf;

    color[0] = color[1] = colorBack = getColor(1);
    if (!solved)
        color[1] = getColor(2);

    /* SS: little change */
    short i;
    for (i = 0; i <= 3; i++)
    //for(short i = 0; i <= 3; i++)
            {
        buf.moveChar(0, ' ', colorBack, 18);
        if (i == 1)
            buf.moveStr(13, "Move", colorBack);
        if (i == 2) {
            sprintf(tmp, "%d", moves);
            buf.moveStr(14, tmp, colorBack);
        }
        for (short j = 0; j <= 3; j++) {
            strcpy(tmp, "   ");
            tmp[1] = board[i][j];
            if (board[i][j] == ' ')
                buf.moveStr((short) (j * 3), tmp, color[0]);
            else
                buf.moveStr((short) (j * 3), tmp, color[(int) map[board[i][j] - 'A']]);
        }
        writeLine(0, i, 18, 1, buf);
    }
}
Boolean drawTree(TOutlineViewer *beingDrawn, TNode *cur, int level,
                 int position, long lines, ushort flags)
{
   ushort  color;
   char s[256];
   char *graph;

   if (position >= beingDrawn->delta.y) {
      if (position >= beingDrawn->delta.y + beingDrawn->size.y)
         return True;

      if ((position == beingDrawn->foc) && ((beingDrawn->state & sfFocused) != 0))
         color = beingDrawn->getColor(0x0202);
      else if (beingDrawn->isSelected(position))
         color = beingDrawn->getColor(0x0303);
      else
         color = beingDrawn->getColor(0x0401);
      dBuf.moveChar(0, ' ', color, beingDrawn->size.x);

      graph = beingDrawn->getGraph(level, lines, flags);
      strcpy(s, graph);
      delete graph;

      if ((flags & ovExpanded) == 0) {
         strcat(s, "~");
         strcat(s, beingDrawn->getText(cur));
         strcat(s, "~");
      } else
         strcat(s, beingDrawn->getText(cur));
      if (beingDrawn->delta.x <= strlen(s))
         dBuf.moveCStr(0, &s[beingDrawn->delta.x], color);
      else
         dBuf.moveCStr(0, "", color);
      beingDrawn->writeLine(0, position - beingDrawn->delta.y,
                            beingDrawn->size.x, 1, dBuf);
      auxPos = position;
   }

   return False;
}
void TStatusLine::drawSelect( TStatusItem *selected )
{
    TDrawBuffer b;
    ushort color;
    char hintBuf[256];

    ushort cNormal = getColor(0x0301);
    ushort cSelect = getColor(0x0604);
    ushort cNormDisabled = getColor(0x0202);
    ushort cSelDisabled = getColor(0x0505);
    b.moveChar( 0, ' ', cNormal, size.x );
    TStatusItem *T =  items;
    ushort i = 0;

    while( T != 0 )
        {
        if( T->text != 0 )
            {
            ushort l = cstrlen( T->text );
            if( i + l < size.x )
                {
                if( commandEnabled( T->command) )
                    if( T == selected )
                        color = cSelect;
                    else
                        color = cNormal;
                else
                    if( T == selected )
                        color = cSelDisabled;
                    else
                        color = cNormDisabled;

                b.moveChar( i, ' ', color, 1 );
                b.moveCStr( i+1, T->text, color );
                b.moveChar( i+l+1, ' ', color, 1 );
                }
            i += l+2;
            }
        T = T->next;
        }
    if( i < size.x - 2 )
        {
        strcpy( hintBuf, hint( helpCtx ) );
        if( *hintBuf != EOS )
            {
            b.moveStr( i, hintSeparator, cNormal );
            i += 2;
            if( strlen(hintBuf) + i > size.x )
                hintBuf[size.x-i] = EOS;
            b.moveStr( i, hintBuf, cNormal );
            i += strlen(hintBuf);
            }
        }
    writeLine( 0, 0, size.x, 1, b );
}