//
//	Copyright © 2006 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#pragma once

namespace VectorWorks
{
	namespace VWUI
	{
		// ---------------------------------------------------------------------------------------
		enum EControlAlignMode {
			kControlAlignModeResize		= 0,
			kControlAlignModeShift		= 1
		};

		// ---------------------------------------------------------------------------------------
		typedef		long			TControlID;

		// ---------------------------------------------------------------------------------------
		class VWDialog;
		class VWDialogEventArgs;

		// ---------------------------------------------------------------------------------------
		class VWControl
		{
			friend class VWDialog;
		public:
										VWControl(TControlID id);
			virtual						~VWControl();

			bool						CreateControl(VWDialog* pDlg);

		public:
			virtual TControlID			GetControlID() const;
			void						AlignLeftEdge(short alingID, EControlAlignMode mode);
			void						AlignRightEdge(short alingID, EControlAlignMode mode);
			void						AlignBottomEdge(short alingID, EControlAlignMode mode);

			void						SetEdgeBinding(bool bBoundToLeft, bool bBoundToRight, bool bBoundToTop, bool bBoundToBottom);

		// eventing
		public:
			virtual void				NotifyEvent();

		// state
		public:
			void						Enable(bool bEnable=true);
			bool						IsEnabled(void) const;
			void						Show(bool bVisible=true);
			bool						IsVisible(void) const;
			void						Editable(bool bEditable);
			void						SetControlText(short strListID, short strTextIndex);
			void						SetControlText(const TXString& text);
			void						SetHelpText(short strListID, short strHelpIndex);
			void						SetHelpText(const TXString& text);

		protected:
			virtual void				AttachControl();

		protected:
			TControlID					fControlID;
			VWDialog*					fpParentDlg;
		};
	}
}

////////////////////////////////////////////////////////////////////////////////////
// dispath function macros for making event dispatch maps for the dialog's controls
#define		DEFINE_EVENT_DISPATH_MAP		virtual void DispatchEvent(TControlID controlID, VWDialogEventArgs& eventArg)
#define		EVENT_DISPATCH_MAP_BEGIN(clas)	void clas::DispatchEvent(TControlID controlID, VWDialogEventArgs& eventArg) { eventArg; switch ( controlID ) {
#define		EVENT_DISPATCH_MAP_END			case -1: default: break; } }
// event handing func: 
// SomeName(VWControl* pControl);
#define		ADD_DISPATCH_EVENT(id,f)		case id: this->f( controlID, eventArg ); break;
