native_widget.km 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. type Widget
  2. protected
  3. Object;
  4. type WidgetTopLevel
  5. protected
  6. Widget;
  7. type Dialog
  8. protected
  9. WidgetTopLevel;
  10. type Window
  11. protected
  12. WidgetTopLevel;
  13. export function show:
  14. &(WidgetTopLevel) => Async
  15. native 'qt-show';
  16. export function show-at-center:
  17. &(WidgetTopLevel) => Async
  18. native 'qt-show-at-center';
  19. type BaseWebView
  20. protected
  21. Widget;
  22. type PlainWebView
  23. protected
  24. BaseWebView;
  25. type WebView
  26. protected
  27. BaseWebView;
  28. function bind:
  29. &(WebView, Component, List[Asset]) => Async[never]
  30. native 'ui-bind';
  31. export function bind:
  32. &(WebView, Component) => Async[never]
  33. &(view, root) => { bind (view, root, []) };
  34. export function bind:
  35. &(WebView, { root: Component, assets: List[Asset] }) => Async[never]
  36. &(view, opts) =>
  37. let { root, assets } := opts,
  38. { bind (view, root, assets) };
  39. type NativeLabel
  40. protected
  41. Widget;
  42. export function bind:
  43. &(NativeLabel, Computed[String]) => Async[never]
  44. &(label, @text) => {
  45. bind-property {
  46. object: label,
  47. prop: 'text',
  48. type: PropTypeString,
  49. source: @text
  50. } };
  51. type NativeInput
  52. protected
  53. Widget;
  54. export function bind:
  55. &(NativeInput, Reactive[String]) => Async[never]
  56. &(input, @text) => {
  57. bind-property {
  58. object: input,
  59. prop: 'text',
  60. type: PropTypeString,
  61. notify: 'textEdited(const QString&)',
  62. sync: @text
  63. } };
  64. export function activated:
  65. &(NativeInput) => Source[unit]
  66. &(input) => { Signal (input, 'returnPressed()') };
  67. type NativeInputMultiLine
  68. protected
  69. Widget;
  70. export function bind:
  71. &(NativeInputMultiLine, Reactive[String]) => Async[never]
  72. &(input, @text) => {
  73. bind-property {
  74. object: input,
  75. prop: 'plainText',
  76. type: PropTypeString,
  77. notify: 'textChanged()',
  78. sync: @text
  79. } };
  80. type NativeButton
  81. protected
  82. Widget;
  83. export function activated:
  84. &(NativeButton) => Source[unit]
  85. &(button) => { Signal (button,'clicked()') };
  86. type NativeCheckbox
  87. protected
  88. Widget;
  89. export function bind:
  90. &(NativeCheckbox, Reactive[Bool]) => Async[never]
  91. &(checkbox, @checked) => {
  92. bind-property {
  93. object: checkbox,
  94. prop: 'checked',
  95. type: PropTypeBool,
  96. notify: 'stateChanged(int)',
  97. sync: @checked
  98. } };
  99. type NativeSelect
  100. protected
  101. Widget;
  102. export function bind:
  103. &(NativeSelect, Reactive[Maybe[Number]]) => Async[never]
  104. &(select-widget, @index) => {
  105. bind-property {
  106. object: select-widget,
  107. prop: 'currentIndex',
  108. type: PropTypeMaybeNumber,
  109. notify: 'activated(int)',
  110. sync: @index
  111. } };
  112. // NativeList
  113. type NativeList
  114. protected
  115. Widget;
  116. type NativeListItem
  117. native;
  118. // TODO: bind { items: Observable[FlexList[String]], current: Reactive[FlexListKey] }
  119. /*
  120. export function set-items:
  121. &(NativeList,List[NativeListItem],Maybe[String]) => Async
  122. native 'qt-list-widget-set-items';
  123. export function list-widget-item:
  124. &(String,String) => NativeListItem
  125. native 'qt-list-widget-item';
  126. export function list-widget-item:
  127. &(String,image::PNG,String) => NativeListItem
  128. native 'qt-list-widget-item-with-icon-png';
  129. function get-current-item:
  130. &(Static[NativeList]) => Maybe[String]
  131. native 'qt-list-widget-get-current';
  132. export function current-item:
  133. &(NativeList) => Observable[Maybe[String]]
  134. &(list) => { Signal (list,'currentRowChanged(int)',get-current-item) };
  135. */