void cbAuiNotebook::AdvanceSelection(bool forward) { if (GetPageCount() <= 1) return; int currentSelection = GetSelection(); wxAuiTabCtrl* tabCtrl = nullptr; int idx = -1; if (!FindTab(GetPage(currentSelection), &tabCtrl, &idx)) return; if (!tabCtrl || idx < 0) return; wxWindow* page = nullptr; size_t maxPages = tabCtrl->GetPageCount(); forward?idx++:idx--; if (idx < 0) idx = maxPages - 1; if ((size_t)idx < maxPages) page = tabCtrl->GetPage(idx).window; if (!page && maxPages > 0) page = tabCtrl->GetPage(0).window; if (page) { currentSelection = GetPageIndex(page); SetSelection(currentSelection); } }
bool wxNotebook::InsertPage(size_t n, wxWindow *page, const wxString& text, bool bSelect, int imageId) { // disable firing qt signals until wx structures are filled m_qtTabWidget->blockSignals(true); if (imageId != -1) { if (HasImageList()) { const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); m_qtTabWidget->insertTab( n, page->GetHandle(), QIcon( *bitmap->GetHandle() ), wxQtConvertString( text )); } else { wxFAIL_MSG("invalid notebook imagelist"); } } else { m_qtTabWidget->insertTab( n, page->GetHandle(), wxQtConvertString( text )); } m_pages.Insert(page, n); m_images.insert(m_images.begin() + n, imageId); // reenable firing qt signals as internal wx initialization was completed m_qtTabWidget->blockSignals(false); if (bSelect && GetPageCount() > 1) { SetSelection( n ); } return true; }
bool CMuleNotebook::DeletePage(int nPage) { wxCHECK_MSG((nPage >= 0) && (nPage < (int)GetPageCount()), false, wxT("Trying to delete invalid page-index in CMuleNotebook::DeletePage")); // Send out close event wxNotebookEvent evt( wxEVT_COMMAND_MULENOTEBOOK_PAGE_CLOSING, GetId(), nPage ); evt.SetEventObject(this); ProcessEvent( evt ); // and finally remove the actual page bool result = wxNotebook::DeletePage( nPage ); // Ensure a valid selection if ( GetPageCount() && (int)GetSelection() >= (int)GetPageCount() ) { SetSelection( GetPageCount() - 1 ); } // Send a page change event to work around wx problem when newly selected page // is identical with deleted page (wx sends a page change event during deletion, // but the control is still the one to be deleted at that moment). if (GetPageCount()) { // Select the tab that took the place of the one we just deleted. size_t page = nPage; // Except if we deleted the last one - then select the one that is last now. if (page == GetPageCount()) { page--; } wxNotebookEvent event( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, GetId(), page ); event.SetEventObject(this); ProcessEvent( event ); } else { // Send an event when no pages are left open wxNotebookEvent event( wxEVT_COMMAND_MULENOTEBOOK_ALL_PAGES_CLOSED, GetId() ); event.SetEventObject(this); ProcessEvent( event ); } return result; }
void wxSTEditorNotebook::SortTabs(int style) { if ((int)GetPageCount() < 2) return; if (STE_HASBIT(style, STN_ALPHABETICAL_TABS)) { int sel = GetSelection(); int new_sel = sel; size_t page_count = GetPageCount(); size_t n; if (page_count < 2) return; wxString curPageName; wxArrayString names; for (n = 0; n < page_count; n++) { wxString name(GetPageText(n)); if ((name.Length() > 0) && (name[0u] == wxT('*'))) name = name.Mid(1); names.Add(name + wxString::Format(wxT("=%d"), (int)n)); } names.Sort(STN_SortNameCompareFunction); bool sel_changed = false; for (n = 0; n < page_count; n++) { long old_page = 0; names[n].AfterLast(wxT('=')).ToLong(&old_page); if (old_page != long(n)) { wxWindow *oldWin = GetPage(old_page); wxString oldName(GetPageText(old_page)); if (oldWin && RemovePage(old_page)) { sel_changed = true; if (old_page == sel) new_sel = (int)n; if (n < page_count - 1) InsertPage((int)(n+1), oldWin, oldName, old_page == sel); else AddPage(oldWin, oldName, old_page == sel); } } } if (sel_changed) { wxNotebookEvent noteEvent(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, GetId(), new_sel, new_sel); noteEvent.SetString(wxT("wxSTEditorNotebook Page Change")); noteEvent.SetExtraLong(new_sel); // FIXME no Clone in wxNotebookEvent // NOTE: this may have to be AddPendingEvent for wx < 2.7 since gtk // can become reentrant GetEventHandler()->AddPendingEvent(noteEvent); } // causes reentrant assert in gtk, even though it's necessary sometimes //SetSelection(new_sel); // force selection for GTK } }
BOOL CTPropertySheet::OnInitDialog() { // TRACE("CTPropertySheet::OnInitDialog()\n"); /* // DR00169 2.001 removed hardcoding from 2.000 NOTE: For MICGM, m_bSameNextFinish is always true. MIC 1.9.0.7 set it false when creating a WATCH window; MICGM uses a different mechanism for creating a WATCH window that doesn't use the wizard functionality. PJM May 18, 2005 */ BOOL bResult = CPropertySheet::OnInitDialog(); SetTimer(1,1000,NULL); char temp[32]; WINDOWPLACEMENT lpwndpl; //grow the property sheet GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 27; // DR00169 2.001 removed hardcoding from 2.000 SetWindowPlacement(&lpwndpl); //we do want the cancel action GetDlgItem(IDCANCEL)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; // DR00169 2.001 removed hardcoding from 2.000 GetDlgItem(IDCANCEL)->SetWindowPlacement(&lpwndpl); int minutes = (m_dMyDlgClose/1000-m_dToClose)/60; int seconds = (m_dMyDlgClose/1000-m_dToClose) % 60; sprintf(temp,"Extend Auto\nClose: %d:%02d",minutes,seconds); SetDlgItemText(IDHELP,temp); GetDlgItem(IDHELP)->ModifyStyle(NULL,BS_MULTILINE); GetDlgItem(IDHELP)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; // DR00169 2.001 removed hardcoding from 2.000 GetDlgItem(IDHELP)->SetWindowPlacement(&lpwndpl); GetDlgItem(IDHELP)->SetDlgCtrlID(IDB_TOCLOSE); if (m_bSameNextFinish) { GetDlgItem(ID_WIZNEXT)->GetWindowPlacement(&lpwndpl); int offset = lpwndpl.rcNormalPosition.right-lpwndpl.rcNormalPosition.left; lpwndpl.rcNormalPosition.bottom += 28; lpwndpl.rcNormalPosition.left -= offset; lpwndpl.rcNormalPosition.right -= offset; // DR00169 2.001 removed hardcoding from 2.000 GetDlgItem(ID_WIZNEXT)->SetWindowPlacement(&lpwndpl); GetDlgItem(ID_WIZBACK)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; lpwndpl.rcNormalPosition.left -= offset; lpwndpl.rcNormalPosition.right -= offset; // DR00169 2.001 removed hardcoding from 2.000 GetDlgItem(ID_WIZBACK)->SetWindowPlacement(&lpwndpl); GetDlgItem(ID_WIZFINISH)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; // DR00169 2.001 removed hardcoding from 2.000 GetDlgItem(ID_WIZFINISH)->SetWindowPlacement(&lpwndpl); // GetDlgItem(ID_WIZFINISH)->EnableWindow(false); } else { GetDlgItem(ID_WIZNEXT)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; GetDlgItem(ID_WIZNEXT)->SetWindowPlacement(&lpwndpl); GetDlgItem(ID_WIZBACK)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; GetDlgItem(ID_WIZBACK)->SetWindowPlacement(&lpwndpl); GetDlgItem(ID_WIZFINISH)->GetWindowPlacement(&lpwndpl); lpwndpl.rcNormalPosition.bottom += 28; GetDlgItem(ID_WIZFINISH)->SetWindowPlacement(&lpwndpl); // GetDlgItem(ID_WIZFINISH)->EnableWindow(false); } for (int i = GetPageCount();i>=0;i--) SetActivePage(i-1); m_dToClose = 0; return bResult; }
bool wxNotebook::InsertPage( size_t position, wxNotebookPage* win, const wxString& text, bool select, int imageId ) { wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") ); wxCHECK_MSG( win->GetParent() == this, false, wxT("Can't add a page whose parent is not the notebook!") ); wxCHECK_MSG( position <= GetPageCount(), false, wxT("invalid page index in wxNotebookPage::InsertPage()") ); // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK // why this has to be done. gtk_widget_unparent(win->m_widget); if (m_themeEnabled) win->SetThemeEnabled(true); GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); wxGtkNotebookPage* pageData = new wxGtkNotebookPage; m_pages.Insert(win, position); m_pagesData.Insert(position, pageData); // set the label image and text // this must be done before adding the page, as GetPageText // and GetPageImage will otherwise return wrong values in // the page-changed event that results from inserting the // first page. pageData->m_imageIndex = imageId; pageData->m_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2); pageData->m_image = NULL; if (imageId != -1) { if (HasImageList()) { const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf()); gtk_box_pack_start(GTK_BOX(pageData->m_box), pageData->m_image, false, false, m_padding); } else { wxFAIL_MSG("invalid notebook imagelist"); } } /* set the label text */ pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text))); gtk_box_pack_end(GTK_BOX(pageData->m_box), pageData->m_label, false, false, m_padding); gtk_widget_show_all(pageData->m_box); gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position); /* apply current style */ #ifdef __WXGTK3__ GTKApplyStyle(pageData->m_label, NULL); #else GtkRcStyle *style = GTKCreateWidgetStyle(); if ( style ) { gtk_widget_modify_style(pageData->m_label, style); g_object_unref(style); } #endif if (select && GetPageCount() > 1) { SetSelection( position ); } InvalidateBestSize(); return true; }
void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style) { GTKApplyStyle(m_widget, style); for (size_t i = GetPageCount(); i--;) GTKApplyStyle(GetNotebookPage(i)->m_label, style); }
BOOL COXTabViewContainer::InsertPage(int nIndex, CRuntimeClass* pClass, CCreateContext* pContext, LPCTSTR lpszTitle/*=NULL*/) { ASSERT_VALID(this); ASSERT(nIndex>=0 && nIndex<=GetPageCount()); ASSERT(pClass!=NULL); ASSERT(pClass->IsDerivedFrom(RUNTIME_CLASS(CWnd))); ASSERT(AfxIsValidAddress(pClass,sizeof(CRuntimeClass),FALSE)); if(!(nIndex>=0 && nIndex<=GetPageCount()) || pClass==NULL) return FALSE; CCreateContext context; if(pContext==NULL) { // if no context specified, generate one from the currently active // view if possible CView* pOldView=(CView*)GetActivePage(); if(pOldView!=NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView))) { // set info about last pane ASSERT(context.m_pCurrentFrame==NULL); context.m_pLastView=pOldView; context.m_pCurrentDoc=pOldView->GetDocument(); if(context.m_pCurrentDoc!=NULL) { context.m_pNewDocTemplate=context.m_pCurrentDoc-> GetDocTemplate(); } } pContext=&context; } CWnd* pWnd; TRY { pWnd=(CWnd*)pClass->CreateObject(); if(pWnd==NULL) AfxThrowMemoryException(); } CATCH_ALL(e) { TRACE(_T("COXTabViewContainer::InsertPage: Out of memory inserting new page\n")); // Note: DELETE_EXCEPTION(e) not required return FALSE; } END_CATCH_ALL ASSERT_KINDOF(CWnd,pWnd); ASSERT(pWnd->m_hWnd==NULL); // not yet created DWORD dwStyle=AFX_WS_DEFAULT_VIEW; #if _MFC_VER < 0x0700 if(afxData.bWin4) #endif dwStyle&=~WS_BORDER; DWORD dwID=GetUniqueId(); // Create with the right size if(!pWnd->Create(NULL,NULL,dwStyle,m_rectPage,this,dwID,pContext)) { TRACE(_T("COXTabViewContainer::InsertPage: couldn't create new page\n")); // pWnd will be cleaned up by PostNcDestroy return FALSE; } if(InsertPage(nIndex,pWnd,lpszTitle)) { CWnd* pWnd=GetPage(nIndex); ASSERT(pWnd!=NULL); ASSERT(::IsWindow(pWnd->m_hWnd)); if(pWnd->IsKindOf(RUNTIME_CLASS(CView))) { // send initial notification message pWnd->SendMessage(WM_INITIALUPDATE); } return TRUE; } return FALSE; }
BOOL CXTPResizePropertySheet::OnInitDialog() { CRect rcClientBegin, rcClientEnd; GetWindowRect(rcClientBegin); SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientBegin); // Modify the window style to include WS_THICKFRAME for resizing. ::SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | WS_THICKFRAME); GetWindowRect(rcClientEnd); SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientEnd); CPropertySheet::OnInitDialog(); // subclass our "flicker-free" tab control. m_tabCtrl.SubclassWindow(GetTabControl()->m_hWnd); // the size icon is too close to the buttons, so inflate the sheet CRect rc; GetWindowRect(rc); if (rcClientBegin.Width() - rcClientEnd.Width() > 3) { rc.InflateRect((rcClientBegin.Width() - rcClientEnd.Width()) / 2, (rcClientBegin.Height() - rcClientEnd.Height()) / 2); MoveWindow(rc); } // Do this last so that any prop pages are moved accordingly else if (!HasFlag(xtpResizeNoSizeIcon) && !IsWizard()) { rc.InflateRect(1, 1, 2, 2); MoveWindow(rc); } // add sizing entries to the system menu CMenu* pSysMenu = (CMenu*)GetSystemMenu(FALSE); if (pSysMenu) { CString szMaximize, szMinimize, szSize, szRestore; // try to get the strings from the topmost window CWnd* pwndTop; for (pwndTop = this; pwndTop->GetParent(); pwndTop = pwndTop->GetParent()); CMenu* pTopSysMenu = (CMenu*)pwndTop->GetSystemMenu(FALSE); if (pTopSysMenu) { pTopSysMenu->GetMenuString(SC_MAXIMIZE, szMaximize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_MINIMIZE, szMinimize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_SIZE, szSize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_RESTORE, szRestore, MF_BYCOMMAND); } // if we din't get the strings then set them to the English defaults if (szMaximize.IsEmpty()) szMaximize = _T("Ma&ximize"); if (szMinimize.IsEmpty()) szMinimize = _T("Mi&nimize"); if (szSize.IsEmpty()) szSize = _T("&Size"); if (szRestore.IsEmpty()) szRestore = _T("&Restore"); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_SEPARATOR, 0, (LPCTSTR) 0); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MAXIMIZE, szMaximize); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MINIMIZE, szMinimize); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_SIZE, szSize); pSysMenu->InsertMenu(0, MF_BYPOSITION | MF_STRING, SC_RESTORE, szRestore); } DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE); if ((dwStyle & WS_THICKFRAME) == 0) { SetFlag(xtpResizeNoSizeIcon); } CXTPResize::Init(); // Check which buttons are available in sheet or wizard if (IsWizard()) { SetResize(ID_WIZBACK, XTP_ATTR_REPOS(1)); SetResize(ID_WIZNEXT, XTP_ATTR_REPOS(1)); SetResize(ID_WIZFINISH, XTP_ATTR_REPOS(1)); SetResize(ID_WIZLINE, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMRIGHT); } else { SetResize(IDOK, XTP_ATTR_REPOS(1)); SetResize(ID_APPLY_NOW, XTP_ATTR_REPOS(1)); SetResize(AFX_IDC_TAB_CONTROL, XTP_ATTR_RESIZE(1)); } SetResize(IDCANCEL, XTP_ATTR_REPOS(1)); SetResize(IDHELP, XTP_ATTR_REPOS(1)); // set page sizings CRect rcPage; GetActivePage()->GetWindowRect(rcPage); ScreenToClient(rcPage); int i; for (i = 0; i <GetPageCount(); i++) { SetResize(GetPage(i), XTP_ATTR_RESIZE(1), rcPage); } return TRUE; }
BOOL COXCustomizeManager::InsertPage(COXCustomizePage* pCustomizePage, int nPageIndex) { ASSERT(pCustomizePage!=NULL); CString sTitle=pCustomizePage->GetTitle(); LPCTSTR lpszImageResource=pCustomizePage->GetImageResource(); COLORREF clrMask=pCustomizePage->GetImageMask(); CString sTooltip=pCustomizePage->GetTooltip(); CString sGroup=pCustomizePage->GetGroup(); #ifdef _DEBUG ASSERT(nPageIndex>=0 && nPageIndex<=GetPageCount(sGroup)); HSHBGROUP hGroupTest=NULL; int nIndexTest=-1; ASSERT(!FindPage(pCustomizePage,hGroupTest,nIndexTest)); ASSERT(!FindPage(sTitle,sGroup,hGroupTest,nIndexTest)); #endif // find/create the corresponding shortcut bar group HSHBGROUP hGroup=m_shb.FindGroupByTitle(sGroup); BOOL bNewGroup=FALSE; if(hGroup==NULL) { hGroup=m_shb.InsertGroup(sGroup); bNewGroup=TRUE; } if(hGroup==NULL) { TRACE(_T("COXCustomizeManager::InsertPage: failed to create group for the specified page\n")); if(bNewGroup) m_shb.DeleteGroup(hGroup); return FALSE; } // associate image list with the created group m_shb.SetLCImageList(hGroup,&m_ilShortcutBar,LVSIL_NORMAL); // get image index for new page int nImageIndex=-1; if(lpszImageResource!=NULL) { CImageList imageList; if(!imageList.Create(lpszImageResource,32,0,clrMask)) { TRACE(_T("COXCustomizeManager::InsertPage: failed to extract image for new page\n")); if(bNewGroup) { m_shb.DeleteGroup(hGroup); } return FALSE; } HICON hIcon=imageList.ExtractIcon(0); ASSERT(hIcon!=NULL); nImageIndex=m_ilShortcutBar.Add(hIcon); ASSERT(nImageIndex!=-1); VERIFY(::DestroyIcon(hIcon)); } int nItem=m_shb.InsertLCItem(hGroup,nPageIndex,sTitle,nImageIndex, (LPARAM)pCustomizePage); if(nItem==-1) { TRACE(_T("COXCustomizeManager::InsertPage: failed to insert new item into the shortcut bar\n")); if(bNewGroup) { m_shb.DeleteGroup(hGroup); } return FALSE; } m_mapPages.SetAt(pCustomizePage,((PtrToLong(hGroup))<<16)+nItem); m_mapTooltips.SetAt(pCustomizePage,sTooltip); return TRUE; }
void COXTabViewContainer::DrawTabButton(CDC* pDC, int nIndex) const { ASSERT(nIndex>=0 && nIndex<GetPageCount()); CRect rect=m_arrTabBtnRects[nIndex]; rect+=m_rectTabBtnArea.TopLeft(); rect.OffsetRect(m_nTabBtnAreaOrigin,0); if(rect.right>m_rectTabBtnArea.left && rect.left<m_rectTabBtnArea.right) { rect.bottom=m_rectTabBtnArea.bottom; POINT arrPoints[4]; arrPoints[0].x=rect.left; arrPoints[0].y=rect.top; arrPoints[1].x=rect.left+ID_TABBTNOVERLAPSIZE; arrPoints[1].y=rect.bottom; arrPoints[2].x=rect.right-ID_TABBTNOVERLAPSIZE; arrPoints[2].y=rect.bottom; arrPoints[3].x=rect.right; arrPoints[3].y=rect.top; CPen penTop(PS_SOLID,1,::GetSysColor(COLOR_BTNHILIGHT)); CPen penBottom(PS_SOLID,1,::GetSysColor(COLOR_BTNSHADOW)); CPen* pOldPen=NULL; if(nIndex==GetActivePageIndex()) { pDC->Polygon(arrPoints,4); pOldPen=pDC->SelectObject(&penTop); arrPoints[0].x++; pDC->MoveTo(arrPoints[0]); pDC->LineTo(arrPoints[3]); pDC->SelectObject(&penBottom); arrPoints[1].y--; arrPoints[2].y--; pDC->MoveTo(arrPoints[1]); pDC->LineTo(arrPoints[2]); } else { pDC->Polygon(arrPoints,4); pOldPen=pDC->SelectObject(&penBottom); arrPoints[1].y--; arrPoints[2].y--; pDC->MoveTo(arrPoints[1]); pDC->LineTo(arrPoints[2]); arrPoints[2].x--; arrPoints[3].x--; pDC->MoveTo(arrPoints[2]); pDC->LineTo(arrPoints[3]); pDC->SelectObject(&penTop); arrPoints[0].x+=2; arrPoints[0].y++; arrPoints[1].x++; pDC->MoveTo(arrPoints[0]); pDC->LineTo(arrPoints[1]); } if(pOldPen!=NULL) pDC->SelectObject(pOldPen); CString sTitle=GetPageTitle(nIndex); if(!sTitle.IsEmpty()) { COLORREF oldColor=pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); int nOldBkMode=pDC->SetBkMode(TRANSPARENT); pDC->DrawText(sTitle,rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER); pDC->SetBkMode(nOldBkMode); pDC->SetTextColor(oldColor); } } }
uint32 CGsCachedArea::GetSize() const { return GetPageCount() * CGsPixelFormats::PAGESIZE; }
int wxTreebook::DoSetSelection(size_t pagePos, int flags) { wxCHECK_MSG( IS_VALID_PAGE(pagePos), wxNOT_FOUND, wxT("invalid page index in wxListbook::DoSetSelection()") ); wxASSERT_MSG( GetPageCount() == DoInternalGetPageCount(), wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!")); wxBookCtrlEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId); const int oldSel = m_selection; wxTreeCtrl *tree = GetTreeCtrl(); bool allowed = false; if (flags & SetSelection_SendEvent) { event.SetEventObject(this); event.SetSelection(pagePos); event.SetOldSelection(m_selection); // don't send the event if the old and new pages are the same; do send it // otherwise and be prepared for it to be vetoed allowed = (int)pagePos == m_selection || !GetEventHandler()->ProcessEvent(event) || event.IsAllowed(); } if ( !(flags & SetSelection_SendEvent) || allowed ) { // hide the previously shown page wxTreebookPage * const oldPage = DoGetCurrentPage(); if ( oldPage ) oldPage->Hide(); // then show the new one m_selection = pagePos; wxTreebookPage *page = wxBookCtrlBase::GetPage(m_selection); if ( !page ) { // find the next page suitable to be shown: the first (grand)child // of this one with a non-NULL associated page wxTreeItemId childId = m_treeIds[pagePos]; int actualPagePos = pagePos; while ( !page && childId.IsOk() ) { wxTreeItemIdValue cookie; childId = tree->GetFirstChild( childId, cookie ); if ( childId.IsOk() ) { page = wxBookCtrlBase::GetPage(++actualPagePos); } } m_actualSelection = page ? actualPagePos : m_selection; } if ( page ) page->Show(); tree->SelectItem(DoInternalGetPage(pagePos)); if (flags & SetSelection_SendEvent) { // notify about the (now completed) page change event.SetEventType(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED); (void)GetEventHandler()->ProcessEvent(event); } } else if ( (flags & SetSelection_SendEvent) && !allowed) // page change vetoed { // tree selection might have already had changed if ( oldSel != wxNOT_FOUND ) tree->SelectItem(DoInternalGetPage(oldSel)); } return oldSel; }
HRESULT STDMETHODCALLTYPE SumatraUIAutomationTextRange::MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count, int *moved) { if (moved == NULL) return E_POINTER; // if document is closed, don't do anything if (!document->IsDocumentLoaded()) return E_FAIL; // if not set, don't do anything if (IsNullRange()) return S_OK; // what to move int *target_page, *target_glyph; if (endpoint == TextPatternRangeEndpoint_Start) { target_page = &startPage; target_glyph = &startGlyph; } else if (endpoint == TextPatternRangeEndpoint_End) { target_page = &endPage; target_glyph = &endGlyph; } else { return E_INVALIDARG; } class EndPointMover { protected: SumatraUIAutomationTextRange* target; int* target_page; int* target_glyph; public: // return false when cannot be moved virtual bool NextEndpoint() const { // HACK: Declaring these as pure virtual causes "unreferenced local variable" warnings ==> define a dummy body to get rid of warnings CrashIf(true); return false; } virtual bool PrevEndpoint() const { CrashIf(true); return false; } // return false when not appliable bool NextPage() const { int max_glyph = target->GetPageGlyphCount(*target_page); if (*target_glyph == max_glyph) { if (*target_page == target->GetPageCount()) { // last page return false; } // go to next page (*target_page)++; (*target_glyph) = 0; } return true; } bool PreviousPage() const { if (*target_glyph == 0) { if (*target_page == 1) { // first page return false; } // go to next page (*target_page)--; (*target_glyph) = target->GetPageGlyphCount(*target_page); } return true; } // do the moving int Move(int count, SumatraUIAutomationTextRange* target, int* target_page, int* target_glyph) { this->target = target; this->target_page = target_page; this->target_glyph = target_glyph; int retVal = 0; if (count > 0) { for (int i=0;i<count && (NextPage() || NextEndpoint());++i) ++retVal; } else { for (int i=0;i<-count && (PreviousPage() || PrevEndpoint());++i) ++retVal; } return retVal; } }; class CharEndPointMover : public EndPointMover { bool NextEndpoint() const { (*target_glyph)++; return true; } bool PrevEndpoint() const { (*target_glyph)--; return true; } }; class WordEndPointMover : public EndPointMover { bool NextEndpoint() const { (*target_glyph) = target->FindNextWordEndpoint(*target_page, *target_glyph, true); return true; } bool PrevEndpoint() const { (*target_glyph) = target->FindPreviousWordEndpoint(*target_page, *target_glyph, true); (*target_glyph)--; return true; } }; class LineEndPointMover : public EndPointMover { bool NextEndpoint() const { (*target_glyph) = target->FindNextLineEndpoint(*target_page, *target_glyph, true); return true; } bool PrevEndpoint() const { (*target_glyph) = target->FindPreviousLineEndpoint(*target_page, *target_glyph, true); (*target_glyph)--; return true; } }; // how much to move if (unit == TextUnit_Character) { CharEndPointMover mover; *moved = mover.Move(count, this, target_page, target_glyph); } else if (unit == TextUnit_Word || unit == TextUnit_Format) { WordEndPointMover mover; *moved = mover.Move(count, this, target_page, target_glyph); } else if (unit == TextUnit_Line || unit == TextUnit_Paragraph) { LineEndPointMover mover; *moved = mover.Move(count, this, target_page, target_glyph); } else if (unit == TextUnit_Page) { *moved = 0; *target_glyph = 0; if (count > 0) { // GetPageCount()+1 => allow overflow momentarily for (int i=0;i<count && *target_page!=GetPageCount()+1;++i) { (*target_page)++; (*moved)++; } // fix overflow, allow seeking to the end this way if (*target_page == GetPageCount()+1) { *target_page = GetPageCount(); *target_glyph = GetPageGlyphCount(*target_page); } } else { for (int i=0;i<-count && *target_page!=1;++i) { (*target_page)--; (*moved)++; } } } else if (unit == TextUnit_Document) { if (count > 0) { int end_page = GetPageCount(); int end_glyph = GetPageGlyphCount(*target_page); if (*target_page != end_page || *target_glyph != end_glyph) { *target_page = end_page; *target_glyph = end_glyph; *moved = 1; } else { *moved = 0; } } else { const int beg_page = 0; const int beg_glyph = 0; if (*target_page != beg_page || *target_glyph != beg_glyph) { *target_page = beg_page; *target_glyph = beg_glyph; *moved = 1; } else { *moved = 0; } } } else { return E_INVALIDARG; } // keep range valid if (endpoint == TextPatternRangeEndpoint_Start) { // drag end with start ValidateEndEndpoint(); } else if (endpoint == TextPatternRangeEndpoint_End) { // drag start with end ValidateStartEndpoint(); } return S_OK; }
void wxSTEditorNotebook::UpdateGotoCloseMenu(wxMenu *menu, int startID) { if (!menu) return; size_t n, page_count = GetPageCount(); size_t item_count = menu->GetMenuItemCount(); // ======== Radio items have problems in gtk /* // delete extra menu items (if any) if (page_count < item_count) { for (n=page_count; n < item_count; n++) menu->Delete(startID+n); item_count = page_count; } wxString label; // change labels of existing items for (n=0; n<item_count; n++) { label = wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str()); if (menu->GetLabel(startID+n) != label) menu->SetLabel(startID+n, label); } // append new pages for (n=item_count; n<page_count; n++) menu->AppendRadioItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ /* // This just clears it and adds the items fresh for (n=0; n<item_count; n++) menu->Delete(startID+n); for (n=0; n<page_count; n++) menu->AppendRadioItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ // ==== check items do not // delete extra menu items (if any) if (page_count < item_count) { for (n = page_count; n < item_count; n++) menu->Delete(int(startID+n)); item_count = page_count; } wxString label; // change labels of existing items for (n = 0; n < item_count; n++) { label = wxString::Format(wxT("%2d : %s"), (int)n+1, GetPageText(n).wx_str()); if (menu->GetLabel(int(startID+n)) != label) menu->SetLabel(int(startID+n), label); menu->Check(int(startID+n), false); } // append new pages for (n = item_count; n < page_count; n++) menu->AppendCheckItem(int(startID+n), wxString::Format(wxT("%2d : %s"), (int)n+1, GetPageText(n).wx_str())); /* // use check items for (n = 0; n < item_count; n++) menu->Delete(startID+n); for (n = 0; n < page_count; n++) menu->AppendCheckItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ // show what page we're on int sel = GetSelection(); if ((sel >= 0) && (page_count >= 0)) menu->Check(startID+sel, true); }
bool wxSTEditorNotebook::HandleMenuEvent(wxCommandEvent &event) { wxSTERecursionGuard guard(m_rGuard_HandleMenuEvent); if (guard.IsInside()) return false; int n_page = (int)GetPageCount(); int win_id = event.GetId(); switch (win_id) { case wxID_NEW: { NewPage(); return true; } case wxID_OPEN: { LoadFiles(); return true; } case wxID_SAVEAS: { wxSTEditor *editor = GetEditor(); if (!editor) return true; // event handled, but we couldn't do anything with it. if (!editor->IsFileFromDisk()) { editor->SaveFile(true); } else { wxFileName selectedFileName; wxString selectedFileEncoding; bool selected_file_bom = false; bool ok = editor->SaveFileDialog(true, wxEmptyString, &selectedFileName, &selectedFileEncoding, &selected_file_bom); if (!ok) return true; // they probably canceled the dialog if (selectedFileName == editor->GetFileName()) { // They want to save to the same filename, update current editor. editor->SaveFile(selectedFileName, selectedFileEncoding, selected_file_bom); return true; } else { // Make a new editor for the new filename, leave the original editor as is. wxSTEditorSplitter *splitter = CreateSplitter(wxID_ANY); wxCHECK_MSG(splitter, true, wxT("Invalid splitter")); wxSTEditor *newEditor = splitter->GetEditor(); wxCHECK_MSG(newEditor, true, wxT("Invalid splitter editor")); // Make this new editor identical to the original one // these are probably not necessary //splitter->GetEditor()->SetOptions(editor->GetOptions()); //splitter->GetEditor()->RegisterPrefs(editor->GetEditorPrefs()); //splitter->GetEditor()->RegisterStyles(editor->GetEditorStyles()); //splitter->GetEditor()->RegisterLangs(editor->GetEditorLangs()); newEditor->SetLanguage(editor->GetLanguageId()); newEditor->SetFileName(editor->GetFileName()); newEditor->SetFileEncoding(editor->GetFileEncoding()); newEditor->SetFileBOM(editor->GetFileBOM()); newEditor->SetText(editor->GetText()); newEditor->ColouriseDocument(); newEditor->GotoPos(editor->PositionFromLine(editor->LineFromPosition(editor->GetCurrentPos()))); newEditor->GotoPos(editor->GetCurrentPos()); newEditor->ScrollToLine(editor->GetFirstVisibleLine()); // if we can save it, then add it to the notebook if (newEditor->SaveFile(selectedFileName, selectedFileEncoding, selected_file_bom)) { if (!InsertEditorSplitter(-1, splitter, true)) splitter->Destroy(); } else splitter->Destroy(); // problem saving, delete new editor } } return true; } case ID_STN_SAVE_ALL: { SaveAllFiles(); return true; } case ID_STN_CLOSE_PAGE: { if ((GetSelection() != -1) && GetEditor(GetSelection())) { ClosePage(GetSelection(), true); } return true; } case ID_STN_CLOSE_ALL: { if (wxYES == wxMessageBox(_("Close all pages?"), _("Confim closing all pages"), wxICON_QUESTION|wxYES_NO, this)) { CloseAllPages(true, -1); } return true; } case ID_STN_CLOSE_ALL_OTHERS: { CloseAllPages(true, GetSelection()); return true; } case ID_STN_WIN_PREVIOUS: { if ((GetPageCount() > 0) && (GetSelection() - 1 >= 0)) SetSelection(GetSelection() - 1); else if (GetPageCount() > 0) SetSelection((int)GetPageCount() - 1); return true; } case ID_STN_WIN_NEXT: { if ((GetPageCount() > 0) && (GetSelection() + 1 < (int)GetPageCount())) SetSelection(GetSelection() + 1); else if (GetPageCount() > 0) SetSelection(0); return true; } case ID_STN_WINDOWS: { wxSTEditorWindowsDialog(this, _("Windows")); return true; } case ID_STE_PASTE_NEW: { wxString text; if (wxSTEditor::GetClipboardText(&text)) { NewPage(); wxSTEditor* editor = GetEditor(); if (editor) { editor->SetText(text); editor->SetModified(false); } } return true; } default: { if ((win_id >= ID_STN_GOTO_PAGE_START) && (win_id < ID_STN_GOTO_PAGE_START+n_page)) { SetSelection(win_id - ID_STN_GOTO_PAGE_START); return true; } else if ((win_id >= ID_STN_CLOSE_PAGE_START) && (win_id < ID_STN_CLOSE_PAGE_START+n_page)) { ClosePage(win_id - ID_STN_CLOSE_PAGE_START); return true; } break; } } return false; }
int Menu::PagekeyToItem(page_t page, item_t key) { size_t start = page * items_per_page; size_t num_pages = GetPageCount(); if (num_pages == 1 || !items_per_page) { if (key > m_Items.length()) { return MENU_EXIT; } else { return key-1; } } else { //first page if (page == 0) { /* The algorithm for spaces here is same as a middle page. */ item_t new_key = key; for (size_t i=start; i<(start+key-1) && i<m_Items.length(); i++) { for (size_t j=0; j<m_Items[i]->blanks.length(); j++) { if (m_Items[i]->blanks[j].EatNumber()) { if (!new_key) { break; } new_key--; } if (!new_key) { break; } } } key = new_key; if (key == items_per_page + 2) { return MENU_MORE; } else if (key == items_per_page + 3) { return MENU_EXIT; } else { return (start + key - 1); } } else if (page == num_pages - 1) { //last page item_t item_tracker = 0; // tracks how many valid items we have passed so far. size_t remaining = m_Items.length() - start; item_t new_key = key; // For every item that takes up a slot (item or padded blank) // we subtract one from new key. // For every item (not blanks), we increase item_tracker. // When new_key equals 0, item_tracker will then be set to // whatever valid item was selected. for (size_t i=m_Items.length() - remaining; i<m_Items.length(); i++) { item_tracker++; if (new_key<=1) // If new_key is 0, or will be 0 after the next decrease { new_key=0; break; } new_key--; for (size_t j=0; j<m_Items[i]->blanks.length(); j++) { if (m_Items[i]->blanks[j].EatNumber()) { new_key--; } if (!new_key) { break; } } } // If new_key doesn't equal zero, then a back/exit button was pressed. if (new_key!=0) { if (key == items_per_page + 1) { return MENU_BACK; } else if (key == items_per_page + 3) { return MENU_EXIT; } // MENU_MORE should never happen here. } // otherwise our item is now start + item_tracker - 1 return (start + item_tracker - 1); } else { /* The algorithm for spaces here is a bit harder. We have to subtract * one from the key for each space we find along the way. */ item_t new_key = key; for (size_t i=start; i<(start+items_per_page-1) && i<m_Items.length(); i++) { for (size_t j=0; j<m_Items[i]->blanks.length(); j++) { if (m_Items[i]->blanks[j].EatNumber()) { if (!new_key) { break; } new_key--; } if (!new_key) { break; } } } key = new_key; if (key > items_per_page && (key-items_per_page<=3)) { unsigned int num = key - items_per_page - 1; static int map[] = {MENU_BACK, MENU_MORE, MENU_EXIT}; return map[num]; } else { return (start + key - 1); } } } }
bool Notebook::SetPageText(size_t index, const wxString &text) { if (index >= GetPageCount()) return false; return wxNotebook::SetPageText(index, text); }
const char *Menu::GetTextString(int player, page_t page, int &keys) { page_t pages = GetPageCount(); item_t numItems = GetItemCount(); if (page >= pages) return NULL; m_Text = nullptr; char buffer[255]; if (items_per_page && (pages != 1)) { if (m_AutoColors) ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages); else ke::SafeSprintf(buffer, sizeof(buffer), "%s %d/%d\n\n", m_Title.chars(), page + 1, pages); } else { if (m_AutoColors) ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s\n\\w\n", m_Title.chars()); else ke::SafeSprintf(buffer, sizeof(buffer), "%s\n\n", m_Title.chars()); } m_Text = m_Text + buffer; enum { Display_Back = (1<<0), Display_Next = (1<<1), }; int flags = Display_Back|Display_Next; item_t start = page * items_per_page; item_t end = 0; if (items_per_page) { if (start + items_per_page >= numItems) { end = numItems; flags &= ~Display_Next; } else { end = start + items_per_page; } } else { end = numItems; if (end > 10) { end = 10; } } if (page == 0) { flags &= ~Display_Back; } menuitem *pItem = NULL; int option = 0; keys = 0; bool enabled = true; int ret = 0; int slots = 0; int option_display = 0; for (item_t i = start; i < end; i++) { // reset enabled enabled = true; pItem = m_Items[i]; if (pItem->access && !(pItem->access & g_players[player].flags[0])) { enabled = false; } if (pItem->handler != -1) { ret = executeForwards(pItem->handler, static_cast<cell>(player), static_cast<cell>(thisId), static_cast<cell>(i)); if (ret == ITEM_ENABLED) { enabled = true; } else if (ret == ITEM_DISABLED) { enabled = false; } } if (pItem->pfn) { ret = (pItem->pfn)(player, thisId, i); if (ret == ITEM_ENABLED) { enabled = true; } else if (ret == ITEM_DISABLED) { enabled = false; } } if (pItem->isBlank) { enabled = false; } if (enabled) { keys |= (1<<option); } option_display = ++option; if (option_display == 10) { option_display = 0; } if (pItem->isBlank) { ke::SafeSprintf(buffer, sizeof(buffer), "%s\n", pItem->name.chars()); } else if (enabled) { if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option_display, pItem->name.chars()); } } else { if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option_display, pItem->name.chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", pItem->name.chars()); } } slots++; m_Text = m_Text + buffer; //attach blanks if (pItem->blanks.length()) { for (size_t j=0; j<pItem->blanks.length(); j++) { if (pItem->blanks[j].EatNumber()) { option++; } m_Text = m_Text + pItem->blanks[j].GetDisplay(); m_Text = m_Text + "\n"; slots++; } } } if (items_per_page) { /* Pad spaces until we reach the end of the max possible items */ for (unsigned int i=(unsigned)slots; i<items_per_page; i++) { m_Text = m_Text + "\n"; option++; } /* Make sure there is at least one visual pad */ m_Text = m_Text + "\n"; /* Don't bother if there is only one page */ if (pages > 1) { if (flags & Display_Back) { keys |= (1<<option++); if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "%s%d. \\w%s\n", m_ItemColor.chars(), option == 10 ? 0 : option, m_OptNames[abs(MENU_BACK)].chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option == 10 ? 0 : option, m_OptNames[abs(MENU_BACK)].chars()); } } else { option++; if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option == 10 ? 0 : option, m_OptNames[abs(MENU_BACK)].chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_BACK)].chars()); } } m_Text = m_Text + buffer; if (flags & Display_Next) { keys |= (1<<option++); if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "%s%d. \\w%s\n", m_ItemColor.chars(), option == 10 ? 0 : option, m_OptNames[abs(MENU_MORE)].chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option == 10 ? 0 : option, m_OptNames[abs(MENU_MORE)].chars()); } } else { option++; if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option == 10 ? 0 : option, m_OptNames[abs(MENU_MORE)].chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_MORE)].chars()); } } m_Text = m_Text + buffer; } else { /* Keep padding */ option += 2; } } if ((items_per_page && !m_NeverExit) || (m_ForceExit && numItems < 10)) { /* Visual pad has not been added yet */ if (!items_per_page) m_Text = m_Text + "\n"; keys |= (1<<option++); if (m_AutoColors) { ke::SafeSprintf(buffer, sizeof(buffer), "%s%d. \\w%s\n", m_ItemColor.chars(), option == 10 ? 0 : option, m_OptNames[abs(MENU_EXIT)].chars()); } else { ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option == 10 ? 0 : option, m_OptNames[abs(MENU_EXIT)].chars()); } m_Text = m_Text + buffer; } return m_Text.ptr(); }
// same as AddPage() but does it at given position bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, int imageId) { wxCHECK_MSG( pPage != NULL, false, wxT("NULL page in wxNotebook::InsertPage") ); wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false, wxT("invalid index in wxNotebook::InsertPage") ); wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") ); // add a new tab to the control // ---------------------------- // init all fields to 0 TC_ITEM tcItem; wxZeroMemory(tcItem); // set the image, if any if ( imageId != -1 ) { tcItem.mask |= TCIF_IMAGE; tcItem.iImage = imageId; } // and the text if ( !strText.empty() ) { tcItem.mask |= TCIF_TEXT; tcItem.pszText = wxMSW_CONV_LPTSTR(strText); } // hide the page: unless it is selected, it shouldn't be shown (and if it // is selected it will be shown later) HWND hwnd = GetWinHwnd(pPage); SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); // this updates internal flag too -- otherwise it would get out of sync // with the real state pPage->Show(false); // fit the notebook page to the tab control's display area: this should be // done before adding it to the notebook or TabCtrl_InsertItem() will // change the notebooks size itself! AdjustPageSize(pPage); // finally do insert it if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 ) { wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); return false; } // need to update the bg brush when the first page is added // so the first panel gets the correct themed background if ( m_pages.empty() ) { #if wxUSE_UXTHEME UpdateBgBrush(); #endif // wxUSE_UXTHEME } // succeeded: save the pointer to the page m_pages.Insert(pPage, nPage); // we may need to adjust the size again if the notebook size changed: // normally this only happens for the first page we add (the tabs which // hadn't been there before are now shown) but for a multiline notebook it // can happen for any page at all as a new row could have been started if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) ) { AdjustPageSize(pPage); // Additionally, force the layout of the notebook itself by posting a // size event to it. If we don't do it, notebooks with pages on the // left or the right side may fail to account for the fact that they // are now big enough to fit all all of their pages on one row and // still reserve space for the second row of tabs, see #1792. const wxSize s = GetSize(); ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(s.x, s.y)); } // now deal with the selection // --------------------------- // if the inserted page is before the selected one, we must update the // index of the selected page if ( int(nPage) <= m_selection ) { // one extra page added m_selection++; } DoSetSelectionAfterInsertion(nPage, bSelect); InvalidateBestSize(); return true; }
void COXTabViewContainer::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(m_nPressedScrlBtn!=NONE) { int hitTest=HitTest(point); // send corresponding messages if(((int)m_nPressedScrlBtn==hitTest && !m_bIsScrlBtnPressed) || ((int)m_nPressedScrlBtn!=hitTest && m_bIsScrlBtnPressed)) { m_bIsScrlBtnPressed=!m_bIsScrlBtnPressed; RedrawScrollButton(m_nPressedScrlBtn); } } else if(m_bIsSplitterPressed) { CPoint ptMoved=point; if(ptMoved.x>m_rectPage.right-ID_MINSCROLLBARWIDTH+ID_SPLITTERWIDTH/2) ptMoved.x=m_rectPage.right-ID_MINSCROLLBARWIDTH+ID_SPLITTERWIDTH/2; if(ptMoved.x<m_rectScrollToEndBtn.right+ID_SPLITTERWIDTH/2) ptMoved.x=m_rectScrollToEndBtn.right+ID_SPLITTERWIDTH/2; int nOldSplitterLeft=m_rectSplitter.left; m_rectSplitter.left=ptMoved.x-ID_SPLITTERWIDTH/2; if(nOldSplitterLeft!=m_rectSplitter.left) { m_rectSplitter.right=m_rectSplitter.left+ID_SPLITTERWIDTH; m_rectScrollBarHorz.left=m_rectSplitter.right; m_nLastTabBtnAreaWidth=m_rectSplitter.left-m_rectScrollToEndBtn.right; m_rectTabBtnArea.right+=m_rectSplitter.left-nOldSplitterLeft; if(m_rectTabBtnArea.right<m_rectTabBtnArea.left) m_rectTabBtnArea.right=m_rectTabBtnArea.left; if(::IsWindow(m_scrlBarHorz.GetSafeHwnd())) m_scrlBarHorz.MoveWindow(m_rectScrollBarHorz); RedrawSplitter(); if(nOldSplitterLeft<m_rectSplitter.left) { CRect rect=m_rectSplitter; rect.left=nOldSplitterLeft; rect.right=m_rectSplitter.left; RedrawWindow(rect); if(m_nTabBtnAreaOrigin<0) { ASSERT(GetPageCount()==m_arrTabBtnRects.GetSize()); rect=m_arrTabBtnRects[GetPageCount()-1]; rect+=m_rectTabBtnArea.TopLeft(); if(rect.right+m_nTabBtnAreaOrigin<=m_rectTabBtnArea.right) { m_nTabBtnAreaOrigin+= m_rectSplitter.left-nOldSplitterLeft; m_nTabBtnAreaOrigin= m_nTabBtnAreaOrigin>0 ? 0 : m_nTabBtnAreaOrigin; RedrawTabBtnArea(); } } } } } CWnd::OnMouseMove(nFlags, point); }
void wxNotebook::OnSize(wxSizeEvent& event) { if ( GetPageCount() == 0 ) { // Prevents droppings on resize, but does cause some flicker // when there are no pages. Refresh(); event.Skip(); return; } #ifndef __WXWINCE__ else { // Without this, we can sometimes get droppings at the edges // of a notebook, for example a notebook in a splitter window. // This needs to be reconciled with the RefreshRect calls // at the end of this function, which weren't enough to prevent // the droppings. wxSize sz = GetClientSize(); // Refresh right side wxRect rect(sz.x-4, 0, 4, sz.y); RefreshRect(rect); // Refresh bottom side rect = wxRect(0, sz.y-4, sz.x, 4); RefreshRect(rect); // Refresh left side rect = wxRect(0, 0, 4, sz.y); RefreshRect(rect); } #endif // !__WXWINCE__ // fit all the notebook pages to the tab control's display area RECT rc; rc.left = rc.top = 0; GetSize((int *)&rc.right, (int *)&rc.bottom); // save the total size, we'll use it below int widthNbook = rc.right - rc.left, heightNbook = rc.bottom - rc.top; // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it // returns completely false values for multiline tab controls after the tabs // are added but before getting the first WM_SIZE (off by ~50 pixels, see // // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863 // // and the only work around I could find was this ugly hack... without it // simply toggling the "multiline" checkbox in the notebook sample resulted // in a noticeable page displacement if ( HasFlag(wxNB_MULTILINE) ) { // avoid an infinite recursion: we get another notification too! static bool s_isInOnSize = false; if ( !s_isInOnSize ) { s_isInOnSize = true; SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc.right, rc.bottom)); s_isInOnSize = false; } // The best size depends on the number of rows of tabs, which can // change when the notepad is resized. InvalidateBestSize(); } #if wxUSE_UXTHEME // background bitmap size has changed, update the brush using it too UpdateBgBrush(); #endif // wxUSE_UXTHEME TabCtrl_AdjustRect(GetHwnd(), false, &rc); int width = rc.right - rc.left, height = rc.bottom - rc.top; size_t nCount = m_pages.Count(); for ( size_t nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_pages[nPage]; pPage->SetSize(rc.left, rc.top, width, height); } // unless we had already repainted everything, we now need to refresh if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { // invalidate areas not covered by pages RefreshRect(wxRect(0, 0, widthNbook, rc.top), false); RefreshRect(wxRect(0, rc.top, rc.left, height), false); RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom), false); RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.right, height), false); } #if USE_NOTEBOOK_ANTIFLICKER // subclass the spin control used by the notebook to scroll pages to // prevent it from flickering on resize if ( !m_hasSubclassedUpdown ) { // iterate over all child windows to find spin button for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD); child; child = ::GetWindow(child, GW_HWNDNEXT) ) { wxWindow *childWindow = wxFindWinFromHandle((WXHWND)child); // see if it exists, if no wxWindow found then assume it's the spin // btn if ( !childWindow ) { // subclass the spin button to override WM_ERASEBKGND if ( !gs_wndprocNotebookSpinBtn ) gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child); wxSetWindowProc(child, wxNotebookSpinBtnWndProc); m_hasSubclassedUpdown = true; break; } } } // Probably because of the games we play above to avoid flicker sometimes // the text controls inside notebook pages are not shown correctly (they // don't have their borders) when the notebook is shown for the first time. // It's not really clear why does this happen and maybe the bug is in // wxTextCtrl itself and not here but updating the page when it's about to // be shown doesn't cost much and works around the problem so do it here // for now. if ( !m_doneUpdateHack && IsShownOnScreen() ) { m_doneUpdateHack = true; wxWindow* const page = GetCurrentPage(); if ( page ) page->Update(); } #endif // USE_NOTEBOOK_ANTIFLICKER event.Skip(); }
BOOL COXTabViewContainer::SetActivePageIndex(int nIndex) { if(nIndex==m_nActivePageIndex) { return TRUE; } CWnd* pWndOld=GetActivePage(); if(pWndOld!=NULL) { ASSERT(::IsWindow(pWndOld->m_hWnd)); if(::IsWindow(pWndOld->m_hWnd)) { UpdateScrollInfo(); pWndOld->ShowWindow(SW_HIDE); PAGEINFO pi=m_arrPages[GetActivePageIndex()]; m_nActivePageIndex=-1; UINT nBar=(pi.bHasScrollHorz&pi.bHasScrollVert ? SB_BOTH : (pi.bHasScrollHorz ? SB_HORZ : (pi.bHasScrollVert ? SB_VERT : 0))); if(nBar!=0) { pWndOld->ShowScrollBar(nBar,TRUE); } } } m_nActivePageIndex=nIndex; if(m_nActivePageIndex>=0 && m_nActivePageIndex<GetPageCount()) { EnsureTabBtnVisible(m_nActivePageIndex); CWnd* pWnd=GetPage(m_nActivePageIndex); if(pWnd!=NULL) { ASSERT(::IsWindow(pWnd->m_hWnd)); if(::IsWindow(pWnd->m_hWnd)) { IniScrollInfo(); pWnd->ShowWindow(SW_SHOW); CRect rect; pWnd->GetWindowRect(rect); if(rect.Width()!=m_rectPage.Width() || rect.Height()!=m_rectPage.Height()) { pWnd->MoveWindow(m_rectPage); } else { pWnd->SendMessage(WM_SIZE,SIZE_RESTORED, MAKELPARAM(rect.Width(),rect.Height())); } // set the focus to the page CFrameWnd* pFrameWnd=(CFrameWnd*)GetParent(); ASSERT(pFrameWnd!=NULL); if(pFrameWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd))) { if(pWnd->IsKindOf(RUNTIME_CLASS(CView))) { pFrameWnd->SetActiveView((CView*)pWnd); } else { if(pWndOld!=NULL && pWndOld->IsKindOf(RUNTIME_CLASS(CView))) { pFrameWnd->SetActiveView(NULL); } pWnd->SetFocus(); } } else { pWnd->SetFocus(); } RedrawTabBtnArea(); } } } else return FALSE; return TRUE; }
void CU8GLcd::SetRotaryFocusMainPage() { _rotarybutton.SetPageIdx((rotarypos_t) _currentpage); _rotarybutton.SetMinMax(0, GetPageCount() - 1, true); _rotaryFocus = RotaryMainPage; }
int wxNotebook::GetPageImage( size_t page ) const { wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index"); return GetNotebookPage(page)->m_imageIndex; }
void wxSTEditorNotebook::OnFindDialog(wxFindDialogEvent &event) { wxSTERecursionGuard guard(m_rGuard_OnFindDialog); if (guard.IsInside()) return; // currently opened page is where the search starts wxSTEditor *editor = GetEditor(); if (!editor) return; // just search the given page by letting the editor handle it if (!STE_HASBIT(event.GetFlags(), STE_FR_ALLDOCS)) { editor->HandleFindDialogEvent(event); return; } wxEventType eventType = event.GetEventType(); wxString findString = event.GetFindString(); long flags = event.GetFlags(); editor->SetFindString(findString, true); editor->SetFindFlags(flags, true); STE_TextPos pos = editor->GetCurrentPos(); if ((eventType == wxEVT_COMMAND_FIND) && STE_HASBIT(flags, STE_FR_WHOLEDOC)) pos = -1; // we have to move cursor to start of word if last backwards search suceeded // note cmp is ok since regexp doesn't handle searching backwards if ((eventType == wxEVT_COMMAND_FIND_NEXT) && !STE_HASBIT(flags, wxFR_DOWN)) { if ((labs(editor->GetSelectionEnd() - editor->GetSelectionStart()) == long(findString.Length())) && (editor->GetFindReplaceData()->StringCmp(findString, editor->GetSelectedText(), flags))) pos -= (STE_TextPos)findString.Length() + 1; // doesn't matter if it matches or not, skip it } if (eventType == wxEVT_STEFIND_GOTO) { wxString findAllString(event.GetString()); wxString fileName; int line_number = 0; int line_start_pos = 0; int string_start_pos = 0; int string_length = 0; wxString lineText; bool ok = wxSTEditorFindReplaceData::ParseFindAllString(findAllString, fileName, line_number, line_start_pos, string_start_pos, string_length, lineText); int page = wxNOT_FOUND; if (ok) page = FindEditorPageByFileName(fileName); if (page != wxNOT_FOUND) { SetSelection(page); GetEditor(page)->HandleFindDialogEvent(event); } } else if ((eventType == wxEVT_COMMAND_FIND) || (eventType == wxEVT_COMMAND_FIND_NEXT)) { if (STE_HASBIT(flags, STE_FR_FINDALL|STE_FR_BOOKMARKALL)) { // sum up all of the find strings in all editors int n, count = (int)GetPageCount(); for (n = 0; n < count; n++) { wxSTEditor* e = GetEditor(n); if (e) e->HandleFindDialogEvent(event); } } else { if ((eventType == wxEVT_COMMAND_FIND) && STE_HASBIT(flags, STE_FR_WHOLEDOC)) pos = 0; pos = FindString(findString, pos, flags, STE_FINDSTRING_SELECT|STE_FINDSTRING_GOTO); if (pos >= 0) { //editor->SetFocus(); } else { wxBell(); // bell ok to signify no more occurances? } } } else if (eventType == wxEVT_COMMAND_FIND_REPLACE) { if (!editor->GetFindReplaceData()->StringCmp(findString, editor->GetSelectedText(), flags)) { wxBell(); return; } STE_TextPos pos = editor->GetSelectionStart(); wxString replaceString(event.GetReplaceString()); editor->ReplaceSelection(replaceString); editor->EnsureCaretVisible(); editor->SetSelection(pos, pos + (STE_TextPos)replaceString.Length()); editor->UpdateCanDo(true); //editor->SetFocus(); } else if (eventType == wxEVT_COMMAND_FIND_REPLACE_ALL) { wxString replaceString(event.GetReplaceString()); if (editor->GetFindReplaceData()->StringCmp(findString, replaceString, flags)) return; wxBusyCursor busy; int pages = 0; int count = ReplaceAllStrings(findString, replaceString, flags, &pages); wxString msg( wxString::Format(_("Replaced %d occurances of\n'%s' with '%s'\nin %d documents."), count, findString.wx_str(), replaceString.wx_str(), pages) ); wxMessageBox( msg, _("Finished replacing"), wxOK|wxICON_INFORMATION|wxSTAY_ON_TOP, wxGetTopLevelParent(this) ); // make it be on top in GTK //wxDynamicCast(event.GetEventObject(), wxDialog)); } else if (eventType == wxEVT_COMMAND_FIND_CLOSE) { //if (wxDynamicCast(event.GetEventObject(), wxDialog)) // ((wxDialog*)event.GetEventObject())->Destroy(); } }
int wxNotebook::HitTest(const wxPoint& pt, long *flags) const { GtkAllocation a; gtk_widget_get_allocation(m_widget, &a); const int x = a.x; const int y = a.y; const size_t count = GetPageCount(); size_t i = 0; #ifndef __WXGTK3__ GtkNotebook * notebook = GTK_NOTEBOOK(m_widget); if (gtk_notebook_get_scrollable(notebook)) i = g_list_position( notebook->children, notebook->first_tab ); #endif for ( ; i < count; i++ ) { wxGtkNotebookPage* pageData = GetNotebookPage(i); GtkWidget* box = pageData->m_box; const gint border = gtk_container_get_border_width(GTK_CONTAINER(box)); if ( IsPointInsideWidget(pt, box, x, y, border) ) { // ok, we're inside this tab -- now find out where, if needed if ( flags ) { if (pageData->m_image && IsPointInsideWidget(pt, pageData->m_image, x, y)) { *flags = wxBK_HITTEST_ONICON; } else if (IsPointInsideWidget(pt, pageData->m_label, x, y)) { *flags = wxBK_HITTEST_ONLABEL; } else { *flags = wxBK_HITTEST_ONITEM; } } return i; } } if ( flags ) { *flags = wxBK_HITTEST_NOWHERE; wxWindowBase * page = GetCurrentPage(); if ( page ) { // rect origin is in notebook's parent coordinates wxRect rect = page->GetRect(); // adjust it to the notebook's coordinates wxPoint pos = GetPosition(); rect.x -= pos.x; rect.y -= pos.y; if ( rect.Contains( pt ) ) *flags |= wxBK_HITTEST_ONPAGE; } } return wxNOT_FOUND; }
void Notebook::AddPage(CustomTab *tab) { InsertPage(tab, GetPageCount()); }
void OperaMenuDialog::OnInit() { int i; //don't save position, the dialog will be aligned automatically SetSavePlacementOnClose(FALSE); // Listen to parent desktop window to get notified about movements if (GetParentDesktopWindow() && GetParentDesktopWindow()->GetParentDesktopWindow()) GetParentDesktopWindow()->GetParentDesktopWindow()->AddListener(this); m_tabs = static_cast<OpTabs *> (GetWidgetByType(WIDGET_TYPE_TABS)); m_tabs->SetButtonStyle(OpButton::STYLE_IMAGE); m_tabs->SetXResizeEffect(RESIZE_FIXED); m_tabs->SetYResizeEffect(RESIZE_SIZE); OpWidget *w = (OpWidget*) m_tabs->childs.First(); while (w) { w->SetListener(this); OpInputAction *action = OP_NEW(OpInputAction, (OpInputAction::ACTION_SHOW_MENU_SECTION)); if (w->GetType() == WIDGET_TYPE_BUTTON) ((OpButton*)w)->SetAction(action); w = (OpWidget*) w->Suc(); } // Basic layout and initialization for(i = 0; i < (int)GetPageCount(); i++) { OpWidget *page = GetPageByNumber(i); OpWidget *w = page->GetFirstChild(); int y = 0, row_add = 0; while (w) { if (w->GetType() == WIDGET_TYPE_BUTTON) { OpButton *b = static_cast<OpButton*> (w); b->SetButtonStyle(OpButton::STYLE_IMAGE_AND_TEXT_ON_RIGHT); b->SetButtonType(OpButton::TYPE_OMENU); b->SetFixedImage(FALSE); if (b->GetBounds().width >= 300) b->SetShowShortcut(TRUE); } // test of some really basic vertical layout so we don't have to do that by hand in ini. /*if (page->GetName().Compare("Menu Page") == 0 || page->GetName().Compare("Menu Tools") == 0 || page->GetName().Compare("Menu Closed Tabs") == 0)*/ { int x = w->GetRect().x; int height = w->GetRect().height; if (x == 0) y += row_add; w->SetRect(OpRect(x, y, w->GetRect().width, height)); w->SetOriginalRect(w->GetRect()); row_add = height; } w = (OpWidget *) w->Suc(); } } if (OpSlider *slider = static_cast<OpSlider*> (GetWidgetByName("zoom_slider"))) { int zoom = 100; slider->SetMin(20); slider->SetMax(300); slider->SetValue(zoom); slider->SetStep(10); slider->ShowTickLabels(TRUE); OpSlider::TICK_VALUE tick_values[5] = { {20, FALSE }, {50, FALSE }, {100, TRUE }, {200, TRUE }, {300, FALSE } }; slider->SetTickValues(5, tick_values, 10); } // Create window animation for slider fade m_window_animation = OP_NEW(QuickAnimationWindowObject, ()); if (!m_window_animation || OpStatus::IsError(m_window_animation->Init(this, NULL))) { OP_DELETE(m_window_animation); m_window_animation = NULL; } }
int wxSTEditorNotebook::FindString(const wxString &str, STE_TextPos start_pos, int flags, int action) { int n_pages = (int)GetPageCount(); int n_sel = GetSelection(); int n = -1; STE_TextPos pos = start_pos; bool forward = STE_HASBIT(flags, wxFR_DOWN) != 0; int noteb_flags = flags & (~STE_FR_WRAPAROUND); // switch to new page wxSTEditor *editor = NULL; if (n_sel < 0) return wxNOT_FOUND; // oops // search this page and later or before to end for (n = n_sel; forward ? n < n_pages : n >= 0; n = forward ? n+1 : n-1) { editor = GetEditor(n); if (!editor) continue; if (n != n_sel) pos = forward ? 0 : editor->GetLength(); pos = editor->FindString(str, pos, -1, noteb_flags, action); if (pos != wxNOT_FOUND) { SetSelection(n); editor->UpdateCanDo(true); // make sure CanFind is updated return pos; } } // search through remaining pages for (n = forward ? 0 : n_pages-1; forward ? n < n_sel : n > n_sel; n = forward ? n+1 : n-1) { editor = GetEditor(n); if (!editor) continue; pos = forward ? 0 : editor->GetLength(); pos = editor->FindString(str, pos, -1, noteb_flags, action); if (pos != wxNOT_FOUND) { SetSelection(n); editor->UpdateCanDo(true); // make sure CanFind is updated return pos; } } // if we haven't found the string then try to wrap around on this doc. editor = GetEditor(n_sel); if ((editor != NULL) && STE_HASBIT(flags, STE_FR_WRAPAROUND)) { pos = editor->FindString(str, start_pos, -1, flags, action); editor->UpdateCanDo(true); // make sure CanFind is updated return pos; } return wxNOT_FOUND; }