Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Original Author: S. M. Shahriar Nirjon
- Last Modified by: Mohammad Saifur Rahman
- last modified: October 13, 2015
- Version: 2.0
- */
- # include "iGraphics.h"
- using namespace std;
- #include<iostream>
- #include<stdio.h>
- #include<conio.h>
- #include<gl\GLU.h>
- #include<gl\GLU.h>
- #include<stdio.h>
- #include<string.h>
- #define Enter 13
- #define Tab 9
- #define BackSpace 8
- #define Space 32
- int mposx, mposy, f = 0;
- /*
- function iDraw() is called again and again by the system.
- */
- int flag = 1;
- //char password [50] = "Onek pera ei achi ";
- //char str[39] = "COde with c";
- char str1[40] = "VIEW BOOK LIST";
- char str2[40] = "ADD BOOK";
- char str3[40] = "ISSUE BOOK";
- char str4[40] = "SEARCH BOOK";
- char str5[40] = "DELETE BOOK";
- char str6[40] = "EDIT LIST";
- char str7[40] = "LOG OUT";
- int len;
- int findex = 0;
- char str[79];
- int i = 0;
- char file[10][100];
- int index1, index2;
- char username[15];
- char passwordd[12];
- int pocha = 0;
- void password(){
- if (findex == 0)
- {
- printf("Enter your username:\n");
- scanf("%s", &username);
- printf("Enter your password:\n");
- scanf("%s", &passwordd);
- index1 = strcmp(username, "AUST");
- index2 = strcmp(passwordd, "123");
- if (index1 == 0 && index2==0)
- {
- printf("\nWelcome.Login Success!");
- findex = 0;
- }
- else {
- printf("\nwrong password");
- }
- //else{
- //printf("\nUser doesn't exist");
- //}
- }
- }
- /*
- void filecseRead(){
- {
- FILE *fp = fopen("h.txt", "r");
- while (fscanf(fp, "%s", &file[i]) != EOF)
- {
- printf("%s\n", file[i]);
- i++;
- }
- fclose(fp);
- }
- {
- struct view_cse_book_list
- {
- int id;
- char book1_name[800];
- char writer1_name[800];
- int publish1_year;
- };
- {
- FILE *infile;
- struct view_cse_book_list input;
- // Open person.dat for reading
- infile = fopen("a.txt", "r");
- if (infile == NULL)
- {
- fprintf(stderr, "\nError opening file\n");
- exit(1);
- }
- // read file contents till end of file
- while (fread(&input, sizeof(struct view_cse_book_list), 1, infile))
- printf("id = %d.= %s \n(%s) (%d)\n", input.id,
- input.book1_name, input.writer1_name, input.publish1_year);
- // close file
- fclose(infile);
- }
- }
- }
- void filephysicsread(){
- struct view_physics_book_list
- {
- int id;
- char book2_name[20];
- char writer2_name[20];
- int publish2_year;
- };
- {
- FILE *infile2;
- struct view_physics_book_list input2;
- // Open person.dat for reading
- infile2 = fopen("a.txt", "r");
- if (infile2 == NULL)
- {
- fprintf(stderr, "\nError opening file\n");
- exit(1);
- }
- // read file contents till end of file
- while (fread(&input2, sizeof(struct view_physics_book_list), 1, infile2))
- printf("id = %d.= %s \n(%s) (%d)\n", input2.id,
- input2.book2_name, input2.writer2_name, input2.publish2_year);
- // close file
- fclose(infile2);
- }
- }
- void filephysicsread(){
- // struct person with 3 fields
- struct view_math_book_list
- {
- int id3;
- char book3_name[20];
- char writer3_name[20];
- int publish3_year;
- };
- // Driver program
- {
- FILE *infile3;
- struct view_math_book_list input3;
- // Open person.dat for reading
- infile3 = fopen("a.txt", "r");
- if (infile3 == NULL)
- {
- fprintf(stderr, "\nError opening file\n");
- exit(1);
- }
- // read file contents till end of file
- while (fread(&input3, sizeof(struct view_math_book_list), 1, infile3))
- printf("id = %d.= %s \n(%s) (%d)\n", input3.id3,
- input3.book3_name, input3.writer3_name, input3.publish3_year);
- // close file
- fclose(infile3);
- }
- }
- void fileeeread(){
- // struct person with 3 fields
- struct view_eee_book_list
- {
- int id4;
- char book4_name4[20];
- char writer4_name[20];
- int publish4_year;
- };
- // Driver program
- int main()
- {
- FILE *infile4;
- struct view_eee_book_list input4;
- // Open person.dat for reading
- infile4 = fopen("a.txt", "r");
- if (infile4 == NULL)
- {
- fprintf(stderr, "\nError opening file\n");
- exit(1);
- }
- // read file contents till end of file
- while (fread(&input4, sizeof(struct view_eee_book_list), 1, infile4))
- printf("id = %d.= %s \n(%s) (%d)\n", input4.id4 ,
- input4.book4_name, input4.writer4_name, input4.publish4_year);
- // close file
- fclose(infile4);
- }
- }
- */
- void iDraw()
- {
- iClear();
- if (findex == 0)
- {
- iRectangle(0, 0, 1000, 700);
- iSetColor(69, 153, 208);
- for (i = 0; i <= 15; i++)
- {
- if (pocha == 1){
- iText(10, 10, "a", GLUT_BITMAP_TIMES_ROMAN_24);
- username[i] = "a";
- }
- if (pocha == 2)
- {
- iText(15, 10, "A", GLUT_BITMAP_TIMES_ROMAN_24);
- }
- }
- iText(50, 50, username, GLUT_BITMAP_TIMES_ROMAN_24);
- iText(50, 50, passwordd, GLUT_BITMAP_TIMES_ROMAN_24);
- }
- if (findex == 0 + 1){
- iShowBMP(0, 0, "1.bmp");
- }
- if (findex == 1){
- iShowBMP(0, 0, "Menu.bmp");
- }
- if (findex == 1 + 1){
- iShowBMP(0, 0, "view.bmp");
- }
- if (findex == 2 + 1){
- iShowBMP(0, 0, "view.bmp");
- iSetColor(255, 255, 255);
- for (int j = 0, y = 650; j<i; j++, y -= 20)
- {
- iText(10, y, file[j]);
- }
- }
- if (findex == 3 + 1){
- iShowBMP(0, 0, "view.bmp");
- }
- if (findex == 4 + 1){
- iShowBMP(0, 0, "view.bmp");
- }
- if (findex == 5 + 1){
- iShowBMP(0, 0, "view.bmp");
- }
- }
- void iMouseMove(int mx, int my)
- {
- //place your codes here
- }
- void iMouse(int button, int state, int mx, int my)
- {
- printf("%d %d\n", mx, my);
- // add book
- if (mx >= 0 && mx <= 1000 && my >= 0 && my <= 700)
- {
- findex = 1000;
- }
- if (mx >= 144 && mx <= 392 && my >= 333 && my <= 384)
- {
- findex = 1;
- }
- if (mx >= 627 && mx <= 834 && my >= 408 && my <= 453)
- {
- findex = 2;
- }
- if (mx >= 142 && mx <= 413 && my >= 214 && my <= 258)
- {
- findex = 3;
- }
- if (mx >= 912 && mx <= 1000 && my >= 640 && my <= 700)
- {
- findex = 1000;
- }
- if (mx >= 619 && mx <= 900 && my >= 285 && my <= 335)
- {
- findex = 4;
- }
- if (mx >= 652 && mx <= 833 && my >= 154 && my <= 200)
- {
- findex = 5;
- }
- }
- /*
- iPassiveMouseMove is called to detect and use
- the mouse point without pressing any button
- */
- void iPassiveMouseMove(int mx, int my)
- {
- //place your code here
- mposx = mx;
- mposy = my;
- if (mx == 2){} /*Something to do with mx*/
- else if (my == 2){} /*Something to do with my*/
- }
- /*
- function iKeyboard() is called whenever the user hits a key in keyboard.
- key- holds the ASCII value of the key pressed.
- */
- void iKeyboard(unsigned char key)
- {
- if (key == 'a')
- pocha = 1;
- if (key == 'A')
- pocha = 2;
- }
- //place your codes for other keys here
- /*
- function iSpecialKeyboard() is called whenver user hits special keys like-
- function keys, home, end, pg up, pg down, arraows etc. you have to use
- appropriate constants to detect them. A list is:
- GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
- GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
- GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
- GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
- */
- void iSpecialKeyboard(unsigned char key)
- {
- if (key == GLUT_KEY_END)
- {
- exit(0);
- }
- }
- int main()
- {
- //password();
- //filephysicsRead();
- iInitialize(1000, 700, "Sdlab");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement