Forms - Image control size with mouse

Discuss the database features
Post Reply
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Forms - Image control size with mouse

Post 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
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Post by arfgh »

somebody ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Forms - Image control size with mouse

Post 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.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Post by arfgh »

so it is more complex, using a single image control ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Forms - Image control size with mouse

Post 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
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Forms - Image control size with mouse

Post 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
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Post 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
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Post Reply