00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HTMENU_H__
00022 #define __HTMENU_H__
00023
00024 #include "htdata.h"
00025 #include "htdialog.h"
00026 #include "htobj.h"
00027
00028
00029
00030
00031
00032 class ht_context_menu;
00033
00034 #define CME_ENTRY 0
00035 #define CME_SEPARATOR 1
00036 #define CME_SUBMENU 2
00037
00038 class ht_context_menu_entry: public Object {
00039 public:
00040 int type;
00041 union {
00042 struct {
00043 char *name;
00044 char *shortcut;
00045 char *comment;
00046 int command;
00047 int key;
00048 bool active;
00049 } entry;
00050 ht_context_menu *submenu;
00051 };
00052
00053 virtual ~ht_context_menu_entry();
00054 };
00055
00056
00057
00058
00059
00060 class ht_context_menu: public Object {
00061 private:
00062 char *name;
00063 char *shortcut;
00064 public:
00065 int xpos, width;
00066
00067 void init(char *name);
00068 virtual void done();
00069
00070 virtual int count();
00071 virtual ht_context_menu_entry *enum_entry_first();
00072 virtual ht_context_menu_entry *enum_entry_next();
00073 virtual ht_context_menu_entry *get_entry(int n);
00074 virtual char *get_name();
00075 virtual char *get_shortcut();
00076 };
00077
00078
00079
00080
00081
00082 class ht_static_context_menu: public ht_context_menu {
00083 protected:
00084 ht_list *context_menu_entry;
00085 int enum_idx;
00086
00087 public:
00088
00089 void init(char *name);
00090 virtual void done();
00091
00092 void insert_entry(char *name, char *comment, int command, int key, bool active);
00093 void insert_separator();
00094 void insert_submenu(ht_context_menu *submenu);
00095
00096 virtual int count();
00097 virtual ht_context_menu_entry *enum_entry_first();
00098 virtual ht_context_menu_entry *enum_entry_next();
00099 };
00100
00101
00102
00103
00104
00105 class ht_menu: public ht_view {
00106 protected:
00107 int lastmenux;
00108 ht_list *menu;
00109 int curmenu;
00110 int localmenu;
00111 bool context_menu_hack2;
00112 ht_context_menu *context_menu_hack;
00113 ht_context_menu *last_context_menu_hack;
00114
00115 void execute_menu(int i);
00116 ht_context_menu *get_context_menu(int i);
00117 bool handle_key_context_menu(ht_context_menu *a, int k);
00118
00119 virtual char *defaultpalette();
00120 virtual char *defaultpaletteclass();
00121 public:
00122 void init(bounds *b);
00123 virtual void done();
00124
00125 virtual void draw();
00126 virtual void handlemsg(htmsg *msg);
00127
00128 int count();
00129 void insert_menu(ht_context_menu *m);
00130 void insert_local_menu();
00131 bool set_local_menu(ht_context_menu *m);
00132 void delete_local_menu();
00133 };
00134
00135
00136
00137
00138
00139 class ht_context_menu_window_body: public ht_view {
00140 protected:
00141 ht_context_menu *context_menu;
00142 int selected;
00143
00144 int next_selectable(int to);
00145 int prev_selectable(int to);
00146
00147
00148 virtual char *defaultpalette();
00149 virtual char *defaultpaletteclass();
00150 public:
00151 void init(bounds *b, ht_context_menu *menu);
00152 virtual void done();
00153
00154 virtual void draw();
00155 virtual void handlemsg(htmsg *msg);
00156 virtual void getdata(ht_object_stream *s);
00157 virtual void setdata(ht_object_stream *s);
00158 };
00159
00160
00161
00162
00163
00164 class ht_menu_window_body;
00165
00166 struct ht_menu_window_data {
00167 int selected;
00168 };
00169
00170 class ht_menu_window: public ht_dialog {
00171 protected:
00172 ht_menu_window_body *body;
00173 ht_context_menu *menu;
00174 public:
00175 void init(bounds *b, ht_context_menu *menu);
00176 virtual void done();
00177
00178 virtual void getdata(ht_object_stream *s);
00179 virtual void handlemsg(htmsg *msg);
00180 virtual void setdata(ht_object_stream *s);
00181 };
00182
00183
00184
00185
00186
00187 class ht_menu_window_body: public ht_context_menu_window_body {
00188 public:
00189 void init(bounds *b, ht_context_menu *menu);
00190 virtual void done();
00191
00192 virtual void handlemsg(htmsg *msg);
00193 };
00194
00195
00196
00197
00198
00199 class ht_menu_frame: public ht_frame {
00200 protected:
00201
00202 virtual int getcurcol_normal();
00203 virtual int getcurcol_killer();
00204
00205 virtual char *defaultpalette();
00206 virtual char *defaultpaletteclass();
00207 public:
00208 void init(bounds *b, char *desc, UINT style, UINT number=0);
00209 virtual void done();
00210 };
00211
00212
00213
00214
00215
00216 bool init_menu();
00217
00218
00219
00220
00221
00222 void done_menu();
00223
00224 #endif