コード例 #1
0
ファイル: Project.cpp プロジェクト: tuanmasterit/audacity
AudacityProject *CreateNewAudacityProject(wxWindow * parentWindow)
{
   wxPoint where;
   where.x = 10;
   where.y = 10;

   int width = 600;
   int height = 400;

   if (gWindowedPalette) {
      where.y += 75;
      height -= 75;
   }
#ifdef __WXMAC__
   where.y += 50;
#endif

#ifdef __WXGTK__
   height += 20;
#endif

   where.x += gAudacityDocNum * 25;
   where.y += gAudacityDocNum * 25;

   AudacityProject *p = new AudacityProject(parentWindow, -1,
                                            where, wxSize(width, height));

   p->Show(true);

   gAudacityDocNum = (gAudacityDocNum + 1) % 10;

   SetActiveProject(p);

   return p;
}
コード例 #2
0
ファイル: Project.cpp プロジェクト: tuanmasterit/audacity
void AudacityProject::OnScroll(wxScrollEvent & event)
{
   int hlast = mViewInfo.sbarH;
   int vlast = mViewInfo.vpos;
   int hoffset = 0;
   int voffset = 0;

   mViewInfo.sbarH = mHsbar->GetThumbPosition();

   if (mViewInfo.sbarH != hlast) {
      mViewInfo.h =
          (mViewInfo.sbarH * mViewInfo.scrollStep) / mViewInfo.zoom;
      if (mViewInfo.h > mViewInfo.total - mViewInfo.screen)
         mViewInfo.h = mViewInfo.total - mViewInfo.screen;
      if (mViewInfo.h < 0.0)
         mViewInfo.h = 0.0;
      hoffset = (mViewInfo.sbarH - hlast) * mViewInfo.scrollStep;
   }

   mViewInfo.vpos = mVsbar->GetThumbPosition() * mViewInfo.scrollStep;
   voffset = mViewInfo.vpos - vlast;

   /*
      TODO: add back fast scrolling code

      // Track panel is updated either way, but it is smart and only redraws
      // what is needed
      trackPanel->FastScroll(-hoffset, -voffset);

      // Ruler panel updated if we scroll horizontally
      if (hoffset) {
      REDRAW(rulerPanel);
      }
    */

   SetActiveProject(this);

   if (!mAutoScrolling) {
      mTrackPanel->Refresh(false);
#ifdef __WXMAC__
      mTrackPanel->MacUpdateImmediately();
#endif
   }
}
コード例 #3
0
ファイル: workspace.cpp プロジェクト: capturePointer/codelite
bool clCxxWorkspace::CreateProject(const wxString& name,
                                   const wxString& path,
                                   const wxString& type,
                                   bool addToBuildMatrix,
                                   wxString& errMsg)
{
    if(!m_doc.IsOk()) {
        errMsg = wxT("No workspace open");
        return false;
    }

    ProjectPtr proj(new Project());
    proj->Create(name, wxEmptyString, path, type);
    proj->AssociateToWorkspace(this);
    m_projects[name] = proj;

    // make the project path to be relative to the workspace, if it's sensible to do so
    wxFileName tmp(path + wxFileName::GetPathSeparator() + name + wxT(".project"));
    tmp.MakeRelativeTo(m_fileName.GetPath());

    // Add an entry to the workspace file
    wxXmlNode* node = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("Project"));
    node->AddProperty(wxT("Name"), name);
    node->AddProperty(wxT("Path"), tmp.GetFullPath(wxPATH_UNIX));

    m_doc.GetRoot()->AddChild(node);

    if(m_projects.size() == 1) {
        SetActiveProject(name, true);
    }

    SaveXmlFile();
    if(addToBuildMatrix) {
        AddProjectToBuildMatrix(proj);
    }
    return true;
}
コード例 #4
0
ファイル: Project.cpp プロジェクト: tuanmasterit/audacity
void AudacityProject::OnMouseEvent(wxMouseEvent & event)
{
   if(event.ButtonDown())
      SetActiveProject(this);

   wxPoint hotspot;
   hotspot.x = event.m_x;
   hotspot.y = event.m_y;

   wxPoint mouse = ClientToScreen(hotspot);

   if (event.ButtonDown() && !mDrag &&
       !gWindowedPalette &&
       event.m_x < 10 && event.m_y < GetAPaletteHeight()) {

      int width, height;
      mAPalette->GetSize(&width, &height);

#ifdef __WXMAC__
      /*
         Point startPt;
         startPt.h = hotspot.x;
         startPt.v = hotspot.y;
         Rect limitRect, slopRect, r;
         SetRect(&limitRect, -32767,-32767,32767,32767);
         SetRect(&slopRect, -32767,-32767,32767,32767);
         SetRect(&r, 10, 0, 10+width, height);
         int axis = noConstraint;
         RgnHandle theRgn = NewRgn();
         RectRgn(theRgn, &r);

         int result = DragGrayRgn(theRgn, startPt, &limitRect, &slopRect, axis, NULL);

         if (result == 0x80008000)
         return;

         mouse -= hotspot;
         mouse.x += (short)(result & 0xFFFF);
         mouse.y += (short)((result & 0xFFFF0000)>>16);

         ShowWindowedPalette(&mouse);
       */
#else

      wxClientDC dc(this);

      wxBitmap *bitmap = new wxBitmap(width, height);
      wxMemoryDC *memDC = new wxMemoryDC();
      memDC->SelectObject(*bitmap);
      memDC->Blit(0, 0, width, height, &dc, 10, 0);
      delete memDC;

      mDrag = new wxDragImage(*bitmap);

      delete bitmap;

      mDrag->BeginDrag(hotspot, this, true);
      mDrag->Move(mouse);
      mDrag->Show();
      mPaletteHotspot = hotspot;

#endif
   }
#ifndef __WXMAC__
   if (event.Dragging() && mDrag) {
      mDrag->Move(mouse);
   }

   if (event.ButtonUp() && mDrag) {
      mDrag->Hide();
      mDrag->EndDrag();
      delete mDrag;
      mDrag = NULL;

      mouse -= mPaletteHotspot;
      ShowWindowedPalette(&mouse);
   }
#endif
}
コード例 #5
0
ファイル: Project.cpp プロジェクト: tuanmasterit/audacity
void AudacityProject::OnActivate(wxActivateEvent & event)
{
   SetActiveProject(this);

   event.Skip();
}
コード例 #6
0
ファイル: Project.cpp プロジェクト: ruthmagnus/audacity
void AudacityProject::OnMouseEvent(wxMouseEvent & event)
{

   if (event.ButtonDown())
      SetActiveProject(this);

   wxPoint hotspot;
   hotspot.x = event.m_x;
   hotspot.y = event.m_y;

   wxPoint mouse = ClientToScreen(hotspot);


   //See if we need to drag a toolbar off the window
   if (event.ButtonDown()
       && !mDrag && event.m_x < 10 && event.m_y < mTotalToolBarHeight) {

      //Now, see which toolbar we need to drag
      int h = 0;
      int i = 0;
      while (i < mToolBarArray.GetCount()) {
         h += mToolBarArray[i]->GetHeight() + 1;

         if (event.m_y < h)
            break;
         i++;
      }

      hotspot.y -= h - mToolBarArray[i]->GetHeight();

      if (i >= mToolBarArray.GetCount()) {
         //This shouldn't really happen, except if the click is on
         //the border--which might occur for some platform-specific formatting
      } else {

         int width, height;
         wxSize s = mToolBarArray[i]->GetIdealSize();

         mToolBarArray[i]->GetSize(&width, &height);


         //To enhance performance, these toolbar bitmaps could be pre-loaded
         //Right now, they are not.

         //Only get as much of the toolbar image as the ideal size is
         width = (width > s.x) ? s.x : width;

         wxClientDC dc(this);
         //Make the new bitmap a bit bigger
         wxBitmap *bitmap = new wxBitmap((width+2),(height+2));
         
         wxMemoryDC *memDC = new wxMemoryDC();
         memDC->SelectObject(*bitmap);
      
         //Draw a black box on perimeter
         memDC->SetPen(*wxBLACK_PEN);
         memDC->DrawRectangle(0,0,width+2, height+2);

         //copy an image of the toolbar into the box
         memDC->Blit(1, 1, width, height, &dc, 0, h - height-1);
         delete memDC;

         mDrag = new wxDragImage(*bitmap);

         delete bitmap;

         mDrag->BeginDrag(hotspot, this, true);
         mDrag->Move(mouse - wxPoint(1,2));  //Adjust a little because the bitmap is bigger than the toolbar
         mDrag->Show();
         mToolBarHotspot = hotspot;

         mDraggingToolBar = mToolBarArray[i]->GetType();

      }
   }

   else if (event.Dragging() && mDrag) {

      mDrag->Move(mouse);

   } else if (event.ButtonUp() && mDrag) {


      mDrag->Hide();
      mDrag->EndDrag();
      delete mDrag;
      mDrag = NULL;

      mouse -= mToolBarHotspot;
      switch (mDraggingToolBar) {
      case ControlToolBarID:
         gControlToolBarStub->ShowWindowedToolBar(&mouse);
         gControlToolBarStub->UnloadAll();
         break;
      case EditToolBarID:
         gEditToolBarStub->ShowWindowedToolBar(&mouse);
         gEditToolBarStub->UnloadAll();
         break;

      case NoneID:
      default:
         break;
      }

     
      mDraggingToolBar = NoneID;
      HandleResize();

   }

}
コード例 #7
0
ファイル: workspace.cpp プロジェクト: capturePointer/codelite
bool clCxxWorkspace::RemoveProject(const wxString& name, wxString& errMsg)
{
    ProjectPtr proj = FindProjectByName(name, errMsg);
    if(!proj) {
        return false;
    }

    // remove the associated build configuration with this
    // project
    RemoveProjectFromBuildMatrix(proj);

    // remove the project from the internal map
    std::map<wxString, ProjectPtr>::iterator iter = m_projects.find(proj->GetName());
    if(iter != m_projects.end()) {
        m_projects.erase(iter);
    }

    // update the xml file
    wxXmlNode* root = m_doc.GetRoot();
    wxXmlNode* child = root->GetChildren();
    while(child) {
        if(child->GetName() == wxT("Project") && child->GetPropVal(wxT("Name"), wxEmptyString) == name) {
            if(child->GetPropVal(wxT("Active"), wxEmptyString).CmpNoCase(wxT("Yes")) == 0) {
                // the removed project was active,
                // select new project to be active
                if(!m_projects.empty()) {
                    std::map<wxString, ProjectPtr>::iterator iter = m_projects.begin();
                    SetActiveProject(iter->first, true);
                }
            }
            root->RemoveChild(child);
            delete child;
            break;
        }
        child = child->GetNext();
    }

    // go over the dependencies list of each project and remove the project
    iter = m_projects.begin();
    for(; iter != m_projects.end(); iter++) {
        ProjectPtr p = iter->second;
        if(p) {
            wxArrayString configs;
            // populate the choice control with the list of available configurations for this project
            ProjectSettingsPtr settings = p->GetSettings();
            if(settings) {
                ProjectSettingsCookie cookie;
                BuildConfigPtr bldConf = settings->GetFirstBuildConfiguration(cookie);
                while(bldConf) {
                    configs.Add(bldConf->GetName());
                    bldConf = settings->GetNextBuildConfiguration(cookie);
                }
            }

            // update each configuration of this project
            for(size_t i = 0; i < configs.GetCount(); i++) {

                wxArrayString deps = p->GetDependencies(configs.Item(i));
                int where = deps.Index(name);
                if(where != wxNOT_FOUND) {
                    deps.RemoveAt((size_t)where);
                }

                // update the configuration
                p->SetDependencies(deps, configs.Item(i));
            }
        }
    }
    return SaveXmlFile();
}