-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcMain.cpp
198 lines (147 loc) · 4.44 KB
/
cMain.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//This is the frame of the Application
#include "cMain.h"
#include "AdminLogin.h"
#include "Seats.h"
#include "AddMovie.h"
#include "BuildBy.h"
//Event Handlers Here
wxBEGIN_EVENT_TABLE(cMain, wxFrame)
EVT_MENU(10002, cMain::OnMenuExit)
EVT_MENU(10001, cMain::OnAdmin)
EVT_MENU(10003, cMain::DevelopBy)
wxEND_EVENT_TABLE()
//Main Window
cMain::cMain() : wxFrame(nullptr, wxID_ANY, "Movie Ticket Booking ", wxPoint(30, 30), wxSize(1000, 800))
{
NewMovie m;
//Icon
wxIcon icon4;
::wxInitAllImageHandlers();
wxBitmap bitmap(wxT("Assets/logo/icon.png"), wxBITMAP_TYPE_PNG);
icon4.CopyFromBitmap(bitmap);
this->SetIcon(icon4);
//Menu Bar
m_MenuBar = new wxMenuBar();
m_MenuBar->SetBackgroundColour(wxColor(1, 2, 3));
this->SetMenuBar(m_MenuBar);
//Add Menu Items
wxMenu* menuFile = new wxMenu();
menuFile->Append(10001, "Admin");
menuFile->Append(10003, "Develop By");
menuFile->Append(10002, "Exit");
//Add Menu Items to Menu Bar
m_MenuBar->Append(menuFile, "All");
//Toolbar for forward home and back buttons
::wxInitAllImageHandlers();
wxBitmap bmpBack("Assets/back.png", wxBITMAP_TYPE_PNG);
wxBitmap bmpForward("Assets/forward.png", wxBITMAP_TYPE_PNG);
wxBitmap bmpHome("Assets/home.png", wxBITMAP_TYPE_PNG);
wxToolBar* toolBar = CreateToolBar();
//add toolbar items
toolBar->AddTool(wxID_ANY, "BAACK", bmpBack);
toolBar->AddTool(wxID_ANY, "HOME", bmpHome);
toolBar->AddTool(wxID_ANY, "FORWARD", bmpForward);
//Show Toolbar
toolBar->Realize();
//Grid Sizers
wxBoxSizer* movieList = new wxBoxSizer(wxVERTICAL);
wxGridSizer* grid = new wxGridSizer(4, 5, 5);
wxFont titleFont(16, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false);
wxFont secondaryFont(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL, false);
/*
for (int i = 0; i < 8; i++)
{
::wxInitAllImageHandlers();
wxBitmap bmp1("Assets/poster/joker.png", wxBITMAP_TYPE_PNG);
wxBitmapButton* button = new wxBitmapButton(panel, 222, bmp1);
gridSizer->Add(button, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTRE_VERTICAL | wxALL,5);
}
*/
//Opening File in Reading Mode
file->Open("data.txt", "r+");
//Check either file is opened or not
if (file->IsOpened())
{
wxLogStatus(wxT("File is opened"));
//Reading Data from File
while ((file->Read(&m, sizeof(m))))
{
//Initializing all image handlers
::wxInitAllImageHandlers();
//wxBitmap bmp(m.filePath, wxBITMAP_TYPE_PNG);
//button = new wxBitmapButton(panel, 222, moviePhoto[i]);
//Display Movie poster from file location
wxBitmap movie = wxBitmap(m.filePath, wxBITMAP_TYPE_PNG);
m_bitmap = new wxStaticBitmap(this, 212, movie,wxDefaultPosition, wxDefaultSize);
movieList->Add(m_bitmap);
//Display Movie Name From File
m_name = new wxStaticText(this, 4004, m.name);
m_name->SetFont(titleFont);
movieList->Add(m_name);
//Displays Movie Price From File
m_price = new wxStaticText(this, 4005, (wxString::Format(wxT("Rs.%d"),m.price)));
m_price->SetFont(secondaryFont);
movieList->Add(m_price);
//Book Now || Button
m_button = new wxButton(this, m.id,"Book Now");
m_button->SetFont(secondaryFont);
movieList->Add(m_button);
//Bind click event to the button
m_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &cMain::OnClick, this);
}
}
else
{
wxLogStatus(wxT("Error Opening Files."));
}
grid->Add(movieList);
//Setting Sizer for this window
SetSizer(grid);
SetScrollbar(wxVERTICAL, 0, 16, 50);
//SetScrollRate(5, -1);
//Bottom Status Bar
stats = CreateStatusBar(2);
stats->SetStatusText(_("Hamro Movie Theater"));
stats->SetStatusText(date1, 1);
}
cMain::~cMain()
{
delete[]button;
}
//Close window event
void cMain::OnMenuExit(wxCommandEvent &evt)
{
Close();
evt.Skip();
}
//Open Login Screen Event
void cMain::OnAdmin(wxCommandEvent &evt)
{
AdminLogin *f = new AdminLogin("Admin Login");
f->Show();
evt.Skip();
}
//Team Member window Event
void cMain::DevelopBy(wxCommandEvent& evt)
{
BuildBy* b = new BuildBy("Developed By");
b->Show();
evt.Skip();
}
//Seat Booking Page Event
void cMain::OnClick(wxCommandEvent& evt)
{
seatId Sid;
Seats* s = new Seats("Book Seats");
//s->Fit();
s->Show();
Sid.id = evt.GetId();
//Saving Last Clicked Movie Id To a File
LastSeatFile->Open("lastseat.txt", "w+");
if (LastSeatFile->IsOpened()) {
LastSeatFile->Write(&Sid, sizeof(Sid));
}
LastSeatFile->Close();
wxLogStatus((wxString::Format(wxT("BTN ID: %d"), evt.GetId())));
evt.Skip();
}