home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / winMenu.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  32.9 KB  |  1,031 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test menus in Tk.  It is
  2. # organized in the standard fashion for Tcl tests. This
  3. # file tests the Macintosh-specific features of the menu
  4. # system.
  5. #
  6. # Copyright (c) 1995-1996 Sun Microsystems, Inc.
  7. #
  8. # See the file "license.terms" for information on usage and redistribution
  9. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10. #
  11. # SCCS: @(#) winMenu.test 1.19 97/07/02 11:29:57
  12.  
  13. if {$tcl_platform(platform) != "windows"} {
  14.     return
  15. }
  16.  
  17. if {![info exists INTERACTIVE]} {
  18.     puts " Some tests were skipped because they could not be performed"
  19.     puts " automatically on this platform. If you wish to execute them"
  20.     puts " interactively, set the TCL variable INTERACTIVE and re-run"
  21.     puts " the test."
  22.     set testConfig(menuInteractive) 0
  23. } else {
  24.     set testConfig(menuInteractive) 1
  25. }
  26.  
  27. if {[lsearch [image types] test] < 0} {
  28.     puts "This application hasn't been compiled with the \"test\" image"
  29.     puts "type, so I can't run this test.  Are you sure you're using"
  30.     puts "tktest instead of wish?"
  31.     return
  32. }
  33.  
  34. if {[info procs test] != "test"} {
  35.     source defs
  36. }
  37.  
  38. proc deleteWindows {} {
  39.     foreach i [winfo children .] {
  40.         catch [destroy $i]
  41.     }
  42. }
  43.  
  44. deleteWindows
  45. wm geometry . {}
  46. raise .
  47.  
  48. test winMenu-1.1 {GetNewID} {
  49.     catch {destroy .m1}
  50.     list [catch {menu .m1} msg] $msg [destroy .m1]
  51. } {0 .m1 {}}
  52. # Basically impossible to test menu IDs wrapping.
  53.  
  54. test winMenu-2.1 {FreeID} {
  55.     catch {destroy .m1}
  56.     menu .m1
  57.     list [catch {destroy .m1} msg] $msg
  58. } {0 {}}
  59.  
  60. test winMenu-3.1 {TkpNewMenu} {
  61.     catch {destroy .m1}
  62.     list [catch {menu .m1} msg] $msg [catch {destroy .m1} msg2] $msg2
  63. } {0 .m1 0 {}}
  64. test winMenu-3.2 {TkpNewMenu} {
  65.     catch {destroy .m1}
  66.     . configure -menu ""
  67.     menu .m1
  68.     .m1 add command -label "foo"
  69.     list [catch {. configure -menu .m1} msg] $msg [. configure -menu ""] [catch {destroy .m1} msg2] $msg2
  70. } {0 {} {} 0 {}}
  71.  
  72. test winMenu-4.1 {TkpDestroyMenu} {
  73.     catch {destroy .m1}
  74.     menu .m1
  75.     list [catch {destroy .m1} msg] $msg
  76. } {0 {}}
  77. test winMenu-4.2 {TkpDestroyMenu - help menu} {
  78.     catch {destroy .m1}
  79.     menu .m1
  80.     .m1 add cascade -menu .m1.system
  81.     . configure -menu .m1
  82.     list [catch {destroy .m1.system} msg] $msg [. configure -menu ""] [destroy .m1]
  83. } {0 {} {} {}}
  84.  
  85. test winMenu-5.1 {TkpDestroyMenuEntry} {
  86.     catch {destroy .m1}
  87.     . configure -menu ""
  88.     menu .m1
  89.     .m1 add command -label "test"
  90.     update idletasks
  91.     list [catch {.m1 delete 1} msg] $msg [destroy .m1]
  92. } {0 {} {}}
  93.  
  94. test winMenu-6.1 {GetEntryText} {
  95.     catch {destroy .m1}
  96.     list [catch {menu .m1} msg] $msg [destroy .m1]
  97. } {0 .m1 {}}
  98. test winMenu-6.2 {GetEntryText} {
  99.     catch {destroy .m1}
  100.     catch {image delete image1}
  101.     menu .m1
  102.     image create test image1
  103.     list [catch {.m1 add command -image image1} msg] $msg [destroy .m1] [image delete image1]
  104. } {0 {} {} {}}
  105. test winMenu-6.3 {GetEntryText} {
  106.     catch {destroy .m1}
  107.     menu .m1
  108.     list [catch {.m1 add command -bitmap questhead} msg] $msg [destroy .m1]
  109. } {0 {} {}}
  110. test winMenu-6.4 {GetEntryText} {
  111.     catch {destroy .m1}
  112.     menu .m1
  113.     list [catch {.m1 add command} msg] $msg [destroy .m1]
  114. } {0 {} {}}
  115. test winMenu-6.5 {GetEntryText} {
  116.     catch {destroy .m1}
  117.     menu .m1
  118.     list [catch {.m1 add command -label "foo"} msg] $msg [destroy .m1]
  119. } {0 {} {}}
  120. test winMenu-6.6 {GetEntryText} {
  121.     catch {destroy .m1}
  122.     menu .m1
  123.     list [catch {.m1 add command -label "This string has one & in it"} msg] $msg [destroy .m1]
  124. } {0 {} {}}
  125. test winMenu-6.7 {GetEntryText} {
  126.     catch {destroy .m1}
  127.     menu .m1
  128.     list [catch {.m1 add command -label "The & should be underlined." -underline 4} msg] $msg [destroy .m1]
  129. } {0 {} {}}
  130. test winMenu-6.8 {GetEntryText} {
  131.     catch {destroy .m1}
  132.     menu .m1
  133.     list [catch {.m1 add command -label "The * should be underlined." -underline 4} msg] $msg [destroy .m1]
  134. } {0 {} {}}
  135. test winMenu-6.9 {GetEntryText} {
  136.     catch {destroy .m1}
  137.     menu .m1
  138.     list [catch {.m1 add command -label "foo" -accel "bar"} msg] $msg [destroy .m1]
  139. } {0 {} {}}
  140. test winMenu-6.10 {GetEntryText} {
  141.     catch {destroy .m1}
  142.     menu .m1
  143.     list [catch {.m1 add command -label "This string has one & in it" -accel "bar"} msg] $msg [destroy .m1]
  144. } {0 {} {}}
  145. test winMenu-6.11 {GetEntryText} {
  146.     catch {destroy .m1}
  147.     menu .m1
  148.     list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1]
  149. } {0 {} {}}
  150. test winMenu-6.12 {GetEntryText} {
  151.     catch {destroy .m1}
  152.     menu .m1
  153.     list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1]
  154. } {0 {} {}}
  155. test winMenu-6.13 {GetEntryText} {
  156.     catch {destroy .m1}
  157.     menu .m1
  158.     list [catch {.m1 add command -label "foo" -accel "&bar"} msg] $msg [destroy .m1]
  159. } {0 {} {}}
  160. test winMenu-6.14 {GetEntryText} {
  161.     catch {destroy .m1}
  162.     menu .m1
  163.     list [catch {.m1 add command -label "This string has one & in it" -accel "&bar"} msg] $msg [destroy .m1]
  164. } {0 {} {}}
  165. test winMenu-6.15 {GetEntryText} {
  166.     catch {destroy .m1}
  167.     menu .m1
  168.     list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1]
  169. } {0 {} {}}
  170. test winMenu-6.16 {GetEntryText} {
  171.     catch {destroy .m1}
  172.     menu .m1
  173.     list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1]
  174. } {0 {} {}}
  175.  
  176. test winMenu-7.1 {ReconfigureWindowsMenu - system menu item removal} {
  177.     catch {destroy .m1}
  178.     menu .m1
  179.     .m1 add cascade -menu .m1.system
  180.     menu .m1.system
  181.     .m1.system add command -label foo
  182.     update idletasks
  183.     .m1.system add command -label bar
  184.     list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
  185. } {0 {} {} {}}
  186. test winMenu-7.2 {ReconfigureWindowsMenu - menu item removal} {
  187.     catch {destroy .m1}
  188.     menu .m1
  189.     .m1 add command -label Hello
  190.     update idletasks
  191.     .m1 add command -label foo
  192.     list [catch {update idletasks} msg] $msg [destroy .m1]
  193. } {0 {} {}}
  194. test winMenu-7.3 {ReconfigureWindowsMenu - zero items} {
  195.     catch {destroy .m1}
  196.     menu .m1 -tearoff 0
  197.     .m1 add command -label Hello
  198.     .m1 delete Hello
  199.     list [catch {update idletasks} msg] $msg [destroy .m1]
  200. } {0 {} {}}
  201. test winMenu-7.4 {ReconfigureWindowsMenu - one item} {
  202.     catch {destroy .m1}
  203.     menu .m1 -tearoff 0
  204.     .m1 add command -label Hello
  205.     list [catch {update idletasks} msg] $msg [destroy .m1]
  206. } {0 {} {}}
  207. test winMenu-7.5 {ReconfigureWindowsMenu - two items} {
  208.     catch {destroy .m1}
  209.     menu .m1 -tearoff 0
  210.     .m1 add command -label One
  211.     .m1 add command -label Two
  212.     list [catch {update idletasks} msg] $msg [destroy .m1]
  213. } {0 {} {}}
  214. test winMenu-7.6 {ReconfigureWindowsMenu - separator item} {
  215.     catch {destroy .m1}
  216.     menu .m1 -tearoff 0
  217.     .m1 add separator
  218.     list [catch {update idletasks} msg] $msg [destroy .m1]
  219. } {0 {} {}}
  220. test winMenu-7.7 {ReconfigureWindowsMenu - non-text item} {
  221.     catch {destroy .m1}
  222.     menu .m1 -tearoff 0
  223.     .m1 add command -label Hello
  224.     list [catch {update idletasks} msg] $msg [destroy .m1]
  225. } {0 {} {}}
  226. test winMenu-7.8 {ReconfigureWindowsMenu - disabled item} {
  227.     catch {destroy .m1}
  228.     menu .m1 -tearoff 0
  229.     .m1 add command -label Hello -state disabled
  230.     list [catch {update idletasks} msg] $msg [destroy .m1]
  231. } {0 {} {}}
  232. test winMenu-7.9 {ReconfigureWindowsMenu - non-selected checkbutton} {
  233.     catch {destroy .m1}
  234.     menu .m1 -tearoff 0
  235.     .m1 add checkbutton -label Hello
  236.     list [catch {update idletasks} msg] $msg [destroy .m1]
  237. } {0 {} {}}
  238. test winMenu-7.10 {ReconfigureWindowsMenu - non-selected radiobutton} {
  239.     catch {destroy .m1}
  240.     menu .m1 -tearoff 0
  241.     .m1 add radiobutton -label Hello
  242.     list [catch {update idletasks} msg] $msg [destroy .m1]
  243. } {0 {} {}}
  244. test winMenu-7.11 {ReconfigureWindowsMenu - selected checkbutton} {
  245.     catch {destroy .m1}
  246.     menu .m1 -tearoff 0
  247.     .m1 add checkbutton -label Hello
  248.     .m1 invoke Hello
  249.     list [catch {update idletasks} msg] $msg [destroy .m1]
  250. } {0 {} {}}
  251. test winMenu-7.12 {ReconfigureWindowsMenu - selected radiobutton} {
  252.     catch {destroy .m1}
  253.     menu .m1 -tearoff 0
  254.     .m1 add radiobutton -label Hello
  255.     .m1 invoke Hello
  256.     list [catch {update idletasks} msg] $msg [destroy .m1]
  257. } {0 {} {}}
  258. test winMenu-7.13 {ReconfigureWindowsMenu - cascade missing} {
  259.     catch {destroy .m1}
  260.     menu .m1 -tearoff 0
  261.     .m1 add cascade -label Hello
  262.     list [catch {update idletasks} msg] $msg [destroy .m1]
  263. } {0 {} {}}
  264. test winMenu-7.14 {ReconfigureWindowsMenu - cascade} {
  265.     catch {destroy .m1}
  266.     catch {destroy .m2}
  267.     menu .m1 -tearoff 0
  268.     menu .m2
  269.     .m1 add cascade -menu .m2 -label Hello
  270.     list [catch {update idletasks} msg] $msg [destroy .m1] [destroy .m2]
  271. } {0 {} {} {}}
  272. test winMenu-7.15 {ReconfigureWindowsMenu - menubar without system menu} {
  273.     catch {destroy .m1}
  274.     menu .m1 -tearoff 0
  275.     .m1 add cascade -menu .m1.file
  276.     menu .m1.file -tearoff 0
  277.     . configure -menu .m1
  278.     list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
  279. } {0 {} {} {}}
  280. test winMenu-7.16 {ReconfigureWindowsMenu - system menu already created} {
  281.     catch {destroy .m1}
  282.     menu .m1 -tearoff 0
  283.     .m1 add cascade -menu .m1.system
  284.     menu .m1.system -tearoff 0
  285.     . configure -menu .m1
  286.     update idletasks
  287.     .m1.system add command -label Hello
  288.     list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
  289. } {0 {} {} {}}
  290. test winMenu-7.17 {ReconfigureWindowsMenu - system menu update pending} {
  291.     catch {destroy .m1}
  292.     menu .m1 -tearoff 0
  293.     .m1 add cascade -menu .m1.system
  294.     menu .m1.system -tearoff 0
  295.     . configure -menu .m1
  296.     list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
  297. } {0 {} {} {}}
  298. test winMenu-7.18 {ReconfigureWindowsMenu - system menu update not pending} {
  299.     catch {destroy .m1}
  300.     menu .m1 -tearoff 0
  301.     .m1 add cascade -menu .m1.system
  302.     menu .m1.system -tearoff 0
  303.     .m1.system add command -label Hello
  304.     update idletasks
  305.     . configure -menu .m1
  306.     list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
  307. } {0 {} {} {}}
  308. test winMenu-7.19 {ReconfigureWindowsMenu - column break} {
  309.     catch {destroy .m1}
  310.     menu .m1 -tearoff 0
  311.     .m1 add command -label one
  312.     .m1 add command -label two -columnbreak 1
  313.     list [catch {update idletasks} msg] $msg [destroy .m1]
  314. } {0 {} {}}
  315.  
  316. #Don't know how to generate nested post menus
  317. test winMenu-8.1 {TkpPostMenu} {
  318.     catch {destroy .m1}
  319.     menu .m1 -postcommand "blork"
  320.     list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
  321. } {1 {invalid command name "blork"} {}}
  322. test winMenu-8.2 {TkpPostMenu} {
  323.     catch {destroy .m1}
  324.     menu .m1 -postcommand "destroy .m1"
  325.     list [.m1 post 40 40] [winfo exists .m1]
  326. } {{} 0}
  327. test winMenu-8.3 {TkpPostMenu - popup menu} {menuInteractive} {
  328.     catch {destroy .m1}
  329.     menu .m1
  330.     .m1 add command -label "winMenu-8.3: Hit ESCAPE."
  331.     list [.m1 post 40 40] [destroy .m1]
  332. } {{} {}}
  333. test winMenu-8.4 {TkpPostMenu - menu button} {menuInteractive} {
  334.     catch {destroy .mb}
  335.     menubutton .mb -text test -menu .mb.menu
  336.     menu .mb.menu
  337.     .mb.menu add command -label "winMenu-8.4 - Hit ESCAPE."
  338.     pack .mb
  339.     list [tkMbPost .mb] [destroy .m1]
  340. } {{} {}}
  341. test winMenu-8.5 {TkpPostMenu - update not pending} {menuInteractive} {
  342.     catch {destroy .m1}
  343.     menu .m1
  344.     .m1 add command -label "winMenu-8.5 - Hit ESCAPE."
  345.     update idletasks
  346.     list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
  347. } {0 {} {}}
  348.  
  349. test winMenu-9.1 {TkpMenuNewEntry} {
  350.     catch {destroy .m1}
  351.     menu .m1
  352.     list [catch {.m1 add command} msg] $msg [destroy .m1]
  353. } {0 {} {}}
  354.  
  355. test winMenu-10.1 {TkwinMenuProc} {menuInteractive} {
  356.     catch {destroy .m1}
  357.     menu .m1
  358.     .m1 add command -label "winMenu-10.1: Hit ESCAPE."
  359.     list [.m1 post 40 40] [destroy .m1]
  360. } {{} {}}
  361.  
  362. # Can't generate a WM_INITMENU without a Tk menu yet.
  363. test winMenu-11.1 {TkWinHandleMenuEvent - WM_INITMENU} {menuInteractive} {
  364.     catch {destroy .m1}
  365.     catch {unset foo}
  366.     menu .m1 -postcommand "set foo test"
  367.     .m1 add command -label "winMenu-11.1: Hit ESCAPE."
  368.     list [.m1 post 40 40] [set foo] [unset foo] [destroy .m1]
  369. } {test test {} {}}
  370. test winMenu-11.2 {TkWinHandleMenuEvent - WM_COMMAND} {menuInteractive} {
  371.     catch {destroy .m1}
  372.     catch {unset foo}
  373.     menu .m1
  374.     .m1 add checkbutton -variable foo -label "winMenu-11.2: Please select this menu item."
  375.     list [.m1 post 40 40] [update] [set foo] [unset foo] [destroy .m1]
  376. } {{} {} 1 {} {}}
  377. # Can't test WM_MENUCHAR
  378. test winMenu-11.3 {TkWinHandleMenuEvent - WM_MEASUREITEM} {menuInteractive} {
  379.     catch {destroy .m1}
  380.     menu .m1
  381.     .m1 add command -label "winMenu-11.3: Hit ESCAPE."
  382.     list [.m1 post 40 40] [destroy .m1]
  383. } {{} {}}
  384. test winMenu-11.4 {TkWinHandleMenuEvent - WM_MEASUREITEM} {menuInteractive} {
  385.     catch {destroy .m1}
  386.     menu .m1
  387.     .m1 add checkbutton -label "winMenu-11.4: Hit ESCAPE" -hidemargin 1
  388.     list [.m1 post 40 40] [destroy .m1]
  389. } {{} {}}
  390. test winMenu-11.5 {TkWinHandleMenuEvent - WM_DRAWITEM} {menuInteractive} {
  391.     catch {destroy .m1}
  392.     menu .m1
  393.     .m1 add command -label "winMenu-11.5: Hit ESCAPE."
  394.     list [.m1 post 40 40] [destroy .m1]
  395. } {{} {}}
  396. test winMenu-11.6 {TkWinHandleMenuEvent - WM_DRAWITEM - item disabled} {menuInteractive} {
  397.     catch {destroy .m1}
  398.     menu .m1
  399.     .m1 add command -label "winMenu-11.6: Hit ESCAPE." -state disabled
  400.     list [.m1 post 40 40] [destroy .m1]
  401. } {{} {}}
  402. test winMenu-11.7 {TkWinHandleMenuEvent - WM_INITMENU - not pending} {menuInteractive} {
  403.     catch {destroy .m1}
  404.     menu .m1 -tearoff 0
  405.     .m1 add command -label "winMenu-11.7: Hit ESCAPE"
  406.     update idletasks
  407.     list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
  408. } {0 {} {}}
  409.  
  410. test winMenu-12.1 {TkpSetWindowMenuBar} {
  411.     catch {destroy .m1}
  412.     . configure -menu ""
  413.     menu .m1
  414.     .m1 add command -label foo
  415.     list [catch {. configure -menu .m1} msg] $msg [. configure -menu ""] [catch {destroy .m1} msg2] $msg2
  416. } {0 {} {} 0 {}}
  417. test winMenu-12.2 {TkpSetWindowMenuBar} {
  418.     catch {destroy .m1}
  419.     . configure -menu ""
  420.     menu .m1
  421.     .m1 add command -label foo
  422.     . configure -menu .m1
  423.     list [catch {. configure -menu ""} msg] $msg [catch {destroy .m1} msg2] $msg2
  424. } {0 {} 0 {}}
  425. test winMenu-12.3 {TkpSetWindowMenuBar - no update pending} {
  426.     catch {destroy .m1}
  427.     . configure -menu ""
  428.     menu .m1 -tearoff 0
  429.     .m1 add command -label foo
  430.     update idletasks
  431.     list [catch {. configure -menu .m1} msg] $msg [. configure -menu ""] [destroy .m1]
  432. } {0 {} {} {}}
  433.  
  434. test winMenu-13.1 {TkpSetMainMenubar - nothing to do} {} {}
  435.  
  436. test winMenu-14.1 {GetMenuIndicatorGeometry} {
  437.     catch {destroy .m1}
  438.     menu .m1
  439.     .m1 add checkbutton -label foo
  440.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  441. } {0 {}}
  442. test winMenu-14.2 {GetMenuIndicatorGeometry} {
  443.     catch {destroy .m1}
  444.     menu .m1
  445.     .m1 add checkbutton -label foo -hidemargin 1
  446.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  447. } {0 {}}
  448.  
  449. test winMenu-15.1 {GetMenuAccelGeometry} {
  450.     catch {destroy .m1}
  451.     menu .m1
  452.     .m1 add cascade -label foo -accel Ctrl+U
  453.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  454. } {0 {}}
  455. test winMenu-15.2 {GetMenuAccelGeometry} {
  456.     catch {destroy .m1}
  457.     menu .m1
  458.     .m1 add command -label foo
  459.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  460. } {0 {}}
  461. test winMenu-15.3 {GetMenuAccelGeometry} {
  462.     catch {destroy .m1}
  463.     menu .m1
  464.     .m1 add command -label foo -accel "Ctrl+U"
  465.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  466. } {0 {}}
  467.  
  468. test winMenu-16.1 {GetTearoffEntryGeometry} {menuInteractive} {
  469.     catch {destroy .m1}
  470.     menu .m1
  471.     .m1 add command -label "winMenu-19.1: Hit ESCAPE."
  472.     list [.m1 post 40 40] [destroy .m1]
  473. } {{} {}}
  474.  
  475. test winMenu-17.1 {GetMenuSeparatorGeometry} {
  476.     catch {destroy .m1}
  477.     menu .m1
  478.     .m1 add separator
  479.     list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
  480. } {0 {}}
  481.  
  482. # Currently, the only callers to DrawWindowsSystemBitmap want things
  483. # centered vertically, and either centered or right aligned horizontally.
  484. test winMenu-18.1 {DrawWindowsSystemBitmap - center aligned} {
  485.     catch {destroy .m1}
  486.     menu .m1
  487.     .m1 add checkbutton -label foo
  488.     .m1 invoke foo
  489.     set tearoff [tkTearOffMenu .m1 40 40]
  490.     list [update] [destroy .m1]
  491. } {{} {}}
  492. test winMenu-18.2 {DrawWindowsSystemBitmap - right aligned} {
  493.     catch {destroy .m1}
  494.     menu .m1
  495.     .m1 add cascade -label foo
  496.     set tearoff [tkTearOffMenu .m1 40 40]
  497.     list [update] [destroy .m1]
  498. } {{} {}}
  499.  
  500. test winMenu-19.1 {DrawMenuEntryIndicator - not checkbutton or radiobutton} {
  501.     catch {destroy .m1}
  502.     menu .m1
  503.     .m1 add command -label foo
  504.     set tearoff [tkTearOffMenu .m1 40 40]
  505.     list [update] [destroy .m1]
  506. } {{} {}}
  507. test winMenu-19.2 {DrawMenuEntryIndicator - not selected} {
  508.     catch {destroy .m1}
  509.     menu .m1
  510.     .m1 add checkbutton -label foo
  511.     set tearoff [tkTearOffMenu .m1 40 40]
  512.     list [update] [destroy .m1]
  513. } {{} {}}
  514. test winMenu-19.3 {DrawMenuEntryIndicator - checkbutton} {
  515.     catch {destroy .m1}
  516.     menu .m1
  517.     .m1 add checkbutton -label foo
  518.     .m1 invoke foo
  519.     set tearoff [tkTearOffMenu .m1 40 40]
  520.     list [update] [destroy .m1]
  521. } {{} {}}
  522. test winMenu-19.4 {DrawMenuEntryIndicator - radiobutton} {
  523.     catch {destroy .m1}
  524.     menu .m1
  525.     .m1 add radiobutton -label foo
  526.     .m1 invoke foo
  527.     set tearoff [tkTearOffMenu .m1 40 40]
  528.     list [update] [destroy .m1]
  529. } {{} {}}
  530. test winMenu-19.5 {DrawMenuEntryIndicator - disabled} {
  531.     catch {destroy .m1}
  532.     menu .m1
  533.     .m1 add checkbutton -label foo
  534.     .m1 invoke foo
  535.     .m1 entryconfigure foo -state disabled
  536.     set tearoff [tkTearOffMenu .m1 40 40]
  537.     list [update] [destroy .m1]
  538. } {{} {}}
  539. test winMenu-19.6 {DrawMenuEntryIndicator - indicator not on} {
  540.     catch {destroy .m1}
  541.     menu .m1
  542.     .m1 add checkbutton -label foo -indicatoron 0
  543.     .m1 invoke foo
  544.     set tearoff [tkTearOffMenu .m1 40 40]
  545.     list [update] [destroy .m1]
  546. } {{} {}}
  547.  
  548. test winMenu-20.1 {DrawMenuEntryAccelerator - disabled} {
  549.     catch {destroy .m1}
  550.     menu .m1 -disabledforeground red
  551.     .m1 add command -label foo -accel "Ctrl+U" -state disabled
  552.     set tearoff [tkTearOffMenu .m1 40 40]
  553.     list [update] [destroy .m1]
  554. } {{} {}}
  555. test winMenu-20.2 {DrawMenuEntryAccelerator - normal text} {
  556.     catch {destroy .m1}
  557.     menu .m1
  558.     .m1 add command -label foo -accel "Ctrl+U"
  559.     set tearoff [tkTearOffMenu .m1 40 40]
  560.     list [update] [destroy .m1]
  561. } {{} {}}
  562. test winMenu-20.3 {DrawMenuEntryAccelerator - disabled, no disabledforeground} {
  563.     catch {destroy .m1}
  564.     menu .m1 -disabledforeground ""
  565.     .m1 add command -label foo -accel "Ctrl+U" -state disabled
  566.     set tearoff [tkTearOffMenu .m1 40 40]
  567.     list [update] [destroy .m1]
  568. } {{} {}}
  569. test winMenu-20.4 {DrawMenuEntryAccelerator - cascade, drawArrow true} {
  570.     catch {destroy .m1}
  571.     menu .m1
  572.     .m1 add cascade -label foo
  573.     set tearoff [tkTearOffMenu .m1 40 40]
  574.     list [update] [destroy .m1]
  575. } {{} {}}
  576. test winMenu-20.5 {DrawMenuEntryAccelerator - cascade, drawArrow false} {menuInteractive} {
  577.     catch {destroy .m1}
  578.     menu .m1
  579.     .m1 add cascade -label "winMenu-23.5: Hit ESCAPE."
  580.     list [.m1 post 40 40] [destroy .m1]
  581. } {{} {}}
  582.  
  583. test winMenu-21.1 {DrawMenuSeparator} {
  584.     catch {destroy .m1}
  585.     menu .m1
  586.     .m1 add separator
  587.     set tearoff [tkTearOffMenu .m1 40 40]
  588.     list [update] [destroy .m1]
  589. } {{} {}}
  590.  
  591. test winMenu-22.1 {DrawMenuUnderline} {
  592.     catch {destroy .m1}
  593.     menu .m1
  594.     .m1 add command -label foo -underline 0
  595.     set tearoff [tkTearOffMenu .m1 40 40]
  596.     list [update] [destroy .m1]
  597. } {{} {}}   
  598.  
  599. test winMenu-23.1 {Don't know how to test MenuKeyBindProc} {} {}
  600. test winMenu-24.1 {TkpInitializeMenuBindings called at boot time} {} {}
  601.  
  602. test winMenu-25.1 {DrawMenuEntryLabel - normal} {
  603.     catch {destroy .m1}
  604.     menu .m1
  605.     .m1 add command -label foo
  606.     set tearoff [tkTearOffMenu .m1 40 40]
  607.     list [update] [destroy .m1]
  608. } {{} {}}
  609. test winMenu-25.2 {DrawMenuEntryLabel - disabled with fg} {
  610.     catch {destroy .m1}
  611.     menu .m1 -disabledforeground red
  612.     .m1 add command -label foo -state disabled
  613.     set tearoff [tkTearOffMenu .m1 40 40]
  614.     list [update] [destroy .m1]
  615. } {{} {}}
  616. test winMenu-25.3 {DrawMenuEntryLabel - disabled with no fg} {
  617.     catch {destroy .m1}
  618.     menu .m1 -disabledforeground ""
  619.     .m1 add command -label foo -state disabled
  620.     set tearoff [tkTearOffMenu .m1 40 40]
  621.     list [update] [destroy .m1]
  622. } {{} {}}
  623.  
  624. test winMenu-26.1 {TkpComputeMenubarGeometry} {
  625.     catch {destroy .m1}
  626.     menu .m1
  627.     .m1 add cascade -label File
  628.     list [. configure -menu .m1] [. configure -menu ""] [destroy .m1]
  629. } {{} {} {}}
  630.  
  631. test winMenu-27.1 {DrawTearoffEntry} {menuInteractive} {
  632.     catch {destroy .m1}
  633.     menu .m1
  634.     .m1 add command -label "winMenu-24.4: Hit ESCAPE."
  635.     list [.m1 post 40 40] [destroy .m1]
  636. } {{} {}}
  637.  
  638. test winMenu-28.1 {TkpConfigureMenuEntry - update pending} {
  639.     catch {destroy .m1}
  640.     menu .m1 -tearoff 0
  641.     .m1 add command -label Hello
  642.     list [catch {.m1 add command -label Two} msg] $msg [destroy .m1]
  643. } {0 {} {}}
  644. test winMenu-28.2 {TkpConfigureMenuEntry - update not pending} {
  645.     catch {destroy .m1}
  646.     menu .m1 -tearoff 0
  647.     .m1 add command -label One
  648.     update idletasks
  649.     list [catch {.m1 add command -label Two} msg] $msg [destroy .m1]
  650. } {0 {} {}}
  651.  
  652. test winMenu-29.1 {TkpDrawMenuEntry - gc for active and not strict motif} {
  653.     catch {destroy .m1}
  654.     menu .m1
  655.     .m1 add command -label foo
  656.     set tearoff [tkTearOffMenu .m1 40 40]
  657.     .m1 entryconfigure 1 -state active
  658.     list [update] [destroy .m1]
  659. } {{} {}}
  660. test winMenu-29.2 {TkpDrawMenuEntry - gc for active menu item with its own gc} {
  661.     catch {destroy .m1}
  662.     menu .m1
  663.     .m1 add command -label foo -activeforeground red
  664.     set tearoff [tkTearOffMenu .m1 40 40]
  665.     .m1 entryconfigure 1 -state active
  666.     list [update] [destroy .m1]
  667. } {{} {}}
  668. test winMenu-29.3 {TkpDrawMenuEntry - gc for active and strict motif} {
  669.     catch {destroy .m1}
  670.     menu .m1
  671.     set tk_strictMotif 1
  672.     .m1 add command -label foo
  673.     set tearoff [tkTearOffMenu .m1 40 40]
  674.     .m1 entryconfigure 1 -state active
  675.     list [update] [destroy .m1] [set tk_strictMotif 0]
  676. } {{} {} 0}
  677. test winMenu-29.4 {TkpDrawMenuEntry - gc for disabled with disabledfg and custom entry} {
  678.     catch {destroy .m1}
  679.     menu .m1 -disabledforeground blue
  680.     .m1 add command -label foo -state disabled -background red
  681.     set tearoff [tkTearOffMenu .m1 40 40]
  682.     list [update] [destroy .m1]
  683. } {{} {}}
  684. test winMenu-29.5 {TkpDrawMenuEntry - gc for disabled with disabledFg} {
  685.     catch {destroy .m1}
  686.     menu .m1 -disabledforeground blue
  687.     .m1 add command -label foo -state disabled
  688.     set tearoff [tkTearOffMenu .m1 40 40]
  689.     list [update] [destroy .m1]
  690. } {{} {}}
  691. test winMenu-29.6 {TkpDrawMenuEntry - gc for disabled - no disabledFg} {
  692.     catch {destroy .m1}
  693.     menu .m1 -disabledforeground ""
  694.     .m1 add command -label foo -state disabled
  695.     set tearoff [tkTearOffMenu .m1 40 40]
  696.     list [update] [destroy .m1]
  697. } {{} {}}
  698. test winMenu-29.7 {TkpDrawMenuEntry - gc for normal - custom entry} {
  699.     catch {destroy .m1}
  700.     menu .m1
  701.     .m1 add command -label foo -foreground red
  702.     set tearoff [tkTearOffMenu .m1 40 40]
  703.     list [update] [destroy .m1]
  704. } {{} {}}
  705. test winMenu-29.8 {TkpDrawMenuEntry - gc for normal} {
  706.     catch {destroy .m1}
  707.     menu .m1
  708.     .m1 add command -label foo
  709.     set tearoff [tkTearOffMenu .m1 40 40]
  710.     list [update] [destroy .m1]
  711. } {{} {}}
  712. test winMenu-29.9 {TkpDrawMenuEntry - gc for indicator - custom entry} {
  713.     catch {destroy .m1}
  714.     menu .m1
  715.     .m1 add checkbutton -label foo -selectcolor orange
  716.     .m1 invoke 1
  717.     set tearoff [tkTearOffMenu .m1 40 40]
  718.     list [update] [destroy .m1]
  719. } {{} {}}
  720. test winMenu-29.10 {TkpDrawMenuEntry - gc for indicator} {
  721.     catch {destroy .m1}
  722.     menu .m1
  723.     .m1 add checkbutton -label foo
  724.     .m1 invoke 1
  725.     set tearoff [tkTearOffMenu .m1 40 40]
  726.     list [update] [destroy .m1]
  727. } {{} {}}
  728. test winMenu-29.11 {TkpDrawMenuEntry - border - custom entry} {
  729.     catch {destroy .m1}
  730.     menu .m1
  731.     .m1 add command -label foo -activebackground green
  732.     set tearoff [tkTearOffMenu .m1 40 40]
  733.     .m1 entryconfigure 1 -state active
  734.     list [update] [destroy .m1]
  735. } {{} {}}
  736. test winMenu-29.12 {TkpDrawMenuEntry - border} {
  737.     catch {destroy .m1}
  738.     menu .m1
  739.     .m1 add command -label foo
  740.     set tearoff [tkTearOffMenu .m1 40 40]
  741.     .m1 entryconfigure 1 -state active
  742.     list [update] [destroy .m1]
  743. } {{} {}}
  744. test winMenu-29.13 {TkpDrawMenuEntry - active border - strict motif} {
  745.     catch {destroy .m1}
  746.     set tk_strictMotif 1
  747.     menu .m1
  748.     .m1 add command -label foo
  749.     set tearoff [tkTearOffMenu .m1 40 40]
  750.     .m1 entryconfigure 1 -state active
  751.     list [update] [destroy .m1] [set tk_strictMotif 0]
  752. } {{} {} 0}
  753. test winMenu-29.14 {TkpDrawMenuEntry - active border - custom entry} {
  754.     catch {destroy .m1}
  755.     menu .m1
  756.     .m1 add command -label foo -activeforeground yellow
  757.     set tearoff [tkTearOffMenu .m1 40 40]
  758.     .m1 entryconfigure 1 -state active
  759.     list [update] [destroy .m1]
  760. } {{} {}}
  761. test winMenu-29.15 {TkpDrawMenuEntry - active border} {
  762.     catch {destroy .m1}
  763.     menu .m1
  764.     .m1 add command -label foo
  765.     set tearoff [tkTearOffMenu .m1 40 40]
  766.     .m1 entryconfigure 1 -state active
  767.     list [update] [destroy .m1]
  768. } {{} {}}
  769. test winMenu-29.16 {TkpDrawMenuEntry - font - custom entry} {
  770.     catch {destroy .m1}
  771.     menu .m1
  772.     .m1 add command -label foo -font "Helvectica 72"
  773.     set tearoff [tkTearOffMenu .m1 40 40]
  774.     list [update] [destroy .m1]
  775. } {{} {}}
  776. test winMenu-29.17 {TkpDrawMenuEntry - font} {
  777.     catch {destroy .m1}
  778.     menu .m1 -font "Courier 72"
  779.     .m1 add command -label foo
  780.     set tearoff [tkTearOffMenu .m1 40 40]
  781.     list [update] [destroy .m1]
  782. } {{} {}}
  783. test winMenu-29.18 {TkpDrawMenuEntry - separator} {
  784.     catch {destroy .m1}
  785.     menu .m1
  786.     .m1 add separator
  787.     set tearoff [tkTearOffMenu .m1 40 40]
  788.     list [update] [destroy .m1]
  789. } {{} {}}
  790. test winMenu-29.19 {TkpDrawMenuEntry - standard} {
  791.     catch {destroy .mb}
  792.     menu .m1
  793.     .m1 add command -label foo
  794.     set tearoff [tkTearOffMenu .m1 40 40]
  795.     list [update] [destroy .m1]
  796. } {{} {}}
  797. test winMenu-29.20 {TkpDrawMenuEntry - disabled cascade item} {
  798.     catch {destroy .m1}
  799.     menu .m1
  800.     .m1 add cascade -label File -menu .m1.file
  801.     menu .m1.file
  802.     .m1.file add command -label foo
  803.     .m1 entryconfigure File -state disabled
  804.     set tearoff [tkTearOffMenu .m1 40 40]
  805.     list [update] [destroy .m1]
  806. } {{} {}}
  807. test winMenu-29.21 {TkpDrawMenuEntry - indicator} {
  808.     catch {destroy .m1}
  809.     menu .m1
  810.     .m1 add checkbutton -label winMenu-31.20
  811.     .m1 invoke winMenu-31.20
  812.     set tearoff [tkTearOffMenu .m1 40 40]
  813.     list [update] [destroy .m1]
  814. } {{} {}}
  815. test winMenu-29.22 {TkpDrawMenuEntry - indicator} {
  816.     catch {destroy .m1}
  817.     menu .m1
  818.     .m1 add checkbutton -label winMenu-31.21 -hidemargin 1
  819.     .m1 invoke winMenu-31.21
  820.     set tearoff [tkTearOffMenu .m1 40 40]
  821.     list [update] [destroy .m1]
  822. } {{} {}}
  823.  
  824. test winMenu-30.1 {GetMenuLabelGeometry - image} {
  825.     catch {destroy .m1}
  826.     catch {image delete image1}
  827.     menu .m1
  828.     image create test image1
  829.     .m1 add command -image image1
  830.     list [update idletasks] [destroy .m1] [image delete image1]
  831. } {{} {} {}}
  832. test winMenu-30.2 {GetMenuLabelGeometry - bitmap} {
  833.     catch {destroy .m1}
  834.     menu .m1
  835.     .m1 add command -bitmap questhead
  836.     list [update idletasks] [destroy .m1]
  837. } {{} {}}
  838. test winMenu-30.3 {GetMenuLabelGeometry - no text} {
  839.     catch {destroy .m1}
  840.     menu .m1
  841.     .m1 add command
  842.     list [update idletasks] [destroy .m1]
  843. } {{} {}}
  844. test winMenu-30.4 {GetMenuLabelGeometry - text} {
  845.     catch {destroy .m1}
  846.     menu .m1
  847.     .m1 add command -label "This is a test."
  848.     list [update idletasks] [destroy .m1]
  849. } {{} {}}
  850.  
  851. test winMenu-31.1 {DrawMenuEntryBackground} {
  852.     catch {destroy .m1}
  853.     menu .m1
  854.     .m1 add command -label foo
  855.     set tearoff [tkTearOffMenu .m1 40 40]
  856.     list [update] [destroy .m1]
  857. } {{} {}}
  858. test winMenu-31.2 {DrawMenuEntryBackground} {
  859.     catch {destroy .m1}
  860.     menu .m1
  861.     .m1 add command -label foo
  862.     set tearoff [tkTearOffMenu .m1 40 40]
  863.     $tearoff activate 0
  864.     list [update] [destroy .m1]
  865. } {{} {}}
  866.  
  867. test winMenu-32.1 {TkpComputeStandardMenuGeometry - no entries} {
  868.     catch {destroy .m1}
  869.     menu .m1
  870.     list [update idletasks] [destroy .m1]
  871. } {{} {}}
  872. test winMenu-32.2 {TkpComputeStandardMenuGeometry - one entry} {
  873.     catch {destroy .m1}
  874.     menu .m1
  875.     .m1 add command -label "one"
  876.     list [update idletasks] [destroy .m1]
  877. } {{} {}}
  878. test winMenu-32.3 {TkpComputeStandardMenuGeometry - more than one entry} {
  879.     catch {destroy .m1}
  880.     menu .m1
  881.     .m1 add command -label "one"
  882.     .m1 add command -label "two"
  883.     list [update idletasks] [destroy .m1]
  884. } {{} {}}
  885. test winMenu-32.4 {TkpComputeStandardMenuGeometry - separator} {
  886.     catch {destroy .m1}
  887.     menu .m1
  888.     .m1 add separator
  889.     list [update idletasks] [destroy .m1]
  890. } {{} {}}
  891. test winMenu-32.5 {TkpComputeStandardMenuGeometry - tearoff entry} {unixOnly} {
  892.     catch {destroy .m1}
  893.     menubutton .mb -text "test" -menu .mb.m
  894.     menu .mb.m
  895.     .mb.m add command -label test
  896.     pack .mb
  897.     catch {tkMbPost .mb}
  898.     list [update] [destroy .mb]
  899. } {{} {}}
  900. test winMenu-32.6 {TkpComputeStandardMenuGeometry - standard label geometry} {
  901.     catch {destroy .m1}
  902.     menu .m1
  903.     .m1 add command -label "test"
  904.     list [update idletasks] [destroy .m1]
  905. } {{} {}}
  906. test winMenu-32.7 {TkpComputeStandardMenuGeometry - different font for entry} {
  907.     catch {destroy .m1}
  908.     menu .m1 -font "Helvetica 12"
  909.     .m1 add command -label "test" -font "Courier 12"
  910.     list [update idletasks] [destroy .m1]
  911. } {{} {}}
  912. test winMenu-32.8 {TkpComputeStandardMenuGeometry - second entry larger} {
  913.     catch {destroy .m1}
  914.     menu .m1
  915.     .m1 add command -label "test"
  916.     .m1 add command -label "test test"
  917.     list [update idletasks] [destroy .m1]
  918. } {{} {}}
  919. test winMenu-32.9 {TkpComputeStandardMenuGeometry - first entry larger} {
  920.     catch {destroy .m1}
  921.     menu .m1
  922.     .m1 add command -label "test test"
  923.     .m1 add command -label "test"
  924.     list [update idletasks] [destroy .m1]
  925. } {{} {}}
  926. test winMenu-32.10 {TkpComputeStandardMenuGeometry - accelerator} {
  927.     catch {destroy .m1}
  928.     menu .m1
  929.     .m1 add command -label "test" -accel "Ctrl+S"
  930.     list [update idletasks] [destroy .m1]
  931. } {{} {}}
  932. test winMenu-32.11 {TkpComputeStandardMenuGeometry - second accel larger} {
  933.     catch {destroy .m1}
  934.     menu .m1
  935.     .m1 add command -label "test" -accel "1"
  936.     .m1 add command -label "test" -accel "1 1"
  937.     list [update idletasks] [destroy .m1]
  938. } {{} {}}
  939. test winMenu-32.12 {TkpComputeStandardMenuGeometry - second accel smaller} {
  940.     catch {destroy .m1}
  941.     menu .m1
  942.     .m1 add command -label "test" -accel "1 1"
  943.     .m1 add command -label "test" -accel "1"
  944.     list [update idletasks] [destroy .m1]
  945. } {{} {}}
  946. test winMenu-32.13 {TkpComputeStandardMenuGeometry - indicator} {
  947.     catch {destroy .m1}
  948.     menu .m1
  949.     .m1 add checkbutton -label test
  950.     .m1 invoke 1
  951.     list [update idletasks] [destroy .m1]
  952. } {{} {}}
  953. test winMenu-32.14 {TkpComputeStandardMenuGeometry - second indicator less or equal } {
  954.     catch {destroy .m1}
  955.     catch {image delete image1}
  956.     image create test image1
  957.     menu .m1
  958.     .m1 add checkbutton -image image1
  959.     .m1 invoke 1
  960.     .m1 add checkbutton -label test
  961.     .m1 invoke 2
  962.     list [update idletasks] [destroy .m1] [image delete image1]
  963. } {{} {} {}}
  964. test winMenu-32.15 {TkpComputeStandardMenuGeometry - second indicator larger } {unixOnly} {
  965.     catch {destroy .m1}
  966.     catch {image delete image1}
  967.     image create test image1
  968.     menu .m1
  969.     .m1 add checkbutton -image image1
  970.     .m1 invoke 1
  971.     .m1 add checkbutton -label test
  972.     .m1 invoke 2
  973.     list [update idletasks] [destroy .m1] [image delete image1]
  974. } {{} {} {}}
  975. test winMenu-32.16 {TkpComputeStandardMenuGeometry - zero sized menus} {
  976.     catch {destroy .m1}
  977.     menu .m1 -tearoff 0
  978.     list [update idletasks] [destroy .m1]
  979. } {{} {}}
  980. test winMenu-32.17 {TkpComputeStandardMenuGeometry - first column bigger} {
  981.     catch {destroy .m1}
  982.     menu .m1
  983.     .m1 add command -label one
  984.     .m1 add command -label two
  985.     .m1 add command -label three -columnbreak 1
  986.     list [update idletasks] [destroy .m1]
  987. } {{} {}}
  988. test winMenu-32.18 {TkpComputeStandardMenuGeometry - second column bigger} {
  989.     catch {destroy .m1}
  990.     menu .m1 -tearoff 0
  991.     .m1 add command -label one
  992.     .m1 add command -label two -columnbreak 1
  993.     .m1 add command -label three
  994.     list [update idletasks] [destroy .m1]
  995. } {{} {}}
  996. test winMenu-32.19 {TkpComputeStandardMenuGeometry - three columns} {
  997.     catch {destroy .m1}
  998.     menu .m1 -tearoff 0
  999.     .m1 add command -label one
  1000.     .m1 add command -label two -columnbreak 1
  1001.     .m1 add command -label three
  1002.     .m1 add command -label four
  1003.     .m1 add command -label five -columnbreak 1
  1004.     .m1 add command -label six
  1005.     list [update idletasks] [destroy .m1]    
  1006. } {{} {}}
  1007.  
  1008. test winMenu-33.1 {TkpNotifyTopLevelCreate - no menu yet} {
  1009.     catch {destroy .t2}
  1010.     catch {destroy .m1}
  1011.     toplevel .t2 -menu .m1
  1012.     wm geometry .t2 +0+0
  1013.     list [update idletasks] [destroy .t2]
  1014. } {{} {}}
  1015. test winMenu-33.2 {TkpNotifyTopLevelCreate - menu} {
  1016.     catch {destroy .t2}
  1017.     catch {destroy .m1}
  1018.     menu .m1
  1019.     menu .m1.system
  1020.     .m1 add cascade -menu .m1.system
  1021.     .m1.system add separator
  1022.     .m1.system add command -label foo
  1023.     toplevel .t2 -menu .m1
  1024.     wm geometry .t2 +0+0
  1025.     list [update idletasks] [destroy .m1] [destroy .t2]
  1026. } {{} {} {}}
  1027.  
  1028. test winMenu-34.1 {TkpMenuInit called at boot time} {} {}
  1029.  
  1030. deleteWindows
  1031.