-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmenu.cpp
More file actions
83 lines (67 loc) · 1.77 KB
/
Copy pathmenu.cpp
File metadata and controls
83 lines (67 loc) · 1.77 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
// source for menu functions
#include "menu.h"
Menu::Menu()
{
strcpy(Name, "Menu item");
x = 100;
y = 100;
h = 40;
w = 100;
FontSize = 14;
strcpy(FontFamily, "GLUT_BITMAP_HELVETICA_");
ActionId = 0;
}
int Menu::IsInside(int MouseX, int MouseY)
{
if( ( MouseX > x && MouseX < x+w ) && ( MouseY < y && MouseY > y-h ) )
return ActionId;
return 0;
}
int Menu::AddName(char TempName[])
{
strcpy(Name, TempName);
// operation sucessfull so return true
return 1;
}
int Menu::AddCoordinates(GLfloat tx, GLfloat ty, GLfloat th, GLfloat tw)
{
x = tx;
y = ty;
h = th;
w = tw;
// operation sucessfull so return true
return 1;
}
int Menu::AddActioId(int TempActionId)
{
ActionId = TempActionId;
// operation sucessfull so return true
}
void Menu::DisplayMenuElement()
{
BasicShapes ShapesObjects;
GLfloat Placeholder[] = {x,y, x+w,y, x+w,y-(h-h/10), x,y-(h-h/10)};
glColor3f((float)150/255, (float)0/255, (float)0/255); // box color
//glColor3f((float)(1/256), (float)(0/256), (float)(0/256)); // box color
ShapesObjects.DrawQuad(Placeholder);
glColor3f(1,1,1); // text color
DrawBitmapText(Name, x+(w/10), y-(h/2));
}
void DisplayMenu(Menu *MenuObject, int size)
{
for (int i=0; i < size ; ++i)
{
MenuObject[i].DisplayMenuElement();
}
}
void CreateMenu(Menu *MenuObject, char (*MenuElementList)[20], int *ActionList, int size, GLfloat tx, GLfloat ty, GLfloat Height, GLfloat Width)
{
GLfloat tempX = tx, tempY = ty;
for (int i=0; i < size ; ++i)
{
MenuObject[i].AddName(MenuElementList[i]);
MenuObject[i].AddCoordinates(tempX, tempY, Height, Width);
MenuObject[i].AddActioId(ActionList[i]);
tempY = tempY - Height;
}
}