void LineEdit::PlaceCaret0(Point p) { Size fsz = GetFontSize(); p -= sb; caretpos = Point(p.x * fsz.cx, p.y * fsz.cy); if(overwrite) SetCaret(caretpos.x, caretpos.y + fsz.cy - 2, fsz.cx, 2); else SetCaret(caretpos.x, caretpos.y, 2, fsz.cy); }
void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) { int32_t nHitIndex = GetItemIndex(point); if (IsMultipleSel()) { if (bCtrl) { if (m_bCtrlSel) m_aSelItems.Add(m_nFootIndex,nHitIndex); else m_aSelItems.Sub(m_nFootIndex,nHitIndex); SelectItems(); } else { m_aSelItems.DeselectAll(); m_aSelItems.Add(m_nFootIndex,nHitIndex); SelectItems(); } SetCaret(nHitIndex); } else { SetSingleSelect(nHitIndex); } if (!IsItemVisible(nHitIndex)) ScrollToListItem(nHitIndex); }
void CScrView::OnLButtonDown(UINT nFlags, CPoint point) { if (mouse_down_) return; // Happens sometimes while debugging // Keep control of the pointer until mouse button released mouse_down_ = TRUE; // Create timer so that we regularly call OnSelUpdate when the mouse is // stationery outside the window so that the window is automatically // scrolled (see OnTimer below for what the timer does). VERIFY(timer_id_ = SetTimer(1, 100, NULL)); // Hide caret while dragging. Plus: calling caret_hide here also means // that the caret is displayed in the correct position when caret_show // is called at the end of the drag (in OnLButtonUp below). caret_hide(); SetCapture(); if (shift_down()) { // Shift click restarts selection from where it left off (on button up) OnSelUpdate(point); } else { // Move caret to where selection started CPointAp newpos = ConvertFromDP(point); ValidateCaret(newpos, FALSE); SetCaret(newpos); } CView::OnLButtonDown(nFlags, point); }
void CFX_ListCtrl::OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl) { if (IsMultipleSel()) { if (nItemIndex >= 0 && nItemIndex < GetCount()) { if (bCtrl) { } else if (bShift) { m_aSelItems.DeselectAll(); m_aSelItems.Add(m_nFootIndex,nItemIndex); SelectItems(); } else { m_aSelItems.DeselectAll(); m_aSelItems.Add(nItemIndex); SelectItems(); m_nFootIndex = nItemIndex; } SetCaret(nItemIndex); } } else { SetSingleSelect(nItemIndex); } if (!IsItemVisible(nItemIndex)) ScrollToListItem(nItemIndex); }
void CPWL_Edit::OnKillFocus() { ShowVScrollBar(false); m_pEdit->SelectNone(); SetCaret(false, CFX_PointF(), CFX_PointF()); SetCharSet(FXFONT_ANSI_CHARSET); m_bFocus = false; }
RegRichTextCtrl::RegRichTextCtrl( wxWindow* parent ) : wxRichTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_NO_VSCROLL), m_sesId(-1) { SetCaret(0); SetCursor(wxCURSOR_ARROW); }
void DocEdit::PlaceCaret(bool scroll) { Point cr = GetCaret(cursor); int fy = font.Info().GetLineHeight(); if(scroll) { if(cursor == total) sb.End(); else sb.ScrollInto(cr.y, fy + 2); } SetCaret(cr.x + 1, cr.y - sb, 1, fy); WhenSel(); }
// moves the caret to the given index, selects it, and ensures it is visible. BOOL CQListCtrl::SetListPos( int index ) { if( index < 0 || index >= GetItemCount() ) return FALSE; RemoveAllSelection(); SetCaret(index); SetSelection(index); EnsureVisible(index,FALSE); return TRUE; }
void TextDocumentView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { if (!fSelectionEnabled) return; BCursor iBeamCursor(B_CURSOR_ID_I_BEAM); SetViewCursor(&iBeamCursor); if (fMouseDown) SetCaret(where, true); }
void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam) { CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); switch (msg) { case PNM_SETSCROLLINFO: switch (wParam) { case SBT_VSCROLL: if (CPWL_Wnd * pChild = GetVScrollBar()) { pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam); } break; } break; case PNM_SETSCROLLPOS: switch (wParam) { case SBT_VSCROLL: if (CPWL_Wnd * pChild = GetVScrollBar()) { pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam); } break; } break; case PNM_SCROLLWINDOW: { FX_FLOAT fPos = *(FX_FLOAT*)lParam; switch (wParam) { case SBT_VSCROLL: m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x,fPos)); break; } } break; case PNM_SETCARETINFO: { if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam) { SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot); } } break; } }
wxHexDataPanel::wxHexDataPanel(wxWindow* parent, size_t increment) : wxPanel(parent), m_startOffset(0), m_increment(increment), m_leftMargin(5), m_rightMargin(5), m_topMargin(5), m_bottomMargin(5), m_lineHeight(15) { m_data = new wxHexDataBuffer(); m_count = m_data->GetLength(); wxCaret *caret = new wxCaret(this, 10, 15); SetCaret(caret); caret->Move(20, 20); caret->Show(); }
wxLayoutWindow::wxLayoutWindow(wxWindow *parent) : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL | wxBORDER | wxWANTS_CHARS), m_llist(NULL) { #if wxUSE_STATUSBAR SetStatusBar(NULL); // don't use statusbar #endif // wxUSE_STATUSBAR m_Editable = false; m_doSendEvents = false; m_ViewStartX = 0; m_ViewStartY = 0; m_DoPopupMenu = true; m_PopupMenu = MakeFormatMenu(); m_memDC = new wxMemoryDC; m_bitmap = new wxBitmap(4,4); m_bitmapSize = wxPoint(4,4); m_llist = new wxLayoutList(); m_BGbitmap = NULL; m_ScrollToCursor = false; #ifndef __WXMSW__ m_FocusFollowMode = false; #endif SetWordWrap(false); SetWrapMargin(0); // no scrollbars initially m_hasHScrollbar = m_hasVScrollbar = false; m_Selecting = false; #ifdef WXLAYOUT_USE_CARET // FIXME cursor size shouldn't be hardcoded wxCaret *caret = new wxCaret(this, 2, 20); SetCaret(caret); m_llist->SetCaret(caret); #endif // WXLAYOUT_USE_CARET m_HaveFocus = false; m_HandCursor = false; m_CursorVisibility = -1; SetCursor(wxCURSOR_IBEAM); SetDirty(); // at least under Windows, this should be the default behaviour m_AutoDeleteSelection = true; }
void CPWL_Edit::OnKillFocus() { ShowVScrollBar(FALSE); m_pEdit->SelectNone(); SetCaret(FALSE, CPDF_Point(0.0f, 0.0f), CPDF_Point(0.0f, 0.0f)); SetCharSet(0); if (!IsReadOnly()) { if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) pFocusHandler->OnKillFocus(this); } m_bFocus = FALSE; }
// Define a constructor for my window //MyDiagramWindow::MyDiagramWindow(wxView *v, wxMDIChildFrame *frame, const wxPoint& pos, const wxSize& size, long style): // wxScrolledWindow(frame, wxID_ANY, pos, size, style) NassiDiagramWindow::NassiDiagramWindow(wxWindow *parent, NassiView *view): wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxWANTS_CHARS ), //dndpt(-1, -1), m_view(view), m_hd(0) { SetDropTarget( new NassiDropTarget(this, view) ); SetCursor(wxCursor(wxCURSOR_ARROW)); SetScrollRate(5, 5); wxClientDC dc(this); dc.SetFont(m_view->GetSourceFont()); SetCaret( new wxCaret(this, 10,10) );//1, dc.GetCharHeight() SetFocus(); }
void TextDocumentView::MouseDown(BPoint where) { if (!fSelectionEnabled) return; MakeFocus(); int32 modifiers = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("modifiers", &modifiers); fMouseDown = true; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); bool extendSelection = (modifiers & B_SHIFT_KEY) != 0; SetCaret(where, extendSelection); }
void CFX_ListCtrl::OnMouseDown(const CFX_PointF& point, bool bShift, bool bCtrl) { int32_t nHitIndex = GetItemIndex(point); if (IsMultipleSel()) { if (bCtrl) { if (IsItemSelected(nHitIndex)) { m_aSelItems.Sub(nHitIndex); SelectItems(); m_bCtrlSel = false; } else { m_aSelItems.Add(nHitIndex); SelectItems(); m_bCtrlSel = true; } m_nFootIndex = nHitIndex; } else if (bShift) { m_aSelItems.DeselectAll(); m_aSelItems.Add(m_nFootIndex, nHitIndex); SelectItems(); } else { m_aSelItems.DeselectAll(); m_aSelItems.Add(nHitIndex); SelectItems(); m_nFootIndex = nHitIndex; } SetCaret(nHitIndex); } else { SetSingleSelect(nHitIndex); } if (!IsItemVisible(nHitIndex)) ScrollToListItem(nHitIndex); }
void Printer::ResetCaret( void ) { SetCaret(x_margin, y_margin); }
KbdFocusCaret() { Sizeable().Zoomable(); SetCaret(60, 60, 10, 10); }
// Responds to a cursor movement key to move the current caret position (if // the caret is being displayed) or the current scroll position. BOOL CScrView::MovePos(UINT nChar, UINT nRepCnt, BOOL control_down, BOOL shift_down, BOOL caret_on) { CPointAp newpos; // Get current position (if no caret then keys just do scrolling) if (!caret_on) newpos = scrollpos_; else if (shift_down && basepos_ == caretpos_) newpos = selpos_; else if (shift_down && basepos_ == selpos_) newpos = caretpos_; else if (nChar == VK_LEFT || nChar == VK_UP || nChar == VK_HOME || nChar == VK_PRIOR) newpos = caretpos_; else newpos = selpos_; // Calculate new position switch (nChar) { case VK_LEFT: if (!control_down) newpos.x -= line_.cx * nRepCnt; break; case VK_RIGHT: if (!control_down) newpos.x += line_.cx * nRepCnt; break; case VK_UP: if (!control_down) newpos.y -= line_.cy * nRepCnt; break; case VK_DOWN: if (!control_down) newpos.y += line_.cy * nRepCnt; break; case VK_HOME: if (!control_down) newpos.x = 0; else { newpos.x = 0; newpos.y = 0; } break; case VK_END: if (!control_down) { if (caret_on) newpos.x = total_.cx; else newpos.x = total_.cx - win_width_; } else { newpos.x = 0; if (caret_on) newpos.y = total_.cy; else newpos.y = total_.cy - win_height_; } break; case VK_PRIOR: if (!control_down) newpos.y -= page_.cy * nRepCnt; break; case VK_NEXT: if (!control_down) newpos.y += page_.cy * nRepCnt; break; } // Move to new position if (caret_on && shift_down) { // Using shifted cursor keys just extends the current selection OnSelUpdate(ConvertToDP(newpos)); } else if (caret_on) { if (newpos == caretpos_ && caretpos_ == selpos_) return FALSE; // Key not handled/had no effect SetCaret(newpos); } else { if (newpos == scrollpos_) return FALSE; // Key not handled/had no effect SetScroll(newpos); } return TRUE; // Indicate that keystroke used }