I need an embeddable menu widget



Hello, Tclers.
I'm a maintainer of Ruby/Tk.
I want a kind of a menu widget which is embeddable into a container
frame.
The reason of why is the following...

I'm developping Ruby/TkORCA (Ruby/Tk on RFB Canvas) for "GUI on the
Net".
That is a framework allowing public access of Tk applications.
Of course, it is dangerous for a server to accept anonymous use of a
window manager. And, for security reason, I want to observe the Tk
application with user's window operation.
So, I use a canvas widget of a master interpreter as a window
manager,
and embed toplevel widgets of slave interpreters to container frames
associated with window items on the canvas widget.
Tk applications to open are loaded to the slave interpreters.
The canvas widget is an only window on a Xvnc process with no window
manager. Then, the Xvnc works as a RFB communication buffer.
Although I omit the detail of Ruby/TkORCA, I planned to use standard
(normal, without patch) version of libraries (normal Xvnc, normal
Tcl/Tk, and normal Ruby) and had a trouble on implementation.
That is "cannot embed tearoff menus".

To keep tearoff menus under control, I decided to use a trick on
Tcl/Tk interpreter by the following operation on Ruby/Tk.
---------------------------------------------------------------------
/*###############################################*/

/*
* The following is based on tkMenu.[ch]
* of Tcl/Tk (>=8.0) source code.
*/
#if TCL_MAJOR_VERSION >= 8

#define MASTER_MENU 0
#define TEAROFF_MENU 1
#define MENUBAR 2

struct dummy_TkMenuEntry {
int type;
struct dummy_TkMenu *menuPtr;
/* , and etc. */
};

struct dummy_TkMenu {
Tk_Window tkwin;
Display *display;
Tcl_Interp *interp;
Tcl_Command widgetCmd;
struct dummy_TkMenuEntry **entries;
int numEntries;
int active;
int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR */
Tcl_Obj *menuTypePtr;
/* , and etc. */
};

struct dummy_TkMenuRef {
struct dummy_TkMenu *menuPtr;
char *dummy1;
char *dummy2;
char *dummy3;
};

EXTERN struct dummy_TkMenuRef *TkFindMenuReferences(Tcl_Interp*,
char*);

#endif

static VALUE
ip_make_menu_embeddable(interp, menu_path)
VALUE interp;
VALUE menu_path;
{
#if TCL_MAJOR_VERSION >= 8
struct tcltkip *ptr = get_ip(interp);
struct dummy_TkMenuRef *menuRefPtr;

StringValue(menu_path);

menuRefPtr = TkFindMenuReferences(ptr->ip, RSTRING(menu_path)-
ptr);
if (menuRefPtr == (struct dummy_TkMenuRef *) NULL) {
rb_raise(rb_eArgError, "not a menu widget, or invalid widget
path");
}

if (menuRefPtr->menuPtr == (struct dummy_TkMenu *) NULL) {
rb_raise(rb_eRuntimeError,
"invalid menu widget (maybe already destroyed)");
}

if ((menuRefPtr->menuPtr)->menuType != MENUBAR) {
rb_raise(rb_eRuntimeError,
"target menu widget must be a MENUBAR type");
}

(menuRefPtr->menuPtr)->menuType = TEAROFF_MENU;

TkEventuallyRecomputeMenu(menuRefPtr->menuPtr);
TkEventuallyRedrawMenu(menuRefPtr->menuPtr,
(struct dummy_TkMenuEntry *)NULL);

#else /* TCL_MAJOR_VERSION <= 7 */
rb_notimplement();
#endif

return interp;
}

/*###############################################*/
---------------------------------------------------------------------

I know that it is a illegal method. But it looks like working.
If there is an embeddable menu (maybe, it is a vertical menubar),
I'll not use such sneaky way.

In conclusion, I want to ask
(1) Can Tcl/Tk support an embeddable clone menu widget?
(2) Please tell me the best (better) way to embed tearoff menus.

P.S.
If you are interested in Ruby/TkORCA,
you can get a beta (trial) version at
<http://qwik.jp/ruby-tk/RubyTkORCA.html>.
I'm very sorry but it has Japanese synoptic documents only.
--
Hidetoshi NAGAI (nagai@xxxxxxxxxxxxxxxx)

.



Relevant Pages

  • Re: Ruby/Tk : How to show tooltips (please correct my ugly implementation)
    ... Subject: Ruby/Tk: How to show tooltips ... So, if you want to create a new widget class, ... in a daughter. ... Of course, there is no native window manager, and each client ...
    (comp.lang.ruby)
  • Re: Does Ruby TK have an HTML rendering "widget"?
    ... Those Tk extensions are available on current Ruby/Tk. ... If you use ActiveTcl binary package for your Ruby/Tk, ... One thing I want to be able to do is send HTML to them (rather than ... I presume I can have multiple instances of the widget without interfering ...
    (comp.lang.ruby)
  • Re: Ruby/Tk : How to show tooltips (please correct my ugly implementation)
    ... Subject: Ruby/Tk: How to show tooltips ... you'll see the flicker of the toplevel widget. ... except geometry manager commands. ... Ruby/Tk passes an empty string for a nil to the Tk interpreter. ...
    (comp.lang.ruby)
  • Re: TkDialogBox missing?
    ... That is NOT a standard widget of Tcl/Tk. ... BWidget extension is written in pure Tcl/Tk. ... it is not difficult to install. ... Ruby/Tk supports BWidget extension by 'tkextlib/bwidget.rb'. ...
    (comp.lang.ruby)
  • Re: struct versioning
    ... to be initialized by client code, by taking the sizeof of the struct. ... write the WIDGET macro-opcode and provide operands for the ... was very often a length indicator for the whole block. ... C's initializers, even now, are not robust ...
    (comp.lang.c)