/*
 * File:		  demo.h
 * Purpose:	  Serial port class demo header file
 * Author:	  George Tasker
 * Created:	  30-05-1997
 */


const char PROGRAM_TITLE[]		= "wxSerial demo program";
const char PROGRAM_VERSION[]	= "v1.0";


// Menu items
#define FILE_EXIT			199

#define PORT_ADD			200
#define PORT_EDIT			205
#define PORT_OPEN			210
#define PORT_CLOSE		290

#define ACTION_SEND		300
#define ACTION_READ		310
#define ACTION_FLUSH		320

#define HELP_ABOUT		500


const int	MAX_SERIAL_PORTS	=  4;
int			DefinedPorts		=  0;
int			SelectedPort		= -1;


wxSerial *SerialPort[MAX_SERIAL_PORTS];

// Define a new frame type
class myFrame: public wxFrame
{ 
	private:
		Bool			AddingPort;
		Bool			exiting;

	public:
		myFrame(wxFrame *frame, char *title, int x, int y, int w, int h);

		wxPanel		*Panel;
		wxButton		*SendBtn, *ReceiveBtn;
		wxText		*SendTxt, *ReceiveTxt;
		wxText		*FramingStartTxt, *FramingStopTxt;
		wxText		*TerminatorTxt, *MaxLenTxt;

		wxText		*BaudTxt;
		wxText		*ParityTxt;
		wxText		*WordLenTxt;
		wxText		*StopBitsTxt;

		wxMessage	*BaudMsg;
		wxMessage	*ParityMsg;
		wxMessage	*WordLenMsg;
		wxMessage	*StopBitsMsg;
		
		wxText		*PortNameTxt;
		wxChoice		*PortChoice;
		wxButton		*AddBtn, *EditBtn;
		wxButton		*SaveBtn;
		wxMessage	*StatusMsg;
//		wxMessage	*SettingsMsg;

		wxGroupBox  *SendGrp, *ReceiveGrp;

		void OnMenuCommand(int id);
		Bool OnClose(void);
		void OnActivate(Bool) {};  // necessary for accelerators to work
		void OnSize(int w=-1, int h=-1);
		void OnCommand(wxWindow& win, wxCommandEvent& event);

		Bool SendMessage();
		Bool ReceiveResponse();
		void ShowResponseInASCII(char *response);

		void BuildPanel();
		void ShowPortStatus(int p=SelectedPort);
		void ShowPortSettings(int p=SelectedPort);
};


// Define a new application type
class myApp: public wxApp
{ 
	public:
		myFrame			*Frame;
		wxTextWindow	*DebugWindow;

		wxFrame 			*OnInit(void);
		void				 DebugMsg(char *msg,char *lf="");
};


