-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTabTracerLogLabelPanel.c
More file actions
138 lines (124 loc) · 4.22 KB
/
TabTracerLogLabelPanel.c
File metadata and controls
138 lines (124 loc) · 4.22 KB
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
#include "TabTracerLogLabelPanel.h"
static int iTracerLabelLeft, iTracerLabelRight, iTracerLabelTop, iTracerLabelBottom;
static TRACERLAYOUT * tracerlayout;
static TRACERSTRUCT ** tracer;
static HFONT hLabelFont;
extern int tracer_count;
/* Variabelen voor scoll functies */
static int iVscrollPos;
static int iVscrollRange;
static int iVscrollMax;
static int iVscrollMin;
static int iHscrollPos;
static int iHscrollRange;
static int iHscrollMax;
static int iHscrollMin;
void TabTracerLogLabelPanel_drawLabels(HDC hDC, int type, int elem, int fc_height)
{
/* Weergeven labels */
int maxWidth = 25;
SetBkMode(hDC, TRANSPARENT);
switch (type)
{
case Fase:
TextOut(hDC, 0, fc_height / 5 - 1, FC_code[elem], min(maxWidth, strlen(FC_code[elem])));
break;
case Detector:
TextOut(hDC, 0, fc_height / 5 - 1, D_code[elem], min(maxWidth, strlen(D_code[elem])));
break;
case Counter:
TextOut(hDC, 0, fc_height / 5 - 1, C_code[elem], min(maxWidth, strlen(C_code[elem])));
break;
case Timer:
TextOut(hDC, 0, fc_height / 5 - 1, T_code[elem], min(maxWidth, strlen(T_code[elem])));
break;
case Hulpelement:
TextOut(hDC, 0, fc_height / 5 - 1, H_code[elem], min(maxWidth, strlen(H_code[elem])));
break;
case Ingang:
TextOut(hDC, 0, fc_height / 5 - 1, IS_code[elem], min(maxWidth, strlen(IS_code[elem])));
break;
case Uitgang:
TextOut(hDC, 0, fc_height / 5 - 1, US_code[elem], min(maxWidth, strlen(US_code[elem])));
break;
case Memoryelem:
TextOut(hDC, 0, fc_height / 5 - 1, MM_code[elem], min(maxWidth, strlen(MM_code[elem])));
break;
default:
break;
}
}
HWND CreateTabTracerLogLabelPanel(HWND hwnd, HINSTANCE hInstance, RECT * r, TRACERLAYOUT * tracerl, TRACERSTRUCT ** tr)
{
tracer = tr;
tracerlayout = tracerl;
RegisterSomeClass(hInstance, "TabTracerLogLabelPanelClass", (WNDPROC)WindowProcTabTracerLogLabelPanel);
int e = GetLastError();
HWND hWnd = CreateWindow(
"TabTracerLoglLabelPanelClass", "",
WS_CHILD,
r->left, r->top, r->right - r->left, r->bottom - r->top,
hwnd, NULL, hInstance, NULL);
e = GetLastError();
iTracerLabelLeft = r->top;
iTracerLabelLeft = r->left;
iTracerLabelRight = r->right;
iTracerLabelBottom = r->bottom;
return hWnd;
}
LRESULT CALLBACK WindowProcTabTracerLogLabelPanel(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT rect;
HDC hdc;
PAINTSTRUCT ps;
switch (uMsg)
{
case WM_CREATE:
hLabelFont = CreateFont(13, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "Arial");
return 0;
case WM_SIZE:
GetClientRect(hWnd, &rect);
InvalidateRect(hWnd, &rect, TRUE);
iTracerLabelLeft = rect.top;
iTracerLabelLeft = rect.left;
iTracerLabelRight = rect.right;
iTracerLabelBottom = rect.bottom;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
/* Nieuwe verticale scroll info */
SetScrollRange(hWnd, SB_VERT, 0, max(0, (tracer_count + 4 - height / tracerlayout->fc_height)), TRUE);
if ((height / tracerlayout->fc_height) > tracer_count) iVscrollPos = 0;
iVscrollPos = min(iVscrollPos, iVscrollMax);
if (iVscrollPos != GetScrollPos(hWnd, SB_VERT))
{
SetScrollPos(hWnd, SB_VERT, iVscrollPos, TRUE);
}
///??? if (iTracerLabelRight - iTracerLabelLeft > (TRACERBUFFERSIZE / tracerzoom) * tracerlayout->timestep)
///??? tracerlayout->timestep = (iTracerLabelRight - iTracerLabelLeft) / (TRACERBUFFERSIZE / tracerzoom);
/* Nieuwe horizontale scroll info */
// int iHscrollPosTRA = iHscrollMax; // tijdelijke opslag van positie
// iHscrollMax = ((TRACERBUFFERSIZE / tracerzoom) - (int)((float)(iTracerLabelRight - iTracerLabelLeft) / (float)tracerlayout->timestep));
// SetScrollRange(hWnd, SB_HORZ, 0, iHscrollMax, TRUE);
// iHscrollPos = iHscrollMax - iHscrollPosTRA + iHscrollPos; // terugzetten positie
// if (iHscrollPos != GetScrollPos(hWnd, SB_HORZ))
// {
// SetScrollPos(hWnd, SB_HORZ, iHscrollPos, TRUE);
// }
// iHscrollPosTRA = iHscrollPos < 0 ? iHscrollMax : iHscrollPos;
return 0;
case WM_PAINT:
hdc = GetDC(hWnd);
BeginPaint(hWnd, &ps);
for (int tr = 0; tr < TRACES_MAX; ++tr)
{
if (tracer[tr])
{
TabTracerLogLabelPanel_drawLabels(hdc, tracer[tr]->type, tracer[tr]->elem, tracerlayout->fc_height);
}
}
EndPaint(hWnd, &ps);
ReleaseDC(hWnd, hdc);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}