EVENT uilistbox( EVENT ev, a_list *list, bool permanent ) { int listsize; int maxline; int newevent; a_list_info *box; int old_line; ORD old_row; bool close; if( Dclick ) { switch( ev ) { case EV_MOUSE_PRESS : Dclick = FALSE; /* must have gotten dlick without release */ /* fall through */ case EV_SCROLL_LINE_UP : case EV_SCROLL_LINE_DOWN : case EV_SCROLL_PAGE_UP : case EV_SCROLL_PAGE_DOWN : case EV_PAGE_UP : case EV_PAGE_DOWN : case EV_CURSOR_UP : case EV_CURSOR_DOWN : SelStart = FALSE; break; case EV_MOUSE_RELEASE : Dclick = FALSE; /* fall through */ default : return( ev ); } } close = FALSE; box = list->box; old_line = box->line; old_row = box->row; listsize = uilistsize( list ); if( listsize > box->area.height ) { maxline = listsize - box->area.height; } else { maxline = 0; } if( maxline > 0 ) { ev = uigadgetfilter( ev, &box->gadget ); } newevent = EV_NO_EVENT; switch( ev ) { case EV_MOUSE_DCLICK: Dclick = TRUE; case EV_MOUSE_PRESS: case EV_MOUSE_RELEASE: case EV_MOUSE_REPEAT: case EV_MOUSE_DRAG: { int row, col, mpos; mpos = getmouseregion( list, &row, &col ); newevent = ev; if( mpos == R_SEL ) { SelStart = TRUE; box->row = (ORD) row - box->area.row; box->row += box->line; } if( ev == EV_MOUSE_RELEASE ) { if( mpos == R_SEL ) { list->choice = list->box->row; newevent = EV_LIST_BOX_CHANGED; } if( SelStart ) { close = TRUE; SelStart = FALSE; } } else if( ev == EV_MOUSE_PRESS || ev == EV_MOUSE_DCLICK ) { if( mpos == R_SEL ) { if( ev == EV_MOUSE_DCLICK ) { newevent = EV_LIST_BOX_DCLICK; } } else { close = TRUE; } } else if( mpos == R_UP && box->line > 0 && SelStart ) { box->line--; box->row--; } else if( mpos == R_DOWN && box->line < maxline ) { box->line++; box->row++; } } break; case EV_CURSOR_UP : if( box->row > 0 ) { if( box->row == box->line ) { box->line--; } box->row--; list->choice = box->row; newevent = EV_LIST_BOX_CHANGED; } if( selectoutofrange( box ) ) { box->line = box->row; setstartline( list ); } break; case EV_SCROLL_LINE_UP : if( box->line > 0 ) { box->line--; } break; case EV_CURSOR_DOWN : if( box->row < listsize - 1 ) { if( box->row - box->line == box->area.height - 1 && box->line < maxline ) { ++box->line; } ++box->row; list->choice = box->row; newevent = EV_LIST_BOX_CHANGED; } if( selectoutofrange( box ) ) { box->line = box->row; setstartline( list ); } break; case EV_SCROLL_LINE_DOWN : if( box->line < maxline ) { box->line++; } break; case EV_PAGE_UP : if( box->row == box->line ) { if( box->line < ( box->area.height - 1 ) ) { box->line = 0; } else { box->line -= ( box->area.height - 1 ); } box->row -= old_line - box->line; } else { box->row = box->line; } if( box->row != old_row ) { list->choice = box->row; newevent = EV_LIST_BOX_CHANGED; } break; case EV_SCROLL_PAGE_UP : if( box->line < box->area.height ) { box->line = 0; } else { box->line -= box->area.height; } break; case EV_PAGE_DOWN : if( box->row == ( box->line + box->area.height - 1 ) ) { box->line += box->area.height - 1; if( box->line > maxline ) { box->line = maxline; } box->row += ( box->line - old_line ); } else { box->row = box->line + box->area.height - 1; } if( box->row != old_row ) { list->choice = box->row; newevent = EV_LIST_BOX_CHANGED; } break; case EV_SCROLL_PAGE_DOWN : box->line += box->area.height; if( box->line > maxline ) { box->line = maxline; } break; case EV_SCROLL_VERTICAL : box->line = box->gadget.pos; break; case EV_ALT_CURSOR_UP : close = TRUE; break; default : if( isalpha( ev ) ) { newevent = charselect( ev, list ); } else { newevent = ev; } break; } if( ( old_line != box->line ) && ( maxline > 0 ) ) { uisetgadget( &box->gadget, box->line ); } if( box->line != old_line || box->row != old_row ) { uipaintlistbox( list ); } if( !permanent && close ) { uiendlistbox( list ); newevent = EV_LIST_BOX_CLOSED; } return( newevent ); }
static EVENT hlpwait( VTAB *tab ) { bool done; static EVENT bumpev = EV_NO_EVENT; char *next_name; unsigned len1; unsigned len2; helpCur = field_find( helpTab, helpStack->cur ); if( helpTab != NULL && helpCur == NULL ) { helpCur = helpTab; } tab->other = helpCur; tab->curr = helpCur; if( helpCur != NULL ) { tab->home = helpCur->area.col; } uipushlist( helpEventList ); if( bumpev != EV_NO_EVENT ) { uitabfilter( bumpev, tab ); helpCur = tab->curr; bumpev = EV_NO_EVENT; } done = false; while( !done ) { if( helpTab != NULL ) { uivattribute( &helpScreen, helpCur->area, AT( ATTR_CURR_EDIT ) ); } do { uipushlist( keyShift ); curEvent = uivget( &helpScreen ); if( curEvent == EV_MOUSE_PRESS ) { ignoreMouseRelease = false; } uipoplist(); curEvent = uigadgetfilter( curEvent, &vGadget ); curEvent = uitabfilter( curEvent, tab ); } while( curEvent == EV_NO_EVENT ); if( eventMapFn != NULL ) { curEvent = (*eventMapFn)( curEvent ); } curEvent = uihotspotfilter( &helpScreen, hotSpotFields, curEvent ); if( helpTab != NULL ) { uivattribute( &helpScreen, helpCur->area, AT( ATTR_EDIT ) ); } switch( curEvent ) { case EV_HELP: nexttopic( helpWord ); done = true; break; case EV_BOTTOM: case E_UP: case EV_PAGE_UP: case EV_PAGE_DOWN: case EV_CURSOR_UP: case EV_CURSOR_DOWN: case EV_TOP: case E_DOWN: case EV_SCROLL_VERTICAL: if( curEvent == EV_BOTTOM ) { bumpev = EV_CURSOR_DOWN; } else if( curEvent == EV_TOP ) { bumpev = EV_CURSOR_UP; } helpStack->cur = field_count( helpTab, helpCur ); done = true; break; case '-': case EV_MOUSE_RELEASE_R: case EV_ALT_B: case 'b': case 'B': case EV_F8: case EV_F4: prevtopic(); if( strcmp( helpStack->helpfname, curFile ) ) { len1 = strlen( helpStack->word ); len2 = strlen( helpStack->helpfname ); helpCur = HelpMemAlloc( sizeof( a_field ) + len1 + len2 ); memcpy( helpCur->keyword, helpStack->word, len1 ); memcpy( helpCur->keyword + len1, helpStack->helpfname, len2 ); helpCur->keyword[len1 + len2] = '\0'; helpCur->key1_len = len1; helpCur->key2_len = len2; helpCur->next = NULL; // prevtopic(); helpTab = helpCur; } done = true; break; case EV_ALT_S: case 'S': case 's': if( helpSearchHdl != NULL ) { uipoplist(); next_name = HelpSearch( helpSearchHdl ); if( next_name != NULL ) { nexttopic( next_name ); HelpMemFree( next_name ); done = true; } uipushlist( helpEventList ); } break; case EV_FIELD_CHANGE: helpCur = tab->curr; break; case EV_MOUSE_RELEASE: if( tab->other == NULL ) break; if( ignoreMouseRelease ) { /* this mouse release is for a mouse press that occured * before this help topic was opened */ ignoreMouseRelease = false; break; } tab->other = tab->curr; /* fall through */ case EV_ENTER: /*same as page-down if there are other topics*/ case EV_F7: case '+': // DEN 90/04/12 - next line necessary for mouse release kludge helpCur = tab->curr; if( helpTab != NULL ) { if( helpCur->key2_len == 0 ) { nexttopic( helpCur->keyword ); } done = true; } break; case EV_KILL_UI: uiforceevadd( EV_KILL_UI ); /* fall through */ case EV_ESCAPE: done = true; break; } } uipoplist(); return( curEvent ); }