-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFrame.cpp
More file actions
177 lines (142 loc) · 5.28 KB
/
MyFrame.cpp
File metadata and controls
177 lines (142 loc) · 5.28 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include "MyFrame.hpp"
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size) {
//mode d'axer
mood_utilisateur = true;
//Menu de l'aplications
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_MOOD_ADMIN, "&Mode Admine\tCtrl-A", "Passer l'application en mode Administrateur.");
menuFile->Append(ID_MOOD_UTILISATEUR, "&Mode Utilisateur\tCtrl-U", "Passer l'application en mode Utilisateur.");
menuFile->AppendSeparator();
menuFile->Append(wxID_EXIT, "&Quitter\tCtrl-Q", "Quitte l'application.");
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
SetMenuBar( menuBar );
CreateStatusBar();
// Création du panel d'affichage
panelAffichage = new wxPanel(this, -1);
//les box
sizer_init = new wxBoxSizer(wxVERTICAL);
sizer_categorie = new wxBoxSizer(wxHORIZONTAL);
sizer_comende = new wxBoxSizer(wxHORIZONTAL);
//les static box
//les commande des client
membres = new Membre(panelAffichage);
commande = new Commande(panelAffichage, membres);
membres->InitCommande(commande);
//les categorie darticle proposer
static_boison = new Categorie(panelAffichage, "boisson", commande);
static_snack = new Categorie(panelAffichage, "snack", commande);
static_nouie = new Categorie(panelAffichage, "nouille", commande);
static_diver = new Categorie(panelAffichage, "autre", commande);
statistiques = new Statistiques(panelAffichage, this, membres);
membres->InitStatistiques(statistiques);
static_boison->initStatistiques(statistiques);
static_snack->initStatistiques(statistiques);
static_nouie->initStatistiques(statistiques);
static_diver->initStatistiques(statistiques);
//la line
wxStaticLine* ligneHoriz = new wxStaticLine(panelAffichage, -1);
// ajour:
//les aurgnisatons des stoke
sizer_init->Add(sizer_categorie, 10, wxALL | wxEXPAND, 0);
sizer_categorie->Add(static_boison, 1, wxALL | wxEXPAND, 5);
sizer_categorie->Add(static_snack, 1, wxALL | wxEXPAND, 5);
sizer_categorie->Add(static_nouie, 1, wxALL | wxEXPAND, 5);
sizer_categorie->Add(static_diver, 1, wxALL | wxEXPAND, 5);
sizer_comende->Add(membres, 0, wxALL | wxEXPAND, 0);
sizer_comende->Add(commande, 1, wxALL | wxEXPAND, 0);
sizer_comende->Add(statistiques, 1, wxALL | wxEXPAND, 0);
//separations
sizer_init->Add(ligneHoriz, 0, wxALL | wxEXPAND, 0);
// vendre a une persone
sizer_init->Add(sizer_comende, 4, wxALL | wxEXPAND, 0);
panelAffichage->SetSizer(sizer_init);
this->Bind(wxEVT_MENU, [this](wxCommandEvent & evt)->void{ OnAdmin(); }, ID_MOOD_ADMIN);
this->Bind(wxEVT_MENU, [this](wxCommandEvent & evt)->void{OnUtilisateur();}, ID_MOOD_UTILISATEUR);
this->Bind(wxEVT_MENU, [this](wxCommandEvent & evt)->void{OnExit();}, wxID_EXIT);
OnUtilisateur();
}
wxArrayString MyFrame::NomSnacks(){
wxArrayString snacks;
snacks.Add(wxString("Tout snacks"));
wxArrayString nom_boison = static_boison->NomSnacks();
for(wxString s : nom_boison)
snacks.Add(s);
wxArrayString nom_snack = static_snack->NomSnacks();
for(wxString s : nom_snack)
snacks.Add(s);
wxArrayString nom_nouie = static_nouie->NomSnacks();
for(wxString s : nom_nouie)
snacks.Add(s);
wxArrayString nom_diver = static_diver->NomSnacks();
for(wxString s : nom_diver)
snacks.Add(s);
return snacks;
}
void MyFrame::OnExit()
{
Close( true );
}
void MyFrame::OnAdmin()
{
wxTextEntryDialog code_is(panelAffichage, wxT("Entrez le code administrateur"), wxT("Administrateur"), "", wxTextEntryDialogStyle | wxTE_PASSWORD);
wxString nom = "code";
if (code_is.ShowModal() == wxID_OK && nom == code_is.GetValue())
{
DesactiveAdmin();
static_boison->MoodAdmin();
static_snack->MoodAdmin();
static_nouie->MoodAdmin();
static_diver->MoodAdmin();
membres->MoodAdmin();
commande->MoodAdmin();
membres->ModeCommandeAdmin();
statistiques->MoodAdmin();
}
code_is.Destroy();
}
void MyFrame::OnUtilisateur()
{
DesactiveUtilisateur();
static_boison->MoodUtilisateur();
static_snack->MoodUtilisateur();
static_nouie->MoodUtilisateur();
static_diver->MoodUtilisateur();
membres->MoodUtilisateur();
membres->ModeCommandeUse();
membres->JustOnePersonne();
statistiques->MoodUtilisateur();
}
void MyFrame::DesactiveUtilisateur(){
wxMenuBar* menuBar = GetMenuBar();
if (menuBar && menuBar->GetMenuCount() > 0)
{
wxMenu* menu1 = menuBar->GetMenu(0);
if (menu1)
{
menu1->Enable(ID_MOOD_UTILISATEUR, false);
}
wxMenu* menu2 = menuBar->GetMenu(0);
if (menu2)
{
menu2->Enable(ID_MOOD_ADMIN, true);
}
}
}
void MyFrame::DesactiveAdmin(){
wxMenuBar* menuBar = GetMenuBar();
if (menuBar && menuBar->GetMenuCount() > 0)
{
wxMenu* menu1 = menuBar->GetMenu(0);
if (menu1)
{
menu1->Enable(ID_MOOD_UTILISATEUR, true);
}
wxMenu* menu2 = menuBar->GetMenu(0);
if (menu2)
{
menu2->Enable(ID_MOOD_ADMIN, false);
}
}
}