Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XY Quadrant Form Splitter
Message
From
25/11/2006 08:52:29
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01171347
Message ID:
01172397
Views:
16
Hi Terry,
>I needed something like the ISE GUI offers - a 4 quandrant form splitter - I couldn't find one - so I impovised one - it seems clean - an any critique appreciated:

nice and short! Your original code switched the mousepointer sometimes with the normal arrow while using the splitters, so I refactored a bit. I bundled most of the duplicate assignments, as this made the code clearer (at least for me) and added more "talking" methods/methodnames - which I probably would not have done to the extend of the "In"-methods in my own code<g>. But for my taste the mousepointer-behaviour is now more intuitive and it is still even less code. I think the magic numbers between -1 and 4 should either be recoded into constants and/or made dependant on the properties of the splitter - if you change the splitter properties for height and width you get "phantom lines".

UPDATE: setting "nActivePointer" in the add object is probably not as intuitive as using "proper property overides" in the class definition - here I went overboard to minimize line number <g>. Cetin's point about object names could also be handled via property... Added a "local" to mouseMove.

regards

thomas
* R6_PSA_Objects.PRG
* November (c) 2006 Terry Thurber
* All Rights Reserved
close all
clear all
set exact on
public myform as form
myform=createobject('frmSPlitter')
myform.show

********************************************************************
*                     START SPLITTER FORM DEMO                     *
********************************************************************
define class frmSplitter as form &&=================================
	nPercentLeft=0
	nPercentTop=0
	lMoveInProgress=.f.

	add object edtNE as edtBox 	with backcolor=15790335
	add object edtNW as edtBox	with backcolor=16056304
	add object edtSE as edtBox	with backcolor=15532031
	add object edtSW as edtBox	with backcolor=16773874

	add object cmdX as cmdXClass	with nActivePointer = 9
	add object cmdY as cmdYClass	with nActivePointer = 7
	add object cmdXY as cmdXYClass	with nActivePointer = 5

	minheight=10
	caption=[XY Quadrant Form Splitter]
	visible =.t.

	procedure init
		with this
			.edtNE.zorder(1)
			.edtNW.zorder(1)
			.edtSE.zorder(1)
			.edtSW.zorder(1)
			.cmdX.zorder(0)
			.cmdY.zorder(0)
			.cmdXY.zorder(0)
			store .50 to .nPercentLeft, .nPercentTop
			.resize
		endwith
	endproc

	procedure release
		this.queryunload
	endproc

	procedure queryunload
		clear events
		release all
	endproc

	procedure resize
		with this
			PSA_MoveSplitter(this,.nPercentLeft*.width,.nPercentTop*.height)
			.cmdX.height=.height-4
			.cmdY.width=.width-4
		endwith
	endproc
enddefine && frmSplitter as Form &&=================================

define class edtBox as editbox &&===================================
	visible=.t.
	left=2
	top=2
enddefine && edtBox as EditBox &&===================================
********************************************************************
*                         END DEMO FORM CLASS                      *
********************************************************************
********************************************************************
*                         START SCREEN SPLITTER                    *
********************************************************************
procedure PSA_MoveSplitter(oform,lnSplitterLeft,lnSplitterTop) &&---
	with oform
		store m.lnSplitterLeft 			to 	.cmdX.left,	.cmdXY.left
		store m.lnSplitterLeft+2 		to 	.edtNW.left,	.edtSW.left
		store m.lnSplitterLeft-2 		to	.edtNE.width,	.edtSE.width
		store .width-m.lnSplitterLeft-3 	to	.edtNW.width,	.edtSW.width
		store m.lnSplitterTop 			to 	.cmdY.top,	.cmdXY.top
		store m.lnSplitterTop+2 		to	.edtSE.top,	.edtSW.top
		store m.lnSplitterTop-2 		to	.edtNE.height,	.edtNW.height
		store .height-m.lnSplitterTop-3		to	.edtSE.height,	.edtSW.height
	endwith
endproc &&PSA_MoveSplitter(oform,lnSplitterLeft,lnSplitterTop) &&---

define class cmdSplitterClass as commandbutton &&===================
	top=2
	left=2
	width=3
	height=3
	caption=[]
	style=1
	visible=.t.
	nActivePointer = 0 	&& override for each subclass!
	function change_mousepointer(nXCoord, nYCoord) && interface only, define in Subclass with nActivePointer!

	procedure set_mousepointer (nXCoord, nYCoord)
		this.mousepointer=iif( this.change_mousepointer(m.nXCoord, m.nYCoord), this.nActivePointer, 0)

	function InWidth(nXCoord)
		return between(m.nXCoord-this.left, -1, +2)

	function InHeight(nYCoord)
		return between(m.nYCoord-this.top, -1 , +2)

	procedure mousemove (nButton, nShift, nXCoord, nYCoord)
		if thisform.lMoveInProgress
			local nSplitterLeft, nSplitterTop
			if [Y]$this.name
				nSplitterTop= max(min(m.nYCoord, thisform.height-4), 4)
				nSplitterLeft=thisform.cmdXY.left
			endif
			if [X]$this.name
				nSplitterLeft= max(min(m.nXCoord, thisform.width-4), 4)
				nSplitterTop=iif([XY]$this.name, m.nSplitterTop, thisform.cmdXY.top)
			endif
			PSA_MoveSplitter(thisform,m.nSplitterLeft,m.nSplitterTop)
		else
			= this.set_mousepointer (m.nXCoord, m.nYCoord)
		endif &&thisform.lMoveInProgress
	endproc

	procedure mousedown (nButton, nShift, nXCoord, nYCoord)
		thisform.lMoveInProgress=.t.
		= this.set_mousepointer (m.nXCoord, m.nYCoord)
	endproc &&MouseDown (nButton, nShift, nXCoord, nYCoord)

	procedure mouseup (nButton, nShift, nXCoord, nYCoord)
		this.mousepointer=0
		thisform.nPercentLeft=thisform.cmdXY.left/thisform.width
		thisform.nPercentTop=thisform.cmdXY.top/thisform.height
		thisform.lMoveInProgress=.f.
	endproc
enddefine && cmdSplitterClass as CommandButton &&===================

define class cmdXClass as cmdSplitterClass && ======================
	function change_mousepointer (nXCoord, nYCoord)
		return 	this.InWidth(m.nXCoord)
enddefine && cmdXClass as cmdSplitterClass && ======================

define class cmdYClass as cmdSplitterClass && ======================
	function change_mousepointer (nXCoord, nYCoord)
		return 	this.InHeight(m.nYCoord)
enddefine && cmdYClass as cmdSplitterClass && ======================

define class cmdXYClass as cmdSplitterClass && =====================
	function change_mousepointer (nXCoord, nYCoord)
		return 	this.InWidth(m.nXCoord) and this.InHeight(m.nYCoord)
enddefine && cmdYClass as cmdSplitterClass && ======================
********************************************************************
*                      END SCREEN SPLITTER                         *
********************************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform