Charles.Forsyth20060303-partialeea662d19 years agoHistory
229 lines · 4.9 KB · Text
RawDownload
.TH TKCLIENT 2.SH NAMEtkclient: makedrawcontext, toplevel, onscreen, startinput,wmctl, settitle, handler, snarfput, snarfget \-window manager interface for Tk applications..SH SYNOPSIS.EXinclude "tkclient.m";tkclient := load Tkclient Tkclient->PATH; Resize,Hide,Help,OK,Plain:     con 1 << iota; Appl:   con Resize | Hide; init:       fn();makedrawcontext: fn():  ref Draw->Context;toplevel:   fn(ctxt: ref Draw->Context, topconfig: string,                title: string, buts: int): (ref Tk->Toplevel, chan of string);onscreen:   fn(top: ref Tk->Toplevel, how: string);startinput: fn(top: ref Tk->Toplevel, devs: list of string);wmctl:      fn(top: ref Tk->Toplevel, request: string): string;settitle:   fn(top: ref Tk->Toplevel, name: string): string;handler:    fn(top: ref Tk->Toplevel, stop: chan of int); snarfput:   fn(buf: string);snarfget:   fn(): string;.EE.SH DESCRIPTIONThe.B Tkclientmodule provides routines for making windows controlled by.IR wm (1)containing.IR tk (2)widgets..PP.B Initshould be called once to initialise the internal state of.BR tkclient ..PP.B Makedrawcontextestablishes an initial connection with the window manager,creating a new.B Drawcontext suitable for creating new windows. It is onlynecessary to call this if the application has not alreadybeen provided with a context..PP.B Toplevelcreates a new window through.IR ctxt ..I Topconfiggives a list of.IR frame (9)options that are applied to thenew tk window, as described in.IR tk (2)..I Titlegives a label that will be displayed in the title barof the window;.I butsdetermines which buttons are created in the titlebar,a bitwise combination of the constants.BR Resize ,.BR Help ,.BR OK,and.BR Hide .If.B Plainis given, the window is given no decoration at all..B Toplevelreturns a tuple, say.RI ( top ,\  ctl ),where.I topis the newly created top level tk window,and.I ctlis a channel down which requests from thetitle bar are sent.Messages received on.I ctlshould be processedby the application or passed to the.B wmctlfunction. Requests are formattedas with.B quotedin.IR string (2).The messages include:.TP.B exitThe window should be closed..B Wmctlwill kill all processes in the currentprocess group..TP.B !move \fIx\fP \fIy\fPThe user has started to try to drag the window..I Xand.I ygive the location of the initial pointer click..TP.B !sizeThe user wishes to resize the window..TP.B helpThe help button has been clicked..TP.B okThe OK  button has been clicked..TP.B hideThe Hide button has been clicked.The window will be deleted, and an entryshown on the toolbar..PPIn order to function correctly, an applicationshould process not only events from thetitle bar channel, but also events fromthe Tk toplevel.I wreqchannel, those received from the windowmanager itself (via.IB top .ctxt.ctl\fR),\fPand pointer and keyboard events received fromthe window manager (via.IB top .ctxt.ptrand.IB top .ctxt.kbdrespectively).Control events can be passed to.BR wmctl ;pointer and keyboard events should bepassed to their respective functionsin.IR tk (2)..PPWhen created, the window is not visibleand will not receive pointer or keyboard events..B Onscreenmakes it visible, and possibly chooses aposition and a size for it..I Howspecifies what sort of placement is requiredfor the window; it can be one of.TP.B placetries to choose a suitable place on the screenwith respect to other windows; it may size thewindow as it feels appropriate. This the default(if.I howis nil)..TP.B onscreentries to keep the position and size the sameas specified on the window, adjusting them onlyto bring the window fully on screen, and making surethat the window is no bigger than the entire display..TP.B exactdoes not change the specified size or positionof the window unless absolutely necessary..PP.B Startinputinforms the window manager that the window isready to the event types specified in.IR devs .Currently understood are.B kbdfor keyboard events, and.B ptrfor pointer events..PPThe simplest well-behaved.I wm (1)client will therefore contain:.PP.EX	(top, ctl) := tkclient->toplevel(ctxt, nil, "My Program", Tkclient->Appl);	# ... populate the window with tk widgets	tkclient->startinput(top, "ptr" :: "kbd" :: nil);	tkclient->onscreen(top, nil);	for(;;){		alt{		s := <-ctl or		s = <-top.ctxt.ctl or		s = <-top.wreq =>			tkclient->wmctl(top, s);		p := <-top.ctxt.ptr =>			tk->pointer(top, *p);		c := <-top.ctxt.kbd =>			tk->keyboard(top, c);		}	}.EE.PP.B Settitlechanges the name displayed in the title barand the window's name when it is in the task bar..PP.B Snarfgetand.B snarfputretrieve and replace the contents of the windowmanager's snarf buffer..SH FILES.TF /chan/snarf.TP.B /chan/snarfsnarf buffer maintained by.IR wm (1).TP.B /chan/wmchannel for interaction with.IR wm (1).SH SOURCE.B /appl/lib/tkclient.b.SH SEE ALSO.IR wm (1),.IR tk (2)