iup_dialog.e 36 KB

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