source: Sophya/branches/EA_Juin98/SophyaPI/PI/pipplist.cc@ 1036

Last change on this file since 1036 was 64, checked in by aubourg, 28 years ago

Portage Mac, 22/12/97

File size: 3.9 KB
Line 
1#include "pipplist.h"
2#include <LTableMonoGeometry.h>
3#include <LTableSingleSelector.h>
4#include <LTableMultiSelector.h>
5#include <LTableArrayStorage.h>
6#include <LComparator.h>
7
8class CellMsgComparator : public LComparator {
9public:
10 virtual Int32 Compare(
11 const void* inItemOne,
12 const void* inItemTwo,
13 Uint32 /*inSizeOne*/,
14 Uint32 /*inSizeTwo*/) const
15 {return ((PIPPListCell*)inItemOne)->msg == ((PIPPListCell*)inItemTwo)->msg;}
16};
17
18static CellMsgComparator cellMsgComparator;
19
20class CellStrComparator : public LComparator {
21public:
22 virtual Int32 Compare(
23 const void* inItemOne,
24 const void* inItemTwo,
25 Uint32 /*inSizeOne*/,
26 Uint32 /*inSizeTwo*/) const
27 {return ((PIPPListCell*)inItemOne)->str == ((PIPPListCell*)inItemTwo)->str;}
28};
29
30static CellStrComparator cellStrComparator;
31
32
33PIPPList::PIPPList(PIMsgHandler* h)
34: mHndl(h)
35{
36 InitPPList();
37}
38
39PIPPList::PIPPList(
40 const SPaneInfo& inPaneInfo,
41 const SViewInfo& inViewInfo,
42 PIMsgHandler* h)
43: LTableView(inPaneInfo, inViewInfo), mHndl(h)
44{
45 InitPPList();
46}
47
48void PIPPList::InitPPList()
49{
50 SetTableGeometry(new LTableMonoGeometry(this, 10, 16));
51 SetTableSelector(tss=new LTableSingleSelector(this));
52 mArray = new LArray(sizeof(PIPPListCell)),
53 SetTableStorage(new LTableArrayStorage(this, mArray));
54 tms = new LTableMultiSelector(this);
55 LTableView::InsertCols(1, 0, nil, 0, Refresh_No);
56}
57
58PIPPList::~PIPPList()
59{
60 SetTableSelector(nil);
61 delete tss;
62 delete tms;
63}
64
65
66void PIPPList::AppendItem(string const& str, PIMessage msg)
67{
68 PIPPListCell cell;
69 cell.str=str;
70 cell.msg=msg;
71 InsertRows(1, -1, &cell, sizeof(cell), Refresh_Yes);
72}
73
74STableCell PIPPList::FindStr(string const& str)
75{
76 PIPPListCell cell;
77 cell.str = str;
78 cell.msg = 0;
79 mArray->SetComparator(&cellStrComparator);
80 STableCell tcell;
81 FindCellData(tcell, &cell, sizeof(cell));
82 return tcell;
83}
84
85STableCell PIPPList::FindMsg(PIMessage msg)
86{
87 PIPPListCell cell;
88 cell.str = "";
89 cell.msg = msg;
90 mArray->SetComparator(&cellMsgComparator);
91 STableCell tcell;
92 FindCellData(tcell, &cell, sizeof(cell));
93 return tcell;
94}
95
96void PIPPList::DeleteItem(string const& str)
97{
98 STableCell tcell = FindStr(str);
99 RemoveRows(1, tcell.row, Refresh_Yes);
100}
101
102void PIPPList::DeleteItem(PIMessage msg)
103{
104 STableCell tcell = FindMsg(msg);
105 RemoveRows(1, tcell.row, Refresh_Yes);
106}
107
108
109void PIPPList::SetMultipleSelect(bool ms);
110
111int PIPPList::GetNbSel()
112{
113 int n = 0;
114 for (TableIndexT j=1; j<=mRows; j++) {
115 STableCell cell;
116 cell.row = j;
117 cell.col = 1;
118 if (CellIsSelected(cell)) n++;
119 }
120 return n;
121}
122
123PIMessage PIPPList::GetSelMsg(int i)
124{
125 int n = 0;
126 for (TableIndexT j=1; j<=mRows; j++) {
127 STableCell cell;
128 cell.row = j;
129 cell.col = 1;
130 if (CellIsSelected(cell)) n++;
131 if (n == i) {
132 PIPPListCell ppcell;
133 UInt32 sz = sizeof(ppcell);
134 GetCellData(cell, &ppcell, sz);
135 return ppcell.msg;
136 }
137 }
138 return 0;
139}
140
141string PIPPList::GetSelStr(int i)
142{
143 int n = 0;
144 for (TableIndexT j=1; j<=mRows; j++) {
145 STableCell cell;
146 cell.row = j;
147 cell.col = 1;
148 if (CellIsSelected(cell)) n++;
149 if (n == i) {
150 PIPPListCell ppcell;
151 UInt32 sz = sizeof(ppcell);
152 GetCellData(cell, &ppcell, sz);
153 return ppcell.str;
154 }
155 }
156 return "";
157}
158void PIPPList::SelectItem(string const& str)
159{
160 STableCell cell = FindStr(str);
161 SelectCell(cell);
162}
163
164void PIPPList::SelectItem(PIMessage msg)
165{
166 STableCell cell = FindMsg(msg);
167 SelectCell(cell);
168}
169
170void PIPPList::ClearSelItem(string const& str)
171{
172 STableCell cell = FindStr(str);
173 UnselectCell(cell);
174}
175
176void PIPPList::ClearSelItem(PIMessage msg)
177{
178 STableCell cell = FindMsg(msg);
179 UnselectCell(cell);
180}
181
182void PIPPList::SetMultipleSelect(bool ms)
183{
184 if (ms)
185 SetTableSelector(tms);
186 else
187 SetTableSelector(tss);
188}
189
190void
191PIPPList::ClickCell(
192 const STableCell& inCell,
193 const SMouseDownEvent& inMouseDown)
194{
195 if (GetClickCount() == 2) {
196
197 }
198}
Note: See TracBrowser for help on using the repository browser.