void CayaRenderView::AppendOwnMessage(const char* message) { Append("You say: ", COL_OWNNICK, COL_OWNNICK, R_TEXT); AddEmoticText(message, COL_TEXT, R_TEXT,COL_TEXT,R_EMOTICON); Append("\n", COL_TEXT, COL_TEXT, R_TEXT); ScrollToSelection(); }
/*------------------------------------------------------------------------------*\ MessageReceived( msg) - \*------------------------------------------------------------------------------*/ BmListViewItem* BmSendAccView::AddModelItem( BmListModelItem* item) { BmListViewItem* viewItem = inherited::AddModelItem( item); if (viewItem) { Select( IndexOf(viewItem)); ScrollToSelection(); } return viewItem; }
void CayaRenderView::AppendOtherMessage(const char* message) { Append(fOtherNick.String(), COL_OTHERNICK, COL_OTHERNICK, R_TEXT); Append(": ", COL_OTHERNICK, COL_OTHERNICK, R_TEXT); AddEmoticText(message, COL_TEXT, R_TEXT, COL_TEXT,R_EMOTICON); Append("\n", COL_TEXT, COL_TEXT, R_TEXT); ScrollToSelection(); }
void DisplayDirector::Undo() { StartRefreshCycle(); if (lastAction != sentinalAction) { lastAction->Undo(this); lastAction = lastAction->PrevAction(); } FinishRefreshCycle(); ClearDeletedSelections(); ScrollToSelection(); }
void DisplayDirector::Redo() { StartRefreshCycle(); Action* nextAction = lastAction->NextAction(); if (nextAction) { nextAction->Do(this); lastAction = nextAction; } FinishRefreshCycle(); ClearDeletedSelections(); ScrollToSelection(); }
void InputTextView::_CheckTextRect() { // update text rect and make sure // the cursor/selection is in view BRect textRect(TextRect()); float width = ceilf(StringWidth(Text()) + 2.0); if (textRect.Width() < width) { textRect.right = textRect.left + width; SetTextRect(textRect); ScrollToSelection(); } }
void MemoryView::MessageReceived(BMessage* message) { switch(message->what) { case MSG_TARGET_ADDRESS_CHANGED: { _RecalcScrollBars(); ScrollToSelection(); Invalidate(); break; } case MSG_SET_HEX_MODE: { int32 mode; if (message->FindInt32("mode", &mode) == B_OK) { fHexMode = mode; _RecalcScrollBars(); Invalidate(); } break; } case MSG_SET_ENDIAN_MODE: { int32 mode; if (message->FindInt32("mode", &mode) == B_OK) { fCurrentEndianMode = mode; Invalidate(); } break; } case MSG_SET_TEXT_MODE: { int32 mode; if (message->FindInt32("mode", &mode) == B_OK) { fTextMode = mode; _RecalcScrollBars(); Invalidate(); } break; } default: { BView::MessageReceived(message); break; } } }
void WrappingTextView::RedoChange() { if (m_curr_undo_index >= m_max_undo_index) return; UndoInfo info = m_undo_vect[m_curr_undo_index++]; m_in_undo_redo = true; if (info.isInsertion) { BTextView::Insert( info.offset, info.text.String(), info.text.Length(), info.text_runs); Select( info.offset+info.text.Length(), info.offset+info.text.Length()); } else { BTextView::Delete( info.offset, info.offset+info.text.Length()); Select( info.offset, info.offset); } ScrollToSelection(); m_in_undo_redo = false; if(!m_modified_disabled) Modified(); }
void MimeTypeListView::UpdateItem(MimeTypeItem* item) { int32 selected = -1; if (IndexOf(item) == CurrentSelection()) selected = CurrentSelection(); item->UpdateText(); _MakeTypesUnique(dynamic_cast<MimeTypeItem*>(Superitem(item))); if (selected != -1) { int32 index = IndexOf(item); if (index != selected) { Select(index); ScrollToSelection(); } } if (Window()) InvalidateItem(IndexOf(item)); }
void MimeTypeListView::SelectItem(MimeTypeItem* item) { if (item == NULL) { Select(-1); return; } // Make sure the item is visible BListItem* superItem = item; while ((superItem = Superitem(superItem)) != NULL) { Expand(superItem); } // Select it, and make it visible int32 index = IndexOf(item); Select(index); ScrollToSelection(); }
void WrappingTextView::UndoChange() { if (!m_curr_undo_index) return; UndoInfo info = m_undo_vect[--m_curr_undo_index]; m_in_undo_redo = true; int32 len = info.text.Length(); if (info.isInsertion) { BTextView::Delete( info.offset, info.offset+len); Select( info.offset, info.offset); } else { BTextView::Insert( info.offset, info.text.String(), info.text.Length(), info.text_runs); if (info.deleteToRight) Select( info.offset, info.offset); else Select( info.offset+len, info.offset+len); } ScrollToSelection(); m_in_undo_redo = false; if(!m_modified_disabled) Modified(); }
void UnicodeBlockView::SelectBlockForCharacter(uint32 character) { // find block containing the character // TODO: could use binary search here for (uint32 i = 0; i < kNumUnicodeBlocks; i++) { if (kUnicodeBlocks[i].end < character) continue; if (kUnicodeBlocks[i].start > character) { // Character is not mapped break; } BlockListItem* block = fBlocks.ItemAt(i); int32 blockNum = IndexOf(block); if (blockNum >= 0) { Select(blockNum); ScrollToSelection(); } } }
// ------------------------------------------------------------------------------- RHTML_text_view - KeyDown - void RHTMLtextview::KeyDown(const char *bytes, int32 numBytes) { pushmenu = false; int32 c,d; GetSelection(&c, &d); BString *oldtext = new BString(Text()); BString *newtext = 0; switch(bytes[0]) { case B_ESCAPE: // - ESC { } break; case B_ENTER: // - ENTER { fTarget->SetModify(true); BString tmp = ""; if (d - OffsetAt(CurrentLine()) > 0) { for (int i = OffsetAt(CurrentLine()); i < d; i++) { if (Text()[i] == B_SPACE || Text()[i] == B_TAB) { tmp << Text()[i]; } else break; } } BTextView::KeyDown(bytes, numBytes); Insert(tmp.String()); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()), 0, c); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength() - 1).y + 50 > fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right, PointAt(TextLength() - 1).y + 50); } break; case '>': // - > { fTagMenu->Stop(); fTarget->SetModify(true); BTextView::KeyDown(bytes,numBytes); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()),0,c); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); } break; case '<': // - < { BTextView::KeyDown(bytes,numBytes); fTarget->SetModify(true); pushmenu=true; ScrollToSelection(); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()),0,c); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); mode=1; fTimer->StartTimer(fOptions->ReakcioIdoTM); } break; case B_SPACE: // - SPACE { fTarget->SetModify(true); BTextView::KeyDown(bytes,numBytes); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()),0,c); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); buf1 = ""; int32 o; for (int i=c;i>=0;i--) { if (Text()[i]=='>') break; if (Text()[i]=='<') { for (o=i+1;o<=c+1;o++) { if (Text()[o]=='>') break; if (Text()[o]=='<') break; if (Text()[o]==' ') { pushmenu=true; mode=2; fTimer->StartTimer(fOptions->ReakcioIdoTM); break; i=-1; } buf1 << Text()[o]; } } } BString str(Text()); int32 a,b; tags.clear(); a=str.FindLast('<',c); if (a>str.FindLast('>',c)) { b=str.FindFirst('>',c); int32 e=str.FindFirst('<',c); if (b>=0 && ((b<e && e>=0) || (e<0))) { while (str[a]!=' ') a++; a++; int32 i=a; while (i<b) { if (str[i]==' ') { BString tmp; str.CopyInto(tmp,a,i-a); tmp.ToLower(); if (tmp!=" " && tmp!="") tags.push_back(tmp); a=i+1; } if (str[i]=='=') { BString tmp; str.CopyInto(tmp,a,i-a); tmp.ToLower(); tags.push_back(tmp); if (str[i+1]=='"') { a=str.FindFirst('"',i+2)+1; i=a-1; } else a=i=str.FindFirst(' ',i+1); } i++; } } } } break; case B_UP_ARROW: // - UP { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_DOWN_ARROW: // - DOWN { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_LEFT_ARROW: // - LEFT { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_RIGHT_ARROW: // - RIGHT { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_PAGE_UP: // - PUP { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_PAGE_DOWN: // - PDOWN { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_HOME: // - HOME { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_END: // - END { BTextView::KeyDown(bytes,numBytes); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); } break; case B_BACKSPACE: // - BackSpace { fTarget->SetModify(true); BTextView::KeyDown(bytes,numBytes); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()),0,c-1); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); } break; default: { fTarget->SetModify(true); BTextView::KeyDown(bytes,numBytes); fFileTypes->SetFontAndColor(oldtext, newtext = new BString(Text()),0,c); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); if (fUpdateTimer->IsActive()) fUpdateTimer->ResetTimer(); else fUpdateTimer->StartTimer(fOptions->ReakcioIdo); if (PointAt(TextLength()-1).y+50>fTarget->fNumView->Bounds().bottom) fTarget->fNumView->ResizeTo(fTarget->fNumView->Bounds().right,PointAt(TextLength()-1).y+50); } } if (oldtext) delete oldtext; if (newtext) delete newtext; // ScrollToSelection(); }
void CCellView::SelectCell(BPoint where) { cell curCell, anchorCell, oldCurCell, tmpCell, prevCurCell; BPoint cPoint; range r, prevSel; BRegion lastSelectionRgn, newSelectionRgn; bool updateBorders = (fSelection.top == 1 && fSelection.bottom == kRowCount) || (fSelection.left == 1 && fSelection.right == kColCount); BMessage * current = Window()->CurrentMessage(); int32 modifiers; FailOSErr(current->FindInt32("modifiers", &modifiers), errMessageMissing); prevSel = fSelection; prevCurCell = fCurCell; StClipCells clip(this); ClearAnts(); cPoint = where; (void)GetCellHitBy(cPoint, curCell); if (!fEntering) HiliteSelection(false, false); if (!fEntering && modifiers & B_SHIFT_KEY) { if (curCell.v < fSelection.top) anchorCell.v = fSelection.bottom; else anchorCell.v = fSelection.top; if (curCell.h < fSelection.left) anchorCell.h = fSelection.right; else anchorCell.h = fSelection.left; fSelection.Set(std::min(anchorCell.h, curCell.h), std::min(anchorCell.v, curCell.v), std::max(anchorCell.h, curCell.h), std::max(anchorCell.v, curCell.v)); } else { anchorCell.h = r.right = r.left = curCell.h; anchorCell.v = r.bottom = r.top = curCell.v; fCurCell = curCell; fSelection = r; } if (!fEntering) HiliteSelection(false, true); DrawStatus(); if (updateBorders) DrawBorders(); oldCurCell = curCell; ulong buttons; GetMouse(&cPoint, &buttons); while (buttons) { (void)GetCellHitBy(cPoint, curCell); SelectionToRegion(lastSelectionRgn); if (curCell.v == anchorCell.v) r.bottom = r.top = curCell.v; else if (curCell.v < anchorCell.v) { r.top = curCell.v; r.bottom = anchorCell.v; } else { r.bottom = curCell.v; r.top = anchorCell.v; } if (curCell.h == anchorCell.h) r.right = r.left = curCell.h; else if (curCell.h < anchorCell.h) { r.left = curCell.h; r.right = anchorCell.h; } else { r.right = curCell.h; r.left = anchorCell.h; } if (fEntering && ((oldCurCell.v != curCell.v) || (oldCurCell.h != curCell.h))) ClearAnts(); fSelection = r; SelectionToRegion(newSelectionRgn); if (!fEntering) ChangeSelection(&lastSelectionRgn, &newSelectionRgn); if (((fCurCell.v != fSelection.top) || (fCurCell.h != fSelection.left)) && !fEntering) ClearAnts(); fCurCell = fSelection.TopLeft(); if (oldCurCell.v != curCell.v || oldCurCell.h != curCell.h) { DrawStatus(); tmpCell = fCurCell; fCurCell = curCell; if (fEntering) fSelection = prevSel; AdjustScrollBars(); ScrollToSelection(); fSelection = r; fCurCell = tmpCell; } MarchAnts(); oldCurCell = curCell; GetMouse(&cPoint, &buttons); } if (fEntering) { ClearAnts(); fEditBox->EnterRange(fSelection); fSelection = prevSel; fCurCell = prevCurCell; } else fCurCell = fSelection.TopLeft(); AdjustScrollBars(); DrawStatus(); }
void CCellView::SelectCol(BPoint where, int colNr) { BPoint curPoint; cell oldAnts, curCurCell = fCurCell; range curSelection = fSelection, tmpSelection; long anchorCol, curCol, lastCol, y; float l, r; BRegion oldSel, newSel, oldClip; ulong modifiers = Window()->CurrentMessage()->FindInt32("modifiers"); curPoint = where; curCol = colNr; ClearAnts(); if (!fEntering && (modifiers & B_SHIFT_KEY)) { if (curCol > fSelection.right) anchorCol = fSelection.left; else anchorCol = fSelection.right; } else anchorCol = curCol; lastCol = curCol; if (!fEntering) SelectionToRegion(oldSel); if (anchorCol > curCol) fSelection.Set(curCol, 1, anchorCol, kRowCount); else fSelection.Set(anchorCol, 1, curCol, kRowCount); fCurCell = fSelection.TopLeft(); DrawStatus(); DrawBorders(); if (!fEntering) { SelectionToRegion(newSel); ChangeSelection(&oldSel, &newSel); } ulong buttons; GetMouse(&curPoint, &buttons); while (buttons) { oldAnts = fCurCell; cell c; GetCellHitBy(curPoint, c); curCol = std::max((int)c.h, 1); fCurCell.h = curCol; if (fEntering) { tmpSelection = fSelection; fSelection = curSelection; } ScrollToSelection(); if (fEntering) fSelection = tmpSelection; fCurCell = oldAnts; if (lastCol != curCol) { if (fEntering) ClearAnts(); else SelectionToRegion(oldSel); if (curCol > anchorCol) fSelection.Set(anchorCol, 1, curCol, kRowCount); else fSelection.Set(curCol, 1, anchorCol, kRowCount); // SetFontName("Emily"); // SetFontSize(12); if (lastCol > curCol) { r = lastCol; l = curCol; } else { r = curCol; l = lastCol; } for (y = static_cast<long>(l) ; y <= static_cast<long>(r) ; y++ ) { c.h = y; BRect r; char s[10]; GetCellRect(c, r); r.top = 1.0; r.bottom = fBorderHeight - 1.0; if (r.left != r.right) { NumToAString(y, s); FillRect3D(this, r, y >= fSelection.left && y <= fSelection.right, true, s); } } if (!fEntering) { SelectionToRegion(newSel); ChangeSelection(&oldSel, &newSel); } if (!fEntering && fCurCell.h != fSelection.left) ClearAnts(); fCurCell = fSelection.TopLeft(); DrawStatus(); } MarchAnts(); lastCol = curCol; GetMouse(&curPoint, &buttons); } if (fEntering) { fEditBox->EnterRange(fSelection); ClearAnts(); fSelection = curSelection; fCurCell = curCurCell; DrawStatus(); DrawBorders(); } }
void CCellView::SelectRow(BPoint where, int rowNr) { BPoint curPoint; cell oldAnts, curCurCell = fCurCell; range curSelection = fSelection, tmpSelection; long anchorRow, curRow, lastRow; float t, b; BRegion oldSel, newSel, oldClip; ulong modifiers = Window()->CurrentMessage()->FindInt32("modifiers"); curPoint = where; curRow = rowNr; ClearAnts(); if (!fEntering && (modifiers & B_SHIFT_KEY)) { if (curRow > fSelection.bottom) anchorRow = fSelection.top; else anchorRow = fSelection.bottom; } else anchorRow = curRow; lastRow = curRow; if (!fEntering) SelectionToRegion(oldSel); if (anchorRow > curRow) fSelection.Set(1, curRow, kColCount, anchorRow); else fSelection.Set(1, anchorRow, kColCount, curRow); fCurCell = fSelection.TopLeft(); DrawStatus(); DrawBorders(); if (!fEntering) { SelectionToRegion(newSel); ChangeSelection(&oldSel, &newSel); } ulong buttons; GetMouse(&curPoint, &buttons); while (buttons) { oldAnts = fCurCell; cell c; GetCellHitBy(curPoint, c); curRow = c.v; fCurCell.v = curRow; if (fEntering) { tmpSelection = fSelection; fSelection = curSelection; } ScrollToSelection(); if (fEntering) fSelection = tmpSelection; fCurCell = oldAnts; if (lastRow != curRow) { if (fEntering) ClearAnts(); else SelectionToRegion(oldSel); if (curRow > anchorRow) fSelection.Set(1, anchorRow, kColCount, curRow); else fSelection.Set(1, curRow, kColCount, anchorRow); // SetFontName("Emily"); // SetFontSize(12); if (lastRow > curRow) { b = lastRow; t = curRow; } else { b = curRow; t = lastRow; } for (long x = static_cast<long>(t) ; x <= static_cast<long>(b) ; x++ ) { BRect r; char s[10]; c.v = x; GetCellRect(c, r); r.left = 0.0; r.right = fBorderWidth - 1.0; if (r.top != r.bottom) { sprintf(s, "%d", x); FillRect3D(this, r, x >= fSelection.top && x <= fSelection.bottom, true, s); } } if (!fEntering) { SelectionToRegion(newSel); ChangeSelection(&oldSel, &newSel); } if (!fEntering && fCurCell.v != fSelection.top) ClearAnts(); fCurCell = fSelection.TopLeft(); DrawStatus(); } MarchAnts(); lastRow = curRow; GetMouse(&curPoint, &buttons); } if (fEntering) { fEditBox->EnterRange(fSelection); ClearAnts(); fSelection = curSelection; fCurCell = curCurCell; DrawStatus(); DrawBorders(); } } /* SelectRow */
void WrappingTextView::KeyDown(const char *bytes, int32 numBytes) { if (IsEditable() && numBytes==1) { m_last_key_was_del = (bytes[0]==B_DELETE); switch( bytes[0]) { case B_RIGHT_ARROW: { // implement word-wise movement: int32 mods = Window()->CurrentMessage()->FindInt32("modifiers"); if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) { int32 len=TextLength(); int32 startPos, endPos; GetSelection( &startPos, &endPos); if (endPos==len) break; if (startPos==endPos && (mods & B_SHIFT_KEY)) m_selection_start=B_RIGHT_ARROW; int32 wordStart, wordEnd; if (mods & B_SHIFT_KEY && m_selection_start==B_LEFT_ARROW) { do { FindWord( startPos, &wordStart, &wordEnd); if (wordEnd > wordStart+1) break; if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ') break; } while( ++startPos < len); Select( MIN(endPos, wordEnd), endPos); } else { do { FindWord( endPos, &wordStart, &wordEnd); if (wordEnd > wordStart+1) break; if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ') break; } while( ++endPos < len); if (mods & B_SHIFT_KEY) { Select( startPos, wordEnd); } else Select( wordEnd, wordEnd); } ScrollToSelection(); } else inherited::KeyDown( bytes, numBytes); break; } case B_LEFT_ARROW: { // implement word-wise movement: int32 mods = Window()->CurrentMessage()->FindInt32("modifiers"); if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) { int32 startPos, endPos; GetSelection( &startPos, &endPos); if (!startPos) break; if (startPos==endPos && (mods & B_SHIFT_KEY)) m_selection_start=B_LEFT_ARROW; int32 wordStart, wordEnd; if (mods & B_SHIFT_KEY && m_selection_start==B_RIGHT_ARROW) { --endPos; do { FindWord( endPos, &wordStart, &wordEnd); if (wordEnd > wordStart+1) break; if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ') break; } while( --endPos > 0); Select( startPos, MAX( startPos, wordStart)); } else { --startPos; do { FindWord( startPos, &wordStart, &wordEnd); if (wordEnd > wordStart+1) break; if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ') break; } while( --startPos > 0); if (mods & B_SHIFT_KEY) Select( wordStart, endPos); else Select( wordStart, wordStart); } ScrollToSelection(); } else inherited::KeyDown( bytes, numBytes); break; } default: inherited::KeyDown( bytes, numBytes); break; } } else if ( numBytes == 1 ) { // in read-only mode, we use cursor-keys to move scrollbar, and // we remap HOME / END to the vertical scrollbar (not the horizontal, // which is default). switch( bytes[0]) { case B_PAGE_UP: case B_PAGE_DOWN: case B_UP_ARROW: case B_DOWN_ARROW: case B_HOME: case B_END: { // move vertical scrollbar: float min, max, smallStep, bigStep, value; BScrollBar* bar = ScrollBar( B_VERTICAL); if (!bar) return; bar->GetRange( &min, &max); bar->GetSteps( &smallStep, &bigStep); value = bar->Value(); if (bytes[0] == B_UP_ARROW) { value = MAX( value-smallStep, min); } else if (bytes[0] == B_DOWN_ARROW) { value = MIN( value+smallStep, max); } else if (bytes[0] == B_PAGE_UP) { value = MAX( value-bigStep, min); } else if (bytes[0] == B_PAGE_DOWN) { value = MIN( value+bigStep, max); } else if (bytes[0] == B_HOME) { value = min; } else if (bytes[0] == B_END) { value = max; } bar->SetValue( value); break; } default: BTextView::KeyDown( bytes, numBytes); break; } } else inherited::KeyDown( bytes, numBytes); }
// LR 1.66 -- complete rewrite (basically) of this entire routine...it was UGLY! OSStatus HandleMenu( long mSelect, short modifiers ) { short menuID = HiWord( mSelect ); short menuItem = LoWord( mSelect ); short colorResID; WindowRef frontWindow; DialogPtr dlgRef = NULL; EditWindowPtr dWin = NULL; Str255 currentWindowName, newFrontWindowName; // NS: v1.6.6, for window menu WindowRef currentWindow; // NS: this too // Predetermine what type of window we have to work with frontWindow = FrontNonFloatingWindow(); if( frontWindow ) { DialogPtr dlg = GetDialogFromWindow( frontWindow ); if( kHexEditWindowTag == GetWindowKind( frontWindow ) ) dWin = (EditWindowPtr) GetWRefCon( frontWindow ); else if( g.gotoDlg == dlg || g.searchDlg == dlg ) dlgRef = dlg; } switch( menuID ) { case kAppleMenu: if( menuItem == AM_About ) HexEditAboutBox(); #if !TARGET_API_MAC_CARBON else { GrafPtr savePort; Str255 name; GetPort( &savePort ); GetMenuItemText( appleMenu, menuItem, name ); OpenDeskAcc( name ); SetPort( savePort ); } #endif break; case kFileMenu: switch( menuItem ) { case FM_New: gPrefs.overwrite = false; //LR 190 -- overwrite mode makes no sense in a new document NewEditWindow(); break; case FM_Open: AskEditWindow( kWindowNormal ); break; // HR/LR 050328 - Handle FM_Disassemble menu item case FM_Disassemble: g.disassemble = !g.disassemble; if ( g.disassemble ) { dWin->drawMode = DM_Disassembly; dWin->bytesPerLine = kDisBytesPerLine; dWin->hexStart = kDisHexStart; dWin->asciiStart = kDisASCIIStart; } else { dWin->drawMode = DM_Dump; dWin->bytesPerLine = kHexBytesPerLine; dWin->hexStart = kHexHexStart; dWin->asciiStart = kHexASCIIStart; } /* Make sure the editOffset position starts on a new line */ dWin->editOffset -= dWin->editOffset % dWin->bytesPerLine; UpdateEditWindows(); break; case FM_OtherFork: // LR: I want to see both! if( dWin ) { short fork; //LR 180 EditWindowPtr ewin; if( dWin->fork == FT_Data ) fork = FT_Resource; else fork = FT_Data; /*LR 180 -- OpenEditWindow checks for this if( NULL != (ewin = LocateEditWindow( &dWin->fsSpec, fork )) ) // LR: 1.7 - boolean typecast causes failure! { SelectWindow( ewin->oWin.theWin ); // just select existing theWin } else // try to open other fork in new theWin! */ { g.forkMode = fork; OpenEditWindow( &dWin->fsSpec, kWindowNormal, true ); } } break; case FM_CompareFiles: //LR 180 -- now pass in modifiers to allow select override if( GetCompareFiles( modifiers ) ) DoComparison(); break; //LR: 1.66 - NOTE: dWin == NULL == frontWindow! case FM_Save: if( dWin && dWin->oWin.Save ) dWin->oWin.Save( frontWindow ); break; case FM_SaveAs: if( dWin && dWin->oWin.SaveAs ) dWin->oWin.SaveAs( frontWindow ); break; case FM_Revert: if( dWin && dWin->oWin.Revert ) //LR 1.72 -- check before reverting (could be dangerous!) { ParamText( dWin->fsSpec.name, NULL, NULL, NULL ); switch( CautionAlert( alertRevert, NULL ) ) { case ok: dWin->oWin.Revert( frontWindow ); break; } } break; case FM_Close: if( dWin ) CloseEditWindow( frontWindow ); else if( dlgRef ) { HideWindow( frontWindow ); //LR: 1.7 -- no need.GetDialogWindow( dlgRef ) ); } break; case FM_Quit: if( CloseAllEditWindows() ) g.quitFlag = true; break; case FM_PageSetup: #if TARGET_API_MAC_CARBON // sel - carbon session based printing _doPageSetupDialog(&g.pageFormat); #else PrOpen(); PrStlDialog( g.HPrint ); PrClose(); #endif break; case FM_Print: if( dWin ) PrintWindow( dWin ); break; } break; case kEditMenu: #if !TARGET_API_MAC_CARBON if( !SystemEdit( menuItem -1 ) ) #endif { if( dWin ) switch( menuItem ) { case EM_Undo: UndoOperation(); break; case EM_Cut: CutSelection( dWin ); break; case EM_Copy: CopySelection( dWin ); break; case EM_Paste: PasteSelection( dWin ); break; case EM_Clear: ClearSelection( dWin ); break; case EM_SelectAll: dWin->startSel = 0; dWin->endSel = dWin->fileSize; UpdateOnscreen( dWin->oWin.theWin ); break; } else if( dlgRef ) switch( menuItem ) { case EM_Cut: DialogCut( dlgRef ); TEToScrap(); break; case EM_Copy: DialogCopy( dlgRef ); TEToScrap(); break; case EM_Paste: TEFromScrap(); DialogPaste( dlgRef ); break; case EM_Clear: DialogDelete( dlgRef ); break; case EM_SelectAll: break; } } break; case kFindMenu: switch ( menuItem ) { case SM_Find: openfind: OpenSearchDialog(); break; case SM_FindForward: gPrefs.searchForward = true; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window, if any (allows search in find dialog) break; case SM_FindBackward: gPrefs.searchForward = false; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window break; case SM_Replace: //LR 190 -- add replace & find next (must have a window with selection to start!) if( !dWin ) dWin = FindFirstEditWindow(); // allow this to work in find dialog, etc. if( dWin && dWin->startSel != dWin->endSel ) { EditChunk **replaceChunk; if( !g.searchBuffer[0] ) // if nothing to find open dialog goto openfind; replaceChunk = NewChunk( g.replaceText[0], 0, 0, CT_Unwritten ); if( replaceChunk ) { // Copy replacement text to chunk buffer BlockMoveData( g.replaceText+1, *(*replaceChunk)->data, g.replaceText[0] ); // Do the replacement (with undo) g.replaceAll = false; RememberOperation( dWin, EO_Paste, &gUndo ); PasteOperation( dWin, replaceChunk ); // We're done with the chunk now DisposeChunk( NULL, replaceChunk ); } // Then try to find the next occurance (in LAST direction searched!) and display it if( !PerformTextSearch( dWin, kSearchUpdateUI ) ) ScrollToSelection( dWin, dWin->startSel, true ); } break; case SM_GotoAddress: OpenGotoAddress(); break; } break; case kOptionsMenu: switch ( menuItem ) { case OM_HiAscii: gPrefs.asciiMode = !gPrefs.asciiMode; if( gPrefs.asciiMode ) g.highChar = 0xFF; else g.highChar = 0x7F; UpdateEditWindows(); break; case OM_DecimalAddr: gPrefs.decimalAddr = !gPrefs.decimalAddr; UpdateEditWindows(); break; case OM_Backups: gPrefs.backupFlag = !gPrefs.backupFlag; break; case OM_WinSize: gPrefs.constrainSize = !gPrefs.constrainSize; break; case OM_Overwrite: gPrefs.overwrite = !gPrefs.overwrite; break; case OM_NonDestructive: gPrefs.nonDestructive = !gPrefs.nonDestructive; break; case OM_MoveOnlyPaging: gPrefs.moveOnlyPaging = !gPrefs.moveOnlyPaging; break; case OM_Unformatted: gPrefs.formatCopies = !gPrefs.formatCopies; break; case OM_VertBars: gPrefs.vertBars = !gPrefs.vertBars; UpdateEditWindows(); break; case OM_ComparePref: // LR: compare options ComparisonPreferences(); break; case OM_OpenOnLaunch: gPrefs.dialogAtLaunch = !gPrefs.dialogAtLaunch; //LR -- 192 break; } break; // LR: Add color scheme menu case kColorMenu: colorResID = GetColorMenuResID( menuItem ); if( menuItem == CM_UseColor ) { gPrefs.useColor = !gPrefs.useColor; // toggle color usage } else if( dWin && dWin->csResID > 0 ) // can't color B&W windows! { if( _cmCheckedItem ) CheckMenuItem( colorMenu, _cmCheckedItem, false ); if( (modifiers & optionKey) ) // option down == change all windows (set default color) { EditWindowPtr eWin = FindFirstEditWindow(); while( eWin ) { if( GetWindowKind( eWin->oWin.theWin ) == kHexEditWindowTag ) { eWin->csResID = colorResID; eWin->csMenuID = menuItem; //LR 181 -- for menu tagging } eWin = FindNextEditWindow( eWin ); } goto savepref; } else //LR 181 -- default is (back) to changing color of a single window! { if( GetWindowKind( dWin->oWin.theWin ) == kHexEditWindowTag ) { dWin->csResID = colorResID; dWin->csMenuID = menuItem; //LR 181 -- for menu tagging } } } else { savepref: //LR 190 -- no window open == set preferred color gPrefs.csResID = colorResID; //LR 180 -- save prefs when changing all gPrefs.csMenuID = menuItem; } UpdateEditWindows(); break; // LR : 1.7 - rewrite with bug checking (could crash accessing NULL window) case kWindowMenu: GetMenuItemText( windowMenu, menuItem, newFrontWindowName ); currentWindow = FrontNonFloatingWindow(); while( currentWindow ) { GetWTitle( currentWindow, currentWindowName ); if( EqualPStrings( currentWindowName, newFrontWindowName ) ) { SelectWindow( currentWindow ); break; } currentWindow = GetNextWindow( currentWindow ); } break; } HiliteMenu( 0 ); AdjustMenus(); return( noErr ); }
boolean ClassEditor::HandleChar (char c) { boolean done = false; int lines = display->LineNumber(0) - display->LineNumber(ymax) + 1; int i; switch (c) { case FirstLine: BeginningOfText(); ScrollToSelection(); break; case LastLine: EndOfText(); ScrollToSelection(); break; case PrevLine: BackwardLine(); ScrollToSelection(); break; case NextLine: ForwardLine(); ScrollToSelection(); break; case PageDown: ForwardPage(); ScrollToSelection(); break; case PageUp: BackwardPage(1); ScrollToSelection(); break; case HalfPageDown: ForwardLine(lines/2); ScrollToSelection(); break; case HalfPageUp: BackwardLine(lines/2); ScrollToSelection(); break; case ScrollDown: ScrollBy(1); break; case ScrollUp: ScrollBy(-1); break; default: for (i = 0; _done[i] != '\0'; ++i) { if (c == _done[i]) { _state->SetValue(c); done = true; } } break; } return done; }
void BListView::KeyDown(const char* bytes, int32 numBytes) { bool extend = fListType == B_MULTIPLE_SELECTION_LIST && (modifiers() & B_SHIFT_KEY) != 0; if (fFirstSelected == -1 && (bytes[0] == B_UP_ARROW || bytes[0] == B_DOWN_ARROW)) { // nothing is selected yet, select the first enabled item int32 lastItem = CountItems() - 1; for (int32 i = 0; i <= lastItem; i++) { if (ItemAt(i)->IsEnabled()) { Select(i); break; } } return; } switch (bytes[0]) { case B_UP_ARROW: { if (fAnchorIndex > 0) { if (!extend || fAnchorIndex <= fFirstSelected) { for (int32 i = 1; fAnchorIndex - i >= 0; i++) { if (ItemAt(fAnchorIndex - i)->IsEnabled()) { // Select the previous enabled item Select(fAnchorIndex - i, extend); break; } } } else { Deselect(fAnchorIndex); do fAnchorIndex--; while (fAnchorIndex > 0 && !ItemAt(fAnchorIndex)->IsEnabled()); } } ScrollToSelection(); break; } case B_DOWN_ARROW: { int32 lastItem = CountItems() - 1; if (fAnchorIndex < lastItem) { if (!extend || fAnchorIndex >= fLastSelected) { for (int32 i = 1; fAnchorIndex + i <= lastItem; i++) { if (ItemAt(fAnchorIndex + i)->IsEnabled()) { // Select the next enabled item Select(fAnchorIndex + i, extend); break; } } } else { Deselect(fAnchorIndex); do fAnchorIndex++; while (fAnchorIndex < lastItem && !ItemAt(fAnchorIndex)->IsEnabled()); } } ScrollToSelection(); break; } case B_HOME: if (extend) { Select(0, fAnchorIndex, true); fAnchorIndex = 0; } else { // select the first enabled item int32 lastItem = CountItems() - 1; for (int32 i = 0; i <= lastItem; i++) { if (ItemAt(i)->IsEnabled()) { Select(i, false); break; } } } ScrollToSelection(); break; case B_END: if (extend) { Select(fAnchorIndex, CountItems() - 1, true); fAnchorIndex = CountItems() - 1; } else { // select the last enabled item for (int32 i = CountItems() - 1; i >= 0; i--) { if (ItemAt(i)->IsEnabled()) { Select(i, false); break; } } } ScrollToSelection(); break; case B_PAGE_UP: { BPoint scrollOffset(LeftTop()); scrollOffset.y = std::max(0.0f, scrollOffset.y - Bounds().Height()); ScrollTo(scrollOffset); break; } case B_PAGE_DOWN: { BPoint scrollOffset(LeftTop()); if (BListItem* item = LastItem()) { scrollOffset.y += Bounds().Height(); scrollOffset.y = std::min(item->Bottom() - Bounds().Height(), scrollOffset.y); } ScrollTo(scrollOffset); break; } case B_RETURN: case B_SPACE: Invoke(); break; default: BView::KeyDown(bytes, numBytes); } }
void TTimeTextView::KeyDown(const char *bytes, int32 numBytes) { char theChar = *bytes; // Check for a return or enter if (theChar == B_ENTER || theChar == B_RETURN || theChar == 'r') { // Deselect all Select(0,0); // Check integrity of last edited value CheckLastEdit(); MakeFocus(false); } // Accept numbers else if( isdigit(theChar) ) { /* short tmpNum; bool addIt = false; switch (m_CurrentCell) { case 1: if (inputNum[0] < 2 || inputNum[0] == 2 && theChar < '4') addIt = true; break; case 2: if (inputNum[1] < 6) addIt = true; break; case 3: if (inputNum[2] < 6) addIt = true; break; case 4: if (GetCurrentTimeFOrmat() == kMIDI && inputNum[3] < 10) addIt = true; else if (inputNum[3] < 2) addIt = true; else if (inputNum[3] == 2) { switch (GetCurrentTimeFormat()) { case kSMPTE24: if (theChar < '4') addIt = true; break; case kSMPTE25: if (theChar < '5') addIt = true; break; case kSMPTE2997: case kSMPTE30: addIt = true; break; } } break; } if (addIt) { inputNum[itsCurrentField - 1] *= 10; inputNum[itsCurrentField - 1] += theChar - '0'; //DrawEditField(); } */ BTextView::KeyDown(bytes, numBytes); } // Tab key moves us through the time elements else if( IsTab(theChar) || theChar == '.' ) { int16 lastCell = m_CurrentCell; // Deselect all Select(0,0); // Check integrity of last edited value CheckLastEdit(); // Check for shift key if ( IsShiftKeyDown() ) { // Select the previous cell m_CurrentCell--; if (m_CurrentCell <= 0) m_CurrentCell = 4; } else { // Select the next cell m_CurrentCell++; if (m_CurrentCell > 4) m_CurrentCell = 1; } switch (m_CurrentCell) { case 1: Select(0,2); ScrollToSelection(); break; case 2: Select(3,5); ScrollToSelection(); break; case 3: Select(6,8); ScrollToSelection(); break; case 4: Select(9,11); ScrollToSelection(); break; default: break; } } // Illegal character else beep(); }
void ScrolledListView::KeyDown(const char* bytes, int32 numBytes) { switch (bytes[0]) { case B_ENTER: case ' ': if (selection >= 0) OpenSelectedItem(selection); break; case B_UP_ARROW: int32 newSelection; if (selection < 0) newSelection = NumItems() - 1; else if (selection > 0) newSelection = selection - 1; else newSelection = selection; Select(newSelection); ScrollToSelection(); break; case B_DOWN_ARROW: if (selection < NumItems() - 1) Select(selection + 1); ScrollToSelection(); break; case B_PAGE_UP: { float itemHeight = ItemHeight(); float visibleHeight = Bounds().Height() + 1; ScrollBy(0, -(visibleHeight - itemHeight)); } break; case B_PAGE_DOWN: { float itemHeight = ItemHeight(); float visibleHeight = Bounds().Height() + 1; ScrollBy(0, visibleHeight - itemHeight); } break; case B_HOME: ScrollTo(0, 0); break; case B_END: { float visibleHeight = Bounds().Height(); ScrollTo(0, NumItems() * ItemHeight() - visibleHeight); } break; case B_BACKSPACE: case B_DELETE: if (selection >= 0) RemoveSelectedItem(selection); break; default: BView::KeyDown(bytes, numBytes); break; } }
// --------------------------------------------------------------------------- RHTML_Tag_Menu_List - KeyDown - void RHTMLTagMenuList::KeyDown(const char *bytes, int32 numBytes) { fTextView->Window()->Lock(); switch(bytes[0]) { case B_ESCAPE: // - ESC { fTagMenu->Stop(); } break; case '>': // - > { fTextView->Select(sel2,sel2); fTextView->Insert(">"); fTagMenu->Stop(); } break; case '=': // - = { fTextView->Select(sel2,sel2); fTextView->Insert("="); fTagMenu->Stop(); } break; case B_SPACE: // - SPACE { fTextView->Select(sel2,sel2); fTextView->Insert(" "); fTagMenu->Stop(); } break; case 0x08: // - BackSpace { if (str.Length()>0) { str.Truncate(str.Length()-1); fTextView->Delete(sel1,sel2); fTextView->Select(sel1,sel1); fTextView->Insert(str.String()); sel2=sel1+str.Length(); BString tmp = ""; if (str.Length()>1) str.CopyInto(tmp,1,str.Length()-1); fTagMenu->LoadList(tmp); } if (str.Length()==0) fTagMenu->Stop(); } break; case 0x1c: // - Left fTagMenu->Stop(); break; case 0x1d: // - Right fTagMenu->Stop(); break; case 0x1e: // - Up BListView::KeyDown(bytes,numBytes); break; case 0x1f: // - Down BListView::KeyDown(bytes,numBytes); break; case 0x01: // - Home BListView::KeyDown(bytes,numBytes); break; case 0x04: // - End BListView::KeyDown(bytes,numBytes); break; case 0x0b: // - PageUp { if (CurrentSelection()>13) Select(CurrentSelection()-13,false); else Select(0,false); ScrollToSelection(); } break; case 0x0c: // - PageDown { if (CurrentSelection()<CountItems()-14) Select(CurrentSelection()+13,false); else Select(CountItems()-1,false); ScrollToSelection(); } break; case B_ENTER: // - Enter { fTextView->Window()->Unlock(); fTagMenu->Put(); fTextView->Window()->Lock(); } break; default: // - Default { str+=bytes[0]; fTextView->Delete(sel1,sel2); fTextView->Select(sel1,sel1); fTextView->Insert(str.String()); sel2=sel1+str.Length(); BString tmp; str.CopyInto(tmp,1,str.Length()-1); fTagMenu->LoadList(tmp); } } fTextView->MessageReceived(new BMessage('UPPM')); fTextView->Window()->Unlock(); }
void BListView::KeyDown(const char* bytes, int32 numBytes) { bool extend = fListType == B_MULTIPLE_SELECTION_LIST && (modifiers() & B_SHIFT_KEY) != 0; switch (bytes[0]) { case B_UP_ARROW: { if (fFirstSelected == -1) { // if nothing is selected yet, always select the first item Select(0); } else { if (fAnchorIndex > 0) { if (!extend || fAnchorIndex <= fFirstSelected) Select(fAnchorIndex - 1, extend); else Deselect(fAnchorIndex--); } } ScrollToSelection(); break; } case B_DOWN_ARROW: { if (fFirstSelected == -1) { // if nothing is selected yet, always select the first item Select(0); } else { if (fAnchorIndex < CountItems() - 1) { if (!extend || fAnchorIndex >= fLastSelected) Select(fAnchorIndex + 1, extend); else Deselect(fAnchorIndex++); } } ScrollToSelection(); break; } case B_HOME: if (extend) { Select(0, fAnchorIndex, true); fAnchorIndex = 0; } else Select(0, false); ScrollToSelection(); break; case B_END: if (extend) { Select(fAnchorIndex, CountItems() - 1, true); fAnchorIndex = CountItems() - 1; } else Select(CountItems() - 1, false); ScrollToSelection(); break; case B_PAGE_UP: { BPoint scrollOffset(LeftTop()); scrollOffset.y = max_c(0, scrollOffset.y - Bounds().Height()); ScrollTo(scrollOffset); break; } case B_PAGE_DOWN: { BPoint scrollOffset(LeftTop()); if (BListItem* item = LastItem()) { scrollOffset.y += Bounds().Height(); scrollOffset.y = min_c(item->Bottom() - Bounds().Height(), scrollOffset.y); } ScrollTo(scrollOffset); break; } case B_RETURN: case B_SPACE: Invoke(); break; default: BView::KeyDown(bytes, numBytes); } }
void LanguageListView::AttachedToWindow() { BOutlineListView::AttachedToWindow(); ScrollToSelection(); }