void TMenuView::do_a_select( TEvent& event ) { putEvent( event ); event.message.command = owner->execView(this); if( event.message.command != 0 && commandEnabled(event.message.command) ) { event.what = evCommand; event.message.infoPtr = 0; putEvent(event); } clearEvent(event); }
void TDirListBox::handleEvent( TEvent& event ) { if( event.what == evMouseDown && event.mouse.doubleClick ) { event.what = evCommand; event.message.command = cmChangeDir; putEvent( event ); clearEvent( event ); } else TListBox::handleEvent( event ); }
void TNHexInputLine::handleEvent( TEvent& event ) { if( ((state & sfSelected) != 0) && (event.what == evKeyDown) ) switch( ctrlToArrow( event.keyDown.keyCode ) ) { case kbLeft: case kbRight: case kbHome: case kbEnd: case kbBack: case kbDel: case kbIns: break; default: if( ((event.keyDown.charScan.charCode < 'a') || (event.keyDown.charScan.charCode > 'f')) && ((event.keyDown.charScan.charCode < 'A') || (event.keyDown.charScan.charCode > 'F')) && isalpha( event.keyDown.charScan.charCode ) ) { clearEvent( event ); return; } int num; getData( &num ); if( (event.keyDown.charScan.charCode == '0') && (num == 0) ) { clearEvent( event ); return; } } TNRightJustInputLine::handleEvent( event ); }
void TProgram::handleEvent( TEvent& event ) { if( event.what == evKeyDown ) { char c = getAltChar( event.keyDown.keyCode ); if( c >= '1' && c <= '9' ) { if( message( deskTop, evBroadcast, cmSelectWindowNum, (void *)(c - '0') ) != 0 ) clearEvent( event ); } } TGroup::handleEvent( event ); if( event.what == evCommand && event.message.command == cmQuit ) { endModal( cmQuit ); clearEvent( event ); } }
void TClickTester::handleEvent(TEvent& event) { TStaticText::handleEvent(event); if (event.what == evMouseDown) { if (event.mouse.doubleClick) { clicked = (clicked) ? 0 : 1; drawView(); } clearEvent(event); } }
void TNNumericInputLine::handleEvent( TEvent& event ) { if( ((state & sfSelected) != 0) && (event.what == evKeyDown) ) switch( ctrlToArrow( event.keyDown.keyCode ) ) { case kbLeft: case kbRight: case kbHome: case kbEnd: case kbBack: case kbDel: case kbIns: break; default: if( (event.keyDown.charScan.charCode >= ' ') && (event.keyDown.charScan.charCode != '.') && !isdigit( event.keyDown.charScan.charCode ) ) { clearEvent( event ); return; } int num; getData( &num ); if( (event.keyDown.charScan.charCode == '0') && (num == 0) ) { clearEvent( event ); return; } } TNRightJustInputLine::handleEvent( event ); }
void TStatusLine::handleEvent( TEvent& event ) { TView::handleEvent(event); switch (event.what) { case evMouseDown: { TStatusItem *T = 0; do { TPoint mouse = makeLocal( event.mouse.where ); if( T != itemMouseIsIn(mouse) ) drawSelect( T = itemMouseIsIn(mouse) ); } while( mouseEvent( event, evMouseMove ) ); if( T != 0 && commandEnabled(T->command) ) { event.what = evCommand; event.message.command = T->command; event.message.infoPtr = 0; putEvent(event); } clearEvent(event); drawView(); break; } case evKeyDown: { for( TStatusItem *T = items; T != 0; T = T->next ) { if( event.keyDown.keyCode == T->keyCode && commandEnabled(T->command)) { event.what = evCommand; event.message.command = T->command; event.message.infoPtr = 0; return; } } break; } case evBroadcast: if( event.message.command == cmCommandSetChanged ) drawView(); break; } }
void TProgressBar::handleEvent(TEvent& event) { TView::handleEvent(event); switch(event.what) { case evKeyboard: mainProcess() ; break; case evBroadcast: if(event.message.command == cmOK) mainProcess() ; break; } clearEvent(event); }
void TMyApp::handleEvent(TEvent& event) { TApplication::handleEvent(event); // act like base! if( event.what == evCommand ) { switch( event.message.command ) { case cmMyNewWin: // but respond to additional commands myNewWindow(); // define action for cmMyNewWin // command break; default: return; } clearEvent( event ); // clear event after handling } }
void TMyApp::handleEvent(TEvent& event) { TApplication::handleEvent(event); if( event.what == evCommand ) { switch( event.message.command ) { case cmInputBox: inputBox(); break; default: return; } clearEvent( event ); } }
void TChDirDialog::handleEvent( TEvent& event ) { TDialog::handleEvent( event ); switch( event.what ) { case evCommand: { char curDir[PATH_MAX]; switch( event.message.command ) { case cmRevert: getCurDir( curDir ); break; case cmChangeDir: { TDirEntry *p = dirList->list()->at( dirList->focused ); strcpy( curDir, p->dir() ); /* SS: changed */ if( curDir[strlen(curDir)-1] != '/' ) strcat( curDir, "/" ); break; } #ifndef __UNPATCHED //!! Handle directory selection. case cmDirSelection: chDirButton->makeDefault( (Boolean) event.message.infoPtr ); return; // NOTE: THIS IS RETURN NOT BREAK!! #endif default: return; } dirList->newDirectory( curDir ); int len = strlen( curDir ); /* SS: changed */ if( len > 0 && curDir[len-1] == '/' ) curDir[len-1] = EOS; strcpy( dirInput->data, curDir ); dirInput->drawView(); dirList->select(); clearEvent( event ); } default: break; } }
void TMouseDialog::handleEvent(TEvent& event) { TDialog::handleEvent(event); switch(event.what) { case evCommand: if(event.message.command == cmCancel) TEventQueue::doubleDelay = oldDelay; break; case evBroadcast: if(event.message.command == cmScrollBarChanged) { TEventQueue::doubleDelay = mouseScrollBar->value; clearEvent(event); } break; } }
void TDeskTop::handleEvent(TEvent& event) { TGroup::handleEvent( event ); if( event.what == evCommand ) { switch( event.message.command ) { case cmNext: selectNext( False ); break; case cmPrev: current->putInFrontOf( background ); break; default: return; } clearEvent( event ); } }
void TMyApp::handleEvent(TEvent& event) { TApplication::handleEvent(event); if( event.what == evCommand ) { switch( event.message.command ) { case cmMyNewWin: newWindow(); break; case cmNewDialog: newDialog(); break; default: return; } clearEvent( event ); // clear event after handling } }
void TitleWindow::handleEvent(MVEvent& event,phaseType) /**************************************************************************** * * Function: TitleWindow::handleEvent * Parameters: event - Event to handle * phase - Current phase for the event (pre,focus,post) * * Description: Event handling routine for the TitleWindow class. Here * we handle events that change the text in the window. * ****************************************************************************/ { if (event.what == evBroadcast) { if (event.message.command == cmSetDemoTitle) { title->setText((const char *)event.message.infoPtr); clearEvent(event); } } }
void TVDemo::getEvent(TEvent &event) { TWindow *w; THelpFile *hFile; fpstream *helpStrm; static Boolean helpInUse = False; TApplication::getEvent(event); switch (event.what) { case evCommand: if ((event.message.command == cmHelp) && ( helpInUse == False)) { helpInUse = True; helpStrm = new fpstream("DEMOHELP.HLP", ios::in|ios::binary); hFile = new THelpFile(*helpStrm); if (!helpStrm) { messageBox("Could not open help file", mfError | mfOKButton); delete hFile; } else { w = new THelpWindow(hFile, getHelpCtx()); if (validView(w) != 0) { execView(w); destroy( w ); } clearEvent(event); } helpInUse = False; } break; case evMouseDown: if (event.mouse.buttons != 1) event.what = evNothing; break; } }
void TFileEditor::handleEvent( TEvent& event ) { TEditor::handleEvent(event); switch( event.what ) { case evCommand: switch( event.message.command ) { case cmSave: save(); break; case cmSaveAs: saveAs(); break; default: return; } break; default: return; } clearEvent(event); }
void TMenuView::handleEvent( TEvent& event ) { if( menu != 0 ) switch (event.what) { case evMouseDown: do_a_select(event); break; case evKeyDown: if( findItem(getAltChar(event.keyDown.keyCode)) != 0 ) do_a_select(event); else { TMenuItem *p = hotKey(event.keyDown.keyCode); if( p != 0 && commandEnabled(p->command)) { event.what = evCommand; event.message.command = p->command; event.message.infoPtr = 0; putEvent(event); clearEvent(event); } } break; case evCommand: if( event.message.command == cmMenu ) do_a_select(event); break; case evBroadcast: if( event.message.command == cmCommandSetChanged ) { if( updateMenu(menu) ) drawView(); } break; } }
ushort TMenuView::execute() { Boolean autoSelect = False; menuAction action; char ch; ushort result = 0; TMenuItem *itemShown = 0; TMenuItem *p; TMenuView *target; TRect r; TEvent e; current = menu->deflt; do { action = doNothing; getEvent(e); switch (e.what) { case evMouseDown: if( mouseInView(e.mouse.where) || mouseInOwner(e) ) { trackMouse(e); if( size.y == 1 ) autoSelect = True; } else action = doReturn; break; case evMouseUp: trackMouse(e); if( mouseInOwner(e) ) current = menu->deflt; else if( current != 0 && current->name != 0 ) action = doSelect; else action = doReturn; break; case evMouseMove: if( e.mouse.buttons != 0 ) { trackMouse(e); if( !(mouseInView(e.mouse.where) || mouseInOwner(e)) && mouseInMenus(e) ) action = doReturn; } break; case evKeyDown: switch( ctrlToArrow(e.keyDown.keyCode) ) { case kbUp: case kbDown: if( size.y != 1 ) trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbDown)); else if( e.keyDown.keyCode == kbDown ) autoSelect = True; break; case kbLeft: case kbRight: if( parentMenu == 0 ) trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbRight)); else action = doReturn; break; case kbHome: case kbEnd: if( size.y != 1 ) { current = menu->items; if( e.keyDown.keyCode == kbEnd ) trackKey(False); } break; case kbEnter: if( size.y == 1 ) autoSelect = True; action = doSelect; break; case kbEsc: action = doReturn; if( parentMenu == 0 || parentMenu->size.y != 1 ) clearEvent(e); break; default: target = this; ch = getAltChar(e.keyDown.keyCode); if( ch == 0 ) ch = e.keyDown.charScan.charCode; else target = topMenu(); p = target->findItem(ch); if( p == 0 ) { p = topMenu()->hotKey(e.keyDown.keyCode); if( p != 0 && commandEnabled(p->command) ) { result = p->command; action = doReturn; } } else if( target == this ) { if( size.y == 1 ) autoSelect = True; action = doSelect; current = p; } else if( parentMenu != target || parentMenu->current != p ) action = doReturn; } break; case evCommand: if( e.message.command == cmMenu ) { autoSelect = False; if (parentMenu != 0 ) action = doReturn; } else action = doReturn; break; } if( itemShown != current ) { itemShown = current; drawView(); } if( (action == doSelect || (action == doNothing && autoSelect)) && current != 0 && current->name != 0 ) if( current->command == 0 ) { if( (e.what & (evMouseDown | evMouseMove)) != 0 ) putEvent(e); r = getItemRect( current ); r.a.x = r.a.x + origin.x; r.a.y = r.b.y + origin.y; r.b = owner->size; if( size.y == 1 ) r.a.x--; target = topMenu()->newSubView(r, current->subMenu,this); result = owner->execView(target); destroy( target ); } else if( action == doSelect ) result = current->command; if( result != 0 && commandEnabled(result) ) { action = doReturn; clearEvent(e); } } while( action != doReturn ); if( e.what != evNothing && (parentMenu != 0 || e.what == evCommand)) putEvent(e); if( current != 0 ) { menu->deflt = current; current = 0; drawView(); } return result; }
void TCluster::handleEvent( TEvent& event ) { TView::handleEvent(event); if( event.what == evMouseDown ) { TPoint mouse = makeLocal( event.mouse.where ); int i = findSel(mouse); if( i != -1 ) sel = i; drawView(); do { mouse = makeLocal( event.mouse.where ); if( findSel(mouse) == sel ) showCursor(); else hideCursor(); } while( mouseEvent(event,evMouseMove) ); showCursor(); mouse = makeLocal( event.mouse.where ); if( findSel(mouse) == sel ) { press(sel); drawView(); } clearEvent(event); } else if( event.what == evKeyDown ) switch (ctrlToArrow(event.keyDown.keyCode)) { case kbUp: if( (state & sfFocused) != 0 ) { if( --sel < 0 ) sel = strings->getCount()-1; movedTo(sel); drawView(); clearEvent(event); } break; case kbDown: if( (state & sfFocused) != 0 ) { if( ++sel >= strings->getCount() ) sel = 0; movedTo(sel); drawView(); clearEvent(event); } break; case kbRight: if( (state & sfFocused) != 0 ) { sel += size.y; if( sel >= strings->getCount() ) { sel = (sel + 1) % size.y; if( sel >= strings->getCount() ) sel = 0; } movedTo(sel); drawView(); clearEvent(event); } break; case kbLeft: if( (state & sfFocused) != 0 ) { if( sel > 0 ) { sel -= size.y; if( sel < 0 ) { sel = ((strings->getCount()+size.y-1) /size.y)*size.y + sel - 1; if( sel >= strings->getCount() ) sel = strings->getCount()-1; } } else sel = strings->getCount()-1; movedTo(sel); drawView(); clearEvent(event); } break; default: for( int i = 0; i < strings->getCount(); i++ ) { char c = hotKey( (char *)(strings->at(i)) ); if( getAltCode(c) == event.keyDown.keyCode || ( ( owner->phase == phPostProcess || (state & sfFocused) != 0 ) && c != 0 && toupper(event.keyDown.charScan.charCode) == c ) ) { select(); sel = i; movedTo(sel); press(sel); drawView(); clearEvent(event); return; } } if( event.keyDown.charScan.charCode == ' ' && (state & sfFocused) != 0 ) { press(sel); drawView(); clearEvent(event); } } }
void TCluster::handleEvent(TEvent &event) { TView::handleEvent(event); if (!(options & ofSelectable)) return; if (event.what == evMouseDown) { TPoint mouse = makeLocal(event.mouse.where); int i = findSel(mouse); if ((i != -1) && buttonState(i)) sel = i; drawView(); do { mouse = makeLocal(event.mouse.where); if ((findSel(mouse) == sel) && buttonState(sel)) showCursor(); else hideCursor(); } while (mouseEvent(event, evMouseMove)); showCursor(); mouse = makeLocal(event.mouse.where); if (findSel(mouse) == sel) { press(sel); drawView(); } clearEvent(event); } else if (event.what == evKeyDown) { int s = sel; switch (ctrlToArrow(event.keyDown.keyCode)) { case kbUp: if ((state & sfFocused) != 0) { int i = 0; do { i++; s--; if (s < 0) s = strings->getCount() - 1; } while (!(buttonState(s) || (i > strings->getCount()))); moveSel(i, s); clearEvent(event); } break; case kbDown: if ((state & sfFocused) != 0) { int i = 0; do { i++; s++; if (s >= strings->getCount()) s = 0; } while (!(buttonState(s) || (i > strings->getCount()))); moveSel(i, s); clearEvent(event); } break; case kbRight: if ((state & sfFocused) != 0) { int i = 0; do { i++; s += size.y; if (s >= strings->getCount()) { // BUG FIX - EFW - 10/25/94 s = (s + 1) % size.y; if (s >= strings->getCount()) s = 0; } } while (!(buttonState(s) || (i > strings->getCount()))); moveSel(i, s); // BUG FIX - EFW - 10/25/94 clearEvent(event); } break; case kbLeft: if ((state & sfFocused) != 0) { int i = 0; do { i++; if (s > 0) { s -= size.y; if (s < 0) { s = ((strings->getCount() + size.y - 1) / size.y) * size.y + s - 1; if (s >= strings->getCount()) s = strings->getCount() - 1; } } else s = strings->getCount() - 1; } while (!(buttonState(s) || (i > strings->getCount()))); moveSel(i, s); // BUG FIX - EFW - 10/25/94 clearEvent(event); } break; default: for (int i = 0; i < strings->getCount(); i++) { char c = hotKey((char *)(strings->at(i))); if (getAltCode(c) == event.keyDown.keyCode || ((owner->phase == phPostProcess || (state & sfFocused) != 0 ) && c != 0 && toupper(event.keyDown.charScan.charCode) == c ) ) { if (buttonState(i)) { if (focus()) { sel = i; movedTo(sel); press(sel); drawView(); } clearEvent(event); } return; } } if (event.keyDown.charScan.charCode == ' ' && (state & sfFocused) != 0 ) { press(sel); drawView(); clearEvent(event); } } } }
void TOutlineViewer::handleEvent(TEvent &event) { const int mouseAutoToSkip = 3; TPoint mouse; TNode *cur; int newFocus; int count; char *graph; uchar dragged; TScroller::handleEvent(event); switch (event.what) { case evMouseDown: count = 0; dragged = 0; do { if (dragged < 2) dragged++; mouse = makeLocal(event.mouse.where); if (mouseInView(event.mouse.where)) newFocus = delta.y + mouse.y; else { if (event.what == evMouseAuto) count++; if (count == mouseAutoToSkip) { count = 0; if (mouse.y < 0) newFocus--; if (mouse.y >= size.y) newFocus++; } } if (foc != newFocus) { adjustFocus(newFocus); drawView(); } } while (!(event.mouse.eventFlags & meDoubleClick) && mouseEvent(event, evMouseMove + evMouseAuto)); if (event.mouse.eventFlags & meDoubleClick) selected(foc); else { if (dragged < 2) { cur = firstThat(isFocused); graph = getGraph(focLevel, focLines, focFlags); if (mouse.x < strlen(graph)) { adjust(cur, ! isExpanded(cur) ? True : False); update(); drawView(); } delete graph; } } break; case evKeyboard: newFocus = foc; switch (ctrlToArrow(event.keyDown.keyCode)) { case kbUp: case kbLeft: newFocus--; break; case kbDown: case kbRight: newFocus++; break; case kbPgDn: newFocus += size.y - 1; break; case kbPgUp: newFocus -= size.y - 1; break; case kbHome: newFocus = delta.y; break; case kbEnd: newFocus = delta.y + size.y - 1; break; case kbCtrlPgUp: newFocus = 0; break; case kbCtrlPgDn: newFocus = limit.y - 1; break; case kbCtrlEnter: case kbEnter: selected(newFocus); break; default: uchar code = event.keyDown.charScan.charCode; switch (code) { case '-': case '+': adjust(getNode(newFocus), code == '+' ? True : False); break; case '*': expandAll(getNode(newFocus)); break; default: return; } update(); } clearEvent(event); adjustFocus(newFocus); drawView(); }; };
void TEditor::handleEvent( TEvent& event ) { TView::handleEvent( event ); convertEvent( event ); Boolean centerCursor = Boolean(!cursorVisible()); uchar selectMode = 0; if( selecting == True || (getShiftState() & 0x03) != 0 ) selectMode = smExtend; switch( event.what ) { case evMouseDown: if( event.mouse.doubleClick == True ) selectMode |= smDouble; do { lock(); if( event.what == evMouseAuto ) { TPoint mouse = makeLocal( event.mouse.where ); TPoint d = delta; if( mouse.x < 0 ) d.x--; if( mouse.x >= size.x ) d.x++; if( mouse.y < 0 ) d.y--; if( mouse.y >= size.y ) d.y++; scrollTo(d.x, d.y); } setCurPtr(getMousePtr(event.mouse.where), selectMode); selectMode |= smExtend; unlock(); } while( mouseEvent(event, evMouseMove + evMouseAuto) ); break; case evKeyDown: if( event.keyDown.charScan.charCode == 9 || ( event.keyDown.charScan.charCode >= 32 && event.keyDown.charScan.charCode < 255 ) ) { lock(); if( overwrite == True && hasSelection() == False ) if( curPtr != lineEnd(curPtr) ) selEnd = nextChar(curPtr); insertText( &event.keyDown.charScan.charCode, 1, False); trackCursor(centerCursor); unlock(); } else return; break; case evCommand: switch( event.message.command ) { case cmFind: find(); break; case cmReplace: replace(); break; case cmSearchAgain: doSearchReplace(); break; default: lock(); switch( event.message.command ) { case cmCut: clipCut(); break; case cmCopy: clipCopy(); // hideSelect(); // JS 12.4.94 break; case cmPaste: clipPaste(); break; case cmUndo: undo(); break; case cmClear: deleteSelect(); break; case cmCharLeft: setCurPtr(prevChar(curPtr), selectMode); break; case cmCharRight: setCurPtr(nextChar(curPtr), selectMode); break; case cmWordLeft: setCurPtr(prevWord(curPtr), selectMode); break; case cmWordRight: setCurPtr(nextWord(curPtr), selectMode); break; case cmLineStart: setCurPtr(lineStart(curPtr), selectMode); break; case cmLineEnd: setCurPtr(lineEnd(curPtr), selectMode); break; case cmLineUp: setCurPtr(lineMove(curPtr, -1), selectMode); break; case cmLineDown: setCurPtr(lineMove(curPtr, 1), selectMode); break; case cmPageUp: setCurPtr(lineMove(curPtr, -(size.y-1)), selectMode); break; case cmPageDown: setCurPtr(lineMove(curPtr, size.y-1), selectMode); break; case cmTextStart: setCurPtr(0, selectMode); break; case cmTextEnd: setCurPtr(bufLen, selectMode); break; case cmNewLine: newLine(); break; case cmBackSpace: deleteRange(prevChar(curPtr), curPtr, True); break; case cmDelChar: deleteRange(curPtr, nextChar(curPtr), True); break; case cmDelWord: deleteRange(curPtr, nextWord(curPtr), False); break; case cmDelStart: deleteRange(lineStart(curPtr), curPtr, False); break; case cmDelEnd: deleteRange(curPtr, lineEnd(curPtr), False); break; case cmDelLine: deleteRange(lineStart(curPtr), nextLine(curPtr), False); break; case cmInsMode: toggleInsMode(); break; case cmStartSelect: startSelect(); break; case cmHideSelect: hideSelect(); break; case cmIndentMode: autoIndent = Boolean(!autoIndent); break; default: unlock(); return; } trackCursor(centerCursor); unlock(); break; } case evBroadcast: switch( event.message.command ) { case cmScrollBarChanged: checkScrollBar( event, hScrollBar, delta.x ); checkScrollBar( event, vScrollBar, delta.y ); break; default: return; } } clearEvent(event); }
void TListViewer::handleEvent(TEvent &event) { TPoint mouse; ushort colWidth; int oldItem, newItem; int count; int mouseAutosToSkip = 4; TView::handleEvent(event); if (event.what == evMouseDown) { colWidth = size.x / numCols + 1; oldItem = focused; mouse = makeLocal(event.mouse.where); if (mouseInView(event.mouse.where)) newItem = mouse.y + (size.y * (mouse.x / colWidth)) + topItem; else newItem = oldItem; count = 0; do { if (newItem != oldItem) { focusItemNum(newItem); drawView(); } oldItem = newItem; mouse = makeLocal(event.mouse.where); if (mouseInView(event.mouse.where)) newItem = mouse.y + (size.y * (mouse.x / colWidth)) + topItem; else { if (numCols == 1) { if (event.what == evMouseAuto) count++; if (count == mouseAutosToSkip) { count = 0; if (mouse.y < 0) newItem = focused - 1; else if (mouse.y >= size.y) newItem = focused + 1; } } else { if (event.what == evMouseAuto) count++; if (count == mouseAutosToSkip) { count = 0; if (mouse.x < 0) newItem = focused - size.y; else if (mouse.x >= size.x) newItem = focused + size.y; else if (mouse.y < 0) newItem = focused - focused % size.y; else if (mouse.y > size.y) newItem = focused - focused % size.y + size.y - 1; } } } if (event.mouse.eventFlags & meDoubleClick) break; } while (mouseEvent(event, evMouseMove | evMouseAuto)); focusItemNum(newItem); drawView(); if ((event.mouse.eventFlags & meDoubleClick) && range > newItem) selectItem(newItem); clearEvent(event); } else if (event.what == evKeyDown) { if (event.keyDown.charScan.charCode == ' ' && focused < range) { selectItem(focused); newItem = focused; } else { switch (ctrlToArrow(event.keyDown.keyCode)) { case kbUp: newItem = focused - 1; break; case kbDown: newItem = focused + 1; break; case kbRight: if (numCols > 1) newItem = focused + size.y; else return; break; case kbLeft: if (numCols > 1) newItem = focused - size.y; else return; break; case kbPgDn: newItem = focused + size.y * numCols; break; case kbPgUp: newItem = focused - size.y * numCols; break; case kbHome: newItem = topItem; break; case kbEnd: newItem = topItem + (size.y * numCols) - 1; break; case kbCtrlPgDn: newItem = range - 1; break; case kbCtrlPgUp: newItem = 0; break; default: return; } } focusItemNum(newItem); drawView(); clearEvent(event); } else if (event.what == evBroadcast) { if ((options & ofSelectable) != 0) { if (event.message.command == cmScrollBarClicked && (event.message.infoPtr == hScrollBar || event.message.infoPtr == vScrollBar)) focus(); // BUG FIX <<------ Change else if (event.message.command == cmScrollBarChanged) { if (vScrollBar == event.message.infoPtr) { focusItemNum(vScrollBar->value); drawView(); } else if (hScrollBar == event.message.infoPtr) drawView(); } } } }
void TWindow::handleEvent( TEvent& event ) { TRect limits; TPoint min, max; TGroup::handleEvent(event); if( event.what== evCommand ) switch (event.message.command) { case cmResize: if( (flags & (wfMove | wfGrow)) != 0 ) { limits = owner->getExtent(); sizeLimits(min, max); dragView( event, dragMode | (flags & (wfMove | wfGrow)), limits, min, max); clearEvent(event); } break; case cmClose: if( (flags & wfClose) != 0 && ( event.message.infoPtr == 0 || event.message.infoPtr == this ) ) { clearEvent(event); if( (state & sfModal) == 0 ) close(); else { event.what = evCommand; event.message.command = cmCancel; putEvent( event ); clearEvent( event ); } } break; case cmZoom: if( (flags & wfZoom) != 0 && (event.message.infoPtr == 0 || event.message.infoPtr == this) ) { zoom(); clearEvent(event); } break; } else if( event.what == evKeyDown ) switch (event.keyDown.keyCode) { case kbTab: focusNext(False); clearEvent(event); break; case kbShiftTab: focusNext(True); clearEvent(event); break; } else if( event.what == evBroadcast && event.message.command == cmSelectWindowNum && /* * Some non-portable code changed. See `TProgram.cc'. */ (int)event.message.infoPtr == number && // event.message.infoInt == number && (options & ofSelectable) != 0 ) { select(); clearEvent(event); } }
void TMyApp::handleEvent(TEvent& event) { TApplication::handleEvent(event); // act like base! if (event.what == evCommand) { switch (event.message.command) { case cmMyNewWin: myNewWindow(); break; case cmAboutCmd: aboutDlgBox(); break; case cmCalendarCmd: calendar(); break; case cmAsciiCmd: asciiTable(); break; case cmCalcCmd: calculator(); break; case cmPuzzleCmd: puzzle(); break; case cmTile: tile(); break; case cmCascade: cascade(); break; case cmCO128x75: setVideoMode(TScreen::smCO128x75); break; case cmCO128x60: setVideoMode(TScreen::smCO128x60); break; case cmCO128x37: setVideoMode(TScreen::smCO128x37); break; case cmCO113x75: setVideoMode(TScreen::smCO113x75); break; case cmCO113x37: setVideoMode(TScreen::smCO113x37); break; case cmCO102x30: setVideoMode(TScreen::smCO102x30); break; case cmCO85x37: setVideoMode(TScreen::smCO85x37); break; case cmCO85x26: setVideoMode(TScreen::smCO85x26); break; case cmCO85x25: setVideoMode(TScreen::smCO85x25); break; case cmCO85x22: setVideoMode(TScreen::smCO85x22); break; case cmCO73x20: setVideoMode(TScreen::smCO73x20); break; case cmCO64x18: setVideoMode(TScreen::smCO64x18); break; case cmCO64x16: setVideoMode(TScreen::smCO64x16); break; case cmCO40x22: setVideoMode(TScreen::smCO40x22); break; default: return; } clearEvent(event); // clear event after handling } }
void MVListBase::handleEvent(MVEvent& event,phaseType phase) /**************************************************************************** * * Function: MVListBase::handleEvent * Parameters: event - Event to handle * phase - Current phase for the event (pre,focus,post) * * Description: Event handling mechanism for the MVListBase class. * ****************************************************************************/ { MVView::handleEvent(event,phase); switch (event.what) { case evMouseDown: if (range.isEmpty()) return; if (event.mouse.buttons & mbLeftButton) { while (event.what != evMouseUp) { switch (event.what) { case evMouseDown: if (!(event.mouse.modifiers & mdShift) && !(flags & lsDisjointSelect)) { clearSelection(); selectCell(cursor); refresh(); } if (event.mouse.doubleClick) { MV_message(owner,evBroadcast,cmListItemSelected,this); goto doneMouse; } case evMouseAuto: case evMouseMove: MVPoint loc; uint modifiers = mdShift; if (event.what == evMouseDown) modifiers = event.mouse.modifiers; if (flags & lsDisjointSelect) modifiers = 0; uint pos = findCellHit(event.where,loc); if (pos == lsInside && event.what != evMouseAuto) { // Selection within the list if (loc == cursor && event.what == evMouseDown) { // Post a message to ensure updates // occur for the first mouse down event // in the list box. MV_message(owner,evBroadcast, cmListCursorChanged,this); } if (loc.x < cursor.x) selectLeft(cursor.x - loc.x,modifiers); else if (loc.x > cursor.x) selectRight(loc.x - cursor.x,modifiers); if (loc.y < cursor.y) selectUp(cursor.y - loc.y,modifiers); else if (loc.y > cursor.y) selectDown(loc.y - cursor.y,modifiers); } else if (event.what == evMouseAuto) { // Auto selection outside window to scroll if (pos & lsAbove) selectUp(1,modifiers); if (pos & lsBelow) selectDown(1,modifiers); if (pos & lsLeft) selectLeft(1,modifiers); if (pos & lsRight) selectRight(1,modifiers); } if (event.what == evMouseDown && flags & lsDisjointSelect) { toggleCell(cursor); refresh(); } break; } getEvent(event); } doneMouse: clearEvent(event); } break; case evKeyDown: case evKeyAuto: if (range.isEmpty()) return; switch (event.key.charScan.scanCode) { case kbSpace: if (event.what == evKeyAuto) break; if (flags & lsDisjointSelect) { toggleCell(cursor); refresh(); } break; case kbLeft: selectLeft(1,event.key.modifiers); break; case kbRight: selectRight(1,event.key.modifiers); break; case kbUp: selectUp(1,event.key.modifiers); break; case kbDown: selectDown(1,event.key.modifiers); break; case kbHome: selectNext(lsLeft | lsAbove,range.bottom(), event.key.modifiers); break; case kbEnd: selectNext(lsRight | lsBelow,range.bottom(), event.key.modifiers); break; case kbPgUp: selectUp(visible.bottom()-visible.top(), event.key.modifiers,true); break; case kbPgDn: selectDown(visible.bottom()-visible.top(), event.key.modifiers,true); default: // Key press is not handled by us, so simply return. return; } clearEvent(event); break; case evBroadcast: if (options & ofSelectable) { if (event.message.command == cmScrollBarClicked && (event.message.infoPtr == hScroll || event.message.infoPtr == vScroll)) select(); else if (event.message.command == cmScrollBarChanged) { if (range.isEmpty()) return; if (event.message.infoPtr == hScroll) hScrollTo(hScroll->getValue()); else if (event.message.infoPtr == vScroll) vScrollTo(vScroll->getValue()); } } break; } }
//***************************************************************** // a single mouse click is not cleared by List View Box, Dialog uses it // to erase inputline if user clicks off of it . void TListViewDialog::handleEvent(TEvent &event) { AllocLocalStr(b,inputLineLen); switch(event.what) { case evMouseDown: // clears input line if (inputLine->state&sfSelected) { inputLine->hide(); } break; case evKeyDown: switch(event.keyDown.keyCode) { case kbEsc: // clears input line if (inputLine->state&sfSelected) { inputLine->hide(); clearEvent(event); } break; case kbEnter: // saves input line to list box using listBoxPtr if (inputLine->state&sfSelected) { listBoxPtr->putData( (void *)inputLine->getData() ); inputLine->hide(); clearEvent(event); } break; } case evBroadcast: // from List Boxes, infoPtr points to orginator switch (event.message.command) { case cmListItemSelected: // if input line is already showing, hide it if (inputLine->state&sfSelected) { inputLine->hide(); clearEvent(event); } else { // show empty input line int mouseLocY =((TListViewBox *)event.message.infoPtr)->cursor.y ; int mouseLocX =((TListViewBox *)event.message.infoPtr)->origin.x ; listBoxPtr =(TListViewBox *)event.message.infoPtr; inputLine->moveTo(mouseLocX, mouseLocY+2); inputLine->setDataFromStr( (void *)" " ); inputLine->show(); clearEvent(event); } break; case cmListKeyEnter: // enter key pressed in list box, copy data to inputline int mouseLocY =((TListViewBox *)event.message.infoPtr)->cursor.y ; int mouseLocX =((TListViewBox *)event.message.infoPtr)->origin.x ; listBoxPtr =(TListViewBox *)event.message.infoPtr; inputLine->moveTo(mouseLocX, mouseLocY+2); listBoxPtr->getText( b,listBoxPtr->focused,inputLineLen ); inputLine->setDataFromStr( b ); inputLine->show(); clearEvent(event); break; } } // Let TDialog handler do it's thing with any remaining events. TDialog::handleEvent(event); sprintf(b,"%d",listBox->focused); itemNumber->setDataFromStr( b ); itemNumber->draw(); } // end of MyDialogBox::eventHandler()
void MVScrollBar::handleEvent(MVEvent& event,phaseType phase) /**************************************************************************** * * Function: MVScrollBar::handleEvent * Parameters: event - Event to handle * phase - Current phase for the event (pre,focus,post) * * Description: Event handling routine for scroll bars. * ****************************************************************************/ { MVView::handleEvent(event,phase); flags |= sbInteracting; if (event.what == evMouseDown) { // Let the owning view know that the scroll bar has been clicked, // so that any associated lists etc can select themselves and // prepare for scroll bar changed events. MV_message(owner,evBroadcast,cmScrollBarClicked,this); MVEvent e; getEvent(e,evRepaint); // Force repaint dc.setClipRect(bounds); ibool down; int part = getPartHit(event.where); if (part == -1) goto QuickExit; if ((part == (int)sbLeftArrow && value == minVal) || (part == (int)sbRightArrow && value == maxVal) || (minVal == maxVal)) { MV_beep(); goto QuickExit; } drawPart(part,down = true); while (event.what != evMouseUp) { switch (event.what) { case evMouseDown: case evMouseAuto: if (part == getPartHit(event.where)) changeValue(part); break; case evMouseMove: if (part != (int)sbThumb) { if (down != (part == getPartHit(event.where))) drawPart(part,down = !down); } else changeValue(event.where); break; } if (part != (int)sbThumb && (value == minVal || value == maxVal)) break; getEvent(event); } if (down) drawPart(part,false); // Redraw the arrows if they have changed state during the // interaction, and we were adjusting the paging state. if (part == (int)sbPageLeft || part == (int)sbPageRight || part == (int)sbThumb) { if (value == minVal) drawLeftArrow(false); else if (value == maxVal) drawRightArrow(false); } QuickExit: clearEvent(event); } flags &= ~sbInteracting; }
void TStaticInputLine::handleEvent(TEvent& event) { char testChar[2]; char *tempData; ccIndex index; if (event.what == evKeyDown) { if (isprint(event.keyDown.charScan.charCode)) { testChar[0] = event.keyDown.charScan.charCode; testChar[1] = '\0'; tempData = (char *)getNextMatch(testChar[0]); if (tempData != 0) { strcpy(data, tempData); selectAll(True); drawView(); } clearEvent(event); } else switch (event.keyDown.keyCode) { case kbUp : index = list->indexOf(data) - 1; if (index < 0) index = list->getCount() - 1; strcpy(data, (char *)list->at(index)); selectAll(True); drawView(); clearEvent(event); break; case kbDown : index = list->indexOf(data) + 1; if (index >= list->getCount()) index = 0; strcpy(data, (char *)list->at(index)); selectAll(True); drawView(); clearEvent(event); break; case kbHome: index = 0; strcpy(data, (char *)list->at(index)); selectAll(True); drawView(); clearEvent(event); break; case kbEnd: index = list->getCount() - 1; strcpy(data, (char *)list->at(index)); selectAll(True); drawView(); clearEvent(event); break; case kbLeft : case kbRight : case kbBack : case kbIns : case kbDel : clearEvent(event); } } TInputLine::handleEvent(event); }