You are on page 1of 15

Mobile keypad using c++ graphics

Mobile keypad using c++


graphics

VVIT PAL
1
Mobile keypad using c++ graphics

INTRODUCTION:

In today's digital age, mobile phones have become an integral part of our lives.
Simulating a mobile device's keypad and interface using C++ and computer graphics is a
fascinating micro project that offers an opportunity to hone your programming and
graphics design skills. This project will enable you to create a visually appealing and
interactive mobile keypad interface on your computer screen, providing users with a
familiar experience.

**Project Objectives:**

1. **Graphical User Interface:** Create an intuitive and user-friendly graphical interface


that emulates a mobile phone keypad.

2. **Keypad Design:** Design a realistic keypad with numerical buttons, navigation


keys, and other essential features found on a typical mobile phone.

3. **User Interaction:** Implement functionality that allows users to interact with the
keypad, press buttons, and simulate keypress events.

4. **Feedback and Visual Effects:** Incorporate visual feedback for button presses, such
as highlighting or changing button colors, and display characters or symbols when a
button is pressed.

5. **Navigation:** Implement a simple navigation system, enabling users to switch


between different screens or menu options.

6. **Error Handling:** Create error handling mechanisms for scenarios like incorrect pin
entries or menu selections.

7. **Customization:** Offer options for customization, such as changing keypad themes,


background images, or ringtones.

**Skills You'll Develop:**

- **C++ Programming:** Enhance your C++ programming skills by creating the core
functionality for the mobile keypad simulator.

- **Computer Graphics:** Learn how to use graphics libraries (e.g., OpenGL and GLUT)
to create the graphical user interface and visualize the keypad.

VVIT PAL
2
Mobile keypad using c++ graphics

- **User Interface Design:** Develop user interface design skills, focusing on layout,
buttons, fonts, and overall aesthetics.

- **User Interaction:** Implement event handling to enable users to interact with the
keypad and navigate through screens.

- **Error Handling:** Incorporate error-checking and validation to enhance the user


experience.

**Outcome:**

By the end of this micro project, you will have a fully functional keypad mobile simulator
running on your computer. This project will give you practical experience in
programming and computer graphics while allowing you to explore user interface design
principles. Additionally, you'll gain a deeper understanding of how real mobile devices
work at the software and interaction levels.

VVIT PAL
3
Mobile keypad using c++ graphics

 Source code
// C program for the
// above approach
#include <conio.h>
#include <graphics.h>
#include <stdio.h>

// Used Function Declaration


void menu_key();
void others();
void key();
void screen();

// Driver Code
void main()
{
int gd = DETECT, gm;

// Initialize of gdriver with


// DETECT macros
initgraph(&gd, &gm,
"C:\\turboc3\\bgi");

// Set Background Color As


// Darkgray
setfillstyle(SOLID_FILL,
DARKGRAY);
floodfill(1, 1, 15);

VVIT PAL
4
Mobile keypad using c++ graphics

// Main Outline
rectangle(800, 100, 1100, 730);

// Set Phone Color AS Black


setfillstyle(SOLID_FILL, BLACK);
floodfill(805, 105, 15);

// Calling screen() Function


screen();

// Calling others() Function


others();

// Calling menu_key() Function


menu_key();

// Calling key() Function


key();

// Holding The Screen For


// A While
getch();

// Close the initialized


// gdriver
closegraph();
}

VVIT PAL
5
Mobile keypad using c++ graphics

void screen()
{
// Screen Outline
rectangle(830, 130, 1070, 370);

// Screen Saver Indian Flag


rectangle(900, 170, 1000, 230);
line(900, 190, 1000, 190);
setfillstyle(SOLID_FILL,
LIGHTRED);
floodfill(905, 175, 15);
circle(950, 200, 10);
setfillstyle(SOLID_FILL, BLUE);
floodfill(955, 205, 15);
line(900, 190, 1000, 190);
line(900, 210, 1000, 210);
setfillstyle(SOLID_FILL, WHITE);
floodfill(905, 195, 15);
floodfill(995, 195, 15);
line(900, 210, 1000, 210);
setfillstyle(SOLID_FILL, GREEN);
floodfill(905, 215, 15);
line(900, 170, 900, 320);
rectangle(880, 320, 920, 330);
setfillstyle(SOLID_FILL, WHITE);
floodfill(885, 325, 15);
}

VVIT PAL
6
Mobile keypad using c++ graphics

void key()
{
int l = 820, t = 500, i = 1;

// Implementing 12 Others Key


// and
// Numbering Them
while (t <= 650) {
while (l <= 1020) {
rectangle(l, t, l + 70,
t + 40);
if (i == 1) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"1 ., ?");
}
else if (i == 2) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"2 ABC");
}
else if (i == 3) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"3 DEF");
}
else if (i == 4) {

VVIT PAL
7
Mobile keypad using c++ graphics

settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"4 GHI");
}
else if (i == 5) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"5 JKL");
}
else if (i == 6) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"6 MNO");
}
else if (i == 7) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"7PQRS");
}
else if (i == 8) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"8 TUV");
}
else if (i == 9) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"9WXYZ");

VVIT PAL
8
Mobile keypad using c++ graphics

}
else if (i == 10) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"* +");
}
else if (i == 11) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"0 _");
}
else if (i == 12) {
settextstyle(8, 0, 2);
outtextxy(l + 5, t + 5,
"# x");
}
i++;
l = l + 100;
}
t = t + 50;
l = 820;
}
}

void others()
{
setfillstyle(SOLID_FILL,
WHITE);

VVIT PAL
9
Mobile keypad using c++ graphics

// Implement Microphone
circle(900, 710, 5);
floodfill(902, 712, 15);

// Implement Selfie Camera


circle(1030, 115, 8);
circle(1030, 115, 4);
floodfill(1031, 116, 15);

// Implement Speaker
rectangle(900, 110, 1000, 120);
setfillstyle(XHATCH_FILL, WHITE);
floodfill(905, 115, 15);

// Implement Mobile Brand Name


settextstyle(8, 0, 3);
outtextxy(895, 375, "SOUNETRA");

// Division Between
// Screen and Keys
line(800, 400, 1100, 400);
}

void menu_key()
{
setfillstyle(SOLID_FILL, WHITE);

VVIT PAL
10
Mobile keypad using c++ graphics

// Menu Key
rectangle(930, 420, 980, 470);
rectangle(920, 410, 990, 480);
settextstyle(10, 0, 3);
outtextxy(940, 430, "OK");
floodfill(925, 415, 15);

// Left Upper Bottom


rectangle(820, 410, 890, 440);
rectangle(830, 420, 880, 430);
floodfill(835, 425, 15);

// Right Upper Bottom


rectangle(1020, 410, 1090, 440);
rectangle(1030, 420, 1080, 430);
floodfill(1035, 425, 15);

// Left Lower Bottom


rectangle(820, 450, 890, 480);
setfillstyle(SOLID_FILL, GREEN);
floodfill(825, 455, 15);

// Right Lower Bottom


rectangle(1020, 450, 1090, 480);
setfillstyle(SOLID_FILL, RED);
floodfill(1025, 455, 15);
}

VVIT PAL
11
Mobile keypad using c++ graphics

Output

VVIT PAL
12
Mobile keypad using c++ graphics

VVIT PAL
13
Mobile keypad using c++ graphics

Conclusion

The "Design and Implement a Keypad Mobile Simulator Using C++ and Computer Graphics"
micro project has been a stimulating journey that has allowed us to explore the world of
programming, computer graphics, and user interface design. Throughout this project, we set out
to create a simulated mobile phone keypad with an intuitive user interface, providing users with a
familiar and interactive experience.

In summary, we achieved the following key objectives:

1. **Graphical User Interface:** We successfully designed and implemented an aesthetically


pleasing and user-friendly graphical interface that replicates a mobile phone keypad.

2. **Keypad Design:** The project included the creation of a realistic keypad, complete with
numerical buttons, navigation keys, and other essential features typically found on a mobile
device.

3. **User Interaction:** Users were able to interact with the keypad, simulate keypress events,
and receive visual feedback upon button presses.

4. **Navigation:** We implemented a basic navigation system, enabling users to navigate


between screens or menu options, enhancing the user experience.

5. **Error Handling:** Error handling mechanisms were included to address scenarios such as
incorrect pin entries or menu selections, making the simulator more realistic.

6. **Customization:** The project provided options for customization, allowing users to


personalize keypad themes, background images, and ringtones.

Throughout this micro project, we honed a diverse set of skills, including:

VVIT PAL
14
Mobile keypad using c++ graphics

- **C++ Programming:** We enhanced our C++ programming skills by developing the core
functionality for the keypad simulator. We learned to structure the code effectively and manage
data and user interactions.

- **Computer Graphics:** The utilization of graphics libraries (e.g., OpenGL and GLUT)
introduced us to the world of computer graphics, allowing us to create the visual aspects of the
keypad mobile simulator.

- **User Interface Design:** We explored user interface design principles, focusing on layout,
button design, font selection, and overall aesthetics. This skill will be valuable for future projects
involving graphical user interfaces.

- **User Interaction:** Event handling was implemented to enable users to interact with the
keypad, fostering an understanding of how software interacts with the user.

- **Error Handling:** We incorporated error-checking and validation to improve the user


experience, addressing potential issues that users may encounter.

The project not only met its primary objectives but also offered an opportunity for creativity and
personalization. Additionally, it allowed for further exploration and expansion, which can include
the addition of advanced features, further customization, and the introduction of more
sophisticated mobile phone functions.

VVIT PAL
15

You might also like