li_pull_menu.cc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #include "menu/pull.hh"
  9. #include "menu/key_item.hh"
  10. #include "lisp/lisp.hh"
  11. #include "app/app.hh"
  12. #include "menu/textitem.hh"
  13. #include "gui/seperate.hh"
  14. #include "device/key_man.hh"
  15. #include "window/wmanager.hh"
  16. i4_event_handler_reference_class<i4_pull_menu_class> li_pull;
  17. static li_object *li_add_sub(li_object *o, li_environment *env)
  18. {
  19. i4_graphical_style_class *style=i4_current_app->get_style();
  20. i4_menu_item_class *top_name;
  21. top_name=new i4_text_item_class(li_string::get(li_eval(li_car(o,env),env),env)->value(),
  22. style,
  23. &li_pull->menu_colors,
  24. 0,0,0,0,0, 5,3);
  25. i4_menu_class *sub=style->create_menu(i4_T);
  26. for (o=li_cdr(o,env); o; o=li_cdr(o,env))
  27. {
  28. if (li_car(o,env)->type()!=LI_LIST)
  29. {
  30. sub->add_item(new i4_seperator_line_class(style,
  31. li_pull->menu_colors.text_background,
  32. 3,4));
  33. }
  34. else
  35. {
  36. li_object *s=li_car(o,env);
  37. char *view_name=li_string::get(li_eval(li_car(s,env),env),env)->value(); s=li_cdr(s,env);
  38. char *com_name=li_string::get(li_eval(li_car(s,env),env),env)->value();
  39. int command_id=i4_key_man.get_command_id(com_name);
  40. i4_do_command_event_class *do_cmd=new i4_do_command_event_class(com_name, command_id);
  41. i4_event_reaction_class *command=new i4_event_reaction_class(i4_current_app, do_cmd);
  42. i4_end_command_event_class *end_cmd=new i4_end_command_event_class(com_name, command_id);
  43. i4_event_reaction_class *end_command=new i4_event_reaction_class(i4_current_app, end_cmd);
  44. i4_text_item_class *ki=new i4_text_item_class(view_name,
  45. style,
  46. &li_pull->menu_colors,
  47. 0,
  48. command, end_command,
  49. 0,0,
  50. 10,3);
  51. sub->add_item(ki);
  52. }
  53. }
  54. li_pull->add_sub_menu(top_name, sub);
  55. return 0;
  56. }
  57. i4_pull_menu_class *li_create_pull_menu(char *filename)
  58. {
  59. if (li_pull.get())
  60. i4_error("pull menu already created");
  61. i4_graphical_style_class *style=i4_current_app->get_style();
  62. li_pull=new i4_pull_menu_class(style, i4_current_app->get_window_manager());
  63. li_environment *env=new li_environment(0, i4_T);
  64. li_add_function("add_sub_menu", li_add_sub, env);
  65. li_load(filename, env);
  66. return li_pull.get();
  67. }