Click here to Skip to main content
15,861,168 members
Articles / Desktop Programming / MFC

Getting Started With Ultimate++

Rate me:
Please Sign up or sign in to vote.
4.72/5 (43 votes)
6 Nov 20066 min read 167.3K   1.4K   68   29
A beginner's tutorial: Using Ultimate++ to quickly create cross-platform GUI applications
In this tutorial, you will learn to make a simple shopping list which will show how easy it is to create applications with the Ultimate++ toolkit.

Introduction

When it comes to creating applications, a number of solutions exist - each with advantages and disadvantages. Cross-platform toolkits have become popular due to their ease of use and portability. The purpose of this tutorial is to show how easy it is to create applications with the Ultimate++ toolkit. We will be making a simple shopping list.

What is Ultimate++?

  1. A cross-platform graphical widget toolkit for the rapid development of GUI programs.
  2. A set of C++ (and U++) libraries (called packages in Ultimate++):
    • "Core" is the base for all other Ultimate++ libraries
    • "CtrlCore" - a base for widgets (or controls)
    • "CtrlLib" - actual widgets (or controls)
    • Other libraries
  3. An IDE called TheIDE.

Ultimate++ puts the focus on the programmer, making it as easy as possible to create GUI applications.

Why Use Ultimate++?

  • It is simple, mature, and powerful.
  • It is free and open source software, released under a mostly BSD license.
  • It is being actively developed. Questions are promptly answered on the site's forums.
  • It runs (and creates applications that run) on Windows, Linux, and FreeBSD. WinCE and MacOS support is planned.
  • Code is portable from one platform to the next.
  • Many advanced features are built-in (SQL, XML, etc.).

Installing Ultimate++

Installation is very simple:

  • Download the latest version of the toolkit (Ultimate++ 605 with MinGW) from SourceForge.
  • Double click the file you just downloaded to begin installation. Leave the install path C:\upp and click install.
  • Read and accept the license agreement, then read the information about compilers. For this tutorial, we will just use the included MinGW.
  • Choose your application directory. It's fine to leave it as C:\MyApps.
  • The default settings should be sufficient. Click OK.

That's it! Wasn't that easy?

Creating a New Project

When you launch TheIDE, you will be prompted by the "Select main package" dialog. Assemblies group projects together - after you finish this tutorial, you should look through all the examples and reference applications provided. They have a wealth of information. You want to select the MyApps assembly and click the "New Package" button.

Select Main Package

Choose a name for your application. We will use SimpleDemo. Then select the template "CtrlLib application with main window".

Create New Package

Click the "Create" button at the bottom. TheIDE's main interface will now open. Two important sections exist at the top left of the screen:

IDE Files

  1. These are the Ultimate++ packages that are needed to compile your program.
  2. These are your package's files. The ones there now were created automatically.

Let's take a look at the code that was created automatically for you:

SimpleDemo.h

C++
#ifndef _SimpleDemo_SimpleDemo_h
#define _SimpleDemo_SimpleDemo_h

#include <CtrlLib/CtrlLib.h>

#define LAYOUTFILE <SimpleDemo/SimpleDemo.lay>
#include <CtrlCore/lay.h>

class SimpleDemo : public WithSimpleDemoLayout<TopWindow> {
public:
    typedef SimpleDemo CLASSNAME;
    SimpleDemo();
};

#endif

main.cpp

C++
#include "SimpleDemo.h"

SimpleDemo::SimpleDemo()
{
    CtrlLayout(*this, "Window title");
}

GUI_APP_MAIN
{
    SimpleDemo().Run();
}

SimpleDemo.lay

This is a layout file - it allows us to visually place widgets into our program. Clicking the filename opens the Layout Designer on the right.

Trying It Out

First Build Screenshot

Believe it or not, we already have a working application! It doesn't do much yet, but notice how Ultimate++ has taken care of all the tedious Windows API stuff for us. Want to try it out? Just press Ctrl-F5. (You can also click the Debug menu and select Execute). This will build the application (with debugging info) and run it.

We have a plain window with a default title. We will need to change that. We also have a close button in the corner - we probably want to add minimize and maximize buttons. Notice that the window is not resizeable.

Note: The first build is always the slowest. The Ultimate++ library must be compiled on the first run, but it is cached for later runs. TheIDE uses Blitz technology to speed up compiles on subsequent runs. (Try it! Make a trivial change-like adding a newline to main.cpp. Press Ctrl-F5 again and see how much faster it compiles.) Users have also reported that using Microsoft's Visual C++ Express compiler is faster and creates a smaller executable.

Making Our Application

We are going to make a simple shopping list application.

Setting Up the Layout

Click on the file, SimpleDemo.lay to open the layout designer. Drag the corner of the box to make our layout a bit larger. You can right-click within the layout to add new widgets.
Add a static text widget. We will use this as a heading for our application. Notice the properties that appear to the left of the layout area.

Layout Designer Properties

Set a name for the widget. It is helpful to use prefixes to distinguish what the widget is - I chose txtTitle. Set the text to "Shopping List", center the text, and set the font to 20pt. Create the following widgets:

  • Label lblItem with label "Item"
  • EditString strItem
  • Button btnAdd with label "Add"
  • ArrayCtrl arrList

Arrange the widgets so it looks like the following picture:

The Final Layout

Try compiling it again (Ctrl-F5). Our program is starting to shape up.

Making it Do Something

Let's add some functionality. We need to write a function that adds an item to our list when we push the button. Add the following to the class definition in SimpleDemo.h:

C++
void AddItem();

Now we need to implement this. Go to main.cpp and begin typing:

C++
void SimpleDemo::

Notice a box pops up with code suggestions. This feature is called Assist++, and it can be accessed anytime by pressing Ctrl-Space.

Assist++

Write the rest of the AddItem() function:

C++
void SimpleDemo::AddItem()
{
    // The ~ operator calls the object's GetData() function
    arrList.Add(~strItem);
    strItem <<= Null;    // Manually clear the item
}

Let's give the list a column title and connect the button to our new function. Add this to SimpleDemo::SimpleDemo():

C++
 arrList.AddColumn("Item");    // Add a column titled "Item"
 arrList.Removing();        // Gives us a right-click menu to delete rows
 btnAdd <<= THISBACK(AddItem);
// Uses a callback to link the button to the function

Compile again (Ctrl-F5) to see the results.

Making It Do Just a Little More

Right now, our application does everything we need it to - simply keep up with items for a shopping list. But to show how easy certain things are in Ultimate++, let's go a little farther.
Change the window title by modifying the first line in SimpleDemo::SimpleDemo():

C++
CtrlLayout(*this, "Shopping List");

Add the following line right after the previous line:

C++
Sizeable().Zoomable();

That adds minimize and maximize buttons to the title bar as well as allows you to resize the window.

Final Code

SimpleDemo.h

C++
#ifndef _SimpleDemo_SimpleDemo_h
#define _SimpleDemo_SimpleDemo_h

#include <CtrlLib/CtrlLib.h>

#define LAYOUTFILE <SimpleDemo/SimpleDemo.lay>
#include <CtrlCore/lay.h>

class SimpleDemo : public WithSimpleDemoLayout<TopWindow> {
    void AddItem();
public:
    typedef SimpleDemo CLASSNAME;
    SimpleDemo();
};

#endif

main.cpp

C++
#include "SimpleDemo.h"

SimpleDemo::SimpleDemo()
{
    CtrlLayout(*this, "Shopping List");
    Sizeable().Zoomable();
    arrList.AddColumn("Item");    // Add a column titled "Item"
    arrList.Removing();  // Gives us a right-click menu to delete rows
    btnAdd <<= THISBACK(AddItem);
    // Uses a callback to link the button to the function
}

void SimpleDemo::AddItem()
{
    // The ~ operator calls the object's GetData() function
    arrList.Add(~strItem);
    strItem <<= Null;        // Manually clear the item
}

GUI_APP_MAIN
{
    SimpleDemo().Run();
}

Here is our application in action:

Final Product

Conclusion

There you have it! A very simple application made in just minutes, thanks to the power and simplicity of Ultimate++. Please note that you could then take this code over to Linux and compile it for X11. It just works. One of Ultimate++'s strengths is that it is self-contained. There is no need to find a separate IDE, a separate layout designer, or a separate compiler. It's all built-in (or bundled). I urge you to look at the example applications that are already installed to see how easy Ultimate++ is to learn.

Helpful Links

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below. A list of licenses authors might use can be found here.

History

  • 6th November, 2006: Initial version

Written By
United States United States
Matt Ezell is a student at the University of Tennessee, USA. He has been programming in C++ for a couple years, and he now uses Ultimate++ for his applications. Visit his website at Ezell Media.

Comments and Discussions

 
NewsGetting Started With Ultimate++ - 2020 Edition Pin
Zbigniew Rębacz2-Sep-20 2:16
Zbigniew Rębacz2-Sep-20 2:16 
PraiseStill going strong Pin
TheRaven22-Nov-17 7:43
TheRaven22-Nov-17 7:43 
QuestionU++ is well and alive Pin
Hans15-Jan-16 6:24
Hans15-Jan-16 6:24 
AnswerRe: U++ is well and alive Pin
TheRaven22-Nov-17 7:17
TheRaven22-Nov-17 7:17 
QuestionCompile errors when tested with U++ 5485 Pin
EdwardX218-Feb-15 17:57
EdwardX218-Feb-15 17:57 
QuestionWill It Compile an Existing SDK Ramdisk.H Pin
CADDex9-Nov-11 11:10
CADDex9-Nov-11 11:10 
GeneralMy vote of 5 Pin
Jeffrey Scott Flesher6-Nov-11 15:03
Jeffrey Scott Flesher6-Nov-11 15:03 
QuestionGreat and not out of date Pin
Jeffrey Scott Flesher6-Nov-11 15:00
Jeffrey Scott Flesher6-Nov-11 15:00 
GeneralUNBELIVEABLE Pin
Nick28th10-Aug-10 4:32
Nick28th10-Aug-10 4:32 
GeneralThanks for article. Ultimate++ great project!!! Pin
kompotfx25-Nov-08 11:46
kompotfx25-Nov-08 11:46 
Questionvb6 Adodc control Pin
Fh Kihufe2-Nov-07 5:09
Fh Kihufe2-Nov-07 5:09 
QuestionHow about the executable size? [modified] Pin
yosetl2-Nov-07 4:57
yosetl2-Nov-07 4:57 
AnswerRe: How about the executable size? Pin
luzr10-Nov-07 3:42
luzr10-Nov-07 3:42 
AnswerRe: How about the executable size? [modified] Pin
TheRaven22-Nov-17 7:21
TheRaven22-Nov-17 7:21 
GeneralThis is an excellent introduction to Ultimate++ Pin
yeohhs15-Oct-06 1:18
yeohhs15-Oct-06 1:18 
GeneralGreat article! Pin
5456246426424-Sep-06 14:18
5456246426424-Sep-06 14:18 
GeneralRe: Great article! Pin
luzr24-Sep-06 20:57
luzr24-Sep-06 20:57 
GeneralRe: Great article! Pin
TheRaven22-Nov-17 7:31
TheRaven22-Nov-17 7:31 
GeneralGreat job! [modified] Pin
Ronnie IJsbrandij26-Aug-06 12:23
Ronnie IJsbrandij26-Aug-06 12:23 
GeneralNot very conviced Pin
Emilio Garavaglia15-Aug-06 5:11
Emilio Garavaglia15-Aug-06 5:11 
GeneralRe: Not very conviced Pin
luzr15-Aug-06 8:01
luzr15-Aug-06 8:01 
GeneralRe: Not very conviced Pin
Emilio Garavaglia16-Aug-06 3:17
Emilio Garavaglia16-Aug-06 3:17 
GeneralRe: Not very conviced Pin
luzr16-Aug-06 3:30
luzr16-Aug-06 3:30 
GeneralRe: Not very conviced Pin
arilect19-Aug-06 11:19
arilect19-Aug-06 11:19 
GeneralRe: Not very conviced Pin
hongdong21-Aug-06 14:44
hongdong21-Aug-06 14:44 
#include <ctrllib ctrllib.h="">

struct App : public TopWindow
{
Button a, b, c, d;
Splitter v, h;

void Toggle();

App();
};

void App::Toggle()
{
h.Zoom(h.GetZoom() == 1 ? -1 : 1);
}

App::App()
{
a.SetLabel("牛叉");
b.SetLabel("比较好");
c.SetLabel("不错");
d.SetLabel("切换!");
h.Horz(a, v);
v << c<< b << d;
v.Vert();
Add(h.SizePos());
Sizeable().Zoomable();
d <<= callback(this, &App::Toggle);
}


GUI_APP_MAIN
{
SetDefaultCharset(CHARSET_UTF8);
App().Run();
}


This can convince you?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.