void CXTPColorHex::CreateCellArray()
{
	CXTPClientRect rcClient(this);
	int x = (rcClient.Width()-CX_HEXDISP)/2;
	int y = 10; /*(rcClient.Height()-CY_HEXDISP)/2*/

	CXTPEmptyRect rect; // row 1
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x80), -1, 8, XOFFSET(x,6), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x69,0x80), -1, 9));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x54,0x80), -1, 10));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x3d,0x80), -1, 11));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x27,0x80), -1, 12));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x12,0x80), -1, 13));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x00,0x80), -1, 14));

	y+=12; // row 2
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x69), -1, 16, XOFFSET(x,5), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0xc0),  0, 17));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xa0,0xc0),  1, 18));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0xc0),  2, 19));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x4b,0xc0),  3, 20));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x24,0xc0),  4, 21));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x00,0xc0),  5, 22));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x12,0x00,0x80),  6, 23));

	y+=12; // row 3
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x54),  6, 25, XOFFSET(x,4), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0xa0),  7, 26));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xff,0xff),  8, 27));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0xff),  9, 28));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0xff), 10, 29));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x46,0xff), 11, 30));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x00,0xff), 12, 31));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x24,0x00,0xc0), 13, 32));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x27,0x00,0x80), 14, 33));

	y+=12; // row 4
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x3d), 14, 35, XOFFSET(x,3), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0x80), 15, 36));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xff,0xc0), 16, 37));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0xff,0xff), 17, 38));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0xc0,0xff), 18, 39));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0x80,0xff), 19, 40));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0x57,0xff), 20, 41));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x46,0x00,0xff), 21, 42));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x4e,0x00,0xc0), 22, 43));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x3d,0x00,0x80), 23, 44));

	y+=12; // row 5
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x27), 23, 46, XOFFSET(x,2), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0x4b), 24, 47));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xff,0x80), 25, 48));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0xff,0xc0), 26, 49));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa0,0xff,0xff), 27, 50));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa0,0xc0,0xff), 28, 51));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa0,0xa0,0xff), 29, 52));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x57,0xff), 30, 53));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0xff), 31, 54));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0xc0), 32, 55));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x56,0x00,0x80), 33, 56));

	y+=12; // row 6
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x12), 33, 58, XOFFSET(x,1), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0x24), 34, 59));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xff,0x46), 35, 60));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0xff,0x80), 36, 61));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa0,0xff,0xc0), 37, 62));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xcc,0xff,0xff), 38, 63));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc3,0xda,0xed), 39, 64));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xa0,0xff), 40, 65));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x57,0xff), 41, 66));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0xff), 42, 67));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa3,0x00,0xc0), 43, 68));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x6b,0x00,0x80), 44, 69));

	y+=12; // row 7
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x80,0x00), 44, 70, x, y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xc0,0x00), 45, 71));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0xff,0x00), 46, 72));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x57,0xff,0x57), 47, 73));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa0,0xff,0xa0), 48, 74));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xcc,0xff,0xcc), 49, 75));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0xff), 50, 76));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xcc,0xff), 51, 77));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xa0,0xff), 52, 78));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x57,0xff), 53, 79));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x00,0xff), 54, 80));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0xc0), 55, 81));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x80), 56, 82));

	y+=12; // row 8
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x12,0x80,0x00), 57, 82, XOFFSET(x,1), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x24,0xc0,0x00), 58, 83));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x46,0xff,0x00), 59, 84));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0xff,0x57), 60, 85));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xff,0xa0), 61, 86));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0xcc), 62, 87));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xcc,0xcc), 63, 88));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xa0,0xc0), 64, 89));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x57,0xc0), 65, 90));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x00,0xc0), 66, 91));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0x9d), 67, 92));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x67), 68, 93));

	y+=12; // row 9
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x27,0x80,0x00), 70, 93, XOFFSET(x,2), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x4e,0xc0,0x00), 71, 94));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0xff,0x00), 72, 95));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xff,0x57), 73, 96));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0xa0), 74, 97));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xc0,0xa0), 75, 98));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xa0,0xa0), 76, 99));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x57,0x80), 77, 100));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x00,0x80), 78, 101));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0x80), 79, 102));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x52), 80, 103));

	y+=12; // row 10
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x3d,0x80,0x00), 82, 103, XOFFSET(x,3), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0xc0,0x00), 83, 104));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xff,0x00), 84, 105));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0x57), 85, 106));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xc0,0x57), 86, 107));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x80,0x57), 87, 108));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x57,0x57), 88, 109));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x00,0x42), 89, 110));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0x4b), 90, 111));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x3b), 91, 112));

	y+=12; // row 11
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x56,0x80,0x00),  93, 112, XOFFSET(x,4), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xa3,0xc0,0x00),  94, 113));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0x00),  95, 114));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xc0,0x00),  96, 115));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x80,0x00),  97, 116));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x42,0x00),  98, 117));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0x00,0x00),  99, 118));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0x20), 100, 119));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x25), 101, 120));

	y+=12; // row 12
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x6b,0x80,0x00), 103, 120, XOFFSET(x,5), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xc0,0x00), 104, 121));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x9d,0x00), 105, 122));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x80,0x00), 106, 123));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x4b,0x00), 107, 124));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x20,0x00), 108, 125));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0x00,0x00), 109, 126));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x10), 110, 142));

	y+=12; // row 13
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x80,0x00), 112, 121, XOFFSET(x,6), y));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x67,0x00), 113, 122));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x52,0x00), 114, 123));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x3b,0x00), 115, 124));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x25,0x00), 116, 125));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x10,0x00), 117, 126));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x00,0x00), 118, 127));

	y+=24; // large white cell
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xff,0xff,0xff), 126, 128, x, y, TRUE));

	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xf8,0xf8,0xf8), 127, 129, XOFFSET(x,5), y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xea,0xea,0xea), 128, 130, XOFFSET(x,6), y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xdd,0xdd,0xdd), 129, 131, XOFFSET(x,5)+14, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xc0,0xc0,0xc0), 130, 132, XOFFSET(x,6)+14, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0xb2,0xb2,0xb2), 131, 133, XOFFSET(x,5)+14*2, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x96,0x96,0x96), 132, 134, XOFFSET(x,6)+14*2, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x80,0x80,0x80), 133, 135, XOFFSET(x,5)+14*3, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x77,0x77,0x77), 134, 136, XOFFSET(x,6)+14*3, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x5f,0x5f,0x5f), 135, 137, XOFFSET(x,5)+14*4, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x4d,0x4d,0x4d), 136, 138, XOFFSET(x,6)+14*4, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x33,0x33,0x33), 137, 139, XOFFSET(x,5)+14*5, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x29,0x29,0x29), 138, 140, XOFFSET(x,6)+14*5, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x1c,0x1c,0x1c), 139, 141, XOFFSET(x,5)+14*6, y+4));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x11,0x11,0x11), 140, 142, XOFFSET(x,6)+14*6, y+16));
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x08,0x08,0x08), 141, 143, XOFFSET(x,5)+14*7, y+4));

	// large black cell
	m_rgnList.AddTail(new CRgnCell(rect, RGB(0x00,0x00,0x00), 142, -1, XOFFSET(x,22), y, TRUE));

	// the color can be set using SetSelectedColor(color) before the
	// window is initialized, so check here and set the active color
	// pointer as well.

	if (m_clrColor != (COLORREF)-1)
	{
		if (!m_pCell)
		{
			m_pCell = GetColorCell(m_clrColor);
		}
	}
}
Exemple #2
0
/*-----------------------------------------------------------------------------

FUNCTION: OutputABufferToWindow(HWND, char *, DWORD)

PURPOSE: Updates TTY Buffer with characters just received.

PARAMETERS:
    hTTY     - handle to the TTY child window
    lpBuf    - address of data buffer
    dwBufLen - size of data buffer

HISTORY:   Date       Author      Comment
            5/ 8/91   BryanW      Wrote it
           10/27/95   AllenD      Modified for MTTTY Sample

-----------------------------------------------------------------------------*/
void OutputABufferToWindow(HWND hTTY, char * lpBuf, DWORD dwBufLen)
{
    RECT rect;

    /*
        update screen buffer with new buffer
        need to do a character by character check
        for special characters
    */
    int i;

    for ( i = 0 ; i < (int) dwBufLen; i++) {
        switch (lpBuf[ i ]) {
            case ASCII_BEL:                // BELL CHAR
                MessageBeep( 0 ) ;
                break ;

            case ASCII_BS:                 // Backspace CHAR
                if (COLUMN( TTYInfo ) > 0)
                   COLUMN( TTYInfo ) -- ;
                break ;

            case ASCII_CR:                 // Carriage Return
                COLUMN( TTYInfo ) = 0 ;
                if (!NEWLINE( TTYInfo ))
                    break;

                //
                // FALL THROUGH
                //

            case ASCII_LF:                 // Line Feed
                if (ROW( TTYInfo )++ == MAXROWS - 1)
                {
                    MoveMemory( (LPSTR) (SCREEN( TTYInfo )),
                                  (LPSTR) (SCREEN( TTYInfo ) + MAXCOLS),
                                  (MAXROWS - 1) * MAXCOLS ) ;
                    FillMemory((LPSTR) (SCREEN( TTYInfo ) + (MAXROWS - 1) * MAXCOLS),
                                  MAXCOLS,  ' ' ) ;
                    InvalidateRect( hTTY, NULL, FALSE ) ;
                    ROW( TTYInfo )-- ;
                }
                break ;

            default:                       // standard character
                SCREENCHAR(TTYInfo, COLUMN(TTYInfo), ROW(TTYInfo)) = lpBuf[ i ];

                rect.left = (COLUMN( TTYInfo ) * XCHAR( TTYInfo )) -
                            XOFFSET( TTYInfo ) ;
                rect.right = rect.left + XCHAR( TTYInfo ) ;
                rect.top = (ROW( TTYInfo ) * YCHAR( TTYInfo )) -
                           YOFFSET( TTYInfo ) ;
                rect.bottom = rect.top + YCHAR( TTYInfo ) ;
                InvalidateRect( hTTY, &rect, FALSE ) ;

                // 
                // Line wrap
                //
                if (COLUMN( TTYInfo ) < MAXCOLS-1 )
                    COLUMN( TTYInfo )++ ;
                else if (AUTOWRAP( TTYInfo ))
                    OutputABufferToWindow(hTTY, "\r\n", 2 ) ;
                
                break;
        }
    }

    MoveTTYCursor(hTTY);
    return;
}