/*
	Copyright (C) 2022-2024 Mark Tyler

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program in the file COPYING.
*/

#ifndef BE_H_
#define BE_H_



#include <mtkit.h>
#include <mtdatawell_math.h>



// Functions return: 0 = success, NULL = fail; unless otherwise stated.



#ifdef __cplusplus
extern "C" {
#endif

// C API



#define PREFS_WINDOW_MAXIMIZED		"main.window_max"
#define PREFS_WINDOW_X			"main.window_x"
#define PREFS_WINDOW_Y			"main.window_y"
#define PREFS_WINDOW_W			"main.window_w"
#define PREFS_WINDOW_H			"main.window_h"

#define PREFS_CALC_FLOAT_BITS		"calc.float.bits"
#define PREFS_CALC_SNIP_SIZE		"calc.snip_size"



#ifdef __cplusplus
}



// C++ API
class CommandLine;
class MemPrefs;



class MemPrefs
{
public:
	int			window_x		= 0;
	int			window_y		= 0;
	int			window_w		= 0;
	int			window_h		= 0;
	int			window_maximized	= 0;

	int			calc_float_bits		= 10;
	int			calc_snip_size		= 1000;

	mtKit::UPrefUIEdit	ui_prefs;
};



class CommandLine
{
public:
	int parse ( int argc, char const * const * argv );
		// 0 = Continue running (start UI)
		// 1 = Terminate program, returning exit.value()

	// Const accessors

	MemPrefs const & get_memprefs () const	{ return m_memprefs; }

	// Accessors

	mtKit::Exit & exit ()			{ return m_exit; }
	mtKit::UserPrefs & userprefs ()		{ return m_userprefs; }

/// ----------------------------------------------------------------------------

private:
	void prefs_init ( char const * filename );

/// ----------------------------------------------------------------------------

	mtKit::Exit		m_exit;

	// uprefs must be destroyed before mprefs, so it appears below it:
	MemPrefs		m_memprefs;
	mtKit::UserPrefs	m_userprefs;
};



#endif		// C++ API



#endif		// BE_H_

