#pragma once

#include <wx/panel.h>
#include <wx/statbmp.h>
#include <wx/textctrl.h>
#include "../../Headers/GUI/ComponentData.h"

/**
* A dashboard tile for a single component: shows its icon, name, enabled status, and current data, auto-sizing the
* data field to fit its text.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*/
class ComponentPanel : public wxPanel
{
protected:
	ComponentData myComponentData;	///< The component this panel displays.

	wxStaticBitmap* myComponentIconField;	///< The icon control.
	wxTextCtrl* myDeviceNameField;			///< The device-name control.
	wxTextCtrl* myStatusField;				///< The enabled/disabled status control.
	wxTextCtrl* myDataField;				///< The data-display control.

	/**
	* Adjusts the height of the data field so all the text can be shown, then re-lays out this panel and its parent.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	//Called by UpdateUI() after the data field's text changes.
	* @endcode
	*/
	void AdjustDataFieldHeight();

public:
	/**
	* Builds the component tile: stores the component data and lays out the icon and the name/status/data text fields
	* in a vertical sizer.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	ComponentPanel* panel = new ComponentPanel(parent, componentData);
	* @endcode
	*
	* @param [in] theParentWindow  The parent window.
	* @param [in] theComponentData The component this panel displays.
	*/
	ComponentPanel(wxWindow* theParentWindow, const ComponentData& theComponentData);

	/**
	* Refreshes the tile's controls from the current component data (icon, name, enabled/disabled status, data) and
	* re-sizes the data field to fit.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	panel.UpdateUI();
	* @endcode
	*/
	void UpdateUI();

	/**
	* Gets the component data this panel displays.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	ComponentData& data = panel.GetComponentData();
	* @endcode
	*
	* @return A reference to the panel's component data.
	*/
	ComponentData& GetComponentData();
};
