How to "Zoom-In" on form elements

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to "Zoom-In" on form elements

Postby Westy » Tue Jan 15, 2008 7:59 pm

To "zoom in" on Servoy form elements like fields, text labels, borderpanels, etc. try the following "Zoom-In" form method:
Code: Select all
/*
January 15, 2008
by Dean Westover
give default value of 8 for globals.fontSize
(or use whatever font size you want to start with)
give default value of 101 for globals.zoom
do give a name property to all elements that should be re-sized
do NOT give a name property to elements that should not to be re-sized
attach the following form method to a "Zoom-In" button on your form
*/

for ( var i = 0 ; i < elements.length ; i++ )
{
   //return height and width
   var w = elements[i].getWidth();
   var h = elements[i].getHeight();
   //set height and width
   elements[i].setSize(w*globals.zoom/100,h*globals.zoom/100);
   //return X and Y location
   var x = elements[i].getLocationX();
   var y = elements[i].getLocationY();
   //set X and Y location
   elements[i].setLocation(x*globals.zoom/100,y*globals.zoom/100);
   //return font size
   globals.fontSize = globals.fontSize * globals.zoom/100;
   //set font 'fontname,style,size'
   //style = (plain=0, bold=1, italic=2, bold-italic=3)
   elements[i].setFont('Tahoma,0,' + globals.fontSize);
}

Any suggestions for enhancing or improving the above code are welcome. Attached is a sample Servoy 3.5.3 solution.

Dean Westover
Choices Software, Inc.
Attachments
zoom.servoy
(4.31 KiB) Downloaded 195 times
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Return to How To

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron