Ejemplo n.º 1
0
 virtual bool OnDropFiles(
     wxCoord x,
     wxCoord y,
     const wxArrayString& filenames) {
     wxExOpenFiles(m_Frame, filenames);
     return true;
 }
Ejemplo n.º 2
0
void wxExOpenFilesDialog(
    wxExFrame* frame,
    long style,
    const wxString& wildcards,
    bool ask_for_continue,
    long file_flags,
    int dir_flags)
{
    wxExSTC* stc = frame->GetSTC();
    wxArrayString files;

    const wxString caption(_("Select Files"));

    if (stc != NULL)
    {
        wxExFileDialog dlg(frame,
                           &stc->GetFile(),
                           caption,
                           wildcards,
                           style);

        if (ask_for_continue)
        {
            if (dlg.ShowModalIfChanged(true) == wxID_CANCEL) return;
        }
        else
        {
            if (dlg.ShowModal() == wxID_CANCEL) return;
        }

        dlg.GetPaths(files);
    }
    else
    {
        wxFileDialog dlg(frame,
                         caption,
                         wxEmptyString,
                         wxEmptyString,
                         wildcards,
                         style);
        if (dlg.ShowModal() == wxID_CANCEL) return;
        dlg.GetPaths(files);
    }

    wxExOpenFiles(frame, files, file_flags, dir_flags);
}
Ejemplo n.º 3
0
void wxExGenericDirCtrl::OnCommand(wxCommandEvent& event)
{
  wxArrayString files;
  GetPaths(files);
    
  if (event.GetId() > ID_EDIT_VCS_LOWEST && 
      event.GetId() < ID_EDIT_VCS_HIGHEST)
  {
    wxExVCSExecute(m_Frame, event.GetId(), files);
  }
  else if (event.GetId() > ID_TOOL_LOWEST && event.GetId() < ID_TOOL_HIGHEST)
  {
    m_Frame->FindInFiles(files, event.GetId());
  }
  else switch (event.GetId())
  {
  case ID_TREE_COPY: 
    {
    wxBusyCursor wait;
    wxString clipboard;
    for (
#ifdef wxExUSE_CPP0X	
      auto it = files.begin();
#else
      wxArrayString::iterator it = files.begin();
#endif	  
      it != files.end();
      ++it)
    {
      clipboard += *it + wxTextFile::GetEOL();
    }
    wxExClipboardAdd(clipboard);
    }
  break;
  
  case ID_TREE_OPEN: 
    wxExOpenFiles(m_Frame, files, 0, wxDIR_FILES); // only files in this dir
  break;
  
  case ID_TREE_RUN_MAKE: 
    wxExMake(m_Frame, files[0]);
    break;
    
  default: wxFAIL;
  }
}
Ejemplo n.º 4
0
void wxExGenericDirCtrl::OnTree(wxTreeEvent& event)
{
  wxArrayString files;
  GetPaths(files);

  if (files.empty()) 
  {
    event.Skip();
    return;
  }

  if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_MENU)
  {
    const wxExFileName filename(files[0]);
  
    wxExMenu menu; // uses AppendVCS
    
    if (filename.FileExists())
    {
      menu.Append(ID_TREE_OPEN, _("&Open"));
      menu.AppendSeparator();
    }
    
    menu.Append(ID_TREE_COPY,
      wxGetStockLabel(wxID_COPY), wxEmptyString, wxART_COPY);

    if (wxExVCS::DirExists(filename))
    {
      menu.AppendSeparator();
      menu.AppendVCS(filename);
    }

    if (filename.GetLexer().GetScintillaLexer() == "makefile")
    {
      menu.AppendSeparator();
      menu.Append(ID_TREE_RUN_MAKE, "&Make");
    }

    menu.AppendSeparator();
    menu.Append(ID_TOOL_REPORT_FIND, 
      wxExEllipsed(m_Frame->GetFindInCaption(ID_TOOL_REPORT_FIND)));

    menu.Append(ID_TOOL_REPORT_REPLACE, 
      wxExEllipsed(m_Frame->GetFindInCaption(ID_TOOL_REPORT_REPLACE)));
      
    PopupMenu(&menu);
  }
  else if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_ACTIVATED)
  {
    const wxFileName fn(files[0]);
    
    if (!fn.FileExists() && fn.DirExists())
    {
      if (!GetTreeCtrl()->IsExpanded(event.GetItem()))
      {
        ExpandAndSelectPath(files[0]);
      }
      else
      {
        CollapsePath(files[0]);
      }
    }
    else
    {
      wxExOpenFiles(m_Frame, files, 0, wxDIR_FILES); // only files in this dir
    }
  }
  else if (event.GetEventType() ==  wxEVT_COMMAND_TREE_SEL_CHANGED)
  {
    wxExLogStatus(wxFileName(files[0]), STAT_FULLPATH);
  }
  else
  {
    wxFAIL;
  }
}
Ejemplo n.º 5
0
void wxExFrame::OnCommand(wxCommandEvent& command)
{
    m_IsCommand = true;

    switch (command.GetId())
    {
    case wxID_FIND:
    {
        if (m_FindReplaceDialog != NULL)
        {
            m_FindReplaceDialog->Destroy();
        }

        m_FindFocus = wxWindow::FindFocus();

        // If stc text is selected, copy to find replace data.
        wxExSTC* stc = GetSTC();

        if (stc != NULL)
        {
            stc->GetFindString();
        }

        m_FindReplaceDialog = new wxFindReplaceDialog(
            this, wxExFindReplaceData::Get(), _("Find"));
        m_FindReplaceDialog->Show();
    }
    break;

    case wxID_REPLACE:
    {
        if (m_FindReplaceDialog != NULL)
        {
            m_FindReplaceDialog->Destroy();
        }

        m_FindFocus = wxWindow::FindFocus();

        // If stc text is selected, copy to find replace data.
        wxExSTC* stc = GetSTC();

        if (stc != NULL)
        {
            stc->GetFindString();
        }

        m_FindReplaceDialog = new wxFindReplaceDialog(
            this,
            wxExFindReplaceData::Get(),
            _("Replace"),
            wxFR_REPLACEDIALOG);
        m_FindReplaceDialog->Show();
    }
    break;

    case wxID_OPEN:
        if (!command.GetString().empty())
        {
            wxExSTC* stc = GetSTC();

            if (stc != NULL)
            {
                wxSetWorkingDirectory(stc->GetFileName().GetPath());
            }

            wxArrayString files;
            wxStringTokenizer tkz(command.GetString());

            while (tkz.HasMoreTokens())
            {
                files.Add(tkz.GetNextToken());
            }

            wxExOpenFiles(this, files);
        }
        else
        {
            wxExOpenFilesDialog(this);
        }
        break;

    case ID_VIEW_MENUBAR:
        if (GetMenuBar() != NULL)
        {
            SetMenuBar(NULL);
        }
        else
        {
            SetMenuBar(m_MenuBar);
        }
        break;

    case ID_VIEW_STATUSBAR:
#if wxUSE_STATUSBAR
        if (GetStatusBar() != NULL)
        {
            GetStatusBar()->Show(!GetStatusBar()->IsShown());
            SendSizeEvent();
        }
#endif
        break;

    case ID_VIEW_TITLEBAR:
        if (!(GetWindowStyleFlag() & wxCAPTION))
        {
            SetWindowStyleFlag(wxDEFAULT_FRAME_STYLE);
            Refresh();
        }
        else
        {
            SetWindowStyleFlag(GetWindowStyleFlag() & ~wxCAPTION);
            Refresh();
        }
        break;

    default:
        wxFAIL;
        break;
    }
}