📄 yyxmenu.cpp
字号:
// 1993 (c) ALL RIGHTS RESERVED
// AUTHOR BY XuYongYong
/* yyxmenu.cpp
*/
#ifndef __YYXMENU_H
#include "yyxmenu.h"
#endif
#ifndef __YYXWIN_H
#include "yyxwin.h"
#endif
#ifndef __APPLICAT_H
#include "applicat.h"
#endif
void menu_class::select()
{
setport (menu_viewport);
PaintRect ( bounds, MENU_ITEM_SELECT_COLOR ,COPY_PUT );
// if (->pfather_menu != NULL ) //The Only exception caused the mouse dead
pfather_menu->psub_menu_selected =this ;
draw_help_texts (help);
draw ();
}
void menu_class::unselect ()
{
setport (menu_viewport);
PaintRect ( bounds, MENU_RECT_COLOR ,COPY_PUT );
pfather_menu->psub_menu_selected =NULL;
draw ();
}
void menu_class::offsetmenu(int dx,int dy )
{ Tmenu * ptmp;
int i;
OffsetRect (&bounds,dx,dy );
if ((ptmp =pson_menu) == NULL ) return;
OffsetRect (&save_bitmap.bounds,dx,dy );
for (i=0; i<sub_menu_nums ; i++ ){
ptmp=(Tmenu *) ptmp->pright;
ptmp->offsetmenu(dx,dy);
}
}
void menu_class::draw_sub_menu_rect ()
{ struct Rect therect;
setport (menu_viewport);
FillRect ( save_bitmap.bounds , MENU_RECT_COLOR);
therect = save_bitmap.bounds;
// InsetRect (&therect,-5,-5 );
setcolor (BLACK);
if ( pfather_menu !=NULL ) FrameRect ( therect);
}
void menu_class::enter_menu ()
{ Tobject * ptmp;
int i;
if ( pcurrent_menu->psub_menu_selected==NULL ) return ;
if (pcurrent_menu->psub_menu_selected->status & DISABLE ) return;
if ( pcurrent_menu->psub_menu_selected->pson_menu == NULL ) {
if (pcurrent_menu->pfather_menu == NULL ) {
pcurrent_menu = pcurrent_menu->psub_menu_selected;
if (pcurrent_menu->psub_menu_selected !=NULL )
pcurrent_menu->psub_menu_selected->select
();
return;
} else {
// thequeue.SendMessage(pcurrent_menu->psub_menu_selected->ID
// ,MenuActionMSG,pcurrent_menu->psub_menu_selected );
// Note: this is a way of communication mode
if (in_menu_trap)
menu_save_queue.SendMessage(pcurrent_menu->psub_menu_selected->ID
,MenuActionMSG,pcurrent_menu->psub_menu_selected );
else
thequeue.SendMessage(pcurrent_menu->psub_menu_selected->ID
,MenuActionMSG,pcurrent_menu->psub_menu_selected );
if (pcurrent_menu !=NULL ) pcurrent_menu->esc_all_menus();
// menu_func ( pcurrent_menu->psub_menu_selected->ID );
return;
} /* execute a command */
}
else {
pcurrent_menu = pcurrent_menu->psub_menu_selected;
pcurrent_menu->save_bitmap.size
=(unsigned long) RectSize (pcurrent_menu->save_bitmap.bounds);
pcurrent_menu->save_bitmap.pbitmap
= myfarmalloc (pcurrent_menu->save_bitmap.size );
getimage ( pcurrent_menu->save_bitmap.bounds.left,
pcurrent_menu->save_bitmap.bounds.top,
pcurrent_menu->save_bitmap.bounds.right,
pcurrent_menu->save_bitmap.bounds.bottom,
pcurrent_menu->save_bitmap.pbitmap);
}
/* used by main menu and those selection which have sub_menus */
pcurrent_menu->draw_sub_menu_rect( );
ptmp=pcurrent_menu->pson_menu;
for (i=0;i<pcurrent_menu->sub_menu_nums ; i++ ) {
if (! ( ptmp->status & INVISIBLE) )
ptmp->draw ();
ptmp=ptmp->pright ;
}
if (pcurrent_menu->psub_menu_selected !=NULL )
pcurrent_menu->psub_menu_selected->select
();
}
void menu_class::draw ()
{
setport (menu_viewport);
moveto
(bounds.left+5,bounds.top);
if (status & DISABLE ) {
setcolor ( MENU_ITEM_DISABLED_COLOR );
outtext (title);
}else if (hotkey == 0xff ) {
if (this !=pfather_menu->psub_menu_selected )
setcolor (MENU_ITEM_ENABLED_COLOR );
else setcolor ( MENU_ITEM_SELECTED_COLOR );
outtext (title );
} else {
if (this !=pfather_menu->psub_menu_selected )
setcolor (MENU_ITEM_ENABLED_COLOR );
else setcolor ( MENU_ITEM_SELECTED_COLOR );
outtext (title );
draw_hotkey(title,hotkey,bounds.left+5,bounds.top);
}
}
void menu_class::draw_help_texts (char *help_texts)
{
setport (menu_viewport);
FillRect ( on_line_help_rect,HELP_RECT_COLOR );
moveto(on_line_help_rect.left+10,on_line_help_rect.top);
setcolor (HELP_TEXT_COLOR);
outtext (help_texts);
}
int menu_class::esc_menu ()
{ // pcurrent_menu---<this
if ( this->pfather_menu == NULL ) {
if ( this->psub_menu_selected != NULL ) {
this->psub_menu_selected->unselect
();
// this->psub_menu_selected =NULL;
/// if ( this->psub_menu_selected == NULL ) ///5/2/1994
draw_help_texts(this-> help); /// else
/// draw_help_texts(this->psub_menu_selected->help);
}
if (in_menu_trap){
in_menu_trap =FALSE; ////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sysmsg=menu_save_sysmsg;
thequeue=menu_save_queue;
}
if ( pcurrent_selected_win !=NULL ) setport ( pcurrent_selected_win->viewport);
/////////////////////////////////////!!!!!!!!!!!!!!!!!!!!!!!!!!!
return (0);
}
/* above is for main menu */
if (this->save_bitmap.pbitmap != NULL ) {
putimage ( this->save_bitmap.bounds.left ,
this->save_bitmap.bounds.top,
this->save_bitmap.pbitmap ,COPY_PUT );
farfree ( this->save_bitmap.pbitmap );
}
pcurrent_menu= this ->pfather_menu ;
/// if ( pcurrent_menu->psub_menu_selected == NULL ) ///5/2/1994
draw_help_texts(pcurrent_menu-> help); /// else
/// draw_help_texts(pcurrent_menu->psub_menu_selected->help);
return (1);
}
Tmenu * menu_class::get_next_sub_item (enum direction direct)
{ Tmenu *ptmp;
ptmp =pcurrent_menu->psub_menu_selected;
if (ptmp==NULL ) { if ( pcurrent_menu->pson_menu == NULL ) return NULL;
else ptmp =(Tmenu*)pcurrent_menu->pson_menu->pleft;
}
return (Tmenu*)ptmp->get_next_object( direct, TRUE);
//determine whether to go to disabled item
}
int menu_class::Left_Right_key_handler(enum direction scroll_direction)
{
if (pcurrent_menu->pfather_menu->pfather_menu ==NULL)
{
pcurrent_menu->esc_menu ();
change_select (pcurrent_menu->psub_menu_selected,
pcurrent_menu->get_next_sub_item ( scroll_direction));
pcurrent_menu->psub_menu_selected->enter_menu ();
return TRUE;
}
else if ((pcurrent_menu->pfather_menu == NULL )&&
(pcurrent_menu->psub_menu_selected !=NULL )) {
change_select (pcurrent_menu->psub_menu_selected,
pcurrent_menu->get_next_sub_item ( scroll_direction));
return TRUE;
}
return FALSE;
}
void menu_class::esc_all_menus(void)
{
while ( pcurrent_menu->pfather_menu != NULL )
pcurrent_menu->esc_menu ( );
if (pcurrent_menu->psub_menu_selected !=NULL)
pcurrent_menu->psub_menu_selected->unselect
();
if (in_menu_trap){
in_menu_trap =FALSE; ////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sysmsg=menu_save_sysmsg;
thequeue=menu_save_queue;
}
if ( pcurrent_selected_win !=NULL ) setport ( pcurrent_selected_win->viewport);
// pcurrent_menu->psub_menu_selected=NULL;
}
int menu_class::bar_Imme_menu_key_handler( int key_scan_num)
{ Tobject * ptmp;
int i;
ptmp =pcurrent_menu->pson_menu;
for(i=0;i<pcurrent_menu->sub_menu_nums;i++ ){
ptmp=ptmp->pright;
if ( ( (pcurrent_menu->pfather_menu ==NULL)
&& (alt_key[ toupper(ptmp->title[ptmp->hotkey])-'A'] ==key_scan_num)
)
||
( (pcurrent_menu->pfather_menu !=NULL)
&& ( (toupper( ptmp->title[ptmp->hotkey])) ==
(toupper( lo (key_scan_num))
)
)
||
( (toupper( ptmp->title[ptmp->hotkey])) ==' ' )
&& ( key_scan_num == ALT_SPACE )
)
) {
change_select (
pcurrent_menu->psub_menu_selected, ptmp );
if (pcurrent_menu->psub_menu_selected != NULL ) {
if (!in_menu_trap){
in_menu_trap =TRUE; ////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
menu_save_sysmsg=sysmsg;
menu_save_queue=thequeue;
}
pcurrent_menu->psub_menu_selected->enter_menu ();
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -