source: golgotha/src/i4/gui/li_pull_menu.cc @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.2 KB
Line 
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
9#include "menu/pull.hh"
10#include "menu/key_item.hh"
11#include "lisp/lisp.hh"
12#include "app/app.hh"
13#include "menu/textitem.hh"
14#include "gui/seperate.hh"
15#include "device/key_man.hh"
16#include "window/wmanager.hh"
17
18i4_event_handler_reference_class<i4_pull_menu_class> li_pull;
19
20static li_object *li_add_sub(li_object *o, li_environment *env)
21{
22  i4_graphical_style_class *style=i4_current_app->get_style();
23
24  i4_menu_item_class *top_name;
25  top_name=new i4_text_item_class(li_string::get(li_eval(li_car(o,env),env),env)->value(),
26                                  style,
27                                  &li_pull->menu_colors,                                   
28                                  0,0,0,0,0,  5,3);
29
30  i4_menu_class *sub=style->create_menu(i4_T);
31
32  for (o=li_cdr(o,env); o; o=li_cdr(o,env))
33  {
34    if (li_car(o,env)->type()!=LI_LIST)
35    {
36      sub->add_item(new i4_seperator_line_class(style,
37                                                li_pull->menu_colors.text_background,
38                                                3,4));
39    }
40    else
41    {
42      li_object *s=li_car(o,env);
43      char *view_name=li_string::get(li_eval(li_car(s,env),env),env)->value(); s=li_cdr(s,env);
44      char *com_name=li_string::get(li_eval(li_car(s,env),env),env)->value();
45
46
47     
48      int command_id=i4_key_man.get_command_id(com_name);
49
50      i4_do_command_event_class *do_cmd=new i4_do_command_event_class(com_name, command_id);
51      i4_event_reaction_class *command=new i4_event_reaction_class(i4_current_app, do_cmd);
52
53      i4_end_command_event_class *end_cmd=new i4_end_command_event_class(com_name, command_id);
54      i4_event_reaction_class *end_command=new i4_event_reaction_class(i4_current_app, end_cmd);
55
56
57      i4_text_item_class *ki=new i4_text_item_class(view_name,
58                                                    style,
59                                                   &li_pull->menu_colors,
60                                                    0,
61                                                   command, end_command,
62                                                   0,0,
63                                                   10,3);
64      sub->add_item(ki);
65    }
66  }
67
68
69  li_pull->add_sub_menu(top_name, sub);
70  return 0;
71}
72
73
74i4_pull_menu_class *li_create_pull_menu(char *filename)
75{
76  if (li_pull.get())
77    i4_error("pull menu already created");
78
79  i4_graphical_style_class *style=i4_current_app->get_style();
80  li_pull=new i4_pull_menu_class(style, i4_current_app->get_window_manager());
81
82  li_environment *env=new li_environment(0, i4_T);
83  li_add_function("add_sub_menu", li_add_sub, env);
84  li_load(filename, env);
85
86  return li_pull.get();
87}
Note: See TracBrowser for help on using the repository browser.