-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCTable.h
157 lines (128 loc) · 3.29 KB
/
CTable.h
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
/*
Copyright 2016, Michael R. Hoopmann, Institute for Systems Biology
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _CTABLE_H
#define _CTABLE_H
#include "CActiveFocus.h"
#include "CDisplay.h"
#include "CFont.h"
#include "Structs.h"
#include <string>
#include <vector>
using namespace std;
typedef struct kvTableColumn {
char dataType; //0=int, 1=double, 2=string
bool visible;
int ID;
int width;
string header;
} kvTableColumn;
typedef struct kvTableDP {
int ID; //matches to kvTableColumn.ID
int iVal;
double dVal;
string sVal;
void clear(){
ID=0;
iVal=0;
dVal=0;
sVal.clear();
}
} kvTableDP;
typedef struct kvTableRow {
size_t psmID;
vector<kvTableDP>* dp;
kvTableRow(){
psmID = 0;
dp = new vector<kvTableDP>;
}
kvTableRow(const kvTableRow& d){
psmID = d.psmID;
dp = new vector<kvTableDP>;
for(size_t i=0;i<d.dp->size();i++) dp->push_back(d.dp->at(i));
}
~kvTableRow(){
delete dp;
}
kvTableRow& operator=(const kvTableRow& d){
if(this!=&d){
psmID = d.psmID;
delete dp;
dp = new vector<kvTableDP>;
for(size_t i=0;i<d.dp->size();i++) dp->push_back(d.dp->at(i));
}
return *this;
}
kvTableDP& operator[](const size_t& index){
return dp->at(index);
}
} kvTableRow;
class CTable {
public:
int posX;
int posY;
int szX;
int szY;
int selected;
CTable();
~CTable();
int addColumn (string str, char dataType, bool visible=true);
void addDataPoint(size_t row, kvTableDP& dp);
void addRow (size_t index);
void applyFilter (kvFilter f);
void clear ();
void clearFilter ();
kvTableColumn& col(size_t index);
void fixLayout();
int getColumn(char* str);
int getColumn(string str);
int getPSMID(size_t index); //psm_id of filtered row.
int logic(int mouseX, int mouseY, int mouseButton, bool mouseButton1);
bool render();
void setDisplay(CDisplay* d);
void setFocus(CActiveFocus* f);
void setFont(CFont* f);
size_t size(bool col=false);
void sort(string colID, bool highToLow=true);
private:
CActiveFocus* activeFocus;
CDisplay* display;
CFont* font;
vector<kvTableColumn> columns;
vector<kvTableRow> rows;
vector<kvTableRow> rowsFilt;
kvColor colors[4];
int txtColors[2];
int bumpV;
int bumpOffsetV;
int lastMouseY;
double scrollJumpV;
bool scrollLockV;
int scrollOffsetV;
bool showScrollbarV;
int stepV;
int thumbHeightV;
int thumbMaxV;
int lastMouseX;
double scrollJumpH;
bool scrollLockH;
int scrollOffsetH;
bool showScrollbarH;
int stepH;
int thumbHeightH;
int thumbMaxH;
static char sortDataType;
static int sortIndex;
static bool sortDir; //true = high to low
static int compar(const void* p1, const void* p2);
};
#endif