-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMenu.h
81 lines (58 loc) · 1.85 KB
/
Menu.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
/*
Menu.h
Apraksts:
Menu headeris, kurâ ietilpst Menu klase âtras izvçlnes izveidç "kosnoles" reþîmam.
Piemçrs:
int main(){
Menu *MyMenu;
void (*f2)(void);
struct MenuLine MenuLines[] = {
{"HelloWorld Program",&HelloWorld},
{"Shitso",&HelloWorld},
{"HelloWorld for test", &power}
};
MyMenu = new Menu;
MyMenu->setHeader("Jaunais headeris", true);
MyMenu->setLines(MenuLines, sizeof(MenuLines) / sizeof(struct MenuLine));
MyMenu->printMenu();
return EXIT_SUCCESS;
}
*/
#define bool int
#define true 1
#define false 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct MenuLine{ //Menu elementu struktûra
char description[50];
void (*f1)( void );
};
class Menu{
private:
int menuCount; //Menu elementu skaits
char header[50], //Menu Header-is
inputText[50], //Ievades izvadoðais teksts
errorInputText[50], //Kïûdas paziòojums, ja izvçlçtais nav iekð vçrtîbâm
footerActions[2][50]; //{"Exit [x]","About Menu[i]"}
struct MenuLine *Lines; //Menu galvenie elementi ar struktûru (Teksts, Pointeris uz funkciju)
protected:
void printHeader();
void printMenuLine( int p_line );
void printMenuLines();
void printMenu();
void aboutMenu();
void breakFooter();
public:
Menu();
void setHeader( const char p_header[] );
//void setHeader( const char p_header[], bool p_setDecoration);
void setHeader ( const char p_header[], bool p_setDecoration);
void setInputText( char p_inputText[] );
void setErrorInputText( char p_errorInputText[] );
void setFooterActionExit( char p_footerActionExit[] );
void setFooterActionInfo( char p_footerActionInfo[] );
void getMenu();
struct MenuLine getStruct(char p_description[50], void ( *p_function )( void ) );
int setLines( struct MenuLine p_Lines[], int p_size_of_array );
};