[Gnocl -the Tcl/Gtk Bindings] gnocl::widget - new command 'attach'

6 views
Skip to first unread message

William J Giddings

unread,
Nov 13, 2013, 1:32:01 PM11/13/13
to gn...@googlegroups.com
The menu widget allows for the organization of menu items into rows and columns. This can now be achieved using the 'attach' sub-command. Where required, menu items can be allow to span multiple rows or columns. The syntax for this this command is:

<widget-id> attach <menuitem-id> row col <options>

The possible options are -rowSpan (int) and -colSpan (int). 

Menu items are only expanded to fill actual rows and columns. So, if the last item requests a spacing of 2 rows, it will only be allocated the space required for its default rendering.

Modifications available in nightly build.

The following test code shows this in operation:

# test-menu-attach.tcl
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"


package require Gnocl

set menu [gnocl::menu]

$menu add [gnocl::menuItem -text "%#New" -onClicked {puts "That's new"}]
$menu add [gnocl::menuSeparator]
$menu add [gnocl::menuItem -text "%#Quit" -onClicked exit ]

set file [gnocl::menuItem -text "%__File" -submenu $menu]

set menu [gnocl::menu]

$menu add [gnocl::menuItem -text "%__About" -onClicked {puts "Menu example"}]

set help [gnocl::menuItem -text "%__Help" -submenu $menu]
set box [gnocl::box -orientation vertical -borderWidth 0 -spacing 0]


set extras_menu [gnocl::menu]
set extras  [gnocl::menuItem -text "%__Extras" -submenu $extras_menu]

$box add [gnocl::menuBar  -children [list $file $help $extras]]

set em(1) [gnocl::menuItem -text FIRST]
set em(2) [gnocl::menuItem -text SECOND]
set em(3) [gnocl::menuItem -text THIRD]
set em(4) [gnocl::menuItem -text FOURTH]
set em(5) [gnocl::menuItem -text FIFTH]
set em(6) [gnocl::menuItem -text SIXTH]
set em(7) [gnocl::menuItem -text SEVENTH]
set em(8) [gnocl::menuItem -text EIGTH]
set em(9) [gnocl::menuItem -text NINTH]

$extras_menu attach $em(1) 0 0
$extras_menu attach $em(2) 0 1
$extras_menu attach $em(3) 1 0 -colSpan 2
$extras_menu attach $em(4) 2 0
$extras_menu attach $em(5) 3 0 -rowSpan 2
$extras_menu attach $em(6) 4 1
$extras_menu attach $em(7) 5 0 -rowSpan 2 -colSpan 2
$extras_menu attach $em(8) 5 2
$extras_menu attach $em(8) 6 2

gnocl::window  -child $box -setSize 0.2

gnocl::mainLoop





--
Posted By William J Giddings to Gnocl -the Tcl/Gtk Bindings on 11/13/2013 06:31:00 pm
Reply all
Reply to author
Forward
0 new messages