void FindInFilesDialog::DoAddSearchPaths(const wxArrayString& paths)
{
    for(size_t i = 0; i < paths.size(); ++i) {
        DoAddSearchPath(paths.Item(i));
    }
}
Exemplo n.º 2
0
/* TextEntryPanel::loadEntry
 * Loads an entry into the panel as text
 *******************************************************************/
bool TextEntryPanel::loadEntry(ArchiveEntry* entry)
{
	// Load entry into the text editor
	if (!text_area->loadEntry(entry))
		return false;

	// Scroll to previous position (if any)
	if (entry->exProps().propertyExists("TextPosition"))
		text_area->GotoPos((int)(entry->exProp("TextPosition")));

	// --- Attempt to determine text language ---
	TextLanguage* tl = NULL;

	// Level markers use FraggleScript
	if (entry->getType() == EntryType::mapMarkerType())
	{
		tl = TextLanguage::getLanguage("fragglescript");
	}

	// From entry language hint
	if (entry->exProps().propertyExists("TextLanguage"))
	{
		string lang_id = entry->exProp("TextLanguage");
		tl = TextLanguage::getLanguage(lang_id);
	}

	// Or, from entry type
	if (!tl && entry->getType()->extraProps().propertyExists("text_language"))
	{
		string lang_id = entry->getType()->extraProps()["text_language"];
		tl = TextLanguage::getLanguage(lang_id);
	}

	// Or, from entry's parent directory
	if (!tl)
	{
		// ZDoom DECORATE (within 'actors' or 'decorate' directories)
		if (S_CMPNOCASE(wxString("/actors/"), entry->getPath().Left(8)) ||
		        S_CMPNOCASE(wxString("/decorate/"), entry->getPath().Left(10)))
			tl = TextLanguage::getLanguage("decorate");
	}

	// Load language
	text_area->setLanguage(tl);

	// Select it in the choice box
	if (tl)
	{
		for (unsigned a = 0; a < languages.size(); a++)
		{
			if (S_CMPNOCASE(tl->getName(), languages[a]))
			{
				choice_text_language->Select(a);
				break;
			}
		}
	}
	else
		choice_text_language->Select(0);

	// Prevent undoing loading the entry
	text_area->EmptyUndoBuffer();

	// Update variables
	this->entry = entry;
	setModified(false);

	return true;
}
Exemplo n.º 3
0
void SearchThread::DoSearchLine(const wxString& line, const int lineNum, const int lineOffset, const wxString& fileName,
                                const SearchData* data, const wxString& findWhat, const wxArrayString& filters,
                                TextStatesPtr statesPtr)
{
    wxString modLine = line;

    if(!data->IsMatchCase()) { modLine.MakeLower(); }

    int pos = 0;
    int col = 0;
    int iCorrectedCol = 0;
    int iCorrectedLen = 0;
    while(pos != wxNOT_FOUND) {
        pos = modLine.Find(findWhat);
        if(pos != wxNOT_FOUND) {
            col += pos;

            // Pipe support
            bool allFiltersOK = true;
            if(!filters.IsEmpty()) {
                // Apply the filters
                for(size_t i = 0; i < filters.size() && allFiltersOK; ++i) {
                    allFiltersOK = (modLine.Find(filters.Item(i)) != wxNOT_FOUND);
                }
            }

            // Pipe filtes OK?
            if(!allFiltersOK) return;

            // we have a match
            if(data->IsMatchWholeWord()) {

                // make sure that the word before is not in the wordChars map
                if((pos > 0) && (m_wordCharsMap.find(modLine.GetChar(pos - 1)) != m_wordCharsMap.end())) {
                    if(!AdjustLine(modLine, pos, findWhat)) {

                        break;
                    } else {
                        col += (int)findWhat.Length();
                        continue;
                    }
                }
                // if we have more characters to the right, make sure that the first char does not match any
                // in the wordCharsMap
                if(pos + findWhat.Length() <= modLine.Length()) {
                    wxChar nextCh = modLine.GetChar(pos + findWhat.Length());
                    if(m_wordCharsMap.find(nextCh) != m_wordCharsMap.end()) {
                        if(!AdjustLine(modLine, pos, findWhat)) {

                            break;
                        } else {
                            col += (int)findWhat.Length();
                            continue;
                        }
                    }
                }
            }

            // Notify our match
            // correct search Pos and Length owing to non plain ASCII multibyte characters
            iCorrectedCol = FileUtils::UTF8Length(line.c_str(), col);
            iCorrectedLen = FileUtils::UTF8Length(findWhat.c_str(), findWhat.Length());
            SearchResult result;
            result.SetPosition(lineOffset + col);
            result.SetColumnInChars(col);
            result.SetColumn(iCorrectedCol);
            result.SetLineNumber(lineNum);
            // Dont use match pattern larger than 500 chars
            result.SetPattern(line.length() > 500 ? line.Mid(0, 500) : line);
            result.SetFileName(fileName);
            result.SetLenInChars((int)findWhat.Length());
            result.SetLen(iCorrectedLen);
            result.SetFindWhat(data->GetFindString());
            result.SetFlags(data->m_flags);

            int position(wxNOT_FOUND);
            bool canAdd(true);

            if(statesPtr) {
                position = statesPtr->LineToPos(lineNum - 1);
                position += iCorrectedCol;
            }

            // Make sure our match is not on a comment
            if(statesPtr && position != wxNOT_FOUND && data->GetSkipComments()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_CPP_COMMENT || state == CppWordScanner::STATE_C_COMMENT) {
                        canAdd = false;
                    }
                }
            }

            if(statesPtr && position != wxNOT_FOUND && data->GetSkipStrings()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_DQ_STRING || state == CppWordScanner::STATE_SINGLE_STRING) {
                        canAdd = false;
                    }
                }
            }

            result.SetMatchState(CppWordScanner::STATE_NORMAL);
            if(canAdd && statesPtr && position != wxNOT_FOUND && data->GetColourComments()) {
                // set the match state
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_C_COMMENT || state == CppWordScanner::STATE_CPP_COMMENT) {
                        result.SetMatchState(state);
                    }
                }
            }

            if(canAdd) {
                m_results.push_back(result);
                m_summary.SetNumMatchesFound(m_summary.GetNumMatchesFound() + 1);
            }

            if(!AdjustLine(modLine, pos, findWhat)) { break; }
            col += (int)findWhat.Length();
        }
    }
}
//Hack to allow use (events) of wxmenu inside a tool like simpletexttool
void ddDrawingView::setTextPopUpList(wxArrayString &strings, wxMenu &mnu)
{
	//DD-TODO: choose a better id for event
	mnu.Disconnect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this);
	int sz = strings.size();  //to avoid warning
	wxMenuItem *item = NULL;
	wxMenu *submenu = NULL;
	bool isSubItem;
	bool subItemsDisable=false;
	for(int i=0 ; i < sz ; i++){
			//DD-TODO: only create options for what I need, this can be improved later
			//String "--submenu##menu item**sub menu title" and "--subitem--" create and add items to last created submenu
			isSubItem=false;
			item=NULL;
			if(strings[i].Contains(wxT("--submenu"))) 
			{
				if(strings[i].Contains(wxT("--disable"))) 
					subItemsDisable=true;
				else
					subItemsDisable=false;
				submenu = new wxMenu(strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); 
				mnu.AppendSubMenu(submenu,strings[i].SubString(strings[i].find(wxT("##"))+2,strings[i].find(wxT("**"))-1));
			}
			else if(strings[i].Contains(wxT("--subitem")))
			{
				isSubItem=true;
				if(submenu)
				{
					if(strings[i].Contains(wxT("--checked")))
					{
						item=submenu->AppendCheckItem(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length()));
					}
					else
					{
						item=submenu->Append(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length()));
					}
				}
				else
				{
					wxMessageDialog *error = new wxMessageDialog(NULL, wxT("Error setting text popup strings list"), wxT("Error!"), wxOK | wxICON_ERROR);
					error->ShowModal();
					delete error;
				}
			}
			else if(strings[i].Contains(wxT("--separator--")))
			{
				mnu.AppendSeparator();
			}
			else if(strings[i].Contains(wxT("--checked")))
			{
				item = mnu.AppendCheckItem(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length()));
			}
			else if(strings[i].Contains(wxT("**")))
			{
				item = mnu.Append(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length()));
			}
			else 
			{
				item = mnu.Append(i, strings[i]);
			}

			if(item && strings[i].Contains(wxT("--checked")))
			{
				item->Check(true);
			}
			if(   item &&  ( strings[i].Contains(wxT("--disable")) || (submenu && isSubItem && subItemsDisable) )   )
			{
				item->Enable(false);
			}

		}
//DD-TODO: create a better version of this hack
	mnu.Connect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this);
}
Exemplo n.º 5
0
// Run
//
int TestApp::RunTests()
{
#if wxUSE_LOG
    // Switch off logging unless --verbose
    bool verbose = wxLog::GetVerbose();
    wxLog::EnableLogging(verbose);
#else
    bool verbose = false;
#endif

    CppUnit::TextTestRunner runner;

    if ( m_registries.empty() )
    {
        // run or list all tests which use the CPPUNIT_TEST_SUITE_REGISTRATION() macro
        // (i.e. those registered in the "All tests" registry); if there are other
        // tests not registered with the CPPUNIT_TEST_SUITE_REGISTRATION() macro
        // then they won't be listed/run!
        AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());

        if (m_list)
        {
            cout << "\nNote that the list above is not complete as it doesn't include the \n";
            cout << "tests disabled by default.\n";
        }
    }
    else // run only the selected tests
    {
        for (size_t i = 0; i < m_registries.size(); i++)
        {
            const wxString reg = m_registries[i];
            Test *test = GetTestByName(reg);

            if ( !test && !reg.EndsWith("TestCase") )
            {
                test = GetTestByName(reg + "TestCase");
            }

            if ( !test )
            {
                cerr << "No such test suite: " << string(reg.mb_str()) << endl;
                return 2;
            }

            AddTest(runner, test);
        }
    }

    if ( m_list )
        return EXIT_SUCCESS;

    runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), cout));

    // there is a bug
    // (http://sf.net/tracker/index.php?func=detail&aid=1649369&group_id=11795&atid=111795)
    // in some versions of cppunit: they write progress dots to cout (and not
    // cerr) and don't flush it so all the dots appear at once at the end which
    // is not very useful so unbuffer cout to work around this
    cout.setf(ios::unitbuf);

    // add detail listener if needed
    DetailListener detailListener(m_timing);
    if ( m_detail || m_timing )
        runner.eventManager().addListener(&detailListener);

    // finally ensure that we report our own exceptions nicely instead of
    // giving "uncaught exception of unknown type" messages
    runner.eventManager().pushProtector(new wxUnitTestProtector);

    bool printProgress = !(verbose || m_detail || m_timing);
    runner.run("", false, true, printProgress);

    return runner.result().testFailures() == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemplo n.º 6
0
void Param::write_values(std::fstream& fs) const {
	const wxArrayString values = get_values();
	for (size_t i = 0; i != values.size(); i++)
		fs << (i ? "," : "") << values[i];
	fs << std::endl;
}
Exemplo n.º 7
0
void ViewLog::InitModList(wxArrayString ModList)
{
    if (ModList.size() > 0)
        ListBox1->InsertItems(GetModNames(ModList), 0);
}
Exemplo n.º 8
0
// Try the test for a single flavour of expression
//
void RegExTestCase::doTest(int flavor)
{
    wxRegEx re(m_pattern, m_compileFlags | flavor);

    // 'e' - test that the pattern fails to compile
    if (m_mode == 'e') {
        failIf(re.IsValid(), wxT("compile succeeded (should fail)"));
        return;
    }
    failIf(!re.IsValid(), wxT("compile failed"));

    bool matches = re.Matches(m_data, m_matchFlags);

    // 'f' or 'p' - test that the pattern does not match
    if (m_mode == 'f' || m_mode == 'p') {
        failIf(matches, wxT("match succeeded (should fail)"));
        return;
    }

    // otherwise 'm' or 'i' - test the pattern does match
    failIf(!matches, wxT("match failed"));

    if (m_compileFlags & wxRE_NOSUB)
        return;

    // check wxRegEx has correctly counted the number of subexpressions
    wxString msg;
    msg << wxT("GetMatchCount() == ") << re.GetMatchCount()
        << wxT(", expected ") << m_expected.size();
    failIf(m_expected.size() != re.GetMatchCount(), msg);

    for (size_t i = 0; i < m_expected.size(); i++) {
        wxString result;
        size_t start, len;

        msg.clear();
        msg << wxT("wxRegEx::GetMatch failed for match ") << i;
        failIf(!re.GetMatch(&start, &len, i), msg);

        // m - check the match returns the strings given
        if (m_mode == 'm')
        {
            if (start < INT_MAX)
                result = m_data.substr(start, len);
            else
                result = wxT("");
        }

        // i - check the match returns the offsets given
        else if (m_mode == 'i')
        {
            if (start > INT_MAX)
                result = wxT("-1 -1");
            else if (start + len > 0)
                result << start << wxT(" ") << start + len - 1;
            else
                result << start << wxT(" -1");
        }

        msg.clear();
        msg << wxT("match(") << i << wxT(") == ") << quote(result)
            << wxT(", expected == ") << quote(m_expected[i]);
        failIf(result != m_expected[i], msg);
    }
}
Exemplo n.º 9
0
void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle)
{
    //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW
    NewGraphicsIfNeeded();
    wxString s;

    // Get extent of whole text.
    wxCoord w, h, heightLine;
    GetOwner()->GetMultiLineTextExtent(sText, &w, &h, &heightLine);

    // Compute the shift for the origin of the next line.
    const double rad = wxDegToRad(angle);
    const double dx = heightLine * sin(rad);
    const double dy = heightLine * cos(rad);

    // wxS("upper left") and wxS("upper right")
    CalcBoundingBox(x, y);
    CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad)));

    // wxS("bottom left") and wxS("bottom right")
    CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad)));
    CalcBoundingBox((wxCoord)(x + h*sin(rad) + w*cos(rad)), (wxCoord)(y + h*cos(rad) - w*sin(rad)));

    if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
    {
        // draw background first
        // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background
        s += wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" "), x, y, w, h);
        s += wxS("style=\"") + wxBrushString(m_textBackgroundColour);
        s += wxS("stroke-width:1; ") + wxPenString(m_textBackgroundColour);
        s += wxString::Format(wxS("\" transform=\"rotate(%s %d %d)\"/>"), NumStr(-angle), x, y);
        s += wxS("\n");
        write(s);
    }

    // Draw all text line by line
    const wxArrayString lines = wxSplit(sText, '\n', '\0');
    for (size_t lineNum = 0; lineNum < lines.size(); lineNum++)
    {
        // convert x,y to SVG text x,y (the coordinates of the text baseline)
        wxCoord ww, hh, desc;
        DoGetTextExtent(lines[lineNum], &ww, &hh, &desc);
        int xx = x + wxRound(lineNum * dx) + (hh - desc) * sin(rad);
        int yy = y + wxRound(lineNum * dy) + (hh - desc) * cos(rad);

        //now do the text itself
        s += wxString::Format(wxS("  <text x=\"%d\" y=\"%d\" textLength=\"%d\" "), xx, yy, ww);

        wxString fontName(m_font.GetFaceName());
        if (fontName.Len() > 0)
            s += wxS("style=\"font-family:") + fontName + wxS("; ");
        else
            s += wxS("style=\" ");

        wxString fontweight;
        switch (m_font.GetWeight())
        {
            case wxFONTWEIGHT_MAX:
                wxFAIL_MSG(wxS("invalid font weight value"));
                wxFALLTHROUGH;

            case wxFONTWEIGHT_NORMAL:
                fontweight = wxS("normal");
                break;

            case wxFONTWEIGHT_LIGHT:
                fontweight = wxS("lighter");
                break;

            case wxFONTWEIGHT_BOLD:
                fontweight = wxS("bold");
                break;
        }

        wxASSERT_MSG(!fontweight.empty(), wxS("unknown font weight value"));

        s += wxS("font-weight:") + fontweight + wxS("; ");

        wxString fontstyle;
        switch (m_font.GetStyle())
        {
            case wxFONTSTYLE_MAX:
                wxFAIL_MSG(wxS("invalid font style value"));
                wxFALLTHROUGH;

            case wxFONTSTYLE_NORMAL:
                fontstyle = wxS("normal");
                break;

            case wxFONTSTYLE_ITALIC:
                fontstyle = wxS("italic");
                break;

            case wxFONTSTYLE_SLANT:
                fontstyle = wxS("oblique");
                break;
        }

        wxASSERT_MSG(!fontstyle.empty(), wxS("unknown font style value"));

        s += wxS("font-style:") + fontstyle + wxS("; ");

        wxString textDecoration;
        if (m_font.GetUnderlined())
            textDecoration += wxS(" underline");
        if (m_font.GetStrikethrough())
            textDecoration += wxS(" line-through");
        if (textDecoration.IsEmpty())
            textDecoration = wxS(" none");

        s += wxS("text-decoration:") + textDecoration + wxS("; ");

        s += wxString::Format(wxS("font-size:%dpt; "), m_font.GetPointSize());
        //text will be solid, unless alpha value isn't opaque in the foreground colour
        s += wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour);
        s += wxString::Format(wxS("stroke-width:0;\" transform=\"rotate(%s %d %d)\""), NumStr(-angle), xx, yy);
        s += wxS(" xml:space=\"preserve\">");
        s += wxMarkupParser::Quote(lines[lineNum]) + wxS("</text>\n");

        write(s);
    }
}
Exemplo n.º 10
0
void mmTransDialog::dataToControls()
{
    if (!skip_date_init_) //Date
    {
        wxDateTime trx_date;
        trx_date.ParseDate(m_trx_data.TRANSDATE);
        dpc_->SetValue(trx_date);
        dpc_->SetFocus();
        //process date change event for set weekday name
        wxDateEvent dateEvent(dpc_, trx_date, wxEVT_DATE_CHANGED);
        GetEventHandler()->ProcessEvent(dateEvent);
        skip_date_init_ = true;
    }

    if (!skip_status_init_) //Status
    {
        choiceStatus_->SetSelection(Model_Checking::status(m_trx_data.STATUS));
        skip_status_init_ = true;
    }

    //Type
    transaction_type_->SetSelection(Model_Checking::type(m_trx_data.TRANSCODE));

    //Advanced
    cAdvanced_->Enable(m_transfer);
    cAdvanced_->SetValue(m_advanced && m_transfer);
    toTextAmount_->Enable(m_advanced && m_transfer);

    if (!skip_amount_init_) //Amounts
    {
        if (m_transfer)
        {
            if (!m_advanced)
                m_trx_data.TOTRANSAMOUNT = m_trx_data.TRANSAMOUNT 
                    * (m_to_currency ? m_currency->BASECONVRATE / m_to_currency->BASECONVRATE : 1);
            toTextAmount_->SetValue(m_trx_data.TOTRANSAMOUNT);
        }
        else
            toTextAmount_->ChangeValue("");

        if (m_trx_data.TRANSID != -1)
            textAmount_->SetValue(m_trx_data.TRANSAMOUNT);
        skip_amount_init_ = true;
    }

    if (!skip_account_init_) //Account
    {
        cbAccount_->SetEvtHandlerEnabled(false);
        cbAccount_->Clear();
        const wxArrayString account_list = Model_Account::instance().all_checking_account_names(true);
        cbAccount_->Append(account_list);
        cbAccount_->AutoComplete(account_list);

        bool acc_closed = false;
        const auto &accounts = Model_Account::instance().find(
            Model_Account::ACCOUNTTYPE(Model_Account::all_type()[Model_Account::INVESTMENT], NOT_EQUAL));
        for (const auto &account : accounts)
        {
            if (account.ACCOUNTID == m_trx_data.ACCOUNTID)
            {
                cbAccount_->ChangeValue(account.ACCOUNTNAME);
                if (account.STATUS == Model_Account::all_status()[Model_Account::CLOSED])
                {
                    cbAccount_->Append(account.ACCOUNTNAME);
                    acc_closed = true;
                }
            }
        }

        if (account_list.size() == 1 && !acc_closed)
            cbAccount_->ChangeValue(account_list[0]);

        cbAccount_->Enable(!acc_closed && (account_list.size() > 1));

        cbAccount_->SetEvtHandlerEnabled(true);
        skip_account_init_ = true;
    }

    if (!skip_payee_init_) //Payee or To Account
    {
        cbPayee_->SetEvtHandlerEnabled(false);

        cbPayee_->Clear();
        cbAccount_->UnsetToolTip();
        cbPayee_->UnsetToolTip();
        wxString payee_tooltip = "";
        if (!m_transfer)
        {
            if (!Model_Checking::is_deposit(m_trx_data.TRANSCODE))
            {
                payee_label_->SetLabelText(_("Payee"));
            }
            else
            {
                payee_label_->SetLabelText(_("From"));
            }

            account_label_->SetLabelText(_("Account"));
            if (!Model_Checking::foreignTransaction(m_trx_data))
            {
                m_trx_data.TOACCOUNTID = -1;
            }

            wxArrayString all_payees = Model_Payee::instance().all_payee_names();
            if (!all_payees.empty())
            {
                cbPayee_->Insert(all_payees, 0);
                cbPayee_->AutoComplete(all_payees);
            }

            if (m_new_trx && (Option::instance().TransPayeeSelection() == Option::UNUSED))
            {
                cbPayee_->Enable(false);
                cbPayee_->ChangeValue(_("Unknown"));
            }

            Model_Payee::Data* payee = Model_Payee::instance().get(m_trx_data.PAYEEID);
            if (payee)
            {
                cbPayee_->ChangeValue(payee->PAYEENAME);
                if (m_new_trx && (Option::instance().TransPayeeSelection() == Option::NONE))
                {
                    cbPayee_->ChangeValue("");
                }
            }
        }
        else //transfer
        {
            cbPayee_->Enable(true);
            if (cSplit_->IsChecked())
            {
                cSplit_->SetValue(false);
                local_splits.clear();
            }

            if (m_new_trx && !m_duplicate)
            {
                const auto &categs = Model_Category::instance().find(Model_Category::CATEGNAME(wxGetTranslation("Transfer")));
                if (!categs.empty())
                {
                    m_trx_data.SUBCATEGID = -1;
                    m_trx_data.CATEGID = categs.begin()->CATEGID;
                    bCategory_->SetLabelText(Model_Category::full_name(m_trx_data.CATEGID, -1));
                }
            }

            cbPayee_->Insert(Model_Account::instance().all_checking_account_names(true), 0);
            Model_Account::Data *account = Model_Account::instance().get(m_trx_data.TOACCOUNTID);
            if (account)
                cbPayee_->ChangeValue(account->ACCOUNTNAME);

            cbPayee_->AutoComplete(Model_Account::instance().all_checking_account_names());

            payee_label_->SetLabelText(_("To"));
            m_trx_data.PAYEEID = -1;
            account_label_->SetLabelText(_("From"));
        }
        skip_payee_init_ = true;
        cbPayee_->SetEvtHandlerEnabled(true);
    }

    if (!skip_category_init_)
    {
        bool has_split = !local_splits.empty();
        wxString fullCategoryName;
        bCategory_->UnsetToolTip();
        if (has_split)
        {
            fullCategoryName = _("Categories");
            textAmount_->SetValue(Model_Splittransaction::get_total(local_splits));
            m_trx_data.CATEGID = -1;
            m_trx_data.SUBCATEGID = -1;
        }
        else
        {
            Model_Category::Data *category = Model_Category::instance().get(m_trx_data.CATEGID);
            Model_Subcategory::Data *subcategory = (Model_Subcategory::instance().get(m_trx_data.SUBCATEGID));
            fullCategoryName = Model_Category::full_name(category, subcategory);
            if (fullCategoryName.IsEmpty()) fullCategoryName = _("Select Category");
        }

        bCategory_->SetLabelText(fullCategoryName);
        cSplit_->SetValue(has_split);
        skip_category_init_ = true;
    }
    textAmount_->Enable(local_splits.empty());
    cSplit_->Enable(!m_transfer);

    if (!skip_notes_init_) //Notes & Transaction Number
    {
        textNumber_->SetValue(m_trx_data.TRANSACTIONNUMBER);
        textNotes_->SetValue(m_trx_data.NOTES);
        skip_notes_init_ = true;
    }

    if (!skip_tooltips_init_)
        setTooltips();
}
Exemplo n.º 11
0
    // returns all new dirs/files present in the immediate level of the dir
    // pointed by watch.GetPath(). "new" means created between the last time
    // the state of watch was computed and now
    void FindChanges(wxFSWatchEntryKq& watch,
                     wxArrayString& changedFiles,
                     wxArrayInt& changedFlags)
    {
        wxFSWatchEntryKq::wxDirState old = watch.GetLastState();
        watch.RefreshState();
        wxFSWatchEntryKq::wxDirState curr = watch.GetLastState();

        // iterate over old/curr file lists and compute changes
        wxArrayString::iterator oit = old.files.begin();
        wxArrayString::iterator cit = curr.files.begin();
        for ( ; oit != old.files.end() && cit != curr.files.end(); )
        {
            if ( *cit == *oit )
            {
                ++cit;
                ++oit;
            }
            else if ( *cit <= *oit )
            {
                changedFiles.push_back(*cit);
                changedFlags.push_back(wxFSW_EVENT_CREATE);
                ++cit;
            }
            else // ( *cit > *oit )
            {
                changedFiles.push_back(*oit);
                changedFlags.push_back(wxFSW_EVENT_DELETE);
                ++oit;
            }
        }

        // border conditions
        if ( oit == old.files.end() )
        {
            for ( ; cit != curr.files.end(); ++cit )
            {
                changedFiles.push_back( *cit );
                changedFlags.push_back(wxFSW_EVENT_CREATE);
            }
        }
        else if ( cit == curr.files.end() )
        {
            for ( ; oit != old.files.end(); ++oit )
            {
                changedFiles.push_back( *oit );
                changedFlags.push_back(wxFSW_EVENT_DELETE);
            }
        }

        wxASSERT( changedFiles.size() == changedFlags.size() );

#if 0
        wxLogTrace(wxTRACE_FSWATCHER, "Changed files:");
        wxArrayString::iterator it = changedFiles.begin();
        wxArrayInt::iterator it2 = changedFlags.begin();
        for ( ; it != changedFiles.end(); ++it, ++it2)
        {
            wxString action = (*it2 == wxFSW_EVENT_CREATE) ?
                                "created" : "deleted";
            wxLogTrace(wxTRACE_FSWATCHER, wxString::Format("File: '%s' %s",
                        *it, action));
        }
#endif
    }