Beispiel #1
0
void AeroQSPFrame::SetUserSize( const wxString &size )
{
	long width = 800, height = 600;
	int pos = size.Index(wxT('x'));
	if (pos > 0 && pos + 1 < size.Length())
	{
		size.Mid(0, pos).ToLong(&width);
		size.Mid(pos + 1).ToLong(&height);
	}
	if (width > 0 && height > 0)
	{
		int curW, curH;
		if (_isFullScreen)
		{
			_isFullScreen = false;
			ShowFullScreen(false);
		}
		GetClientSize(&curW, &curH);
		if (width != curW || height != curH)
		{
			SetClientSize(width, height);
			CenterOnParent();
		}
	}
}
Beispiel #2
0
bool FileFilters::Add(const wxString& name, const wxString& mask)
{
    if (name.IsEmpty() || mask.IsEmpty())
        return false; // both must be valid
    if (mask.Index(_T(',')) != wxString::npos)
    {
        // replace commas with semicolons
        wxString tmp = mask;
        while (tmp.Replace(_T(","), _T(";")))
            ;
        s_Filters[name] = tmp;
    }
    else
        s_Filters[name] = mask;
    return true;
}
Beispiel #3
0
bool EdiComposer::WriteData(const FieldDescriptor& desc, const wxString& value) {

    if ( desc.GetType().Cmp(NUMERIC_TYPE) == 0 ) {
        wxString data = value;
        BufferWriteRawData(data.Pad(desc.GetLenght() - value.Len(), '0', FALSE),
                           desc.GetLenght(),
                           desc.GetAlign());
    } else if ( desc.GetType().Cmp(MONEY_TYPE) == 0 ) {
        wxString data = value;
        data = data.erase(value.Index('.'), 1);
        BufferWriteRawData(data.Pad(desc.GetLenght() - data.Len(), '0', FALSE),
                           desc.GetLenght(),
                           desc.GetAlign());
    } else if ( desc.GetType().Cmp(CHOICE_TYPE) == 0 ) {
        BufferWriteRawData(desc.PrepareValue(value), desc.GetLenght(), desc.GetAlign());
    } else {
        BufferWriteRawData(ConvertDataForType(value, desc.GetType()), 
                           desc.GetLenght(), desc.GetAlign());
    }
    return true;
};
Beispiel #4
0
// 获取远程文件
bool CUpdate::getUrlFile(const wxString &url, unsigned char urlType, const wxString dir, wxString saveName)
{
	// 处理文件名
	wxString fileName = url.substr(url.Last('/')+1);	// 如果没有指定文件名,则使用链接地址文件名
	if (saveName.IsEmpty())
		saveName = fileName;
	bool res = true;
	// access save file.
	if (urlType == EUT_HTTP)
	{			
		wxURL *purl = new wxURL(url);		
		wxInputStream *in = purl->GetInputStream();		
		if (!in)
		{
			wxLogError("Couldn't get the file:%s",fileName);			
		}
		else
		{
			res &= SaveFile(in, saveName, dir);
			delete in;
		}
		in = NULL;
		delete purl;
	}
	else if (urlType == EUT_FTP)
	{
		wxFTP ftp;
		// access ftp hostName
		wxString tempFtpAddr = url.substr(0, url.Index('/'));
		// access ftp Dir
		wxString fileDir = url.substr(tempFtpAddr.Len(), url.Len()-tempFtpAddr.Len()-fileName.Len());		
		//ftp.SetUser(_("Anonymous"));	//匿名访问
		ftp.SetUser(_("guest"));
		//ftp.SetPassword(wxEmptyString);
		if ( !ftp.Connect(tempFtpAddr))
		{
			wxLogError("Lost connect,The url is %s and filename is %s.",tempFtpAddr, fileName);
		}
		else
		{
			ftp.ChDir(fileDir);
			// 文件包大小判断
			int size = ftp.GetFileSize(fileName);
			if ( size == -1 )
			{
				wxLogError("Couldn't get the file size for \"%s\"", fileName);
			}
			else
			{
				// 文件流判断
				wxInputStream *in = ftp.GetInputStream(fileName);
				if ( !in )
				{
					wxLogError("Couldn't get the file:%s",fileName);				
				}
				else
				{
					// 保存文件
					res &= SaveFile(in, saveName, dir, size);
					delete in;
				}
				in = NULL;
			}
		}
		// gracefully close the connection to the server
		ftp.Close();
	}
	else if (urlType == EUT_HTTPS)
	{
		//TODO: 实现HTTPS,传输机密文件或核心文件
	}
	// 传输成功且传输总数大于零,避免零作除数(有点冗余判断)
	if (res && m_mainAmountValue>0)
	{
		m_mainAmountValue++;
	}
	return res;
}
void ToDoListView::ParseBuffer(const wxString& buffer, const wxString& filename)
{
    // this is the actual workhorse...

    HighlightLanguage hlang = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageForFilename(filename);
    CommentToken cmttoken = Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken(hlang);
    wxString langName = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(hlang);

    m_ItemsMap[filename].clear();

    wxArrayString allowedTypes;
    size_t t = 0;
    while(t < m_Types.Count())
    {
        if(m_pAllowedTypesDlg->IsChecked(m_Types.Item(t)))
            allowedTypes.Add(m_Types.Item(t));
        t++;
    }

    wxArrayString startStrings;
    if (langName == _T("C/C++") )
    {
        startStrings.Add(_T("#warning"));
        startStrings.Add(_T("#error"));
    }
    if (!cmttoken.doxygenLineComment.IsEmpty())
        startStrings.Add(cmttoken.doxygenLineComment);
    if (!cmttoken.doxygenStreamCommentStart.IsEmpty())
        startStrings.Add(cmttoken.doxygenStreamCommentStart);

    if ( !cmttoken.lineComment.IsEmpty() )
        startStrings.Add(cmttoken.lineComment);
    if ( !cmttoken.streamCommentStart.IsEmpty() )
        startStrings.Add(cmttoken.streamCommentStart);

    if ( startStrings.IsEmpty() || allowedTypes.IsEmpty() )
    {
        Manager::Get()->GetLogManager()->Log(_T("ToDoList: Warning: No to-do types or comment symbols selected to search for, nothing to do."));
        return;
    }

    for ( unsigned k = 0; k < startStrings.size(); k++)
    {
        size_t pos = 0;
        int oldline=0, oldlinepos=0;
        while (1)
        {
            pos = buffer.find(startStrings[k], pos);
            if ( pos == (size_t)wxNOT_FOUND )
                break;

            pos += startStrings[k].length();
            SkipSpaces(buffer, pos);

            for (unsigned int i = 0; i < allowedTypes.GetCount(); ++i)
            {
                wxString type = buffer.Mid(pos, allowedTypes[i].length());
                if ( type != allowedTypes[i])
                    continue;
                pos += allowedTypes[i].length();
                SkipSpaces(buffer, pos);

                ToDoItem item;
                item.type = allowedTypes[i];
                item.filename = filename;


                // ok, we look for two basic kinds of todo entries in the text
                // our version...
                // TODO (mandrav#0#): Implement code to do this and the other...
                // and a generic version...
                // TODO: Implement code to do this and the other...

                wxChar c = buffer.GetChar(pos);
                // is it ours or generic todo?
                if (c == _T('('))
                {
                    // it's ours, find user and/or priority
                    ++pos;
                    while(pos < buffer.length() && buffer.GetChar(pos) != _T('\r') && buffer.GetChar(pos) != _T('\n'))
                    {
                        wxChar c1 = buffer.GetChar(pos);
                        if (c1 != _T('#') && c1 != _T(')'))
                        {
                            // a little logic doesn't hurt ;)
                            if (c1 == _T(' ') || c1 == _T('\t'))
                            {
                                // allow one consecutive space
                                if (item.user.Last() != _T(' '))
                                    item.user << _T(' ');
                            }
                            else
                                item.user << c1;
                        }
                        else if (c1 == _T('#'))
                        {
                            // look for priority
                            c1 = buffer.GetChar(++pos);
                            const wxString allowedChars = _T("0123456789");
                            if ((int)allowedChars.Index(c1) != wxNOT_FOUND)
                                item.priorityStr << c1;
                            // skip to start of date
                            while (pos < buffer.length() && buffer.GetChar(pos) != _T('\r') && buffer.GetChar(pos) != _T('\n') )
                            {
                                wxChar c2 = buffer.GetChar(pos);
                                if ( c2 == _T('#'))
                                {
                                    pos++;
                                    break;
                                }
                                if ( c2 == _T(')') )
                                    break;
                                pos++;
                            }
                            // look for date
                            while (pos < buffer.length() && buffer.GetChar(pos) != _T('\r') && buffer.GetChar(pos) != _T('\n') )
                            {
                                wxChar c2 = buffer.GetChar(pos++);
                                if (c2 == _T(')'))
                                    break;
                                item.date << c2;
                            }

                            break;
                        }
                        else if (c1 == _T(')'))
                        {
                            ++pos;
                            break;
                        }
                        else
                            break;
                        ++pos;
                    }
                }
                // ok, we 've reached the actual todo text :)
                // take everything up to the end of line
                if( buffer.GetChar(pos) == _T(':'))
                    ++pos;
                size_t idx = pos;
                while (buffer.GetChar(idx) != _T('\r') && buffer.GetChar(idx) != _T('\n'))
                    idx++;
                item.text = buffer.Mid(pos, idx-pos);

                // do some clean-up
                item.text.Trim();
                item.text.Trim(false);
                item.user.Trim();
                item.user.Trim(false);
                wxDateTime date;
                if ( !date.ParseDate(item.date.wx_str()) )
                {
                    item.date.clear(); // not able to parse date so clear the string
                }
                item.line = CalculateLineNumber(buffer, pos, oldline, oldlinepos);
                item.lineStr << wxString::Format(_T("%d"), item.line + 1); // 1-based line number for list
                m_ItemsMap[filename].push_back(item);
                m_Items.Add(item);

                pos = idx;
            }
            pos ++;
        }
    }
}