#include "CAccEditMainForm.h"
#include "CGenericTableForm.h"
#include "CApplication.h"
#include "Finance3_Rsc.h"

CAccountEditMainForm::CAccountEditMainForm()
	: CEditForm(AccountEditMainForm, &recAccount, AccountEditMainOKButton, AccountEditMainCancelButton, AccountEditMainDeleteButton,
	AccountEditMainInfoButton, AccountEditMainUpRepeating, AccountEditMainDownRepeating, "Редактор счетов")
{
}

void CAccountEditMainForm::LoadData()
{
	ResetControls();
	UpdateScroller();
	
	form_record->Cache();
	
	AddControl().RegisterControl(ctText, AccountEditMainNameField, transaction_notes_idx);
	AddControl().RegisterSignedFloat(ctSignedFloat, AccountEditMainAmountField, transaction_amount_idx, AccountEditMainMinusPushButton, AccountEditMainPlusPushButton);
	AddControl().RegisterControl(ctCheckBox, AccountEditMainTotalCheckbox, transaction_flag1_idx);
	AddControl().RegisterControl(ctCheckBox, AccountEditMainActiveCheckbox, transaction_flag2_idx);
	
	// currency
	static sListStrings currency_string_list[] = { { "редакт...", pvEdit }, { "", 0 } };
	AddControl().RegisterPopupList(ctPopupList, AccountEditMainCurrencyPopTrigger, AccountEditMainCurrencyList, transaction_currency1_name_idx, currency_string_list);
	
	// group
	static sListStrings category_string_list[] = { { "редактировать...", pvEdit }, { "в полный экран...", pvFullScreen },  { "", 0 } };
	AddControl().RegisterPopupList(ctPopupList, AccountEditMainGroupPopTrigger, AccountEditMainGroupList, transaction_category1_name_idx, category_string_list);
	
	// note
//	AddControl().RegisterControl(ctText, AccountEditMainNotesField, transaction_notes_idx);
	SetScrollable(AccountEditMainNotesField, AccountEditMainNotesScrollBar, false);
	
	LoadControls();
}

void CAccountEditMainForm::SaveData()
{
	SaveControls();
	
	form_record->Pack();
}

Boolean CAccountEditMainForm::HandleEvent(EventType * eventP, ePhase phase, bool was_handled)
{
	Boolean handled = CEditForm::HandleEvent(eventP, phase, was_handled);
	
/*	if(phase != phaseHandle || handled)
		return handled;
	
	switch (eventP->eType)
	{
		case ctlSelectEvent:
			switch(eventP->data.ctlSelect.controlID)
			{
			}
		break;
	}*/
    
	return handled;
}
