#!/bin/sh
# the next line restarts using wish \
exec tclsh "$0" "$@"

# this example shows all stock bitmaps for buttons and menuitems
load ../src/gnocl.so

set top [gnocl::window -title "Widget Test Window"]
set box [gnocl::box -orientation vertical -homogeneous 0]
$top configure -child $box

set menubar [gnocl::menubar]
$box addBegin $menubar

set stockMenuItems [lsort { "New" "Save" "Save As" "Revert" "Open" \
      "Close" "Quit" "Cut" "Copy" "Paste" "Properties" \
      "Preferences" "About" "Scores" "Undo" "Redo" "Print" \
      "Search" "Search/Replace" "Back" "Forward" "First" "Last"\
      "Home" "Stop" "Refresh" "Mail" "Receive Mail" "Send Mail" \
      "Reply to Mail" "Forward Mail" "New Mail" "Trash" "Trash Full" \
      "Undelete" "Timer" "Timer Stopped" "Spellchecker" "Microphone" \
      "Line In" "Cdrom" "Volume" "Midi" "Book Red" "Book Green" \
      "Book Blue" "Book Yellow" "Book Open" "Convert" "Jump To" \
      "Up" "Down" "Top" "Bottom" "Attach" "Index" "Font" "Exec" } ]

for { set k 0 } { $k < [llength $stockMenuItems] } { incr k } {
   if { $k % 10 == 0 } {
      set menu [gnocl::menu]
      set start [lindex $stockMenuItems $k]
      set end [lindex $stockMenuItems [expr {$k+9}]]
      $menubar addBegin [gnocl::menuItem label -text "$start - $end " \
            -submenu $menu]
   }
   set el [lindex $stockMenuItems $k]
   $menu add [gnocl::menuItem label -text "%#$el" -command "puts $el"]
}

# gnocl::box .box2 -orientation horizontal 
set stockButtons { "Ok" "Cancel" "Yes" "No" "Close" "Apply" \
      "Next" "Prev" "Up" "Down" "Help" "Font" }
for { set k 0 } { $k < [llength $stockButtons] } { incr k }  {
   if { $k % 4 == 0 } {
      set boxHor [gnocl::box -orientation horizontal -homogeneous 1]
      $box add $boxHor
   }
   set el [lindex $stockButtons $k]
   $boxHor add [gnocl::button -text "%#$el" -command "puts $el"] 
}

set statusbar [gnocl::statusbar]
$box addBegin $statusbar

set stockPixmaps { "New" "Open" "Close" "Revert" "Save" "Save As" \
      "Cut" "Copy" "Paste" "Clear" "Properties" "Preferences" \
      "Help" "Scores" "Print" "Search" "Search/Replace" "Back" \
      "Forward" "First" "Last" "Home" "Stop" "Refresh" "Undo" \
      "Redo" "Timer" "Timer Stopped" "Mail" "Receive Mail" \
      "Send Mail" "Reply to Mail" "Forward Mail" "New Mail" "Trash" \
      "Trash Full" "Undelete" "Spellchecker" "Microphone" "Line In" \
      "Cdrom" "Volume" "Midi" "Book Red" "Book Green" "Book Blue" \
      "Book Yellow" "Book Open" "About" "Quit" "Multiple" "Not" \
      "Convert" "Jump To" "Up" "Down" "Top" "Bottom" "Attach" \
      "Index" "Font" "Exec" "Left" "Right" "Center" "Justify" \
      "Bold" "Italic" "Underline" "Strikeout" "Text Indent" \
      "Text Unindent" "Color Select" "Add" "Remove" "Table Borders" \
      "Table Fill" "Text Bulleted List" "Text Numbered List" }
      # "regular" "disabled" "focused" 
for { set k 0 } { $k < [llength $stockPixmaps] } { incr k }  {
   if { $k % 10 == 0 } {
      set toolbar [gnocl::toolbar -style both]
      $box add $toolbar
   }
   set el [lindex $stockPixmaps $k]
   $toolbar add item -text $el -icon %#$el -tooltip $el \
             -tooltip_private "Tooltip_private $el"
}

if { [info exists tk_patchLevel] } {
   wm withdraw .
} else {
   gnocl::mainLoop
}

