|
|
1.1 root 1: #include <windows.h>
2: #include <windowsx.h>
3: #include "app.h"
4: #include "box.hxx"
5:
6: CTextField::CTextField(TCHAR *sz)
7: {
8: _sz = sz;
9: }
10:
11: void CTextField::Paint(CCanvas &canvas, int x, int y)
12: {
13: SetTextAlign(canvas, TA_LEFT | TA_BASELINE );
14: CFontSelect fs(canvas, _font);
15: canvas.Text(x, y, _sz, lstrlen(_sz) );
16: }
17:
18: void CTextField::GetExtent(CCanvas &canvas, SIZE *pSize)
19: {
20: GetTextExtentPoint(canvas, _sz, lstrlen(_sz), pSize);
21: }
22:
23: void CTextField::SetFont(HFONT hfont)
24: {
25: _font = hfont;
26: }
27:
28: //-----------------------------------------------
29: CBoxFormat::CBoxFormat(SIZE sizeChar) :
30: _fontAlias(TEXT("Arial Narrow"), -10, FALSE),
31: _fontCtype(TEXT("Arial"), 12, TRUE, FALSE, TRUE)
32: {
33: _size = sizeChar;
34: }
35:
36: //-----------------------------------------------
37: CBox::CBox( CBoxFormat &bxf, UINT iChar, HFONT hfont ) :
38: _fontBlock( hfont ),
39: _Block(1, 1, iChar, bxf ),
40: _bxf(bxf),
41: _Alias(TEXT("Character Type Bits:"))
42: {
43:
44: _fontBlock.Update( -40, TRUE);
45: _Block.SetFont(_fontBlock);
46:
47: _sizeBox.cx = bxf._size.cx+100; // shadow 100/20 poitns
48: _sizeBox.cy = bxf._size.cy+100;
49:
50: #ifdef UNICODE
51: _sizeBox.cx += INCH4;
52: _sizeBox.cy += INCH4;
53: #endif
54:
55:
56: _Alias.SetFont(bxf._fontAlias);
57: _iChar = iChar;
58: }
59:
60:
61: void CBox::Paint(CCanvas &canvas, POINT pt, RECT rc)
62: {
63: int x = pt.x;
64: int y = pt.y;
65:
66: #ifdef UNICODE
67: // adjust to length of header
68:
69: SIZE size;
70: _Alias.GetExtent(canvas, &size);
71: _sizeBox.cx += size.cx;
72: #endif
73: // make rc large enough
74: rc.left = pt.x;
75: rc.top = pt.y;
76: rc.right = pt.x+_sizeBox.cx-100;
77: rc.bottom = pt.y+_sizeBox.cy-100;
78:
79: OffsetRect( &rc, 100, 100 );
80: FillRect(canvas, &rc, GetStockBrush(GRAY_BRUSH));
81: OffsetRect( &rc, -100, -100 );
82: FillRect(canvas, &rc, GetStockBrush(WHITE_BRUSH));
83:
84: #ifdef UNICODE
85: CBlackPen pen(canvas, PS_SOLID, 20);
86: Rectangle(canvas, rc.left, rc.top, rc.right, rc.bottom);
87:
88: pt.x += INCH8;
89: pt.y += INCH8;
90: #endif
91:
92: _Block.Paint(canvas, rc, pt);
93:
94: #ifdef UNICODE
95: _Alias.Paint(canvas, x+=INCH1, y+= INCH4);
96: _Alias.GetExtent(canvas, &size);
97:
98: pt.x = x;
99: pt.y = y+INCH10;
100:
101: USHORT uTemp[2]={_iChar, 0};
102: USHORT uType[2];
103:
104: SetTextColor(canvas, RGB(0,128,0));
105: for( int i = 0; i < 3; i++ )
106: {
107: pt.y += size.cy;
108:
109: GetStringTypeW(1<<i, uTemp, 2, uType );
110: CCodeGrid Ctype(1,1, size, uType[0]);
111: Ctype.SetFont(_bxf._fontCtype);
112: Ctype.SetFormat(HEXADECIMAL,4);
113: Ctype.Paint(canvas, rc, pt);
114: }
115: SetTextColor(canvas, RGB(0,0,0));
116: #endif
117: }
118:
119: UINT CBox::Hittest(CCanvas &canvas, POINT pt)
120: {
121: return 0x00C5;
122: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.