Leopard Client Properties

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

Leopard Client Properties

Postby david » Sun Jul 26, 2009 10:48 pm

If you want to do a L&F targeted to Mac Leopard, here's an example solution with various objects modified.

Note that you have to call the property code before a form loads.

Cheers Harjo :)

Code: Select all
//JComponent.sizeVariant
//MEMO: valid options: regular, small, mini

//push buttons
elements.btn_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.btn_small.putClientProperty('JComponent.sizeVariant','small')
elements.btn_mini.putClientProperty('JComponent.sizeVariant','mini')


//checkboxes
elements.check_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.check_small.putClientProperty('JComponent.sizeVariant','small')
elements.check_mini.putClientProperty('JComponent.sizeVariant','mini')


//combobox
elements.combo_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.combo_small.putClientProperty('JComponent.sizeVariant','small')
elements.combo_mini.putClientProperty('JComponent.sizeVariant','mini')
elements.combo_square.putClientProperty('JComboBox.isSquare',true)


//search
elements.fld_search.putClientProperty('JTextField.variant','search')

//circular progress
elements.progressBar.indeterminate = true
elements.progressBar.putClientProperty("JProgressBar.style", "circular")


//more buttons
elements.btn_square.putClientProperty('JButton.buttonType','square')
elements.btn_gradient.putClientProperty('JButton.buttonType','gradient')
elements.btn_bevel.putClientProperty('JButton.buttonType','bevel')
elements.btn_texture.putClientProperty('JButton.buttonType','textured')
elements.btn_roundrect.putClientProperty('JButton.buttonType','roundRect')
elements.btn_recessed.putClientProperty('JButton.buttonType','recessed')
elements.btn_help.putClientProperty('JButton.buttonType','help')
Attachments
leopard_client_property.servoy
(6.85 KiB) Downloaded 363 times
client property.png
client property.png (33.13 KiB) Viewed 9911 times
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Leopard Client Properties

Postby Harjo » Sun Jul 26, 2009 11:37 pm

Thanks David, for sharing this! :D :D
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Leopard Client Properties

Postby kazar » Sun Jul 26, 2009 11:37 pm

great. as one would expect :-)

kazar
User avatar
kazar
 
Posts: 367
Joined: Sat Sep 13, 2003 9:59 pm
Location: New York City

Re: Leopard Client Properties

Postby bobcusick » Fri Jul 31, 2009 4:51 am

Harjo & David - this is AWESOME! Thanks very much for sharing!
User avatar
bobcusick
 
Posts: 126
Joined: Mon Jan 12, 2009 9:13 pm

Re: Leopard Client Properties

Postby Harjo » Fri Aug 14, 2009 12:25 pm

David, I have 2 questions:

1. Can I set the element property only once for ALL buttons, instead of every single element?
2. In Leopard you see many times, this kind of comboboxes:

Afbeelding 11.png
Afbeelding 11.png (6.69 KiB) Viewed 9709 times


Do you know if this is possible in Servoy?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Leopard Client Properties

Postby david » Fri Aug 14, 2009 6:22 pm

1- Since these are runtime client properties you're setting, each element needs to be set individually when they are created. Some Java guru may have a slick way to override L&F at startup but I would just do something like this and call it from each form onLoad method. Save a ton of time not having to call each element by name:

Code: Select all
// fun-ction to set client properties on all form objects (call from form onLoad)

var formName = arguments[0]

for ( var i = 0 ; i < forms[formName].elements.length ; i++ ) {
   try {
      switch( forms[formName].elements[i].getElementType() ) {
         
         case "COMBOBOX" :
            forms[formName].elements[i].putClientProperty('JComboBox.isSquare',true)
            break
         
         case "BUTTON" :
            forms[formName].elements[i].putClientProperty('JButton.buttonType','square')
            break
            
         case "CHECK" :
            forms[formName].elements[i].putClientProperty('JComponent.sizeVariant','small')
            break
            
         case "TEXT_FIELD" :
            //
            break
            
         default:
      }
   }
   catch (e) {}
}


2- Doesn't look like its available on Mac Java. The list of available properties to date:

http://developer.apple.com/technotes/tn2007/tn2196.html
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Leopard Client Properties

Postby david » Fri Aug 14, 2009 6:51 pm

Sorry, had a lazy coding moment there. Better without the try statement:

Code: Select all
// fun-ction to set client properties on all form objects (call from form onLoad)

var formName = arguments[0]

for ( var i = 0 ; i < forms[formName].elements.length ; i++ ) {
   if ( forms[formName].elements[i].getElementType ) {
      switch( forms[formName].elements[i].getElementType() ) {
         
         case "COMBOBOX" :
            forms[formName].elements[i].putClientProperty('JComboBox.isSquare',true)
            break
         
         case "BUTTON" :
            forms[formName].elements[i].putClientProperty('JButton.buttonType','square')
            break
            
         case "CHECK" :
            forms[formName].elements[i].putClientProperty('JComponent.sizeVariant','small')
            break
            
         case "TEXT_FIELD" :
            //
            break
            
         default:
      }
   }
}
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Leopard Client Properties

Postby pbakker » Mon Aug 17, 2009 9:52 am

1. Can I set the element property only once for ALL buttons, instead of every single element?


Yes: application.setUIProperty() should do the trick.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Leopard Client Properties

Postby Harjo » Mon Aug 17, 2009 10:04 am

ah, cool! :-)

thanks Paul!
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Leopard Client Properties

Postby Harjo » Fri Aug 21, 2009 10:39 pm

Paul, I have tried this, but this does not work: (I do this in the onOpen method)

Code: Select all
   application.setUIProperty('JComboBox.isSquare',true)
   application.setUIProperty('JButton.buttonType','textured')


am I doing something wrong?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Leopard Client Properties

Postby david » Fri Aug 21, 2009 11:17 pm

Harjo wrote:am I doing something wrong?


UI and client properties are two different things. There is some property overlap but there is no direct mapping of most of the "custom" apple leopard client properties at the UI level.

application.setUIProperty() function also takes java code in its parameters:

http://www.servoy.com/forum/viewtopic.php?f=3&t=11217
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Leopard Client Properties

Postby Harjo » Fri Aug 21, 2009 11:27 pm

oke, thanks David.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands


Return to How To

Who is online

Users browsing this forum: No registered users and 3 guests