iup_dialog.e 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. class IUP_DIALOG
  2. -- In IUP you can create your own dialogs or use one of the predefined dialogs.
  3. -- To create your own dialogs you will have to create all the controls of the
  4. -- dialog before the creation of the dialog. All the controls must be composed
  5. -- in a hierarchical structure so the root will be used as a parameter to the
  6. -- dialog creation.
  7. --
  8. -- When a control is created, its parent is not known. After the dialog is
  9. -- created all elements receive a parent. This mechanism is quite different
  10. -- from that of native systems, who first create the dialog and then the
  11. -- element are inserted, using the dialog as a parent. This feature creates
  12. -- some limitations for IUP, usually related to the insertion and removal of
  13. -- controls.
  14. --
  15. -- Since the controls are created in a different order from the native system,
  16. -- native controls can only be created after the dialog. This will happen
  17. -- automatically when the application call the show function to show the dialog.
  18. -- But we often need the native controls to be created so we can use some other
  19. -- functionality of those before they are visible to the user. For that
  20. -- purpose, map function was created. It forces IUP to map the controls to
  21. -- their native system controls. The show function internally uses map before
  22. -- showing the dialog on the screen. show can be called many times, but the map
  23. -- process will occur only once.
  24. --
  25. -- show can be replaced by popup. In this case the result will be a modal
  26. -- dialog and all the other previously shown dialogs will be unavailable to the
  27. -- user. Also the program will interrupt in the function call until the
  28. -- application return IUP_CLOSE or exit_loop is called.
  29. --
  30. -- All dialogs are automatically destroyed in iup_close.
  31. inherit
  32. IUP_CONTAINER
  33. undefine
  34. execute_dragbegin,
  35. execute_dragdatasize,
  36. execute_dragdata,
  37. execute_dragend,
  38. execute_dropdata,
  39. execute_dropmotion
  40. redefine
  41. -- set_maxsize,
  42. -- get_maxsize,
  43. -- set_minsize,
  44. -- get_minsize
  45. execute_map,
  46. execute_unmap,
  47. execute_destroy,
  48. execute_getfocus,
  49. execute_killfocus,
  50. execute_enterwindow,
  51. execute_leavewindow,
  52. execute_k_any,
  53. execute_help,
  54. execute_close,
  55. execute_copydata,
  56. execute_dropfiles,
  57. execute_mdiactivate,
  58. execute_move,
  59. execute_resize,
  60. execute_show,
  61. execute_trayclick,
  62. execute_focus
  63. end
  64. IUP_WIDGET_EXPAND
  65. IUP_WIDGET_TITLE
  66. IUP_WIDGET_VISIBLE
  67. IUP_WIDGET_ACTIVE
  68. IUP_WIDGET_BGCOLOR
  69. IUP_WIDGET_FONT
  70. IUP_WIDGET_SCREENPOSITION
  71. IUP_WIDGET_TIP
  72. IUP_WIDGET_CLIENTOFFSET
  73. IUP_WIDGET_CLIENTSIZE
  74. IUP_WIDGET_RASTERSIZE
  75. IUP_WIDGET_USERSIZE
  76. IUP_WIDGET_ZORDER
  77. IUP_WIDGET_POPUP
  78. IUP_WIDGET_SHOW
  79. IUP_WIDGET_HIDE
  80. IUP_WIDGET_PARENT_DIALOG
  81. IUP_WIDGET_ICON
  82. IUP_WIDGET_DEFAULT_ENTER_ESC
  83. IUP_WIDGET_MAXMIN_SIZE
  84. redefine
  85. set_maxsize,
  86. get_maxsize,
  87. set_minsize,
  88. get_minsize
  89. end
  90. IUP_DRAG_AND_DROP
  91. insert
  92. IUP_WIDGET_CUSTOM_ATTRIBUTES
  93. create {ANY}
  94. dialog
  95. create {IUP}
  96. dialog_widget
  97. feature {ANY}
  98. dialog (content: IUP_WIDGET)
  99. -- Create a new dialog with the specified content
  100. local
  101. a_dialog: POINTER
  102. do
  103. a_dialog := int_dialog(content.widget)
  104. set_widget(a_dialog)
  105. end
  106. -- Attributes
  107. -- Skip BACKGROUND attribute
  108. set_border (state: BOOLEAN)
  109. -- (non inheritable) (creation only): Shows a resize border around the
  110. -- dialog. Default: "YES". BORDER=NO is useful only when RESIZE=NO,
  111. -- MAXBOX=NO, MINBOX=NO, MENUBOX=NO and TITLE=NULL, if any of these are
  112. -- defined there will be always some border.
  113. do
  114. iup_open.set_attribute(Current, "BORDER", boolean_to_yesno(state))
  115. end
  116. has_border: BOOLEAN
  117. -- Border state.
  118. local
  119. str: STRING
  120. do
  121. str := iup_open.get_attribute(Current, "BORDER")
  122. Result := yesno_to_boolean(str)
  123. end
  124. get_border_width: INTEGER
  125. -- (non inheritable): returns the border size.
  126. local
  127. str: STRING
  128. do
  129. str := iup_open.get_attribute(Current, "BORDERSIZE")
  130. Result := str.to_integer
  131. end
  132. set_child_offset (horizontal, vertical: INTEGER)
  133. -- Allow to specify a position offset for the child. Available for native
  134. -- containers only. It will not affect the natural size, and allows to
  135. -- position controls outside the client area. Are integer values
  136. -- corresponding to the horizontal and vertical offsets, respectively,
  137. -- in pixels. Default: 0x0.
  138. require
  139. horizontal >= 0
  140. vertical >= 0
  141. local
  142. offset: STRING
  143. do
  144. offset := horizontal.to_string
  145. offset.append_string("x")
  146. offset.append_string(vertical.to_string)
  147. iup_open.set_attribute(Current, "CHILDOFFSET", offset)
  148. end
  149. get_child_offset: TUPLE[INTEGER, INTEGER]
  150. -- Return the offset of the child.
  151. local
  152. offset: STRING
  153. do
  154. offset := iup_open.get_attribute(Current, "CHILDOFFSET")
  155. Result := components_of_size(offset)
  156. end
  157. set_cursor (name: STRING)
  158. -- Defines the element's cursor. See documentation. Default: ARROW
  159. do
  160. iup_open.set_attribute(Current, "CURSOR", name)
  161. end
  162. get_cursor: STRING
  163. -- Return the cursor name.
  164. do
  165. Result := iup_open.get_attribute(Current, "CURSOR")
  166. end
  167. set_nactive (state: BOOLEAN)
  168. -- (non inheritable): same as set_active but does not affects the
  169. -- controls inside the dialog.
  170. do
  171. iup_open.set_attribute(Current, "NACTIVE", boolean_to_yesno(state))
  172. end
  173. is_nactive: BOOLEAN
  174. -- Return the state of nactive.
  175. local
  176. str: STRING
  177. do
  178. str := iup_open.get_attribute(Current, "NACTIVE")
  179. Result := yesno_to_boolean(str)
  180. end
  181. set_size (width, height: INTEGER)
  182. -- (non inheritable): Dialog’s size.
  183. --
  184. -- The dialog Natural size is only considered when the User size is not
  185. -- defined or when it is bigger than the Current size. This behavior is
  186. -- different from a control that goes inside the dialog. Because of that,
  187. -- when SIZE or RASTERSIZE are set (changing the User size), the Current
  188. -- size is internally reset to 0x0, so the the Natural size can be
  189. -- considered when re-computing the Current size of the dialog.
  190. --
  191. -- Values set at SIZE or RASTERSIZE attributes of a dialog are always
  192. -- accepted, regardless of the minimum size required by its children. For
  193. -- a dialog to have the minimum necessary size to fit all elements
  194. -- contained in it, simply define SIZE or RASTERSIZE to NULL. Also if you
  195. -- set SIZE or RASTERSIZE to be used as the initial size of the dialog,
  196. -- its contents will be limited to this size as the minimum size, if you
  197. -- do not want that, then after showing the dialog reset this size to NULL
  198. -- so the dialog can be resized to smaller values. But notice that its
  199. -- contents will still be limited by the Natural size, to also remove
  200. -- that limitation set SHRINK=True. To only change the User size in
  201. -- pixels, without resetting the Current size, set the USERSIZE attribute
  202. -- (since 3.12). Notice that the dialog size includes its decoration (it
  203. -- is the Window size), the area available for controls are returned by
  204. -- the dialog CLIENTSIZE. For more information see Layout Guide.
  205. local
  206. size: STRING
  207. do
  208. size := width.to_string
  209. size.append_string("x")
  210. size.append_string(height.to_string)
  211. iup_open.set_attribute(Current, "SIZE", size)
  212. end
  213. set_predefined_size (width, height: STRING)
  214. -- (non inheritable): Dialog’s size using predefined values
  215. -- for width and/or height. However you can combine a predefined
  216. -- value with an integer (as string). The predefined values are:
  217. --
  218. -- "FULL": Defines the dialog’s width (or height) equal to the screen's
  219. -- width (or height)
  220. -- "HALF": Defines the dialog’s width (or height) equal to half the
  221. -- screen's width (or height)
  222. -- "THIRD": Defines the dialog’s width (or height) equal to 1/3 the
  223. -- screen's width (or height)
  224. -- "QUARTER": Defines the dialog’s width (or height) equal to 1/4 of the
  225. -- screen's width (or height)
  226. -- "EIGHTH": Defines the dialog’s width (or height) equal to 1/8 of the
  227. -- screen's width (or height)
  228. require
  229. is_valid_size (width, height)
  230. local
  231. size: STRING
  232. do
  233. size := width
  234. size.append_string("x")
  235. size.append_string(height)
  236. iup_open.set_attribute(Current, "SIZE", size)
  237. end
  238. get_size: TUPLE[INTEGER, INTEGER]
  239. -- The size of the dialog.
  240. local
  241. str: STRING
  242. do
  243. str := iup_open.get_attribute(Current, "SIZE")
  244. Result := components_of_size(str)
  245. end
  246. set_simulate_modal (state: BOOLEAN)
  247. -- Disable all other visible dialogs, just like when the dialog is made
  248. -- modal.
  249. do
  250. iup_open.set_attribute(Current, "SIMULATEMODAL", boolean_to_yesno(state))
  251. end
  252. -- Exclusive
  253. set_modal_dialog_frame (state: BOOLEAN)
  254. -- Set the common decorations for modal dialogs. This means RESIZE=NO,
  255. -- MINBOX=NO and MAXBOX=NO. In Windows, if the PARENTDIALOG is defined
  256. -- then the MENUBOX is also removed, but the Close button remains.
  257. do
  258. iup_open.set_attribute(Current, "DIALOGFRAME", boolean_to_yesno(state))
  259. end
  260. is_modal_dialog_frame: BOOLEAN
  261. -- Modal dialog.
  262. local
  263. str: STRING
  264. do
  265. str := iup_open.get_attribute(Current, "DIALOGFRAME")
  266. Result := yesno_to_boolean(str)
  267. end
  268. set_fullscreen (state: BOOLEAN)
  269. -- Makes the dialog occupy the whole screen over any system bars in the
  270. -- main monitor. All dialog details, such as title bar, borders, maximize
  271. -- button, etc, are removed. Possible values: True, False. In Motif you
  272. -- may have to click in the dialog to set its focus.
  273. -- In Motif if set to Trur when the dialog is hidden, then it can not be
  274. -- changed after it is visible.
  275. do
  276. iup_open.set_attribute(Current, "FULLSCREEN", boolean_to_yesno(state))
  277. end
  278. get_fullscreen: BOOLEAN
  279. -- Fullscreen status
  280. local
  281. str: STRING
  282. do
  283. str := iup_open.get_attribute(Current, "FULLSCREEN")
  284. Result := yesno_to_boolean(str)
  285. end
  286. set_maxbox (state: BOOLEAN)
  287. -- (creation only): Requires a maximize button from the window manager.
  288. -- If RESIZE=NO then MAXBOX will be set to NO. Default: True. In Motif the
  289. -- decorations are controlled by the Window Manager and may not be
  290. -- possible to be changed from IUP. In Windows MAXBOX is hidden only if
  291. -- MINBOX is hidden as well, or else it will be just disabled.
  292. do
  293. iup_open.set_attribute(Current, "MAXBOX", boolean_to_yesno(state))
  294. end
  295. set_maxsize (width, height: INTEGER)
  296. -- Maximum size for the dialog in raster units (pixels). The windowing
  297. -- system will not be able to change the size beyond this limit. Default:
  298. -- 65535x65535.
  299. do
  300. Precursor (width, height)
  301. end
  302. get_maxsize: TUPLE[INTEGER, INTEGER]
  303. -- Max size of the dialog.
  304. do
  305. Result := Precursor
  306. end
  307. set_menu (name: STRING)
  308. -- Name of a menu. Associates a menu to the dialog as a menu bar. The
  309. -- previous menu, if any, is unmapped. Use set_attribute_handle to
  310. -- associate a menu to a name.
  311. do
  312. iup_open.set_attribute(Current, "MENU", name)
  313. end
  314. set_menu_widget (menu: IUP_MENU)
  315. -- Set the menu widget to the dialog as a menu bar. The previous menu, if
  316. -- any, is unmapped.
  317. do
  318. iup_open.set_attribute_widget(Current, "MENU", menu)
  319. end
  320. set_menubox (state: BOOLEAN)
  321. -- (creation only): Requires a system menu box from the window manager.
  322. -- If hidden will also remove the Close button. Default: True. In Motif
  323. -- the decorations are controlled by the Window Manager and may not be
  324. -- possible to be changed from IUP. In Windows if hidden will hide also
  325. -- MAXBOX and MINBOX.
  326. do
  327. iup_open.set_attribute(Current, "MENUBOX", boolean_to_yesno(state))
  328. end
  329. set_minbox (state: BOOLEAN)
  330. -- (creation only): Requires a minimize button from the window manager.
  331. -- Default: True. In Motif the decorations are controlled by the Window
  332. -- Manager and may not be possible to be changed from IUP. In Windows
  333. -- MINBOX is hidden only if MAXBOX is hidden as well, or else it will be
  334. -- just disabled.
  335. do
  336. iup_open.set_attribute(Current, "MINBOX", boolean_to_yesno(state))
  337. end
  338. set_minsize (width, height: INTEGER)
  339. -- Minimum size for the dialog in raster units (pixels). The windowing
  340. -- system will not be able to change the size beyond this limit. Default:
  341. -- 1x1. Some systems define a very minimum size greater than this, for
  342. -- instance in Windows the horizontal minimum size includes the window
  343. -- decoration buttons.
  344. do
  345. Precursor (width, height)
  346. end
  347. get_minsize: TUPLE[INTEGER, INTEGER]
  348. -- Min size of the dialog.
  349. do
  350. Result := Precursor
  351. end
  352. is_modal: BOOLEAN
  353. local
  354. str: STRING
  355. do
  356. str := iup_open.get_attribute(Current, "MODAL")
  357. Result := yesno_to_boolean(str)
  358. end
  359. set_native_parent (dlg: IUP_DIALOG)
  360. -- (creation only): Dialog to be used as parent. Used
  361. -- only if PARENTDIALOG is not defined.
  362. do
  363. iup_open.set_attribute_widget(Current, "NATIVEPARENT", dlg)
  364. end
  365. -- Skip placement.
  366. set_resize (state: BOOLEAN)
  367. -- (creation only): Allows interactively changing the dialog’s size.
  368. -- Default: True. If RESIZE=NO then MAXBOX will be set to NO. In Motif
  369. -- the decorations are controlled by the Window Manager and may not be
  370. -- possible to be changed from IUP.
  371. do
  372. iup_open.set_attribute(Current, "RESIZE", boolean_to_yesno(state))
  373. end
  374. set_shrink (state: BOOLEAN)
  375. -- Allows changing the elements’ distribution when the dialog is smaller
  376. -- than the minimum size. Default: False.
  377. do
  378. iup_open.set_attribute(Current, "SHRINK", boolean_to_yesno(state))
  379. end
  380. set_start_focus (name: STRING)
  381. -- Name of the element that must receive the focus right after the dialog
  382. -- is shown using IupShow or IupPopup. If not defined then the first
  383. -- control than can receive the focus is selected. Updated after SHOW_CB
  384. -- is called and only if the focus was not changed during the callback.
  385. do
  386. iup_open.set_attribute(Current, "STARTFOCUS", name)
  387. end
  388. -- Exclusive [System Dependent]
  389. -- Skip HWND
  390. -- Skip SAVEUNDER
  391. -- Skip XWINDOW
  392. -- The next attributes are Windows and GTK only.
  393. is_active_window: BOOLEAN
  394. -- [Windows and GTK Only] (read-only): informs if the dialog is the
  395. --active window (the window with focus). Can be True or False.
  396. local
  397. str: STRING
  398. do
  399. str := iup_open.get_attribute(Current, "ACTIVEWINDOW")
  400. Result := yesno_to_boolean(str)
  401. end
  402. -- Skip CUSTOMFRAME
  403. set_as_drop_files_target (state: BOOLEAN)
  404. -- [Windows and GTK Only] (non inheritable): Enable or disable the drop
  405. -- of files. Default: False, but if DROPFILES_CB is defined when the
  406. -- element is mapped then it will be automatically enabled.
  407. do
  408. iup_open.set_attribute(Current, "DROPFILESTARGET", boolean_to_yesno(state))
  409. end
  410. is_drop_files_target: BOOLEAN
  411. -- Drop files target state.
  412. local
  413. str: STRING
  414. do
  415. str := iup_open.get_attribute(Current, "DROPFILESTARGET")
  416. Result := yesno_to_boolean(str)
  417. end
  418. is_maximized: BOOLEAN
  419. -- [Windows Only] (read-only): indicates if the dialog is maximized. Can
  420. -- be True or False.
  421. local
  422. str: STRING
  423. do
  424. str := iup_open.get_attribute(Current, "MAXIMIZED")
  425. Result := yesno_to_boolean(str)
  426. end
  427. is_minimized: BOOLEAN
  428. -- [Windows Only] (read-only): indicates if the dialog is minimized. Can
  429. -- be True or False.
  430. local
  431. str: STRING
  432. do
  433. str := iup_open.get_attribute(Current, "MINIMIZED")
  434. Result := yesno_to_boolean(str)
  435. end
  436. set_opacity (value: INTEGER)
  437. -- [Windows and GTK Only]: sets the dialog transparency alpha value.
  438. -- Valid values range from 0 (completely transparent) to 255 (opaque). In
  439. -- Windows must be set before map so the native window would be properly
  440. -- initialized when mapped
  441. require
  442. value >= 0
  443. value <= 255
  444. do
  445. iup_open.set_attribute(Current, "OPACITY", value.to_string)
  446. end
  447. set_opacity_image (name: STRING)
  448. -- [Windows and GTK Only]: sets a transparent image as the dialog shape so
  449. -- it is possible to create a non rectangle window. In Windows must be
  450. -- set before map so the native window would be properly initialized when
  451. -- mapped. In GTK the shape works only as a bitmap mask, to view a color
  452. -- image must also use a label.
  453. do
  454. iup_open.set_attribute(Current, "OPACITYIMAGE", name)
  455. end
  456. set_top_most (state: BOOLEAN)
  457. -- [Windows and GTK Only]: puts the dialog always in front of all other
  458. -- dialogs in all applications. Default: False.
  459. do
  460. iup_open.set_attribute(Current, "TOPMOST", boolean_to_yesno(state))
  461. end
  462. -- Exclusive Taskbar and Tray/Status Area [Windows and GTK Only]
  463. set_hide_taskbar (state: BOOLEAN)
  464. -- [Windows and GTK Only] (write-only): Action attribute that when set to
  465. -- "YES", hides the dialog, but does not decrement the visible dialog
  466. -- count, does not call SHOW_CB and does not mark the dialog as hidden
  467. -- inside IUP. It is usually used to hide the dialog and keep the tray
  468. -- icon working without closing the main loop. It has the same effect as
  469. -- setting LOCKLOOP=Yes and normally hiding the dialog. IMPORTANT: when
  470. -- you hide using HIDETASKBAR, you must show using HIDETASKBAR also.
  471. -- Possible values: True, False.
  472. do
  473. iup_open.set_attribute(Current, "HIDETASKBAR", boolean_to_yesno(state))
  474. end
  475. -- Skip TASKBARPROGRESS, TASKBARPROGRESSSTATE, TASKBARPROGRESSVALUE
  476. set_tray (state: BOOLEAN)
  477. -- [Windows and GTK Only]: When set to "True", displays an icon on the
  478. -- system tray.
  479. do
  480. iup_open.set_attribute(Current, "TRAY", boolean_to_yesno(state))
  481. end
  482. set_tray_image (name: STRING)
  483. -- [Windows and GTK Only]: Name of a IUP image to be used as the tray
  484. -- icon. The Windows SDK recommends that cursors and icons should be
  485. -- implemented as resources rather than created at run time.
  486. do
  487. iup_open.set_attribute(Current, "TRAYIMAGE", name)
  488. end
  489. set_tray_tip (text: STRING)
  490. -- [Windows and GTK Only]: Tray icon's tooltip text.
  491. do
  492. iup_open.set_attribute(Current, "TRAYTIP", text)
  493. end
  494. -- Skip TRAYTIPMARKUP, TRAYTIPBALLOON, TRAYTIPBALLOONDELAY,
  495. -- TRAYTIPBALLOONTITLE, TRAYTIPBALLOONTITLEICON
  496. -- Exclusive [GTK Only]
  497. set_dialog_hint (state: BOOLEAN)
  498. -- [GTK Only] (creation-only): if enabled sets the window type hint to a
  499. -- dialog hint.
  500. do
  501. iup_open.set_attribute(Current, "DIALOGHINT", boolean_to_yesno(state))
  502. end
  503. set_hide_title_bar (state: BOOLEAN)
  504. -- [GTK Only] (non inheritable): hides the title bar with all its
  505. -- elements. (since 3.20) (GTK 3.10)
  506. do
  507. iup_open.set_attribute(Current, "HIDETITLEBAR",
  508. boolean_to_yesno(state))
  509. end
  510. -- Exclusive [Windows Only]
  511. set_bring_front (state: BOOLEAN)
  512. -- [Windows Only] (write-only): makes the dialog the foreground window.
  513. -- Use "True" to activate it. Useful for multithreaded applications.
  514. do
  515. iup_open.set_attribute(Current, "BRINGFRONT", boolean_to_yesno(state))
  516. end
  517. set_composited (state: BOOLEAN)
  518. -- [Windows Only] (creation only): controls if the window will have an
  519. -- automatic double buffer for all children. Default is "False". In
  520. -- Windows Vista it is NOT working as expected.
  521. do
  522. iup_open.set_attribute(Current, "COMPOSITED", boolean_to_yesno(state))
  523. end
  524. -- Skip CONTROL
  525. -- Skip CUSTOMFRAMEDRAW, CUSTOMFRAMECAPTIONHEIGHT, CUSTOMFRAMECAPTIONLIMITS
  526. set_help_button (state: BOOLEAN)
  527. -- [Windows Only] (creation only): Inserts a help button in the same
  528. -- place of the maximize button. It can only be used for dialogs without
  529. -- the minimize and maximize buttons, and with the menu box. For the next
  530. -- interaction of the user with a control in the dialog, the callback
  531. -- HELP_CB will be called instead of the control defined ACTION callback.
  532. -- Possible values: True, False. Default: False.
  533. do
  534. iup_open.set_attribute(Current, "HELPBUTTON", boolean_to_yesno(state))
  535. end
  536. set_toolbox (state: BOOLEAN)
  537. -- [Windows Only] (creation only): makes the dialog look like a toolbox
  538. -- with a smaller title bar. It is only valid if the PARENTDIALOG or
  539. -- NATIVEPARENT attribute is also defined. Default: False.
  540. do
  541. iup_open.set_attribute(Current, "TOOLBOX", boolean_to_yesno(state))
  542. end
  543. -- Exclusive MDI [Windows Only]
  544. set_mdi_frame (state: BOOLEAN)
  545. --(creation only) [Windows Only] (non inheritable): Configure this dialog
  546. -- as a MDI frame. Can be True or False. Default: False.
  547. do
  548. iup_open.set_attribute(Current, "MDIFRAME", boolean_to_yesno(state))
  549. end
  550. get_mdi_active: STRING
  551. -- [Windows Only] (read-only): Returns the name of the current active MDI
  552. -- child. Use get_attribute_handle to directly retrieve the child
  553. -- widget.
  554. do
  555. Result := iup_open.get_attribute(Current, "MDIACTIVE")
  556. end
  557. set_mdi_activate (name: STRING)
  558. -- [Windows Only] (write-only): Name of a MDI child window to be
  559. -- activated. If value is "NEXT" will activate the next window after the
  560. -- current active window. If value is "PREVIOUS" will activate the
  561. -- previous one.
  562. do
  563. iup_open.set_attribute(Current, "MDIACTIVATE", name)
  564. end
  565. set_mdi_arrange (type: STRING)
  566. -- [Windows Only] (write-only): Action to arrange MDI child windows.
  567. -- Possible values: TILEHORIZONTAL, TILEVERTICAL, CASCADE and ICON
  568. -- (arrange the minimized icons).
  569. require
  570. is_valid_type(type)
  571. do
  572. iup_open.set_attribute(Current, "MDIARRANGE", type)
  573. end
  574. set_mdi_close_all
  575. -- [Windows Only] (write-only): Action to close and destroy all MDI child
  576. -- windows. The CLOSE_CB callback will be called for each child.
  577. -- IMPORTANT: When a MDI child window is closed it is automatically
  578. -- destroyed. The application can override this returning IUP_IGNORE in
  579. -- CLOSE_CB.
  580. do
  581. iup_open.set_attribute(Current, "MDICLOSEALL", "YES")
  582. end
  583. get_mdi_next: STRING
  584. -- [Windows Only] (read-only): Returns the name of the next available
  585. -- MDI child. Use get_attribute_handle to directly retrieve the child
  586. -- widget. Must use MDIACTIVE to retrieve the first child. If the
  587. -- application is going to destroy the child retrieve the next child
  588. -- before destroying the current.
  589. do
  590. Result := iup_open.get_attribute(Current, "MDINEXT")
  591. end
  592. -- For the MDI Client MDICLIENT and MDIMENU see IUP_CANVAS
  593. set_mdi_child (state: BOOLEAN)
  594. -- (creation only) [Windows Only]: Configure this dialog to be a MDI
  595. -- child. The PARENTDIALOG attribute must also be defined. Each MDI child
  596. -- is automatically named if it does not have one. Default: "False".
  597. do
  598. iup_open.set_attribute(Current, "MDICHILD", boolean_to_yesno(state))
  599. end
  600. -- Commands to handle callbacks
  601. -- Common
  602. set_cb_map (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  603. -- Called right after an element is mapped and its attributes updated.
  604. local
  605. operation: INTEGER
  606. do
  607. cb_map := act
  608. if cb_map /= Void then
  609. operation := 1
  610. else
  611. operation := 0
  612. end
  613. iup_open.set_callback (Current, "MAP_CB", "NONEEDED", operation)
  614. end
  615. set_cb_unmap (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  616. -- Called right before an element is unmapped.
  617. local
  618. operation: INTEGER
  619. do
  620. cb_unmap := act
  621. if cb_unmap /= Void then
  622. operation := 1
  623. else
  624. operation := 0
  625. end
  626. iup_open.set_callback (Current, "UNMAP_CB", "NONEEDED", operation)
  627. end
  628. set_cb_destroy (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  629. -- Called right before an element is destroyed.
  630. local
  631. operation: INTEGER
  632. do
  633. cb_destroy := act
  634. if cb_destroy /= Void then
  635. operation := 1
  636. else
  637. operation := 0
  638. end
  639. iup_open.set_callback (Current, "DESTROY_CB", "NONEEDED", operation)
  640. end
  641. set_cb_get_focus (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  642. -- Action generated when an element is given keyboard focus.
  643. -- This callback is called after the KILLFOCUS_CB of the element
  644. -- that loosed the focus. The {IUP}.get_focus function during the
  645. -- callback returns the element that loosed the focus.
  646. local
  647. operation: INTEGER
  648. do
  649. cb_getfocus := act
  650. if cb_getfocus /= Void then
  651. operation := 1
  652. else
  653. operation := 0
  654. end
  655. iup_open.set_callback (Current, "GETFOCUS_CB", "NONEEDED", operation)
  656. end
  657. set_cb_kill_focus (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  658. -- Action generated when an element loses keyboard focus. This
  659. -- callback is called before the GETFOCUS_CB of the element that
  660. -- gets the focus.
  661. local
  662. operation: INTEGER
  663. do
  664. cb_killfocus := act
  665. if cb_killfocus /= Void then
  666. operation := 1
  667. else
  668. operation := 0
  669. end
  670. iup_open.set_callback (Current, "KILLFOCUS_CB", "NONEEDED", operation)
  671. end
  672. set_cb_enter_window (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  673. -- Action generated when the mouse enters the native element.
  674. local
  675. operation: INTEGER
  676. do
  677. cb_enterwindow := act
  678. if cb_enterwindow /= Void then
  679. operation := 1
  680. else
  681. operation := 0
  682. end
  683. iup_open.set_callback (Current, "ENTERWINDOW_CB", "NONEEDED", operation)
  684. end
  685. set_cb_leave_window (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  686. -- Action generated when the mouse leaves the native element.
  687. local
  688. operation: INTEGER
  689. do
  690. cb_leavewindow := act
  691. if cb_leavewindow /= Void then
  692. operation := 1
  693. else
  694. operation := 0
  695. end
  696. iup_open.set_callback (Current, "LEAVEWINDOW_CB", "NONEEDED", operation)
  697. end
  698. set_cb_k_any (act: FUNCTION[TUPLE[IUP_DIALOG, INTEGER], STRING])
  699. -- Action generated when a keyboard event occurs.
  700. -- IUP_WIDGET the element that activated the event.
  701. -- INTEGER identifier of typed key. Please refer to the Keyboard
  702. -- Codes table for a list of possible values.
  703. --
  704. -- Returns: If IUP_IGNORE is returned the key is ignored and not
  705. -- processed by the control and not propagated. If returns
  706. -- IUP_CONTINUE, the key will be processed and the event will be
  707. -- propagated to the parent of the element receiving it, this is
  708. -- the default behavior. If returns IUP_DEFAULT the key is processed
  709. -- but it is not propagated. IUP_CLOSE will be processed.
  710. local
  711. operation: INTEGER
  712. do
  713. cb_k_any := act
  714. if cb_k_any /= Void then
  715. operation := 1
  716. else
  717. operation := 0
  718. end
  719. iup_open.set_callback (Current, "K_ANY", "NONEEDED", operation)
  720. end
  721. set_cb_help (act: PROCEDURE[TUPLE[IUP_DIALOG]])
  722. -- Action generated when the user press F1 at a control. In Motif
  723. -- is also activated by the Help button in some workstations
  724. -- keyboard.
  725. -- Returns: IUP_CLOSE will be processed.
  726. local
  727. operation: INTEGER
  728. do
  729. cb_help := act
  730. if cb_help /= Void then
  731. operation := 1
  732. else
  733. operation := 0
  734. end
  735. iup_open.set_callback (Current, "HELP_CB", "NONEEDED", operation)
  736. end
  737. -- Extra
  738. set_cb_close (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  739. local
  740. operation: INTEGER
  741. do
  742. cb_close := act
  743. if cb_close /= Void then
  744. operation := 1
  745. else
  746. operation := 0
  747. end
  748. iup_open.set_callback (Current, "CLOSE_CB", "NONEEDED", operation)
  749. end
  750. set_cb_copy_data (act: FUNCTION[TUPLE[IUP_DIALOG, STRING, INTEGER], STRING])
  751. local
  752. operation: INTEGER
  753. do
  754. cb_copydata := act
  755. if cb_copydata /= Void then
  756. operation := 1
  757. else
  758. operation := 0
  759. end
  760. iup_open.set_callback (Current, "COPYDATA_CB", "NONEEDED", operation)
  761. end
  762. set_cb_drop_files (act: FUNCTION[TUPLE[IUP_DIALOG, STRING, INTEGER, INTEGER, INTEGER], STRING])
  763. local
  764. operation: INTEGER
  765. do
  766. cb_dropfiles := act
  767. if cb_dropfiles /= Void then
  768. operation := 1
  769. else
  770. operation := 0
  771. end
  772. iup_open.set_callback (Current, "DROPFILES_CB", "NONEEDED", operation)
  773. end
  774. set_cb_mdi_activate (act: FUNCTION[TUPLE[IUP_DIALOG], STRING])
  775. local
  776. operation: INTEGER
  777. do
  778. cb_mdiactivate := act
  779. if cb_mdiactivate /= Void then
  780. operation := 1
  781. else
  782. operation := 0
  783. end
  784. iup_open.set_callback (Current, "MDIACTIVATE_CB", "NONEEDED", operation)
  785. end
  786. set_cb_move (act: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER], STRING])
  787. local
  788. operation: INTEGER
  789. do
  790. cb_move := act
  791. if cb_move /= Void then
  792. operation := 1
  793. else
  794. operation := 0
  795. end
  796. iup_open.set_callback (Current, "MOVE_CB", "NONEEDED", operation)
  797. end
  798. set_cb_resize (act: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER], STRING])
  799. local
  800. operation: INTEGER
  801. do
  802. cb_resize := act
  803. if cb_resize /= Void then
  804. operation := 1
  805. else
  806. operation := 0
  807. end
  808. iup_open.set_callback (Current, "RESIZE_CB", "NONEEDED", operation)
  809. end
  810. set_cb_show (act: FUNCTION[TUPLE[IUP_DIALOG, STRING], STRING])
  811. local
  812. operation: INTEGER
  813. do
  814. cb_show := act
  815. if cb_show /= Void then
  816. operation := 1
  817. else
  818. operation := 0
  819. end
  820. iup_open.set_callback (Current, "SHOW_CB", "NONEEDED", operation)
  821. end
  822. set_cb_tray_click (act: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER, INTEGER], STRING])
  823. local
  824. operation: INTEGER
  825. do
  826. cb_trayclick := act
  827. if cb_trayclick /= Void then
  828. operation := 1
  829. else
  830. operation := 0
  831. end
  832. iup_open.set_callback (Current, "TRAYCLICK_CB", "NONEEDED", operation)
  833. end
  834. set_cb_focus (act: FUNCTION[TUPLE[IUP_DIALOG, INTEGER], STRING])
  835. -- Called when the dialog or any of its children gets the focus, or when
  836. -- another dialog or any control in another dialog gets the focus. It is
  837. -- called after the common callbacks GETFOCUS_CB and KILLFOCUS_CB.
  838. local
  839. operation: INTEGER
  840. do
  841. cb_focus := act
  842. if cb_focus /= Void then
  843. operation := 1
  844. else
  845. operation := 0
  846. end
  847. iup_open.set_callback (Current, "FOCUS_CB", "NONEEDED", operation)
  848. end
  849. feature {ANY}
  850. execute_map: STRING
  851. do
  852. Result := cb_map.item([Current])
  853. end
  854. execute_unmap: STRING
  855. do
  856. Result := cb_unmap.item([Current])
  857. end
  858. execute_destroy: STRING
  859. do
  860. Result := cb_destroy.item([Current])
  861. end
  862. execute_getfocus: STRING
  863. do
  864. Result := cb_getfocus.item([Current])
  865. end
  866. execute_killfocus: STRING
  867. do
  868. Result := cb_getfocus.item([Current])
  869. end
  870. execute_enterwindow: STRING
  871. do
  872. Result := cb_enterwindow.item([Current])
  873. end
  874. execute_leavewindow: STRING
  875. do
  876. Result := cb_leavewindow.item([Current])
  877. end
  878. execute_k_any (c: INTEGER): STRING
  879. do
  880. Result := cb_k_any.item([Current, c])
  881. end
  882. execute_help
  883. do
  884. cb_help.call([Current])
  885. end
  886. execute_close: STRING
  887. do
  888. Result := cb_close.item([Current])
  889. end
  890. execute_copydata (cmdline: STRING; size: INTEGER): STRING
  891. do
  892. Result := cb_copydata.item([Current, cmdline, size])
  893. end
  894. execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
  895. do
  896. Result := cb_dropfiles.item([Current, filename, num, x, y])
  897. end
  898. execute_mdiactivate: STRING
  899. do
  900. Result := cb_mdiactivate.item([Current])
  901. end
  902. execute_move (x: INTEGER; y: INTEGER): STRING
  903. do
  904. Result := cb_move.item([Current, x, y])
  905. end
  906. execute_resize (width: INTEGER; height: INTEGER): STRING
  907. do
  908. Result := cb_resize.item([Current, width, height])
  909. end
  910. execute_show (state: STRING): STRING
  911. do
  912. Result := cb_show.item([Current, state])
  913. end
  914. execute_trayclick (but: INTEGER; pressed: INTEGER; dclick: INTEGER): STRING
  915. do
  916. Result := cb_trayclick.item([Current, but, pressed, dclick])
  917. end
  918. execute_focus (focus: INTEGER): STRING
  919. do
  920. Result := cb_focus.item([Current, focus])
  921. end
  922. feature {IUP}
  923. dialog_widget (a_dialog: POINTER)
  924. do
  925. set_widget(a_dialog)
  926. end
  927. feature {}
  928. -- Callbacks
  929. cb_map: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  930. cb_unmap: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  931. cb_destroy: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  932. cb_getfocus: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  933. cb_killfocus: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  934. cb_enterwindow: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  935. cb_leavewindow: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  936. cb_k_any: FUNCTION[TUPLE[IUP_DIALOG, INTEGER], STRING]
  937. cb_help: PROCEDURE[TUPLE[IUP_DIALOG]]
  938. cb_close: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  939. cb_copydata: FUNCTION[TUPLE[IUP_DIALOG, STRING, INTEGER], STRING]
  940. cb_dropfiles: FUNCTION[TUPLE[IUP_DIALOG, STRING, INTEGER, INTEGER, INTEGER], STRING]
  941. cb_mdiactivate: FUNCTION[TUPLE[IUP_DIALOG], STRING]
  942. cb_move: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER], STRING]
  943. cb_resize: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER], STRING]
  944. cb_show: FUNCTION[TUPLE[IUP_DIALOG, STRING], STRING]
  945. cb_trayclick: FUNCTION[TUPLE[IUP_DIALOG, INTEGER, INTEGER, INTEGER], STRING]
  946. cb_focus: FUNCTION[TUPLE[IUP_DIALOG, INTEGER], STRING]
  947. -- Validations
  948. is_valid_size (width, height: STRING): BOOLEAN
  949. local
  950. widths, heights: BOOLEAN
  951. do
  952. if width.is_equal("NULL") or
  953. width.is_equal("FULL") or
  954. width.is_equal("HALF") or
  955. width.is_equal("THIRD") or
  956. width.is_equal("QUARTER") or
  957. width.is_equal("EIGHTH") then
  958. widths := True
  959. elseif width.is_integer and width.to_integer >= 0 then
  960. widths := True
  961. else
  962. widths := False
  963. end
  964. if height.is_equal("NULL") or
  965. height.is_equal("FULL") or
  966. height.is_equal("HALF") or
  967. height.is_equal("THIRD") or
  968. height.is_equal("QUARTER") or
  969. height.is_equal("EIGHTH") then
  970. heights := True
  971. elseif height.is_integer and height.to_integer >= 0 then
  972. heights := True
  973. else
  974. heights := False
  975. end
  976. if widths and heights then
  977. Result := True
  978. else
  979. Result := False
  980. end
  981. end
  982. is_valid_type (type: STRING): BOOLEAN
  983. do
  984. if type.is_equal("TILEHORIZONTAL") or
  985. type.is_equal("TILEVERTICAL") or
  986. type.is_equal("CASCADE") or
  987. type.is_equal("ICON") then
  988. Result := True
  989. else
  990. Result := False
  991. end
  992. end
  993. -- Internals
  994. int_dialog (wdt: POINTER): POINTER
  995. external "plug_in"
  996. alias "{
  997. location: "${sys}/plugins"
  998. module_name: "iup"
  999. feature_name: "IupDialog"
  1000. }"
  1001. end
  1002. end -- class IUP_DIALOG
  1003. -- The MIT License (MIT)
  1004. -- Copyright (c) 2016, 2017, 2018 by German A. Arias
  1005. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  1006. -- of this software and associated documentation files (the "Software"), to deal
  1007. -- in the Software without restriction, including without limitation the rights
  1008. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1009. -- copies of the Software, and to permit persons to whom the Software is
  1010. -- furnished to do so, subject to the following conditions:
  1011. --
  1012. -- The above copyright notice and this permission notice shall be included in
  1013. -- all copies or substantial portions of the Software.
  1014. --
  1015. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1016. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1017. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1018. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1019. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1020. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1021. -- SOFTWARE.