Exemple #1
0
void MyFrame::OnPageChanged(wxNotebookEvent& event)
{//=================================================
    int pagenum;
    wxString title;
    SpectDisplay *page;

    pagenum = event.GetSelection();

    if(event.GetId() == ID_SCREENPAGES)
    {
        title = screenpages->GetPageText(pagenum);

        if((title != _T("Prosody")) && (adding_page != 2))
        {
            page = (SpectDisplay *)screenpages->GetPage(pagenum);

            if(page != currentcanvas)
            {
                if(currentcanvas != NULL)
                {
                    currentcanvas->OnActivate(0);
                }
                page->OnActivate(1);
            }
            MakeMenu(2, NULL);
        }
        else
        {
            MakeMenu(3, NULL);
        }
    }
	adding_page = 0;   // work around for wxNotebook bug (version 2.8.7)
}
void GLIBitmapNotebook::OnPageChange(wxNotebookEvent &event)
{
  // Ensure our window ID and a valid page was selected previously
  if(event.GetId() == GetId())
  {
    int newPage = event.GetSelection();
    int oldPage = event.GetOldSelection();

    // Get if the selected pages are valid
    if(newPage >= 0 && newPage < bitmapViews.size() &&
       oldPage >= 0 && oldPage < bitmapViews.size())
    {
      int scrollStartX = 0;
      int scrollStartY = 0;
      int oldScrollPPUX = 1;
      int oldScrollPPUY = 1;
      int newScrollPPUX = 1;
      int newScrollPPUY = 1;

      // Get the old scroll position
      bitmapViews[oldPage]->GetViewStart(&scrollStartX, &scrollStartY);
      bitmapViews[oldPage]->GetScrollPixelsPerUnit(&oldScrollPPUX, &oldScrollPPUY);

      // Get the new scroll pixels per unit (probably the same as the old one)
      bitmapViews[newPage]->GetScrollPixelsPerUnit(&newScrollPPUX, &newScrollPPUY);

      // Ensure a valid setting of the scroll area
      if(newScrollPPUX != 0 && newScrollPPUY != 0)
      {
        // Set the new scroll position
        bitmapViews[newPage]->Scroll(scrollStartX*oldScrollPPUX/newScrollPPUX,
                                     scrollStartY*oldScrollPPUY/newScrollPPUY);
      }
      else
      {
        bitmapViews[newPage]->Scroll(0, 0);
      }

      // Get the current GL buffer type displayed
      bitmapViews[newPage]->GetGLBufferType(preferedBufferTypeID, preferedDrawBufferID);

      // Update the window title the new image
      parentControl->UpdateWindowTitle();
    }
  }

  // Allow others to process
  event.Skip();
}