📄 yyxwin.cpp
字号:
// 1993 (c) ALL RIGHTS RESERVED
// AUTHOR: XuYongYong
/* yyxwin.cpp
*/
#include "yyxwin.h"
#include "sysmenu.h"
#include "applicat.h"
int win_class::make_it_and_above_invisible()
{ struct pwin_list *temp;
if ( pfirst_above != NULL ) /* ? */
for (temp=pfirst_above ;
temp != NULL ; temp = temp ->pnext_list)
temp->pthe_win->make_it_and_above_invisible ();
if (visible == IN_VISIBLE ) return 0;
if (visible == TEMP_IN_VISIBLE ) return 0;
reserve_self_bitmap ( );
restore_under_bitmap ( );
visible =TEMP_IN_VISIBLE ;
return 1;
}
int win_class::make_it_and_above_visible ()
{ struct pwin_list *temp;
if (visible ==VISIBLE ) return 0;
if (visible ==IN_VISIBLE ) return 0;
if (pfirst_under !=NULL )
reserve_under_bitmap ( );
restore_self_bitmap ( );
visible = VISIBLE;
if ( pfirst_above != NULL )
for (temp=pfirst_above ;
temp != NULL ; temp = temp ->pnext_list)
temp->pthe_win->make_it_and_above_visible ();
return 1;
}
int win_class::invisible_one_win ()
{
// if (pwin_handled==NULL ) return 0;
if (visible ==IN_VISIBLE ) return 0;
make_it_and_above_invisible ( ); //invisible
if (pfirst_above != NULL )
pfirst_above->pthe_win->make_it_and_above_visible ();
visible =IN_VISIBLE ;
return 1;
}
int win_class::visible_one_win ()
{
// if (pwin_handled==NULL ) return 0;
if (visible ==VISIBLE ) return 0;
make_it_and_above_invisible ( );
visible=TEMP_IN_VISIBLE;
make_it_and_above_visible ( );
visible = VISIBLE ;
return 1;
}
void win_class::select ()
{ Twin *ptemp_win;
if (this ==pcurrent_selected_win ) return ;
unselect_current_selected_win ();
if (visible == IN_VISIBLE ) return ;
pcurrent_selected_win = this ;
if (pfirst_above !=NULL ){
make_it_and_above_invisible ( );
if (pfirst_above != NULL )
pfirst_above->pthe_win->make_it_and_above_visible ();
if (pfirst_above !=NULL )
reserve_under_bitmap ( );
restore_self_bitmap ( );
/* change_selected_win_links ( ); */
kill_all_links ( );
build_all_links ();
}
visible = VISIBLE;
draw_win_frame ( );
thequeue.SendMessage(ID,WinSelectedMSG,this);
}
void win_class::draw()
{
draw_win_frame ();
draw_win_control ();
draw_win_contents ();
}
int win_class::unselect_current_selected_win()
{ Twin *ptemp_win;
ptemp_win =pcurrent_selected_win;
pcurrent_selected_win=NULL;
if (ptemp_win !=NULL )
ptemp_win->draw_win_frame ();
return 0;
}
int win_class::restore_self_bitmap ()
{
if ( type & UNRESERVE_WIN ) {
draw();
return 1;
}
if (pself_bitmap != NULL ){
setport(win_living_viewport);
putimage (bounds.left,bounds.top
,pself_bitmap ,COPY_PUT);
farfree (pself_bitmap );
pself_bitmap=NULL;
}
return 0;
}
BOOL win_class::above_has_this (Twin *pwin) //no recursion
{
struct pwin_list *temp_list ;
if (pwin == NULL ) return FALSE;
if ( pwin->pfirst_above==NULL ) return FALSE;
for (temp_list =pwin->pfirst_above; temp_list !=NULL;temp_list=temp_list->pnext_list ) {
if ( temp_list->pthe_win == this) return TRUE;
}
return FALSE;
}
BOOL win_class::mark_above_win (Twin *pwin) //no recursion
{
struct pwin_list *temp_list ;
BOOL ret;
if (pwin == NULL ) return FALSE;
if ( pwin->pfirst_above==NULL ) return FALSE;
ret =FALSE;
for (temp_list =pwin->pfirst_above; temp_list !=NULL;temp_list=temp_list->pnext_list ) {
if (!(temp_list->pthe_win->type & 0x40)) {
temp_list->pthe_win->type |= 0x40;
ret= TRUE;
}
}
return ret;
}
BOOL win_class::under_all_redrawed (Twin *pwin) // not include itself
{ Rect dstrect; // recurse
struct pwin_list *temp_list ;
if (pwin==NULL ) return TRUE;
if ( pwin->pfirst_under ==NULL ) return TRUE;
for (temp_list =pwin->pfirst_under; temp_list !=NULL;temp_list=temp_list->pnext_list ) {
if ( (temp_list->pthe_win->type & 0x40) &&
(!(temp_list->pthe_win->type & 0x80))
) return FALSE;
else if (! under_all_redrawed(temp_list->pthe_win) ) return FALSE;
}
return TRUE;
}
int win_class::mark_need_redraw()
{ int no_more;
Twin *temp_win;
do{
no_more= TRUE;
for (temp_win=pfirst_win_of_all; temp_win !=NULL; temp_win=temp_win->pnext_win){
if ( temp_win == this ) continue;
if ( temp_win->visible==IN_VISIBLE ) continue;
if ( temp_win->visible==TEMP_IN_VISIBLE ) continue;
if ( temp_win->type & 0x40 ) {
no_more=! mark_above_win(temp_win);
continue;
}
if (above_has_this (temp_win)) {
temp_win->type |= 0x40;
no_more=FALSE;
}
}
}while (!no_more);
return 0;
}
int win_class::restore ()
{
Twin *temp_win;
mark_need_redraw();
int no_more;
do{
no_more= TRUE;
for (temp_win=pfirst_win_of_all; temp_win !=NULL; temp_win=temp_win->pnext_win){
if (temp_win == this ) continue;
if (!( temp_win->type & 0x40 )) continue;
if( (under_all_redrawed (temp_win)) && (!(temp_win->type & 0x80) )) {
temp_win->draw ();
temp_win->type |= 0x80;
no_more=FALSE;
continue;
}
}
}while (!no_more);
for (temp_win=pfirst_win_of_all; temp_win !=NULL; temp_win=temp_win->pnext_win)
temp_win ->type &= 0x3f;
return 0;
}
int win_class::restore_under_bitmap ()
{
if (( type & UNRESERVE_WIN ) && (pfirst_under != NULL )){
setport (win_living_viewport );
FillRect(bounds,WHITE);
restore ();
return 1;
}
setport(win_living_viewport);
if (punder_bitmap != NULL ){
putimage (bounds.left,bounds.top
,punder_bitmap ,COPY_PUT);
farfree (punder_bitmap );
punder_bitmap=NULL;
} else FillRect (bounds, SCREEN_BACK_COLOR );
return 0;
}
int win_class::reserve_self_bitmap ()
{
if ( type & UNRESERVE_WIN ) return 1;
if (pself_bitmap !=NULL )
farfree(pself_bitmap);
pself_bitmap = myfarmalloc
( (unsigned long) RectSize (bounds) );
setport (win_living_viewport);
getimage ( bounds.left,bounds.top,
bounds.right ,bounds.bottom ,
pself_bitmap );
return 0;
}
int win_class::reserve_under_bitmap()
{
if ( type & UNRESERVE_WIN ) return 1;
if (punder_bitmap !=NULL )
farfree(punder_bitmap);
punder_bitmap = myfarmalloc
( (unsigned long) RectSize (bounds) );
setport(win_living_viewport);
getimage ( bounds.left,bounds.top,
bounds.right ,bounds.bottom ,
punder_bitmap );
return 0;
}
int win_class::open_one_win ()
{ Twin *temp1;
unselect_current_selected_win();
if ( pfirst_win_of_all == NULL ) pfirst_win_of_all =this;
else {
for(temp1=pfirst_win_of_all;temp1->pnext_win!= NULL;temp1 =temp1 ->pnext_win);
temp1->pnext_win=this ;
}
build_all_links ( );
if (pfirst_under !=NULL )
reserve_under_bitmap();
pcurrent_selected_win =this ;
draw();
thequeue.SendMessage(pcurrent_selected_win->ID
,WinOpenedMSG,pcurrent_selected_win );
thequeue.SendMessage(ID,WinSelectedMSG,this);
return 0;
}
/* note : after a close it's users duty to NULL the ptr */
int win_class::close_one_win ()
{ Twin *temp_win, *front_temp_win;
// if (pwin_handled==NULL ) return 0;
if ( pfirst_above == NULL ) {
setport (win_living_viewport);
restore_under_bitmap ( );
} else // only for reserve space
invisible_one_win ( );
kill_all_links ( );
for (temp_win=pfirst_win_of_all ;
(( temp_win != NULL ) && (temp_win !=this ));
temp_win=temp_win ->pnext_win ) front_temp_win =temp_win;
if (pfirst_win_of_all == this )
pfirst_win_of_all =pnext_win;
else if (temp_win == this )
front_temp_win->pnext_win = pnext_win ;
this->pnext_win =NULL;
if (punder_bitmap != NULL )
farfree (punder_bitmap);
if (pself_bitmap != NULL )
farfree (pself_bitmap);
//????????????????????????????????
// farfree (pwin_handled );
/* now select the next window */
if (pfirst_win_of_all !=NULL ) {
for (temp_win=pfirst_win_of_all ;
( temp_win->pnext_win!= NULL ) && (temp_win->pfirst_above !=NULL);
temp_win=temp_win ->pnext_win ) ;
if (temp_win->pfirst_above ==NULL ) {
pcurrent_selected_win =temp_win;
temp_win-> visible = VISIBLE;
temp_win->draw_win_frame ();
}
} else pcurrent_selected_win =NULL;
if ( pcurrent_selected_win !=NULL )
thequeue.SendMessage(pcurrent_selected_win->ID,WinSelectedMSG,pcurrent_selected_win);
return 0;
}
int win_class::build_all_links ()
{
Twin *temp_win;
struct pwin_list *temp_list, *temp_under_list ;
struct Rect dstrect ;
/* condition pwin_handled is front-most in the screen */
for (temp_win=pfirst_win_of_all ; temp_win != NULL;
temp_win=temp_win ->pnext_win ){
if (( SectRect ( bounds ,
temp_win->bounds,&dstrect ) == TRUE_SECT) &&
( temp_win !=this ) ) {
if (temp_win->pfirst_above == NULL ) {
temp_win->pfirst_above =(struct pwin_list *) myfarmalloc ( sizeof(struct pwin_list));
temp_win->pfirst_above->pthe_win =this;
temp_win->pfirst_above->pnext_list=NULL ;
} else {
for ( temp_list= temp_win->pfirst_above;
temp_list->pnext_list!= NULL;temp_list =temp_list->pnext_list);
temp_list->pnext_list= (struct pwin_list *)myfarmalloc ( sizeof(struct pwin_list));
temp_list->pnext_list->pthe_win =this;
temp_list->pnext_list->pnext_list =NULL ;
};
/* above is to set up a win's above_link */
if (pfirst_under==NULL ) {
pfirst_under= (struct pwin_list *)myfarmalloc ( sizeof(struct pwin_list));
pfirst_under->pthe_win=temp_win;
pfirst_under->pnext_list=NULL;
temp_under_list =pfirst_under;
} else {
temp_under_list->pnext_list = (struct pwin_list *)myfarmalloc ( sizeof(struct pwin_list));
temp_under_list->pnext_list->pthe_win=temp_win;
temp_under_list->pnext_list->pnext_list=NULL;
temp_under_list =temp_under_list->pnext_list;
}
/* above is set up its own under win_list */
}
}
return 0;
}
int win_class::kill_all_links ()
{
Twin *temp_win;
struct pwin_list *temp_list, *front_temp_list ;
struct Rect dstrect ;
for (temp_win=pfirst_win_of_all ; temp_win!=NULL;
temp_win=temp_win ->pnext_win ){
if ( (temp_win->pfirst_above != NULL) && (temp_win !=this)){
for ( temp_list= temp_win->pfirst_above;
((temp_list->pnext_list!= NULL)&& (temp_list->pthe_win!=this)) ;
temp_list =temp_list->pnext_list)
front_temp_list =temp_list;
if (temp_list->pthe_win==this){
if (temp_list==temp_win->pfirst_above) temp_win->pfirst_above=temp_list->pnext_list;
else front_temp_list->pnext_list =temp_list->pnext_list;
farfree (temp_list );
}
};
/* above is to kill a win's above_link */
if ( (temp_win->pfirst_under != NULL) && (temp_win !=this)){
for ( temp_list= temp_win->pfirst_under;
((temp_list->pnext_list!= NULL)&& (temp_list->pthe_win!=this)) ;
temp_list =temp_list->pnext_list)
front_temp_list =temp_list;
if (temp_list->pthe_win==this ) {
if (temp_list==temp_win->pfirst_under) temp_win->pfirst_under=temp_list->pnext_list;
else front_temp_list->pnext_list =temp_list->pnext_list;
farfree (temp_list );
}
};
/* above is to kill a win's under_link */
}
if (pfirst_above !=NULL) {
temp_list =pfirst_above;
while ( temp_list != NULL ) {
front_temp_list =temp_list->pnext_list;
farfree ( temp_list );
temp_list=front_temp_list;
}
}
if (pfirst_under !=NULL) {
temp_list =pfirst_under;
while ( temp_list != NULL ) {
front_temp_list =temp_list->pnext_list;
farfree ( temp_list );
temp_list=front_temp_list;
}
}
pfirst_above =NULL;
pfirst_under =NULL;
return 0;
}
void win_class::draw_win_frame ()
{ struct Rect title_rect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -