Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htmenu.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htmenu.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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  *      CLASS ht_context_menu_entry
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  *      CLASS ht_context_menu
00058  */
00059 
00060 class ht_context_menu: public Object {
00061 private:
00062         char *name;
00063         char *shortcut;
00064 public:
00065         int xpos, width; /* used externally */
00066 
00067                         void init(char *name);
00068         virtual void done();
00069 /* new */
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  *      CLASS ht_static_context_menu
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 /* new */
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 /* overwritten */
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  *      CLASS ht_menu
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 /* overwritten */
00119         virtual char *defaultpalette();
00120         virtual char *defaultpaletteclass();
00121 public:
00122                         void init(bounds *b);
00123         virtual void done();
00124 /* overwritten */
00125         virtual void draw();
00126         virtual void handlemsg(htmsg *msg);
00127 /* new */
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  *      CLASS ht_context_menu_window_body
00137  */
00138 
00139 class ht_context_menu_window_body: public ht_view {
00140 protected:
00141         ht_context_menu *context_menu;
00142         int selected;
00143 /* new */
00144         int next_selectable(int to);
00145         int prev_selectable(int to);
00146 
00147 /* overwritten */
00148         virtual char *defaultpalette();
00149         virtual char *defaultpaletteclass();
00150 public:
00151                         void init(bounds *b, ht_context_menu *menu);
00152         virtual void done();
00153 /* overwritten */
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  *      CLASS ht_menu_window
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 /* overwritten */
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  *      CLASS ht_menu_window_body
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 /* overwritten */
00192         virtual void handlemsg(htmsg *msg);
00193 };
00194 
00195 /*
00196  *      CLASS ht_menu_frame
00197  */
00198 
00199 class ht_menu_frame: public ht_frame {
00200 protected:
00201 /* overwritten */
00202         virtual int getcurcol_normal();
00203         virtual int getcurcol_killer();
00204 /* overwritten */
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  *      INIT
00214  */
00215 
00216 bool init_menu();
00217 
00218 /*
00219  *      DONE
00220  */
00221 
00222 void done_menu();
00223 
00224 #endif /* !__HTMENU_H__ */

Generated on Fri May 7 21:15:35 2004 by doxygen 1.3.5