Turbo C++ Graphics Library Introduction In recent years people appreciate user-friendliness and speed of development of an application to efficiency which led to the making of a new kind of application development software known as RAD tools. RAD tools include languages such as Visual Basic, Delphi and so on. Due to the introduction of these RAD tools, application development using programming languages such as Turbo C++ and JAVA have become obsolete. Even though Java is used for Web-Based application development it is being replaced by other tools which achieve the same level of functionality and efficiency by providing the programmer with libraries that make it easier to develop the application. All the above technologies are concerned and limited to Windows and high-end platforms. These days nobody appreciates DOS programming because it lacks the userfriendliness that windows and other GUI based operating systems provide to the user. Also applications developed in DOS environment do not look as good as the ones developed in windows environment nor are they as user-friendly. It also seen that application development in DOS is at least 100 times more difficult that developing it in windows or some other OS by using recent tools. These recently developed tools give even more functionality to the application. But there are a few advantages in using DOS based applications which are listed as follows: They do not crash as frequently as their windows counterparts. They utilize only a minimum amount of you primary/RAM memory and the rest can be used for other purposes. The system requirements are very low for DOS-based applications. Systems running MS-DOS are always reliable and have almost negligible amount of failures DOS-Based applications also occupy only a few KB s of your hard disk space unlike windows-based applications. Of course there are few disadvantages of using DOS-based applications which I tend to overcome by using my libraries. These demerits are as follows: DOS-based applications are not user-friendly. Creating GUIs for DOS-based applications is a very strenuous and difficult job. Even if mouse support is available for DOS when windows is loaded, it is not so in the case when you have only DOS installed and no windows present in your system. Multi-Tasking is not available in DOS. A lot of skill is required to perform DOS-based application development. Need for the Turbo C++ Graphics Library At present there is no proper library provided with the either the Turbo C++ compiler or the Borland C++ compiler. All a programmer can do the provided graphics library is draw lines, rectangles and ellipses. Using such primitive functions a programmer has to hard-code a lot to generate GUIs that look at least half as good as the ones generated by Windows tools. The main aim of this graphics library is to provide additional functionalities to the programmer which will enable him/her to generate GUIs that are comparable to its windows counterpart. The usage of the functions provided in the graphics library is very simple and anyone from the novice level to the expert level can understand the programming construct to be followed. In short this graphics library serves as a RAD tool in conjunction with the Turbo C++ compiler for developing DOSbased applications. Features provided by the graphics library The Turbo C++ graphics library provides a lot of custom made objects such labels, buttons and menus that are very to create using by creating the object variable and calling a single draw() function. The graphics library also follows a strict hierarchical method of association which is described below. There is also facility provided to add your own objects which must also have the same functions as the embedded objects. The hierarchy is as follows S_Objects (provides the functionality for Simple objects) Label Button Button3d AnimeButton WinLabel WinButton LinkButton DateBox TextField RadioGroup CheckBoxGroup SelectBox ListBox ToggleButton ProgressBar LoadingBar ColorPalette C_Objects (provides the functionalities for more complex objects such as menus, menubars and panels) Menu MenuBar Panel S_Container P_Objects (provides the functionalities for pop up objects such as message boxes and right click menus) PopUpMenu InputBox MessageBox All the above mentioned objects written in bold are the class names of the respective objects specified by the graphics library. Apart from these there are other classes that are specified for special purposes. The Mouse Class – This class allows the user to enable and control the operation of the mouse hardware. It even includes functions to change the mouse pointer and control the sensitivity of the mouse. The Gui Class – This class lets the programmer to set the line, text and background colors of the objects that are going to be used. Multiple instances of this class can also be created in order to have variety of colors. But the programmer must see to that, when using multiple instances the background color specified by each Gui object must be the same or else it will result in serious graphics coloring problems. The Frame Class – This class is a container object to which a maximum of 50 complex objects specified by C_Objects can be added. The adding function is similar to that of the gridbaglayout function specified in java. The panel class is also a container object but can take only simple objects such as labels and buttons. There are other useful functions specified in the library that solve a lot of problems:restoreDefaultSettings – saves the current graph settings and restores the default settings. restoreUserSettings – restores the settings saved by restoreDefaultSettings. isOverLapped – checks if one object is overlapping another object (1–TRUE,0–FALSE). Super_save – saves the area of the screen to a file. Super_restore – restores the are of the screen with the file contents. Clear_keyboard_buffer – makes sure that no key pressed during the mouse movement is stored in the keyboard buffer. For further details on the functions provided by the library refer the header file named “gui.h”. Programming Construct to be followed The programming construct to be followed while developing applications using this graphics library is very simple to understand and if followed as specified as below then there will not be operational problems and will also be easy to debug errors ( both logical and syntactical ). The first while which is an infinite one ensures that the program is running even after the mouse-click event has occurred. The second do-while loop keeps assigning the button-click, x-co-ordinate and y-co-ordinate values of the mouse object to the pre-defined global variables B, X and Y respectively. The following B values signify the following:B=0 -> No button click event has occurred B=1 -> Left-Button-Click event has occurred B=2 -> Right-Button-Click event has occurred B=3 -> Middle-Button-Click event has occurred The button-click values (i.e. B values) are automatically set to zero after each loop so there is no need of the user to set it manually. Every function that has to perform Gui operation has to follow the programming construct as specified by below. Other functions that perform only calculations need not follow the construct. For the full operational code please refer the example files provided. #include <gui.h> …other header files required…. Gui <gui-object> Mouse <mouse-object> …other objects and variables required…. <Function> ( ) { <gui-object>.init ( ); //Must be written only once per program <mouse-object>.init ( ); //Must be written only once per program <mouse-object>.showmouseptr( ); while (1) { do { clear_keyboard_buffer(); // (Optional) <mouse-object>.getmousepos(B,X,Y); …functions that will perform an operation for every movement of the mouse (like animate functions)… } while (B==0); …functions called for every mouse-click (like the operate functions)… if ( <object-name>.mouseIn( ) ) { …Your code here… } } <gui-object>.close( ); //Must be written only once per program } Add-on Libraries DOS graphics library Apart from the library specified in the previous section, I have also created another library for the use in situations where the mouse hardware is not present. This DOS graphics library uses a custom made mouse pointer that is controlled using the numpad of the keyboard. This is very useful when the application developed is going to be run on systems without the mouse hardware or in a pure DOS environment (where the mouse hardware cannot be initialized). The programmer need not be worried about this fact because the DOS graphics library also follows the same programming construct as the previous library. All he/she has to do is to prefix a ‘D’ to the object names while declaring them. The name of the header file to be included is “dgui.h”. The following are the analogous class names in dgui.h to that in gui.h. Gui.h class name Mouse Gui S_Objects C_Objects P_Objects Frame Label Button Button3d AnimeButton WinLabel WinButton LinkButton DateBox TextField RadioGroup CheckBoxGroup SelectBox Dgui.h class name DMouse DGui DS_Objects DC_Objects DP_Objects DFrame DLabel DButton DButton3d DAnimeButton DWinLabel DWinButton DLinkButton DDateBox DTextField DRadioGroup DCheckBoxGroup DSelectBox ListBox ProgressBar LoadingBar ColorPalette Menu MenuBar Panel S_Container PopUpMenu InputBox MessageBox DListBox DProgressBar DLoadingBar DColorPalette DMenu DMenuBar DPanel DS_Container DPopUpMenu DInputBox DMessageBox *Please note that the clear_keyboard_buffer function is not specified the dos graphics library and should also not be used while developing applications using the same.* Extended Library The extended graphics library is used by including the header file “egui.h”. The objects specified are mostly going to be editors such mouse pointer editor, icon editor, fill pattern editor, image editor and so on. The main purpose of the extended graphics library is to provide tools for editing mouse cursors and other things during the running of an application. As of now only the mouse pointer editor has been completed. The rest of the editors will be completed in due course of time. Using the extended graphics library will also provide the functionalities of the basic GUI development graphics library specified by “gui.h” Advantages Easy to develop GUI based DOS applications that provide the user with all the user-friendliness he/she requires. Application can be used on machines that do not have the compiler installed. Memory utilized by the application developed is very less. Application developed using these libraries rarely enter into a deadlocked state. Skills required for using these libraries are minimal. System requirements are minimal. Applications can be developed in very less time. Applications Developed can be easily transferred by floppies or e-mail. Disadvantages Programmer must change memory model to medium. To do so option->compiler->code generation->model (medium) Does not provide multi-tasking facility. Future Developments Multi-Tasking feature to be added Network support to be added. Encryption functions to be added. More objects to be added. Editor classes are to be added. Printer feature are to be added. New types of data types are to be added. Conclusion Overall, these new graphics libraries provided can be used to generate GUIs for DOS-based applications with great ease and efficiency with minimum skill. It also decreases the time for application development by great deal of time. This library can be used by anyone with great ease and understanding.