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

#include "frame.hpp"
#include "account.hpp"
#include "account_dialog.hpp"
#include "account_list_ctrl.hpp"
#include "app.hpp"
#include "entry_list_ctrl.hpp"
#include "icon.xpm"
#include "phatbooks_database_connection.hpp"
#include "top_panel.hpp"
#include <jewel/on_windows.hpp>
#include <wx/menu.h>
#include <wx/string.h>
#include <wx/icon.h>
#include <wx/wx.h>
#include <vector>

using std::vector;

#include <jewel/debug_log.hpp>  // for debugging / testing
#include <iostream>  // for debugging / testinga
using std::cout;     // for debugging / testing
using std::endl;     // for debubbing / testing


namespace phatbooks
{
namespace gui
{


Frame::Frame
(	wxString const& title,
	PhatbooksDatabaseConnection& p_database_connection
):
	wxFrame
	(	0,
		wxID_ANY,
		title,
		wxDefaultPosition,
#		if JEWEL_ON_WINDOWS
			wxDefaultSize
#		else
			wxSize
			(	wxSystemSettings::GetMetric(wxSYS_SCREEN_X),
				wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)
			)
#		endif
	),
	m_database_connection(p_database_connection),
	m_top_panel(0),
	m_menu_bar(0),
	m_file_menu(0),
	m_new_menu(0),
	m_edit_menu(0),
	m_help_menu(0)
{
	// Set the frame icon
	// TODO I should use SetIcons to associate several icons of
	// different sizes with the Window. This avoids possible ugliness from
	// resizing of a single icon when different sizes are required in
	// different situations.
	SetIcon(wxIcon(icon_xpm));

	// Create menus
	m_menu_bar = new wxMenuBar;
	m_file_menu = new wxMenu;
	m_new_menu = new wxMenu;
	m_edit_menu = new wxMenu;
	m_help_menu = new wxMenu;

	// Configure "file" menu
	m_file_menu->Append
	(	wxID_EXIT,
		wxString("E&xit\tAlt-X"),
		wxString("Quit this program")
	);
	m_menu_bar->Append(m_file_menu, wxString("&File"));

	// Configure "new" menu
	m_new_menu->Append
	(	s_new_bs_account_id,
		wxString("New &account"),
		wxString("Create a new asset or liability account")
	);
	m_new_menu->Append
	(	s_new_pl_account_id,
		wxString("New &category"),
		wxString("Create a new revenue or expenditure category")
	);
	m_new_menu->Append
	(	s_new_transaction_id,
		wxString("New &transaction \tAlt-T"),
		wxString("Record a new transaction")
	);
	m_menu_bar->Append(m_new_menu, wxString("&New"));

	// Configure "edit" menu
	m_edit_menu->Append
	(	s_edit_bs_account_id,
		wxString("Edit selected &account"),
		wxString("Edit an exising asset or liability account")
	);
	m_edit_menu->Append
	(	s_edit_pl_account_id,
		wxString("Edit selected &category"),
		wxString("Edit an existing revenue or expenditure category")
	);
	m_menu_bar->Append(m_edit_menu, wxString("&Edit"));

	// Configure "help" menu
	m_help_menu->Append
	(	wxID_ABOUT,
		wxString("&About...\tF1"),
		wxString("Show about dialog")
	);
	m_menu_bar->Append(m_help_menu, wxString("&Help"));

	SetMenuBar(m_menu_bar);

	// Connect events to menus
	Connect
	(	wxID_EXIT,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_quit)
	);
	Connect
	(	s_new_bs_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_bs_account)
	);
	Connect
	(	s_new_pl_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_pl_account)
	);
	Connect
	(	s_new_transaction_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_transaction)
	);
	Connect
	(	s_edit_bs_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_edit_bs_account)
	);
	Connect
	(	s_edit_pl_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_edit_pl_account)
	);
	Connect
	(	wxID_ABOUT,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_about)
	);

#	if JEWEL_ON_WINDOWS
		Maximize();
#	endif

	m_top_panel = new TopPanel(this, m_database_connection);

}
	
void
Frame::on_about(wxCommandEvent& event)
{
	// TODO Put proper messages here
	wxString msg;
	msg.Printf("Hello and welcome to %s", wxVERSION_STRING);
	wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this);
	(void)event;  // Silence compiler warning re. unused parameter.
	return;<commit_msg>Removed reference to wxWidgets from "About" in Help menu; replaced with reference to Phatbooks.<commit_after>// Copyright (c) 2013, <NAME>. All rights reserved.

#include "frame.hpp"
#include "account.hpp"
#include "account_dialog.hpp"
#include "account_list_ctrl.hpp"
#include "application.hpp"
#include "app.hpp"
#include "entry_list_ctrl.hpp"
#include "icon.xpm"
#include "phatbooks_database_connection.hpp"
#include "top_panel.hpp"
#include <jewel/on_windows.hpp>
#include <wx/menu.h>
#include <wx/string.h>
#include <wx/icon.h>
#include <wx/wx.h>
#include <vector>

using std::vector;

#include <jewel/debug_log.hpp>  // for debugging / testing
#include <iostream>  // for debugging / testinga
using std::cout;     // for debugging / testing
using std::endl;     // for debubbing / testing


namespace phatbooks
{
namespace gui
{


Frame::Frame
(	wxString const& title,
	PhatbooksDatabaseConnection& p_database_connection
):
	wxFrame
	(	0,
		wxID_ANY,
		title,
		wxDefaultPosition,
#		if JEWEL_ON_WINDOWS
			wxDefaultSize
#		else
			wxSize
			(	wxSystemSettings::GetMetric(wxSYS_SCREEN_X),
				wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)
			)
#		endif
	),
	m_database_connection(p_database_connection),
	m_top_panel(0),
	m_menu_bar(0),
	m_file_menu(0),
	m_new_menu(0),
	m_edit_menu(0),
	m_help_menu(0)
{
	// Set the frame icon
	// TODO I should use SetIcons to associate several icons of
	// different sizes with the Window. This avoids possible ugliness from
	// resizing of a single icon when different sizes are required in
	// different situations.
	SetIcon(wxIcon(icon_xpm));

	// Create menus
	m_menu_bar = new wxMenuBar;
	m_file_menu = new wxMenu;
	m_new_menu = new wxMenu;
	m_edit_menu = new wxMenu;
	m_help_menu = new wxMenu;

	// Configure "file" menu
	m_file_menu->Append
	(	wxID_EXIT,
		wxString("E&xit\tAlt-X"),
		wxString("Quit this program")
	);
	m_menu_bar->Append(m_file_menu, wxString("&File"));

	// Configure "new" menu
	m_new_menu->Append
	(	s_new_bs_account_id,
		wxString("New &account"),
		wxString("Create a new asset or liability account")
	);
	m_new_menu->Append
	(	s_new_pl_account_id,
		wxString("New &category"),
		wxString("Create a new revenue or expenditure category")
	);
	m_new_menu->Append
	(	s_new_transaction_id,
		wxString("New &transaction \tAlt-T"),
		wxString("Record a new transaction")
	);
	m_menu_bar->Append(m_new_menu, wxString("&New"));

	// Configure "edit" menu
	m_edit_menu->Append
	(	s_edit_bs_account_id,
		wxString("Edit selected &account"),
		wxString("Edit an exising asset or liability account")
	);
	m_edit_menu->Append
	(	s_edit_pl_account_id,
		wxString("Edit selected &category"),
		wxString("Edit an existing revenue or expenditure category")
	);
	m_menu_bar->Append(m_edit_menu, wxString("&Edit"));

	// Configure "help" menu
	m_help_menu->Append
	(	wxID_ABOUT,
		wxString("&About...\tF1"),
		wxString("Show about dialog")
	);
	m_menu_bar->Append(m_help_menu, wxString("&Help"));

	SetMenuBar(m_menu_bar);

	// Connect events to menus
	Connect
	(	wxID_EXIT,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_quit)
	);
	Connect
	(	s_new_bs_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_bs_account)
	);
	Connect
	(	s_new_pl_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_pl_account)
	);
	Connect
	(	s_new_transaction_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_new_transaction)
	);
	Connect
	(	s_edit_bs_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_edit_bs_account)
	);
	Connect
	(	s_edit_pl_account_id,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_edit_pl_account)
	);
	Connect
	(	wxID_ABOUT,
		wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Frame::on_about)
	);

#	if JEWEL_ON_WINDOWS
		Maximize();
#	endif

	m_top_panel = new TopPanel(this, m_database_connection);

}
	
void
Frame::on_about(wxCommandEvent& event)
{
	(void)event;  // Silence compiler warning re. unused parameter.
	// TODO Put better message here
	wxString msg;
	msg.Printf
	(	"Hello and welcome to %s",
		bstring_to_wx(Application::application_name())
	);
	wxMessageBox(msg);
	return;
{'fraction_non_alphanumeric': 0.11665257819103973, 'fraction_numerical': 0.0028982007003985027, 'mean_word_length': 5.222389181066867, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 43, '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': '2952274', 'n_tokens_mistral': 3280, 'n_tokens_neox': 3154, 'n_words': 616}