//-----------------------------------------------------------------------------
#ifndef DeviceConfigureFrameH
#define DeviceConfigureFrameH DeviceConfigureFrameH
//-----------------------------------------------------------------------------
#include "DevCtrl.h"
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <wx/wx.h>

class DevicePropertyHandler;
class HistogramCanvas;
class ImageCanvas;
class LineProfileCanvas;
class wxPropertyGrid;
class wxPropertyGridEvent;
class wxSplitterEvent;
class wxSplitterWindow;

DECLARE_EVENT_TYPE(imageReadyEvent, -1)
DECLARE_EVENT_TYPE(imageSkippedEvent, -2)
DECLARE_EVENT_TYPE(toggleDisplayArea, -3)
DECLARE_EVENT_TYPE(liveModeAborted, -4)

//-----------------------------------------------------------------------------
class PropViewFrame : public wxFrame
//-----------------------------------------------------------------------------
{
public:
	PropViewFrame(const wxString& title, const wxPoint& pos, const wxSize& size, const std::string& cmdLine );
	~PropViewFrame();
protected:
	// event handlers (these functions should _not_ be virtual)
	void OnAbout( wxCommandEvent& e );
	void OnActivateDisplay( wxCommandEvent& e );
	void OnBtnAbort( wxCommandEvent& e );
	void OnBtnLive( wxCommandEvent& e );
	void OnBtnStop( wxCommandEvent& e );
	void OnUseDevice( wxCommandEvent& e );
	void OnBtnSnap( wxCommandEvent& e );
	void OnCBEnableHistogram( wxCommandEvent& );
	void OnCBEnableLineProfile( wxCommandEvent& );
	void OnClose( wxCloseEvent& e );
	void OnConnectedOnly( wxCommandEvent& e );
	void OnDevComboTextChanged( wxCommandEvent& e );
	void OnExportActiveDevice( wxCommandEvent& e );
	void OnHistogramUpdateSpeedTextChanged( wxCommandEvent& e );
	void OnHistogramAOIxTextChanged( wxCommandEvent& e );
	void OnHistogramAOIyTextChanged( wxCommandEvent& e );
	void OnHistogramAOIwTextChanged( wxCommandEvent& e );
	void OnHistogramAOIhTextChanged( wxCommandEvent& e );
	void OnImageReady( wxCommandEvent& e );
	void OnImageSkipped( wxCommandEvent& e );
	void OnImportActiveDevice( wxCommandEvent& e );
	void OnLineProfileUpdateSpeedTextChanged( wxCommandEvent& e );
	void OnLineProfileAOIxTextChanged( wxCommandEvent& e );
	void OnLineProfileAOIyTextChanged( wxCommandEvent& e );
	void OnLineProfileAOIwTextChanged( wxCommandEvent& e );
	void OnLineProfileAOIhTextChanged( wxCommandEvent& e );
	void OnLiveModeAborted( wxCommandEvent& e );
	void OnLoadActiveDevice( wxCommandEvent& e );
	void OnLoadFromDefault( wxCommandEvent& e );
	void OnPaint( wxPaintEvent& e );
	void OnPopUpMethExec( wxCommandEvent& e );
	void OnPopUpPropRestoreDefault( wxCommandEvent& e );
	void OnPopUpPropAppendValue( wxCommandEvent& e );
	void OnPopUpPropDeleteValue( wxCommandEvent& e );
	void OnPropertyChanged( wxPropertyGridEvent& e );
	void OnPropertyRightClicked( wxPropertyGridEvent& e );
	void OnQuit( wxCommandEvent& e );
	void OnSaveActiveDevice( wxCommandEvent& e );
	void OnSaveBitmap( wxCommandEvent& e );
	void OnSaveToDefault( wxCommandEvent& e );
	void OnSaveSystemToDefault( wxCommandEvent& e );
	void OnScaleDisplay( wxCommandEvent& e );
	void OnShowDisplayMessagesAsOverlay( wxCommandEvent& e );
	void OnSettingsDisplayLogWindow( wxCommandEvent& );
	void OnSettingsPropGrid_Show( wxCommandEvent& );
	void OnSettingsPropGrid_StandardView( wxCommandEvent& );
	void OnSettingsPropGrid_DevelopersView( wxCommandEvent& );
	void OnSize( wxSizeEvent& e );
	void OnSplitterSashPosChanged( wxSplitterEvent& e );
	void OnTimer( wxTimerEvent& e );	
	void OnToggleDisplayWindowSize( wxCommandEvent& e );	
	void SetupDlgControls( void );
private:
	//-----------------------------------------------------------------------------
    enum TTimerEvent
	//-----------------------------------------------------------------------------
	{
		teListUpdate
	};
	//-----------------------------------------------------------------------------
	// IDs for the controls and the menu commands
	enum TMenuItem
	//-----------------------------------------------------------------------------
	{
		miQuit = 1,
		miHelp_About,
		miAction_UseDevice,
		miActionSave_ToDefault,
		miActionSave_SystemToDefault,
		miActionSave_ActiveDevice,
		miActionSave_ExportActiveDevice,
		miActionLoad_FromDefault,
		miActionLoad_ActiveDevice,
		miActionLoad_ImportActiveDevice,
		miAction_SaveBitmap,
		miPopUpMethExec,
		miPopUpPropRestoreDefault,
		miPopUpPropAppendValue,
		miPopUpPropDeleteValue,
		miCapture_Live,
		miCapture_Snap,
		miCapture_Stop,
		miCapture_Abort,
		miSettingsDisplay_Scale,
		miSettingsDisplay_OverlayMessages,
		miSettingsDisplay_Active,
		miSettings_ShowConnectedDevicesOnly,
		miSettings_ShowLogWindow,
		miSettingsPropGrid_Show,
		miSettingsPropGrid_StandardView,
		miSettingsPropGrid_DevelopersView
	};
	//-----------------------------------------------------------------------------
	enum TWidgetIDs
	//-----------------------------------------------------------------------------
	{
		widBtnAbort = 1,
		widBtnLive,
		widUseDevice,
		widBtnSnap,
		widCBEnableHistogram,
		widCBEnableLineProfile,
		widTextDevice,
		widDevCombo,
		widHorSplitter,
		widLogHistogramSplitter,
		widMainFrame,
		widPropGrid,
		widSCHistogramAOIh,
		widSCHistogramAOIw,
		widSCHistogramAOIx,
		widSCHistogramAOIy,
		widSCHistogramUpdateSpeed,
		widSCLineProfileAOIh,
		widSCLineProfileAOIw,
		widSCLineProfileAOIx,
		widSCLineProfileAOIy,
		widSCLineProfileUpdateSpeed,
		widStatusBar,
		widVerSplitter,
	};
	//-----------------------------------------------------------------------------
	enum
	//-----------------------------------------------------------------------------
	{
		NO_OF_STATUSBAR_FIELDS = 6,
		TIMER_PERIOD = 750
	};
	//-----------------------------------------------------------------------------
	enum TStatusBarField
	//-----------------------------------------------------------------------------
	{
		sbfFPS,
		sbfFrameCount,
		sbfImageFormat,
		sbfErrorCount,
		sbfExposeTime,
		sbfGain
	};
	bool								m_boDisplayWindowMaximized;
	mvIMPACT::acquire::ImageBufferDesc	m_CurrentImage;
	wxString							m_CurrentPixelFormat;
	mvIMPACT::acquire::RequestInfo		m_CurrentRequestInfo;
	unsigned int						m_DeviceListChangedCounter;
	int									m_HorizontalSplitterPos;
	wxTimer								m_ListUpdateTimer;
	const wxString						m_NoDevStr;
	wxCheckBox*							m_pCBEnableLineProfile;
	wxCheckBox*							m_pCBEnableHistogram;
	wxComboBox*							m_pDevCombo;
	DevicePropertyHandler*				m_pDevPropHandler;
	ImageCanvas*						m_pDisplayArea;
	HistogramCanvas*					m_pHistogramArea;
	wxSplitterWindow*					m_pHorizontalSplitter;
	LineProfileCanvas*					m_pLineProfileArea;
	wxTextCtrl*							m_pLogWindow;
	wxNotebook*							m_pLowerRightWindow;
	wxMenuItem*							m_pMIUse;
	wxMenuItem*							m_pMISaveToDefault;
	wxMenuItem*							m_pMISaveSystemToDefault;
	wxMenuItem*							m_pMISaveActiveDevice;
	wxMenuItem*							m_pMIExportActiveDevice;
	wxMenuItem*							m_pMILoadFromDefault;
	wxMenuItem*							m_pMILoadActiveDevice;
	wxMenuItem*							m_pMIImportActiveDevice;
	wxMenuItem*							m_pMIActionSaveBitmap;
	wxMenuItem*							m_pMICaptureLive;
	wxMenuItem*							m_pMICaptureStop;
	wxMenuItem*							m_pMICaptureSnap;
	wxMenuItem*							m_pMICaptureAbort;
	wxMenuItem*							m_pMISettingsDisplayScale;
	wxMenuItem*							m_pMISettingsDisplayShowMessagesAsOverlay;
	wxMenuItem*							m_pMISettingsDisplayActive;
	wxMenuItem*							m_pMISettingsConnectedOnly;
	wxMenuItem*							m_pMISettingsDisplayLogWindow;
	wxMenuItem*							m_pMISettingsPropGrid_Show;
	wxMenuItem*							m_pMISettingsPropGrid_StandardView;
	wxMenuItem*							m_pMISettingsPropGrid_DevelopersView;
	wxToolBar*							m_pToolBar;
	wxPropertyGrid*						m_pPropGrid;
	wxSpinCtrl*							m_pSCLineProfileAOIx;
	wxSpinCtrl*							m_pSCLineProfileAOIy;
	wxSpinCtrl*							m_pSCLineProfileAOIw;
	wxSpinCtrl*							m_pSCLineProfileAOIh;
	wxSpinCtrl*							m_pSCLineProfileUpdateSpeed;
	wxSpinCtrl*							m_pSCHistogramAOIx;
	wxSpinCtrl*							m_pSCHistogramAOIy;
	wxSpinCtrl*							m_pSCHistogramAOIw;
	wxSpinCtrl*							m_pSCHistogramAOIh;
	wxSpinCtrl*							m_pSCHistogramUpdateSpeed;
	wxStatusBar*						m_pStatusBar;
	wxSplitterWindow*					m_pVerticalSplitter;
	int									m_VerticalSplitterPos;
	DevicePropertyHandler::TViewMode	m_ViewMode;
	void								Deinit( void );
	void								SetupDisplayLogSplitter( bool boSplit );
	void								SetupVerSplitter( bool boSplit );
	void								StartLive( void );
	void								UpdateDeviceComboBox( void );
	void								UpdateDeviceFromComboBox( void );
	void								UpdateData( void );
	void								UpdateStatusBar( void );
	void								UpdateTitle( void );
	void								UpdatePropGridSplitter( void );
	void								ToggleCurrentDevice( void );
	void								WriteLogMessage( const wxString& msg, const wxTextAttr& style );
	void								WriteErrorMessage( const wxString& msg );
	// any class wishing to process wxWidgets events must use this macro
	DECLARE_EVENT_TABLE()
};

#endif // DeviceConfigureFrameH

