Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / Win32

RAD C++ Integrated Development Environment

4.34/5 (27 votes)
7 Jun 2010CPOL3 min read 1   3.4K  
RAD Tool for C++ Developers, Code Generator

Project Examples are included in the ZIP package in folder 'projects'

RAD Studio Screenshot

Introduction

RAD Studio (aka RAD C++ IDE) is a tool designed specifically to speed up the development process without the hassle of running a heavy weight Integrated Development Environment. RAD Studio concentrates on highly increased level of ease, by providing an in-place GUI Designer as well as event handlers attachment within the IDE. It also lessens the burden of writing event handlers for a range of controls, from normal buttons to very sophisticated Grid controls. This project was originally designed for use with the gcc-mingw compiler. It is completely based on RAD C++ GUI Library which has also been ported to Microsoft Visual C++.

Background

The basic idea behind RAD Studio was to provide a HIGHLY INCREASED LEVEL OF EASE for C++ developers. The code produced by RAD Studio is compilable with DEV C++ without any problem, if v1.2.4 radc++.h and libradc++.a are present in the dev c++ installation folder.

Using the code

If you start by reading the source code you will likely get lost, because it depends heavily on the RAD C++ GUI Library itself. It is much easier to examine an application. If anyone is interested in reviewing the code, please feel free to ask questions wherever needed.

The backbone of RADStudio is the RAD C++ GUI Library, of course, but the files denv.h, dform.h, and dcontrol.h are very good examples of how to create your own dialog designer which can be used in your commercial applications as well.

The code that RADStudio produces is plain C-style code that is easy for a moderate level C developer to understand, since RAD C++ Library itself concentrates upon ease of use. Here is a small example of a Dialog/Form designed in RADStudio and then code exported as custom framework:

Screenshot of a simple form created in RAD Studio

//Header file for Form1 - Form1.h
FormProcedure CForm1_Procedure(FormProcArgs);

class CForm1 : public Form {
    public:
        Button Button20;
        TextBox TextBox21;

        //constructor
        CForm1();

        //Form events
        void onClose(CForm1 &me);
        void onFocus(CForm1 &me);
        void onLeftClick(CForm1 &me, int mouseX, int mouseY);
        void onLoad(CForm1 &me);
        void onMouseMove(CForm1 &me, int mouseX, int mouseY);
        void onRefresh(CForm1 &me);
        void onResize(CForm1 &me, int newWidth, int newHeight);
        void onRightClick(CForm1 &me, int mouseX, int mouseY);

        //Controls' events
        void Button20_onClick(CForm1 &parent,Button &me);
        void TextBox21_onChange(CForm1 &parent, TextBox &me, String newText);
};
//And corresponding cpp file for Form1 - Form1.cpp
CForm1::CForm1() : Form("Form 1", 95, 127, 400, 210, RCP_SIMPLE,
                   True, True, False, False, True, 
                   _window(HWND_DESKTOP),False,0) {
    Button20.create("Button 20", AUTO_ID, 238, 98, 100, 25, 
                    *this,True,True,False,False);
    TextBox21.create("TextBox 21", AUTO_ID, 28, 98, 200, 25, 
                    *this,True,True,False,False,WS_EX_CLIENTEDGE);
    this->procedure=CForm1_Procedure;
    SetWindowLong(hwnd,GWL_USERDATA,(LONG)this);
    this->onLoad(*this);
}

FormProcedure CForm1_Procedure(FormProcArgs) {
    CForm1 *FRM = reinterpret_cast <cform1 /> (GetWindowLong(hwnd,GWL_USERDATA));
    ON_COMMAND_BY(FRM->Button20)  FRM->Button20_onClick(*FRM,FRM->Button20);
    ON_TEXT_CHANGED(FRM->TextBox21) FRM->TextBox21_onChange(*FRM, 
                    FRM->TextBox21,FRM->TextBox21.getText());
    ON_CLOSE() FRM->onClose(*FRM);
    ON_FOCUS() FRM->onFocus(*FRM);
    ON_LEFT_CLICK() FRM->onLeftClick(*FRM,_xmouse,_ymouse);
    ON_MOUSEMOVE() FRM->onMouseMove(*FRM,_xmouse,_ymouse);
    ON_PAINT() FRM->onRefresh(*FRM);
    ON_RESIZE() FRM->onResize(*FRM,FRM->getWidth(),FRM->getHeight());
    ON_RIGHT_CLICK() FRM->onRightClick(*FRM,_xmouse,_ymouse);
    return 0;
}

/* implementation of event handlers and developer's code */
void CForm1::Button20_onClick(CForm1 &parent,Button &me){
/* Code when button is clicked. */
}
void CForm1::TextBox21_onChange(CForm1 &parent, TextBox &me, String newText){
/* Code when text is changed. */
}
/* implementation of event handlers and developer's code */
void CForm1::onClose(CForm1 &me) {
/* [X] Code when form is closed . */
Application.close(); //remove this line if it is not main form of application
}
void CForm1::onFocus(CForm1 &me) {
/* When form receives focus */
}
void CForm1::onLeftClick(CForm1 &me, int mouseX, int mouseY) {
/* When left mouse button is clicked */
}
void CForm1::onLoad(CForm1 &me) {
/* Code when for is very first time loaded. */
}
void CForm1::onMouseMove(CForm1 &me, int mouseX, int mouseY) {
/* When mouse cursor moves over surface of form */
}
void CForm1::onRefresh(CForm1 &me) {
/* When surface of form is redrawn */
}
void CForm1::onResize(CForm1 &me, int newWidth, int newHeight) {
/* Code when form is resized. */
}
void CForm1::onRightClick(CForm1 &me, int mouseX, int mouseY) {
/* When right mouse button is clicked */
}
</cform1 />
//Main program file
#define PROJECT_NAME "RAD C++ Studio Project"
#include <radc++.h />

enum __BOOL { False=0, True=1 };//IDE specific

/* Globals go here which are accessible throughout application code */

#include "Form1.h"

CForm1 Form1;

#include "Form1.cpp"

rad_main()
rad_end()
</radc++.h></radc++.h />

Compiling RAD Studio generated Code

RAD Studio is not integrated with any compiler yet, but the code it produces does compile. Please first obtain a copy of DEV C++ from www.bloodshed.net and install it. Then obtain the RAD C++ GUI Library 1.2.4 DevPak from radcpp.com's main page and install that too.

Once both are installed, start RAD C++ and open a GUI project you saved. Export your project using the menus Export | Framework Classes, select a folder to write project file and code files to, and hit Ok. Now open RADCPP_Project.dev, compile and run, and enjoy the simplicity.

Point of Interest

RAD Studio is continuously being developed and enhanced. It is being made compatible with additional c++ compilers, but for now the code it generates is exactly what it is built upon (i.e. rad c++ gui library). The library behind it is also being updated from time to time and a port to X11-Linux environment as well as Mac OSX are planned. We hope to finally have a free, full-fledged IDE for C++ developers to develop GUI applciations rapidly and cross-platform.

Important

RAD Studio is still a work in progress. WHY? because I have been concentrating on completing the RAD C++ GUI Library. Some additional effort is needed to make it full-fledged IDE. In general it seems to be stable, but if it crashes, please notify me by posting message to this article so that I can fix it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)