/*
 * Electric(tm) VLSI Design System
 *
 * File: graphpcdialog.cpp
 * Dialogs Implementation file
 * Written by: Steven M. Rubin, Static Free Software
 *
 * Copyright (c) 2000 Static Free Software.
 *
 * Electric(tm) 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 2 of the License, or
 * (at your option) any later version.
 *
 * Electric(tm) 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 Electric(tm); see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, Mass 02111-1307, USA.
 *
 * Static Free Software
 * 4119 Alpine Road
 * Portola Valley, California 94028
 * info@staticfreesoft.com
 */

#include "graphpcstdafx.h"
#include "graphpc.h"
#include "graphpcdialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CElectricDialog dialog


CElectricDialog::CElectricDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CElectricDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CElectricDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CElectricDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CElectricDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CElectricDialog, CDialog)
	//{{AFX_MSG_MAP(CElectricDialog)
	ON_WM_CREATE()
	ON_LBN_DBLCLK(ID_DIALOGITEM_0, OnDialogDoubleClick0)
	ON_LBN_DBLCLK(ID_DIALOGITEM_1, OnDialogDoubleClick1)
	ON_LBN_DBLCLK(ID_DIALOGITEM_2, OnDialogDoubleClick2)
	ON_LBN_DBLCLK(ID_DIALOGITEM_3, OnDialogDoubleClick3)
	ON_LBN_DBLCLK(ID_DIALOGITEM_4, OnDialogDoubleClick4)
	ON_LBN_DBLCLK(ID_DIALOGITEM_5, OnDialogDoubleClick5)
	ON_LBN_DBLCLK(ID_DIALOGITEM_6, OnDialogDoubleClick6)
	ON_LBN_DBLCLK(ID_DIALOGITEM_7, OnDialogDoubleClick7)
	ON_LBN_DBLCLK(ID_DIALOGITEM_8, OnDialogDoubleClick8)
	ON_LBN_DBLCLK(ID_DIALOGITEM_9, OnDialogDoubleClick9)
	ON_LBN_DBLCLK(ID_DIALOGITEM_10, OnDialogDoubleClick10)
	ON_LBN_DBLCLK(ID_DIALOGITEM_11, OnDialogDoubleClick11)
	ON_LBN_DBLCLK(ID_DIALOGITEM_12, OnDialogDoubleClick12)
	ON_LBN_DBLCLK(ID_DIALOGITEM_13, OnDialogDoubleClick13)
	ON_LBN_DBLCLK(ID_DIALOGITEM_14, OnDialogDoubleClick14)
	ON_LBN_DBLCLK(ID_DIALOGITEM_15, OnDialogDoubleClick15)
	ON_LBN_DBLCLK(ID_DIALOGITEM_16, OnDialogDoubleClick16)
	ON_LBN_DBLCLK(ID_DIALOGITEM_17, OnDialogDoubleClick17)
	ON_LBN_DBLCLK(ID_DIALOGITEM_18, OnDialogDoubleClick18)
	ON_LBN_DBLCLK(ID_DIALOGITEM_19, OnDialogDoubleClick19)
	ON_LBN_DBLCLK(ID_DIALOGITEM_20, OnDialogDoubleClick20)
	ON_LBN_DBLCLK(ID_DIALOGITEM_21, OnDialogDoubleClick21)
	ON_LBN_DBLCLK(ID_DIALOGITEM_22, OnDialogDoubleClick22)
	ON_LBN_DBLCLK(ID_DIALOGITEM_23, OnDialogDoubleClick23)
	ON_LBN_DBLCLK(ID_DIALOGITEM_24, OnDialogDoubleClick24)
	ON_LBN_DBLCLK(ID_DIALOGITEM_25, OnDialogDoubleClick25)
	ON_LBN_DBLCLK(ID_DIALOGITEM_26, OnDialogDoubleClick26)
	ON_LBN_DBLCLK(ID_DIALOGITEM_27, OnDialogDoubleClick27)
	ON_LBN_DBLCLK(ID_DIALOGITEM_28, OnDialogDoubleClick28)
	ON_LBN_DBLCLK(ID_DIALOGITEM_29, OnDialogDoubleClick29)
	ON_LBN_DBLCLK(ID_DIALOGITEM_30, OnDialogDoubleClick30)
	ON_LBN_DBLCLK(ID_DIALOGITEM_31, OnDialogDoubleClick31)
	ON_LBN_DBLCLK(ID_DIALOGITEM_32, OnDialogDoubleClick32)
	ON_LBN_DBLCLK(ID_DIALOGITEM_33, OnDialogDoubleClick33)
	ON_LBN_DBLCLK(ID_DIALOGITEM_34, OnDialogDoubleClick34)
	ON_LBN_DBLCLK(ID_DIALOGITEM_35, OnDialogDoubleClick35)
	ON_LBN_DBLCLK(ID_DIALOGITEM_36, OnDialogDoubleClick36)
	ON_LBN_DBLCLK(ID_DIALOGITEM_37, OnDialogDoubleClick37)
	ON_LBN_DBLCLK(ID_DIALOGITEM_38, OnDialogDoubleClick38)
	ON_LBN_DBLCLK(ID_DIALOGITEM_39, OnDialogDoubleClick39)
	ON_EN_CHANGE(ID_DIALOGITEM_0, OnDialogTextChanged0)
	ON_EN_CHANGE(ID_DIALOGITEM_1, OnDialogTextChanged1)
	ON_EN_CHANGE(ID_DIALOGITEM_2, OnDialogTextChanged2)
	ON_EN_CHANGE(ID_DIALOGITEM_3, OnDialogTextChanged3)
	ON_EN_CHANGE(ID_DIALOGITEM_4, OnDialogTextChanged4)
	ON_EN_CHANGE(ID_DIALOGITEM_5, OnDialogTextChanged5)
	ON_EN_CHANGE(ID_DIALOGITEM_6, OnDialogTextChanged6)
	ON_EN_CHANGE(ID_DIALOGITEM_7, OnDialogTextChanged7)
	ON_EN_CHANGE(ID_DIALOGITEM_8, OnDialogTextChanged8)
	ON_EN_CHANGE(ID_DIALOGITEM_9, OnDialogTextChanged9)
	ON_EN_CHANGE(ID_DIALOGITEM_10, OnDialogTextChanged10)
	ON_EN_CHANGE(ID_DIALOGITEM_11, OnDialogTextChanged11)
	ON_EN_CHANGE(ID_DIALOGITEM_12, OnDialogTextChanged12)
	ON_EN_CHANGE(ID_DIALOGITEM_13, OnDialogTextChanged13)
	ON_EN_CHANGE(ID_DIALOGITEM_14, OnDialogTextChanged14)
	ON_EN_CHANGE(ID_DIALOGITEM_15, OnDialogTextChanged15)
	ON_EN_CHANGE(ID_DIALOGITEM_16, OnDialogTextChanged16)
	ON_EN_CHANGE(ID_DIALOGITEM_17, OnDialogTextChanged17)
	ON_EN_CHANGE(ID_DIALOGITEM_18, OnDialogTextChanged18)
	ON_EN_CHANGE(ID_DIALOGITEM_19, OnDialogTextChanged19)
	ON_EN_CHANGE(ID_DIALOGITEM_20, OnDialogTextChanged20)
	ON_EN_CHANGE(ID_DIALOGITEM_21, OnDialogTextChanged21)
	ON_EN_CHANGE(ID_DIALOGITEM_22, OnDialogTextChanged22)
	ON_EN_CHANGE(ID_DIALOGITEM_23, OnDialogTextChanged23)
	ON_EN_CHANGE(ID_DIALOGITEM_24, OnDialogTextChanged24)
	ON_EN_CHANGE(ID_DIALOGITEM_25, OnDialogTextChanged25)
	ON_EN_CHANGE(ID_DIALOGITEM_26, OnDialogTextChanged26)
	ON_EN_CHANGE(ID_DIALOGITEM_27, OnDialogTextChanged27)
	ON_EN_CHANGE(ID_DIALOGITEM_28, OnDialogTextChanged28)
	ON_EN_CHANGE(ID_DIALOGITEM_29, OnDialogTextChanged29)
	ON_EN_CHANGE(ID_DIALOGITEM_30, OnDialogTextChanged30)
	ON_EN_CHANGE(ID_DIALOGITEM_31, OnDialogTextChanged31)
	ON_EN_CHANGE(ID_DIALOGITEM_32, OnDialogTextChanged32)
	ON_EN_CHANGE(ID_DIALOGITEM_33, OnDialogTextChanged33)
	ON_EN_CHANGE(ID_DIALOGITEM_34, OnDialogTextChanged34)
	ON_EN_CHANGE(ID_DIALOGITEM_35, OnDialogTextChanged35)
	ON_EN_CHANGE(ID_DIALOGITEM_36, OnDialogTextChanged36)
	ON_EN_CHANGE(ID_DIALOGITEM_37, OnDialogTextChanged37)
	ON_EN_CHANGE(ID_DIALOGITEM_38, OnDialogTextChanged38)
	ON_EN_CHANGE(ID_DIALOGITEM_39, OnDialogTextChanged39)
	ON_WM_PAINT()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_VKEYTOITEM()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CElectricDialog message handlers
void gra_itemclicked(int nID);
void gra_itemdoubleclicked(int nID);
void gra_diaredrawitem(void);
void gra_dodialogtextchange(int nID);
void gra_buttonaction(int state, UINT nFlags, CPoint point, CWnd *frm);
void gra_mouseaction(UINT nFlags, CPoint point, CWnd *frm);
int gra_dodialoglistkey(UINT nKey, CListBox* pListBox, UINT nIndex);

BOOL CElectricDialog::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
	switch (nCode)
	{
		case 1:
		case BN_CLICKED:
			gra_itemclicked(nID);
			break;
	}
	return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

int CElectricDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	return 0;
}

BOOL CElectricDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	return TRUE;
}

void CElectricDialog::OnOK()
{
	gra_itemclicked(1);
}

void CElectricDialog::OnCancel()
{
	gra_itemclicked(2);
}

void CElectricDialog::OnDialogDoubleClick0() { gra_itemdoubleclicked(0); }
void CElectricDialog::OnDialogDoubleClick1() { gra_itemdoubleclicked(1); }
void CElectricDialog::OnDialogDoubleClick2() { gra_itemdoubleclicked(2); }
void CElectricDialog::OnDialogDoubleClick3() { gra_itemdoubleclicked(3); }
void CElectricDialog::OnDialogDoubleClick4() { gra_itemdoubleclicked(4); }
void CElectricDialog::OnDialogDoubleClick5() { gra_itemdoubleclicked(5); }
void CElectricDialog::OnDialogDoubleClick6() { gra_itemdoubleclicked(6); }
void CElectricDialog::OnDialogDoubleClick7() { gra_itemdoubleclicked(7); }
void CElectricDialog::OnDialogDoubleClick8() { gra_itemdoubleclicked(8); }
void CElectricDialog::OnDialogDoubleClick9() { gra_itemdoubleclicked(9); }
void CElectricDialog::OnDialogDoubleClick10() { gra_itemdoubleclicked(10); }
void CElectricDialog::OnDialogDoubleClick11() { gra_itemdoubleclicked(11); }
void CElectricDialog::OnDialogDoubleClick12() { gra_itemdoubleclicked(12); }
void CElectricDialog::OnDialogDoubleClick13() { gra_itemdoubleclicked(13); }
void CElectricDialog::OnDialogDoubleClick14() { gra_itemdoubleclicked(14); }
void CElectricDialog::OnDialogDoubleClick15() { gra_itemdoubleclicked(15); }
void CElectricDialog::OnDialogDoubleClick16() { gra_itemdoubleclicked(16); }
void CElectricDialog::OnDialogDoubleClick17() { gra_itemdoubleclicked(17); }
void CElectricDialog::OnDialogDoubleClick18() { gra_itemdoubleclicked(18); }
void CElectricDialog::OnDialogDoubleClick19() { gra_itemdoubleclicked(19); }
void CElectricDialog::OnDialogDoubleClick20() { gra_itemdoubleclicked(20); }
void CElectricDialog::OnDialogDoubleClick21() { gra_itemdoubleclicked(21); }
void CElectricDialog::OnDialogDoubleClick22() { gra_itemdoubleclicked(22); }
void CElectricDialog::OnDialogDoubleClick23() { gra_itemdoubleclicked(23); }
void CElectricDialog::OnDialogDoubleClick24() { gra_itemdoubleclicked(24); }
void CElectricDialog::OnDialogDoubleClick25() { gra_itemdoubleclicked(25); }
void CElectricDialog::OnDialogDoubleClick26() { gra_itemdoubleclicked(26); }
void CElectricDialog::OnDialogDoubleClick27() { gra_itemdoubleclicked(27); }
void CElectricDialog::OnDialogDoubleClick28() { gra_itemdoubleclicked(28); }
void CElectricDialog::OnDialogDoubleClick29() { gra_itemdoubleclicked(29); }
void CElectricDialog::OnDialogDoubleClick30() { gra_itemdoubleclicked(30); }
void CElectricDialog::OnDialogDoubleClick31() { gra_itemdoubleclicked(31); }
void CElectricDialog::OnDialogDoubleClick32() { gra_itemdoubleclicked(32); }
void CElectricDialog::OnDialogDoubleClick33() { gra_itemdoubleclicked(33); }
void CElectricDialog::OnDialogDoubleClick34() { gra_itemdoubleclicked(34); }
void CElectricDialog::OnDialogDoubleClick35() { gra_itemdoubleclicked(35); }
void CElectricDialog::OnDialogDoubleClick36() { gra_itemdoubleclicked(36); }
void CElectricDialog::OnDialogDoubleClick37() { gra_itemdoubleclicked(37); }
void CElectricDialog::OnDialogDoubleClick38() { gra_itemdoubleclicked(38); }
void CElectricDialog::OnDialogDoubleClick39() { gra_itemdoubleclicked(39); }

void CElectricDialog::OnDialogTextChanged0() { gra_dodialogtextchange(0); }
void CElectricDialog::OnDialogTextChanged1() { gra_dodialogtextchange(1); }
void CElectricDialog::OnDialogTextChanged2() { gra_dodialogtextchange(2); }
void CElectricDialog::OnDialogTextChanged3() { gra_dodialogtextchange(3); }
void CElectricDialog::OnDialogTextChanged4() { gra_dodialogtextchange(4); }
void CElectricDialog::OnDialogTextChanged5() { gra_dodialogtextchange(5); }
void CElectricDialog::OnDialogTextChanged6() { gra_dodialogtextchange(6); }
void CElectricDialog::OnDialogTextChanged7() { gra_dodialogtextchange(7); }
void CElectricDialog::OnDialogTextChanged8() { gra_dodialogtextchange(8); }
void CElectricDialog::OnDialogTextChanged9() { gra_dodialogtextchange(9); }
void CElectricDialog::OnDialogTextChanged10() { gra_dodialogtextchange(10); }
void CElectricDialog::OnDialogTextChanged11() { gra_dodialogtextchange(11); }
void CElectricDialog::OnDialogTextChanged12() { gra_dodialogtextchange(12); }
void CElectricDialog::OnDialogTextChanged13() { gra_dodialogtextchange(13); }
void CElectricDialog::OnDialogTextChanged14() { gra_dodialogtextchange(14); }
void CElectricDialog::OnDialogTextChanged15() { gra_dodialogtextchange(15); }
void CElectricDialog::OnDialogTextChanged16() { gra_dodialogtextchange(16); }
void CElectricDialog::OnDialogTextChanged17() { gra_dodialogtextchange(17); }
void CElectricDialog::OnDialogTextChanged18() { gra_dodialogtextchange(18); }
void CElectricDialog::OnDialogTextChanged19() { gra_dodialogtextchange(19); }
void CElectricDialog::OnDialogTextChanged20() { gra_dodialogtextchange(20); }
void CElectricDialog::OnDialogTextChanged21() { gra_dodialogtextchange(21); }
void CElectricDialog::OnDialogTextChanged22() { gra_dodialogtextchange(22); }
void CElectricDialog::OnDialogTextChanged23() { gra_dodialogtextchange(23); }
void CElectricDialog::OnDialogTextChanged24() { gra_dodialogtextchange(24); }
void CElectricDialog::OnDialogTextChanged25() { gra_dodialogtextchange(25); }
void CElectricDialog::OnDialogTextChanged26() { gra_dodialogtextchange(26); }
void CElectricDialog::OnDialogTextChanged27() { gra_dodialogtextchange(27); }
void CElectricDialog::OnDialogTextChanged28() { gra_dodialogtextchange(28); }
void CElectricDialog::OnDialogTextChanged29() { gra_dodialogtextchange(29); }
void CElectricDialog::OnDialogTextChanged30() { gra_dodialogtextchange(30); }
void CElectricDialog::OnDialogTextChanged31() { gra_dodialogtextchange(31); }
void CElectricDialog::OnDialogTextChanged32() { gra_dodialogtextchange(32); }
void CElectricDialog::OnDialogTextChanged33() { gra_dodialogtextchange(33); }
void CElectricDialog::OnDialogTextChanged34() { gra_dodialogtextchange(34); }
void CElectricDialog::OnDialogTextChanged35() { gra_dodialogtextchange(35); }
void CElectricDialog::OnDialogTextChanged36() { gra_dodialogtextchange(36); }
void CElectricDialog::OnDialogTextChanged37() { gra_dodialogtextchange(37); }
void CElectricDialog::OnDialogTextChanged38() { gra_dodialogtextchange(38); }
void CElectricDialog::OnDialogTextChanged39() { gra_dodialogtextchange(39); }

void CElectricDialog::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	gra_diaredrawitem();
}

void CElectricDialog::OnMouseMove(UINT nFlags, CPoint point)
{
	gra_mouseaction(nFlags, point, this);
	CDialog::OnMouseMove(nFlags, point);
}

void CElectricDialog::OnLButtonDown(UINT nFlags, CPoint point)
{
	gra_buttonaction(0, nFlags|MK_LBUTTON, point, this);
	CDialog::OnLButtonDown(nFlags, point);
}

void CElectricDialog::OnLButtonUp(UINT nFlags, CPoint point)
{
	gra_buttonaction(1, nFlags|MK_LBUTTON, point, this);
	CDialog::OnLButtonUp(nFlags, point);
}

int CElectricDialog::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
	if (gra_dodialoglistkey(nKey, pListBox, nIndex) == 0) return(-2);
	return(-1);
}
