📄 applicat.cpp
字号:
if ( pcurrent_selected_win !=NULL )
pcurrent_selected_win->msg_handler(sysmsg);
second_class_msg_handler(sysmsg);
////////////////!!!!!!!!!!!! New
/////////// if ( sysmsg.Action == KeyPressedMSG ) key_code =0;
}
if (
(!in_menu_trap) &&
( ( pcurrent_selected_win ==NULL )||((!in_win_moving)&&(!(pcurrent_selected_win->type & DIALOG_WIN))))
)
anything_in_the_loop();
return ret_value;
}
void application_class::anything_in_the_loop(){};
void application_class::run()
{
int keynum;
Begin_Program:
init();
while (1) {
/* if( (keynum=bioskey(1) )== -1 ) break;
else if (keynum !=0 ) {
keynum=bioskey(0);
key_pressed_handler( keynum );
}
*/ if (main_message_loop()==Sys_QUIT) break;
// if (RE_START != 0) init_screen(); //goto Begin_Program;
}
}
/* ********************************************************************* */
/* **************************** INIT ******************************* */
/* ********************************************************************* */
void application_class::init()
{
init_screen();
init_menu(); // the order is important
draw_application_win();
// settextstyle (DEFAULT_FONT,HORIZ_DIR,1 );
init_win();
init_ctrl();
void far *mouse_addr;
mouse_addr =getvect (0x33);
if ( (!((mouse_addr==NULL )||(*(unsigned char *)mouse_addr==0xcf))) &&
!nomouse
) { sysmouse=new Tmouse();
old_mouse =getvect (MOUSE_VECTOR);
setvect (MOUSE_VECTOR,application_class::mouse );
}
else sysmouse =NULL;
}
//#include "tvga256.h" // Needs More MEMORY
void application_class::init_screen()
{
int gdriver = DETECT, gmode, errorcode;
// gdriver = installuserdriver("TVGA256",DETECTTVGA);/* Request auto-detection */
// gmode = TVGA640x480;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */ {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
error("graphics error exit"); /* return with error code */
}
// RE_START =0;
screen_viewport.left=0; screen_viewport.top =0;
screen_viewport.right =getmaxx(); screen_viewport.bottom=getmaxy();
screen_viewport.clip =CLIP_ON;
setusercharsize (10,10,10,10);
settextstyle (DEFAULT_FONT+SMALL_FONT,HORIZ_DIR, /*USER_CHAR_SIZE*/6 );
setport (screen_viewport);
setfillstyle (SOLID_FILL, LIGHTGRAY );
bar (screen_viewport.left,screen_viewport.top,screen_viewport.right,screen_viewport.bottom);
font_height =textheight ("HjklMq") +8;
bar_height =20;
menu_viewport =screen_viewport;
menu_viewport.left +=5; menu_viewport.top +=5;
menu_viewport.right -=5; menu_viewport.bottom-=5;
}
void application_class::draw_application_win()
{
/////////////////////////////INIT MENUS PART/////////////////////////////////
/////////////////////////////INIT MENUS PART/////////////////////////////////
/////////////////////////////INIT MENUS PART/////////////////////////////////
// draw Frame rect of the screen
pcurrent_menu =start_menu;
pcurrent_menu->psub_menu_selected =my_menu[0];
setport (screen_viewport);
setlinestyle ( SOLID_LINE,1,THICK_WIDTH );
setcolor(LIGHTGRAY);
Rect temp_rect;
SetRect (&temp_rect,menu_viewport.left,menu_viewport.top,
menu_viewport.right,menu_viewport.bottom );
InsetRect (&temp_rect, -LINE_WIDTH,-LINE_WIDTH);
draw_win_frame_rect ( temp_rect );
// change menu_viewport
setfillstyle (SOLID_FILL, WHITE );
bar (menu_viewport.left,menu_viewport.top,menu_viewport.right,menu_viewport.bottom);
// draw help_rect
/* SetRect (&on_line_help_rect,0,
menu_viewport.bottom-menu_viewport.top-bar_height-10,
menu_viewport.right-menu_viewport.left,
menu_viewport.bottom-menu_viewport.top);
*/
SetRect (&on_line_help_rect,0,
menu_viewport.bottom-menu_viewport.top-bar_height-10,
250,
menu_viewport.bottom-menu_viewport.top);
SetRect (&sys_status_rect,270,
menu_viewport.bottom-menu_viewport.top-bar_height-10,
360,
menu_viewport.bottom-menu_viewport.top);
SetRect (&status_rect,380,
menu_viewport.bottom-menu_viewport.top-bar_height-10,
menu_viewport.right-menu_viewport.left,
menu_viewport.bottom-menu_viewport.top);
setport (menu_viewport);
FillRect (on_line_help_rect, HELP_RECT_COLOR );
InsetRect (&on_line_help_rect, -5, -5 );
draw_in_button (on_line_help_rect );
InsetRect (&on_line_help_rect, -1, -1 );
FillRect (sys_status_rect, HELP_RECT_COLOR );
InsetRect (&sys_status_rect, -5, -5 );
draw_in_button (sys_status_rect );
InsetRect (&sys_status_rect, -1, -1 );
FillRect (status_rect, HELP_RECT_COLOR );
InsetRect (&status_rect, -5, -5 );
draw_in_button (status_rect );
InsetRect (&status_rect, -1, -1 );
if (pcurrent_menu ->psub_menu_selected !=NULL ) {
pcurrent_menu ->psub_menu_selected->pfather_menu=pcurrent_menu;
pcurrent_menu ->psub_menu_selected->select();
pcurrent_menu ->psub_menu_selected->pfather_menu=NULL;
// this makes MOUSE DEAD
}
pcurrent_menu ->enter_menu();
// draw sys menu
setcolor (BLACK);
if (pcurrent_menu != NULL ) {
Rect tmprect;
setport (menu_viewport);
tmprect = pcurrent_menu->save_bitmap.bounds;
InsetRect (&tmprect ,0,1);
FrameRect (tmprect);
}
FillRect (sysmenu->bounds,LIGHTGRAY );
setcolor (BLACK );
FrameRect (sysmenu->bounds);
sysmenu->bounds.bottom -=1;
sysmenu->bounds.right -=1;
sysmenu->draw (); //Not Very Good
// draw up & down rect;
Rect up_rect,down_rect;
down_rect =my_menu[0]->bounds;
down_rect.left=down_rect.right -bar_height+1;
down_rect.right -=1;
down_rect.bottom -=1;
OffsetRect (&down_rect,LINE_WIDTH-1,0 );
up_rect=down_rect;
OffsetRect (&up_rect, -bar_height+1,0 );
draw_out_button (down_rect);
draw_out_button (up_rect);
}
void application_class::init_msg()
{
thequeue.Reset();
}
void application_class::init_menu()
{ in_menu_trap =FALSE;
start_menu =new Tmenu ("INIT","");
MENU_ITEM_ENABLED_COLOR =BLACK ;
MENU_ITEM_SELECTED_COLOR =WHITE ; // for text
MENU_ITEM_DISABLED_COLOR =DARKGRAY;
MENU_ITEM_SELECT_COLOR =BLUE ; // for bar
HELP_RECT_COLOR =LIGHTGRAY ;
HELP_TEXT_COLOR = BLACK;
MENU_RECT_COLOR = WHITE ;
get_my_menu();
// show menus
}
void application_class::init_win ()
{
win_living_viewport=menu_viewport;
win_living_viewport.top +=2*bar_height;
win_living_viewport.bottom -=2*bar_height;
pfirst_win_of_all =NULL;
pcurrent_selected_win =NULL;
WIN_TITLEBAR_SELECTED_COLOR =BLUE;
WIN_TITLEBAR_UNSELECTED_COLOR =LIGHTGRAY;
WIN_TITLE_SELECTED_COLOR =WHITE;
WIN_TITLE_UNSELECTED_COLOR =BLACK;
WIN_BACKGROUND_COLOR =WHITE;
}
void application_class::init_ctrl ()
{
}
//////////////////////////////////////////////////////////////////////////
///////////////////////////////DOSSHELL///////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/* // OLD VERSION
void application_class::DosShell(void)
{
int result;
if (pcurrent_selected_win != NULL ) {
exec_dialog(new Tmsgbox("Message","MUST CLOSE ALL WINDOWS",MB_OK));
// thequeue.SendMessage(pcurrent_selected_win->ID,
// WinSysCloseMSG,pcurrent_selected_win);
// return ;
}
closegraph();
setvect (KEY_VECTOR,old_key);
setvect (TIMER_VECTOR,old_timer); //otherwise; queue will run out of it
puts("Type EXIT to return to Main Program . . .");
result = spawnlp(P_WAIT, "command.com", NULL);
if(result==-1) {
puts("\nNot enough memory to run command.com. . .");
getch();
}
init_screen();
draw_application_win();
setvect (KEY_VECTOR,application_class::key );
setvect (TIMER_VECTOR,application_class::timer );
if (sysmouse) sysmouse->on(0);
}
*/
void application_class::DosShell(void)
{
int result;
void interrupt (*mynow_timer)(...);
void interrupt (*mynow_key )(...);
void interrupt (*mynow_dos_error)(...);
void interrupt (*mynow_mouse)(...);
mynow_timer=getvect (TIMER_VECTOR);
mynow_key =getvect (KEY_VECTOR);
mynow_dos_error=getvect (DOS_ERROR_VECTOR);
mynow_mouse=getvect (MOUSE_VECTOR);
setvect (KEY_VECTOR,old_key);
setvect (DOS_ERROR_VECTOR,old_dos_error);
setvect (TIMER_VECTOR,old_timer);
if (getvect(MOUSE_VECTOR)==application_class::mouse)
setvect (MOUSE_VECTOR,old_mouse);
//otherwise; queue will run out of it
mouse_off;
_screen2Disk ( "XYYSWP.SWP" );
closegraph();
puts("Type EXIT to return to Main Program . . .");
result = spawnlp(P_WAIT, "command.com", NULL);
if(result==-1) {
puts("\nNot enough memory to run command.com. . .");
getch();
}
init_screen();
// cleardevice ();
if ( ( _disk2Screen ( "XYYSWP.SWP" ) ) != 0 ) exit (144);
remove ( "XYYSWP.SWP" );
/// draw_application_win();
setvect (KEY_VECTOR,mynow_key );
setvect (TIMER_VECTOR,mynow_timer );
setvect (DOS_ERROR_VECTOR,mynow_dos_error);
setvect (MOUSE_VECTOR,mynow_mouse);
mouse_on;
}
// if swp file error occur, it return DOS_ERR Code!
int application_class::_screen2Disk ( const char * swpfile )
// return 0 on success // else fail
{
int result = 0, i;
FILE *stream;
size_t count;
char tmpstr [ 32 ] = "ADFFT(c)LDh1994";
struct dosdate_t da;
struct dostime_t ti;
_dos_gettime ( & ti );
_dos_getdate ( & da );
for ( i = strlen ( tmpstr ); i < 32; i ++ ) tmpstr [ i ] = 0;
i = 24;
tmpstr [ i ++ ] = 0x05; // swp file's bandle ID
i ++;
*( (unsigned int *) ( & ( tmpstr [ i ] ) ) ) =
( (unsigned) ti.hour<<11 ) + ( (unsigned) ti.minute<<5) +
(unsigned) ti.second + 2;
i ++; i ++;
*( (unsigned int *) ( & ( tmpstr [ i ] ) ) ) =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -