# QCad
# (c) Q Solutions 1998
#
#
#
# Key Bindings
#
#
#

proc defaultBindings {} {

	global GBL

	set GBL(bind,Motion)	 <Motion>
	set GBL(bind,ShiftMotion)	 <Shift-Motion>
	set GBL(bind,Select) 	<Button-1>
	set GBL(bind,End)	 	<Button-3>
	set GBL(bind,Cancel) 	<Button-2>
	set GBL(bind,Help)	 	<Key-F1>
	set GBL(bind,DragStart) <Alt-Button-1>
	set GBL(bind,DragEnd) 	<ButtonRelease-1>
	set GBL(bind,Drag)		<Motion>

	if { [file exists ~/.sperc] } {

	  catch {
		set f [open ~/.sperc r]
		while { ! [eof $f] } {
			set l [gets $f]
			set GBL(bind,[Lindex $l 0]) [lindex $l 1]
		}
		close $f
	 }
	}
	event add	<<SELECT>> 	$GBL(bind,Select)
	event add	<<END>>   	$GBL(bind,End)

	event add	<<CANCEL>> 	$GBL(bind,Cancel)
	event add	<<MOTION>>	$GBL(bind,Motion)
	event add	<<SHIFT-MOTION>>	$GBL(bind,ShiftMotion)

	event add	<<HELP>>	$GBL(bind,Help)
#
	event add	<<DRAGSTART>> 	$GBL(bind,DragStart)
	event add	<<DRAGEND>>		$GBL(bind,DragEnd)
	event add	<<DRAG>>		$GBL(bind,Drag)


set GBL(Bindings) {

*		-		-			<<SELECT>>			{procGrab Move}
*		*		-			<<SELECT>>			{procGrab}
*		Group	*			<<MOTION>>			{procMove}
*		Group	*			<<SELECT>>			{procGroup End}
*		Group	-			<<MOTION>>			{procGroup Box}
*		Group	-			<<SELECT>>			{procGroup Mark}
*		Group	-			<<END>>				{procGroup Clear}
*		Group	-			<<SHIFT-MOTION>>	{procGroup Shift}
*		Move	*			<<MOTION>>			{procMove}
*		Move	*			<<SELECT>>			<<END>>
*		Move	*			<Key-b>				{procBreak}
*		Adjust	Connection	<<END>>				<<CANCEL>>
*		Adjust	Net			<<END>>				<<CANCEL>>
*		Adjust	Track		<Key-v>				{procTrackVia}
*		Adjust	*			<<MOTION>>			{procAdjust}
*		Adjust	*			<<SELECT>>			{procExtend}
*		AdjustS	*			<<MOTION>>			{procAdjust}
*		AdjustS	*			<<SELECT>>			<<END>>
*		Resize	*			<<MOTION>>			{procResize}
*		Resize	*			<<SELECT>>			{procEnd}
*		Resize	*			<<END>>				{procCancel}
*		Move	*			<<SELECT>>			{procEnd}
*		Create	-			<<SELECT>>			{procCreate}

*		Edit	text		<<MOTION>>			{procNull}
*		Edit	text		<<SELECT>>			<<END>>
*		Edit	text		<Key-Return>		<<END>>
*		Edit	text		<Key>				{textKey}
*		Edit	text		<Control-Key-Return> {textKey}
*		Edit	text		<Key-Esc>			<<END>>
*		Edit	text		<Alt-Key-mM>		{modePush Move}

*		Edit	line		<<SELECT>>			{procExtend}
*		Edit	rectangle	<<MOTION>>			{procResize}
*		Edit	*			<<MOTION>>			{procAdjust}
*		Edit	*			<<SELECT>>			<<END>>

B		Move	Track		<Key-l>				{procLayer Next}
B		Move	Track		<Key-L>				{procLayer Prior}
B		Move	*			<Key-Space>			{procGrabNext}
B		-		-			<Key-r>				{modePush Route}
*		Move	*			<Key-r>				{canvasTransform Rotate}
*		Move	*			<Key-x>				{canvasTransform MirrorX}
*		Move	*			<Key-y>				{canvasTransform MirrorY}

B		Route	-			<<SELECT>>			{pcbRoute}

P		Edit	PinNum		<Key-Space>			{procPartRenumber Next}
CF		-		-			<Key-a>				{schAddItem}
CF		#		#			<Alt-Key-a>			{schAddItem}
CF		Place	*			<<MOTION>>			{procMove}
CF		Place	*			<<SELECT>>			{schAddItem 1}
CF		Place	*			<<END>>				<<CANCEL>>
C		Place	*			<Key-a>				{schAltDecal}
C		-		-			<Key-D>				{schDupItem}
C		-		-			<Key-r>				{schAddItem 0 RES}
C		-		-			<Key-c>				{schAddItem 0 CAP}
CB		Move	*			<Key-a>				{schAltDecal}
CB		Place	*			<Key-a>				{schAltDecal}
CB		Place	*			<Key-Space>			{schAltDecal}
F		-		-			<Key-d>				{schAddItem 0 FLOW_CHOICE}
F		-		-			<Key-b>				{schAddItem 0 FLOW_BOX}

PD		-		-			<Key-r>				{varSet Mode PinNum}
PD		PinNum	-			<Key-r>				{pinRenumber Reset}
PD		PinNum	-			<<SELECT>>			{pinRenumber Stamp}

*		-		-			<Key-d>				{varSet Mode Delete}
*		-		-			<Key-e>				{varSet Mode Edit}
*		-		-			<Key-C>				{varSet Mode Copy}

F		-		-			<Key-c>				{schAddItem 0 FLOW_CHOICE}

*		# 		#			<<END>>				{procEnd}
*		#		#			<<CANCEL>>			{procCancel}
*		#		#			<<HELP>>			{procHelp}
*		#		#			<Alt-Key-s>			{Source}
*		#		#			<Alt-Key-l>			{LogShow}
*		#		#			<Key-i>				{canvasInfo 0}
*		#		#			<Alt-Key-i>			{canvasInfo 1}
*		?		#			<Alt-Key-m>			{varSet Mode Move}
*		?		#			<Alt-Key-c>			{varSet Mode Create}
D		-		-			<Key-l>				{varSet Mode,Create line}
*		-		-			<Key-t>				{varSet Mode,Create text}
*		#		#			<Alt-Key-m>			{modePush Move}
X		#		#			<Alt-Key-c>			{modePush Create}
*		#		#			<Alt-Key-d>			{varSet Mode Delete}
*		#		#			<Alt-Key-E>			{procGrab ObjEdit}

*		#		#			<Key-greater>		{canvasScale 1}
*		#		#			<Key-less>			{canvasScale 0}

*		#		#			<Control-Key-Up>	{canvasScroll yview scroll -1 page}
*		#		#			<Control-Key-Down>	{canvasScroll yview scroll  1 page}
*		#		#			<Control-Key-Left>	{canvasScroll xview scroll -1 page}
*		#		#			<Control-Key-Right>	{canvasScroll xview scroll  1 page}
*		#		#			<Key-Up>			{canvasScroll yview scroll -3 units}
*		#		#			<Key-Down>			{canvasScroll yview scroll  3 units}
*		#		#			<Key-Left>			{canvasScroll xview scroll -3 units}
*		#		#			<Key-Right>			{canvasScroll xview scroll  3 units}
*		#		#			<Alt-Key-P>			{canvasPrint}
*		#		#			<Alt-Key-p>			{canvasPrint}
*		#		#			<Alt-Key-z>			{procexec "source ../tkcon.tcl"}
C		-		-			<Alt-Key-n>			{schGenNet}
*		#		#			<Alt-Key-g>			{varSet Mode Group}
*		#		#			<Key-g>				{varAlt GridList}
B		-		-			<Alt-Key-n>			{pcbReadNet}
*		#		#			<<HELP>>			{procHelp}
*		#		#			<Key-F12>			{procHelp}
*		#		#			<Key-KP_Add>		{procZoom Out}
*		#		#			<Key-KP_Subtract>	{procZoom In}
*		#		#			<Key-Home>			{procZoom Fit}
*		#		#			<Key-End>			{procZoom None}
}

### Function entering should be via procGrab + Mode to go to.
### If procGrab finds an object , will go to Mode unless
### Logic causes it to use another mode.
### procGrab may chain through to procMode to find proper mode to go to
### after grab.

}

proc procexec { name args} {
	Log procExec $args
	uplevel #0 [list eval [join $args]]
}









