00001
00019 #ifndef SBDMENU_H
00020 #define SBDMENU_H
00021
00022 #include "hosthplb.h"
00023 #include "elst.h"
00024 #include "strngs.h"
00025 #include "grphics.h"
00026 #include "varable.h"
00027 #include "rect.h"
00028 #include "points.h"
00029 #include "notdll.h"
00030
00042 extern INT_VAR_H (menu_char_width, 8, "Width of characters in menu text");
00043 extern INT_VAR_H (menu_char_height, 14, "Height characters in menu text");
00046 class MENU_L;
00047 ELISTIZEH(MENU_L);
00048
00049 class COMMAND_WINDOW;
00050
00051
00052
00053
00054 class MENU_NODE;
00055 class LEAF_MENU_NODE;
00056 class SIMPLE_MENU_LEAF;
00057 class TOGGLE_MENU_LEAF;
00058 class RADIO_MENU_LEAF;
00059 class VARIABLE_MENU_LEAF;
00060 class NON_LEAF_MENU_NODE;
00061 class MENU_ROOT;
00062 class NON_RADIO_MENU;
00063 class RADIO_MENU;
00064
00069 class MENU_NODE
00070 {
00071 friend class MENU_ROOT;
00072 friend class NON_LEAF_MENU_NODE;
00073 friend class LEAF_MENU_NODE;
00074 friend class RADIO_MENU;
00075 protected:
00076 STRING name;
00077 BOX box;
00078
00079 MENU_NODE(
00080 const char *txt) {
00081 name = STRING (txt);
00082 }
00083
00084 virtual void event (
00085 COMMAND_WINDOW * cmd_win,
00086 FCOORD pt,
00087 INT32 * cmd_event_id,
00088 char *new_value) = 0;
00089
00090
00091 virtual INT8 max_num_chars () = 0;
00092
00093 virtual void plotx (
00094 WINDOW window) = 0;
00095
00096
00097 virtual BOX &recalc_bounding_box(INT16 tl_x,
00098 INT16 tl_y);
00099
00100 private:
00101 BOX &recalc_fixed_width_bb(
00102 INT16 tl_x,
00103 INT16 tl_y,
00104 INT16 width);
00105
00106 public:
00107
00108 virtual const char *cmp_str() {
00109 return name.string ();
00110 }
00111
00112 void plot(
00113 WINDOW window);
00114
00115 void new_label(
00116 const char *label) {
00117 name = label;
00118 }
00119
00120 virtual void write_vars(
00121 FILE *,
00122 BOOL8) {
00123
00124 }
00125 };
00126
00131 class LEAF_MENU_NODE:public MENU_NODE
00132 {
00133 protected:
00134 LEAF_MENU_NODE (
00135 const char *menu_text):MENU_NODE (menu_text) {
00136 }
00137
00138 INT8 max_num_chars() {
00139 return (INT8) name.length ();
00140 }
00141
00142 virtual void plotx(
00143 WINDOW window);
00144 };
00145
00150 class SIMPLE_MENU_LEAF:public LEAF_MENU_NODE
00151 {
00152 INT32 event_id;
00153
00154 private:
00155 void event(
00156 COMMAND_WINDOW *cmd_win,
00157 FCOORD pt,
00158 INT32 *cmd_event_id,
00159 char *new_value);
00160
00161 public:
00162 SIMPLE_MENU_LEAF (
00163 const char *menu_text,
00164 INT32 code):LEAF_MENU_NODE (menu_text) {
00165 event_id = code;
00166 }
00167 };
00168
00173 class TOGGLE_MENU_LEAF:public LEAF_MENU_NODE
00174 {
00175 friend class RADIO_MENU;
00176
00177 INT32 event_id;
00178 BOOL8 state;
00179
00180 private:
00181 void event(
00182 COMMAND_WINDOW *cmd_win,
00183 FCOORD pt,
00184 INT32 *cmd_event_id,
00185 char *new_value);
00186
00187 void plotx(
00188 WINDOW window);
00189
00190 public:
00191 TOGGLE_MENU_LEAF (
00192 const char *menu_text,
00193 INT32 code,
00194 BOOL8 initial_state):LEAF_MENU_NODE (menu_text) {
00195 event_id = code;
00196 state = initial_state;
00197 }
00198
00199 void set_toggle(
00200 BOOL8 value) {
00201 state = value;
00202 }
00203 };
00204
00209 class RADIO_MENU_LEAF:public TOGGLE_MENU_LEAF
00210 {
00211 public:
00212 RADIO_MENU_LEAF (
00213 const char *menu_text,
00214 INT32 code):TOGGLE_MENU_LEAF (menu_text, code, FALSE) {
00215 }
00216 };
00217
00222 class VARIABLE_MENU_LEAF:public LEAF_MENU_NODE
00223 {
00224 INT32 event_id;
00225 STRING current_value;
00226
00227 void event(
00228 COMMAND_WINDOW *cmd_win,
00229 FCOORD pt,
00230 INT32 *cmd_event_id,
00231 char *new_value);
00232
00233 public:
00234 VARIABLE_MENU_LEAF (
00235 const char *menu_text,
00236 INT32 code,
00237 const char *initial_value):LEAF_MENU_NODE (menu_text) {
00238 event_id = code;
00239 current_value = STRING (initial_value);
00240 }
00241
00242 void replace_value(
00243 const char *new_value) {
00244 current_value = new_value;
00245 }
00246 };
00247
00252 class NON_LEAF_MENU_NODE:public MENU_NODE
00253 {
00254 public:
00255 void clear_children() {
00256 menu_list.clear ();
00257 };
00258
00259 protected:
00260 MENU_L_LIST menu_list;
00261
00262 NON_LEAF_MENU_NODE (
00263 const char *menu_text):MENU_NODE (menu_text) {
00264 }
00265
00266 void link_child(
00267 MENU_NODE *new_child);
00268
00269 void link_child_link(
00270 MENU_L *new_child);
00271
00272 virtual void event(
00273 COMMAND_WINDOW *cmd_win,
00274 FCOORD pt,
00275 INT32 *cmd_event_id,
00276 char *new_value);
00277
00278 INT8 max_num_chars();
00279
00280 virtual void plotx(
00281 WINDOW window);
00282
00283
00284 virtual BOX &recalc_bounding_box(INT16 tl_x,
00285 INT16 tl_y);
00286
00287 };
00288
00293 class MENU_ROOT:public NON_LEAF_MENU_NODE
00294 {
00295 private:
00296 void plotx(
00297 WINDOW window);
00298
00299 public:
00300 MENU_ROOT ():NON_LEAF_MENU_NODE ("") {
00301 }
00302
00303
00304 void add_child(
00305 NON_LEAF_MENU_NODE *new_child) {
00306 link_child(new_child);
00307 }
00308
00309
00310 void event(
00311 COMMAND_WINDOW *cmd_win,
00312 FCOORD pt,
00313 INT32 *cmd_event_id,
00314 char *new_value) {
00315 NON_LEAF_MENU_NODE::event(cmd_win, pt, cmd_event_id, new_value);
00316 }
00317
00318 BOX &recalc_bounding_box(
00319 INT16 tl_x,
00320 INT16 tl_y);
00321
00322
00323 void write_vars(
00324 FILE *fp,
00325 BOOL8 changes_only);
00326 };
00327
00332 class NON_RADIO_MENU:public NON_LEAF_MENU_NODE
00333 {
00334 public:
00335 NON_RADIO_MENU (
00336 const char *menu_text):NON_LEAF_MENU_NODE (menu_text) {
00337 }
00338
00339 void add_child(
00340 SIMPLE_MENU_LEAF *new_child) {
00341 link_child(new_child);
00342 }
00343
00344 void add_child(
00345 TOGGLE_MENU_LEAF *new_child) {
00346 link_child(new_child);
00347 }
00348
00349 void add_child(
00350 VARIABLE_MENU_LEAF *new_child) {
00351 link_child(new_child);
00352 }
00353
00354 };
00355
00360 class RADIO_MENU:public NON_LEAF_MENU_NODE
00361 {
00362 private:
00363 RADIO_MENU_LEAF * on_button;
00364
00365 void event(
00366 COMMAND_WINDOW *cmd_win,
00367 FCOORD pt,
00368 INT32 *cmd_event_id,
00369 char *new_value);
00370
00371 public:
00372 RADIO_MENU (
00373 const char *menu_text):NON_LEAF_MENU_NODE (menu_text) {
00374 }
00375
00376 void add_child(
00377 RADIO_MENU_LEAF *new_child);
00378
00379 void press_radio_button(
00380 RADIO_MENU_LEAF *button);
00381 };
00382
00387 class MENU_L:public ELIST_LINK
00388 {
00389 public:
00390 MENU_NODE * ptr;
00391
00392 MENU_L() {
00393 }
00394
00395 MENU_L(
00396 MENU_NODE *p) {
00397 ptr = p;
00398 }
00399 };
00400
00401 #include "cmndwin.h"
00402 #include "notdll.h"
00403 #endif