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); } }
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 ); }
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 ); } }
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; }
void TInputLine::draw() { int l, r; TDrawBuffer b; uchar color = (state & sfFocused) ? getColor( 2 ) : getColor( 1 ); b.moveChar( 0, ' ', color, size.x ); char buf[256]; strncpy( buf, data+firstPos, size.x - 2 ); buf[size.x - 2 ] = EOS; b.moveStr( 1, buf, color ); if( canScroll(1) ) b.moveChar( size.x-1, rightArrow, getColor(4), 1 ); if( (state & sfSelected) != 0 ) { if( canScroll(-1) ) b.moveChar( 0, leftArrow, getColor(4), 1 ); l = selStart - firstPos; r = selEnd - firstPos; l = max( 0, l ); r = min( size.x - 2, r ); if (l < r) b.moveChar( l+1, 0, getColor(3), r - l ); } writeLine( 0, 0, size.x, size.y, b ); setCursor( curPos-firstPos+1, 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 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); }
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() { AllocLocalStr(str, size.x + 1); unsigned current = 1 - dayOfWeek(1, month, year); unsigned 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, size.x); sprintf(str, "%c%12s %4d %c", upArrowChar, monthNames[month], year, downArrowChar); //wsz: to see full year and down arrow /*ostrstream( str, sizeof str) << setw(9) << monthNames[month] << " " << setw(4) << year << " " << (char) 30 << " " << (char) 31 << " " << ends;*/ buf.moveStr(0, str, color); writeLine(0, 0, size.x, 1, buf); buf.moveChar(0, ' ', color, size.x); buf.moveStr(0, "Su Mo Tu We Th Fr Sa", color); writeLine(0, 1, size.x, 1, buf); for (i = 1; i <= 6; i++) { buf.moveChar(0, ' ', color, size.x); for (j = 0; j <= 6; j++) { if (current < 1 || current > days) buf.moveStr(j * 3, " ", color); else { sprintf(str, "%2d", (int) current); if (year == curYear && month == curMonth && current == curDay) buf.moveStr(j * 3, str, boldColor); else buf.moveStr(j * 3, str, color); } current++; } writeLine(0, (short) (i + 1), size.x, 1, buf); } }
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 ); }
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); }
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&¤t==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); } }
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); }
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 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); }
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 TCalcDisplay::draw() { char color = getColor(1); int i; TDrawBuffer buf; i = size.x - strlen(number) - 2; buf.moveChar(0, ' ', color, size.x); if (hexmode) buf.moveChar(1, 'x', color&0xF0|0xC , 1); if (memory) buf.moveChar(2, 'm', color&0xF0|0xD , 1); buf.moveChar(i, sign, color, 1); buf.moveStr(i + 1, number, color); writeLine(0, 0, size.x, 1, buf); }
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); } }