这篇教程C++ wxGetApp函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wxGetApp函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetApp函数的具体用法?C++ wxGetApp怎么用?C++ wxGetApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wxGetApp函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: filter_dlg_shared_state filter_dlg_shared_state() { app = &(wxGetApp()); }
开发者ID:JGRennison,项目名称:retcon,代码行数:3,
示例2: wxGetAppvoid CSelectMode::OnDragging( wxMouseEvent& event ){ if(event.MiddleIsDown()) { wxPoint dm; dm.x = event.GetX() - CurrentPoint.x; dm.y = event.GetY() - CurrentPoint.y; if(wxGetApp().ctrl_does_rotate == event.ControlDown()) { if(wxGetApp().m_rotate_mode) { wxGetApp().m_current_viewport->m_view_point.Turn(dm); } else { wxGetApp().m_current_viewport->m_view_point.TurnVertical(dm); } } else { wxGetApp().m_current_viewport->m_view_point.Shift(dm, wxPoint(event.GetX(), event.GetY())); } wxGetApp().m_current_viewport->m_need_update = true; wxGetApp().m_current_viewport->m_need_refresh = true; } else if(event.LeftIsDown()) { if(wxGetApp().drag_gripper) { double to[3], from[3]; wxGetApp().m_digitizing->digitize(wxPoint(event.GetX(), event.GetY())); extract(wxGetApp().m_digitizing->digitized_point.m_point, to); wxGetApp().grip_to = wxGetApp().m_digitizing->digitized_point.m_point; extract(wxGetApp().grip_from, from); wxGetApp().drag_gripper->OnGripperMoved(from, to); wxGetApp().grip_from = gp_Pnt(from[0], from[1], from[2]); wxGetApp().grip_from = make_point(from); } else if(abs(button_down_point.x - event.GetX())>2 || abs(button_down_point.y - event.GetY())>2) { if(wxGetApp().m_dragging_moves_objects && !window_box_exists) { std::list<HeeksObj*> selected_objects_dragged; wxGetApp().m_show_grippers_on_drag = true; if( wxGetApp().m_marked_list->list().size() > 0) { for(std::list<HeeksObj*>::iterator It = wxGetApp().m_marked_list->list().begin(); It != wxGetApp().m_marked_list->list().end(); It++) { HeeksObj* object = *It; if(object->CanBeDragged())selected_objects_dragged.push_back(object); } } else { MarkedObjectManyOfSame marked_object; wxGetApp().FindMarkedObject(button_down_point, &marked_object); if(marked_object.m_map.size()>0){ HeeksObj* object = marked_object.GetFirstOfTopOnly(); double min_depth = 0.0; HeeksObj* closest_object = NULL; while(object) { if(object->CanBeDragged()) { double depth = marked_object.GetDepth(); if(closest_object == NULL || depth<min_depth) { min_depth = depth; closest_object = object; } } object = marked_object.Increment(); } if(selected_objects_dragged.size() == 0 && closest_object){ selected_objects_dragged.push_back(closest_object); wxGetApp().m_show_grippers_on_drag = false; } } } if(selected_objects_dragged.size() > 0) { wxGetApp().drag_gripper = &drag_object_gripper; wxGetApp().m_digitizing->SetOnlyCoords(wxGetApp().drag_gripper, true); wxGetApp().m_digitizing->digitize(button_down_point); wxGetApp().grip_from = wxGetApp().m_digitizing->digitized_point.m_point; wxGetApp().grip_to = wxGetApp().grip_from; double from[3]; from[0] = wxGetApp().grip_from.X(); from[1] = wxGetApp().grip_from.Y(); from[2] = wxGetApp().grip_from.Z(); wxGetApp().drag_gripper->OnGripperGrabbed(selected_objects_dragged, wxGetApp().m_show_grippers_on_drag, from); wxGetApp().grip_from = gp_Pnt(from[0], from[1], from[2]); double to[3]; wxGetApp().m_digitizing->digitize(wxPoint(event.GetX(), event.GetY())); extract(wxGetApp().m_digitizing->digitized_point.m_point, to); wxGetApp().grip_to = wxGetApp().m_digitizing->digitized_point.m_point; extract(wxGetApp().grip_from, from); wxGetApp().drag_gripper->OnGripperMoved(from, to);//.........这里部分代码省略.........
开发者ID:CassieMarie,项目名称:heekscad,代码行数:101,
示例3: Run void Run(){ wxGetApp().m_marked_list->m_filter = -1; wxGetApp().m_frame->RefreshInputCanvas(); }
开发者ID:CassieMarie,项目名称:heekscad,代码行数:4,
示例4: wxFrame// ------------------------------------------------------------------------MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) : wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER) ) , m_statusbar( *CreateStatusBar(2, 0) ) , m_background( this, wxID_ANY, wxGetApp().GetLogoBitmap() ) // All menu components must be created on the heap! , m_menubar( *new wxMenuBar() ) , m_menuCDVD ( *new wxMenu() ) , m_menuSys ( *new wxMenu() ) , m_menuConfig ( *new wxMenu() ) , m_menuMisc ( *new wxMenu() ) , m_menuDebug ( *new wxMenu() ) , m_LoadStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Load01, MenuId_State_LoadBackup ) ) , m_SaveStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Save01 ) ) , m_MenuItem_Console( *new wxMenuItem( &m_menuMisc, MenuId_Console, _("Show Console"), wxEmptyString, wxITEM_CHECK ) ) , m_MenuItem_Console_Stdio( *new wxMenuItem( &m_menuMisc, MenuId_Console_Stdio, _("Console to Stdio"), wxEmptyString, wxITEM_CHECK ) ){ m_RestartEmuOnDelete = false; for( int i=0; i<PluginId_Count; ++i ) m_PluginMenuPacks[i].Populate( (PluginsEnum_t)i ); // ------------------------------------------------------------------------ // Initial menubar setup. This needs to be done first so that the menu bar's visible size // can be factored into the window size (which ends up being background+status+menus) //m_menubar.Append( &m_menuBoot, _("&Boot") ); m_menubar.Append( &m_menuSys, _("&System") ); m_menubar.Append( &m_menuCDVD, _("CD&VD") ); m_menubar.Append( &m_menuConfig, _("&Config") ); m_menubar.Append( &m_menuMisc, _("&Misc") );#ifdef PCSX2_DEVBUILD m_menubar.Append( &m_menuDebug, _("&Debug") );#endif SetMenuBar( &m_menubar ); // ------------------------------------------------------------------------ wxSize backsize( m_background.GetSize() ); wxString wintitle; if( PCSX2_isReleaseVersion ) { // stable releases, with a simple title. wintitle.Printf( _("%s %d.%d.%d"), pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo ); } else { // beta / development editions, which feature revision number and compile date. wintitle.Printf( _("%s %d.%d.%d.%d%s (svn) %s"), pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV, SVN_MODS ? L"m" : wxEmptyString, fromUTF8(__DATE__).c_str() ); } SetTitle( wintitle ); // Ideally the __WXMSW__ port should use the embedded IDI_ICON2 icon, because wxWidgets sucks and // loses the transparency information when loading bitmaps into icons. But for some reason // I cannot get it to work despite following various examples to the letter. SetIcons( wxGetApp().GetIconBundle() ); int m_statusbar_widths[] = { (int)(backsize.GetWidth()*0.73), (int)(backsize.GetWidth()*0.25) }; m_statusbar.SetStatusWidths(2, m_statusbar_widths); //m_statusbar.SetStatusText( L"The Status is Good!", 0); m_statusbar.SetStatusText( wxEmptyString, 0); wxBoxSizer& joe( *new wxBoxSizer( wxVERTICAL ) ); joe.Add( &m_background ); SetSizerAndFit( &joe ); // Use default window position if the configured windowpos is invalid (partially offscreen) if( g_Conf->MainGuiPosition == wxDefaultPosition || !pxIsValidWindowPosition( *this, g_Conf->MainGuiPosition) ) g_Conf->MainGuiPosition = GetScreenPosition(); else SetPosition( g_Conf->MainGuiPosition ); // Updating console log positions after the main window has been fitted to its sizer ensures // proper docked positioning, since the main window's size is invalid until after the sizer // has been set/fit. InitLogBoxPosition( g_Conf->ProgLogBox ); // ------------------------------------------------------------------------ // Some of the items in the System menu are configured by the UpdateCoreStatus() method. m_menuSys.Append(MenuId_Boot_CDVD, _("Initializing...")); m_menuSys.Append(MenuId_Boot_CDVD2, _("Initializing...")); m_menuSys.Append(MenuId_Boot_ELF, _("Run ELF..."), _("For running raw PS2 binaries directly"));//.........这里部分代码省略.........
开发者ID:jimmyleith,项目名称:pcsx2,代码行数:101,
示例5: wxPointvoid CSelectMode::OnLeftDown( wxMouseEvent& event ){ button_down_point = wxPoint(event.GetX(), event.GetY()); CurrentPoint = button_down_point; m_button_down = true; m_highlighted_objects.clear(); if(wxGetApp().m_dragging_moves_objects) { MarkedObjectManyOfSame marked_object; wxGetApp().FindMarkedObject(button_down_point, &marked_object); if(marked_object.m_map.size()>0) { HeeksObj* object = marked_object.GetFirstOfTopOnly(); if (event.ShiftDown()) { // Augment the marked_object list with objects that 'look' like // the one selected. CCorrelationTool correlate(wxGetApp().m_min_correlation_factor, wxGetApp().m_max_scale_threshold, wxGetApp().m_number_of_sample_points, wxGetApp().m_correlate_by_color ); std::list<HeeksObj *> similar_objects = correlate.SimilarSymbols( object ); std::list<HeeksObj *>::const_iterator l_itSymbol; for (l_itSymbol = similar_objects.begin(); l_itSymbol != similar_objects.end(); l_itSymbol++) { HeeksObj *ob = *l_itSymbol; if (! wxGetApp().m_marked_list->ObjectMarked(ob)) { wxGetApp().m_marked_list->Add(ob, true); } } // End for } // End if - then while(object) { if(object->GetType() == GripperType) { wxGetApp().m_current_viewport->DrawFront(); wxGetApp().drag_gripper = (Gripper*)object; wxGetApp().m_digitizing->SetOnlyCoords(wxGetApp().drag_gripper, true); wxGetApp().m_digitizing->digitize(button_down_point); wxGetApp().grip_from = wxGetApp().m_digitizing->digitized_point.m_point; wxGetApp().grip_to = wxGetApp().grip_from; double from[3]; from[0] = wxGetApp().grip_from.X(); from[1] = wxGetApp().grip_from.Y(); from[2] = wxGetApp().grip_from.Z(); std::list<HeeksObj*> selected_objects; for(std::list<HeeksObj*>::iterator It = wxGetApp().m_marked_list->list().begin(); It != wxGetApp().m_marked_list->list().end(); It++) { HeeksObj* object = *It; if(object->CanBeDragged())selected_objects.push_back(object); } wxGetApp().drag_gripper->OnGripperGrabbed(selected_objects, true, from); wxGetApp().grip_from = gp_Pnt(from[0], from[1], from[2]); wxGetApp().m_current_viewport->EndDrawFront(); return; } object = marked_object.Increment(); } } }}
开发者ID:CassieMarie,项目名称:heekscad,代码行数:66,
示例6: WXUNUSEDvoid CViewWork::OnWorkAbort( wxCommandEvent& WXUNUSED(event) ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function Begin")); wxInt32 iAnswer = 0; wxString strMessage = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame); CWork* work; int row, n; wxASSERT(pDoc); wxASSERT(pFrame); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame)); wxASSERT(m_pTaskPane); wxASSERT(m_pListPane); if (!pDoc->IsUserAuthorized()) return; n = m_pListPane->GetSelectedItemCount(); if (n == 1) { row = -1; row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (row < 0) return; if (GetWorkCacheAtIndex(work, m_iSortedIndexes[row])) { return; } strMessage.Printf( _("Are you sure you want to abort this task '%s'?/n(Progress: %s, Status: %s)"), (work->m_strName).c_str(), (work->m_strProgress).c_str(), (work->m_strStatus).c_str() ); } else { strMessage.Printf(_("Are you sure you want to abort these %d tasks?"), n); } iAnswer = wxGetApp().SafeMessageBox( strMessage, _("Abort task"), wxYES_NO | wxICON_QUESTION, this ); if (wxYES != iAnswer) { return; } row = -1; while (1) { // Step through all selected items row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (row < 0) break; RESULT* result = pDoc->result(m_iSortedIndexes[row]); if (result) { pDoc->WorkAbort(result->project_url, result->name); } } UpdateSelection(); pFrame->FireRefreshView(); wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function End"));}
开发者ID:DanAurea,项目名称:boinc,代码行数:67,
示例7: wxGetAppvoid CViewWork::UpdateSelection() { int i, n, row; CTaskItemGroup* pGroup = NULL; RESULT* result = NULL; PROJECT* project = NULL; CC_STATUS status; CMainDocument* pDoc = wxGetApp().GetDocument(); std::string first_project_url; wxString strMachineName; bool wasSuspended=false; bool all_same_project=false; bool enableShowGraphics = false; bool enableShowVMConsole = false; bool enableSuspendResume = false; bool enableAbort = false; bool enableProperties = false; wxASSERT(NULL != pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(NULL != m_pTaskPane); CBOINCBaseView::PreUpdateSelection(); pGroup = m_TaskGroups[0]; n = m_pListPane->GetSelectedItemCount(); if (n > 0) { enableShowGraphics = true; enableShowVMConsole = true; enableSuspendResume = true; enableAbort = true; pDoc->GetCoreClientStatus(status); if (status.task_suspend_reason & ~(SUSPEND_REASON_CPU_THROTTLE)) { enableShowGraphics = false; enableShowVMConsole = false; } pDoc->GetConnectedComputerName(strMachineName); if (!pDoc->IsComputerNameLocal(strMachineName)) { enableShowGraphics = false; enableShowVMConsole = false; } } if (pDoc->m_ActiveTasksOnly) { m_pTaskPane->UpdateTask( pGroup->m_Tasks[BTN_ACTIVE_ONLY], _("Show all tasks"), _("Show all tasks.") ); } else { m_pTaskPane->UpdateTask( pGroup->m_Tasks[BTN_ACTIVE_ONLY], _("Show active tasks"), _("Show only active tasks.") ); } row = -1; for (i=0; i<n; i++) { // Step through all selected items row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (row < 0) break; // Should never happen result = pDoc->result(m_iSortedIndexes[row]); if (!result) continue; if (i == 0) { wasSuspended = result->suspended_via_gui; if (result->suspended_via_gui) { m_pTaskPane->UpdateTask( pGroup->m_Tasks[BTN_SUSPEND], _("Resume"), _("Resume work for this task.") ); } else { m_pTaskPane->UpdateTask( pGroup->m_Tasks[BTN_SUSPEND], _("Suspend"), _("Suspend work for this task.") ); } } else { if (wasSuspended != result->suspended_via_gui) { // Disable Suspend / Resume button if the multiple selection // has a mix of suspended and not suspended tasks enableSuspendResume = false; } } // Disable Show VM console if the selected task hasn't registered a remote // desktop connection // if (!strlen(result->remote_desktop_addr)) { enableShowVMConsole = false; } // Disable Show Graphics button if the selected task can't display graphics // if (!strlen(result->web_graphics_url) && !strlen(result->graphics_exec_path)) {//.........这里部分代码省略.........
开发者ID:DanAurea,项目名称:boinc,代码行数:101,
示例8: GetRectvoid CSlideShowPanel::AdvanceSlideShow(bool changeSlide, bool reload) { double xRatio, yRatio, ratio; TaskSelectionData* selData = ((CSimpleTaskPanel*)GetParent())->GetTaskSelectionData(); if (selData == NULL) return; if (reload) { m_bCurrentSlideIsDefault = false; selData->lastSlideShown = -1; } int numSlides = (int)selData->slideShowFileNames.size();#if TESTALLDESCRIPTIONS // For testingnumSlides = 0;#endif if (numSlides <= 0) {#if HIDEDEFAULTSLIDE if (!reload) { return; } wxRect r = GetRect(); wxBitmap backgroundBitmap = ((CSimpleTaskPanel*)GetParent())->GetBackgroundBmp().GetSubBitmap(r); wxWindowDC dc(this); dc.DrawBitmap(backgroundBitmap, 0, 0); // Force redraws if text unchanged; hide all if not in all-projects list m_description->Show(false); Enable( false ); if (!m_bGotAllProjectsList) { CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); pDoc->rpc.get_all_projects_list(m_AllProjectsList); m_bGotAllProjectsList = true; } SetDescriptionText(); return;#else // HIDEDEFAULTSLIDE SetBackgroundColour(*wxBLACK); if (m_bCurrentSlideIsDefault) return; CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); wxASSERT(pSkinSimple); wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple)); m_SlideBitmap = *pSkinSimple->GetWorkunitAnimationImage()->GetBitmap(); if (m_SlideBitmap.Ok()) { m_bCurrentSlideIsDefault = true; }#endif // HIDEDEFAULTSLIDE } else {#if HIDEDEFAULTSLIDE m_description->Show(false); Enable( false );#endif // HIDEDEFAULTSLIDE // TODO: Should we allow slide show to advance if task is not running? int newSlide = selData->lastSlideShown; if (selData->dotColor == runningIcon) { // Advance only if running if (changeSlide) { if (++newSlide >= numSlides) { newSlide = 0; } } } if (newSlide < 0) { newSlide = 0; } if (selData->lastSlideShown != newSlide) { // Don't update if only one slide selData->lastSlideShown = newSlide; wxBitmap *bm = new wxBitmap(); bm->LoadFile(selData->slideShowFileNames[newSlide], wxBITMAP_TYPE_ANY); if (bm->Ok()) { m_SlideBitmap = *bm; delete bm; m_bCurrentSlideIsDefault = false; } } } if (m_SlideBitmap.Ok()) { // Check to see if they need to be rescaled to fit in the window ratio = 1.0; xRatio = (double)SLIDESHOWWIDTH / (double)m_SlideBitmap.GetWidth(); yRatio = (double)SLIDESHOWHEIGHT / (double)m_SlideBitmap.GetHeight(); ratio = xRatio; if ( yRatio < ratio ) { ratio = yRatio; } if ( (ratio < 0.95) || (ratio > 1.05) ) { wxImage img = m_SlideBitmap.ConvertToImage(); img.Rescale((int) (m_SlideBitmap.GetWidth()*ratio), (int) (m_SlideBitmap.GetHeight()*ratio), (ratio > 1.0) ? wxIMAGE_QUALITY_BILINEAR : wxIMAGE_QUALITY_BOX_AVERAGE//.........这里部分代码省略.........
开发者ID:WilliamStilte,项目名称:boinc,代码行数:101,
示例9: wxGetAppvoid CSimpleTaskPanel::UpdatePanel(bool delayShow) { wxString s = wxEmptyString; wxString projName = wxEmptyString; TaskSelectionData *selData; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); int workCount = pDoc->GetSimpleGUIWorkCount(); // Workaround for Linux refresh problem static bool wasDelayed = false;#ifndef __WXMAC__ Freeze();#endif if ((workCount <= 0) || delayShow) { if ((workCount != m_oldWorkCount) || delayShow) { wasDelayed = true; m_myTasksLabel->Hide(); m_TaskSelectionCtrl->Hide(); m_TaskProjectLabel->Hide(); m_TaskProjectName->Hide();#if SELECTBYRESULTNAME m_TaskApplicationName->Hide();#endif // SELECTBYRESULTNAME m_SlideShowArea->Hide(); m_ElapsedTimeValue->Hide(); m_TimeRemainingValue->Hide(); if (m_ipctDoneX1000 >= 0) { m_ipctDoneX1000 = -1; m_ProgressBar->Hide(); } m_ProgressValueText->Hide(); m_TaskCommandsButton->Hide(); this->Layout();#ifdef __WXMAC__ m_ProgressRect = m_ProgressBar->GetRect(); m_ProgressRect.Inflate(0, -2); m_ProgressRect.Offset(0, -2);#endif } DisplayIdleState(); } else { if ((m_oldWorkCount == 0) || wasDelayed) { wasDelayed = false; m_myTasksLabel->Show(); m_TaskSelectionCtrl->Show(); m_TaskProjectLabel->Show(); m_TaskProjectName->Show();#if SELECTBYRESULTNAME m_TaskApplicationName->Show();#endif // SELECTBYRESULTNAME m_SlideShowArea->Show(); m_ElapsedTimeValue->Show(); m_TimeRemainingValue->Show(); m_ProgressBar->Show(); m_ProgressValueText->Show(); m_TaskCommandsButton->Show(); this->Layout(); #ifdef __WXMAC__ m_ProgressRect = m_ProgressBar->GetRect(); m_ProgressRect.Inflate(0, -2); m_ProgressRect.Offset(0, -2);#endif } UpdateTaskSelectionList(false); // We now have valid result pointers, so extract our data int count = m_TaskSelectionCtrl->GetCount(); if (count <= 0) { m_CurrentTaskSelection = -1; } else { if ((m_CurrentTaskSelection < 0) || (m_CurrentTaskSelection > count -1)) { m_TaskSelectionCtrl->SetSelection(0); m_CurrentTaskSelection = 0; m_bStableTaskInfoChanged = true; } selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(m_CurrentTaskSelection); RESULT* result = selData->result; if (result) { if (m_bStableTaskInfoChanged) {#if SELECTBYRESULTNAME wxString str = wxEmptyString; GetApplicationAndProjectNames(result, &s, &projName); str.Printf(_("Application: %s"), s.c_str()); UpdateStaticText(&m_TaskApplicationName, str); UpdateStaticText(&m_TaskProjectName, projName);#else // SELECTBYRESULTNAME GetApplicationAndProjectNames(result, NULL, &projName);#endif // SELECTBYRESULTNAME UpdateStaticText(&m_TaskProjectName, projName); m_SlideShowArea->AdvanceSlideShow(false, true); m_bStableTaskInfoChanged = false; } double f = result->elapsed_time;//.........这里部分代码省略.........
开发者ID:WilliamStilte,项目名称:boinc,代码行数:101,
示例10: LockRead/// Reads the specified data from the aliased file, using libsndfile,/// and converts it to the given sample format./// Copied from PCMAliasBlockFIle but wxLog calls taken out for thread safety////// @param data The buffer to read the sample data into./// @param format The format to convert the data into/// @param start The offset within the block to begin reading/// @param len The number of samples to readint ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, sampleCount start, sampleCount len) const{ LockRead(); SF_INFO info; if(!mAliasedFileName.IsOk()){ // intentionally silenced memset(data,0,SAMPLE_SIZE(format)*len); UnlockRead(); return len; } memset(&info, 0, sizeof(info)); wxString aliasPath = mAliasedFileName.GetFullPath(); wxFile f; // will be closed when it goes out of scope SFFile sf; if (f.Exists(aliasPath) && f.Open(aliasPath)) { // Even though there is an sf_open() that takes a filename, use the one that // takes a file descriptor since wxWidgets can open a file with a Unicode name and // libsndfile can't (under Windows). sf.reset(SFCall<SNDFILE*>(sf_open_fd, f.fd(), SFM_READ, &info, FALSE)); } if (!sf) { memset(data,0,SAMPLE_SIZE(format)*len); mSilentAliasLog = TRUE; // Set a marker to display an error message if (!wxGetApp().ShouldShowMissingAliasedFileWarning()) wxGetApp().MarkAliasedFilesMissingWarning(this); UnlockRead(); return len; } mSilentAliasLog=FALSE; SFCall<sf_count_t>(sf_seek, sf.get(), mAliasStart + start, SEEK_SET); SampleBuffer buffer(len * info.channels, floatSample); int framesRead = 0; if (format == int16Sample && !sf_subtype_more_than_16_bits(info.format)) { // Special case: if the file is in 16-bit (or less) format, // and the calling method wants 16-bit data, go ahead and // read 16-bit data directly. This is a pretty common // case, as most audio files are 16-bit. framesRead = SFCall<sf_count_t>(sf_readf_short, sf.get(), (short *)buffer.ptr(), len); for (int i = 0; i < framesRead; i++) ((short *)data)[i] = ((short *)buffer.ptr())[(info.channels * i) + mAliasChannel]; } else { // Otherwise, let libsndfile handle the conversion and // scaling, and pass us normalized data as floats. We can // then convert to whatever format we want. framesRead = SFCall<sf_count_t>(sf_readf_float, sf.get(), (float *)buffer.ptr(), len); float *bufferPtr = &((float *)buffer.ptr())[mAliasChannel]; CopySamples((samplePtr)bufferPtr, floatSample, (samplePtr)data, format, framesRead, true, info.channels); } UnlockRead(); return framesRead;}
开发者ID:Avi2011class,项目名称:audacity,代码行数:83,
|