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, ' ' ); } }
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); } }