Ejemplo n.º 1
0
/*!
 * \brief Open an existing document.
 *
 */
bool CNutConfDoc::OnOpenDocument(const wxString & filename)
{
    /*
     * Check if the current document has been modified.
     */
    if (!OnSaveModified())
        return false;

    SetFilename(filename, true);
    Modify(false);
    UpdateAllViews();

    return true;
}
Ejemplo n.º 2
0
HttpGetSocket::HttpGetSocket(ISocketHandler& h,const std::string& url_in,const std::string& to_file) : HttpClientSocket(h, url_in)
{
	if (to_file.size())
	{
		SetFilename(to_file);
	}
	if (!Open(GetUrlHost(),GetUrlPort()))
	{
		if (!Connecting())
		{
			Handler().LogError(this, "HttpGetSocket", -1, "connect() failed miserably", LOG_LEVEL_FATAL);
			SetCloseAndDelete();
		}
	}
}
Ejemplo n.º 3
0
void LLDBBreakpoint::FromJSON(const JSONElement& json)
{
    m_children.clear();
    m_id = json.namedObject("m_id").toInt(wxNOT_FOUND);
    m_type = json.namedObject("m_type").toInt(kInvalid);
    m_name = json.namedObject("m_name").toString();
    SetFilename(json.namedObject("m_filename").toString());
    m_lineNumber = json.namedObject("m_lineNumber").toInt();
    JSONElement arr = json.namedObject("m_children");
    for(int i=0; i<arr.arraySize(); ++i) {
        LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint() );
        bp->FromJSON( arr.arrayItem(i) );
        m_children.push_back( bp );
    }
}
Ejemplo n.º 4
0
//! Constructor.
SkinnedModel::SkinnedModel()
{
	SetFilename("#NOVALUE");
	mAnimator = nullptr;
	mElapsedTime = 0.0f;

	AddAnimation(0, 37, 662, 20);
	AddAnimation(38, 83, 662, 20);
	AddAnimation(84, 264, 662, 20);
	AddAnimation(265, 445, 662, 20);
	AddAnimation(446, 491, 662, 20);
	AddAnimation(492, 537, 662, 20);
	AddAnimation(538, 553, 662, 20);
	AddAnimation(554, 662, 662, 20);
}
void CQueueEntry::InternalizeL( RReadStream& aStream )
    {
    TInt size;
    RBuf text;
	CleanupClosePushL( text );
    RBuf8 text8;
	CleanupClosePushL( text8 );

    size =  aStream.ReadInt32L( );
    text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetUrlL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetTitleL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetTagsL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetDescriptionL( text );

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetFilename( text );

	CleanupStack::PopAndDestroy( &text8 );
	CleanupStack::PopAndDestroy( &text );
    
    iType = (TEntryType) aStream.ReadInt32L( );

	iStatus = (TEntryStatus) aStream.ReadInt32L( );

	iCategory = (TMovieCategory) aStream.ReadInt32L( );

	iPublic = aStream.ReadInt32L( );
		
	iSize = aStream.ReadInt32L( );

	iUid = aStream.ReadInt32L( );
    }
Ejemplo n.º 6
0
HttpGetSocket::HttpGetSocket(ISocketHandler& h,const std::string& host,port_t port,const std::string& url,const std::string& to_file) : HttpClientSocket(h)
{
	SetUrl(url);
	if (to_file.size())
	{
		SetFilename(to_file);
	}
	if (!Open(host, port))
	{
		if (!Connecting())
		{
			Handler().LogError(this, "HttpGetSocket", -1, "connect() failed miserably", LOG_LEVEL_FATAL);
			SetCloseAndDelete();
		}
	}
}
Ejemplo n.º 7
0
/*!
 * \brief Save the config file.
 *
 * \param filename Name of the config file including path.
 *
 * \return true on success, otherwise false is returned.
 */
bool CNutConfDoc::OnSaveDocument(const wxString& filename)
{
    if (filename.IsEmpty()) {
        return false;
    }

    FILE *fp = fopen(filename.mb_str(), "w");
    if (fp) {
        SaveComponentOptions(fp, m_root->nc_child);
        fclose(fp);
        Modify(false);
        SetFilename(filename);
        return true;
    }
    return false;
}
Ejemplo n.º 8
0
void
SiloDumpAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SiloDumpAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("filename")) != 0)
        SetFilename(node->AsString());
    if((node = searchNode->GetNode("display")) != 0)
        SetDisplay(node->AsBool());
}
bool wxJigsawEditorDocument::OnOpenDocument(const wxString& filename)
{
	wxLogTrace(wxTraceMask(), wxT("wxJigsawEditorDocument::OnOpenDocument"));
    do
	{
		m_XmlIO.DeserializeFromXml(filename);

		SetFilename(filename, true);
		Modify(false);
		m_Diagram->UpdateParents();
		//UpdateAllViews();
		//return true;
		break;
	}
	while(false);
    return true;
}
Ejemplo n.º 10
0
bool wxGenericFileCtrl::SetPath( const wxString& path )
{
    if ( !wxFileName::FileExists( ( path ) ) )
        return false;

    wxString ext;
    wxFileName::SplitPath( path, &m_dir, &m_fileName, &ext );
    if ( !ext.empty() )
    {
        m_fileName += wxT( "." );
        m_fileName += ext;
    }

    SetDirectory( m_dir );
    SetFilename( m_fileName );

    return true;
}
Ejemplo n.º 11
0
void MERGE::SignalSource::ParseParameters()
{
    SourceParametersT params = GetSourceParameters();

    if (params.size() != Parameters::SOURCE_PARAM_N)
    {
        throw std::runtime_error("Invalid number of source parameters: " + m_SourceDescription);
    }
    else
    {
        SetFormat(params[Parameters::LOG_FORMAT]);
        SetSyncPoint(params[Parameters::SYNC_POINT]);
        SetTimeUnit(params[Parameters::TIME_UNIT]);
        SetPrefix(params[Parameters::PREFIX]);
        SetCounterName(params[Parameters::LINE_COUNTER]);
        SetFilename(params[Parameters::FILENAME]);
    }
}
Ejemplo n.º 12
0
/**	Opens a file
 *
 *	@param filename	The name of the file to open
 *	@param create		Whether to create a non-existant file or return false
 *
 *	@returns boolean true or false, depending on whether was able to open
 *
 *	Operation:
 *		-#	The filename will be preceeded by "file://" so move the filename 
 *				pointer forward, past the vfs specific section of the file, and 
 *				to the actual filename itself e.g. file://image.jpg => image.jpg
 *		-#	Opens a filestream with read/write capabilities in binary mode
 *		-#	Sets the handles filename
 *		-#	Attempts to open the file
 *		-#	If successful, calculates the length of the file
 *		-#	returns whether the file was opened successfully
 *
 *	@todo	Add functionality to decide whether to create a new file, if the file requested does not exist
 */
bool VFSHandle_file::Open(std::string filename, bool create )
{
	SetFilename( filename );

	if ( IsFile( m_filename ) == false && create == true ) Createfile( m_filename );

	if ( IsFile( m_filename ) == true )
	{
		m_stream.clear();
		m_stream.open( m_filename.c_str(), std::ios::in | std::ios::out | std::ios::binary );

		Length();

		return ( bool ) m_stream.is_open();
	}

	return false;
}
Ejemplo n.º 13
0
bool VDialogResource::Parse(TiXmlElement *pNode, const char *szPath)
{
  if (!IVMenuSystemResource::Parse(pNode,szPath))
    return false;

  // creates a clone of the dialog XML node
  V_SAFE_DELETE(m_pXMLNode);
  m_pXMLNode = pNode->Clone()->ToElement();

  // since we need the path for creating the items later (GetFilePath), we create a dummy filename
  // that contains the path
  if (!GetFilename())
  {
    char szDummyName[FS_MAX_PATH];
    VFileHelper::CombineDirAndFile(szDummyName,szPath,"<XMLFile>");
    SetFilename(szDummyName);
  }
  return true;
}
Ejemplo n.º 14
0
ImportDialogFileWidget::ImportDialogFileWidget(uint32 id, QWidget *parent)
:	QWidget(parent)
,	ui(new Ui::ImportDialogFileWidget)
,	id(id)
,	activeAction(ImportDialog::ACTION_IGNORE)
,	neverShowSizeWidget(false)
,	showUpperIcons(false)
{
	ui->setupUi(this);
	ui->resetToParentButton->setIcon(QIcon(IconHelper::GetIgnoreIconPath()));
	ui->upperIgnoreIcon->setPixmap(QIcon(IconHelper::GetIgnoreIconPath()).pixmap(16, 16));
	ui->upperScreenIcon->setPixmap(QIcon(IconHelper::GetScreenIconPath()).pixmap(16, 16));
	ui->upperAggregatorIcon->setPixmap(QIcon(IconHelper::GetAggregatorIconPath()).pixmap(16, 16));

	UpdateState(ImportDialog::ACTION_IGNORE);
	SetFilename("");

	ui->actionButtons->setId(ui->ignoreRadioButton, ImportDialog::ACTION_IGNORE);
	ui->actionButtons->setId(ui->screenRadioButton, ImportDialog::ACTION_SCREEN);
	ui->actionButtons->setId(ui->aggregatorRadioButton, ImportDialog::ACTION_AGGREGATOR);

	connect(ui->actionButtons, SIGNAL(buttonClicked(int)), this, SLOT(UpdateState(int)));
	connect(ui->resetToParentButton, SIGNAL(clicked()), this, SLOT(ResetAggregatorSize()));
	connect(ui->aggregatorWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnSizeChanged()));
	connect(ui->aggregatorHeightSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnSizeChanged()));

	QColor color;
	if (id % 2 == 0)
	{
		color = EVEN_COLOR;
	}
	else
	{
		color = ODD_COLOR;
	}

	QPalette pal(palette());
	pal.setColor(QPalette::Background, color);
	setAutoFillBackground(true);
	setPalette(pal);

	UpdateState(activeAction);
}
Ejemplo n.º 15
0
// =============================================================================
void LogBuffer::Load( PvConfigurationReader &aReader )
{
    PvResult lResult;
    PvString lPvStr;

	// Always load from a blank setup!
	ResetConfig();

	// bool mGenICamEnabled;
    lResult = aReader.Restore( TAG_GENICAMENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mGenICamEnabled = ( lPvStr == VAL_TRUE );
    }

	// bool mBufferAllEnabled;
    lResult = aReader.Restore( TAG_BUFFERALLENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mBufferAllEnabled = ( lPvStr == VAL_TRUE );
    }

	// bool mBufferErrorEnabled;
    lResult = aReader.Restore( TAG_BUFFERERRORENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        mBufferErrorEnabled = ( lPvStr == VAL_TRUE );
    }

	// QString mFilename;
    lResult = aReader.Restore( TAG_LOGFILENAME, lPvStr );
    if ( lResult.IsOK() )
	{
		SetFilename( lPvStr.GetAscii() );
	}

	// bool mWriteToFileEnabled;
    lResult = aReader.Restore( TAG_WRITETOFILEENABLED, lPvStr );
    if ( lResult.IsOK() )
    {
        SetWriteToFileEnabled( lPvStr == VAL_TRUE );
    }
}
Ejemplo n.º 16
0
bool wxGenericFileCtrl::SetPath( const wxString& path )
{
    wxString dir, fn, ext;
    wxFileName::SplitPath(path, &dir, &fn, &ext);

    if ( !dir.empty() && !wxFileName::DirExists(dir) )
        return false;

    m_dir = dir;
    m_fileName = fn;
    if ( !ext.empty() || path.Last() == '.' )
    {
        m_fileName += wxT( "." );
        m_fileName += ext;
    }

    SetDirectory( m_dir );
    SetFilename( m_fileName );

    return true;
}
Ejemplo n.º 17
0
/** Constructor
  * \param parent    a pointer to the parent window
  * \param title     the title which will appear in the tab
  * \param bitmap    a pointer to the Bitmap to display. Can be NULL
  * \param sFileName the filename associated to the editor. Can be empty
  */
XPMEditorBase::XPMEditorBase(wxWindow* parent, const wxString& title,wxImage *img, wxString sFileName, wxBitmapType bt)
    :EditorBase(parent,title)
{
    //constructor
    Freeze();

    //initialisation code
    m_bModified = false;
    m_bReadOnly = false;
    SetFilename(sFileName);
    if (m_Filename == wxEmptyString) m_bIsFileNameOK = false; else m_bIsFileNameOK = true;

    m_DrawArea = new XPMEditorPanel(this);

    //project file
    m_pProjectFile = NULL;

    //sizing & refreshing
    wxSize s;
    s = GetClientSize();
    m_DrawArea->SetSize(0,0,s.GetWidth(),s.GetHeight(), 0);
    Refresh();
    Update();

    Connect(wxEVT_SIZE,(wxObjectEventFunction)&XPMEditorBase::OnResize);

    //editors set
    m_AllEditors.insert( this );

    //get the configuration
    UpdateConfiguration();
    if (m_DrawArea)
    {
        m_DrawArea->SetImage(img);
        m_DrawArea->SetImageFormat(bt); //default behaviour : autodetection using file extension
    }

    Thaw();

}
Ejemplo n.º 18
0
Archivo: doc.cpp Proyecto: EdgarTx/wx
bool csDiagramDocument::OnSaveDocument(const wxString& file)
{
  if (file == wxEmptyString)
    return false;

  if (!m_diagram.SaveFile(file))
  {
    wxString msgTitle;
    if (wxTheApp->GetAppName() != wxEmptyString)
        msgTitle = wxTheApp->GetAppName();
    else
        msgTitle = wxString(_T("File error"));

    (void)wxMessageBox(_T("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
      GetDocumentWindow());
    return false;
  }

  Modify(false);
  SetFilename(file);
  return true;
}
Ejemplo n.º 19
0
bool U2FrameXmlParser::OpenXml()
{
	U2ASSERT(!m_pXmlDoc);

	// Get FullPath
	m_pXmlDoc = new TiXmlDocument;

	SetFilename(m_pOwnerFrame->GetFilename());

	if(m_pXmlDoc->LoadFile(m_szFullPath.Str()))
	{
		TiXmlHandle docHandle(m_pXmlDoc);
		TiXmlElement* pFrameXmlElem = docHandle.FirstChildElement("Frame").Element();
		U2ASSERT(pFrameXmlElem);
		m_pOwnerFrame->SetName(pFrameXmlElem->Attribute("name"));
		//m_pOwnerFrame->SetShaderPath
		return true;
	}
	delete (m_pXmlDoc);
	m_pXmlDoc = NULL;
	return false;
}
Ejemplo n.º 20
0
/*!
 * \brief Create a document from a specified file.
 *
 * \param path Pathname of the configuration file.
 */
bool CNutConfDoc::OnCreate(const wxString & path, long flags)
{
    bool rc = false;
    wxString normPath(path);
    CSettings *cfg = wxGetApp().GetSettings();

    normPath.Replace(wxT("\\"), wxT("/"));
    cfg->m_configname = normPath;

    wxGetApp().m_currentDoc = this;

    /*
     * The repository may refer to certain configuration values. Thus, 
     * it must be loaded before reading the repository.
     */
    cfg->Load(cfg->m_configname);
    if ((rc = ReadRepository(cfg->m_repositoryname, normPath)) == true) {

        Modify(false);
        SetDocumentSaved(false);

        rc = wxDocument::OnCreate(path, flags);
        if (rc) {
            if (flags & wxDOC_NEW) {
                wxBusyCursor wait;

                CNutConfHint hint(NULL, nutSelChanged);
                UpdateAllViews(NULL, &hint);

                SetFilename(GetFilename(), true);
            }
        }
    }

    if(!rc) {
        wxGetApp().m_currentDoc = NULL;
    }
    return rc;
}
Ejemplo n.º 21
0
/*===========================================================================
 *
 * Class CSrEspFile Method - bool Load (pFilename, pCallback);
 *
 * Description
 *
 *=========================================================================*/
bool CSrEspFile::Load (const SSCHAR* pFilename, CSrCallback* pCallback) {
  srtimer_t Timer;  
  bool      Result;

		/* Clear the current object contents */
  Destroy();
  SetFilename(pFilename);
  m_Records.SetParent(this);
  
  SrStartTimer(Timer);

		/* Attempt to load any string files associated with the file */
  Result = LoadStringFiles(pCallback);
  MakeStringMap(pCallback);

  Result = CSrRecord::InitIOBuffers();
  if (!Result) return (false);

  Result = m_File.Open(pFilename, "rb");
  if (!Result) return (false);

  if (pCallback) pCallback->SetLabel("Loading '%s'...", pFilename);

  Result = Read(pCallback);

  SystemLog.Printf("End read position for file '%s' is 0x%08X.", pFilename, m_File.Tell64());
  m_File.Close();

  if (IsLocalStrings())
  {
	  LoadLocalStrings(pCallback);
  }    

  CSrRecord::DestroyIOBuffers();

  SrEndTimer(Timer, "\tLoaded file in");

  return (Result);
}
Ejemplo n.º 22
0
CLangData::CLangData(const CLangData& ld) :
	m_pszFilename(NULL),
	m_pszLngName(NULL),
	m_pszFontFace(NULL),
	m_pszHelpName(NULL),
	m_pszAuthor(NULL),
	m_bRTL(ld.m_bRTL),
	m_bUpdating(ld.m_bUpdating),
	m_uiSectionID(ld.m_uiSectionID),
	m_wPointSize(ld.m_wPointSize),
	m_bModified(false)
{
	SetFilename(ld.GetFilename(true));
	SetLangName(ld.GetLangName());
	SetFontFace(ld.GetFontFace());
	SetPointSize(ld.GetPointSize());
	SetDirection(ld.GetDirection());
	SetHelpName(ld.GetHelpName());
	SetAuthor(ld.GetAuthor());

	m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end());
}
Ejemplo n.º 23
0
bool VFSHandle_ZIP::OpenLocation(char *loc, bool create)
{
	SetFilename(loc);

	FindArchiveName();
	
	VFSHandle *h = fusion->vfs->Open(m_archive,"bin",false);
	
	if(h == NULL && create == true){
		VFSHandle *h = fusion->vfs->Open(m_archive,"bin",true);
		fusion->vfs->Close(h);
	}else{
		return false;
	}

	if(VFSHandle_file::Open(m_archive,false) == true){
		CreateCache();
		return true;
	}
	
	return false;	
}
Ejemplo n.º 24
0
CLangData& CLangData::operator=(const CLangData& rSrc)
{
	if(this != &rSrc)
	{
		SetFilename(rSrc.GetFilename(true));
		SetLangName(rSrc.GetLangName());
		SetFontFace(rSrc.GetFontFace());
		SetPointSize(rSrc.GetPointSize());
		SetDirection(rSrc.GetDirection());
		SetHelpName(rSrc.GetHelpName());
		SetAuthor(rSrc.GetAuthor());
		m_bRTL = rSrc.m_bRTL;
		m_bUpdating = rSrc.m_bUpdating;
		m_uiSectionID = rSrc.m_uiSectionID;
		m_wPointSize = rSrc.m_wPointSize;
		m_bModified = false;

		m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end());
	}

	return *this;
}
Ejemplo n.º 25
0
//writes message and/or time/date to log file
void CEventLog::LogData(string text, int status=0)
{
  if (log_file.size() <1) SetFilename("log.txt");
  ofstream file(log_file.c_str(), std::ios::app);
  if(file){
    switch(status)
    {
      case LOG_TEXT:
        file << text.c_str() << endl;
        break;
      case LOG_TEXT_TIME:
        file << GetTimeString() << ": " << text.c_str() << endl;
        break;  
      case LOG_TEXT_DATE:
        file << GetDateString() << ": " << text.c_str() << endl;
        break;  
      case LOG_TEXT_DATE_TIME:
        file << GetDateString() << ", " << GetTimeString() << ": "
			 << text.c_str() << endl;
        break;  
    }
  }
}
Ejemplo n.º 26
0
// Open the document
bool ctConfigToolDoc::OnOpenDocument(const wxString& filename)
{
    wxBusyCursor cursor;

    bool opened = DoOpen(filename);

    if (opened)
    {
        SetFilename(filename);
        wxGetApp().GetSettings().m_lastFilename = filename;

        ((ctConfigToolView*)GetFirstView())->OnChangeFilename();

        RefreshDependencies();

        // ctConfigToolHint hint(NULL, ctFilenameChanged);
        ctConfigToolHint hint(NULL, ctInitialUpdate);
        UpdateAllViews (NULL, & hint);
    }

    SetDocumentSaved(true); // Necessary or it will pop up the Save As dialog

    return opened;
}
Ejemplo n.º 27
0
/*===========================================================================
 *
 * Class CSrEspFile Method - bool Save (pFilename, pCallback);
 *
 * Saves the mod data to the given file (overwritten if it exists). Returns
 * false on any error.
 *
 *=========================================================================*/
bool CSrEspFile::Save (const SSCHAR* pFilename, CSrCallback* pCallback) 
{
  srtimer_t Timer;  
  srtimer_t Timer1;
  bool      Result;

  SrStartTimer(Timer);

  UpdateFormCount();
  
  Result = CSrRecord::InitIOBuffers();
  if (!Result) return (false);

  SrStartTimer(Timer1);
  UpdateLoadLocalString();
  UpdateStringMap();
  SrEndTimer(Timer1, "\tUpdated local strings in");

  SrStartTimer(Timer1);
  Result = SaveLocalStrings(pFilename);
  if (!Result) return (false);
  SrEndTimer(Timer1, "\tSaved local strings in");

  SetFilename(pFilename);
  
  Result = m_File.Open(pFilename, "wb");
  if (!Result) return (false);

  Result = Write(pCallback);
  m_File.Close();

  CSrRecord::DestroyIOBuffers();

  SrEndTimer(Timer, "\tSaved file in");
  return (Result);
}
Ejemplo n.º 28
0
Archivo: doc.cpp Proyecto: EdgarTx/wx
bool csDiagramDocument::OnOpenDocument(const wxString& file)
{
  if (!OnSaveModified())
    return false;

  wxString msgTitle;
  if (wxTheApp->GetAppName() != wxEmptyString)
    msgTitle = wxTheApp->GetAppName();
  else
    msgTitle = wxString(_T("File error"));

  m_diagram.DeleteAllShapes();
  if (!m_diagram.LoadFile(file))
  {
    (void)wxMessageBox(_T("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
     GetDocumentWindow());
    return false;
  }
  SetFilename(file, true);
  Modify(false);
  UpdateAllViews();

  return true;
}
Ejemplo n.º 29
0
bool wxGenericFileCtrl::Create( wxWindow *parent,
                                wxWindowID id,
                                const wxString& defaultDirectory,
                                const wxString& defaultFileName,
                                const wxString& wildCard,
                                long style,
                                const wxPoint& pos,
                                const wxSize& size,
                                const wxString& name )
{
    this->m_style = style;
    m_inSelected = false;
    m_noSelChgEvent = false;
    m_check = NULL;

    // check that the styles are not contradictory
    wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_OPEN ) ),
                  wxT( "can't specify both wxFC_SAVE and wxFC_OPEN at once" ) );

    wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_MULTIPLE ) ),
                  wxT( "wxFC_MULTIPLE can't be used with wxFC_SAVE" ) );

    wxNavigationEnabled<wxControl>::Create( parent, id,
                                            pos, size,
                                            wxTAB_TRAVERSAL,
                                            wxDefaultValidator,
                                            name );

    m_dir = defaultDirectory;

    m_ignoreChanges = true;

    if ( ( m_dir.empty() ) || ( m_dir == wxT( "." ) ) )
    {
        m_dir = wxGetCwd();
        if ( m_dir.empty() )
            m_dir = wxFILE_SEP_PATH;
    }

    const size_t len = m_dir.length();
    if ( ( len > 1 ) && ( wxEndsWithPathSeparator( m_dir ) ) )
        m_dir.Remove( len - 1, 1 );

    m_filterExtension = wxEmptyString;

    // layout

    const bool is_pda = ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA );

    wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );

    wxBoxSizer *staticsizer = new wxBoxSizer( wxHORIZONTAL );
    if ( is_pda )
        staticsizer->Add( new wxStaticText( this, wxID_ANY, _( "Current directory:" ) ),
                          wxSizerFlags().DoubleBorder(wxRIGHT) );
    m_static = new wxStaticText( this, wxID_ANY, m_dir );
    staticsizer->Add( m_static, 1 );
    mainsizer->Add( staticsizer, wxSizerFlags().Expand().Border());

    long style2 = wxLC_LIST;
    if ( !( m_style & wxFC_MULTIPLE ) )
        style2 |= wxLC_SINGLE_SEL;

#ifdef __WXWINCE__
    style2 |= wxSIMPLE_BORDER;
#else
    style2 |= wxSUNKEN_BORDER;
#endif

    m_list = new wxFileListCtrl( this, ID_FILELIST_CTRL,
                                 wxEmptyString, false,
                                 wxDefaultPosition, wxSize( 400, 140 ),
                                 style2 );

    m_text = new wxTextCtrl( this, ID_TEXT, wxEmptyString,
                             wxDefaultPosition, wxDefaultSize,
                             wxTE_PROCESS_ENTER );
    m_choice = new wxChoice( this, ID_CHOICE );

    if ( is_pda )
    {
        // PDAs have a different screen layout
        mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().HorzBorder() );

        wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
        textsizer->Add( m_text, wxSizerFlags( 1 ).Centre().Border() );
        textsizer->Add( m_choice, wxSizerFlags( 1 ).Centre().Border() );
        mainsizer->Add( textsizer, wxSizerFlags().Expand() );

    }
    else // !is_pda
    {
        mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().Border() );
        mainsizer->Add( m_text, wxSizerFlags().Expand().Border() );

        wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
        choicesizer->Add( m_choice, wxSizerFlags( 1 ).Centre() );

        if ( !( m_style & wxFC_NOSHOWHIDDEN ) )
        {
            m_check = new wxCheckBox( this, ID_CHECK, _( "Show &hidden files" ) );
            choicesizer->Add( m_check, wxSizerFlags().Centre().DoubleBorder(wxLEFT) );
        }

        mainsizer->Add( choicesizer, wxSizerFlags().Expand().Border() );
    }

    SetWildcard( wildCard );

    SetAutoLayout( true );
    SetSizer( mainsizer );

    if ( !is_pda )
    {
        mainsizer->Fit( this );
    }

    m_list->GoToDir( m_dir );
    UpdateControls();
    m_text->SetValue( m_fileName );

    m_ignoreChanges = false;

    // must be after m_ignoreChanges = false
    SetFilename( defaultFileName );

    return true;
}
Ejemplo n.º 30
0
void BuildLineInfo::NormalizeFilename(const wxArrayString& directories, const wxString &cygwinPath)
{
    wxFileName fn(this->GetFilename());

    if(fn.IsAbsolute()) {
        SetFilename( fn.GetFullPath() );
        return;
        
    } else if ( fn.IsAbsolute(wxPATH_UNIX) && IS_WINDOWS && !cygwinPath.IsEmpty()) {
        
        wxFileName cygfile(fn);
        wxString path = cygwinPath + cygfile.GetFullPath();
        SetFilename(wxFileName(path).GetFullPath());
        return;
        
    }

    if(directories.IsEmpty()) {
        SetFilename(fn.GetFullName());
        return;
    }
    
    // we got a relative file name
    int dircount = directories.GetCount();
    for(int i=dircount-1; i>=0; --i) {
        wxFileName tmp = fn;
        if( tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG) ) {
            // Windows sanity
            if ( IS_WINDOWS && tmp.GetVolume().length() > 1 ) {
                // Invalid file path
                SetFilename("");
                return;
            }
            
            if ( tmp.FileExists() && tmp.MakeAbsolute(directories.Item(i))) {
                SetFilename( tmp.GetFullPath() );
                return;
            }
        }
    }

    // One more try: the above will fail if the project isn't stored in the cwd that Normalize() assumes
    // So see if one of 'directories' is the correct path to use
    for(int i=dircount-1; i>=0; --i) {
        wxFileName tmp = fn;
        if( tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG, directories.Item(i)) ) {
            // Windows sanity
            if ( IS_WINDOWS && tmp.GetVolume().length() > 1 ) {
                // Invalid file path
                SetFilename("");
                return;
            }

            if ( tmp.FileExists()) {
                SetFilename( tmp.GetFullPath() );
                return;
            }
        }
    }

    // failed.. keep it as fullname only
    SetFilename(fn.GetFullName());
}