Example #1
0
void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
  if (nCount == -1) {
    nCount = m_pTxtBuf->GetTextLength() - nStart;
  }
  int32_t nEnd = nStart + nCount - 1;
  ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength());
  m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
  FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd;
  TextPos2ParagPos(nStart, ParagPosBgn);
  TextPos2ParagPos(nEnd, ParagPosEnd);
  CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPosEnd.nParagIndex];
  FX_BOOL bLastParag = FALSE;
  if (ParagPosEnd.nCharIndex == pParag->GetTextLength() - 1) {
    if (ParagPosEnd.nParagIndex < m_ParagPtrArray.GetSize() - 1) {
      ParagPosEnd.nParagIndex++;
    } else {
      bLastParag = TRUE;
    }
  }
  int32_t nTotalLineCount = 0;
  int32_t nTotalCharCount = 0;
  int32_t i = 0;
  for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) {
    CFDE_TxtEdtParag* pTextParag = m_ParagPtrArray[i];
    pTextParag->CalcLines();
    nTotalLineCount += pTextParag->GetLineCount();
    nTotalCharCount += pTextParag->GetTextLength();
  }
  m_pTxtBuf->Delete(nStart, nCount);
  int32_t nNextParagIndex = (ParagPosBgn.nCharIndex == 0 && bLastParag)
                                ? ParagPosBgn.nParagIndex
                                : (ParagPosBgn.nParagIndex + 1);
  for (i = nNextParagIndex; i <= ParagPosEnd.nParagIndex; i++) {
    delete m_ParagPtrArray[nNextParagIndex];
    m_ParagPtrArray.RemoveAt(nNextParagIndex);
  }
  if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) {
    pParag = m_ParagPtrArray[ParagPosBgn.nParagIndex];
    pParag->SetTextLength(nTotalCharCount - nCount);
    pParag->CalcLines();
    nTotalLineCount -= pParag->GetTextLength();
  }
  int32_t nParagCount = m_ParagPtrArray.GetSize();
  for (i = nNextParagIndex; i < nParagCount; i++)
    m_ParagPtrArray[i]->DecrementStartIndex(nCount);

  m_nLineCount -= nTotalLineCount;
  UpdatePages();
  int32_t nPageCount = CountPages();
  if (m_nCaretPage >= nPageCount) {
    m_nCaretPage = nPageCount - 1;
  }
  m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
}
Example #2
0
void CFDE_TxtEdtEngine::EndLayout() {
  UpdatePages();
  int32_t nLength = GetTextLength();
  if (m_nCaret > nLength) {
    m_nCaret = nLength;
  }
  int32_t nIndex = m_nCaret;
  if (!m_bBefore) {
    nIndex--;
  }
  m_rtCaret.Set(0, 0, 1, m_Param.fFontSize);
  Unlock();
}
Example #3
0
void MyFrame::OnOpenDatabase(wxCommandEvent& WXUNUSED(event))
{


    wxString defaultDir("");
    wxString defaultFile("");

    if (lastDatabasePath.size() > 0) defaultDir = lastDatabasePath;
    if (lastDatabaseFile.size() > 0) defaultFile = lastDatabaseFile;


    wxFileDialog dialog(this, "Choose database file", defaultDir, defaultFile, "*.db", wxFD_OPEN | wxFD_FILE_MUST_EXIST, wxDefaultPosition, wxDefaultSize, "filedlg");

    if (dialog.ShowModal() == wxID_OK)
    {    
        if (tcDatabaseManager::Get()->IsOpen())
        {
            tcDatabaseManager::Get()->Close();
            SetStatusText("Closed database");
        }

        std::string databaseFileName;
        databaseFileName = dialog.GetPath().c_str();

        if (tcDatabaseManager::Get()->Open(databaseFileName))
        {
            UpdatePages();

            wxString fullPath = dialog.GetPath();

            lastDatabasePath = fullPath.BeforeLast('\\');
            lastDatabaseFile = fullPath.AfterLast('\\');


            wxString msg = wxString("Editing ") + fullPath;
            SetStatusText(msg);
        }
        else
        {
            wxMessageBox("Open failed");
        }
    }

}
Example #4
0
//リファレンスページの更新
Help::STATE Help::UpdateReference(void)
{
	int nextPage = m_Page;

	//α値更新
	m_PageAlpha += 10;
	if(m_PageAlpha > 255)
		m_PageAlpha = 255;

	//押されたボタンごとの処理
	switch(UpdatePages())
	{
	case STAY:
		break;
	case PREV:
			nextPage--;
		break;
	case NEXT:
			nextPage++;
		break;
	case BACK:
		m_Index = -1;
		return INDEX;
		break;
	}

	//ページが変われば更新
	if(nextPage != m_Page)
	{
		m_OldPage = m_Page;	//前ページ保存
		m_Page = nextPage;	//次ページ格納
		m_PageAlpha = 0;	//α初期化
	}

	return REFERENCE;
}
Example #5
0
void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
                                     const FX_WCHAR* lpText,
                                     int32_t nLength) {
  ASSERT(nLength > 0);
  FDE_TXTEDTPARAGPOS ParagPos;
  TextPos2ParagPos(nStart, ParagPos);
  m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
  int32_t nParagCount = m_ParagPtrArray.GetSize();
  int32_t i = 0;
  for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++)
    m_ParagPtrArray[i]->IncrementStartIndex(nLength);

  CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
  int32_t nReserveLineCount = pParag->GetLineCount();
  int32_t nReserveCharStart = pParag->GetStartIndex();
  int32_t nLeavePart = ParagPos.nCharIndex;
  int32_t nCutPart = pParag->GetTextLength() - ParagPos.nCharIndex;
  int32_t nTextStart = 0;
  FX_WCHAR wCurChar = L' ';
  const FX_WCHAR* lpPos = lpText;
  FX_BOOL bFirst = TRUE;
  int32_t nParagIndex = ParagPos.nParagIndex;
  for (i = 0; i < nLength; i++, lpPos++) {
    wCurChar = *lpPos;
    if (wCurChar == m_wLineEnd) {
      if (bFirst) {
        pParag->SetTextLength(nLeavePart + (i - nTextStart + 1));
        pParag->SetLineCount(-1);
        nReserveCharStart += pParag->GetTextLength();
        bFirst = FALSE;
      } else {
        pParag = new CFDE_TxtEdtParag(this);
        pParag->SetLineCount(-1);
        pParag->SetTextLength(i - nTextStart + 1);
        pParag->SetStartIndex(nReserveCharStart);
        m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
        nReserveCharStart += pParag->GetTextLength();
      }
      nTextStart = i + 1;
    }
  }
  if (bFirst) {
    pParag->IncrementTextLength(nLength);
    pParag->SetLineCount(-1);
    bFirst = FALSE;
  } else {
    pParag = new CFDE_TxtEdtParag(this);
    pParag->SetLineCount(-1);
    pParag->SetTextLength(nLength - nTextStart + nCutPart);
    pParag->SetStartIndex(nReserveCharStart);
    m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
  }
  m_pTxtBuf->Insert(nStart, lpText, nLength);
  int32_t nTotalLineCount = 0;
  for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) {
    pParag = m_ParagPtrArray[i];
    pParag->CalcLines();
    nTotalLineCount += pParag->GetLineCount();
  }
  m_nLineCount += nTotalLineCount - nReserveLineCount;
  m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
  UpdatePages();
}
Example #6
0
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
	tcGameEngineInit::Init(this);

    SetBackgroundColour(wxColour("white"));

    wxMenu *menuFile = new wxMenu;

    menuFile->Append(ID_OpenDatabase, _T("&Open database"));
    menuFile->Append(ID_SaveDatabase, _T("&Save database"));
    menuFile->AppendSeparator();
    menuFile->Append(ID_About, _T("&About..."));
    menuFile->AppendSeparator();
    menuFile->Append(ID_Quit, _T("E&xit") );

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( menuFile, _T("&File") );


    wxMenu* menuTools = new wxMenu;
    menuTools->Append(ID_CheckForErrors, _T("&Check for errors"));
    menuTools->Append(ID_CheckSetups, _T("Check platform &setups"));
    menuTools->Append(ID_ECMEvaluation, _T("&ECM evaluation"));
    menuBar->Append(menuTools, _T("&Tools"));

    SetMenuBar( menuBar );

    CreateStatusBar();
    SetStatusText( _T("GCB2 dbeditor started") );


    notebook = new wxNotebook(this, NOTEBOOK_ID, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxNB_MULTILINE, "MainNotebook");


    tcBaseViewer* subViewer = new tcBaseViewer(notebook, "sub", "SubViewer");
    subViewer->AddPage("Sub", "config/sub_form.xml");
    subViewer->AddGridPage("Launchers", "config/platform_launcher_grid.xml");
    subViewer->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    subViewer->AddGridPage("Magazines", "config/platform_magazine_grid.xml");
    subViewer->AddSetupPanel("Setup");
    subViewer->AddGridPage("Names", "config/platform_names_grid.xml");
    notebook->AddPage(subViewer, "Sub", true);

    tcBaseViewer* shipViewer = new tcBaseViewer(notebook, "ship", "ShipViewer");
    shipViewer->AddPage("Ship", "config/ship_form.xml");
    shipViewer->AddGridPage("Launchers", "config/platform_launcher_grid.xml");
    shipViewer->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    shipViewer->AddGridPage("Magazines", "config/platform_magazine_grid.xml");
    shipViewer->AddSetupPanel("Setup");
    shipViewer->AddGridPage("Names", "config/platform_names_grid.xml");
    notebook->AddPage(shipViewer, "Ship", true);

    tcBaseViewer* groundViewer = new tcBaseViewer(notebook, "ground", "GroundViewer");
    groundViewer->AddPage("Ground", "config/ground_form.xml");
    groundViewer->AddGridPage("Launchers", "config/platform_launcher_grid.xml");
    groundViewer->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    groundViewer->AddGridPage("Magazines", "config/platform_magazine_grid.xml");
    groundViewer->AddSetupPanel("Setup");
    groundViewer->AddGridPage("Names", "config/platform_names_grid.xml");
    notebook->AddPage(groundViewer, "Ground", true);

    tcBaseViewer* airViewer = new tcBaseViewer(notebook, "air", "AirViewer");
    airViewer->AddPage("Air", "config/air_form.xml");
    airViewer->AddPage("Tables", "config/airtable_form.xml");
    airViewer->AddGridPage("Launchers", "config/platform_launcher_grid.xml");
    airViewer->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    airViewer->AddGridPage("Magazines", "config/platform_magazine_grid.xml");
    airViewer->AddSetupPanel("Setup");
    notebook->AddPage(airViewer, "Air", true);

    tcBaseViewer* simpleairViewer = new tcBaseViewer(notebook, "simpleair", "SimpleAirViewer");
    simpleairViewer->AddPage("SimpleAir", "config/simpleair_form.xml");
    simpleairViewer->AddGridPage("Launchers", "config/platform_launcher_grid.xml");
    simpleairViewer->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    simpleairViewer->AddGridPage("Magazines", "config/platform_magazine_grid.xml");
    simpleairViewer->AddSetupPanel("Setup");
    notebook->AddPage(simpleairViewer, "SimpleAir", true);

    tcBaseViewer* radarViewer = new tcBaseViewer(notebook, "radar", "RadarViewer");
    radarViewer->AddPage("radar", "config/radar_form.xml");
    notebook->AddPage(radarViewer, "Radar", false);

    tcBaseViewer* sonarViewer = new tcBaseViewer(notebook, "sonar", "SonarViewer");
    sonarViewer->AddPage("sonar", "config/sonar_form.xml");
	sonarViewer->AddPage("range calc", "config/sonar_calc_form.xml");
    notebook->AddPage(sonarViewer, "Sonar", false);

    tcBaseViewer* esmViewer = new tcBaseViewer(notebook, "esm", "ESMViewer");
    esmViewer->AddPage("esm", "config/esm_form.xml");
    notebook->AddPage(esmViewer, "ESM", false);

    tcBaseViewer* ecmViewer = new tcBaseViewer(notebook, "ecm", "ECMViewer");
    ecmViewer->AddPage("ecm", "config/ecm_form.xml");
    notebook->AddPage(ecmViewer, "ECM", false);

    tcBaseViewer* optical = new tcBaseViewer(notebook, "optical", "OpticalViewer");
    optical->AddPage("optical", "config/optical_form.xml");
    notebook->AddPage(optical, "Optical", false);

    tcBaseViewer* torpedo = new tcBaseViewer(notebook, "torpedo", "TorpedoViewer");
    torpedo->AddPage("torpedo", "config/torpedo_form.xml");
    notebook->AddPage(torpedo, "Torpedo", false);

    tcBaseViewer* missile = new tcBaseViewer(notebook, "missile", "MissileViewer");
    missile->AddPage("missile", "config/missile_form.xml");
    missile->AddPage("profile", "config/missile_profile_form.xml");
	missile->AddPage("calc", "config/missile_calc_form.xml");
    notebook->AddPage(missile, "Missile", false);

    tcBaseViewer* bmissile = new tcBaseViewer(notebook, "ballistic_missile", "BMissileViewer");
    bmissile->AddPage("ballistic missile", "config/ballisticmissile_form.xml");
    notebook->AddPage(bmissile, "Ballistic Missile", false);

    tcBaseViewer* ballistic = new tcBaseViewer(notebook, "ballistic", "BallisticViewer");
    ballistic->AddPage("ballistic", "config/ballistic_form.xml");
    notebook->AddPage(ballistic, "Ballistic", false);

    tcBaseViewer* launcherConfig = new tcBaseViewer(notebook, "launcher_configuration", "LauncherConfigViewer");
    launcherConfig->AddGridPage("launcher_config", "config/launcher_config_grid.xml");
    notebook->AddPage(launcherConfig, "Launcher Config", false);

    tcBaseViewer* stores = new tcBaseViewer(notebook, "stores", "StoresViewer");
    stores->AddPage("stores", "config/stores_form.xml");
    notebook->AddPage(stores, "Stores", false);

    tcBaseViewer* magazineLoadout = new tcBaseViewer(notebook, "magazine_loadout", "MagazineLoadoutViewer");
    magazineLoadout->AddGridPage("magazine_loadout", "config/magazine_loadout_grid.xml");
    notebook->AddPage(magazineLoadout, "Magazine Loadouts", false);

    tcBaseViewer* airComplement = new tcBaseViewer(notebook, "air_complement", "AirComplementViewer");
    airComplement->AddGridPage("air_complement", "config/air_complement_grid.xml");
    notebook->AddPage(airComplement, "Air Complements", false);

    tcBaseViewer* cm = new tcBaseViewer(notebook, "cm", "CMViewer");
    cm->AddPage("cm", "config/cm_form.xml");
    notebook->AddPage(cm, "CM", false);

    tcBaseViewer* flightport = new tcBaseViewer(notebook, "flightport", "FlightportViewer");
    flightport->AddPage("flightport", "config/flightport_form.xml");
    notebook->AddPage(flightport, "Flightport", false);

    tcBaseViewer* sonobuoy = new tcBaseViewer(notebook, "sonobuoy", "SonobuoyViewer");
    sonobuoy->AddPage("sonobuoy", "config/sonobuoy_form.xml");
    sonobuoy->AddGridPage("Sensors", "config/platform_sensor_grid.xml");
    notebook->AddPage(sonobuoy, "Sonobuoy", false);

    toolPanel = new tcToolPanel(notebook);
    notebook->AddPage(toolPanel, "Import/Export", false);

    LoadConfigFromFile();


    wxString autoOpenPath = lastDatabasePath + wxString("\\") + lastDatabaseFile;
    if (autoOpenPath.size() > 3)
    {
        try
        {
            tcDatabaseManager::Get()->Open(autoOpenPath.ToStdString());
            UpdatePages();
            wxString msg = wxString("Editing ") + autoOpenPath;
            SetStatusText(msg);
        }
        catch (...)
        {
        }
    }

    tcGridPanel::eventFrame = this;

	//wxWindow::bypassEraseBkgnd = false;
}