Please comment on VIEW, WINDOW and associated

Forum for discussion about the documentation project.
Post Reply
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Please comment on VIEW, WINDOW and associated

Post by Tourist Trap »

Hi,

This is a try to get a full understanding of VIEW, combined to WINDOW SCREEN, or WINDOW.

For instance, some programming "objects" are affected by WINDOW, like CIRCLE, whereas GETMOUSE won't, neither an image. What difference between scaling effets involved by WINDOW SCREEN, compared to WINDOW?

About VIEW, it's good to know that CLS may be restricted if a view is set up... How manage to CLS then.

And so on. Not all questions are equally hard to answer of course.

I've made a program that allows one make the parameters of those command vary and observe the effect on:
  • an image buffer,
    some circle,
    line,
    and pointcoord

Code: Select all

'VIEW, WINDOW SCREEN, and PUT parameters
    view (ViewOriginX,ViewOriginY)-_
         (ViewEndCoordinateX,ViewEndCoordinateY), _
         , _
         rgb(120,120,220)
    window screen (WindowScreenOriginX,WindowScreenOriginY)-_
                  (WindowScreenEndCoordinateX,WindowScreenEndCoordinateY)
    put (PutOriginX,PutOriginY), Img, PSET
I can not really put words in particular on what WINDOW SCREEN is doing exactly when the context vary. My first objective here is then very simple, being able to explain this program (what seen at screen).

Here is a sort of "how-to", because it's not really intuitive otherwise:
Image

And here the program:

Code: Select all

'level0----------------------------------------
'program purpose: .............................
'...testing around VIEW language instruction...

'level1----------------------------------------
'------------------------PREPROCESSOR DIRECTIVE
#include once "fbgfx.bi"
#include once "slidebar.bas"

'level2----------------------------------------
'-------------------------------ENUM / CONSTANT
enum _RANDOMPOINT
	_add		=> -1
	_dontAdd	=> 0
end enum '_RANDOMPOINT

'level3----------------------------------------
'--------------------------------UDT / OPERATOR

'level4----------------------------------------
'-------------------------FUNCT/SUB DECLARATION
declare sub ImageReset(byref as fb.IMAGE ptr, _ 
					   byval as integer, _ 
					   byval as integer, _ 
					   byval as ulong, _ 
					   byval as integer)
declare sub BuildBackground(byref as fb.IMAGE ptr, _ 
							byval as _RANDOMPOINT=_RANDOMPOINT._dontAdd)
declare sub DisplayView(byval as fb.IMAGE ptr, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer, _ 
                		byval as integer)

'level5----------------------------------------
'--------------------------------INITIALIZATION
randomize timer

'SCREEN parameters
dim as integer screenWidth				=> 600
dim as integer screenHeight				=> 400
dim as integer screenDepth				=> 032
screenRes screenWidth, screenHeight, screenDepth
windowTitle "demonstration of VIEW, WINDOW SCREEN ..etc." & _ 
			"(screen="& str(screenWidth) &"x"& str(screenHeight) &")"

'BACKGROUND IMAGE parameters
dim as integer backgroundImageWidth		=> 800
dim as integer backgroundImageHeight	=> 800
dim as fb.IMAGE ptr img
img => ImageCreate(backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
BuildBackground(img)

'VIEW / WINDOW SCREEN / PUT parameters
dim as integer viewOriginX, viewOriginY
dim as integer viewEndCoordinateX, viewEndCoordinateY
dim as integer windowScreenOriginX, windowScreenOriginY
dim as integer windowScreenEndCoordinateX, _ 
               windowScreenEndCoordinateY
dim as integer putOriginX, putOriginY
viewOriginX                 => 0
viewOriginY                 => 0
viewEndCoordinateX          => 0
viewEndCoordinateY          => 0
windowScreenOriginX         => 0
windowScreenOriginY         => 0
windowScreenEndCoordinateX  => 0
windowScreenEndCoordinateY  => 0
putOriginX                  => 0
putOriginY                  => 0

'VIEW slidebar
dim as SLIDEBAR viewXslideBar
viewXslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 0, _ 
		 25, _ 
		 10, _ 
		 2*screenWidth\3, _ 
		 10)
viewXslideBar.MinValue = 0
viewXslideBar.MaxValue = 3*screenWidth\2

dim as SLIDEBAR viewYslideBar
viewYslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._vertical, _ 
		 0, _ 
		 10, _ 
		 40, _ 
		 20, _ 
		 screenHeight\2)
viewYslideBar.MinValue = 0
viewYslideBar.MaxValue = 3*screenHeight\2

dim as SLIDEBAR viewEndCoordinateXslideBar
viewEndCoordinateXslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 screenWidth\3, _ 
		 25, _ 
		 screenHeight\2 + 60, _ 
		 2*screenWidth\3, _ 
		 10)
viewEndCoordinateXslideBar.MinValue = 0
viewEndCoordinateXslideBar.MaxValue = 3*screenWidth\2

dim as SLIDEBAR viewEndCoordinateYslideBar
viewEndCoordinateYslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._vertical, _ 
		 screenHeight\4, _ 
		 2*screenWidth\3 + 22, _ 
		 40, _ 
		 20, _ 
		 screenHeight\2)
viewEndCoordinateYslideBar.MinValue = 0
viewEndCoordinateYslideBar.MaxValue = 3*screenHeight\2

'WINDOW SCREEN slidebar
dim as SLIDEBAR windowScrOriginXslideBar
windowScrOriginXslideBar => _ 
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 0, _ 
		 25, _
		 22, _ 
		 2*screenWidth\3, _ 
		 10)
windowScrOriginXslideBar.MinValue = 0
windowScrOriginXslideBar.MaxValue = 3*screenWidth\2

dim as SLIDEBAR windowScrOriginYslideBar
windowScrOriginYslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._vertical, _
		 0, _ 
		 32, _ 
		 40, _
		 20, _ 
		 screenHeight\2)
windowScrOriginYslideBar.MinValue = 0
windowScrOriginYslideBar.MaxValue = 3*screenHeight\2

dim as SLIDEBAR windowScrEndCooXslideBar
windowScrEndCooXslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 screenWidth\3, _ 
		 25, _ 
		 screenHeight\2 + 48, _ 
		 2*screenWidth\3, _ 
		 10)
windowScrEndCooXslideBar.MinValue = 0
windowScrEndCooXslideBar.MaxValue = 3*screenWidth\2

dim as SLIDEBAR windowScrEndCooYslideBar
windowScrEndCooYslideBar => _
SLIDEBAR(SLIDEBAR._SBORIENTATION._vertical, _
		 screenHeight\4, _ 
		 2*screenWidth\3, _ 
		 40, _
		 20, _ 
		 screenHeight\2)
windowScrEndCooYslideBar.MinValue = 0
windowScrEndCooYslideBar.MaxValue = 3*screenHeight\2

'PUT slidebar
dim as SLIDEBAR putOriginXslideBar
putOriginXslideBar => _ 
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 0, _ 
		 25, _
		 4*screenHeight\5, _ 
		 2*screenWidth\3, _ 
		 10)
putOriginXslideBar.MinValue = 0
putOriginXslideBar.MaxValue = 3*screenWidth\2

dim as SLIDEBAR putOriginYslideBar
putOriginYslideBar => _ 
SLIDEBAR(SLIDEBAR._SBORIENTATION._horizontal, _ 
		 0, _ 
		 25, _
		 4*screenHeight\5 + 12, _ 
		 2*screenWidth\3, _ 
		 10)
putOriginYslideBar.MinValue = 0
putOriginYslideBar.MaxValue = 3*screenWidth\2

'level6----------------------------------------
'------------------------------------------MAIN

'level7----------------------------------------
'-------------------------------------MAIN LOOP
do
	'
	'*********************
	'******graphisms******
	'*********************
	screenLock
	cls
	'
	'...........draw image
	DisplayView(img, _ 
				viewOriginX, _ 
				viewOriginY, _ 
				viewEndCoordinateX, _ 
				viewEndCoordinateY, _ 
				windowScreenOriginX, _ 
				windowScreenOriginY, _ 
				windowScreenEndCoordinateX, _ 
				windowScreenEndCoordinateY, _ 
				putOriginX, _ 
				putOriginY)
	'
	'........control board
	view screen
	window screen
	'
	'VIEW slidebar
	viewXslideBar.DrawSlideBar()
	if viewOriginX<>viewXslideBar.CurrentValue then
		viewOriginX = viewXslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	viewYslideBar.DrawSlideBar()
	if viewOriginY<>viewYslideBar.CurrentValue then
		viewOriginY = viewYslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	viewEndCoordinateXslideBar.DrawSlideBar()
	if viewEndCoordinateX<>viewEndCoordinateXslideBar.CurrentValue then
		viewEndCoordinateX = viewEndCoordinateXslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	viewEndCoordinateYslideBar.DrawSlideBar()
	if viewEndCoordinateY<>viewEndCoordinateYslideBar.CurrentValue then
		viewEndCoordinateY = viewEndCoordinateYslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	'
	'WINDOW SCREEN sidebar
	windowScrOriginXslideBar.DrawSlideBar()
	if windowScreenOriginX<>windowScrOriginXslideBar.CurrentValue then
		windowScreenOriginX = windowScrOriginXslideBar.CurrentValue
		window screen (windowScreenOriginX,windowScreenOriginY)-_ 
					  (windowScreenEndCoordinateX,windowScreenEndCoordinateY)
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img,_RANDOMPOINT._add)
		window screen
	end if
	windowScrOriginYslideBar.DrawSlideBar()
	if windowScreenOriginY<>windowScrOriginYslideBar.CurrentValue then
		windowScreenOriginY = windowScrOriginYslideBar.CurrentValue
		window screen (windowScreenOriginX,windowScreenOriginY)-_ 
					  (windowScreenEndCoordinateX,windowScreenEndCoordinateY)
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img,_RANDOMPOINT._add)
		window screen
	end if
	windowScrEndCooXslideBar.DrawSlideBar()
	if windowScreenEndCoordinateX<>windowScrEndCooXslideBar.CurrentValue then
		windowScreenEndCoordinateX = windowScrEndCooXslideBar.CurrentValue
		window screen (windowScreenOriginX,windowScreenOriginY)-_ 
					  (windowScreenEndCoordinateX,windowScreenEndCoordinateY)
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img,_RANDOMPOINT._add)
		window screen
	end if
	windowScrEndCooYslideBar.DrawSlideBar()
	if windowScreenEndCoordinateY<>windowScrEndCooYslideBar.CurrentValue then
		windowScreenEndCoordinateY = windowScrEndCooYslideBar.CurrentValue
	    window screen (windowScreenOriginX,windowScreenOriginY)-_ 
					  (windowScreenEndCoordinateX,windowScreenEndCoordinateY)
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img,_RANDOMPOINT._add)
		window screen
	end if
	'
	'PUT sidebar
	putOriginXslideBar.DrawSlideBar()
	if putOriginX<>putOriginXslideBar.CurrentValue then
		putOriginX = putOriginXslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	putOriginYslideBar.DrawSlideBar()
	if putOriginY<>putOriginYslideBar.CurrentValue then
		putOriginY = putOriginYslideBar.CurrentValue
		ImageReset(img, _ 
				   backgroundImageWidth, _ 
				   backgroundImageHeight, _ 
				   rgb(120,200,12), _ 
				   screenDepth)
		BuildBackground(img)
	end if
	'
	screenUnlock
	'
	'***********************
	'***user interactions***
	'***********************
	
loop until inkey=chr(27)

'level8----------------------------------------
'----------------------------------FINALIZATION
imageDestroy(img)

sleep
end

'level9----------------------------------------
'----------------------FUNCT/SUB IMPLEMENTATION
sub ImageReset(byref Img as fb.IMAGE ptr, _ 
			   byval W as integer, _ 
			   byval H as integer, _ 
			   byval C as ulong, _ 
			   byval D as integer)
	imageDestroy(Img)
	'---->
	Img = imageCreate(W, H, C, D)
end sub 'ImageReset(refFB_IMAGE_PTR,valINT,valINT,valULNG,valINT)

sub BuildBackground(byref Img as fb.IMAGE ptr, _ 
					byval RdP as _RANDOMPOINT=_RANDOMPOINT._dontAdd)
	dim as integer ImgW, ImgH
	imageInfo Img, ImgW, ImgH
	'
	dim as integer i, j
	for i = 0 to (ImgW - 1) step 40
	    draw string Img, _ 
	    			(i, 20), _ 
	    			str(i), _ 
	    			0
	    for j = 0 to (ImgH - 1) step 40
		    draw string Img, _ 
	    				(i, 20 + j), _ 
	    				str(i), _ 
	    				rgb(0,0,200)
	    	draw string Img, _ 
	    				(20 + i, j), _ 
	    				str(j), _ 
	    				0
	    next j
	next i
	'
	'global boundary square
	line Img, _ 
		 (0,0)-(ImgW - 1, ImgH - 1), _ 
		 rgb(240,080,080), _ 
		 b
	line Img, _ 
		 (2,2)-(ImgW - 3, ImgH - 3), _ 
		 rgb(240,080,080), _ 
		 b
	'
	if RdP=_RANDOMPOINT._dontAdd then exit sub
	'random point in screen vs window coordinate
	for i = 1 to 25
	    draw "BM "& _ 
		     str(cInt(rnd*_Max(ImgW,ImgH))) & _ 
		     ","& _ 
		     str(cInt(rnd*_Max(ImgW,ImgH)))
		dim as integer x, y, u, v
		x => pointcoord(0) : y => pointcoord(1)
		u => pointcoord(2) : v => pointcoord(3)
		line Img, (x - 20, y - 05)- _ 
				  (x + 60, y + 20), _ 
				  rgb(255,255,255), _ 
				  bf
		line Img, (x - 18, y - 03)- _ 
				  (x + 58, y + 18), _ 
				  rgb(055,055,155), _ 
				  b
	    circle Img,(x, y), 4, 0
	    draw string Img,(x, y), _ 
	                str(x) &"&"& str(y), _ 
	                0
	    draw string Img,(x, y + 10), _ 
	                str(u) &"&"& str(v), _ 
	                0
	next i
	'
end sub 'BuildBackground(refFB_IMAGE_PTR)

sub DisplayView(byval Img as fb.IMAGE ptr, _ 
                byval ViewOriginX as integer, _ 
                byval ViewOriginY as integer, _ 
                byval ViewEndCoordinateX as integer, _ 
                byval ViewEndCoordinateY as integer, _ 
                byval WindowScreenOriginX as integer, _ 
                byval WindowScreenOriginY as integer, _ 
                byval WindowScreenEndCoordinateX as integer, _ 
                byval WindowScreenEndCoordinateY as integer, _ 
                byval PutOriginX as integer, _ 
                byval PutOriginY as integer _                
                )
    view (ViewOriginX,ViewOriginY)-_ 
    	 (ViewEndCoordinateX,ViewEndCoordinateY), _ 
    	 , _ 
    	 rgb(120,120,220)
    window screen (WindowScreenOriginX,WindowScreenOriginY)-_ 
    			  (WindowScreenEndCoordinateX,WindowScreenEndCoordinateY)
    put (PutOriginX,PutOriginY), Img, PSET
end sub 'DisplayView(valFB_IMAGE_PTR,{valINT}*10)

'level10
'------------------------------------------DATA

'[end of the freebasic code file]

Code: Select all

'slidebar.bas
'......a standalone simple sidebar object......

'------------------------PREPROCESSOR DIRECTIVE
#macro _Max(x,y)	'note: required by SLIDEBAR
	iif (x<y, y, x)
#endMacro '_Max(_,_)

'--------------------------------UDT / OPERATOR

'                                       -------
'                                       SIDEBAR
'                                       -------
type SLIDEBAR
	enum _SBORIENTATION
		_vertical	= -1
		_horizontal =  0
	end enum '_SBORIENTATION
	declare constructor()
	declare constructor(byval as _SBORIENTATION=_SBORIENTATION._horizontal, _ 
						byval as integer=0, _ 
						byval as integer, _ )
						byval as integer, _ 
						byval as integer, _
						byval as integer)
	declare property MinValue(byval as integer)
	declare property MinValue() as integer
	declare property MaxValue(byval as integer)
	declare property MaxValue() as integer 
	declare property CurrentValue() as integer 
	declare sub TestSlideBar()
	declare sub DrawSlideBar()
		as _SBORIENTATION	_orientation
		as integer			_minValue
		as integer			_maxValue
		as integer			_barTopLeftCornerX
		as integer			_barTopLeftCornerY
		as integer			_barWidth
		as integer			_barHeight
		as integer			_buttonHVPosition
		as boolean			_isMouseOverBar
		as boolean			_isMouseClickedBar
		as boolean			_isMouseOverButton
		as boolean			_isMouseClickedButton
		as integer			_xPositionOnDrag
		as integer			_yPositionOnDrag
end type 'SLIDEBAR
constructor SLIDEBAR()
	dim as integer scrW, scrH
    if screenPtr()=0 then
        scrW = 200
        scrH = 200
    else
        screenInfo scrW, scrH
    end if
	'
	with THIS
		._orientation			=> SLIDEBAR._SBORIENTATION._horizontal
		._minValue				=> 0
		._maxValue				=> 10
		._barTopLeftCornerX		=> scrW\4
		._barTopLeftCornerY		=> scrH\4
		._barWidth				=> scrW\2
		._barHeight				=> 15
		._buttonHVPosition		=> 0
		._isMouseOverBar		=> FALSE
		._isMouseClickedBar		=> FALSE
		._isMouseOverButton		=> FALSE
		._isMouseClickedButton	=> FALSE
	end with 'THIS
end constructor 'default constructor
constructor SLIDEBAR(byval Orientation as _ 
					 _SBORIENTATION=SLIDEBAR._SBORIENTATION._horizontal, _ 
					 byval DistanceToMin as integer=0, _ 
					 byval TopLeftCornerX as integer, _ )
					 byval TopLeftCornerY as integer, _ 
					 byval BarWidth as integer, _ 
					 byval BarHeight as integer)
	with THIS
		._orientation			= Orientation
		._minValue				= 0
		._maxValue				= 100
		._barTopLeftCornerX		= TopLeftCornerX
		._barTopLeftCornerY		= TopLeftCornerY
		._barWidth				= BarWidth
		._barHeight				= BarHeight
		._buttonHVPosition		= DistanceToMin
		._isMouseOverBar		=> FALSE
		._isMouseClickedBar		=> FALSE
		._isMouseOverButton		=> FALSE
		._isMouseClickedButton	=> FALSE
	end with 'THIS
end constructor 'SLIDEBAR(val_SBORIENTATION[0],valINT[0],{valINT}*4)
property SLIDEBAR.MinValue(byval SetValue as integer)
	THIS._minValue = SetValue
end property 'set SLIDEBAR.MinValue(valINT)
property SLIDEBAR.MinValue() as integer
	'---->
	return THIS._minValue
end property 'get INT:=SLIDEBAR.MinValue
property SLIDEBAR.MaxValue(byval SetValue as integer)
	THIS._maxValue = SetValue
end property 'set SLIDEBAR.MaxValue(valINT)
property SLIDEBAR.MaxValue() as integer 
	'---->
	return THIS._maxValue
end property 'get INT:=SLIDEBAR.MaxValue
property SLIDEBAR.CurrentValue() as integer
	with THIS
		select case ._orientation
			case SLIDEBAR._SBORIENTATION._horizontal
				'---->
				return cInt(._minValue + (._maxValue - ._minValue)*_ 
							(._buttonHVPosition)/._barWidth)
			case SLIDEBAR._SBORIENTATION._vertical
				'---->
				return cInt(._minValue + (._maxValue - ._minValue)*_ 
							(._buttonHVPosition)/._barHeight)
		end select 'THIS._orientation
	end with 'THIS
end property 'get INT:=SLIDEBAR.CurrentValue
sub SLIDEBAR.TestSlideBar()
	dim as integer gmX, gmY, gmBtn1
	getMouse gmX, gmY, , gmBtn1
	'
	with THIS
		select case ._orientation
			case SLIDEBAR._SBORIENTATION._horizontal
				if gmX>(._barTopLeftCornerX + ._buttonHVPosition - 5) and _ 
				   gmX<(._barTopLeftCornerX + ._buttonHVPosition + 5) and _ 
				   gmY>(._barTopLeftCornerY) and _ 
				   gmY<(._barTopLeftCornerY + ._barHeight) then
					if ._isMouseOverButton=FALSE then _ 
					   ._isMouseOverButton = TRUE
						if gmBtn1=+1 then 
							if ._isMouseClickedButton=FALSE then
								._isMouseClickedButton = TRUE
								._xPositionOnDrag = gmX
							end if
						else
							if ._isMouseClickedButton=TRUE then _ 
						   	   ._isMouseClickedButton = FALSE
						end if
				else
					if ._isMouseOverButton=TRUE then _ 
					   ._isMouseOverButton = FALSE
					if ._isMouseClickedButton=TRUE then _ 
					   ._isMouseClickedButton = FALSE
				end if
				'
				'drag/drop along x axis
				if THIS._isMouseClickedButton=TRUE then
			   		THIS._buttonHVPosition += (gmX - THIS._xPositionOnDrag)
					THIS._xPositionOnDrag = gmX
				end if
				'
			case SLIDEBAR._SBORIENTATION._vertical
				if gmX>(._barTopLeftCornerX) and _ 
				   gmX<(._barTopLeftCornerX + ._barWidth) and _ 
				   gmY>(._barTopLeftCornerY + ._buttonHVPosition - 5) and _ 
				   gmY<(._barTopLeftCornerY + ._buttonHVPosition + 5) then
					if ._isMouseOverButton=FALSE then _ 
					   ._isMouseOverButton = TRUE
						if gmBtn1=+1 then 
							if ._isMouseClickedButton=FALSE then
								._isMouseClickedButton = TRUE
								._yPositionOnDrag = gmY
							end if
						else
							if ._isMouseClickedButton=TRUE then _ 
						   	   ._isMouseClickedButton = FALSE
						   	if ._isMouseClickedButton=TRUE then _ 
					   		   ._isMouseClickedButton = FALSE
						end if
				else
					if ._isMouseOverButton=TRUE then _ 
					   ._isMouseOverButton = FALSE
				end if
				'
				'drag/drop along y axis
				if THIS._isMouseClickedButton=TRUE then
			   		THIS._buttonHVPosition += (gmY - THIS._yPositionOnDrag)
					THIS._yPositionOnDrag = gmY
				end if
				'
		end select '._orientation		
	end with 'THIS
	'
	if gmX>THIS._barTopLeftCornerX and _ 
	   gmX<(THIS._barTopLeftCornerX + THIS._barWidth) and _
	   gmY>THIS._barTopLeftCornerY and _ 
	   gmY<(THIS._barTopLeftCornerY + THIS._barHeight) then
	   	'
		if THIS._isMouseOverBar=FALSE then THIS._isMouseOverBar = TRUE
		if gmBtn1=+1 then 
			if THIS._isMouseClickedBar=FALSE and _ 
			   THIS._isMouseClickedButton=FALSE then 
				THIS._isMouseClickedBar = TRUE
			end if
		else
			if THIS._isMouseClickedBar=TRUE then THIS._isMouseClickedBar = FALSE
		end if
		'
	else
		if THIS._isMouseOverBar=TRUE then THIS._isMouseOverBar = FALSE
	end if
	'	
end sub 'SLIDEBAR.TestSlideBar()
sub SLIDEBAR.DrawSlideBar()
    dim as integer scrW, scrH, depth
    if screenPtr()=0 then
        scrW    = 200
        scrH    = 200
        depth   = 032
        screenRes scrW, scrH, depth
        windowTitle "opened by SLIDEBAR"
    else
        screenInfo , , depth
    end if
    '
	THIS.TestSlideBar()
	with THIS
		select case ._orientation
			case SLIDEBAR._SBORIENTATION._horizontal
				if		._isMouseClickedBar	then
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(205,255,200), _ 
						  bf
				elseif	._isMouseOverBar	then
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(240,205,240), _ 
						  bf
				else
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(255,255,200), _ 
						  bf
				end if
				'
				if		._isMouseClickedButton		then
					line (._barTopLeftCornerX + _buttonHVPosition - 5,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._buttonHVPosition + 5, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(105,195,150), _ 
						  bf					
				elseif	._isMouseOverButton	then
					line (._barTopLeftCornerX + _buttonHVPosition - 5,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._buttonHVPosition + 5, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(150,155,150), _ 
						  bf					
				else
					line (._barTopLeftCornerX + _buttonHVPosition - 5,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._buttonHVPosition + 5, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(105,155,150), _ 
						  bf
				end if
				'
				'show numeric boundaries along x axis
				draw string (._barTopLeftCornerX,._barTopLeftCornerY), _ 
							 str(.MinValue), _ 
							 0
				draw string (._barTopLeftCornerX + ._barWidth - 8*len(str(.MaxValue)), _ 
							 ._barTopLeftCornerY), _ 
							 str(.MaxValue), _ 
							 0
				'
			case SLIDEBAR._SBORIENTATION._vertical
				if		._isMouseClickedBar	then
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(205,255,200), _ 
						  bf
				elseif	._isMouseOverBar	then
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(240,205,240), _ 
						  bf
				else
					line (._barTopLeftCornerX,._barTopLeftCornerY)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._barHeight), _
						  rgb(255,255,200), _ 
						  bf
				end if
				'
				if		._isMouseClickedButton		then
					line (._barTopLeftCornerX,._barTopLeftCornerY + _buttonHVPosition - 5)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._buttonHVPosition + 5), _
						  rgb(105,195,150), _ 
						  bf					
				elseif	._isMouseOverButton	then
					line (._barTopLeftCornerX,._barTopLeftCornerY + _buttonHVPosition - 5)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._buttonHVPosition + 5), _
						  rgb(150,155,150), _ 
						  bf					
				else
					line (._barTopLeftCornerX,._barTopLeftCornerY + _buttonHVPosition - 5)-_ 
						 (._barTopLeftCornerX + ._barWidth, _ 
						  ._barTopLeftCornerY + ._buttonHVPosition + 5), _
						  rgb(105,155,150), _ 
						  bf
				end if
				'
				'show numeric boundaries along y axis
				draw string (._barTopLeftCornerX,._barTopLeftCornerY), _ 
							 str(.MinValue), _ 
							 0
				draw string (._barTopLeftCornerX, _ 
							 ._barTopLeftCornerY + ._barHeight - 8), _ 
							 str(.MaxValue), _ 
							 0
				'
		end select '._orientation
	end with 'THIS
end sub 'SLIDEBAR.DrawSlideBar()

'[end of the freebasic code file]
Thanks for any comment that extending the rather short descriptions (clear but short) of the documentation would put clarity on those commands, with the nuances (that seems being a lot here).
fxm
Moderator
Posts: 12106
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Please comment on VIEW, WINDOW and associated

Post by fxm »

I consider that a very short but complete example (using 'View', 'Window', 'Pmap') is already in the documentation at page:
KeyPgWindow.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Please comment on VIEW, WINDOW and associated

Post by Tourist Trap »

fxm wrote:I consider that a very short but complete example (using 'View', 'Window', 'Pmap') is already in the documentation at page:
KeyPgWindow.
Yes I think I'll restart from drawing a function representation, maybe in many views and see what happens before introduction of images buffers. The images don't resize which make hard to see the scale factors changes.
fxm
Moderator
Posts: 12106
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Please comment on VIEW, WINDOW and associated

Post by fxm »

KeyPgWindow ⇒ FxMwikki [Added example of zooming in and out, by changing coordinates system with keyword 'Window']
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Please comment on VIEW, WINDOW and associated

Post by Tourist Trap »

fxm wrote:KeyPgWindow ⇒ FxMwikki [Added example of zooming in and out, by changing coordinates system with keyword 'Window']
Thanks a lot! I'll try to see from this code how independant view and window are, since again this is not obvious when combining both.
Post Reply