Page 1 of 1

Forms - Image control size with mouse

Posted: Sat Sep 02, 2017 2:50 pm
by arfgh
Here there.

I want to know for the best way to make an Image control bigger when we place the mouse over it, and back to its original size and position on mouse out.

At the moment i did it using two Image controls, the big one is hidden by default. So i use two controls to do it, but i am sure that is possible to perform the same with only one. See the fact that using two controls when we move so fast the mouse, sometimes it is messed up... that's the reason i want to see other way to do it.

thx in advance

Re: Forms - Image control size with mouse

Posted: Wed Sep 06, 2017 6:45 pm
by arfgh
somebody ?

Re: Forms - Image control size with mouse

Posted: Thu Sep 07, 2017 7:42 pm
by UnklDonald418
See the fact that using two controls when we move so fast the mouse, sometimes it is messed up...
I tried this with 3 small images and 3 corresponding large images using the approach you mentioned. I've not seen any problems even when quickly sweeping the mouse across the 3 small images. My images are linked to external .jpg files.
Here is the macro code I used.

Code: Select all

REM  *****  BASIC  *****
Rem This is triggered by the Mouse inside event
Sub LargeImageOn(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControlMod as object

SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
Select Case SourceName
	Case "SmImage01"
		oImageControlMod = oForm.getByName("LgImage01")
	Case "SmImage02"
		oImageControlMod = oForm.getByName("LgImage02")
	Case "SmImage03"
		oImageControlMod = oForm.getByName("LgImage03")
End Select

oImageControlMod.setPropertyValue("EnableVisible", TRUE)
End Sub

REM ==================================================
Rem This is triggered by the Mouse outside event
Sub LargeImageOff(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControl as object

SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
Select Case SourceName
	Case "SmImage01"
		oImageControlMod = oForm.getByName("LgImage01")
	Case "SmImage02"
		oImageControlMod = oForm.getByName("LgImage02")
	Case "SmImage03"
		oImageControlMod = oForm.getByName("LgImage03")
End Select
oImageControlMod.setPropertyValue("EnableVisible", FALSE)
End Sub
i use two controls to do it, but i am sure that is possible to perform the same with only one.
That would likely require a listener but setting up debugging listeners can be a painful process. Use two events.

Re: Forms - Image control size with mouse

Posted: Sat Sep 23, 2017 10:30 pm
by arfgh
so it is more complex, using a single image control ?

Re: Forms - Image control size with mouse

Posted: Sun Sep 24, 2017 1:34 am
by UnklDonald418
Sorry, I misread what you wanted.
I looked a little closer and using the MRI tool I found that each image has an ImageURL property. Using that property it is possible to use a single large image control and the macro is actually less complex (no Select Case needed).

Code: Select all

REM  *****  BASIC  *****

Sub LargeImageOn(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControlMod as object

If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End If
oMRI = CreateUnoService( "mytools.Mri" )
'oMRI.inspect oEv
SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
'oMRI.inspect oForm
image = oForm.getByName(SourceName).ImageUrl
oImageControlMod = oForm.getByName("LgImage01")
oImageControlMod.setPropertyValue("ImageURL", image)
'oMRI.inspect oImageControlAMod
oImageControlMod.setPropertyValue("EnableVisible", TRUE)
End Sub

REM ==================================================
Sub LargeImageOff(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControl as object

If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End If
oMRI = CreateUnoService( "mytools.Mri" )

oForm =  oEv.Source.Model.Parent

oImageControlMod = oForm.getByName("LgImage01")
oImageControlMod.setPropertyValue("EnableVisible", FALSE)
End Sub

Re: Forms - Image control size with mouse

Posted: Sun Sep 24, 2017 9:45 am
by RPG
Maybe this helps you? I do understand the problem is to change the size of a control.
I have the idea that OOo is not the best tool to use.

When you want use OOo then it is maybe better to use something else to use instead of a image control. I do think to: insert image and use that object. I have no idea how.

Code: Select all

sub resizecontrol(oEvent)
' Start with a button
' the imagecontrol and the button must in the same data-form as you see in the form-navigator
dim oButton
'dim oImage
'ImageforResize
dim oForm
dim oControlResizeModel ' This for the model of the control
dim oControlResizeView	' This is the view of the same control
dim oControlResizeShape	' This is the shape of the control
' This tree different thing of the same control are explained in the BASIC guide.
' You have to read chapter 12 Forms
' We have to use two strucs
dim size as new com.sun.star.awt.Size
dim point as new com.sun.star.awt.Point




' This macro must be loaded
if not globalscope.BasicLibraries.islibraryloaded("Tools") then 
	' Load now the library
	globalscope.BasicLibraries.loadlibrary("Tools")
end if


oButton=oEvent.source.model ' Now we have the button what is pressed
oButton.toggle=true ' Buttonstate must change when clicked

select case oButton.state
case 0 
	' Place the value in strucs 
	size.height=2000 ' I believe 1mm = 100
	size.width=6000
	
	point.x=800
	point.y=800
	'zorder=4

case 1
	' Place the value in strucs 
	size.height=4000 ' I believe 1mm = 100
	size.width=12000
	
	point.x=200
	point.y=200
	'zorder=4

end select


oForm= oButton.parent ' We have the form as we see in the form navigator.
'mri thisComponent.getCurrentController.getformcontroller(oForm) : end
oControlResizeModel=oForm.getbyname("ImageforResize") ' We have the model of the control
oControlResizeShape = GetControlShape(thisComponent.getCurrentController.Model ,oControlResizeModel.name)
oControlResizeShape.setSize(size)
oControlResizeShape.setPosition(point)
'mri thisComponent.getCurrentController.getcontrol(oControlResizeModel)
'call makezorder
end sub

Re: Forms - Image control size with mouse

Posted: Sun Oct 08, 2017 5:21 pm
by arfgh
i am still trying to understand how to do it and i did this, without lucky, Result of print is 0, why ?
I want to work directly with the image control, and no with buttons. So first i want to obtain its size and point. But restult is 0.

Code: Select all

	oForm = oImage.parent 'We have the form as we see in the form navigator.
	oControlResizeModel = oForm.getbyname("Image") 'We have the model of the control
	oControlResizeShape = GetControlShape(thisComponent.getCurrentController.Model ,oControlResizeModel.name)
	oControlResizeShape.getSize(size)
	print size.width