window.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package fyne
  2. // Window describes a user interface window. Depending on the platform an app
  3. // may have many windows or just the one.
  4. type Window interface {
  5. // Title returns the current window title.
  6. // This is typically displayed in the window decorations.
  7. Title() string
  8. // SetTitle updates the current title of the window.
  9. SetTitle(string)
  10. // FullScreen returns whether or not this window is currently full screen.
  11. FullScreen() bool
  12. // SetFullScreen changes the requested fullScreen property
  13. // true for a fullScreen window and false to unset this.
  14. SetFullScreen(bool)
  15. // Resize this window to the requested content size.
  16. // The result may not be exactly as desired due to various desktop or
  17. // platform constraints.
  18. Resize(Size)
  19. // RequestFocus attempts to raise and focus this window.
  20. // This should only be called when you are sure the user would want this window
  21. // to steal focus from any current focused window.
  22. RequestFocus()
  23. // FixedSize returns whether or not this window should disable resizing.
  24. FixedSize() bool
  25. // SetFixedSize sets a hint that states whether the window should be a fixed
  26. // size or allow resizing.
  27. SetFixedSize(bool)
  28. // CenterOnScreen places a window at the center of the monitor
  29. // the Window object is currently positioned on.
  30. CenterOnScreen()
  31. // Padded, normally true, states whether the window should have inner
  32. // padding so that components do not touch the window edge.
  33. Padded() bool
  34. // SetPadded allows applications to specify that a window should have
  35. // no inner padding. Useful for fullscreen or graphic based applications.
  36. SetPadded(bool)
  37. // Icon returns the window icon, this is used in various ways
  38. // depending on operating system.
  39. // Most commonly this is displayed on the window border or task switcher.
  40. Icon() Resource
  41. // SetIcon sets the icon resource used for this window.
  42. // If none is set should return the application icon.
  43. SetIcon(Resource)
  44. // SetMaster indicates that closing this window should exit the app
  45. SetMaster()
  46. // MainMenu gets the content of the window's top level menu.
  47. MainMenu() *MainMenu
  48. // SetMainMenu adds a top level menu to this window.
  49. // The way this is rendered will depend on the loaded driver.
  50. SetMainMenu(*MainMenu)
  51. // SetOnClosed sets a function that runs when the window is closed.
  52. SetOnClosed(func())
  53. // SetCloseIntercept sets a function that runs instead of closing if defined.
  54. // Close() should be called explicitly in the interceptor to close the window.
  55. //
  56. // Since: 1.4
  57. SetCloseIntercept(func())
  58. // SetOnDropped allows setting a window-wide callback to receive dropped items.
  59. // The callback function is called with the absolute position of the drop and a
  60. // slice of all of the dropped URIs.
  61. //
  62. // Since 2.4
  63. SetOnDropped(func(Position, []URI))
  64. // Show the window on screen.
  65. Show()
  66. // Hide the window from the user.
  67. // This will not destroy the window or cause the app to exit.
  68. Hide()
  69. // Close the window.
  70. // If it is he "master" window the app will Quit.
  71. // If it is the only open window and no menu is set via [desktop.App]
  72. // SetSystemTrayMenu the app will also Quit.
  73. Close()
  74. // ShowAndRun is a shortcut to show the window and then run the application.
  75. // This should be called near the end of a main() function as it will block.
  76. ShowAndRun()
  77. // Content returns the content of this window.
  78. Content() CanvasObject
  79. // SetContent sets the content of this window.
  80. SetContent(CanvasObject)
  81. // Canvas returns the canvas context to render in the window.
  82. // This can be useful to set a key handler for the window, for example.
  83. Canvas() Canvas
  84. // Clipboard returns the system clipboard
  85. Clipboard() Clipboard
  86. }