Here is a docked cell solution that can be added to a stylesheet:
Firstly make the docked cell grid. I'm using PaneSelector
rather than If
to choose how to layout the docked cell. An alternative is to create two separate docked cells, one for working and one for slideshow. This seems easier.
grid = DynamicModule[{slideshow = False},
PaneSelector[{
True -> Grid[{
{Button[Graphics[{GrayLevel[0.3], Disk[]}, ImageSize -> 30],
(FEPrivate`NotebookToggleFullScreen[]; {}),
Appearance -> None],
Style[Row[{
Button["\[FirstPage]",
FrontEndTokenExecute[ButtonNotebook[], "ScrollPageFirst"],
Appearance -> "Palette"],
Button["\[LeftPointer]",
FrontEndTokenExecute[ButtonNotebook[],
"ScrollPagePrevious"], Appearance -> "Palette"],
Button["\[RightPointer]",
FrontEndTokenExecute[ButtonNotebook[], "ScrollPageNext"],
Appearance -> "Palette"],
Button["\[LastPage]",
FrontEndTokenExecute[ButtonNotebook[], "ScrollPageLast"],
Appearance -> "Palette"]}],
DefaultOptions -> {
Button -> {
BaseStyle -> {FontSize -> 25, GrayLevel[0.3]},
FrameMargins -> 0,
ImageMargins -> 0,
ImageSize -> 20}
}
],
DynamicModule[{cells = {}, tagFind = False},
EventHandler[
Dynamic[
PopupMenu[Dynamic[0, With[{nb = ButtonNotebook[]},
SelectionMove[nb, Before, Notebook,
AutoScroll -> False];
If[tagFind,
Do[NotebookFind[nb, "SlideShowHeader", Next, CellTags,
AutoScroll -> False], {#}],
Do[NotebookFind[nb, "SlideShowNavigationBar", Next,
CellStyle, AutoScroll -> False], {#}]
];
SelectionMove[nb, After, Cell, AutoScroll -> False];
NotebookWrite[nb,
Cell["", Deletable -> True, ShowCellBracket -> False],
All];
NotebookDelete[nb];
SelectionMove[nb, If[tagFind, Previous, Next],
Cell]] &
], cells,
Style[Row[{
Dynamic[
CurrentValue[{"CounterValue",
"SlideShowNavigationBar"}]],
Dynamic[
FrontEndResource["SlideshowToolbarText",
"SlideshowToolbarCounterText"]],
Dynamic[
CurrentValue[{"MaxCounterValue",
"SlideShowNavigationBar"}]]
}], "ControlStyle"],
Appearance -> None,
ImageSize -> Automatic]
],
{"MouseDown" :> Module[{cnt, nb = InputNotebook[]},
cells = {};
cnt = Apply[(NotebookFind[nb, #1, All, #2,
AutoScroll -> False];
CurrentValue[
nb, {"CellCount",
True}]) &, {{"SlideShowNavigationBar",
CellStyle}, {"SlideShowHeader", CellTags}}, {1}];
cnt = (If[tagFind = #1 == 0, #2, #1] &) @@ cnt;
SelectionMove[nb, Before, Notebook,
AutoScroll -> False];
If[tagFind,
cells = (#1 -> "Slide " <> ToString[#1] &) /@
Range[cnt],
Do[NotebookFind[nb, "SlideShowNavigationBar", Next,
CellStyle, AutoScroll -> False];
SelectionMove[nb, Next, Cell, AutoScroll -> False];
AppendTo[cells,
NotebookRead[nb] /.
s_Style :>
With[{ss =
Join[Take[s, 1],
DeleteCases[Rest[s], _String | _[FontColor, _]]]},
ss /; True]], {cnt}];
cells =
Replace[
cells[[All, 1]], {BoxData[c_] :> c,
TextData[c_] :> Row[If[ListQ[c], c, {c}]]}, 1];
cells = Thread[Range[cnt] -> cells]]]},
PassEventsDown -> True,
EvaluationOrder -> Before,
PassEventsUp -> True]
],
EventHandler[
Pane[
Style[Dynamic@
If[TrueQ[slideshow], "Switch to Working",
"Switch to Slideshow"], FontFamily -> "Arial", 14], {150,
30}, Alignment -> {Center, Center}],
{"MouseClicked" :> If[TrueQ[slideshow],
SetOptions[InputNotebook[],
ScreenStyleEnvironment -> "Working"];
slideshow = ! slideshow,
SetOptions[InputNotebook[],
ScreenStyleEnvironment -> "SlideShow"];
slideshow = ! slideshow]}]
}},
AutoDelete -> False,
Alignment -> {{Left, Center, Right}, Center},
ItemSize -> {Automatic, Fit, Automatic},
Spacings -> 3],
False -> Grid[{
{Button[Graphics[{GrayLevel[0.3], Disk[]}, ImageSize -> 30],
(FEPrivate`NotebookToggleFullScreen[]; {}),
Appearance -> None],
EventHandler[
Pane[
Style[Dynamic@
If[TrueQ[slideshow], "Switch to Working",
"Switch to Slideshow"], FontFamily -> "Arial", 14], {150,
30}, Alignment -> {Center, Center}],
{"MouseClicked" :> If[TrueQ[slideshow],
SetOptions[InputNotebook[],
ScreenStyleEnvironment -> "Working"];
slideshow = ! slideshow,
SetOptions[InputNotebook[],
ScreenStyleEnvironment -> "SlideShow"];
slideshow = ! slideshow]}]
}},
AutoDelete -> False,
Alignment -> {{Left, Center, Right}, Center},
ItemSize -> {Automatic, Fit, Automatic},
Spacings -> 3]
},
Dynamic[slideshow]]
]
To add this as a docked cell:
SetOptions[EvaluationNotebook[], DockedCells -> {First[ToBoxes[
TextCell[grid, Background -> GrayLevel[0.8], CellMargins -> 0]
]]}]
To remove it:
SetOptions[EvaluationNotebook[], DockedCells -> {}]
Notes:
This has been cobbled together after studying how other slideshow docked cells work. Note the red EvalutionOrder
option to EventHandler
.
This places the option (button, i.e. the disk on the left)) to go full screen from the working environment.
You can switch between slideshow and working via the docked cell by clicking on "Switch to Working" and "Switch to Slideshow".
To make the stylesheet:
CreateDocument@Notebook[{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Notebook"],
DockedCells -> {First[ToBoxes[
TextCell[grid, Background -> GrayLevel[0.8],
CellMargins -> 0]
]]}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]
From there give it a name and install it.
DockedCell
so while you could do as you suggested it would require you to create your own stylesheet that adds the switching buttons to your docked cell and preserves the existing slideshowDockedCell
. $\endgroup$ – Mike Honeychurch Jun 26 '12 at 7:01