(text);=textheight(text);(x+(w-wt)/2,y+(h-ht)/2,text);(getch()!=13);(x,y,x+w+1,y+h+1);(text[0]gt;=48amp;amp;text[0]lt;=57) return text [0] - 48; 0;
} Desk :: strInput (int x, int y, int w, int h, char * prompt, char * text, int limit) {// строкаht, wt; (BLUE);=textwidth (prompt);=textheight(prompt);+=wt;(x+(w-wt)/2,y+(h-ht)/2,prompt);i=0;[0]=laquo; raquo;;(((text[i++]=getch())!=13)amp;amp;(ilt;=limit)){[i]=laquo; raquo;;(x,y,x+w+1,y+h+1);=wt;= textwidth (text);=textheight (text); +=wt; (x + (w-wt)/2, y + (h-ht)/2, text);
} [i - 1]= 0 raquo ;; (x, y, x + w + 1, y + h + 1);
} Desk :: PaintBg () {// вікно (1,1); (0,0,640,480); (11); (5,5,635,475);
} Desk :: Go () {// командиchar ch; (;;) {= getch (); (ch) {13: Command (); break; 72: mn.Upward (); break; 75: mn.Backward (); break; 77: mn.Forward (); break; 80: mn.Downward (); break; 27: exit (0);
}
}
} Desk :: Command (void) {/// команди - gt; Clear (); * smn=mn.getSubMenu (mn.getSelected ()); * smn1=NULL; (smn) smn1=smn- gt; getSubMenu (smn- gt; getSelected ()); (mn.getSelected ()) {0: if (smn) {(smn- gt; getSelected ()) {- 1: smn- gt; Show (); break; 0: setCount (); break; 1: Init (); break;
}
}; 1: if (smn) {(smn- gt; getSelected ()) {- 1: smn- gt; Show (); break; 0: if (smn1) {(smn1- gt; getSelected ()) {- 1: smn1- gt; Show (); break; 0: strclear (); break;
}
}; 1: if (smn1) {(smn1- gt; getSelected ()) {- 1: smn1- gt; Show (); break; 0: sidToUpper (); break; 1: sidAssign (); break; 2: sidSub (); break; 3: Ind (); break;
}
}; 2: if (smn1) {(smn1- gt; getSelected ()) {- 1: smn1- gt; Show (); break; 0: sbtChangeChar (); break; 1: sbtAssign (); break; 2: sbtSub (); break; 3: sbtInd (); break;
}
}; 3: break;
}
}; 2: exit (0);
}
}
Додаток 7. Файл menu.h
# ifndef MENU_H
# define MENU_HMenuItem {: status; x, y, w, h; text [16];
: (); (int, int, int, int, char *); Show (void); Hide (void); setStatus (int); getStatus (void);
~ MenuItem () {}
}; Menu; MItem {* item; enabled; * submenu;
}; Menu {: * supmenu; mItem [10]; n; selected; visible;: (); (Menu *, int);
~ Menu (); Add (int, int, int, int, char *); setSubmenu (Menu *,int);Show(void);Hide(void);setSelect(int);getSelected(void);setEnable(int);isEnable(int);setDisable(int);Forward(void);Backward(void);Upward(void);Downward(void);setSubMenu(int, Menu *); * getSubMenu (int);
};
# endif/* MENU_H */
Додаток 8. Файл Menu.cpp
# include lt; cstdlib gt;
# include lt; cstdio gt;
# include lt; cstring gt;
# include lt; conio.h gt;
# include lt; graphics.h gt;
# include menu.h :: MenuItem () {= 0;=0; y=0; w=120; h=30; (text, Item ); ();
} :: MenuItem (int xx, int yy, int ww, int hh, char * s) {= 0;=xx; y=yy; w=ww; h=hh; (text, s, 16); ();
} MenuItem :: setStatus (int k) {= k; ();
} MenuItem :: getStatus () {status;
} MenuItem :: Show (void) {(x, y, x + w, y + h); clr=getcolor (); (status gt; 0) setcolor (RED); if ( status == 0) setcolor (LIGHTGREEN); setcolor (LIGHTGRAY); (BLUE); wt=textwidth (text); ht=textheight (text); (x + (w-wt)/2, y + (h-ht)/ 2, text); (clr);
} MenuItem :: Hide (void) {(status == 1) status=0; clr=getcolor (); (BLUE); (x, y, x + w + 1, y + h + 1); (clr);
} :: Menu () {= 0;=- 1;=1;=NULL; (int i=0; i lt; 10; i ++) {[i] .item=NULL; [ i] .submenu=NULL; [i] .enabled=1;
}
} :: Menu (Menu * mn, int k) {= 0;=- 1;=1;=mn; (int i=0; i lt; 10; i ++) {[i].item=NULL; [i] .submenu=NULL; [i] .enabled=1;
} gt; setSubMenu (k, this);
} :: ~ Menu () {(n gt;=0) delete mItem [- n] .item;
} Menu :: isEnable (int k) {mItem [k] .item- gt; getStatus () gt;=0;
} Menu :: Add (int x, int y, int w, int h, char * s) {[n ++]. item=new MenuItem (x, y, w, h, s) ;;
} Menu :: setSubmenu (Menu * mn, int k)...