GRIDPLUS2 - Example 4
Home Reference Manpage Examples Download License Contact

An Example Using Notebook, Images and Nested Widget Grids

Windows:


Source Code:

package require gridplus 2.4
namespace import gridplus::*

option add *Gridplus.widgetWidth 16

gridplus widget .preferences -space 0 {
   {"^E-mail"}   {=}
   {:mail16}     {"Change the apperence of messages and the way they are handled."}
   {}            {|&b "Junk E-mail..." .junk-email |: "E-mail Options..." .email-options |:}
   {"^Calendar"} {=}
   {:caltoday16} {"Customize the appearance of the Calendar."}
   {}            {&c .default-reminder "Default Reminder: " |> &d .default-reminder-time |: &b "Calendar Options..." .calendar-options}
   {"^Tasks"}    {=}
   {:caltodo16}  {"Change the appearance of tasks."}
   {}            {"Reminder time: " |> &d .reminder-time |: &b "Task Options..." .task-options}
}

gridplus widget .security -space 0 {
   {"^Encrypted E-mail"} {=}
   {:actlock16}          {&c .encrypt "Encrypt contents and attachments for outgoing messages"}
   {}                    {&c .digital-signature "Add digital signature to outgoing messages"}
   {}                    {&c .send-clear-text "Send clear text signed message when sending signed messages"}
   {}                    {&c .request-receipt "Request S/MIME receipt for all S/MIME signed messages"}
   {}                    {"Default setting: " |> &d .default-setting |: &b "Settings..." .settings}
   {"^Security Zones"}   {=}
   {:appbrowser16}       {"Security zones allow you to customize whether scripts and active<n>content can be run in HTML messages"}
   {}                    {"Zone: " |> &d .zone-type |: &b "Zone Settings..." .zone-settings}
}

gridplus notebook .user {
   "Preferences" .preferences
   "Security"    .security
}

gridplus button .action -width 12 {
   {"Ok" .ok} {"Cancel" .cancel}
}

gridplus layout .main -wtitle "Options" {
   .user
   .action:e
}

pack .main


Comments:

package require gridplus 2.4
namespace import gridplus::*
Loads the GRIDPLUS package and imports the commands.
option add *Gridplus.widgetWidth 16

Sets option to set the default widget width to "16" characters.

gridplus widget .preferences -space 0 {
   {"^E-mail"}   {=}
   {:mail16}     {"Change the apperence of messages and the way they are handled."}
   {}            {|&b "Junk E-mail..." .junk-email |: "E-mail Options..." .email-options |:}
   {"^Calendar"} {=}
   {:caltoday16} {"Customize the appearance of the Calendar."}
   {}            {&c .default-reminder "Default Reminder: " |> &d .default-reminder-time |: &b "Calendar Options..." .calendar-options}
   {"^Tasks"}    {=}
   {:caltodo16}  {"Change the appearance of tasks."}
   {}            {"Reminder time: " |> &d .reminder-time |: &b "Task Options..." .task-options}
}
Creates a GRIDPLUS widget grid named ".preferences". The "-space" option sets the space between columns to be "0".

The "^" prefix used on "^E-mail", "^Calendar" and "^Tasks" causes the labels to be printed in a bold font. "=" creates a horizontal line. The ":" prefix used on ":mail16", ":caltoday16" and ":caltodo16" causes the the specified ICONS images to be displayed.

The "{|&b "Junk E-mail..." .junk-email |: "E-mail Options..." .email-options |:}" column creates an Embedded Grid where the default widget is button ("|&b"). The "|:" between the button columns specifies that the link between the buttons will not stretch. The "|:" at the end specifies that the contents of the Embedded Grid are right justified. Two buttons are created; ".junk-email" and ".email-options".

>> The buttons invoke procedures named preferences,junk-email and preferences,email-options.

The "{&c .default-reminder "Default Reminder: " |> &d .default-reminder-time |: &b "Calendar Options..." .calendar-options}" column creates an Embedded Grid. As the Embedded Grid contains a stretch link (":>") the contents of the grid is anchored to both the left and right sides of the column. The grid contains three columns; A checkbutton ("&c") named ".default-reminder", a dropdown list ("&d") named ".default-reminder-time" and a button ("&b") named ".calendar-options".

>> The checkbutton value is referenced as $(.preferences,default-reminder) and the dropdown as $(.preferences,default-reminder-time). The button invokes a procedure named preferences,calendar-options.

The "{"Reminder time: " |> &d .reminder-time |: &b "Task Options..." .task-options}" column creates an Embedded Grid. As the Embedded Grid contains a stretch link (":>") the contents of the grid is anchored to both the left and right sides of the column. The grid contains three columns; A label ("Reminder time:"), a dropdown list ("&d") named ".reminder-time" and a button ("&b") named ".task-options".

>> The dropdown value is referenced as $(.preferences,reminder-time). The button invokes a procedure named preferences,task-options.

Note: When it is required that a label terminates with a colon (":"), the colon must be followed by a space otherwise it will be treated as an anchor specification delimeter.

gridplus widget .security -space 0 {
   {"^Encrypted E-mail"} {=}
   {:actlock16}          {&c .encrypt "Encrypt contents and attachments for outgoing messages"}
   {}                    {&c .digital-signature "Add digital signature to outgoing messages"}
   {}                    {&c .send-clear-text "Send clear text signed message when sending signed messages"}
   {}                    {&c .request-receipt "Request S/MIME receipt for all S/MIME signed messages"}
   {}                    {"Default setting: " |> &d .default-setting |: &b "Settings..." .settings}
   {"^Security Zones"}   {=}
   {:appbrowser16}       {"Security zones allow you to customize whether scripts and active<n>content can be run in HTML messages"}
   {}                    {"Zone: " |> &d .zone-type |: &b "Zone Settings..." .zone-settings}
}

Creates a GRIDPLUS widget grid named ".security". The "-space" option sets the space between columns to be "0".

The "^" prefix used on "^Encrypted E-mail" and "^Security Zones" causes the labels to be printed in a bold font. "=" creates a horizontal line. The ":" prefix used on ":actlock16" and ":appbrowser16" causes the the specified ICONS images to be displayed.

Four checkbuttons are created named ".encrypt", "digital-signature", ".send-clear-text" and ".request-receipt".

>> The checkbutton values are referenced as $(.security,encrypt), $(.security,digital-signature), $(.security,send-clear-text) and $(.security,request-receipt).

The "{"Default setting: " |> &d .default-setting |: &b "Settings..." .settings}" column creates an Embedded Grid. As the Embedded Grid contains a stretch link (":>") the contents of the grid is anchored to both the left and right sides of the column. The grid contains three columns; a label ("Default setting:"), a dropdown list ("&d") named ".default-setting" and a button ("&b") named ".settings".

>> The dropdown list value is referenced as $(.security,default-setting). The button invokes a procedure named security,settings.

The "<n>" in the "{"Security zones allow you to customize whether scripts and active<n>content can be run in HTML messages"} column causes the following text to be on a new line.

The "{"Zone: " |> &d .zone-type |: &b "Zone Settings..." .zone-settings}" column creates an Embedded Grid. As the Embedded Grid contains a stretch link (":>") the contents of the grid is anchored to both the left and right sides of the column. The grid contains three columns; a label ("Zone:"), a dropdown list ("&d") named ".zone-type" and a button ("&b") named ".zone-settings".

The nested embedded grids are required to allow the "Zone:" label to be aligned to the left of the column, while The dropdown and the button are aligned to the right of the column directly under those in an above row.

>> The dropdown value is referenced as $(.security,zone-type). The button invokes a procedure named security,settings.

gridplus notebook .user {
   "Preferences" .preferences
   "Security"    .security
}

Creates a GRIDPLUS notebook named ".user" with two pages; One labeled "Preferences" which contains the ".preferences" grid, the other labeled "Security" which contains the ".security" grid.

gridplus button .action -width 12 {
   {"Ok" .ok} {"Cancel" .cancel}
}

Creates a GRIDPLUS button grid width two buttons; "Ok" and "Cancel" each with a "-width" of "12" characters.

>> The buttons invoke procedures called action,ok and action,cancel.

gridplus layout .main -wtitle "Options" {
   .user
   .action:e
}

Creates a grid of GRIDPLUS layout named ".main".

The "-wtitle" option sets the name of the window to "Options". The ".user" notebook is above the ".action" buttons. The buttons are anchored to the east (right) side of the layout (":e").

pack .main
Packs the ".main" layout.


Copyright © 2008 Adrian Davis.