caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Labltk: Canvas item -state hidden
@ 2005-04-20  8:22 Dirk Thierbach
  2005-04-20 16:38 ` [Caml-list] " Matt Gushee
  0 siblings, 1 reply; 2+ messages in thread
From: Dirk Thierbach @ 2005-04-20  8:22 UTC (permalink / raw)
  To: caml-list

Is there any reason that Labltk doesn't allow to configure canvas items
with -state hidden (or with any state at all)?

After wading through the interface information, I came up with 
the following workaround:

let canvas_configure_item ?state widget tag = 
  let tk_widget = cCAMLtoTKwidget widget in
  let tk_state = match state with 
    | None           -> []
    | Some `Normal   -> [TkToken "-state"; TkToken "normal"]
    | Some `Disabled -> [TkToken "-state"; TkToken "disabled"]
    | Some `Hidden   -> [TkToken "-state"; TkToken "hidden"]
  in
  (* Tk.Tkintf.cCAMLtOTKtagOrId doesn't quote the tag *)
  let cCAMLtoTKtag (tag : Tk.tagOrId) = match tag with
    | `Id i  -> TkToken (string_of_int i)
    | `Tag s -> TkQuote (TkToken s)
  in
  let tk_tag = cCAMLtoTKtag tag in
  let cmd = TkTokenList [tk_widget; TkToken "itemconfigure"; tk_tag] in
  tkCommand [| cmd; TkTokenList tk_state |] 

But of course it would be nicer if Labltk would already support it :-)

- Dirk


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Labltk: Canvas item -state hidden
  2005-04-20  8:22 Labltk: Canvas item -state hidden Dirk Thierbach
@ 2005-04-20 16:38 ` Matt Gushee
  0 siblings, 0 replies; 2+ messages in thread
From: Matt Gushee @ 2005-04-20 16:38 UTC (permalink / raw)
  To: caml-list

Dirk Thierbach wrote:

 > Is there any reason that Labltk doesn't allow to configure canvas items
 > with -state hidden (or with any state at all)?


Probably just an oversight. Since Labltk is poorly documented and not 
very widely used, there are few people in a position to find the bugs.

 > After wading through the interface information, I came up with the 
following workaround:


Actually, that's not where you want to make the change. The code you 
modified was automatically generated from a file called Widgets.src, 
which you will find in $OCAML_SOURCE/otherlibs/labltk.

What you need to do is to open up Widgets.src and find the blocks that 
start with

   subtype option(arc) {

and so on ... there's one for each canvas item type. Just add "State" to 
the options in each of those blocks. Once you see it it should be pretty 
obvious.

 > But of course it would be nicer if Labltk would already support it :-)


I'd suggest you make the modifications as I described, rebuild OCaml and 
make sure it works, then submit your request (with a patch or at least a 
description of the fix) to the OCaml bug tracker. It may take a while, 
but unless there's some good reason for not including that option (can't 
imagine what reason there would be), it should eventually get into the 
distribution.

-- 
Matt Gushee
Englewood, CO, USA


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-04-20 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-20  8:22 Labltk: Canvas item -state hidden Dirk Thierbach
2005-04-20 16:38 ` [Caml-list] " Matt Gushee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).