<commit_before>// Copyright (c) 2013, <NAME>. All rights reserved.

#include "account_type_ctrl.hpp"
#include "account_dialog.hpp"
#include "account_type.hpp"
#include "b_string.hpp"
#include "phatbooks_exceptions.hpp"
#include <wx/combobox.h>
#include <wx/window.h>
#include <vector>

using std::vector;

namespace phatbooks
{
namespace gui
{

AccountTypeCtrl::AccountTypeCtrl
(	wxWindow* p_parent,
	wxWindowID p_id,
	wxSize const& p_size,
	PhatbooksDatabaseConnection& p_database_connection,
	account_super_type::AccountSuperType p_account_super_type
):
	wxComboBox
	(	p_parent,
		p_id,
		wxEmptyString,  // TODO HIGH PRIORITY Needs to be an AccountType name
		wxDefaultPosition,
		p_size,
		wxArrayString(),
		wxCB_READONLY
	),
	m_account_super_type(p_account_super_type),
	m_database_connection(p_database_connection)
{
	typedef vector<account_type::AccountType> ATypeVec;
	ATypeVec const& atypes = account_types(m_account_super_type);
	ATypeVec::const_iterator it = atypes.begin();
	ATypeVec::const_iterator const end = atypes.end();
	for ( ; it != end; ++it)
	{
		// WARNING Hack to stop users from accessing account_type::equity.
		if (*it != account_type::equity)
		{
			Append(bstring_to_wx(account_type_to_string(*it)));
		}
	}	
	SetSelection(0);  // In effort to avoid apparent bug in Windows
}

account_type::AccountType
AccountTypeCtrl::account_type() const
{<commit_msg>Addressed a TODO in AccountTypeCtrl whereby in the AccountTypeCtrl constructor, the displayed string was initially being set to wxEmptyString rather than an string indicating some "default" AccountType. (This possibly didn't matter, but it's fixed now anyway.)<commit_after>// Copyright (c) 2013, <NAME>. All rights reserved.

#include "account_type_ctrl.hpp"
#include "account_dialog.hpp"
#include "account_type.hpp"
#include "b_string.hpp"
#include "phatbooks_exceptions.hpp"
#include <wx/combobox.h>
#include <wx/window.h>
#include <vector>

using std::vector;

namespace phatbooks
{
namespace gui
{

namespace
{
	wxString default_account_type_string
	(	account_super_type::AccountSuperType p_account_super_type
	)
	{
		assert (!account_types(p_account_super_type).empty());
		account_type::AccountType const default_account_type =
			account_types(p_account_super_type)[0];
		assert (default_account_type != account_type::equity);
		return bstring_to_wx(account_type_to_string(default_account_type));
	}

}  // end anonymous namespace


AccountTypeCtrl::AccountTypeCtrl
(	wxWindow* p_parent,
	wxWindowID p_id,
	wxSize const& p_size,
	PhatbooksDatabaseConnection& p_database_connection,
	account_super_type::AccountSuperType p_account_super_type
):
	wxComboBox
	(	p_parent,
		p_id,
		default_account_type_string(p_account_super_type),
		wxDefaultPosition,
		p_size,
		wxArrayString(),
		wxCB_READONLY
	),
	m_account_super_type(p_account_super_type),
	m_database_connection(p_database_connection)
{
	typedef vector<account_type::AccountType> ATypeVec;
	ATypeVec const& atypes = account_types(m_account_super_type);
	ATypeVec::const_iterator it = atypes.begin();
	ATypeVec::const_iterator const end = atypes.end();
	for ( ; it != end; ++it)
	{
		// WARNING Hack to stop users from accessing account_type::equity.
		if (*it != account_type::equity)
		{
			Append(bstring_to_wx(account_type_to_string(*it)));
		}
	}	
	SetSelection(0);  // In effort to avoid apparent bug in Windows
}

account_type::AccountType
AccountTypeCtrl::account_type() const
{
{'fraction_non_alphanumeric': 0.10282551704048937, 'fraction_numerical': 0.003204194581998252, 'mean_word_length': 6.369098712446352, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4544253', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1167, 'n_words': 251}