From: Georgios Petasis on 20 Feb 2010 09:24 Hi all, I need to get the toplevel window of a widget. But there is no such function in Tk API :-) winfo toplevel calls GetTopHierarchy (it is not public). Which does: static TkWindow * GetTopHierarchy( Tk_Window tkwin) /* Window for which the top-of-hierarchy * ancestor should be deterined. */ { TkWindow *winPtr = (TkWindow *) tkwin; while ((winPtr != NULL) && !(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } return winPtr; } TkWindow is also not public. So, difficult to do this in a portable way... George
From: Donal K. Fellows on 20 Feb 2010 12:12 On 20/02/2010 14:24, Georgios Petasis wrote: > So, difficult to do this in a portable way... I think that this is portable. It's even supported for some reason... Tcl_Eval(interp, "winfo toplevel $theDialog"); Donal.
From: Georgios Petasis on 20 Feb 2010 14:21 στις 20/2/2010 19:12, O/H Donal K. Fellows έγραψε: > On 20/02/2010 14:24, Georgios Petasis wrote: >> So, difficult to do this in a portable way... > > I think that this is portable. It's even supported for some reason... > > Tcl_Eval(interp, "winfo toplevel $theDialog"); > > Donal. Yes, until somebody redefines winfo, and everything collapses :D (I think that sometimes we forget that tcl commands can be redefined, and you cannot actually rely on anything. Like my first attempt to translate itcl classes tp tcloo, and I had redefined "set' inside a namespace. Tcl was not even possible to report errors... :D) Regards, George
From: Pat Thoyts on 20 Feb 2010 19:12 Georgios Petasis <petasis(a)iit.demokritos.gr> writes: >Hi all, > >I need to get the toplevel window of a widget. But there is no such >function in Tk API :-) > >winfo toplevel calls GetTopHierarchy (it is not public). Which does: > >static TkWindow * >GetTopHierarchy( > Tk_Window tkwin) /* Window for which the top-of-hierarchy > * ancestor should be deterined. */ >{ > TkWindow *winPtr = (TkWindow *) tkwin; > > while ((winPtr != NULL) && !(winPtr->flags & TK_TOP_HIERARCHY)) { > winPtr = winPtr->parentPtr; > } > return winPtr; >} > >TkWindow is also not public. So, difficult to do this in a portable way... I would loop using Tk_Parent and Tk_IsToplevel. Will this not do? static Tk_Window GetTop(Tk_Window tkwin) { while (tkwin && !Tk_IsToplevel(tkwin)) { tkwin = Tk_Parent(tkwin); } return tkwin; } Actually Tk_TopWinHierarchy _is_ declared in the public tk.h so you can use that too. -- Pat Thoyts http://www.patthoyts.tk/ To reply, rot13 the return address or read the X-Address header. PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD
|
Pages: 1 Prev: Interest JOS thread on Tcl/Tk Next: ANNOUNCE: TkRibbon 1.0 aplha 1! |