eiffel-iup.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. // The MIT License (MIT)
  2. // Copyright (c) 2020 by German A. Arias
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  19. // SOFTWARE.
  20. // IUP
  21. #include <stdlib.h>
  22. #include <iup/iup.h>
  23. #include <iup/iupkey.h>
  24. #include <iup/iup_config.h>
  25. #include <iup/iupcontrols.h>
  26. // For IM
  27. #include <im/im.h>
  28. #include <im/im_image.h>
  29. #include <iup/iupim.h>
  30. // For CD
  31. #include <cd/cd.h>
  32. #include <cd/wd.h>
  33. #include <cd/cdiup.h>
  34. #include <cd/cdim.h>
  35. #ifndef _library_eiffel_iup_h
  36. # define _library_eiffel_iup_h
  37. # if defined(_MSC_VER) && (_MSC_VER >= 1020)
  38. # pragma once
  39. # endif
  40. // Convert const char* to char*
  41. char* unconst_char (const char* s);
  42. void set_callbacks (EIF_REFERENCE iup_obj,
  43. EIF_PROC launch_help_cb_fn, EIF_PROC launch_idle_action_fidle, EIF_PROC launch_map_cb_fn,
  44. EIF_PROC launch_unmap_cb_fn, EIF_PROC launch_destroy_cb_fn, EIF_PROC launch_ldestroy_cb_fn,
  45. EIF_PROC launch_getfocus_cb_fn, EIF_PROC launch_killfocus_cb_fn, EIF_PROC launch_enterwindow_cb_fn,
  46. EIF_PROC launch_leavewindow_cb_fn, EIF_PROC launch_action_fn, EIF_PROC launch_k_any_fni,
  47. EIF_PROC launch_close_cb_fn, EIF_PROC launch_copydata_cb_fnsi, EIF_PROC launch_dropfiles_cb_fnsiii,
  48. EIF_PROC launch_mdiactivate_cb_fn, EIF_PROC launch_move_cb_fnii, EIF_PROC launch_resize_cb_fnii,
  49. EIF_PROC launch_show_cb_fni, EIF_PROC launch_trayclick_cb_fniii, EIF_PROC launch_file_cb_fnss,
  50. EIF_PROC launch_colorupdate_cb_fn, EIF_PROC launch_cancel_cb_fn, EIF_PROC launch_tabchange_cb_fnnn,
  51. EIF_PROC launch_tabchangepos_cb_fnii, EIF_PROC launch_tabclose_cb_fni, EIF_PROC launch_rightclick_cb_fni,
  52. EIF_PROC launch_detached_cb_fnnii, EIF_PROC launch_restored_cb_fnnii, EIF_PROC launch_openclose_cb_fni,
  53. EIF_PROC launch_extrabutton_cb_fnii, EIF_PROC launch_valuechanged_cb_fn, EIF_PROC launch_button_cb_fniiiis,
  54. EIF_PROC launch_action_fnff, EIF_PROC launch_focus_cb_fni, EIF_PROC launch_motion_cb_fniis, EIF_PROC launch_keypress_cb_fnii,
  55. EIF_PROC launch_scroll_cb_fniff, EIF_PROC launch_wheel_cb_fndiis, EIF_PROC launch_click_cb_fns,
  56. EIF_PROC launch_action_fnsii, EIF_PROC launch_caret_cb_fniii, EIF_PROC launch_dblclick_cb_fnis,
  57. EIF_PROC launch_dragdrop_cb_fniiii, EIF_PROC launch_dropdown_cb_fni, EIF_PROC launch_edit_cb_fnis,
  58. EIF_PROC launch_multiselect_cb_fns, EIF_PROC launch_spin_cb_fni, EIF_PROC launch_action_fnis,
  59. EIF_PROC launch_action_fni, EIF_PROC launch_selection_cb_fnii, EIF_PROC launch_multiselection_cb_fnpi,
  60. EIF_PROC launch_multiunselection_cb_fnpi, EIF_PROC launch_branchopen_cb_fni, EIF_PROC launch_branchclose_cb_fni,
  61. EIF_PROC launch_executeleaf_cb_fni, EIF_PROC launch_showrename_cb_fni, EIF_PROC launch_rename_cb_fnis,
  62. EIF_PROC launch_noderemoved_cb_fns, EIF_PROC launch_togglevalue_cb_fnii, EIF_PROC launch_highlight_cb_fn,
  63. EIF_PROC launch_open_cb_fn, EIF_PROC launch_menuclose_cb_fn, EIF_PROC launch_dragbegin_cb_fnii,
  64. EIF_PROC launch_dragdatasize_cb_fns, EIF_PROC launch_dragdata_cb_fnsvi, EIF_PROC launch_dragend_cb_fni,
  65. EIF_PROC launch_dropdata_cb_fnsviii, EIF_PROC launch_dropmotion_cb_fniis, EIF_PROC launch_recent_cb_fn,
  66. EIF_PROC launch_param_cb_fniv, EIF_PROC launch_flat_action_fn, EIF_PROC launch_flat_button_cb_fniiiis,
  67. EIF_PROC launch_flat_focus_cb_fni, EIF_PROC launch_flat_enterwindow_cb_fn, EIF_PROC launch_flat_leavewindow_cb_fn,
  68. EIF_PROC launch_draw_cb_fniiiiiic, EIF_PROC launch_height_cb_fni, EIF_PROC launch_hspan_cb_fnii,
  69. EIF_PROC launch_mouseclick_cb_fniiiiiis, EIF_PROC launch_mousemotion_cb_fniiiis, EIF_PROC launch_ncols_cb_fn,
  70. EIF_PROC launch_nlines_cb_fn, EIF_PROC launch_scrolling_cb_fnii, EIF_PROC launch_vspan_cb_fnii,
  71. EIF_PROC launch_width_cb_fni, EIF_PROC launch_cell_fni, EIF_PROC launch_extended_fni,
  72. EIF_PROC launch_select_fnii, EIF_PROC launch_switch_fnii, EIF_PROC launch_action_fniiiis,
  73. EIF_PROC launch_click_fniis, EIF_PROC launch_colresize_fni, EIF_PROC launch_release_fniis,
  74. EIF_PROC launch_resizematrix_fnii, EIF_PROC launch_mousemove_fnii, EIF_PROC launch_enteritem_fnii,
  75. EIF_PROC launch_leaveitem_fnii, EIF_PROC launch_scrolltop_fnii, EIF_PROC launch_bgcolor_fniivvv,
  76. EIF_PROC launch_fgcolor_fniivvv, EIF_PROC launch_font_fnii, EIF_PROC launch_type_fnii,
  77. EIF_PROC launch_dropcheck_fnii, EIF_PROC launch_translatevalue_fniis, EIF_PROC launch_togglevalue_fniii,
  78. EIF_PROC launch_drop_fnnii, EIF_PROC launch_menudrop_fnnii, EIF_PROC launch_dropselect_fniinsii,
  79. EIF_PROC launch_edition_fniiii, EIF_PROC launch_value_fnii, EIF_PROC launch_value_edit_fniis,
  80. EIF_PROC launch_mark_fnii, EIF_PROC launch_markedit_fniii, EIF_PROC launch_flat_motion_cb_fniis,
  81. EIF_PROC launch_dropshow_cb_fni, EIF_PROC launch_button_press_cb_fnd, EIF_PROC launch_button_release_cb_fnd,
  82. EIF_PROC launch_mousemove_cb_fnd, EIF_PROC launch_change_cb_fnvvv, EIF_PROC launch_drag_cb_fnvvv);
  83. int param_action(Ihandle* dialog, int param_index, void* user_data);
  84. int get_param_dialog (const char* title, void* user_data, const char* format, int param_count, int param_extra, void** param_data);
  85. // One function for each type of event
  86. // Common callbacks
  87. int callback_idle_action(void);
  88. void callback_help_cb(Ihandle *ih);
  89. int callback_map_cb(Ihandle *ih);
  90. int callback_unmap_cb(Ihandle *ih);
  91. int callback_destroy_cb(Ihandle *ih);
  92. int callback_ldestroy_cb(Ihandle *ih);
  93. int callback_getfocus_cb(Ihandle *ih);
  94. int callback_killfocus_cb(Ihandle *ih);
  95. int callback_enterwindow_cb(Ihandle *ih);
  96. int callback_leavewindow_cb(Ihandle *ih);
  97. int callback_k_any(Ihandle *ih, int c);
  98. // Action callbacks
  99. int callback_action_Fn(Ihandle *ih);
  100. // Dialog and progress dialog callback
  101. int callback_close_cb(Ihandle *ih);
  102. int callback_copydata_cb(Ihandle *ih, char* cmdLine, int size);
  103. int callback_dropfiles_cb(Ihandle *ih, char* filename, int num, int x, int y);
  104. int callback_mdiactivate_cb(Ihandle *ih);
  105. int callback_move_cb(Ihandle *ih, int x, int y);
  106. int callback_resize_cb(Ihandle *ih, int width, int height);
  107. int callback_show_cb(Ihandle *ih, int state);
  108. int callback_trayclick_cb(Ihandle *ih, int but, int pressed, int dclick);
  109. // File dialog callback
  110. int callback_file_cb(Ihandle *ih, char* file_name, char* status);
  111. // Color dialog callback
  112. int callback_colorupdate_cb (Ihandle* ih);
  113. // Progress dialog callback
  114. int callback_cancel_cb (Ihandle* ih);
  115. /*
  116. // Get param dialog callback
  117. int callback_getparam(Ihandle* dialog, int param_index, void* user_data);
  118. */
  119. // Tabs callbacks
  120. int callback_tabchange_cb(Ihandle *ih, Ihandle* new_tab, Ihandle* old_tab);
  121. int callback_tabchangepos_cb(Ihandle *ih, int new_pos, int old_pos);
  122. int callback_tabclose_cb(Ihandle *ih, int pos);
  123. int callback_rightclick_cb(Ihandle *ih, int pos);
  124. // Detach box callback
  125. int callback_detached_cb(Ihandle *ih, Ihandle *new_parent, int x, int y);
  126. int callback_restored_cb(Ihandle *ih, Ihandle *old_parent, int x, int y);
  127. // Expander callbacks
  128. int callback_openclose_cb(Ihandle *ih, int state);
  129. int callback_extrabutton_cb(Ihandle *ih, Ihandle *new_parent, int button, int pressed);
  130. // Val callback
  131. int callback_valuechanged_cb(Ihandle *ih);
  132. // Button callback
  133. int callback_button_cb(Ihandle *ih, int button, int pressed, int x, int y, char* status);
  134. // Canvas callbacks
  135. int callback_action_Fnff(Ihandle *ih, float posx, float posy);
  136. // Also Dialog
  137. int callback_focus_cb(Ihandle *ih, int focus);
  138. int callback_motion_cb(Ihandle *ih, int x, int y, char *status);
  139. int callback_keypress_cb(Ihandle *ih, int c, int press);
  140. int callback_scroll_cb(Ihandle *ih, int op, float posx, float posy);
  141. int callback_wheel_cb(Ihandle *ih, float delta, int x, int y, char *status);
  142. int callback_click_cb(Ihandle *ih, char *url);
  143. // List callbacks
  144. int callback_action_Fnsii(Ihandle *ih, char *text, int item, int state);
  145. int callback_caret_cb(Ihandle *ih, int lin, int col, int pos);
  146. int callback_dblclick_cb(Ihandle *ih, int item, char *text);
  147. int callback_dragdrop_cb(Ihandle *ih, int drag_id, int drop_id, int isshift, int iscontrol);
  148. int callback_dropdown_cb(Ihandle *ih, int state);
  149. int callback_edit_cb(Ihandle *ih, int c, char *new_value);
  150. int callback_multiselect_cb(Ihandle *ih, char *value);
  151. // Spin callback
  152. int callback_spin_cb(Ihandle *ih, int inc);
  153. // Text callback
  154. int callback_action_Fnis(Ihandle *ih, int c, char *new_value);
  155. // Toggle callback
  156. int callback_action_Fni(Ihandle* ih, int state);
  157. // Tree callbacks
  158. int callback_selection_cb (Ihandle *ih, int id, int status);
  159. int callback_multiselection_cb (Ihandle *ih, int* ids, int n);
  160. int callback_multiunselection_cb (Ihandle *ih, int* ids, int n);
  161. int callback_branchopen_cb (Ihandle *ih, int id);
  162. int callback_branchclose_cb (Ihandle *ih, int id);
  163. int callback_executeleaf_cb (Ihandle *ih, int id);
  164. int callback_showrename_cb (Ihandle *ih, int id);
  165. int callback_rename_cb (Ihandle *ih, int id, char *title);
  166. int callback_noderemoved_cb (Ihandle *ih, void* userdata);
  167. int callback_togglevalue_cb_Fnii (Ihandle *ih, int id, int state);
  168. // Menu callbacks
  169. int callback_highlight_cb (Ihandle *ih);
  170. int callback_open_cb (Ihandle *ih);
  171. int callback_menuclose_cb (Ihandle *ih);
  172. // Drag&Drop callbacks
  173. int callback_dragbegin_cb (Ihandle* ih, int x, int y);
  174. int callback_dragdatasize_cb (Ihandle* ih, char* type);
  175. int callback_dragdata_cb (Ihandle* ih, char* type, void* data, int size);
  176. int callback_dragend_cb (Ihandle* ih, int action);
  177. int callback_dropdata_cb (Ihandle* ih, char* type, void* data, int size, int x, int y);
  178. int callback_dropmotion_cb (Ihandle *ih, int x, int y, char *status);
  179. // Menu recent files
  180. int callback_recent_cb (Ihandle *ih);
  181. void config_recent_init (Ihandle* ih, Ihandle* menu, int max_recent);
  182. // Flat button
  183. int callback_flat_action_Fn(Ihandle *ih);
  184. int callback_flat_button_cb(Ihandle *ih, int button, int pressed, int x, int y, char* status);
  185. int callback_flat_focus_cb(Ihandle *ih, int focus);
  186. int callback_flat_enterwindow_cb(Ihandle *ih);
  187. int callback_flat_leavewindow_cb(Ihandle *ih);
  188. // Cells
  189. int callback_draw_cb(Ihandle* ih, int line, int column, int xmin, int xmax, int ymin, int ymax, cdCanvas* canvas);
  190. int callback_height_cb(Ihandle* ih, int line);
  191. int callback_hspan_cb(Ihandle* ih, int line, int column);
  192. int callback_mouseclick_cb(Ihandle* ih, int button, int pressed, int line, int column, int x, int y, char* status);
  193. int callback_mousemotion_cb(Ihandle *ih, int line, int column, int x, int y, char *r);
  194. int callback_ncols_cb(Ihandle* ih);
  195. int callback_nlines_cb(Ihandle* ih);
  196. int callback_scrolling_cb(Ihandle* ih, int line, int column);
  197. int callback_vspan_cb(Ihandle* ih, int line, int column);
  198. int callback_width_cb(Ihandle* ih, int column);
  199. // Color bar
  200. char* callback_cell_cb(Ihandle* ih, int cell);
  201. int callback_extended_cb(Ihandle* ih, int cell);
  202. int callback_select_cb(Ihandle* ih, int cell, int type);
  203. int callback_switch_cb(Ihandle* ih, int prim_cell, int sec_cell);
  204. // Matrix
  205. int callback_action_Fniiiis(Ihandle *ih, int key, int lin, int col, int edition, char* value);
  206. int callback_click_cb_Fniis (Ihandle *ih, int lin, int col, char *status);
  207. int callback_colresize_cb (Ihandle *ih, int col);
  208. int callback_release_cb (Ihandle *ih, int lin, int col, char *status);
  209. int callback_resizematrix_cb (Ihandle *ih, int width, int height);
  210. int callback_mousemove_cb (Ihandle *ih, int lin, int col);
  211. int callback_enteritem_cb (Ihandle *ih, int lin, int col);
  212. int callback_leaveitem_cb (Ihandle *ih, int lin, int col);
  213. int callback_scrolltop_cb (Ihandle *ih, int lin, int col);
  214. int callback_bgcolor_cb (Ihandle *ih, int lin, int col, int *red, int *green, int *blue);
  215. int callback_fgcolor_cb (Ihandle *ih, int lin, int col, int *red, int *green, int *blue);
  216. char* callback_font_cb (Ihandle* ih, int lin, int col);
  217. char* callback_type_cb (Ihandle* ih, int lin, int col);
  218. int callback_dropcheck_cb (Ihandle *ih, int lin, int col);
  219. char* callback_translatevalue_cb (Ihandle* ih, int lin, int col, char* value);
  220. int callback_togglevalue_cb_Fniii (Ihandle *ih, int lin, int col, int status);
  221. int callback_drop_cb (Ihandle *ih, Ihandle *drop, int lin, int col);
  222. int callback_menudrop_cb (Ihandle *ih, Ihandle *drop, int lin, int col);
  223. int callback_dropselect_cb (Ihandle *ih, int lin, int col, Ihandle *drop, char *t, int i, int v);
  224. int callback_edition_cb (Ihandle *ih, int lin, int col, int mode, int update);
  225. char* callback_value_cb (Ihandle* ih, int lin, int col);
  226. int callback_value_edit_cb (Ihandle *ih, int lin, int col, char* newval);
  227. int callback_mark_cb (Ihandle* ih, int lin, int col);
  228. int callback_markedit_cb (Ihandle *ih, int lin, int col, int marked);
  229. // Flat tabs
  230. int callback_flat_motion_cb(Ihandle *ih, int x, int y, char *status);
  231. // Drop button
  232. int callback_flat_dropshow_cb (Ihandle *ih, int state);
  233. // Dial
  234. int callback_button_press_cb (Ihandle *ih, double angle);
  235. int callback_button_release_cb (Ihandle *ih, double angle);
  236. int callback_mousemove_cb_Fnd (Ihandle *ih, double angle);
  237. // Color browse
  238. int callback_change_cb (Ihandle *ih, unsigned char r, unsigned char g, unsigned char b);
  239. int callback_drag_cb (Ihandle *ih, unsigned char r, unsigned char g, unsigned char b);
  240. // Set callbacks
  241. void connect_function (const char *name, int operation);
  242. void connect_callback (Ihandle* ih, const char *name, const char *type, int operation);
  243. #endif