-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUTTON.CPP
101 lines (72 loc) · 1.48 KB
/
BUTTON.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
97
98
99
100
101
#ifndef BUTTON_CPP
#define BUTTON_CPP
#include "button.h"
#include <string.h>
#include <conio.h>
#include <stdio.h>
Button::Button(int left, int top, int width, int height, char caption[], int Id)
{
Left = left;
Top = top;
Width = width;
Height = height;
strcpy(Caption,caption);
ID = Id;
//btnStatus = BUTTON_STATUS_NORMAL;
State = false;
IsClicked=false;
}
void Button::Highlight(char a)
{
int m = Left,n=Top;
char w[70] = " ";
for(int i = 0;i<l;i++)
w[i] = a;
textcolor(RED);
gotoxy(m,n+Height+1);
cprintf(w);
textcolor(WHITE);
}
void Button::Draw(int color)
{
textcolor(color);
int n = Top;
int a = Width-1;
gotoxy(Left,Top);
char w[70] = " ";
char h[25] = " ";
h[0] = char(179) ;
for(int i = 0;i<Width;i++)
{
w[i]=char(196);
h[i+1] = ' ';
}
h[a] = char(179);
cprintf(w);
n++;
for(int j = 0 ;j<Height;j++)
{
gotoxy(Left,n);
cprintf(h);
n++;
}
gotoxy(Left,n);
cprintf(w);
gotoxy(Left+2,Top+(Height%2));
textcolor(WHITE);
cprintf(Caption);
}
void Button::EnableClickHandler()
{
// if(navigate.get_status()==ID)
// {
// Highlight('*');
// }
if(IsClicked)
{
ButtonId = ID;
//btnStatus = BUTTON_STATUS_NORMAL;
State = true;
}
}
#endif //BUTTON_CPP