void wxFlatNotebook::SetSelection(size_t page) { int curSel = GetSelection(); if(curSel == (int)page) { return; } DoSetSelection(page); }
void wxTextCtrl::Replace(long from, long to, const wxString& value) { // Set selection and remove it DoSetSelection(from, to, false); DoWriteText(value, SetValue_SelectionOnly); }
void wxListBoxBase::SetSelection(int n) { if ( !HasMultipleSelection() ) DoChangeSingleSelection(n); DoSetSelection(n, true); }
void wxTreebook::DoInternalAddPage(size_t newPos, wxTreebookPage *page, wxTreeItemId pageId) { wxASSERT_MSG( newPos <= m_treeIds.GetCount(), wxT("Ivalid index passed to wxTreebook::DoInternalAddPage") ); // hide newly inserted page initially (it will be shown when selected) if ( page ) page->Hide(); if ( newPos == m_treeIds.GetCount() ) { // append m_treeIds.Add(pageId); } else // insert { m_treeIds.Insert(pageId, newPos); if ( m_selection != wxNOT_FOUND && newPos <= (size_t)m_selection ) { // selection has been moved one unit toward the end ++m_selection; if ( m_actualSelection != wxNOT_FOUND ) ++m_actualSelection; } else if ( m_actualSelection != wxNOT_FOUND && newPos <= (size_t)m_actualSelection ) { DoSetSelection(m_selection); } } }
// wxTextCtrl::Remove is somewhat slow, this is a faster version virtual void Remove(long from, long to) { DoSetSelection(from, to, false); m_updatesCount = -2; // suppress any update event ::SendMessage((HWND)GetHandle(), EM_REPLACESEL, 0, (LPARAM)_T("")); }
void wxTextEntry::SetInsertionPoint(long pos) { // calling DoSetSelection(-1, -1) would select everything which is not what // we want here if ( pos == -1 ) pos = GetLastPosition(); // be careful to call DoSetSelection() which is overridden in wxTextCtrl // and not just SetSelection() here DoSetSelection(pos, pos); }
void wxTextCtrl::SetSelection(long from, long to) { // if from and to are both -1, it means (in wxWidgets) that all text should // be selected - translate into Windows convention if ( (from == -1) && (to == -1) ) { from = 0; to = -1; } DoSetSelection(from, to); }
void wxFlatNotebook::SetWindowStyleFlag(long style) { wxPanel::SetWindowStyleFlag(style); if(m_pages) { // For changing the tab position (i.e. placing them top/bottom) // refreshing the tab container is not enough m_sendPageChangeEvent = false; DoSetSelection(m_pages->m_iActivePage); m_sendPageChangeEvent = true; } }
void wxPageContainer::MoveTabPage(int nMove, int nMoveTo) { if(nMove == nMoveTo) return; else if(nMoveTo < (int)((wxFlatNotebook *)m_pParent)->GetWindows().GetCount()) nMoveTo++; m_pParent->Freeze(); // Remove the window from the main sizer int nCurSel = ((wxFlatNotebook *)m_pParent)->GetPages()->GetSelection(); ((wxFlatNotebook *)m_pParent)->GetMainSizer()->Detach(((wxFlatNotebook *)m_pParent)->GetWindows().Item(nCurSel)); ((wxFlatNotebook *)m_pParent)->GetWindows().Item(nCurSel)->Hide(); wxWindow *pWindow = ((wxFlatNotebook *)m_pParent)->GetWindows().Item(nMove); ((wxFlatNotebook *)m_pParent)->GetWindows().RemoveAt(nMove); ((wxFlatNotebook *)m_pParent)->GetWindows().Insert(pWindow, nMoveTo-1); wxPageInfo pgInfo = m_pagesInfoVec[nMove]; m_pagesInfoVec.RemoveAt( nMove ); m_pagesInfoVec.Insert(pgInfo, nMoveTo - 1); // Add the page according to the style wxBoxSizer* pSizer = ((wxFlatNotebook *)m_pParent)->GetMainSizer(); long style = GetParent()->GetWindowStyleFlag(); if(style & wxFNB_BOTTOM) { pSizer->Insert(0, pWindow, 1, wxEXPAND); } else { // We leave a space of 1 pixel around the window pSizer->Add(pWindow, 1, wxEXPAND); } pWindow->Show(); pSizer->Layout(); m_iActivePage = nMoveTo-1; m_iPreviousActivePage = -1; DoSetSelection(m_iActivePage); // Refresh(); m_pParent->Thaw(); }
void wxFlatNotebook::OnNavigationKey(wxNavigationKeyEvent& event) { if ( event.IsWindowChange() ) { if( HasFlag(wxFNB_SMART_TABS) ) { if( !m_popupWin && GetPageCount() > 0) { m_popupWin = new wxTabNavigatorWindow( this ); m_popupWin->ShowModal(); m_popupWin->Destroy(); DoSetSelection((size_t)GetSelection()); m_popupWin = NULL; } else if( m_popupWin ) { // a dialog is already opened m_popupWin->OnNavigationKey( event ); return; } } else { // change pages AdvanceSelection(event.GetDirection()); } } else { // pass to the parent if ( GetParent() ) { event.SetCurrentFocus(this); GetParent()->ProcessEvent(event); } } }
void wxTextCtrl::SetInsertionPoint(long pos) { DoSetSelection(pos, pos); }
void wxPageContainer::SetSelection(size_t page) { wxFlatNotebook* book = (wxFlatNotebook*)GetParent(); book->SetSelection(page); DoSetSelection(page); }
void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount) { // Attention: this function is only for a situation when we delete a node // with all its children so pagePos is the node's index and subCount is the // node children count wxASSERT_MSG( pagePos + subCount < m_treeIds.GetCount(), wxT("Ivalid page index") ); wxTreeItemId pageId = m_treeIds[pagePos]; m_treeIds.RemoveAt(pagePos, subCount + 1); if ( m_selection != wxNOT_FOUND ) { if ( (size_t)m_selection > pagePos + subCount) { // selection is far after the deleted page, so just update the index and move on m_selection -= 1 + subCount; if ( m_actualSelection != wxNOT_FOUND) { m_actualSelection -= subCount + 1; } } else if ( (size_t)m_selection >= pagePos ) { wxTreeCtrl *tree = GetTreeCtrl(); // as selected page is going to be deleted, try to select the next // sibling if exists, if not then the parent wxTreeItemId nodeId = tree->GetNextSibling(pageId); m_selection = wxNOT_FOUND; m_actualSelection = wxNOT_FOUND; if ( nodeId.IsOk() ) { // selecting next siblings tree->SelectItem(nodeId); } else // no next sibling, select the parent { wxTreeItemId parentId = tree->GetItemParent(pageId); if ( parentId.IsOk() && parentId != tree->GetRootItem() ) { tree->SelectItem(parentId); } else // parent is root { // we can't select it as it's hidden DoUpdateSelection(false, wxNOT_FOUND); } } } else if ( m_actualSelection != wxNOT_FOUND && (size_t)m_actualSelection >= pagePos ) { // nothing to do -- selection is before the deleted node, but // actually shown page (the first (sub)child with page != NULL) is // already deleted m_actualSelection = m_selection; // send event as documented DoSetSelection(m_selection, SetSelection_SendEvent); } //else: nothing to do -- selection is before the deleted node } else { DoUpdateSelection(false, wxNOT_FOUND); } }
void wxTextEntry::Remove(long from, long to) { DoSetSelection(from, to, SetSel_NoScroll); WriteText(wxString()); }
void wxTextEntry::SetInsertionPoint(long pos) { // be careful to call DoSetSelection() which is overridden in wxTextCtrl // and not just SetSelection() here DoSetSelection(pos, pos); }