Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. /*
  2. Original Author: S. M. Shahriar Nirjon
  3. Last Modified by: Mohammad Saifur Rahman
  4. last modified: October 13, 2015
  5. Version: 2.0
  6. */
  7. # include "iGraphics.h"
  8. using namespace std;
  9. #include<iostream>
  10. #include<stdio.h>
  11. #include<conio.h>
  12. #include<gl\GLU.h>
  13. #include<gl\GLU.h>
  14. #include<stdio.h>
  15. #include<string.h>
  16. #define Enter 13
  17. #define Tab 9
  18. #define BackSpace 8
  19. #define Space 32
  20. int mposx, mposy, f = 0;
  21. /*
  22. function iDraw() is called again and again by the system.
  23.  
  24. */
  25. int flag = 1;
  26. //char password [50] = "Onek pera ei achi ";
  27. //char str[39] = "COde with c";
  28. char str1[40] = "VIEW BOOK LIST";
  29. char str2[40] = "ADD BOOK";
  30. char str3[40] = "ISSUE BOOK";
  31. char str4[40] = "SEARCH BOOK";
  32. char str5[40] = "DELETE BOOK";
  33. char str6[40] = "EDIT LIST";
  34. char str7[40] = "LOG OUT";
  35. int len;
  36. int findex = 0;
  37. char str[79];
  38. int i = 0;
  39. char file[10][100];
  40. int index1, index2;
  41. char username[15];
  42. char passwordd[12];
  43. int pocha = 0;
  44. void password(){
  45. if (findex == 0)
  46. {
  47.  
  48.  
  49.  
  50. printf("Enter your username:\n");
  51. scanf("%s", &username);
  52.  
  53. printf("Enter your password:\n");
  54. scanf("%s", &passwordd);
  55.  
  56. index1 = strcmp(username, "AUST");
  57. index2 = strcmp(passwordd, "123");
  58. if (index1 == 0 && index2==0)
  59.  
  60. {
  61. printf("\nWelcome.Login Success!");
  62. findex = 0;
  63.  
  64. }
  65. else {
  66. printf("\nwrong password");
  67. }
  68.  
  69. //else{
  70. //printf("\nUser doesn't exist");
  71. //}
  72.  
  73. }
  74. }
  75. /*
  76.  
  77.  
  78. void filecseRead(){
  79. {
  80.  
  81.  
  82. FILE *fp = fopen("h.txt", "r");
  83. while (fscanf(fp, "%s", &file[i]) != EOF)
  84. {
  85. printf("%s\n", file[i]);
  86. i++;
  87. }
  88. fclose(fp);
  89.  
  90. }
  91. {
  92.  
  93.  
  94. struct view_cse_book_list
  95. {
  96. int id;
  97. char book1_name[800];
  98. char writer1_name[800];
  99. int publish1_year;
  100. };
  101.  
  102. {
  103. FILE *infile;
  104. struct view_cse_book_list input;
  105.  
  106. // Open person.dat for reading
  107. infile = fopen("a.txt", "r");
  108. if (infile == NULL)
  109. {
  110. fprintf(stderr, "\nError opening file\n");
  111. exit(1);
  112. }
  113.  
  114. // read file contents till end of file
  115. while (fread(&input, sizeof(struct view_cse_book_list), 1, infile))
  116. printf("id = %d.= %s \n(%s) (%d)\n", input.id,
  117. input.book1_name, input.writer1_name, input.publish1_year);
  118.  
  119. // close file
  120. fclose(infile);
  121.  
  122.  
  123. }
  124. }
  125.  
  126. }
  127. void filephysicsread(){
  128.  
  129.  
  130. struct view_physics_book_list
  131. {
  132. int id;
  133. char book2_name[20];
  134. char writer2_name[20];
  135. int publish2_year;
  136. };
  137.  
  138.  
  139. {
  140. FILE *infile2;
  141. struct view_physics_book_list input2;
  142.  
  143. // Open person.dat for reading
  144. infile2 = fopen("a.txt", "r");
  145. if (infile2 == NULL)
  146. {
  147. fprintf(stderr, "\nError opening file\n");
  148. exit(1);
  149. }
  150.  
  151. // read file contents till end of file
  152. while (fread(&input2, sizeof(struct view_physics_book_list), 1, infile2))
  153. printf("id = %d.= %s \n(%s) (%d)\n", input2.id,
  154. input2.book2_name, input2.writer2_name, input2.publish2_year);
  155.  
  156. // close file
  157. fclose(infile2);
  158.  
  159. }
  160. }
  161. void filephysicsread(){
  162.  
  163.  
  164. // struct person with 3 fields
  165. struct view_math_book_list
  166. {
  167. int id3;
  168. char book3_name[20];
  169. char writer3_name[20];
  170. int publish3_year;
  171. };
  172.  
  173. // Driver program
  174.  
  175. {
  176. FILE *infile3;
  177. struct view_math_book_list input3;
  178.  
  179. // Open person.dat for reading
  180. infile3 = fopen("a.txt", "r");
  181. if (infile3 == NULL)
  182. {
  183. fprintf(stderr, "\nError opening file\n");
  184. exit(1);
  185. }
  186.  
  187. // read file contents till end of file
  188. while (fread(&input3, sizeof(struct view_math_book_list), 1, infile3))
  189. printf("id = %d.= %s \n(%s) (%d)\n", input3.id3,
  190. input3.book3_name, input3.writer3_name, input3.publish3_year);
  191.  
  192. // close file
  193. fclose(infile3);
  194.  
  195. }
  196. }
  197. void fileeeread(){
  198.  
  199. // struct person with 3 fields
  200. struct view_eee_book_list
  201. {
  202. int id4;
  203. char book4_name4[20];
  204. char writer4_name[20];
  205. int publish4_year;
  206. };
  207.  
  208. // Driver program
  209. int main()
  210. {
  211. FILE *infile4;
  212. struct view_eee_book_list input4;
  213.  
  214. // Open person.dat for reading
  215. infile4 = fopen("a.txt", "r");
  216. if (infile4 == NULL)
  217. {
  218. fprintf(stderr, "\nError opening file\n");
  219. exit(1);
  220. }
  221.  
  222. // read file contents till end of file
  223. while (fread(&input4, sizeof(struct view_eee_book_list), 1, infile4))
  224. printf("id = %d.= %s \n(%s) (%d)\n", input4.id4 ,
  225. input4.book4_name, input4.writer4_name, input4.publish4_year);
  226.  
  227. // close file
  228. fclose(infile4);
  229. }
  230. }
  231. */
  232.  
  233. void iDraw()
  234. {
  235. iClear();
  236. if (findex == 0)
  237. {
  238.  
  239. iRectangle(0, 0, 1000, 700);
  240. iSetColor(69, 153, 208);
  241. for (i = 0; i <= 15; i++)
  242. {
  243. if (pocha == 1){
  244. iText(10, 10, "a", GLUT_BITMAP_TIMES_ROMAN_24);
  245. username[i] = "a";
  246.  
  247. }
  248. if (pocha == 2)
  249. {
  250. iText(15, 10, "A", GLUT_BITMAP_TIMES_ROMAN_24);
  251. }
  252. }
  253. iText(50, 50, username, GLUT_BITMAP_TIMES_ROMAN_24);
  254. iText(50, 50, passwordd, GLUT_BITMAP_TIMES_ROMAN_24);
  255.  
  256.  
  257.  
  258. }
  259.  
  260.  
  261. if (findex == 0 + 1){
  262. iShowBMP(0, 0, "1.bmp");
  263.  
  264. }
  265. if (findex == 1){
  266. iShowBMP(0, 0, "Menu.bmp");
  267.  
  268. }
  269. if (findex == 1 + 1){
  270. iShowBMP(0, 0, "view.bmp");
  271. }
  272.  
  273. if (findex == 2 + 1){
  274.  
  275. iShowBMP(0, 0, "view.bmp");
  276. iSetColor(255, 255, 255);
  277. for (int j = 0, y = 650; j<i; j++, y -= 20)
  278. {
  279. iText(10, y, file[j]);
  280. }
  281. }
  282. if (findex == 3 + 1){
  283. iShowBMP(0, 0, "view.bmp");
  284. }
  285. if (findex == 4 + 1){
  286. iShowBMP(0, 0, "view.bmp");
  287. }
  288. if (findex == 5 + 1){
  289. iShowBMP(0, 0, "view.bmp");
  290. }
  291.  
  292.  
  293.  
  294.  
  295.  
  296. }
  297.  
  298.  
  299.  
  300. void iMouseMove(int mx, int my)
  301. {
  302. //place your codes here
  303. }
  304.  
  305.  
  306.  
  307. void iMouse(int button, int state, int mx, int my)
  308. {
  309. printf("%d %d\n", mx, my);
  310.  
  311. // add book
  312. if (mx >= 0 && mx <= 1000 && my >= 0 && my <= 700)
  313. {
  314. findex = 1000;
  315. }
  316. if (mx >= 144 && mx <= 392 && my >= 333 && my <= 384)
  317. {
  318. findex = 1;
  319. }
  320. if (mx >= 627 && mx <= 834 && my >= 408 && my <= 453)
  321. {
  322. findex = 2;
  323. }
  324. if (mx >= 142 && mx <= 413 && my >= 214 && my <= 258)
  325. {
  326. findex = 3;
  327. }
  328. if (mx >= 912 && mx <= 1000 && my >= 640 && my <= 700)
  329. {
  330. findex = 1000;
  331. }
  332. if (mx >= 619 && mx <= 900 && my >= 285 && my <= 335)
  333. {
  334. findex = 4;
  335. }
  336. if (mx >= 652 && mx <= 833 && my >= 154 && my <= 200)
  337. {
  338. findex = 5;
  339. }
  340.  
  341.  
  342. }
  343.  
  344.  
  345. /*
  346. iPassiveMouseMove is called to detect and use
  347. the mouse point without pressing any button
  348. */
  349. void iPassiveMouseMove(int mx, int my)
  350. {
  351.  
  352. //place your code here
  353.  
  354. mposx = mx;
  355. mposy = my;
  356. if (mx == 2){} /*Something to do with mx*/
  357. else if (my == 2){} /*Something to do with my*/
  358. }
  359. /*
  360. function iKeyboard() is called whenever the user hits a key in keyboard.
  361. key- holds the ASCII value of the key pressed.
  362. */
  363.  
  364. void iKeyboard(unsigned char key)
  365. {
  366.  
  367. if (key == 'a')
  368. pocha = 1;
  369. if (key == 'A')
  370. pocha = 2;
  371.  
  372.  
  373. }
  374.  
  375.  
  376.  
  377. //place your codes for other keys here
  378.  
  379.  
  380. /*
  381. function iSpecialKeyboard() is called whenver user hits special keys like-
  382. function keys, home, end, pg up, pg down, arraows etc. you have to use
  383. appropriate constants to detect them. A list is:
  384. GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
  385. GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
  386. GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
  387. GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
  388. */
  389. void iSpecialKeyboard(unsigned char key)
  390. {
  391.  
  392. if (key == GLUT_KEY_END)
  393. {
  394. exit(0);
  395. }
  396.  
  397. }
  398.  
  399. int main()
  400. {
  401. //password();
  402. //filephysicsRead();
  403. iInitialize(1000, 700, "Sdlab");
  404.  
  405.  
  406. return 0;
  407. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement