📄 applicat.b
字号:
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);
/// 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 ] ) ) ) =
( ( da.year - 1980 )<<9 ) + ( (unsigned) da.month<<5) +
(unsigned) da.day;
if (( stream = fopen(swpfile, "w+b")) == NULL ) return (-1);
if (( count = fwrite(tmpstr,32 , 1, stream)) != 1 ) return (-1);
// if ( ( _currentGrafPort->device == VGA ) // IS VGAHI
// && ( _currentGrafPort->mode == VGAHI ) )
if ( ( 1 )
&& ( 1 ) )
{
for ( i = 0; i < 4; i ++ )
{
// enable VGA bit-plane read
_selectVGABitPlane ( i, 0 );
fseek ( stream,i* 38400L+32, SEEK_SET );
if ((count =fwrite((void far*)0xa0000000L,
(unsigned)38400, 1, stream) ) != 1 ) return (-1);
}
}
else return (-1);
if ( ( fclose ( stream ) ) != 0 ) return -1;
return 0;
}
int application_class::_disk2Screen ( const char * swpfile )
{
int result = 0, i;
FILE *stream;
size_t count;
char tmpstr [ 32 ];
if (( stream = fopen(swpfile, "r+b")) == NULL ) return (-1);
if (( count = fread (tmpstr,32 , 1, stream)) != 1 ) return (-1);
if ( ( strcmp ( tmpstr, "ADFFT(c)LDh1994" ) != 0 ) || ( tmpstr [ 24 ] != 0x05 ) )
return dosFileNotFound;
// if ( ( _currentGrafPort->device == VGA ) // OK VGAHI
// && ( _currentGrafPort->mode == VGAHI ) )
if ( ( 1 )
&& ( 1 ) )
{
for ( i = 0; i < 4; i ++ )
{
// enable VGA bit-plane write
_selectVGABitPlane ( i, 1 );
fseek ( stream,i* 38400L+32, SEEK_SET );
if ((count =fread ((void far*)0xa0000000L,
(unsigned)38400, 1, stream) ) != 1 ) return (-1);
}
}
else return (-1);
if ( ( fclose ( stream ) ) != 0 ) return -1;
return 0;
}
/////////////////////////////////////////////////////////////////////////
////////////////////////// exec a dialog //////////////////////////////
/////////////////////////////////////////////////////////////////////////
int application_class::exec_dialog(Tdialog *pdialog_handled)
{ int ret_value;
int keynum;
class MSGQueue savqueue;
MSG savmsg;
savqueue =thequeue;
savmsg =sysmsg;
thequeue.Reset();
pdialog_handled->open_one_win ();
do {
ret_value=main_message_loop();
} while ( ( (ret_value != Dlg_OK)&&(ret_value!=Dlg_CANCEL) ) || //Dlg_OK or Dlg_CANCEL
(pdialog_handled ==pcurrent_selected_win ) );
// similar to run
// others no need to delete now
// No need to delete pdialog_handled;--->deleted as it is closed
asm cli;
sysmsg =savmsg;
thequeue =savqueue;
asm sti;
return ret_value;
}
///////////////////////////////////////////////////////////////////////////
void interrupt application_class::timer(...)
{
// disable();
// mouse still makes the program crash////////////////// WHY
if (!timer_active){
timer_active =TRUE;
(*old_timer)(...);
if (thequeue.QueueFull()) goto Ret;
///Prevent more queue
if ( thequeue.first !=thequeue.last ) {
if (( thequeue.msg_array[thequeue.oldfirst].Action==TimerMSG)
|| (thequeue.msg_array[thequeue.oldfirst].Action==SlowTimerMSG))
goto Ret;
}
time_counter++;
slow_time_counter ++;
if ( time_counter > TIMER_COUNT ){
time_counter =0;
thequeue.SendMessage(0,TimerMSG,NULL);
}
if (slow_time_counter > SLOW_TIMER_COUNT ) {
slow_time_counter =0 ;
thequeue.SendMessage(0,SlowTimerMSG,NULL);
}
Ret: timer_active =FALSE;
}
// enable();
}
void interrupt (* application_class::old_timer) (...)=getvect(0x19);
void interrupt (* application_class::old_key ) (...)=getvect(0x19);
void interrupt (* application_class::old_mouse) (...)=getvect(0x19);
void interrupt (* application_class::old_dos_error) (...)=getvect(0x19);
/*
#define MYBIOSKEY \
switch (key_code) { \
case 0x48e0: \
key_code=UPKEY; \
break; \
case 0x4be0: \
key_code=LEFTKEY; \
break; \
case 0x4de0: \
key_code=RIGHTKEY; \
break; \
case 0x50e0: \
key_code=DOWNKEY; \
break; \
\
case 0x8de0: \
key_code=CTRL_UP; \
break; \
case 0x73e0: \
key_code=CTRL_LEFT; \
break; \
case 0x74e0: \
key_code=CTRL_RIGHT; \
break; \
case 0x91e0: \
key_code=CTRL_DOWN; \
break; \
case SPACEKEY: \
if ( bioskey (0x12) & 0x08 ) \
key_code =ALT_SPACE; \
break; \
case ALT_LEFT: \
if ( bioskey (0x12) & 0x04 ) \
key_code =CTRL_ALT_LEFT; \
break; \
case ALT_RIGHT: \
if ( bioskey (0x12) & 0x04 ) \
key_code =CTRL_ALT_RIGHT; \
break; \
};
*/
#define MYBIOSKEY \
switch (tmp) { \
case 0x53e0: \
tmp=DELKEY; \
break; \
case 0x52e0: \
tmp=INSKEY; \
break; \
case 0x49e0: \
tmp=PGUPKEY; \
break; \
case 0x47e0: \
tmp=HOMEKEY; \
break; \
case 0x4fe0: \
tmp=ENDKEY; \
break; \
case 0x51e0: \
tmp=PGDNKEY; \
break; \
case 0x4be0: \
tmp=LEFTKEY; \
break; \
case 0x4de0: \
tmp=RIGHTKEY; \
break; \
case 0x48e0: \
tmp=UPKEY; \
break; \
case 0x50e0: \
tmp=DOWNKEY; \
break; \
\
case 0x8de0: \
tmp=CTRL_UP; \
break; \
case 0x73e0: \
tmp=CTRL_LEFT; \
break; \
case 0x74e0: \
tmp=CTRL_RIGHT; \
break; \
case 0x91e0: \
tmp=CTRL_DOWN; \
break; \
case SPACEKEY: \
if ( bioskey (0x12) & 0x08 ) \
tmp =ALT_SPACE; \
break; \
case ALT_LEFT: \
if ( bioskey (0x12) & 0x04 ) \
tmp =CTRL_ALT_LEFT; \
break; \
case ALT_RIGHT: \
if ( bioskey (0x12) & 0x04 ) \
tmp =CTRL_ALT_RIGHT; \
break; \
};
void interrupt application_class::key (...)
{ register int tmp;
MSG tmpmsg;
// disable();
//~ (*old_key)(...);
if (!kb_active ){
kb_active =TRUE;
(*old_key)(...);
//~ switch (bioskey(1)) {
switch (bioskey(0x11)) {
case -1:
thequeue.SendMessage(0,CtrlBreakMSG,NULL );
break;
case 0:break;
default :
//~ key_code=bioskey(0);
// tmp =key_code;
//~ key_code=bioskey(0x10);
tmp=bioskey(0x10);
if (thequeue.QueueFull()) goto Ret;
MYBIOSKEY;
if ( thequeue.first !=thequeue.last ) {
if (( thequeue.msg_array[thequeue.oldfirst].Action
==KeyPressedMSG) && (tmp==key_code))
goto Ret;
}
// if ( thequeue.PeekMessage (tmpmsg) !=FALSE ){
// if ((tmpmsg.Action==KeyPressedMSG) && (tmp==key_code))
// goto Ret;
// }
key_code =tmp;
thequeue.SendMessage(0, KeyPressedMSG,NULL);
}
Ret: kb_active =FALSE;
}
// enable();
}
void interrupt application_class::mouse(...)
{
// disable();
(*old_mouse)(...);
if (!mouse_active ){
mouse_active =TRUE;
if (in_win_moving) {
if (sysmouse->get_release_count(LEFT_BUTTON) >0 ) {
thequeue.SendMessage(pcurrent_selected_win->ID
,WinMovedSizedMSG,pcurrent_selected_win );
in_win_moving =FALSE;
mouse_active =FALSE;
return ;
}
sysmouse->get_posn ();
if ( (abs(old_mouse_x-mouse_x )<10) && (abs(old_mouse_y-mouse_y)<10) ){
mouse_active =FALSE;
return ;
}
thequeue.SendMessage(0,WinMovingSizingMSG,pcurrent_selected_win);
mouse_active =FALSE;
return;
}
if (sysmouse->get_press_count(LEFT_BUTTON) >0 )
thequeue.SendMessage(0,MouseLButtonDownMSG,NULL );
mouse_active =FALSE;
}
// enable();
}
void interrupt application_class::dos_error(...)
{ int i,j;
i=_AX;
j=_DI;
if (dos_error_active ) return ;
dos_error_active =TRUE;
// enable();
if ( i & 0x8000 ); // AH bit7 is set ; means not disk error
else {
switch (j & 0xff ) {
case 0x00:strcpy (msgbuf,"Write Protected");break;
case 0x01:strcpy (msgbuf,"Invalid Drive Number");break;
case 0x02:strcpy (msgbuf,"Drive not ready");break;
default :strcpy (msgbuf,"Drive error");break;
}
diskerrorno = j & 0xff ;
putch('\007');
// To let the owner do next && retry,etc
// if (theprogram->exec_dialog(new Tmsgbox("Message",msgbuf,MB_RETRYCANCEL))
// == Dlg_OK ) _AL=0x01;
// else _AL =0x02;
dos_error_active =FALSE;
// _AL =0x00; cannot be touched by the caller
// asm {
// mov bp,sp
// mov ax,[bp+22]
// mov al,0
// mov [bp+22],ax
// }
return;
}
(*old_dos_error );
dos_error_active =FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -