[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal for a unified GUI to support Motif/Gtk/(Qt?)

From: Peter Wainwright
Subject: Proposal for a unified GUI to support Motif/Gtk/(Qt?)
Date: Sun, 28 Jan 2007 20:13:47 +0000

Proposal for a unified GUI to support Motif/Gtk/(Qt?)

In order to support Gtk, without dropping the existing Motif interface
or forking the project, I have begun to experiment with a unified O-O
toolkit interface under the "gddd" branch.

The gddd branch now has preliminary support for three GUI interfaces:

(1) Motif(Xm) : The old procedural Motif interface.
    This is selected by ./configure without arguments.
    The macros IF_MOTIF and IF_XM are defined in config.h.

(2) Motif(Xmmm) : The new object-oriented Motif wrapper.
    This is selected by ./configure --with-xmmm.
    The macros IF_MOTIF and IF_XMMM are defined in config.h.

(3) Gtk(GtkX) : The object-oriented Gtk wrapper.
    This is selected by ./configure --with-gtk.
    None of the above macros is defined.

At the end of the rewrite, the following conditions should be true
- as far as possible :-)

(i) The old and new Motif interfaces will provide the same
    functionality.  Then the old interface (#ifdef IF_XM sections)
    can be dropped.  At present these sections are left as a fallback
    and to show the old code for comparison purposes.

(ii) The Xmmm and GtkX interfaces will be isomorphic.  Then a single
     macro in config.h will be used to switch between Motif and Gtk
     #define GUI Xmmm     ... OR ...
     #define GUI GtkX

The unified interface will look very much like Gtkmm, the C++
object-oriented interface to Gtk, but with minimal modifications which
are required to support Motif (and possibly Qt in future).

In the meantime, the transition from Xm to Xmmm will be done
incrementally. Widget handles will be stored as instances of a new
template class Xmmm::WidgetPtr<Xmmm::CLASS>.  This has conversion
operators which allow it to be used wherever an Xmmm::CLASS* is
required OR an Xt Widget is required.  This type of widget handle is
automatically converted to the appropriate type whether it is used in
a new-style O-O method call or an old-style Xm... or Xt... call.

The GtkX namespace is a thin wrapper over Gtkmm, provided for
compatibility with Xmmm.  The main difference is that Gtkmm widgets
are created, and THEN added to the parent in a separate call.  This
cannot be done in the unified GUI, since Widgets cannot be reparented
in the Xt architecture.  Thus the parent widget must be passed to the
constructor.  Also, a Widget name is mandatory in order to allow the
Xt resource mechanism to work.  Constructors in GtkX/Xmmm therefore
follow this pattern:

GUI::CLASS::CLASS(GUI::Widget &parent, const char *name, ...);

As an example of how this might work (remember, IF_XM marks the old
interface for comparison purposes), here are some fragments from

#if !defined(IF_XM)
#include <GUI/WidgetPtr.h>
#include <GUI/RadioBox.h>
#include <GUI/SelectionDialog.h>
#include <GUI/RadioButton.h>


#if defined(IF_XM)
Widget SourceView::register_dialog_w         = 0;
GUI::WidgetPtr<GUI::SelectionDialog> SourceView::register_dialog_w = 0;


#if defined(IF_XM)
Widget SourceView::int_registers_w           = 0;
Widget SourceView::all_registers_w           = 0;
GUI::WidgetPtr<GUI::RadioButton> SourceView::int_registers_w = 0;
GUI::WidgetPtr<GUI::RadioButton> SourceView::all_registers_w = 0;


#if defined(IF_XM)
    arg = 0;
    XtSetArg(args[arg], XmNautoUnmanage, False); arg++;
    register_dialog_w = 
        verify(createTopLevelSelectionDialog(parent, "register_dialog", args,
#elif defined(IF_XMMM)
    register_dialog_w = 
        new GUI::SelectionDialog(parent, "register_dialog");
#else // Gtk
    register_dialog_w = 
        new GUI::SelectionDialog(*parent, "register_dialog");


#if defined(IF_XM)
    arg = 0;
    Widget box = XmCreateRadioBox(register_dialog_w, XMST("box"), args,
    GUI::WidgetPtr<GUI::RadioBox> box = new
GUI::RadioBox(*register_dialog_w, "box", GUI::ORIENTATION_HORIZONTAL);

#if defined(IF_XM)
    arg = 0;
    XtSetArg(args[arg], XmNset, !all_registers); arg++;
    int_registers_w = 
        XmCreateToggleButton(box, XMST("int_registers"), args, arg);
    int_registers_w =
        new GUI::RadioButton(*box, "int_registers");

#if defined(IF_XM)
    arg = 0;
    XtSetArg(args[arg], XmNset, all_registers); arg++;
    all_registers_w = 
        XmCreateToggleButton(box, XMST("all_registers"), args, arg);
#else // NOT IF_XM
    all_registers_w =
        new GUI::RadioButton(*box, "all_registers");
#endif // IF_XM

#if defined(IF_XM)
    XtAddCallback(int_registers_w, XmNvalueChangedCallback,
sourceSetIntRegistersCB, XtPointer(0));
    XtAddCallback(all_registers_w, XmNvalueChangedCallback,
sourceSetAllRegistersCB, XtPointer(0));



Peter Wainwright

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]