Toggling Zoom with a Custom Toolbar

The Libronix Digital Library System is a very modular framework. The user interface is separate from the system internals. This modularity not only makes for a better application architecture, it allows us to deliver new features and user interface without changing the underlying system. (Below I am going to show you how to add a “Toggle Zoom” feature right now, without downloading anything.)

The Libronix DLS exposes its internal interfaces publicly, allowing external applications to control it. It also allows users to add their own functionality, either with an external programming language or with JavaScript inside custom toolbar commands.

The documentation for the scriptable object model is available as a free Libronix DLS compatible resource. The automation newsgroup is where you can ask questions about automating the Libronix DLS and get help from Logos programmers and other users.

I’m going to show you how to add a custom toolbar with a new command that toggles resource windows between their default zoom and 200% zoom. (This is really useful when you are projecting Logos Bible Software in a classroom, or even just leaning back to read.)

First, right-click on a toolbar and select Customize… Then choose New… and give your toolbar a name, like “Logos Blog Toolbar”.

The Category drop down lets you choose from the kind of commands you can add to your customer toolbar. Different categories contain most of the menu commands in the system. We want to create a new command, though, not use an existing one. So choose Special from the Category drop down and then select Run Script Code and click the Add button to move it to your toolbar list on the right.

Now click Details… to edit the Run Script Code item. In the Command Details dialog give your command the name Toggle Zoom and choose a display style – I use Image and Text for custom commands. The Change… button lets you choose an icon for the button.

Now, in the Script Code box, copy and paste the script below.


// Toggle the zoom of a resource window
var objWindow = Application.ActiveWindow;
if ( objWindow != null )
{
if ( objWindow.Type == "resource" )
{
var objView = objWindow.View;
if ( objView && objView.IsOpen() )
{
var objDisplayPane = objView.Panes("display");
if ( objDisplayPane )
{
var strZoom = objDisplayPane.Control.Zoom;
if ( strZoom == "auto" || strZoom == "100%" )
strZoom = "200%";
else
strZoom = "auto";
objDisplayPane.Control.Zoom = strZoom;
}
}
}
}

Now use OK and Close to get out of the dialogs, and you should see your new toolbar on the screen. (You can drag it wherever you would like using the left-side of the toolbar.) Open a resource and click your button to toggle the zoom factor back and forth. (You can edit the script code you pasted to choose something other than 200%, too.)

On Facebook? Join the Discussion

2 Responses to “Toggling Zoom with a Custom Toolbar”

  1. Richard L August 30, 2005 at 10:33 am #

    Thanks for that, Bob. I can use this same outline for some other coding ideas that require access to the active window.
    Thanks
    Richard

  2. Reid Curry September 3, 2005 at 11:44 pm #

    Thanks. I am currently learning Java and this was a cool little script.
    ~ Reid