Difference between revisions of "RibbonControl"

From wiki.visual-prolog.com

(Initial)
 
m (release)
Line 1: Line 1:
{{Preliminary Documentation}}
The <vp>ribbonControl</vp>
The <vp>ribbonControl</vp>



Revision as of 20:47, 24 November 2012

The ribbonControl

Ribbon Demo

The Ribbon Demo project illustrates how to develop applications using the Ribbon and Command packages of pfc/gui.

RibbonDemo.png

Commands provide a convenient and abstract way of encapsulating end-user actions/operations/features.

Example A simple command that invokes a specific operation

clauses
        ...
        ChangeOrgUnitCmd=command::new(This,"system/organization/change"),
        ChangeOrgUnitCmd:menuLabel:="Organization",
        ChangeOrgUnitCmd:icon:=some(icon::createFromImages(
            [bitmap::createFromBinary(#binInclude(@"Icons\Organization16.png")),
            bitmap::createFromBinary(#binInclude(@"Icons\Organization32.png"))])),
        ChangeOrgUnitCmd:tipText:=tooltip::tip("Change Organizational Settings"),
        ChangeOrgUnitCmd:run:=onCmdRun,
        ...

Commands feature all required properties for presentation and operation.

Command objects can be included and referenced from menus and ribbon controls. The Action popup menu is constructed as a menuCommand,

clauses
        ...
        MenuCmd=menuCommand::new(This,"actions"),
        MenuCmd:menuLabel:="Actions",
        MenuCmd:style:= popupMenu,
        MenuCmd:icon:=some(icon::createFromImages(
            [bitmap::createFromBinary(#binInclude(@"Icons\Reports16.png")),
            bitmap::createFromBinary(#binInclude(@"Icons\Reports32.png"))])),
        MenuCmd:layout:= menuStatic(
            [cmd(ChangeOrgUnitCmd),
            separator,
            cmd(OptionMenuCmd)]),
        ...

RibbonDemoOrganization.png

Note how the command icons are used in menus as well.

Three kinds of menuCommands are supported:

popupMenu
A traditional menu from which user can choose a command
toolMenu
The menu items are considered tools. When user picks a tool the ribbon button changes to this tool such that repeative uses are simplified. Tool can be altered by opening menu and selecting another one.
variantMenu
The menu items are variations of a common, super command. If menu is reduced to a single variant the ribbon button looks and behaves just like an ordinary command button, i.e. no dropdown triangle and command is executed by clicking button.

Variant menus can be aggregated/gathered automatically by declaratively stating which categories of commands constitute a metaCommand. Typically this is used for actions and clipboard commands. A number of New actions may be supported by various UI components of a form. Instead of presenting all these as separate ribbon buttons a metaCommand can be defined

clauses
        ...
        ActionNewCmd = metaCommand::new(This,"action/new"),
        ActionNewCmd:category := ["action/new"],
        ActionNewCmd:menuLabel:="New",
        ActionNewCmd:icon:=some(icon::createFromImages(
            [bitmap::createFromBinary(#binInclude(@"Icons\NewPane16.png")),
            bitmap::createFromBinary(#binInclude(@"Icons\NewPane32.png"))])),
        ...

The category property defines the criteria that New commands should satisfy in order to be included in variantMenu. Initially our demo form supports two commands that are to be considered New commands,

clauses
        ...
        CallinActionNewCmd:category := ["action/new"],
        PersonActionNewCmd:category := ["action/new"],
        ...

RibbonDemoNew.png

By clicking on/off button we disable one of them. The New button immediately becomes an ordinary looking command button for the only remaining variant command New Person

RibbonDemoNewPerson.png

If New CallIn is later re-enabled or other commands with matching category are defined the button will again appear as a menu button with dropdown option.

When Command state properties (visible, enabled, labels, icons) are changed, menus and ribbons react immediately.

RibbonDemoStateChange.png

Toggle/Check buttons are supported by the checkCommand.

RibbonDemoOnOff.png


A checkStateChange event is supported on these commands. The current check state can be read and set directly on Command as a property. If check state is updated all uses of this command reflects change.

The customCommand allows all pfc/gui Controls to be embedded in Ribbons. Popup menu does currently not support customCommands. The demo shows how an editControl can easily be embedded in ribbons.

Designer

The ribbon control furthermore features a rich, visual Designer. Try clicking the Design button and customize the demo ribbon to your likings.