canvas.go 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  1. // Copyright 2025 The tk9.0-go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package tk9_0 // import "modernc.org/tk9.0"
  5. import (
  6. "context"
  7. "fmt"
  8. "os"
  9. "os/exec"
  10. )
  11. // Graph — use gnuplot to draw on a canvas. Graph returns 'w'.
  12. //
  13. // The 'script' argument is passed to a gnuplot executable, which must be
  14. // installed on the machine. See the [gnuplot site] for documentation about
  15. // producing graphs. The script must not use the 'set term <device>' command.
  16. //
  17. // [gnuplot site]: http://www.gnuplot.info/
  18. func (w *CanvasWidget) Graph(script string) *CanvasWidget {
  19. script = fmt.Sprintf("set terminal tkcanvas size %s, %s\n%s", w.Width(), w.Height(), script)
  20. out, err := gnuplot(script)
  21. if err != nil {
  22. fail(fmt.Errorf("plot: executing script: %s", err))
  23. return w
  24. }
  25. evalErr(fmt.Sprintf("%s\ngnuplot %s", out, w))
  26. return w
  27. }
  28. func gnuplot(script string) (out []byte, err error) {
  29. f, err := os.CreateTemp("", "tk9.0-")
  30. if err != nil {
  31. return nil, err
  32. }
  33. defer os.Remove(f.Name())
  34. if err := os.WriteFile(f.Name(), []byte(script), 0o660); err != nil {
  35. return nil, err
  36. }
  37. ctx, cancel := context.WithTimeout(context.Background(), gnuplotTimeout)
  38. defer cancel()
  39. return exec.CommandContext(ctx, "gnuplot", f.Name()).Output()
  40. }
  41. func (w *CanvasWidget) create(typ string, args ...any) string {
  42. return evalErr(fmt.Sprintf("%s create %s %s", w, typ, collectAny(args...)))
  43. }
  44. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  45. //
  46. // # Description
  47. //
  48. // Create a new arc in pathName of type type. The exact format of the
  49. // arguments after type depends on type, but usually they consist of the
  50. // coordinates for one or more points, followed by specifications for zero or
  51. // more item options. See the subsections on individual item types below for
  52. // more on the syntax of this command. This command returns the id for the new
  53. // item.
  54. //
  55. // Items of type arc appear on the display as arc-shaped regions. An arc is a
  56. // section of an oval delimited by two angles (specified by either the -start
  57. // and -extent options or the -height option) and displayed in one of several
  58. // ways (specified by the -style option). Arcs are created with widget commands
  59. // of the following form:
  60. //
  61. // pathName create arc x1 y1 x2 y2 ?option value ...?
  62. //
  63. // The arguments x1, y1, x2, and y2 or coordList give the coordinates of two
  64. // diagonally opposite corners of a rectangular region enclosing the oval that
  65. // defines the arc (except when -height is specified - see below). After the
  66. // coordinates there may be any number of option-value pairs, each of which
  67. // sets one of the configuration options for the item. These same option-value
  68. // pairs may be used in itemconfigure widget commands to change the item's
  69. // configuration. An arc item becomes the current item when the mouse pointer
  70. // is over any part that is painted or (when fully transparent) that would be
  71. // painted if both the -fill and -outline options were non-empty.
  72. //
  73. // The following standard options are supported by arcs:
  74. //
  75. // - [Dash]
  76. // - [Activedash]
  77. // - [Disableddash]
  78. // - [Dashoffset]
  79. // - [Fill]
  80. // - [Activefill]
  81. // - [Disabledfill]
  82. // - [Offset]
  83. // - [Outline]
  84. // - [Activeoutline]
  85. // - [Disabledoutline]
  86. // - [Outlineoffset]
  87. // - [Outlinestipple]
  88. // - [Activeoutlinestipple]
  89. // - [Disabledoutlinestipple]
  90. // - [Stipple]
  91. // - [Activestipple]
  92. // - [Disabledstipple]
  93. // - [State]
  94. // - [Tags]
  95. // - [Width]
  96. // - [Activewidth]
  97. // - [Disabledwidth]
  98. //
  99. // The following extra options are supported for arcs:
  100. //
  101. // - [Extent] degrees
  102. //
  103. // - [Start] degrees
  104. //
  105. // - [Height] distance
  106. //
  107. // Provides a shortcut for creating a circular arc segment by defining the
  108. // distance of the mid-point of the arc from its chord. When this option is
  109. // used the coordinates are interpreted as the start and end coordinates of
  110. // the chord, and the options -start and -extent are ignored. The value of
  111. // distance has the following meaning:
  112. //
  113. // distance > 0 creates a clockwise arc,
  114. // distance < 0 creates an counter-clockwise arc,
  115. // distance = 0 creates an arc as if this option had not been specified.
  116. //
  117. // If you want the arc to have a specific radius, r, use the formula:
  118. //
  119. // distance = r ± sqrt(r**2 - (chordLength / 2)**2)
  120. //
  121. // choosing the minus sign for the minor arc and the plus sign for the major
  122. // arc.
  123. //
  124. // Note that itemcget -height always returns 0 so that introspection code can
  125. // be kept simple.
  126. //
  127. // - [Style] type
  128. //
  129. // Specifies how to draw the arc. If type is pieslice (the default) then the
  130. // arc's region is defined by a section of the oval's perimeter plus two line
  131. // segments, one between the center of the oval and each end of the perimeter
  132. // section. If type is chord then the arc's region is defined by a section of
  133. // the oval's perimeter plus a single line segment connecting the two end
  134. // points of the perimeter section. If type is arc then the arc's region
  135. // consists of a section of the perimeter alone. In this last case the -fill
  136. // option is ignored.
  137. //
  138. // More information might be available at the [Tcl/Tk canvas] page.
  139. //
  140. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  141. func (w *CanvasWidget) CreateArc(x1, y1, x2, y2 any, options ...any) (r string) {
  142. return w.create("arc", append([]any{x1, y1, x2, y2}, options...)...)
  143. }
  144. // Dash option.
  145. //
  146. // This option specifies the dash pattern for the normal state of an item. If
  147. // the dash option is omitted then the default is a solid outline.
  148. //
  149. // Many items support the notion of a dash pattern for outlines. The syntax is
  150. // a list of integers. Each element represents the number of pixels of a line
  151. // segment. Only the odd segments are drawn using the “outline” color. The
  152. // other segments are drawn transparent.
  153. //
  154. // Known uses:
  155. // - [CanvasWidget.CreateArc] (widget specific)
  156. func Dash(pattern ...int) Opt {
  157. list := fmt.Sprint(pattern)
  158. return rawOption(fmt.Sprintf(`-dash {%s}`, list[1:len(list)-1]))
  159. }
  160. // Activedash option.
  161. //
  162. // This option specifies the dash pattern for the active state of an item. If
  163. // the dash option is omitted then the default is a solid outline.
  164. //
  165. // Many items support the notion of a dash pattern for outlines. The syntax is
  166. // a list of integers. Each element represents the number of pixels of a line
  167. // segment. Only the odd segments are drawn using the “outline” color. The
  168. // other segments are drawn transparent.
  169. //
  170. // Known uses:
  171. // - [CanvasWidget.CreateArc] (widget specific)
  172. func Activedash(pattern ...int) Opt {
  173. list := fmt.Sprint(pattern)
  174. return rawOption(fmt.Sprintf(`-activedash {%s}`, list[1:len(list)-1]))
  175. }
  176. // Disableddash option.
  177. //
  178. // This option specifies the dash pattern for the disabled state of an item. If
  179. // the dash option is omitted then the default is a solid outline.
  180. //
  181. // Many items support the notion of a dash pattern for outlines. The syntax is
  182. // a list of integers. Each element represents the number of pixels of a line
  183. // segment. Only the odd segments are drawn using the “outline” color. The
  184. // other segments are drawn transparent.
  185. //
  186. // Known uses:
  187. // - [CanvasWidget.CreateArc] (widget specific)
  188. func Disableddash(pattern ...int) Opt {
  189. list := fmt.Sprint(pattern)
  190. return rawOption(fmt.Sprintf(`-disableddash {%s}`, list[1:len(list)-1]))
  191. }
  192. // Dashoffset option.
  193. //
  194. // The starting offset in pixels into the pattern provided by the -dash option.
  195. // -dashoffset is ignored if there is no -dash pattern.
  196. //
  197. // Known uses:
  198. // - [CanvasWidget.CreateArc] (widget specific)
  199. func Dashoffset(offset any) Opt {
  200. return rawOption(fmt.Sprintf(`-dashoffset %s`, tclSafeString(fmt.Sprint(offset))))
  201. }
  202. // Activefill option.
  203. //
  204. // This option specifies the color to be used to fill item's area in its active
  205. // state. The even-odd fill rule is used. Color may have any of the forms
  206. // accepted by Tk_GetColor. For the line item, it specifies the color of the
  207. // line drawn. For the text item, it specifies the foreground color of the
  208. // text. If color is an empty string (the default for all canvas items except
  209. // line and text), then the item will not be filled.
  210. //
  211. // Known uses:
  212. // - [CanvasWidget.CreateArc] (widget specific)
  213. func Activefill(color any) Opt {
  214. return rawOption(fmt.Sprintf(`-activefill %s`, tclSafeString(fmt.Sprint(color))))
  215. }
  216. // Disabledfill option.
  217. //
  218. // This option specifies the color to be used to fill item's area in its disabled
  219. // state. The even-odd fill rule is used. Color may have any of the forms
  220. // accepted by Tk_GetColor. For the line item, it specifies the color of the
  221. // line drawn. For the text item, it specifies the foreground color of the
  222. // text. If color is an empty string (the default for all canvas items except
  223. // line and text), then the item will not be filled.
  224. //
  225. // Known uses:
  226. // - [CanvasWidget.CreateArc] (widget specific)
  227. func Disabledfill(color any) Opt {
  228. return rawOption(fmt.Sprintf(`-disabledfill %s`, tclSafeString(fmt.Sprint(color))))
  229. }
  230. // Outline option.
  231. //
  232. // This option specifies the color that should be used to draw the outline of
  233. // the item in its normal state. Color may have any of the forms accepted by
  234. // Tk_GetColor. If color is specified as an empty string then no outline is
  235. // drawn for the item.
  236. //
  237. // Known uses:
  238. // - [CanvasWidget.CreateArc] (widget specific)
  239. func Outline(color any) Opt {
  240. return rawOption(fmt.Sprintf(`-outline %s`, tclSafeString(fmt.Sprint(color))))
  241. }
  242. // Activeoutline option.
  243. //
  244. // This option specifies the color that should be used to draw the outline of
  245. // the item in its active state. Color may have any of the forms accepted by
  246. // Tk_GetColor. If color is specified as an empty string then no outline is
  247. // drawn for the item.
  248. //
  249. // Known uses:
  250. // - [CanvasWidget.CreateArc] (widget specific)
  251. func Activeoutline(color any) Opt {
  252. return rawOption(fmt.Sprintf(`-activeoutline %s`, tclSafeString(fmt.Sprint(color))))
  253. }
  254. // Disabledline option.
  255. //
  256. // This option specifies the color that should be used to draw the outline of
  257. // the item in its disabled state. Color may have any of the forms accepted by
  258. // Tk_GetColor. If color is specified as an empty string then no outline is
  259. // drawn for the item.
  260. //
  261. // Known uses:
  262. // - [CanvasWidget.CreateArc] (widget specific)
  263. func Disabledoutline(color any) Opt {
  264. return rawOption(fmt.Sprintf(`-disabledoutline %s`, tclSafeString(fmt.Sprint(color))))
  265. }
  266. // Outlineoffset option.
  267. //
  268. // Specifies the offset of the stipple pattern used for outlines, in the same
  269. // way that the -outline option controls fill stipples. (See the -outline
  270. // option for a description of the syntax of offset.)
  271. //
  272. // Known uses:
  273. // - [CanvasWidget.CreateArc] (widget specific)
  274. func Outlineoffset(offset any) Opt {
  275. return rawOption(fmt.Sprintf(`-outlineoffset %s`, tclSafeString(fmt.Sprint(offset))))
  276. }
  277. // Outlinestipple option.
  278. //
  279. // This option specifies the stipple pattern that should be used to draw the
  280. // outline of the item in its normal state. Indicates
  281. // that the outline for the item should be drawn with a stipple pattern; bitmap
  282. // specifies the stipple pattern to use, in any of the forms accepted by
  283. // Tk_GetBitmap. If the -outline option has not been specified then this option
  284. // has no effect. If bitmap is an empty string (the default), then the outline
  285. // is drawn in a solid fashion. Note that stipples are not well supported on
  286. // platforms that do not use X11 as their drawing API.
  287. //
  288. // Known uses:
  289. // - [CanvasWidget.CreateArc] (widget specific)
  290. func Outlinestipple(bitmap any) Opt {
  291. return rawOption(fmt.Sprintf(`-outlinestipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  292. }
  293. // Activeoutlinestipple option.
  294. //
  295. // This option specifies the stipple pattern that should be used to draw the
  296. // outline of the item in its active state. Indicates
  297. // that the outline for the item should be drawn with a stipple pattern; bitmap
  298. // specifies the stipple pattern to use, in any of the forms accepted by
  299. // Tk_GetBitmap. If the -outline option has not been specified then this option
  300. // has no effect. If bitmap is an empty string (the default), then the outline
  301. // is drawn in a solid fashion. Note that stipples are not well supported on
  302. // platforms that do not use X11 as their drawing API.
  303. //
  304. // Known uses:
  305. // - [CanvasWidget.CreateArc] (widget specific)
  306. func Activeoutlinestipple(bitmap any) Opt {
  307. return rawOption(fmt.Sprintf(`-activeoutlinestipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  308. }
  309. // Disabledoutlinestipple option.
  310. //
  311. // This option specifies the stipple pattern that should be used to draw the
  312. // outline of the item in its disabled state. Indicates
  313. // that the outline for the item should be drawn with a stipple pattern; bitmap
  314. // specifies the stipple pattern to use, in any of the forms accepted by
  315. // Tk_GetBitmap. If the -outline option has not been specified then this option
  316. // has no effect. If bitmap is an empty string (the default), then the outline
  317. // is drawn in a solid fashion. Note that stipples are not well supported on
  318. // platforms that do not use X11 as their drawing API.
  319. //
  320. // Known uses:
  321. // - [CanvasWidget.CreateArc] (widget specific)
  322. func Disabledoutlinestipple(bitmap any) Opt {
  323. return rawOption(fmt.Sprintf(`-disabledoutlinestipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  324. }
  325. // Stipple option.
  326. //
  327. // This option specifies the stipple patterns that should be used to fill the item in
  328. // its normal state. bitmap specifies the stipple pattern
  329. // to use, in any of the forms accepted by Tk_GetBitmap. If the -fill option
  330. // has not been specified then this option has no effect. If bitmap is an empty
  331. // string (the default), then filling is done in a solid fashion. For the text
  332. // item, it affects the actual text. Note that stipples are not well supported
  333. // on platforms that do not use X11 as their drawing API.
  334. //
  335. // Known uses:
  336. // - [CanvasWidget.CreateArc] (widget specific)
  337. // - [CanvasWidget.CreateBitmap] (widget specific)
  338. func Stipple(bitmap any) Opt {
  339. return rawOption(fmt.Sprintf(`-stipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  340. }
  341. // Activestipple option.
  342. //
  343. // This option specifies the stipple patterns that should be used to fill the item in
  344. // its active state. bitmap specifies the stipple pattern
  345. // to use, in any of the forms accepted by Tk_GetBitmap. If the -fill option
  346. // has not been specified then this option has no effect. If bitmap is an empty
  347. // string (the default), then filling is done in a solid fashion. For the text
  348. // item, it affects the actual text. Note that stipples are not well supported
  349. // on platforms that do not use X11 as their drawing API.
  350. //
  351. // Known uses:
  352. // - [CanvasWidget.CreateArc] (widget specific)
  353. func Activestipple(bitmap any) Opt {
  354. return rawOption(fmt.Sprintf(`-activestipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  355. }
  356. // Disabledstipple option.
  357. //
  358. // This option specifies the stipple patterns that should be used to fill the item in
  359. // its disabled state. bitmap specifies the stipple pattern
  360. // to use, in any of the forms accepted by Tk_GetBitmap. If the -fill option
  361. // has not been specified then this option has no effect. If bitmap is an empty
  362. // string (the default), then filling is done in a solid fashion. For the text
  363. // item, it affects the actual text. Note that stipples are not well supported
  364. // on platforms that do not use X11 as their drawing API.
  365. //
  366. // Known uses:
  367. // - [CanvasWidget.CreateArc] (widget specific)
  368. func Disabledstipple(bitmap any) Opt {
  369. return rawOption(fmt.Sprintf(`-disabledstipple %s`, tclSafeString(fmt.Sprint(bitmap))))
  370. }
  371. // Tags option.
  372. //
  373. // Specifies a set of tags to apply to the item. TagList consists of a list of
  374. // tag names, which replace any existing tags for the item. TagList may be an
  375. // empty list.
  376. //
  377. // Known uses:
  378. // - [CanvasWidget.CreateArc] (widget specific)
  379. // - [CanvasWidget.CreateBitmap] (widget specific)
  380. func Tags(tagList ...string) Opt {
  381. list := fmt.Sprint(tagList)
  382. return rawOption(fmt.Sprintf(`-tags {%s}`, list[1:len(list)-1]))
  383. }
  384. // Activewidth option.
  385. //
  386. // This option specifies the width of the outline to be drawn around the item's
  387. // region, in its active state. outlineWidth may be in
  388. // any of the forms described in the COORDINATES section above. If the -outline
  389. // option has been specified as an empty string then this option has no effect.
  390. // This option defaults to 1.0. For arcs, wide outlines will be drawn centered
  391. // on the edges of the arc's region.
  392. //
  393. // Known uses:
  394. // - [CanvasWidget.CreateArc] (widget specific)
  395. func Activewidth(outlineWidth any) Opt {
  396. return rawOption(fmt.Sprintf(`-activewidth %s`, tclSafeString(fmt.Sprint(outlineWidth))))
  397. }
  398. // Disabledwidth option.
  399. //
  400. // This option specifies the width of the outline to be drawn around the item's
  401. // region, in its disabled state. outlineWidth may be in
  402. // any of the forms described in the COORDINATES section above. If the -outline
  403. // option has been specified as an empty string then this option has no effect.
  404. // This option defaults to 1.0. For arcs, wide outlines will be drawn centered
  405. // on the edges of the arc's region.
  406. //
  407. // Known uses:
  408. // - [CanvasWidget.CreateArc] (widget specific)
  409. func Disabledwidth(outlineWidth any) Opt {
  410. return rawOption(fmt.Sprintf(`-disabledwidth %s`, tclSafeString(fmt.Sprint(outlineWidth))))
  411. }
  412. // Extent option.
  413. //
  414. // Specifies the size of the angular range occupied by the arc. The arc's
  415. // range extends for degrees degrees counter-clockwise from the starting
  416. // angle given by the -start option. Degrees may be negative. If it is
  417. // greater than 360 or less than -360, then degrees modulo 360 is used as
  418. // the extent.
  419. //
  420. // Known uses:
  421. // - [CanvasWidget.CreateArc] (widget specific)
  422. func Extent(degrees any) Opt {
  423. return rawOption(fmt.Sprintf(`-extent %s`, tclSafeString(fmt.Sprint(degrees))))
  424. }
  425. // Start option.
  426. //
  427. // Specifies the beginning of the angular range occupied by the arc. Degrees
  428. // is given in units of degrees measured counter-clockwise from the
  429. // 3-o'clock position; it may be either positive or negative.
  430. //
  431. // Known uses:
  432. // - [CanvasWidget.CreateArc] (widget specific)
  433. func Start(degrees any) Opt {
  434. return rawOption(fmt.Sprintf(`-start %s`, tclSafeString(fmt.Sprint(degrees))))
  435. }
  436. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  437. //
  438. // # Description
  439. //
  440. // Items of type bitmap appear on the display as images with two colors,
  441. // foreground and background. Bitmaps are created with widget commands of the
  442. // following form:
  443. //
  444. // pathName create bitmap x y ?option value ...?
  445. //
  446. // The arguments x and y or coordList (which must have two elements) specify
  447. // the coordinates of a point used to position the bitmap on the display, as
  448. // controlled by the -anchor option. After the coordinates there may be any
  449. // number of option-value pairs, each of which sets one of the configuration
  450. // options for the item. These same option-value pairs may be used in
  451. // itemconfigure widget commands to change the item's configuration. A bitmap
  452. // item becomes the current item when the mouse pointer is over any part of its
  453. // bounding box.
  454. //
  455. // The following standard options are supported by bitmaps:
  456. //
  457. // - [Anchor]
  458. // - [State]
  459. // - [Tags]
  460. //
  461. // The following extra options are supported for bitmaps:
  462. //
  463. // - [Background] color
  464. //
  465. // - [Activebackground] color
  466. //
  467. // - [Disabledbackground] color
  468. //
  469. // Specifies the color to use for each of the bitmap's “0” valued pixels in
  470. // its normal, active and disabled states. Color may have any of the forms
  471. // accepted by Tk_GetColor. If this option is not specified, or if it is
  472. // specified as an empty string, then nothing is displayed where the bitmap
  473. // pixels are 0; this produces a transparent effect.
  474. //
  475. // - [Bitmap] bitmap
  476. //
  477. // - [Activebitmap] bitmap
  478. //
  479. // - [Disabledbitmap] bitmap:
  480. //
  481. // These options specify the bitmaps to display in the item in its normal,
  482. // active and disabled states. Bitmap may have any of the forms accepted by
  483. // Tk_GetBitmap.
  484. //
  485. // - [Foreground] color
  486. //
  487. // - [Activeforeground] color
  488. //
  489. // - [Disabledforeground] color:
  490. //
  491. // These options specify the color to use for each of the bitmap's “1” valued
  492. // pixels in its normal, active and disabled states. Color may have any of the
  493. // forms accepted by Tk_GetColor.
  494. //
  495. // More information might be available at the [Tcl/Tk canvas] page.
  496. //
  497. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  498. func (w *CanvasWidget) CreateBitmap(x, y any, options ...any) (r string) {
  499. return w.create("bitmap", append([]any{x, y}, options...)...)
  500. }
  501. // Activebitmap option.
  502. //
  503. // This option specify the bitmap to display in the item in its active state.
  504. // Bitmap may have any of the forms accepted by Tk_GetBitmap.
  505. //
  506. // Known uses:
  507. // - [CanvasWidget.CreateBitmap] (widget specific)
  508. func Activebitmap(bitmap any) Opt {
  509. return rawOption(fmt.Sprintf(`-activebitmap %s`, tclSafeString(fmt.Sprint(bitmap))))
  510. }
  511. // Disabledbitmap option.
  512. //
  513. // This option specify the bitmap to display in the item in its disabled state.
  514. // Bitmap may have any of the forms accepted by Tk_GetBitmap.
  515. //
  516. // Known uses:
  517. // - [CanvasWidget.CreateBitmap] (widget specific)
  518. func Disabledbitmap(bitmap any) Opt {
  519. return rawOption(fmt.Sprintf(`-disabledbitmap %s`, tclSafeString(fmt.Sprint(bitmap))))
  520. }
  521. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  522. //
  523. // # Description
  524. //
  525. // Items of type image are used to display images on a canvas. Images are
  526. // created with widget commands of the following form:
  527. //
  528. // pathName create image x y ?option value ...?
  529. //
  530. // The arguments x and y or coordList specify the coordinates of a point used
  531. // to position the image on the display, as controlled by the -anchor option.
  532. // After the coordinates there may be any number of option-value pairs, each of
  533. // which sets one of the configuration options for the item. These same
  534. // option-value pairs may be used in itemconfigure widget commands to change
  535. // the item's configuration. An image item becomes the current item when the
  536. // mouse pointer is over any part of its bounding box.
  537. //
  538. // The following standard options are supported by images:
  539. //
  540. // - [Anchor]
  541. // - [State]
  542. // - [Tags]
  543. //
  544. // The following extra options are supported for images:
  545. //
  546. // - [Image] name
  547. //
  548. // - [Activeimage] name
  549. //
  550. // - [Disabledimage] name
  551. //
  552. // Specifies the name of the images to display in the item in is normal,
  553. // active and disabled states. This image must have been created previously
  554. // with the image create command.
  555. //
  556. // More information might be available at the [Tcl/Tk canvas] page.
  557. //
  558. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  559. func (w *CanvasWidget) CreateImage(x, y any, options ...any) (r string) {
  560. return w.create("image", append([]any{x, y}, options...)...)
  561. }
  562. // Activeimage option.
  563. //
  564. // Specifies the name of the image to display in the item in its active state.
  565. // This image must have been created previously with the image create command.
  566. //
  567. // Known uses:
  568. // - [CanvasWidget.CreateImage] (widget specific)
  569. func Activeimage(val any) Opt {
  570. return rawOption(fmt.Sprintf(`-activeimage %s`, optionString(val)))
  571. }
  572. // Disabledimage option.
  573. //
  574. // Specifies the name of the image to display in the item in its disabled state.
  575. // This image must have been created previously with the image create command.
  576. //
  577. // Known uses:
  578. // - [CanvasWidget.CreateImage] (widget specific)
  579. func Disabledimage(val any) Opt {
  580. return rawOption(fmt.Sprintf(`-disabledimage %s`, optionString(val)))
  581. }
  582. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  583. //
  584. // # Description
  585. //
  586. // Items of type line appear on the display as one or more connected line
  587. // segments or curves. Line items support coordinate indexing operations using
  588. // the dchars, index and insert widget commands. Lines are created with widget
  589. // commands of the following form:
  590. //
  591. // pathName create line x1 y1... xn yn ?option value ...?
  592. //
  593. // The following standard options are supported by lines:
  594. //
  595. // - [Dash]
  596. // - [Activedash]
  597. // - [Disableddash]
  598. // - [Dashoffset]
  599. // - [Fill]
  600. // - [Activefill]
  601. // - [Disabledfill]
  602. // - [Stipple]
  603. // - [Activestipple]
  604. // - [Disabledstipple]
  605. // - [State]
  606. // - [Tags]
  607. // - [Width]
  608. // - [Activewidth]
  609. // - [Disabledwidth]
  610. //
  611. // The following extra options are supported for lines:
  612. //
  613. // - [Linearrow] where
  614. // - [Arrowshape] shape
  615. // - [Capstyle] style
  616. // - [Joinstyle] style
  617. // - [Smooth] smoothMethod
  618. // - [Splinesteps] number
  619. //
  620. // More information might be available at the [Tcl/Tk canvas] page.
  621. //
  622. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  623. func (w *CanvasWidget) CreateLine(x1, y1 any, options ...any) (r string) {
  624. return w.create("line", append([]any{x1, y1}, options...)...)
  625. }
  626. // Linearrow option.
  627. //
  628. // Indicates whether or not arrowheads are to be drawn at one or both ends of
  629. // the line. Where must have one of the values none (for no arrowheads), first
  630. // (for an arrowhead at the first point of the line), last (for an arrowhead
  631. // at the last point of the line), or both (for arrowheads at both ends). This
  632. // option defaults to none. When requested to draw an arrowhead, Tk internally
  633. // adjusts the corresponding line end point so that the rendered line ends at
  634. // the neck of the arrowhead rather than at its tip so that the line doesn't
  635. // extend past the edge of the arrowhead. This may trigger a Leave event if
  636. // the mouse is hovering this line end. Conversely, when removing an arrowhead
  637. // Tk adjusts the corresponding line point the other way round, which may
  638. // trigger an Enter event.
  639. //
  640. // Known uses:
  641. // - [CanvasWidget.CreateLine] (widget specific)
  642. func Linearrow(where any) Opt {
  643. return rawOption(fmt.Sprintf(`-arrow %s`, optionString(where)))
  644. }
  645. // Arrowshape option.
  646. //
  647. // This option indicates how to draw arrowheads. The shape argument must be
  648. // a list with three elements, each specifying a distance in any of the
  649. // forms described in the COORDINATES section above. The first element of
  650. // the list gives the distance along the line from the neck of the
  651. // arrowhead to its tip. The second element gives the distance along the
  652. // line from the trailing points of the arrowhead to the tip, and the third
  653. // element gives the distance from the outside edge of the line to the
  654. // trailing points. If this option is not specified then Tk picks a
  655. // “reasonable” shape.
  656. //
  657. // Known uses:
  658. // - [CanvasWidget.CreateLine] (widget specific)
  659. func Arrowshape(a, b, c any) Opt {
  660. return rawOption(fmt.Sprintf(`-arrowshape {%s}`, tclSafeList(a, b, c)))
  661. }
  662. // Capstyle option.
  663. //
  664. // Specifies the ways in which caps are to be drawn at the endpoints of the
  665. // line. Style may have any of the forms accepted by Tk_GetCapStyle (butt,
  666. // projecting, or round). If this option is not specified then it defaults to
  667. // butt. Where arrowheads are drawn the cap style is ignored.
  668. //
  669. // Known uses:
  670. // - [CanvasWidget.CreateLine] (widget specific)
  671. func Capstyle(style any) Opt {
  672. return rawOption(fmt.Sprintf(`-capstyle %s`, tclSafeString(fmt.Sprint(style))))
  673. }
  674. // Joinstyle option.
  675. //
  676. // Specifies the ways in which joints are to be drawn at the vertices of the
  677. // line. Style may have any of the forms accepted by Tk_GetJoinStyle (bevel,
  678. // miter, or round). If this option is not specified then it defaults to
  679. // round. If the line only contains two points then this option is irrelevant.
  680. //
  681. // Known uses:
  682. // - [CanvasWidget.CreateLine] (widget specific)
  683. func Joinstyle(style any) Opt {
  684. return rawOption(fmt.Sprintf(`-joinstyle %s`, tclSafeString(fmt.Sprint(style))))
  685. }
  686. // Smooth option.
  687. //
  688. // smoothMethod must have one of the forms accepted by Tcl_GetBoolean or a
  689. // line smoothing method. Only true and raw are supported in the core (with
  690. // bezier being an alias for true), but more can be added at runtime. If a
  691. // boolean false value or empty string is given, no smoothing is applied. A
  692. // boolean truth value assumes true smoothing. If the smoothing method is
  693. // true, this indicates that the line should be drawn as a curve, rendered as
  694. // a set of quadratic splines: one spline is drawn for the first and second
  695. // line segments, one for the second and third, and so on. Straight-line
  696. // segments can be generated within a curve by duplicating the end-points of
  697. // the desired line segment. If the smoothing method is raw, this indicates
  698. // that the line should also be drawn as a curve but where the list of
  699. // coordinates is such that the first coordinate pair (and every third
  700. // coordinate pair thereafter) is a knot point on a cubic Bezier curve, and
  701. // the other coordinates are control points on the cubic Bezier curve.
  702. // Straight line segments can be generated within a curve by making control
  703. // points equal to their neighbouring knot points. If the last point is a
  704. // control point and not a knot point, the point is repeated (one or two
  705. // times) so that it also becomes a knot point.
  706. //
  707. // Known uses:
  708. // - [CanvasWidget.CreateLine] (widget specific)
  709. func Smooth(smoothMethod any) Opt {
  710. return rawOption(fmt.Sprintf(`-smooth %s`, tclSafeString(fmt.Sprint(smoothMethod))))
  711. }
  712. // Splinesteps option.
  713. //
  714. // Specifies the degree of smoothness desired for curves: each spline will be
  715. // approximated with number line segments. This option is ignored unless the
  716. // -smooth option is true or raw.
  717. //
  718. // Known uses:
  719. // - [CanvasWidget.CreateLine] (widget specific)
  720. func Splinesteps(number any) Opt {
  721. return rawOption(fmt.Sprintf(`-splinesteps %s`, tclSafeString(fmt.Sprint(number))))
  722. }
  723. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  724. //
  725. // # Description
  726. //
  727. // Items of type oval appear as circular or oval regions on the display. Each
  728. // oval may have an outline, a fill, or both. Ovals are created with widget
  729. // commands of the following form:
  730. //
  731. // pathName create oval x1 y1 x2 y2 ?option value ...?
  732. //
  733. // The following standard options are supported by ovals:
  734. //
  735. // - [Dash]
  736. // - [Activedash]
  737. // - [Disableddash]
  738. // - [Dashoffset]
  739. // - [Fill]
  740. // - [Activefill]
  741. // - [Disabledfill]
  742. // - [Offset]
  743. // - [Outline]
  744. // - [Activeoutline]
  745. // - [Disabledoutline]
  746. // - [Outlineoffset]
  747. // - [Outlinestipple]
  748. // - [Activeoutlinestipple]
  749. // - [Disabledoutlinestipple]
  750. // - [Stipple]
  751. // - [Activestipple]
  752. // - [Disabledstipple]
  753. // - [State]
  754. // - [Tags]
  755. // - [Width]
  756. // - [Activewidth]
  757. // - [Disabledwidth]
  758. //
  759. // There are no oval-specific options.
  760. //
  761. // More information might be available at the [Tcl/Tk canvas] page.
  762. //
  763. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  764. func (w *CanvasWidget) CreateOval(x1, y1, x2, y2 any, options ...any) (r string) {
  765. return w.create("oval", append([]any{x1, y1, x2, y2}, options...)...)
  766. }
  767. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  768. //
  769. // # Description
  770. //
  771. // Items of type polygon appear as polygonal or curved filled regions on the
  772. // display. Polygon items support coordinate indexing operations using the
  773. // dchars, index and insert widget commands. Polygons are created with widget
  774. // commands of the following form:
  775. //
  776. // pathName create polygon x1 y1 ... xn yn ?option value ...?
  777. //
  778. // The arguments x1 through yn or coordList specify the coordinates for three
  779. // or more points that define a polygon. The first point should not be repeated
  780. // as the last to close the shape; Tk will automatically close the periphery
  781. // between the first and last points. After the coordinates there may be any
  782. // number of option-value pairs, each of which sets one of the configuration
  783. // options for the item. These same option-value pairs may be used in
  784. // itemconfigure widget commands to change the item's configuration. A polygon
  785. // item is the current item whenever the mouse pointer is over any part of the
  786. // polygon, whether drawn or not and whether or not the outline is smoothed.
  787. //
  788. // The following standard options are supported by polygons:
  789. // - [Dash]
  790. // - [Activedash]
  791. // - [Disableddash]
  792. // - [Dashoffset]
  793. // - [Fill]
  794. // - [Activefill]
  795. // - [Disabledfill]
  796. // - [Offset]
  797. // - [Outline]
  798. // - [Activeoutline]
  799. // - [Disabledoutline]
  800. // - [Outlineoffset]
  801. // - [Outlinestipple]
  802. // - [Activeoutlinestipple]
  803. // - [Disabledoutlinestipple]
  804. // - [Stipple]
  805. // - [Activestipple]
  806. // - [Disabledstipple]
  807. // - [State]
  808. // - [Tags]
  809. // - [Width]
  810. // - [Activewidth]
  811. // - [Disabledwidth]
  812. //
  813. // The following extra options are supported for polygons:
  814. //
  815. // - [Joinstyle] style
  816. //
  817. // Specifies the ways in which joints are to be drawn at the vertices of the
  818. // outline. Style may have any of the forms accepted by Tk_GetJoinStyle (bevel,
  819. // miter, or round). If this option is not specified then it defaults to round.
  820. //
  821. // - [Smooth] boolean
  822. //
  823. // Boolean must have one of the forms accepted by Tcl_GetBoolean or a line
  824. // smoothing method. Only true and raw are supported in the core (with bezier
  825. // being an alias for true), but more can be added at runtime. If a boolean
  826. // false value or empty string is given, no smoothing is applied. A boolean
  827. // truth value assumes true smoothing. If the smoothing method is true, this
  828. // indicates that the polygon should be drawn as a curve, rendered as a set of
  829. // quadratic splines: one spline is drawn for the first and second line
  830. // segments, one for the second and third, and so on. Straight-line segments
  831. // can be generated within a curve by duplicating the end-points of the
  832. // desired line segment. If the smoothing method is raw, this indicates that
  833. // the polygon should also be drawn as a curve but where the list of
  834. // coordinates is such that the first coordinate pair (and every third
  835. // coordinate pair thereafter) is a knot point on a cubic Bezier curve, and
  836. // the other coordinates are control points on the cubic Bezier curve.
  837. // Straight line segments can be generated within a curve by making control
  838. // points equal to their neighbouring knot points. If the last point is not
  839. // the second point of a pair of control points, the point is repeated (one or
  840. // two times) so that it also becomes the second point of a pair of control
  841. // points (the associated knot point will be the first control point).
  842. //
  843. // - [Splinesteps] number
  844. //
  845. // Specifies the degree of smoothness desired for curves: each spline will be
  846. // approximated with number line segments. This option is ignored unless the
  847. // -smooth option is true or raw.
  848. //
  849. // Polygon items are different from other items such as rectangles, ovals and
  850. // arcs in that interior points are considered to be “inside” a polygon (e.g.
  851. // for purposes of the find closest and find overlapping widget commands) even
  852. // if it is not filled. For most other item types, an interior point is
  853. // considered to be inside the item only if the item is filled or if it has
  854. // neither a fill nor an outline. If you would like an unfilled polygon whose
  855. // interior points are not considered to be inside the polygon, use a line item
  856. // instead.
  857. //
  858. // More information might be available at the [Tcl/Tk canvas] page.
  859. //
  860. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  861. func (w *CanvasWidget) CreatePolygon(x1, y1 any, options ...any) (r string) {
  862. return w.create("polygon", append([]any{x1, y1}, options...)...)
  863. }
  864. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  865. //
  866. // # Description
  867. //
  868. // Items of type rectangle appear as rectangular regions on the display. Each
  869. // rectangle may have an outline, a fill, or both. Rectangles are created with
  870. // widget commands of the following form:
  871. //
  872. // pathName create rectangle x1 y1 x2 y2 ?option value ...?
  873. //
  874. // The arguments x1, y1, x2, and y2 or coordList (which must have four
  875. // elements) give the coordinates of two diagonally opposite corners of the
  876. // rectangle (the rectangle will include its upper and left edges but not its
  877. // lower or right edges). After the coordinates there may be any number of
  878. // option-value pairs, each of which sets one of the configuration options for
  879. // the item. These same option-value pairs may be used in itemconfigure widget
  880. // commands to change the item's configuration. A rectangle item becomes the
  881. // current item when the mouse pointer is over any part that is painted or
  882. // (when fully transparent) that would be painted if both the -fill and
  883. // -outline options were non-empty.
  884. //
  885. // The following standard options are supported by rectangles:
  886. //
  887. // - [Dash]
  888. // - [Activedash]
  889. // - [Disableddash]
  890. // - [Dashoffset]
  891. // - [Fill]
  892. // - [Activefill]
  893. // - [Disabledfill]
  894. // - [Offset]
  895. // - [Outline]
  896. // - [Activeoutline]
  897. // - [Disabledoutline]
  898. // - [Outlineoffset]
  899. // - [Outlinestipple]
  900. // - [Activeoutlinestipple]
  901. // - [Disabledoutlinestipple]
  902. // - [Stipple]
  903. // - [Activestipple]
  904. // - [Disabledstipple]
  905. // - [State]
  906. // - [Tags]
  907. // - [Width]
  908. // - [Activewidth]
  909. // - [Disabledwidth]
  910. //
  911. // There are no rectangle-specific options.
  912. //
  913. // More information might be available at the [Tcl/Tk canvas] page.
  914. //
  915. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  916. func (w *CanvasWidget) CreateRectangle(x1, y1, x2, y2 any, options ...any) (r string) {
  917. return w.create("rectangle", append([]any{x1, y1, x2, y2}, options...)...)
  918. }
  919. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  920. //
  921. // # Description
  922. //
  923. // A text item displays a string of characters on the screen in one or more
  924. // lines. Text items support indexing, editing and selection through the dchars
  925. // widget command, the focus widget command, the icursor widget command, the
  926. // index widget command, the insert widget command, and the select widget
  927. // command. Text items are created with widget commands of the following form:
  928. //
  929. // pathName create text x y ?option value ...?
  930. //
  931. // The arguments x and y or coordList (which must have two elements) specify
  932. // the coordinates of a point used to position the text on the display (see the
  933. // options below for more information on how text is displayed). After the
  934. // coordinates there may be any number of option-value pairs, each of which
  935. // sets one of the configuration options for the item. These same option-value
  936. // pairs may be used in itemconfigure widget commands to change the item's
  937. // configuration. A text item becomes the current item when the mouse pointer
  938. // is over any part of its bounding box.
  939. //
  940. // The following standard options are supported by text items:
  941. //
  942. // - [Anchor]
  943. // - [Fill]
  944. // - [Activefill]
  945. // - [Disabledfill]
  946. // - [Stipple]
  947. // - [Activestipple]
  948. // - [Disabledstipple]
  949. // - [State]
  950. // - [Tags]
  951. //
  952. // The following extra options are supported for text items:
  953. //
  954. // - [Angle] rotationDegrees
  955. //
  956. // RotationDegrees tells how many degrees to rotate the text anticlockwise
  957. // about the positioning point for the text; it may have any floating-point
  958. // value from 0.0 to 360.0. For example, if rotationDegrees is 90, then the
  959. // text will be drawn vertically from bottom to top. This option defaults
  960. // to 0.0.
  961. //
  962. // - [Font] fontName
  963. //
  964. // Specifies the font to use for the text item. FontName may be any string
  965. // acceptable to Tk_GetFont. If this option is not specified, it defaults to a
  966. // system-dependent font.
  967. //
  968. // - [Justify] how
  969. //
  970. // Specifies how to justify the text within its bounding region. How must be
  971. // one of the values left, right, or center. This option will only matter if
  972. // the text is displayed as multiple lines. If the option is omitted, it
  973. // defaults to left.
  974. //
  975. // - [Txt] string
  976. //
  977. // String specifies the characters to be displayed in the text item. Newline
  978. // characters cause line breaks. The characters in the item may also be
  979. // changed with the insert and delete widget commands. This option defaults to
  980. // an empty string.
  981. //
  982. // - [Underline] number
  983. //
  984. // Specifies the integer index of a character within the text to be
  985. // underlined. 0 corresponds to the first character of the text displayed, 1
  986. // to the next character, and so on. -1 means that no underline should be
  987. // drawn (if the whole text item is to be underlined, the appropriate font
  988. // should be used instead).
  989. //
  990. // - [Width] lineLength
  991. //
  992. // Specifies a maximum line length for the text, in any of the forms described
  993. // in the COORDINATES section above. If this option is zero (the default) the
  994. // text is broken into lines only at newline characters. However, if this
  995. // option is non-zero then any line that would be longer than lineLength is
  996. // broken just before a space character to make the line shorter than
  997. // lineLength; the space character is treated as if it were a newline
  998. // character.
  999. //
  1000. // More information might be available at the [Tcl/Tk canvas] page.
  1001. //
  1002. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  1003. func (w *CanvasWidget) CreateText(x, y any, options ...any) (r string) {
  1004. return w.create("text", append([]any{x, y}, options...)...)
  1005. }
  1006. // Angle option.
  1007. //
  1008. // RotationDegrees tells how many degrees to rotate the text anticlockwise
  1009. // about the positioning point for the text; it may have any floating-point
  1010. // value from 0.0 to 360.0. For example, if rotationDegrees is 90, then the
  1011. // text will be drawn vertically from bottom to top. This option defaults
  1012. // to 0.0.
  1013. //
  1014. // Known uses:
  1015. // - [CanvasWidget.CreateText] (widget specific)
  1016. func Angle(rotationDegrees any) Opt {
  1017. return rawOption(fmt.Sprintf(`-angle %s`, tclSafeString(fmt.Sprint(rotationDegrees))))
  1018. }
  1019. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  1020. //
  1021. // # Description
  1022. //
  1023. // Items of type window cause a particular window to be displayed at a given
  1024. // position on the canvas. Window items are created with widget commands of the
  1025. // following form:
  1026. //
  1027. // pathName create window x y ?option value ...?
  1028. //
  1029. // The arguments x and y or coordList (which must have two elements) specify
  1030. // the coordinates of a point used to position the window on the display, as
  1031. // controlled by the -anchor option. After the coordinates there may be any
  1032. // number of option-value pairs, each of which sets one of the configuration
  1033. // options for the item. These same option-value pairs may be used in
  1034. // itemconfigure widget commands to change the item's configuration.
  1035. // Theoretically, a window item becomes the current item when the mouse pointer
  1036. // is over any part of its bounding box, but in practice this typically does
  1037. // not happen because the mouse pointer ceases to be over the canvas at that
  1038. // point.
  1039. //
  1040. // The following standard options are supported by window items:
  1041. //
  1042. // - [Anchor]
  1043. // - [State]
  1044. // - [Tags]
  1045. //
  1046. // The following extra options are supported for window items:
  1047. //
  1048. // - [Height] pixels
  1049. //
  1050. // Specifies the height to assign to the item's window. Pixels may have any of
  1051. // the forms described in the COORDINATES section above. If this option is not
  1052. // specified, or if it is specified as zero, then the window is given whatever
  1053. // height it requests internally.
  1054. //
  1055. // - [Width] pixels
  1056. // Specifies the width to assign to the item's window. Pixels may have any of
  1057. // the forms described in the COORDINATES section above. If this option is not
  1058. // specified, or if it is specified as zero, then the window is given whatever
  1059. // width it requests internally.
  1060. //
  1061. // - [ItemWindow] pathName
  1062. //
  1063. // Specifies the window to associate with this item. The window specified by
  1064. // pathName must either be a child of the canvas widget or a child of some
  1065. // ancestor of the canvas widget. PathName may not refer to a top-level
  1066. // window.
  1067. //
  1068. // Note that, due to restrictions in the ways that windows are managed, it is
  1069. // not possible to draw other graphical items (such as lines and images) on top
  1070. // of window items. A window item always obscures any graphics that overlap it,
  1071. // regardless of their order in the display list. Also note that window items,
  1072. // unlike other canvas items, are not clipped for display by their containing
  1073. // canvas's border, and are instead clipped by the parent widget of the window
  1074. // specified by the -window option; when the parent widget is the canvas, this
  1075. // means that the window item can overlap the canvas's border.
  1076. //
  1077. // More information might be available at the [Tcl/Tk canvas] page.
  1078. //
  1079. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  1080. func (w *CanvasWidget) CreateWindow(x, y any, options ...any) (r string) {
  1081. return w.create("window", append([]any{x, y}, options...)...)
  1082. }
  1083. // ItemWindow option.
  1084. //
  1085. // Specifies the window to associate with this item. The window specified by
  1086. // pathName must either be a child of the canvas widget or a child of some
  1087. // ancestor of the canvas widget. PathName may not refer to a top-level window.
  1088. //
  1089. // Known uses:
  1090. // - [CanvasWidget.CreateWindow] (widget specific)
  1091. func ItemWindow(w *Window) Opt {
  1092. return rawOption(fmt.Sprintf(`-window %s`, w))
  1093. }
  1094. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  1095. //
  1096. // # Description
  1097. //
  1098. // More information might be available at the [Tcl/Tk canvas] page.
  1099. //
  1100. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  1101. func (w *CanvasWidget) Delete(tagOrId ...any) (r string) {
  1102. return evalErr(fmt.Sprintf("%s delete {%s}", w, tclSafeList(tagOrId...)))
  1103. }
  1104. // Canvas — Create and manipulate 'canvas' hypergraphics drawing surface widgets
  1105. //
  1106. // # Description
  1107. //
  1108. // Returns a list with four elements giving an approximate bounding box for all
  1109. // the items named by the tagOrId arguments. The list has the form “x1 y1 x2 y2”
  1110. // such that the drawn areas of all the named elements are within the region
  1111. // bounded by x1 on the left, x2 on the right, y1 on the top, and y2 on the bottom.
  1112. // The return value may overestimate the actual bounding box by a few pixels. If
  1113. // no items match any of the tagOrId arguments or if the matching items have empty
  1114. // bounding boxes (i.e. they have nothing to display) then an empty string is returned.
  1115. //
  1116. // More information might be available at the [Tcl/Tk canvas] page.
  1117. //
  1118. // [Tcl/Tk canvas]: https://www.tcl-lang.org/man/tcl9.0/TkCmd/canvas.html
  1119. func (w *CanvasWidget) Bbox(tagIds ...string) []string {
  1120. return parseList(evalErr(fmt.Sprintf("%s bbox %s", w, tclSafeStrings(tagIds...))))
  1121. }