Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Joust in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98338] Re: Joust in Mathematica
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Mon, 6 Apr 2009 05:03:13 -0400 (EDT)
  • References: <gr21m6$lr4$1@smc.vnet.net> <6221704.1238754373701.JavaMail.root@m02> <gra1ae$246$1@smc.vnet.net>

Hi David,

> Maybe a horizontal scrollbar, and then what are the chances of adding an
> invisible locator or EventHandler to alter the width of the left hand panel?

the additional scrollbars are not so difficult, it takes a little effort
to make the two panes behave more user friendly, but it is rather
straightforward (but could probably be improved further). Using locators
or EventHandler for this might work but I think it is much easier and
probably more robust to stick with the resize areas that the Pane shows
with Scrollbars->True. The following has some improvements, but still is
more of a demonstration that I think you can probably do what the
original poster asked for, although I'm not sure whether I fully
understood what that was :-)

This defines a function that shows an outline with content in an extra
window:

Moust[outline_, content_] := CreateDialog[{
   DynamicModule[{
     widthleft = 150, widthright = 600, height = 400,
     selectedkey = Level[outline, -1][[1]], outlineview
     },
    Dynamic[
     Row[{
       Panel[Pane[
         outlineview[outline],
         ImageSize -> Dynamic[{widthleft, height},
           (
             height = #[[2]];
             widthright = widthright + widthleft - #[[1]];
             widthleft = #[[1]];
             #
             ) &],
         Scrollbars -> True
         ]
        ],
       Panel[Pane[
         Dynamic[content[selectedkey]],
         ImageSize -> Dynamic[{widthright, height}, (
             height = #[[2]];
             widthright = #[[1]];
             #
             ) &
           ],
         Scrollbars -> True, Alignment -> {Center, Center}
         ]]
       }]
     ],
    Initialization :> (
      outlineview[key_] :=
       Button[key, selectedkey = key, Appearance -> None];
      outlineview[expr_?(StringQ[Head[#]] &)] :=
       OpenerView[{Head[expr], Column[outlineview /@ (List @@ expr)]}];
      )
    ]}
  ]

This defines an expression which can be shown with the above function:

outline = "Functions"[
  "Arithmetic"[x, x^2, x^3, x^4, Sqrt[x]],
  "Elementary"[Log[x], Exp[x]],
  "Trigonometric"[Sin[x], Cos[x], Tan[x], Cot[x]],
  "Hyperbolic"[Sinh[x], Cosh[x], Tanh[x]]
  ]

This defines a function which will be used to create the content for the
right hand side of the window:

content[key_] := Plot[Evaluate[key], {x, 0, 3},
  Frame -> True, PlotLabel -> key, Background -> White,
  ImageSize -> 500
  ]

This will create the window:

Moust[outline, content]


hth,

albert



  • Prev by Date: AMERICAN MATHEMATICAL MONTHLY -April 2009:Transformations Between
  • Next by Date: Re: Re: Can nobody help me? Re: selecting a column in a grid
  • Previous by thread: Re: Joust in Mathematica
  • Next by thread: Re: Joust in Mathematica