Chapter X10. Developing applications for the CDE
 
 
Goals for this chapter: rpm packages covered in this chapter: 
  • XFree86 (X)
  • CDE© by Xi Graphics
 
 
Is CDE copyright? ... Yes, is copyright by the OpenGroup.
 - Dr. Giovanni A. Orlando

What is CDE© ?


This is the chapter about CDE development. More than a Graphical User Interface, CDE is a standard. Designed by HP, Novell (Unix Labs), IBM and Sun Microsystems, Inc.

This chapter covers the now "obsolete" Xi Graphics (CDE), that we run on a Linux system. (However  CDE still to be available on other UNIX vendor systems like HP, IBM and still SUN).

[root@world /root]# uname -a
Linux world.futuretg.com 2.2.14 #1 SMP Thu Feb 17 11:49:42 MST 2000 i586 unknown
[root@world /root]# cd /usr/dt
[root@world dt]# ls -F
app-defaults/  appconfig/  backdrops@  bin/  config/  copyright  dthelp/  examples@  include@  lib/  man@  palettes@  share/
[root@world dt]#

CDE stand for Common Desktop Interface. It is based on Motif but not only. It is an extension of Motif. Each file start with "Dt" that stand for Desktop.

Listing for example the file:

[root@world C]# more DtABa0.m.bm
/* $XConsortium: DtABa0.m.bm /main/2 1995/07/17 14:11:49 drk $ */
/*********************************************************************
*  (c) Copyright 1993, 1994 Hewlett-Packard Company
*  (c) Copyright 1993, 1994 International Business Machines Corp.
*  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
*  (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
*      Novell, Inc.
**********************************************************************/
#define DtABa0.m.bm_width 32
#define DtABa0.m.bm_height 32
static char DtABa0.m.bm_bits[] = {
   0x00, 0xf0, 0x0f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00,
   0xc0, 0xff, 0xff, 0x03, 0xe0, 0x1f, 0xf8, 0x07, 0xf0, 0x03, 0xc0, 0x0f,
   0xf8, 0x01, 0x80, 0x1f, 0x78, 0x00, 0x80, 0x1f, 0x3c, 0x00, 0xc0, 0x3f,
   0x3e, 0x00, 0xe0, 0x7d, 0x1e, 0x00, 0xf0, 0x78, 0x1e, 0x00, 0x78, 0x78,
   0x0f, 0x00, 0x3c, 0xf0, 0x0f, 0x00, 0x1e, 0xf0, 0x0f, 0x00, 0x0f, 0xf0,
   0x0f, 0x80, 0x07, 0xf0, 0x0f, 0xc0, 0x03, 0xf0, 0x0f, 0xe0, 0x01, 0xf0,
   0x0f, 0xf0, 0x00, 0xf0, 0x0f, 0x78, 0x00, 0xf0, 0x1e, 0x3c, 0x00, 0x78,
   0x1e, 0x1e, 0x00, 0x78, 0x3e, 0x0f, 0x00, 0x7c, 0xbc, 0x07, 0x00, 0x3c,
   0xf8, 0x03, 0x00, 0x1e, 0xf8, 0x01, 0x80, 0x1f, 0xf0, 0x03, 0xc0, 0x0f,
   0xe0, 0x1f, 0xf8, 0x07, 0xc0, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x00,
   0x00, 0xfe, 0x7f, 0x00, 0x00, 0xf0, 0x0f, 0x00};
[root@world C]#
 

Note that also a BITMAP (bm) file includes the copyright.

The CDE organization is as follows:
 
 

Note the different shemas: Note that basically using Motif as a GUI engine is developed the entire Desktop.
 

The CDE development tools


CDE propose its well-know enviroment:

All the User Operations in the Graphical enviroment are encapsulated in the standard.

Now, if the company that choose CDE wants to develop applications they may choose between two development tools:

Without to count these tools, that are development tools is important to remember the "Create Actions" (dtaction) that define actions connected with an application graphical or shell based.

The Desktop Korn Shell: "dtksh"

The "dtksh", is the standard graphical shell to write CDE applications. When we said graphical shell, we understand that is a shell, but the results will be graphical applications.

Now, we browse the Xi Graphics CDE 2.1 directory.

[root@world dt]# pwd
/usr/dt
[root@world dt]# ls -F
app-defaults/  appconfig/  backdrops@  bin/  config/  copyright  dthelp/  examples@  include@  lib/  man@  palettes@  share/
[root@world dt]#

[root@world dt]# cd bin
[root@world bin]#

[root@world bin]# ls -F
Xsession*        dtcm_editor*  dtexec*        dthelpgen*       dtlp*          dtsession*      dtsrload*     rpc.cmsd*        ttsnoop*
dsdm*            dtcm_insert*  dtfile*        dthelpgen.ds*    dtlslocale*    dtsession_res*  dtstyle*      rpc.ttdbserver*  tttar*
dtaction*        dtcm_lookup*  dtfile_copy*   dthelpprint*     dtmail*        dtspcd*         dtterm*       suid_exec*       tttrace*
dtappgather*     dtcodegen*    dtfile_error*  dthelpprint.sh*  dtmailpr*      dtsrclean*      dttypes*      tt_type_comp*
dtappintegrate*  dtconfig*     dtfplist*      dthelptag*       dtpad*         dtsrcreate*     dtudcexch*    ttcp*
dtbuilder*       dtcreate*     dtgreet*       dthelpview*      dtpdm*         dtsrdbrec*      dtudcfonted*  ttdbck*
dtcalc*          dtdbcache*    dthello*       dticon*          dtpdmd*        dtsrdelete*     dtwm*         ttmv*
dtchooser*       dtdocbook*    dthelp_ctag1*  dtimsstart*      dtprintinfo*   dtsrhan*        dtxlock*      ttrm*
dtcm*            dtdspmsg*     dthelp_htag1*  dtksh*           dtscreen*      dtsrindex*      huffcode*     ttrmdir@
dtcm_delete*     dterror.ds*   dthelp_htag2*  dtlogin*         dtsearchpath*  dtsrkdump*      ksh*          ttsession*
[root@world bin]#

The dtksh is a binary.

[root@world bin]# file dtksh
dtksh: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), not stripped
[root@world bin]#

CDE includes different examples, also for the dtksh.

We run here one:

[root@world bin]# ./dtksh ../examples/dtksh/ListPosSel1

... and get ...
 

Clicking on the button "Get Item Selection List" ... we will get:

Item 1 is not selected
Item 2 is selected
Item 3 is not selected
Item 4 is selected
Item 5 is not selected
Item 6 is selected
Item 7 is not selected
Item 8 is not selected
Item 9 is not selected
Item 10 is not selected
Item 11 is not selected

The source is copyright. However we can list some lines to offers you and idea.

...
XtInitialize TOPLEVEL listPosSel1 ListPosSel1 "$0" "$@"
XtSetValues $TOPLEVEL allowShellResize:True

XmCreateScrolledList LIST $TOPLEVEL list        itemCount:11    items:"item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11"
        visibleItemCount:15     listSizePolicy:VARIABLE
XtSetValues $LIST       selectedItemCount:3     selectedItems:"item2,item4,item6"
XtManageChild $LIST

XtRealizeWidget $TOPLEVEL
...

It is basically write shell programs where primitives are equivalent to C code used on Motif development.
 

The CDE Application Builder: "dtbuilder"

The second and more important ... "at all" development tool included in CDE is it Application Builder (AB).

We can see this product here.

Using drag-and-drop techniques ... the "dtbuilder" simply CDE development in an easy and innovative mode ... that is not available on modern tools like KDE or GNOME.

The graphic elements of development

The CDE AB (dtbuilder) includes different zones we are displayed the graphical components.

The primary components where we need to play attention are the "Windows" and "Panes" column.

For example dragging the window on the backroung we will get:

Then we assign a name (or just hit enter to confirm) ... then we must add a pane and for example a textfield. In question of seconds we get:


Source generation

One of the most important and significative components (that any builder must have) is the Code Generation. The CDE AB, includes not only this but also the compilation and testing (visualization).

After we design a CDE Application, we may generate the code clicking the appropriate entry inside the CDE AB.

We will have the following working masks:
 

We will have that the source, including ".h", ".c" and Makefile will be similar to the following:

[root@world CDE_Example1]# ls
Makefile      Makefile.bsd   Makefile.linux  Makefile.sunos  dtb_utils.c  module1.bil      module1_ui.c  project.bip  project.h
Makefile.aix  Makefile.hpux  Makefile.osf1   Makefile.uxp    dtb_utils.h  module1_stubs.c  module1_ui.h  project.c
[root@world CDE_Example1]#
 

After adding a second Pane ... and resize we will have:

In any moment we will visualize, edit, arrange ... or import components with the "Module Browser"

The code is the following:

/*** DTB_USER_CODE_START vvv Add file header below vvv ***/
/*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/

/*
 * File: ex1.c
 * Contains: main() and cross-module connections
 *
 * This file was generated by dtcodegen, from project ex1
 *
 * Any text may be added between the DTB_USER_CODE_START and
 * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
 * are provided only as an aid.
 *
 *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
 *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
 *  ** DELETE THE GENERATED COMMENTS!                                 **
 */

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include <Xm/Protocols.h>
#include <Dt/Help.h>
#include <Dt/HelpQuickD.h>
#include <Dt/HelpDialog.h>
#include "module_ui.h"
#include "ex1.h"
#include "dtb_utils.h"
 

/**************************************************************************
 *** DTB_USER_CODE_START
 ***
 *** All necessary header files have been included.
 ***
 *** Add include files, types, macros, externs, and user functions here.
 ***/

/*** DTB_USER_CODE_END
 ***
 *** End of user code section
 ***
 **************************************************************************/
 
 

/*
 * command line options...
 */
static XrmOptionDescRec optionDescList[] = {
    {"-session", "*session", XrmoptionSepArg, (XPointer)NULL}

    /*** DTB_USER_CODE_START vvv Add structure fields below vvv ***/
    /*** DTB_USER_CODE_END   ^^^ Add structure fields above ^^^ ***/
};

/*
 * Application Resources
 */
static XtResource resources[] = {
    {"session", "Session", XtRString, sizeof(String),
        XtOffsetOf(DtbAppResourceRec, session_file), XtRImmediate, (XtPointer)NULL}

    /*** DTB_USER_CODE_START vvv Add structure fields below vvv ***/
    /*** DTB_USER_CODE_END   ^^^ Add structure fields above ^^^ ***/
};

DtbAppResourceRec dtb_app_resource_rec;
 

/*
 * main for application ex1
 */
int
main(int argc, char **argv)
{
    Widget  toplevel = (Widget)NULL;
    Display  *display = (Display*)NULL;
    XtAppContext app = (XtAppContext)NULL;
    String  *fallback_resources = (String*)NULL;
    ArgList  init_args = (ArgList)NULL;
    Cardinal  num_init_args = (Cardinal)0;
    ArgList  get_resources_args = (ArgList)NULL;
    Cardinal  num_get_resources_args = (Cardinal)0;
    Atom  save_yourself_atom = (Atom)NULL;
 

    /**************************************************************************
     *** DTB_USER_CODE_START
     ***
     ***  No initialization has been done.
     ***
     *** Add local variables and code.
     ***/

    /*** DTB_USER_CODE_END
     ***
     *** End of user code section
     ***
     **************************************************************************/
 

    toplevel = XtAppInitialize(&app, "Ex1",
        optionDescList, XtNumber(optionDescList),
        &argc, argv, fallback_resources,
        init_args, num_init_args);

    /*
     * Get display and verify initialization was successful.
     */
    if (toplevel != NULL)
    {
        display = XtDisplayOfObject(toplevel);
    }
    if (display == NULL)
    {
        fprintf(stderr, "Could not open display.");
        exit(1);
    }

    /*
     * Save the toplevel widget so it can be fetched later as needed.
     */
    dtb_save_toplevel_widget(toplevel);

    /*
     * Save the command used to invoke the application.
     */
    dtb_save_command(argv[0]);

    XtGetApplicationResources(toplevel, (XtPointer)&dtb_app_resource_rec,
        resources, XtNumber(resources),
        get_resources_args, num_get_resources_args);
 

    /**************************************************************************
     *** DTB_USER_CODE_START
     ***
     ***      A connection to the X server has been established, and all
     *** initialization has been done.
     ***
     ***  Add extra initialization code after this comment.
     ***/

    /*** DTB_USER_CODE_END
     ***
     *** End of user code section
     ***
     **************************************************************************/
 
 

    /*
     * Initialize all global variables.
     */
    dtbModuleMainwindowInfo_clear(&dtb_module_mainwindow);

    /*
     * Set up the application's root window.
     */
    dtb_module_mainwindow.mainwindow = toplevel;
    XtVaSetValues(dtb_module_mainwindow.mainwindow,
        XmNallowShellResize, True,
        XmNtitle, "Main Window",
        XmNinitialState, NormalState,
        XmNbackground, dtb_cvt_string_to_pixel(dtb_module_mainwindow.mainwindow, "white"),
        NULL);

    dtb_module_mainwindow_initialize(&(dtb_module_mainwindow), dtb_get_toplevel_widget());

    /*
     * Map any initially-visible windows
     */

    save_yourself_atom = XmInternAtom(XtDisplay(toplevel),
     "WM_SAVE_YOURSELF", False);

    XmAddWMProtocolCallback(toplevel, save_yourself_atom,
     dtb_session_save, (XtPointer)NULL);
 

    /**************************************************************************
     *** DTB_USER_CODE_START
     ***
     ***      All initially-mapped widgets have been created, but not
     *** realized. Set resources on widgets, or perform other operations
     *** that must be completed before the toplevel widget is
     *** realized.
     ***/

    /*** DTB_USER_CODE_END
     ***
     *** End of user code section
     ***
     **************************************************************************/
 

    XtRealizeWidget(toplevel);
 

    /**************************************************************************
     *** DTB_USER_CODE_START
     ***
     ***      The initially-mapped widgets have all been realized, and
     *** the Xt main loop is about to be entered.
     ***/

    /*** DTB_USER_CODE_END
     ***
     *** End of user code section
     ***
     **************************************************************************/

    /*
     * Enter event loop
     */
    XtAppMainLoop(app);
    return 0;
}
 

/**************************************************************************
 *** DTB_USER_CODE_START
 ***
 *** All automatically-generated data and functions have been defined.
 ***
 *** Add new functions here, or at the top of the file.
 ***/

/*** DTB_USER_CODE_END
 ***
 *** End of user code section
 ***
 **************************************************************************/

The compilation command was:

As we note there are both: Motif but also Dt (CDE) libraries.

In the code we note also a function called:

 dtb_module_mainwindow_initialize(&(dtb_module_mainwindow), dtb_get_toplevel_widget());

Project maintenance

The CDE designer not only consider and design a standard for the GUI, for UNIX systems, not only write a builder to develop a graphical builder, but also consider the possibility to mix or re-use modules developed by the builder.

In fact, from the "File" Menu entry we will see the following entry. ... If we choose the "Project Organizer ..." meu entry (in the right) you will see
 

There also a particular
 
 

CDE Documentation.

Open Group CDE - Motif Documentation is the following:

The Motif Manuals (M213, M214A, M214B, M214C, M216) are included in FT-OpenMotif. Others manuals are available from the OpenGroup or from Prentice-Hall. Also, DeXtop includes it.
 

Conclusions

Actually CDE is used only on some systems. Sun adopt GNOME and others uses KDE. But, as basically happens when a new program is released generally something is missing. Most KDE original features that emulates CDE had been removed or not included to emulate GNOME or MS Windows or Mac OSX. Also, Xi Graphics, the CDE copyright holder company for Linux, removes the product and release a company vertical desktop called DeXtop.

Therefore, CDE actually is a Graphical "limbo" zone.

However, CDE concepts are not only necessary to be understood but also studied. CDE manuals as you can know are very extensive. There are 11 manuals.

With this words, I want to explain that CDE continues to be standard, also if not used. Probably, soon a company will 'in some day' adopt the CDE standards on a new frame.
 

Exercises

Because Xi Graphics CDE is now 'obsolete' there are no exercises for this chapter. Xi Graphics resume CDE in a new product called DeXtop. We does not test this product.
Test
  1. What's CDE ?
  2. List three copyright holder for CDE.
  3. What is the CDE suffix for applications and development tools ?
  4. List the two more important CDE development tools.
  5. Are there are CDE builder ? How it is called ?
  6. What's the CDE Window manager ?
  7. What is the GUI Engine used by CDE, GUI and Development ?
  8. What source may includes a code line like: "XtRealizeWidget $TOPLEVEL" ?
  9. Would be "Editors" a component in "Productivity Applications" ?
  10. It is possible to add a menu with the CDE AB ?
  11. What Motif technique use the "dtbuilder" to develop CDE applications ?
  12. Would be possible to generate the code or display the final application for test with the dtbuilder ?
  13. List three vendors that develop the CDE Application Builder.
  14. The code generated code by the CDE AB will use Motif or CDE "includes" files ?
  15. List five CDE manuals.
  16. It is possible to re-use module components developed by the Builder ?
  17. What is the "Module Browser" ?
  18. Is possible to handle projects with the CDE AB ?
  19. Are there some particular standard or guide also to handle projects with the CDE ?
  20. Can you list some libraries included in the CDE Builder compilation ?
Consult the answers

Check the Interactive Exam Cram X Window: Try the interactive cram ...

Internet Resources for this Chapter.