-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOMOTimer App
353 lines (324 loc) · 14.7 KB
/
POMOTimer App
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#include <iostream>
#include <memory>
#include <vector>
#include <map>
#include <nana/deploy.hpp>
#include <nana/gui.hpp>
#include <nana/gui/place.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/combox.hpp>
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/progress.hpp>
#include <nana/gui/widgets/tabbar.hpp>
#include <nana/gui/widgets/panel.hpp>
#include <nana/gui/widgets/listbox.hpp>
#include <nana/gui/widgets/treebox.hpp>
#include <nana/gui/widgets/checkbox.hpp>
#include <nana/gui/widgets/date_chooser.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/categorize.hpp>
#include <nana/gui/widgets/group.hpp>
#include <nana/gui/timer.hpp>
#include <nana/gui/tooltip.hpp>
#include <nana/filesystem/filesystem_ext.hpp>
#include <windows.h>
#include <string>
int s1=0;
int s2=25;
int s3 = 0;
nana::msgbox mb4;
using namespace std;
class Timer { //class
private: //private data members
int Sec, Min, Hrs;
public: //public data members
void setSec(int), setMin(int), setHrs(int); //function prototypes
int getSec(), getMin(), getHrs();
string credits, info, steps;
Timer(); //default constructor; sets timer if user does not set hours, minutes and seconds
};
void Timer::setSec(int s) { //setter for seconds
Sec = s3;
}
int Timer::getSec() {
return Sec;
}
void Timer::setMin(int m) { //setter for minutes
Min = m;
}
int Timer::getMin() {
return Min;
}
void Timer::setHrs(int h) { //setter for hours
Hrs = h;
}
int Timer::getHrs() {
return Hrs;
}
Timer::Timer() { //sets timer to 25 minutes by default (avg. pomodoro time)
Sec = s3;
Min = s2;
Hrs = s1;
credits = "CREDITS\n\nAyesha Tahir\t\tBSCS-10A\nAzka Khan\t\tBSCS-10A\nLIBRARY\t\t\tNANA"; //information for menu
steps = "STEPS TO UTILIZING THE POMODORO TECHNIQUE\n\nThere are six steps in the original technique:\n1. Decide on the task to be done\n2. Set the pomodoro timer(traditionally to 25 minutes).\n3. Work on the task.\n4. End work when the timer rings and put a checkmark on a piece of paper.\n5. If you have fewer than four checkmarks, take a short break (3 to 5 minutes) and then return to step 2; otherwise continue to step 6.\n6. After four pomodoros, take a longer break (15 to 30 minutes), reset your checkmark count to zero, then go to step 1.\n[Source: Wikipedia]\n";
info = "WHAT IS THE POMODORO?\n\nThe Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. The technique uses a timer to break down work into intervals, traditionally 25 minutes in length, separated by short breaks. Each interval is known as a pomodoro, from the Italian word for 'tomato', after the tomato-shaped kitchen timer that Cirillo used as a university student.\n[Source: Wikipedia]\n";
}
void displayTime() { //timer display
Timer t; //creation of Timer object
nana::msgbox msg{ "POMOSession Ended" }; //call messagebox upon end of interval
int hrs1= t.getHrs(); //getting values of hours, minutes and seconds
int sec1 = t.getSec();
int min1 = t.getMin();
for (int h = hrs1; h >= 0; h--) //starts decrementing for hours
{
for (int m = min1; m >= 0; m--) //starts decrementing for minutes
{
if (m == 0 && hrs1 > 0) //if hours remains, resets value of minutes to 59 for the next hour
min1=59;
for (int s = sec1; s >= 0; s--) //starts decrementing for seconds
{
if (s == 0) //resets value of seconds to 59 for the next minute
sec1=59;
Sleep(1000); //1 second pause
}
}
}
cout << '\a'; //send system alarm upon end
msg << "Good job!" << endl << "Interval ended. Proceed to your break! See you soon!" ; //messagebox message
msg.show(); //rings alarm once timer ends
}
namespace demo //gui programming start
{
using namespace nana;
namespace fs = std::filesystem;
namespace fs_ext = nana::filesystem_ext;
class widget_show : public form //class for display of form and including widgets
{
place place_{ *this };
timer timer_;
group simple_{ *this, "<bold=true, color=0x3366ff>POMOTimer</>", true /*formated*/ }, //setting divs within form
buttons_{ simple_, "<bold=true>About</>", true },
comboxes_{ simple_, "<bold=true>SET POMOTimer</>", true },
labels_{ simple_, "Labels" },
progreses_{ simple_, "Progres bars" };
button b_n{ buttons_, ("About POMODORO") }, //setting button names
b_i{ buttons_, ("POMODORO Steps") },
b_p{ buttons_, ("Credits") },
b_s{ buttons_, ("Start POMOSession") };
combox cb_u0{ comboxes_, ("Set minutes") }, //setting comboxes names
cb_u{ comboxes_, ("Set hours") },
cb_u3{ comboxes_, ("Set seconds") };
public:
widget_show() //defining details of form
: form(API::make_center(500, 300), appear::decorate<appear::sizable>()) //making sure interface is responsive and setting dimensions
{
nana::API::track_window_size(*this, { 300,300 }, false); //minimum
this->caption(("POMOTimer v1.0")); //window title
place_.div(R"(vertical
<weight=30% min=260 <weight=10> <simples gap=3 margin=5> >
<weight=20 tab >
<tab_frame> )"); //sizing
place_["simples"] << simple_;
simple_.div("vertical all min=260 gap=3 margin=5"); //arrangement and spacing of all components
simple_["all"] << buttons_ << comboxes_ ; //setting order of widgets
_m_init_buttons(); //functions for button and combox details
_m_init_comboxs();
this->events().unload([this](const arg_unload& ei) //event generation upon clicking on cross button
{
msgbox mb(*this, ("Quit"), msgbox::yes_no); //generate messagebox with options of "yes/no" and setting window title
mb.icon(mb.icon_question) << ("Are you sure you want to exit?"); //making msgbox of type information (icon) and including msgbox message
ei.cancel = (mb() == mb.pick_no); //exit msgbox on click of no
});
place_.collocate();
};
public:
void _m_init_buttons() //button details
{
Timer t; //creation of object of Timer class
buttons_.div("buttons min=25 gap=5 margin=3"); //setting arrangement of buttons
buttons_["buttons"] << b_n << b_i << b_p << b_s; //setting button order
msgbox mb1(*this, "About POMODORO"); //creation of msgboxes for menu options, setting of type information and calling stored string data members
mb1.icon(mb1.icon_information) << t.info;
msgbox mb{ *this, "POMODORO Steps" };
mb.icon(mb.icon_information) << t.steps;
msgbox mb0{ *this, "Credits" };
mb0.icon(mb0.icon_information) << t.credits;
msgbox mb4 { *this, "POMOSession" };
b_n.events().click(mb1); //calling messageboxes upon clicking of each button
b_i.events().click(mb);
b_p.events().click(mb0);
b_s.events().click(displayTime); //calling of timer countdown once the associated button is clicked
}
void _m_init_comboxs() //comboxes details
{
comboxes_.div("buttons min=25 gap=5 margin=3"); //setting arrangement of comboxes
comboxes_["buttons"] << cb_u0 << cb_u << cb_u3; //setting order of comboxes
cb_u3.push_back(("0")); //setting drop-down options of combox for seconds
cb_u3.push_back(("1"));
cb_u3.push_back(("2"));
cb_u3.push_back(("3"));
cb_u3.push_back(("4"));
cb_u3.push_back(("5"));
cb_u3.push_back(("6"));
cb_u3.push_back(("7"));
cb_u3.push_back(("8"));
cb_u3.push_back(("9"));
cb_u3.push_back(("10"));
cb_u3.push_back(("11"));
cb_u3.push_back(("12"));
cb_u3.push_back(("13"));
cb_u3.push_back(("14"));
cb_u3.push_back(("15"));
cb_u3.push_back(("16"));
cb_u3.push_back(("17"));
cb_u3.push_back(("18"));
cb_u3.push_back(("19"));
cb_u3.push_back(("20"));
cb_u3.push_back(("21"));
cb_u3.push_back(("22"));
cb_u3.push_back(("23"));
cb_u3.push_back(("24"));
cb_u3.push_back(("25"));
cb_u3.push_back(("26"));
cb_u3.push_back(("27"));
cb_u3.push_back(("28"));
cb_u3.push_back(("29"));
cb_u3.push_back(("30"));
cb_u3.push_back(("31"));
cb_u3.push_back(("32"));
cb_u3.push_back(("33"));
cb_u3.push_back(("34"));
cb_u3.push_back(("35"));
cb_u3.push_back(("36"));
cb_u3.push_back(("37"));
cb_u3.push_back(("38"));
cb_u3.push_back(("39"));
cb_u3.push_back(("40"));
cb_u3.push_back(("41"));
cb_u3.push_back(("42"));
cb_u3.push_back(("43"));
cb_u3.push_back(("44"));
cb_u3.push_back(("45"));
cb_u3.push_back(("46"));
cb_u3.push_back(("47"));
cb_u3.push_back(("48"));
cb_u3.push_back(("49"));
cb_u3.push_back(("50"));
cb_u3.push_back(("51"));
cb_u3.push_back(("52"));
cb_u3.push_back(("53"));
cb_u3.push_back(("54"));
cb_u3.push_back(("55"));
cb_u3.push_back(("56"));
cb_u3.push_back(("57"));
cb_u3.push_back(("58"));
cb_u3.push_back(("59"));
cb_u0.push_back(("0")); //setting drop-down options of combox for minutes
cb_u0.push_back(("1"));
cb_u0.push_back(("2"));
cb_u0.push_back(("3"));
cb_u0.push_back(("4"));
cb_u0.push_back(("5"));
cb_u0.push_back(("6"));
cb_u0.push_back(("7"));
cb_u0.push_back(("8"));
cb_u0.push_back(("9"));
cb_u0.push_back(("10"));
cb_u0.push_back(("11"));
cb_u0.push_back(("12"));
cb_u0.push_back(("13"));
cb_u0.push_back(("14"));
cb_u0.push_back(("15"));
cb_u0.push_back(("16"));
cb_u0.push_back(("17"));
cb_u0.push_back(("18"));
cb_u0.push_back(("19"));
cb_u0.push_back(("20"));
cb_u0.push_back(("21"));
cb_u0.push_back(("22"));
cb_u0.push_back(("23"));
cb_u0.push_back(("24"));
cb_u0.push_back(("25"));
cb_u0.push_back(("26"));
cb_u0.push_back(("27"));
cb_u0.push_back(("28"));
cb_u0.push_back(("29"));
cb_u0.push_back(("30"));
cb_u0.push_back(("31"));
cb_u0.push_back(("32"));
cb_u0.push_back(("33"));
cb_u0.push_back(("34"));
cb_u0.push_back(("35"));
cb_u0.push_back(("36"));
cb_u0.push_back(("37"));
cb_u0.push_back(("38"));
cb_u0.push_back(("39"));
cb_u0.push_back(("40"));
cb_u0.push_back(("41"));
cb_u0.push_back(("42"));
cb_u0.push_back(("43"));
cb_u0.push_back(("44"));
cb_u0.push_back(("45"));
cb_u0.push_back(("46"));
cb_u0.push_back(("47"));
cb_u0.push_back(("48"));
cb_u0.push_back(("49"));
cb_u0.push_back(("50"));
cb_u0.push_back(("51"));
cb_u0.push_back(("52"));
cb_u0.push_back(("53"));
cb_u0.push_back(("54"));
cb_u0.push_back(("55"));
cb_u0.push_back(("56"));
cb_u0.push_back(("57"));
cb_u0.push_back(("58"));
cb_u0.push_back(("59"));
cb_u.push_back(("0")); //setting drop-down options of combox for hours
cb_u.push_back(("1"));
cb_u.push_back(("2"));
cb_u.push_back(("3"));
cb_u.push_back(("4"));
cb_u.push_back(("5"));
cb_u.push_back(("6"));
cb_u.push_back(("7"));
cb_u.push_back(("8"));
cb_u.push_back(("9"));
cb_u.push_back(("10"));
cb_u.push_back(("11"));
cb_u.push_back(("12"));
msgbox mb(*this, ("Item Selected")); //generation of messagebox upon clicking of drop down options
mb.icon(mb.icon_information); //msgbox of type information
cb_u0.events().selected([this, mb](const nana::arg_combox& acmb) mutable //content to display in msgbox upon setting minutes
{
mb << ("Minutes set to ") << acmb.widget.option();
s2 = acmb.widget.option();
mb();
//Clear the buffer, otherwise the mb shows the text generated in
//the last selected event.
mb.clear();
});
cb_u.events().selected([this, mb](const nana::arg_combox& acmb) mutable //content to display in msgbox upon setting hours
{
mb << ("Hours set to ") << acmb.widget.option();
s1 = acmb.widget.option();
mb();
mb.clear();
});
cb_u3.events().selected([this, mb](const nana::arg_combox& acmb) mutable //content to display in msgbox upon setting seconds
{
mb << ("Seconds set to ") << acmb.widget.option();
s3 = acmb.widget.option();
mb();
mb.clear();
});
}
};//end class widget_show
void go() { //function to execute all gui components
widget_show wdshow;
wdshow.show();
exec();
}
}
int main() { //main start
demo::go(); //calling function to load interface
} //end main