示例#1
0
void EditorBase::BasicAddToContextMenu(wxMenu* popup, ModuleType type)
{
    if (type == mtOpenFilesList)
    {
      popup->Append(idCloseMe, _("Close"));
      popup->Append(idCloseAll, _("Close all"));
      popup->Append(idCloseAllOthers, _("Close all others"));
      popup->AppendSeparator();
      popup->Append(idSaveMe, _("Save"));
      popup->Append(idSaveAll, _("Save all"));
      popup->AppendSeparator();
      // enable/disable some items, based on state
      popup->Enable(idSaveMe, GetModified());

      bool hasOthers = ThereAreOthers();
      popup->Enable(idCloseAll, hasOthers);
      popup->Enable(idCloseAllOthers, hasOthers);
    }
    if (type != mtEditorManager) // no editor
    {
        wxMenu* switchto = CreateContextSubMenu(idSwitchTo);
        if (switchto)
            popup->Append(idSwitchTo, _("Switch to"), switchto);
    }
}
void cbEditorPanel::UpdateModified()
{
    if ( GetModified() )
        SetTitle( _T("*") + GetShortName() );
    else
        SetTitle( GetShortName() );
}
示例#3
0
/** Set the Project file of the Image. Can be NULL
  * \param project_file pointer to the Project File. Can be NULL
  * \param preserve_modified boolean indicating if file modification flag should be preserved
  * \return no return value
  */
void XPMEditorBase::SetProjectFile(ProjectFile* project_file, bool preserve_modified)
{
    if (m_pProjectFile == project_file) return;

    bool wasmodified = false;
    if(preserve_modified) wasmodified = GetModified();

    m_pProjectFile = project_file;
    if (m_pProjectFile)
    {
        // update our filename
        m_Filename = UnixFilename(project_file->file.GetFullPath());
        m_pProjectFile->editorOpen = true;

        if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/tab_text_relative"), true))
            m_Shortname = m_pProjectFile->relativeToCommonTopLevelPath;
        else
            m_Shortname = m_pProjectFile->file.GetFullName();
        SetTitle(m_Shortname);

        if (!wxFileExists(m_Filename)) m_pProjectFile->SetFileState(fvsMissing);
        else if (!wxFile::Access(m_Filename.c_str(), wxFile::write)) // readonly
            m_pProjectFile->SetFileState(fvsReadOnly);
    }

    if(preserve_modified) SetModified(wasmodified);
}
示例#4
0
/** Update the Window title with a '*' char if the file is modified
  */
void XPMEditorBase::UpdateModified(void)
{
    if (GetModified())
    {
        SetTitle(_T("*") + GetShortName());
    }
    else
    {
        SetTitle(GetShortName());
    }
}
示例#5
0
/** Save the image
  * Set the modification flag
  * \return true on success, false on failure
  */
bool XPMEditorBase::Save(void)
{
    //save the image
    if (!GetModified()) return(true); //nothing to save


    wxImage img;
    img = GetImage();
    if (!img.IsOk()) return(false); //no bitmap to save

    wxBitmapType bt;
    if (!m_DrawArea) return(false);
    bt = m_DrawArea->GetImageFormat();

    if (!m_bIsFileNameOK) return(SaveAs());

    return(XPM_Plugin()->SaveImage(&img, m_Filename, bt, this));
}
示例#6
0
long CDocCommands::GetCommand(LPCTSTR rstrCommand)
{
	CString strCommand = rstrCommand;
	strCommand.MakeUpper();

	// The return value of this function is a set of bitwise flags about the command
	// Bit 1 = Enabled
	// Bit 2 = Checked
	const long Enable = 1;
	const long Disable = 0;
	const long Checked = 2;
	const long Unchecked = 0;
	long lDocDependent = false;

	DWORD dwResult = 0;
	     if (strCommand == "OPEN")
		dwResult = Enable;
	else if (strCommand == "CLOSE")
		dwResult = lDocDependent;
	else if (strCommand == "GETWIDTH")
		dwResult = GetWidth();
	else if (strCommand == "GETHEIGHT")
		dwResult = GetHeight();
	else if (strCommand == "GETANGLE")
		dwResult = GetAngle();
	else if (strCommand == "GETCROPLEFT")
		dwResult = GetCropLeft();
	else if (strCommand == "GETCROPTOP")
		dwResult = GetCropTop();
	else if (strCommand == "GETCROPRIGHT")
		dwResult = GetCropRight();
	else if (strCommand == "GETCROPBOTTOM")
		dwResult = GetCropBottom();
	else if (strCommand == "GETCANUNDO")
		dwResult = GetCanUndo();
	else if (strCommand == "GETMODIFIED")
		dwResult = GetModified();
	else
		CMessageBox::Message(String("'%s' is not implemented.", strCommand));

	return dwResult;
}
示例#7
0
bool EditorBase::QueryClose()
{
    if ( GetModified() )
    {
        wxString msg;
        msg.Printf(_("File %s is modified...\nDo you want to save the changes?"), GetFilename().c_str());
        switch (cbMessageBox(msg, _("Save file"), wxICON_QUESTION | wxYES_NO | wxCANCEL))
        {
            case wxID_YES:
                if (!Save())
                    return false;
                break;
            case wxID_NO:
                break;
            case wxID_CANCEL:
            default:
                return false;
        }
        SetModified(false);
    }
    return true;
}