-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
155 lines (126 loc) · 4.5 KB
/
main.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
// generated by Fast Light User Interface Designer (fluid) version 1.0107
/******************************************
Mobarak Hosen Shakil
ICT, Islamic University
ID: mhiceiuk(all), 29698(LOJ)
E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
Blog: https://iuconvergent.wordpress.com
*******************************************/
#include "main.h" /// custom header file
#include "SystemAnalyzer.h" /// custom header file
#include <iostream>
#include <fstream>
#include <string>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Text_Display.H>
using namespace std;
int minWidth = 650, minHeight = 450; /// Application Window Size
Fl_Double_Window *window_main=(Fl_Double_Window *)0;
Fl_Button *btnTest=(Fl_Button *)0;
Fl_Return_Button *btnClose=(Fl_Return_Button *)0;
/** Method to create an object of
SystemAnalyzer Class to call
each method and store information
into text files
**/
void GenarateInformation()
{
SystemAnalyzer sysinfo;
sysinfo.GetCPUInfo();
sysinfo.GetDeviceInfo();
sysinfo.GetGPUInfo();
sysinfo.GetHDDInfo();
sysinfo.GetMemInfo();
}
/** Custom Method to load
information using text buffer
and display in monitor
**/
void LoadInformation(char *File)
{
Fl_Text_Buffer *buff = new Fl_Text_Buffer();
Fl_Text_Display *disp = new Fl_Text_Display(20, 35, 580, 350);
disp->buffer(buff);
buff->loadfile(File);
}
void SetWaterMark()
{
Fl_Box *box = new Fl_Box(0, minHeight-30,330,20,"PC i NooB ~ https://github.com/imshakil/PCiNooB");
box->labelcolor(FL_DARK_CYAN);
}
/** Button callback to display new window
with Tabs & specific Device Information.
Created an object of SystemAnalyzer class
to call each method
**/
void bt_callback(Fl_Widget*, void* userdata) {
if(userdata == "test") {
GenarateInformation(); /// Stored Information in text files.
this_thread::sleep_for(chrono::microseconds(2000));
Fl_Window* adw = new Fl_Window (minWidth, minHeight, "PCiNooB - Hardware Information"); /// Added Window
adw->align(FL_ALIGN_CENTER);
Fl_Tabs *tabs = new Fl_Tabs(10,0,600,400);
tabs->selection_color(FL_DARK3);
{
Fl_Group *grp0 = new Fl_Group(20, 30, 280, 450, "Device");
{
LoadInformation("Device.info"); /// loaded information from text file
}
grp0->end(); /// tabs1 ended here
Fl_Group *grp1 = new Fl_Group(20,30,280,450,"CPU Information");
{
LoadInformation("CPU.info"); /// loaded information from text file
}
grp1->end(); /// tabs2 ended here
Fl_Group *grp2 = new Fl_Group(20,30,280,450,"HDD Information");
{
LoadInformation("HardDisk.info"); /// loaded information from text file
}
grp2->end(); /// tabs3 ended here
Fl_Group *grp3 = new Fl_Group(20,30,280,450,"Memory Information");
{
LoadInformation("Memory.info"); /// loaded information from text file
}
grp3->end(); /// tabs4 ended here
Fl_Group *grp4 = new Fl_Group(20,30,280,450,"GPU Information");
{
LoadInformation("GPU.info"); ///loaded information from text file
}
grp4->end();
}
tabs->end(); /// tabs ended here
SetWaterMark(); /// my github link
adw->show(); /// Display new Window with list of tabs
}
else if (userdata == "close")
exit(0); /// close program with exit button
}
/** Main Function of this Application**/
int main(int argc, char **argv) {
Fl_Double_Window* w;
{
Fl_Double_Window* o = window_main = new Fl_Double_Window(minWidth, minHeight, "PCiNooB - PC Configuration");
w = o;
o->align(FL_ALIGN_CENTER);
{
Fl_Box *box = new Fl_Box(minWidth/2-130,40,260,100,"PC i NooB");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);
}
{ Fl_Button* o = btnTest = new Fl_Button(minWidth/2 - 80, minHeight/2-40, 160, 40, "Get PC Specification"); /// centralized button in window
o->callback((Fl_Callback*)bt_callback, (void*)("test"));
}
{ Fl_Return_Button* o = btnClose = new Fl_Return_Button(minWidth/2-50, minHeight/2+20, 100, 40, "Exit"); /// centralized button in window
o->callback((Fl_Callback*)bt_callback, (void*)("close"));
}
{
SetWaterMark();
}
o->end();
}
w->show(argc, argv);
return Fl::run();
}