I need an embeddable menu widget
- From: hidetoshi.nagai@xxxxxxxxx
- Date: 29 Jan 2007 22:39:01 -0800
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)
.
- Follow-Ups:
- Re: I need an embeddable menu widget
- From: Jeff Hobbs
- Re: I need an embeddable menu widget
- From: suchenwi
- Re: I need an embeddable menu widget
- Prev by Date: Expect binary is too slow on solaris but works fine on linux
- Next by Date: Re: Trouble understanding TCL code
- Previous by thread: Expect binary is too slow on solaris but works fine on linux
- Next by thread: Re: I need an embeddable menu widget
- Index(es):
Relevant Pages
|