forked from jankowskib/D2Ex2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExListBox.cpp
96 lines (83 loc) · 2.37 KB
/
ExListBox.cpp
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
#include "stdafx.h"
#include "ExListBox.h"
#include "Misc.h"
#include "Vars.h"
ExListBox::ExListBox(int X, int Y, int Width, int Height, int Color, int Font) : aScrollBar(Width,Y,0,0,Height,0), ExControl(X,Y,Width,Height,0)
{
aColor=Color;
aFont=Font;
Members.clear();
MsgOffset =0;
aScrollBar.ptParent=this;
//#ifdef _DEBUG
//Misc::Log(L"--->Stworzylem nowa klase ExListBox '%d ,%d'",X,Y);
//#endif
LeaveCriticalSection(&CON_CRITSECT);
}
void ExListBox::Draw()
{
//D2Funcs::D2GFX_DrawRectangle(cX,cY,cWidth,cHeight,0xff,1);
}
void ExListBox::AddToList(wstring Member)
{
int tX,tY;
D2Funcs::D2WIN_SetTextSize(aFont);
int a = D2Funcs::D2WIN_GetFontHeight();
if(!Members.empty())
{
tX = Members.back()->GetX();
tY = Members.back()->GetY() Members.back()->GetHeight();
}
else
{
tX= cX;
tY= cY a;
}
cWidth-=aScrollBar.GetWidth();
ExTextBox* Mem = new ExTextBox(tX,tY,aColor,aFont,Member,0,this);
cWidth =aScrollBar.GetWidth();
Members.push_back(Mem);
aScrollBar.sMax=Members.size();
while(Mem->GetHeight() Mem->GetY()>=cHeight)
for(vector<ExTextBox*>::size_type i =0;i<Members.size();i )
{
if(Members.at(i)->cState==INVISIBLE) continue;
Members.at(i)->cState=INVISIBLE;
MsgOffset = i ;
int fOffset=Members.at(i)->GetY() Members.at(i)->GetHeight()-cY;
for(vector<ExTextBox*>::size_type z =MsgOffset;z<Members.size();z ) Members.at(z)->SetY(Members.at(z)->GetY()-fOffset);
break;
}
}
void ExListBox::RemoveFromList(wstring Member)
{
for(vector<ExTextBox*>::iterator it1 = Members.begin(); it1!=Members.end(); it1 )
{
if ( (*it1)->GetText() == Member) { delete *it1; Members.erase(it1); aScrollBar.sMax=Members.size(); break;}
}
//przesun w gore
}
void ExListBox::GfxMove(vector<ExTextBox*>::size_type Offset)
{
for(vector<ExTextBox*>::size_type i=0; i<Members.size() ;i ) Members.at(i)->cState=INVISIBLE;
for(vector<ExTextBox*>::size_type i =Offset;i<Members.size();i )
{
if(i==Offset) Members.at(i)->SetY(cY Members.at(i)->GetHeight());
else Members.at(i)->SetY(Members.at(i-1)->GetY() Members.at(i-1)->GetHeight() Members.at(i)->GetHeight());
if(Members.at(i)->GetY()>cHeight) break;
else
Members.at(i)->cState=VISIBLE;
}
}
ExListBox::~ExListBox(void)
{
EnterCriticalSection(&CON_CRITSECT);
for(vector<ExTextBox*>::size_type i=0 ; i<Members.size(); i )
{
delete Members.at(i);
}
Members.clear();
//#ifdef _DEBUG
//Misc::Log(L"--->Zniszczylem obiekt ExListBox 'X=%d, Y=%d'",cX,cY);
//#endif
}