<commit_before>/******************************************************************************\
* File:          appl.cpp
* Purpose:       Implementation of sample classes for wxFileTool
* Author:        <NAME>
* RCS-ID:        $Id$
*
* Copyright (c) 1998-2009, <NAME>
* All rights are reserved. Reproduction in whole or part is prohibited
* without the written consent of the copyright owner.
\******************************************************************************/

#ifndef __WXMSW__
  #include "mondrian.xpm"
#endif

#include <wx/aboutdlg.h>
#include <wx/stdpaths.h> // for wxStandardPaths
#include <wx/filetool/filetool.h>
#include <wx/filetool/process.h>
#include "appl.h"

enum
{
  ID_PROCESS_DIALOG,
  ID_PROCESS_RUN,
  ID_RECENTFILE_MENU,
};

BEGIN_EVENT_TABLE(ftSampleFrame, ftFrame)
  EVT_MENU(ID_PROCESS_DIALOG, ftSampleFrame::OnCommand)
  EVT_MENU(ID_PROCESS_RUN, ftSampleFrame::OnCommand)
  EVT_MENU_RANGE(wxID_LOWEST, wxID_HIGHEST, ftSampleFrame::OnCommand)
  EVT_TREE_ITEM_ACTIVATED(wxID_TREECTRL, ftSampleFrame::OnTree)
END_EVENT_TABLE()

IMPLEMENT_APP(ftSampleApp)

bool ftSampleApp::OnInit()
{
  SetAppName("ftSample");
  SetLogging();

  exApp::OnInit();

  ftSampleFrame *frame = new ftSampleFrame("ftSample");

  frame->Show(true);

  SetTopWindow(frame);

  return true;
}

ftSampleFrame::ftSampleFrame(const wxString& title)
  : ftFrame(NULL, wxID_ANY, title)
{
  SetIcon(wxICON(mondrian));

  exMenu *menuFile = new exMenu;
  menuFile->Append(wxID_OPEN);
  UseFileHistory(ID_RECENTFILE_MENU, menuFile);
  menuFile->AppendSeparator();
  menuFile->AppendPrint();
  menuFile->AppendSeparator();
  menuFile->Append(wxID_EXIT);

  exMenu *menuProcess = new exMenu;
  menuProcess->Append(ID_PROCESS_DIALOG, exEllipsed(_("Dialog")));
  menuProcess->Append(ID_PROCESS_RUN, _("Run"));
  menuProcess->AppendSeparator();
  menuProcess->Append(wxID_STOP);
  
  exMenu* menuHelp = new exMenu;
  menuHelp->Append(wxID_ABOUT);

  wxMenuBar *menubar = new wxMenuBar;
  menubar->Append(menuFile, _("&File"));
  menubar->Append(menuProcess, _("&Process"));
  menubar->Append(menuHelp, _("&Help"));
  SetMenuBar(menubar);

  CreateToolBar();

  m_ToolBar->AddTool(wxID_OPEN);
  m_ToolBar->Realize();

  std::vector<exPane> panes;
  panes.push_back(exPane("PaneText", -3));
  panes.push_back(exPane("PaneFileType", 50));
  panes.push_back(exPane("PaneLines", 100));
  panes.push_back(exPane("PaneLexer", 60));
  panes.push_back(exPane("PaneItems", 60));
  SetupStatusBar(panes);

  const exLexer lexer = exApp::GetLexers()->FindByName("cpp");

  m_DirCtrl = new wxGenericDirCtrl(this, wxID_ANY, wxStandardPaths::Get().GetDocumentsDir());

  m_NotebookWithLists = new exNotebook(
    this, this,
    wxID_ANY, wxDefaultPosition, wxDefaultSize,
    wxAUI_NB_DEFAULT_STYLE | 
    wxAUI_NB_WINDOWLIST_BUTTON);
  ftFindToolBar* findbar = new ftFindToolBar(this, this);

  m_STC = new ftSTC(this); // use all flags (default)

  for (
    int i = ftListView::LIST_BEFORE_FIRST + 1;
    i < ftListView::LIST_AFTER_LAST;
    i++)
  {
    ftListView* vw = new ftListView(this, (ftListView::ftListType)i, 0xFF, &lexer); // set all flags
    m_NotebookWithLists->AddPage(vw, vw->GetTypeDescription(), vw->GetTypeDescription(), true);
  }

  GetManager().AddPane(m_STC, wxAuiPaneInfo().CenterPane().CloseButton(false).MaximizeButton(true));
  GetManager().AddPane(m_NotebookWithLists, wxAuiPaneInfo().CloseButton(false).Bottom().MinSize(wxSize(250, 250)));
  GetManager().AddPane(m_DirCtrl, wxAuiPaneInfo().Caption(_("DirCtrl")).Left().MinSize(wxSize(250, 250)));
  GetManager().AddPane(findbar,
    wxAuiPaneInfo().ToolbarPane().Bottom().Name("FINDBAR").Caption(_("Findbar")));

  GetManager().Update();

  ftDir dir(
    (ftListView*)m_NotebookWithLists->GetPageByKey(
      ftListView::GetTypeDescription(ftListView::LIST_PROJECT)),
    wxGetCwd(), 
    "*.cpp;*.h");

  dir.FindFiles();

  ftListItem item(
    (ftListView*)m_NotebookWithLists->GetPageByKey(
      ftListView::GetTypeDescription(ftListView::LIST_PROJECT)), 
    "NOT EXISTING ITEM");

  item.Insert();
}

ftListView* ftSampleFrame::Activate(int type, const exLexer* lexer)
{
  for (
    std::map<wxString, wxWindow*>::const_iterator it = m_NotebookWithLists->GetMapPages().begin();
    it != m_NotebookWithLists->GetMapPages().end();
    ++it)
  {
    ftListView* vw = (ftListView*)it->second;

    if (vw->GetType() == type)
    {
      if (type == ftListView::LIST_KEYWORD)
      {
        if (lexer != NULL)
        {
          if (lexer->GetScintillaLexer() != "cpp")
          {
            wxLogMessage(lexer->GetScintillaLexer() + ", only cpp for the sample");
            return NULL;
          }
        }
      }

      return vw;
    }
  }

  return NULL;
}
<commit_msg>sample no longer uses the map pages<commit_after>/******************************************************************************\
* File:          appl.cpp
* Purpose:       Implementation of sample classes for wxFileTool
* Author:        <NAME>
* RCS-ID:        $Id$
*
* Copyright (c) 1998-2009, <NAME>
* All rights are reserved. Reproduction in whole or part is prohibited
* without the written consent of the copyright owner.
\******************************************************************************/

#ifndef __WXMSW__
  #include "mondrian.xpm"
#endif

#include <wx/aboutdlg.h>
#include <wx/stdpaths.h> // for wxStandardPaths
#include <wx/filetool/filetool.h>
#include <wx/filetool/process.h>
#include "appl.h"

enum
{
  ID_PROCESS_DIALOG,
  ID_PROCESS_RUN,
  ID_RECENTFILE_MENU,
};

BEGIN_EVENT_TABLE(ftSampleFrame, ftFrame)
  EVT_MENU(ID_PROCESS_DIALOG, ftSampleFrame::OnCommand)
  EVT_MENU(ID_PROCESS_RUN, ftSampleFrame::OnCommand)
  EVT_MENU_RANGE(wxID_LOWEST, wxID_HIGHEST, ftSampleFrame::OnCommand)
  EVT_TREE_ITEM_ACTIVATED(wxID_TREECTRL, ftSampleFrame::OnTree)
END_EVENT_TABLE()

IMPLEMENT_APP(ftSampleApp)

bool ftSampleApp::OnInit()
{
  SetAppName("ftSample");
  SetLogging();

  exApp::OnInit();

  ftSampleFrame *frame = new ftSampleFrame("ftSample");

  frame->Show(true);

  SetTopWindow(frame);

  return true;
}

ftSampleFrame::ftSampleFrame(const wxString& title)
  : ftFrame(NULL, wxID_ANY, title)
{
  SetIcon(wxICON(mondrian));

  exMenu *menuFile = new exMenu;
  menuFile->Append(wxID_OPEN);
  UseFileHistory(ID_RECENTFILE_MENU, menuFile);
  menuFile->AppendSeparator();
  menuFile->AppendPrint();
  menuFile->AppendSeparator();
  menuFile->Append(wxID_EXIT);

  exMenu *menuProcess = new exMenu;
  menuProcess->Append(ID_PROCESS_DIALOG, exEllipsed(_("Dialog")));
  menuProcess->Append(ID_PROCESS_RUN, _("Run"));
  menuProcess->AppendSeparator();
  menuProcess->Append(wxID_STOP);
  
  exMenu* menuHelp = new exMenu;
  menuHelp->Append(wxID_ABOUT);

  wxMenuBar *menubar = new wxMenuBar;
  menubar->Append(menuFile, _("&File"));
  menubar->Append(menuProcess, _("&Process"));
  menubar->Append(menuHelp, _("&Help"));
  SetMenuBar(menubar);

  CreateToolBar();

  m_ToolBar->AddTool(wxID_OPEN);
  m_ToolBar->Realize();

  std::vector<exPane> panes;
  panes.push_back(exPane("PaneText", -3));
  panes.push_back(exPane("PaneFileType", 50));
  panes.push_back(exPane("PaneLines", 100));
  panes.push_back(exPane("PaneLexer", 60));
  panes.push_back(exPane("PaneItems", 60));
  SetupStatusBar(panes);

  const exLexer lexer = exApp::GetLexers()->FindByName("cpp");

  m_DirCtrl = new wxGenericDirCtrl(this, wxID_ANY, wxStandardPaths::Get().GetDocumentsDir());

  m_NotebookWithLists = new exNotebook(
    this, this,
    wxID_ANY, wxDefaultPosition, wxDefaultSize,
    wxAUI_NB_DEFAULT_STYLE | 
    wxAUI_NB_WINDOWLIST_BUTTON);
  ftFindToolBar* findbar = new ftFindToolBar(this, this);

  m_STC = new ftSTC(this); // use all flags (default)

  for (
    int i = ftListView::LIST_BEFORE_FIRST + 1;
    i < ftListView::LIST_AFTER_LAST;
    i++)
  {
    ftListView* vw = new ftListView(this, (ftListView::ftListType)i, 0xFF, &lexer); // set all flags
    m_NotebookWithLists->AddPage(vw, vw->GetTypeDescription(), vw->GetTypeDescription(), true);
  }

  GetManager().AddPane(m_STC, wxAuiPaneInfo().CenterPane().CloseButton(false).MaximizeButton(true));
  GetManager().AddPane(m_NotebookWithLists, wxAuiPaneInfo().CloseButton(false).Bottom().MinSize(wxSize(250, 250)));
  GetManager().AddPane(m_DirCtrl, wxAuiPaneInfo().Caption(_("DirCtrl")).Left().MinSize(wxSize(250, 250)));
  GetManager().AddPane(findbar,
    wxAuiPaneInfo().ToolbarPane().Bottom().Name("FINDBAR").Caption(_("Findbar")));

  GetManager().Update();

  ftDir dir(
    (ftListView*)m_NotebookWithLists->GetPageByKey(
      ftListView::GetTypeDescription(ftListView::LIST_PROJECT)),
    wxGetCwd(), 
    "*.cpp;*.h");

  dir.FindFiles();

  ftListItem item(
    (ftListView*)m_NotebookWithLists->GetPageByKey(
      ftListView::GetTypeDescription(ftListView::LIST_PROJECT)), 
    "NOT EXISTING ITEM");

  item.Insert();
}

ftListView* ftSampleFrame::Activate(int type, const exLexer* lexer)
{
  for (
    size_t i = 0;
    i < m_NotebookWithLists->GetPageCount();
    i++)
  {
    ftListView* vw = (ftListView*)m_NotebookWithLists->GetPage(i);

    if (vw->GetType() == type)
    {
      if (type == ftListView::LIST_KEYWORD)
      {
        if (lexer != NULL)
        {
          if (lexer->GetScintillaLexer() != "cpp")
          {
            wxLogMessage(lexer->GetScintillaLexer() + ", only cpp for the sample");
            return NULL;
          }
        }
      }

      return vw;
    }
  }

  return NULL;
}

{'fraction_non_alphanumeric': 0.1750211505922166, 'fraction_numerical': 0.006873942470389171, 'mean_word_length': 4.805402087170043, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4634967', 'n_tokens_mistral': 3491, 'n_tokens_neox': 3299, 'n_words': 533}