1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#include "CFilePluginList.h"
#include "T2AdvertisePlugin.h"
#include "T2AdvertiseTable.h"
/*virtual*/ int T2AdvertiseTable::OnT2DlgItemCreate(CREATESTRUCT* cs) {
T2DlgItemTable::SetColWidth(cs->cx, 0, 0);
return T2DlgItemTable::OnT2DlgItemCreate(cs);
}
T2AdvertiseTable::T2AdvertiseTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2VerticalTable(inDoc, inImageObj, inPalette)
{
mClearBackground = true;
SetCellDataSize(sizeof(T2AdvertisePlugin *));
InsertCols(1, 0, NULL);
SetHScrollerStyle(AlwaysHide);
SetVScrollerStyle(AlwaysShow);
}
void T2AdvertiseTable::Add(T2AdvertisePlugin* inPlugin, BOOL inSelect) {
unsigned int theRowIndex = mRows;
InsertRows(1, theRowIndex, &inPlugin);
if (mCols == 1)
InsertCols(1, mCols, NULL);
SetMark(mRows, inSelect);
if (inSelect) {
TableCellT cell;
cell.row = mRows;
cell.col = 1;
SelectCell(cell);
}
}
void T2AdvertiseTable::Add(CFilePluginList* inPluginList) {
T2AdvertisePlugin *thePlugin;
int theSubType = GetUserCon();
POSITION pos = inPluginList->GetHeadPosition();
while (pos) {
thePlugin = (T2AdvertisePlugin *) inPluginList->GetNext(pos);
if (thePlugin->GetSubType() == theSubType && !thePlugin->IsTieupFinish())
Add(thePlugin, false);
}
}
/*virtual*/ void T2AdvertiseTable::DrawCell(CDC* pDC, const TableCellT& inCell) {
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
CFont font;
CPen pen;
CBrush theBrush;
RECT cellRect;
if (FetchLocalCellFrame(inCell, cellRect) && inCell.col == 1) {
T2AdvertisePlugin *thePlugin;
GetCellData(inCell, &thePlugin);
if (thePlugin) {
DWORD pluginType = GetUserCon();
int x = cellRect.left + 4;
int y = cellRect.bottom - 12;
font.CreateFont(-9, 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E");
pDC->SelectObject(&font);
pDC->SetBkMode(TRANSPARENT);
if (pluginType == 'CFPI') {
if (IsMark(inCell.row)) {
RECT rect;
rect.left = x;
rect.top = y;
rect.right = x + 4;
rect.bottom = y + 4;
pen.CreateStockObject(BLACK_PEN);
theBrush.CreateStockObject(WHITE_BRUSH);
pDC->SelectObject(&pen);
pDC->SelectObject(&theBrush);
pDC->MoveTo(rect.left + 2, rect.top + 3);
pDC->LineTo((rect.right + rect.left) / 2 - 2, rect.bottom - 1);
pDC->LineTo(rect.right - 1, rect.top - 1);
}
x = cellRect.left + 20;
y = cellRect.bottom - 12;
}
CString pluginName;
thePlugin->GetName(pluginName);
pDC->TextOutA(x, y, pluginName, strlen(pluginName));
}
}
pDC->RestoreDC(save);
}
void T2AdvertiseTable::ClickCell(const TableCellT& inCell, const CPoint& inPt) {
T2DlgItemTable::ClickCell(inCell, inPt);
if (IsValidCell(mSelectedCell) && mSelectedCell.col == 1) {
T2AdvertisePlugin *thePlugin;
GetCellData(mSelectedCell, &thePlugin);
if (thePlugin)
BroadcastMessage(GetDlgCtrlID(), thePlugin);
}
}
BOOL T2AdvertiseTable::IsMark(unsigned int inRow) {
void *theData = NULL;
TableCellT theCell;
theCell.row = inRow;
theCell.col = 2;
GetCellData(theCell, &theData);
return (theData != NULL);
}
void T2AdvertiseTable::SetMark(unsigned int inRow, BOOL inValue) {
void *theData = inValue ? this : NULL;
TableCellT theCell;
theCell.row = inRow;
theCell.col = 2;
SetCellData(theCell, &theData);
InvalidateRect(NULL);
}
/*virtual*/ void T2AdvertiseTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
POINT pt = inPt;
ClientToView(&pt, 1);
TableCellT cell;
FetchCellHitBy(pt, cell);
if (IsValidCell(cell))
ClickCell(cell, inPt);
}
/*virtual*/ BOOL T2AdvertiseTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
T2VerticalTable::OnT2DlgItemEraseBkgnd(pDC);
unsigned int numOfRows, numOfColumns, theRow, theColumn;
GetTableSize(numOfRows, numOfColumns);
for (theColumn = 1; theColumn <= numOfColumns; theColumn++) {
for (theRow = 1; theRow <= numOfRows; theRow++) {
TableCellT cell;
cell.row = theRow;
cell.col = theColumn;
DrawCell(pDC, cell);
}
}
T2DlgItemTable::HiliteCell(pDC, mSelectedCell);
return true;
}
/*virtual*/ void T2AdvertiseTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
DrawCell(pDC, inCell);
}
|