window.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // Show the window on screen.
  59. Show()
  60. // Hide the window from the user.
  61. // This will not destroy the window or cause the app to exit.
  62. Hide()
  63. // Close the window.
  64. // If it is he "master" window the app will Quit.
  65. // If it is the only open window and no menu is set via [desktop.App]
  66. // SetSystemTrayMenu the app will also Quit.
  67. Close()
  68. // ShowAndRun is a shortcut to show the window and then run the application.
  69. // This should be called near the end of a main() function as it will block.
  70. ShowAndRun()
  71. // Content returns the content of this window.
  72. Content() CanvasObject
  73. // SetContent sets the content of this window.
  74. SetContent(CanvasObject)
  75. // Canvas returns the canvas context to render in the window.
  76. // This can be useful to set a key handler for the window, for example.
  77. Canvas() Canvas
  78. // Clipboard returns the system clipboard
  79. Clipboard() Clipboard
  80. }