<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Palm Pre Touch Phone &#187; development</title>
	<atom:link href="http://www.palmpretouchphone.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.palmpretouchphone.com</link>
	<description>Everything Palm Pre, We Feed You!</description>
	<lastBuildDate>Thu, 09 Feb 2012 03:43:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New tutorial – Buttons and Interactive Dialogs</title>
		<link>http://www.palmpretouchphone.com/development/new-tutorial-%e2%80%93-buttons-and-interactive-dialogs/</link>
		<comments>http://www.palmpretouchphone.com/development/new-tutorial-%e2%80%93-buttons-and-interactive-dialogs/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 16:24:51 +0000</pubDate>
		<dc:creator>Fred Patton</dc:creator>
				<category><![CDATA[DevRel Team]]></category>
		<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=4025</guid>
		<description><![CDATA[Do you have questions about best practices for using buttons in your app? Maybe you&#8217;d like advice on the best way to use buttons in a dialog box. Well, our own Tomomi Imura, webOS Developer Relations&#8217; in-house UI wizard is here to help with her new tutorial, &#8220;Creating Usable UI—Buttons and Interactive Dialogs&#8221;, available now [...]]]></description>
			<content:encoded><![CDATA[<p>Do you have questions about best practices for using buttons in your app? Maybe you&#8217;d like advice on the best way to use buttons in a dialog box. Well, our own Tomomi Imura, webOS Developer Relations&#8217; in-house UI wizard is here to help with her new tutorial, &#8220;Creating Usable UI—Buttons and Interactive Dialogs&#8221;, available now on the webOS Developer Portal. She&#8217;ll walk you through button setup, the proper use of color and text, and how best to use buttons in intuitive, consistent user dialogs.</p>
<p>Consistent user interaction is one of the keys to happy users. So, <a href="https://developer.palm.com/content/resources/develop/creating_usable_ui_buttons_and_interactive_dialogs.html">check out Tomomi&#8217;s tutorial</a> and get coding!</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/0qQnkTZ3y1U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/new-tutorial-%e2%80%93-buttons-and-interactive-dialogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly App Hack – 12-18 October</title>
		<link>http://www.palmpretouchphone.com/development/weekly-app-hack-%e2%80%93-12-18-october/</link>
		<comments>http://www.palmpretouchphone.com/development/weekly-app-hack-%e2%80%93-12-18-october/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:38:22 +0000</pubDate>
		<dc:creator>joshmarinacci</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[announcements]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=4532</guid>
		<description><![CDATA[&#160; The apps are in and judging has begun. We will have the winners of the Text to Speech challenge up in a few days. Thanks to everybody who submitted apps! This week&#8217;s challenge is to do something with Exhibition Mode, one of the most under-appreciated features of webOS. Exhibition mode is a way to [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>The apps are in and judging has begun. We will have the winners of the Text to Speech challenge up in a few days. Thanks to everybody who submitted apps!</p>
<p>This week&#8217;s challenge is to do something with <a href="https://developer.palm.com/content/api/dev-guide/mojo/exhibition.html" class="broken_link">Exhibition Mode</a>, one of the most under-appreciated features of webOS.</p>
<p>Exhibition mode is a way to turn your TouchPad into an <a href="http://en.wikipedia.org/wiki/Ambient_device">ambient display</a>. When the user puts their TouchPad onto the TouchStone dock, the device will go into a special mode where a single app is shown and the screen will never turn off.  Exhibition mode apps are used for things the user wants to see in the background rather than something they will focus their attention on.</p>
<p><span id="more-4532"></span></p>
<p>So what is a good use for an ambient display? Lots of things! The classic examples are a clock or a photo slideshow but there is so much more you could do with the concept. What information would be useful if you could glance at it rather than directly interacting with it? How about a realtime weather map? A list of tweets posted to a hashtag during a party?  A music visualizer? A webcam display? How about showing the status of the last 4 builds on your continuous build server? If the build breaks it flashes red and plays an alarm. The possibilities really are endless.</p>
<p>Since we are getting to the holiday season I chose to make a clock that displays the number of days to Christmas, in <em>decimal</em>. And just to make it a bit more fun I added falling snowflakes.  The code was actually quite simple. I used my open source drawing program, <a href="http://leonardosketch.org/">Leonardo Sketch</a>, to  draw the entire interface, then exported it to a webpage using <a href="http://goamino.org/">Amino</a> to draw everything with Canvas. Finally I added the snow and text effects with hand coding. Once I knew it worked in Chrome I just added an <code>appinfo.json</code> file and packaged it up. Nothing special is required; not even Enyo initialization (Amino will do the PalmStage stuff for you).</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="test2.png" src="http://developer.palm.com/blog/wp-content/uploads/2011/10/canvastest2.png" border="0" alt="Countdown to Christmas" width="400" height="293" /></p>
<p>Turning Christmas Countdown into an exhibition mode app was really easy.  I just added the line  <code>"dockMode": true</code> to my <code>appinfo.json</code> file. webOS detects this and lets the user choose my app from the Exhibition Mode preferences.  That&#8217;s all there is to it.  <a href="https://developer.palm.com/content/api/dev-guide/mojo/exhibition.html" class="broken_link">This page has more</a> on how to use Exhibition mode, including how to tell which way your app is launched.</p>
<p>You can find the source for my at our new App Hack Github repository <a href="https://github.com/palm/Weekly-App-Hack">here</a>. It&#8217;s also available in the catalog <a href="https://developer.palm.com/appredirect/?packageid=com.joshondesign.webos.christmascountdown" class="broken_link">here</a>.</p>
<p>You&#8217;ve got one week to make an interesting app that uses Exhibition mode. We can&#8217;t wait to see what you come up with!</p>
<p><strong>The Rules</strong></p>
<p>1) Submit your app based on the sample above to the App Catalog by  October 18th at 11:59pm Pacific Daylight Time. We will be accepting both  new apps as  well as incorporation of the theme into existing apps as  an improvement. A submission to the Beta catalog is acceptable.</p>
<p>2) Notify us that you want to participate in the App Hack by sending  us an email containing your app redirect link (it&#8217;s generated automatically and placed on the app&#8217;s detail page in &#8220;My Apps&#8221;) and any extra information  you want to share with us at <a href="mailto:apphack@palm.com">apphack@palm.com</a>. This is also due by October 18th at 11:59pm Pacific Daylight Time.  If you do not send us this note, your app <strong>will not be considered</strong> for the App Hack.</p>
<p>3) By the end of the day on Friday, October 21st, the Developer  Relations team will  announce the winning app (along with honorable  mentions and other  entrants). The winner will get a blog post dedicated  to him/her and  his/her fantastic app.</p>
<p><strong>Additional terms and conditions</strong><br />
<em> </em></p>
<p><em>NO PURCHASE NECESSARY AND PURCHASE WILL NOT INCREASE CHANCE OF WINNING. OPEN ONLY TO REGISTERED DEVELOPERS.  HP reserves the right to request additional information for consideration. False information disqualifies you and your app from consideration, making it subject to review under applicable laws. Violators may be prosecuted. This offer is void where prohibited or restricted by law. Taxes, if applicable, are winner’s responsibility.  HP employees are not eligible.  Winner may have to sign and return an eligibility and liability release, unless prohibited.  If eligible winner fails to sign and return required documents, prize may be forfeited.  HP is committed to protecting your privacy. Your personal information will not be passed on from HP without your explicit consent.  Visit our Online Privacy Statement to learn how we use automatic data collection tools and your personal information to tailor your communications. Neither party acquires any patent, copyright, mask work or trademark rights during this event. Participation imposes no obligation on either party to purchase, sell, license, transfer or otherwise dispose of any technology, services or products, and does not create any agency or partnership relationship. The terms herein may be added to or modified by HP at any time at its sole discretion. Additional terms and conditions may apply. Entry constitutes agreement to rules and HP’s decisions. Entrants release and hold harmless HP, its subsidiaries, affiliates, and their officers, directors, employees, agents from any claim arising out of entry or prize receipt or use.</em></p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/KPgK9c4aFTI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/weekly-app-hack-%e2%80%93-12-18-october/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring the Enyo Map Control</title>
		<link>http://www.palmpretouchphone.com/development/exploring-the-enyo-map-control/</link>
		<comments>http://www.palmpretouchphone.com/development/exploring-the-enyo-map-control/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 18:49:19 +0000</pubDate>
		<dc:creator>Fred Patton</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[announcements]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=4507</guid>
		<description><![CDATA[Have you been wanting to add maps, complete with pushpins and infoboxes to your Enyo-based app? We&#8217;ve added a tutorial from our own Markus Leutwyler (@twtomcat for those following him on Twitter) that shows you all the details. You&#8217;ll find the article on the HP webOS Developer Center here. &#160;]]></description>
			<content:encoded><![CDATA[<p>Have you been wanting to add maps, complete with pushpins and infoboxes to your Enyo-based app? We&#8217;ve added a tutorial from our own Markus Leutwyler (@twtomcat for those following him on Twitter) that shows you all the details.</p>
<p>You&#8217;ll find the article on the HP webOS Developer Center <a href="https://developer.palm.com/content/resources/develop/exploring_the_enyo_map_control.html" class="broken_link">here</a>.</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/3NQAWYs5UCw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/exploring-the-enyo-map-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling Component Placement in Custom Kinds</title>
		<link>http://www.palmpretouchphone.com/development/controlling-component-placement-in-custom-kinds/</link>
		<comments>http://www.palmpretouchphone.com/development/controlling-component-placement-in-custom-kinds/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 14:36:08 +0000</pubDate>
		<dc:creator>sugardave</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=4051</guid>
		<description><![CDATA[In this article, I want to share how you can help ensure that your custom kind&#8217;s components are contained where you want them to be. Let&#8217;s start with the following example: Here is a kind that is simply a VFlexBox with a Header (for a header), a Scroller (for holding whatever gets added later), and [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I want to share how you can help ensure that your custom kind&#8217;s components are contained where you want them to be.</p>
<p>Let&#8217;s start with the following example: Here is a kind that is simply a VFlexBox with a Header (for a header), a Scroller (for holding whatever gets added later), and a Toolbar (for a footer):<br />
<span id="more-4051"></span></p>
<pre>enyo.kind({
    name: "MyKind",
    kind: enyo.VFlexBox,
    components: [
        {name: "header", kind: enyo.Header, content: "Header"},
        {name: "scroller", kind: enyo.Scroller, flex: 1},
        {name: "footer", kind: enyo.Toolbar}
    ],
    create: function() {
        this.inherited(arguments);
    }
});</pre>
<p>&nbsp;</p>
<p>And here is an action shot of this kind:</p>
<p>&nbsp;</p>
<p><a rel="nofollow" target="_blank" href="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind.png"><img class="alignnone size-full wp-image-4054" src="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind.png" alt="MyKind in action!" width="1011" height="683" /></a></p>
<p>&nbsp;</p>
<p>Next, let&#8217;s use our new kind and add something to its components block:</p>
<p>&nbsp;</p>
<pre>enyo.kind({
    name: "Display",
    kind: enyo.Control,
    components: [
        {kind: "MyKind", className: "enyo-fit", components: [
            {name: "list", kind: enyo.VirtualRepeater, onSetupRow: "setupRow", components: [
                {kind: enyo.Item, components: [
                    {name: "itemName"}
                ]}
            ]}
        ]}
    ],
    create: function() {
        this.inherited(arguments);
    },
    setupRow: function(inSender, inIndex) {
        if (inIndex &lt; 15) {
            this.$.itemName.setContent("webOS");
            return true;
        }
    }
});</pre>
<p>&nbsp;</p>
<p>Here&#8217;s what you get:</p>
<p><a rel="nofollow" target="_blank" href="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind_wrong.png"><img class="alignnone size-full wp-image-4058" src="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind_wrong.png" alt="Wrong" width="1011" height="684" /></a></p>
<p>Okay, that doesn&#8217;t look right.  First, the repeater is in the wrong place.  It has been rendered <em>below</em> the footer of the kind we wanted to contain it.  Second, it doesn&#8217;t scroll.  Fixing the first issue will fix the second.  The first issue is caused by the fact that any time a component is added to a kind, it is <em>appended</em> to the list of <em>components that already exist</em>.</p>
<p>One option to get around this would be to write some custom methods in MyKind that could be used to populate the Scroller, but it would be a lot easier if you could declare the components block and have it &#8220;just work.&#8221;  </p>
<p>Luckily, there is an easy way to specify where new components should be rendered for a particular kind.  Add a component to your kind with the name <strong>client</strong> and any new components will be appended there.  This should work for any component type, but it is probably a good idea to stick with something like a V/HFlexBox, Scroller, or any other kind designed to hold other components.  In this example, we can just rename the Scroller in MyKind:<br />
&nbsp;</p>
<pre>...
{name: "client", kind: enyo.Scroller, flex: 1},
...</pre>
<p>&nbsp;<br />
Now when the Display kind creates its VirtualRepeater, here is what you will get:</p>
<p><a rel="nofollow" target="_blank" href="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind_right.png"><img class="alignnone size-full wp-image-4059" src="http://developer.palm.com/blog/wp-content/uploads/2011/08/mykind_right.png" alt="" width="1012" height="683" /></a></p>
<p>Perfect!  Now anything added to MyKind will go into the Scroller.  Using this feature should enable application developers to gain more control over their custom kinds and how they interact when used in other projects.</p>
<p><img src="http://feeds.feedburner.com/~r/pdnblog/~4/s2WQ24dXMGI" height="1" width="1"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/controlling-component-placement-in-custom-kinds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Enyo HTML5 Support</title>
		<link>http://www.palmpretouchphone.com/development/extending-enyo-html5-support/</link>
		<comments>http://www.palmpretouchphone.com/development/extending-enyo-html5-support/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 22:12:03 +0000</pubDate>
		<dc:creator>rburdick</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=4136</guid>
		<description><![CDATA[Developers building applications with webOS 3.0 are enjoying the benefits of the Enyo framework. Enyo is HP&#8217;s JavaScript-based framework for building mobile web applications which abstracts the complexities of building features like web service access, localization and complex user interfaces into mobile applications away from the developer. At the same time, mobile developers are increasingly [...]]]></description>
			<content:encoded><![CDATA[<p>Developers building applications with webOS 3.0 are enjoying the benefits of the Enyo framework.  Enyo is HP&#8217;s JavaScript-based framework for building mobile web applications which abstracts the complexities of building features like web service access, localization and complex user interfaces into mobile applications away from the developer.  At the same time, mobile developers are increasingly using HTML5 specific features like video, audio, canvas, to name a few, in their applications.</p>
<p>Fortunately, webOS is built on a WebKit engine with strong HTML5 support.  HTML5 development for webOS is thus supported by default.  Furthermore, the Enyo framework allows developers to take advantage of these HTML5 features in their webOS applications.  However, not all supported HTML5 elements are wrapped with convenient Enyo kinds “out of the box.”  But it is relatively easy for developers to extend Enyo’s HTML5 support.  In this article we explore how to extend Enyo to integrate HTML5 features that are not part of the Enyo framework.</p>
<p><span id="more-4136"></span></p>
<h3>Sample Application</h3>
<p>&nbsp;<br />
This article demonstrates these concepts by means of a simple Enyo sample application.  The full source can be downloaded from this link:</p>
<p><a href="http://developer.palm.com/blog/wp-content/uploads/2011/08/EnyoCanvas.zip">EnyoCanvas Sample Application Source Code</a></p>
<p>The application looks like this when run on the HP TouchPad:</p>
<div id="attachment_4163" class="wp-caption alignnone" style="width: 394px"><a href="http://developer.palm.com/blog/wp-content/uploads/2011/08/enyocanvas_2011-25-08_1610131.png"><img class="size-full wp-image-4163" src="http://developer.palm.com/blog/wp-content/uploads/2011/08/enyocanvas_2011-25-08_1610131.png" alt="" width="384" height="512" /></a><p class="wp-caption-text">EnyoCanvas Sample Application Screen Shot</p></div>
<h3>HTML5 Specific Enyo Kinds</h3>
<p>&nbsp;<br />
The easiest form of Enyo HTML5 support is those cases where Enyo provides built-in kinds for specific HTML5 features. Two examples of this are the Enyo.Video and the Enyo.Sound kinds, which implement HTML5 video and audio, respectively.  For example, adding HTML5 video to an Enyo application is as simple as adding an Enyo.Video component to your application:<br />
&nbsp;</p>
<pre>   {kind: "Enyo.Video",
    name: "video",
    style:"width:1024px; height:640px;",
    src:'http://.../somevideo.mp4'}</pre>
<p>&nbsp;<br />
In the resulting application, the Enyo.Video instance is rendered as an HTML5  element with the specified properties.<br />
&nbsp;</p>
<h3>What if There Isn&#8217;t a Kind for That?</h3>
<p>&nbsp;<br />
This is all great, but what if you want to integrate an HTML5 feature that doesn&#8217;t have a corresponding kind as part of the Enyo framework?  Fortunately, creating your own custom Enyo kinds to supplement Enyo&#8217;s HTML5 support is easy.  Thanks to the Enyo.DomNode kind, you can create custom kinds that render any HTML5 tag you like.  You can also specify a collection of custom tag properties through the domAttributes property.  Let&#8217;s take a look at how to build a custom Enyo kind to implement an HTML5 feature that is not specifically part of the Enyo framework. In the following example, we&#8217;ll create a simple HTML5 canvas Enyo kind.<br />
&nbsp;</p>
<h4>Implementing an HTML5 Canvas Kind</h4>
<p>&nbsp;<br />
We will define a new Enyo kind called Enyo.CanvasControl, derived from Enyo.Control.  Since Enyo.Control has Enyo.DomNode as a parent in its inheritance hierarchy, Enyo.CanvasControl has nodeTag and domAttributes properties that we can customize.<br />
&nbsp;</p>
<pre>enyo.kind({
   name: "MyApps.CanvasControl",
   kind: "enyo.Control",
   nodeTag: "canvas",
   canvas: "",
   context: "",
   domAttributes: {
      width: window.innerWidth,
      height:"200px"
   }
   ...
};</pre>
<p>&nbsp;<br />
Our kind specifies &#8220;canvas&#8221; as the nodeTag, and sets &#8220;domAttributes&#8221; to a width and height value.  When rendered on my TouchPad, Enyo produces markup with the  tag and those width and height attribute values as follows:</p>
<pre><code>
&lt;canvas width="768" height="200" id="mainView_canvasControl"&gt;
</code></pre>
<p>&nbsp;<br />
At this point, we now have an HTML5 canvas embedded in an Enyo application.  We can do whatever canvas 2D drawing we like now in the context of this application.  A key part of making this happen is overriding the rendered method which is called by the Enyo framework once the underlying DOM element has been created and rendered.<br />
&nbsp;</p>
<pre>rendered: function() {
   this.hasNode();	 //Sets the node property of the rendered DOM node
   this.canvas = this.node;
   this.context = this.canvas.getContext('2d');
   this.drawCanvas();
}</pre>
<p>&nbsp;<br />
This code sets and stores the canvas and 2D context values in our associated CanvasControl properties, canvas and content, for use in other parts of the code.  We then call drawCanvas to perform some 2D graphics.  Specifically, we fill a rectangle with a gradient based on the color selected in the application&#8217;s Enyo based color picker:<br />
&nbsp;</p>
<pre>drawCanvas: function() {
    var gradient = this.context.createLinearGradient(0, 0, this.canvas.width, this.canvas.height);
    gradient.addColorStop(0, "white");
    gradient.addColorStop(1, this.color);
    this.context.fillStyle = gradient;
    this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
}</pre>
<p>&nbsp;<br />
Nothing fancy, but it gives you the idea of how to bake custom HTML5 features into an Enyo application.<br />
&nbsp;</p>
<h3>Enyo And HTML5 &#8211; Better Together!</h3>
<p>&nbsp;<br />
Not only does this mean that we can now do all kinds of cool HTML5 canvas drawing in the application, but we can integrate Enyo user interface elements into the same application.  Developers can thus build TouchPad style user interfaces into canvas or other HTML5 applications without having to build UI components themselves.</p>
<p>To see how this is done, let&#8217;s take a look at how I embedded an instance of our CanvasControl kind into my application.  This is done in MainView.js:<br />
&nbsp;</p>
<pre>enyo.kind({
   name: "MyApps.MainView",
   kind: "enyo.VFlexBox",
   components:[
      {kind: "PageHeader", components: [
           {content: "Simple HTML5 Canvas + Enyo Demo", flex: 4},
           {kind: "ListSelector", name: "colorPicker", ...}
      ],
      {kind: "MyApps.CanvasControl", name: "canvasControl"},
      {kind: "Button", name: "clearCanvasButton", caption: "Clear Canvas", ...}
   ]
   ...
});</pre>
<p>&nbsp;<br />
From this code snippet, you can see that our custom Canvas kind is integrated with standard Enyo framework UI elements in the same application.<br />
&nbsp;</p>
<h3>Next Steps</h3>
<p>&nbsp;<br />
If you haven’t already, it&#8217;s time to get started with webOS 3.0 and Enyo development by <a href="https://developer.palm.com/content/resources/develop/sdk_pdk_download.html">downloading the webOS 3.0 SDK</a>!</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/yQNxrJ-IJqA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/extending-enyo-html5-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What’s new for HTML Canvas in webOS 3.0</title>
		<link>http://www.palmpretouchphone.com/development/what%e2%80%99s-new-for-html-canvas-in-webos-3-0/</link>
		<comments>http://www.palmpretouchphone.com/development/what%e2%80%99s-new-for-html-canvas-in-webos-3-0/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 20:47:24 +0000</pubDate>
		<dc:creator>joshmarinacci</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=3707</guid>
		<description><![CDATA[As you know, we’re big fans of web standards. The Canvas API is a crucial part of HTML 5 web standards, letting you draw complex 2D graphics in the middle of your web content without any plugins. All it takes is some simple JavaScript. I just wanted to go over some of the improvements we’ve [...]]]></description>
			<content:encoded><![CDATA[<p>As you know, we’re big fans of web standards. The Canvas API is a crucial part of HTML 5 web standards, letting you draw complex 2D graphics in the middle of your web content without any plugins. All it takes is some simple JavaScript. I just wanted to go over some of the improvements we’ve made to the Canvas API for webOS 3.0.</p>
<p><strong>Here are some of the highlights:</strong></p>
<ul>
<li>- The <em>Canvas.toDataURL</em> function is now supported –      you can manipulate pixels to your heart’s content, getting the results out      as a Base64 encoded PNG. From there you can use it as the source to an IMG      tag, upload it to a web service, or save it locally.</li>
<li>- Line caps and Line Joins are fully implemented. This      makes charts and graphs a lot prettier.</li>
<li>- More composite modes.</li>
<li>- Multi-touch events: While this isn&#8217;t specific to      Canvas, it&#8217;s common for Canvas apps to use multi-touch events.  Now      webOS can join the fun.</li>
<li>- Bug fixes: Lots and lots of bug fixes, including some      around transforms and arc drawing.</li>
</ul>
<p>Beyond features and bug fixes, one of the biggest changes is speed. We’ve been working hard to improve HTML Canvas performance and I think the results speak for themselves. As a frame of reference, <a href="http://demo.joshy.org/Amino/particles/">my particle demo</a> previously would reach around 90 or 100 particles before dropping below 20 frames per second. Now, I can get to 200 particles in the same demo, which is a significant bump in basic drawing performance.</p>
<p>&nbsp;</p>
<p><span id="more-3707"></span></p>
<p>Others have taken notice as well. Sencha recently <a href="http://www.sencha.com/blog/hp-touchpad-the-html5-developer-scorecard/">reviewed</a> the TouchPad&#8217;s HTML support on their blog and they said it had “the fastest Canvas implementation [they've] seen thus far”:</p>
<p style="padding-left: 30px;">“We had heard good things about the Canvas support so we decided to push the browser further. So, we tried some of the Microsoft mobile performance tests to stress canvas. Here the TouchPad screams—it has the fastest Canvas implementation we’ve seen thus far. For example, on the Mobile Speed Reading test, the TouchPad gets 16 FPS (PlayBook gets 10 FPS, iPad 2 gets 3 FPS, and the Xoom fails to load the test). Even more impressive is the Fish Tank demo, where the TouchPad hovers around 25 FPS. Canvas performance is stellar.”</p>
<p>Of course, we’re not stopping there. We’re already working on making future updates even better.</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/HL8g5r3-d10" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/what%e2%80%99s-new-for-html-canvas-in-webos-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS 3 Flexible Box Model and Enyo Flex Layout</title>
		<link>http://www.palmpretouchphone.com/development/css-3-flexible-box-model-and-enyo-flex-layout/</link>
		<comments>http://www.palmpretouchphone.com/development/css-3-flexible-box-model-and-enyo-flex-layout/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 21:29:56 +0000</pubDate>
		<dc:creator>Tomomi Imura</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=3734</guid>
		<description><![CDATA[I&#8217;d like to talk about the fundamental concept of CSS 3 Flexible Box Models and how you can take advantage of it as you create the interface using the Enyo framework. In addition, I&#8217;d also recommend checking out one of our previous posts, &#8220;Getting Familiar with the Flexible Box Layout Model.&#8221; CSS 3 Flexible Box [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to talk about the fundamental concept of CSS 3 Flexible Box Models and how you can take advantage of it as you create the interface using the Enyo framework. In addition, I&#8217;d also recommend checking out one of our previous posts, &#8220;<a href="http://developer.palm.com/blog/2011/04/getting-familiar-with-the-flexible-box-layout-model/" >Getting Familiar with the Flexible Box Layout Model</a>.&#8221;</p>
<h4 style="font-size: 18px;margin-top: 1em">CSS 3 Flexible Box Model (&#8220;Flexbox&#8221;)</h4>
<p>&nbsp;</p>
<p>The flexbox model is a new box model introduced in CSS 3. The flexbox model determines how the children of a box are laid out either horizontally or vertically, and determine how to share the available space.</p>
<pre>&lt;div class="container"&gt;
  &lt;div&gt;1&lt;/div&gt;
  &lt;div&gt;2&lt;/div&gt;
  &lt;div&gt;3&lt;/div&gt;
&lt;/div&gt;</pre>
<p>&nbsp;</p>
<pre>.container {
  display: -webkit-box;
  -webkit-box-orient: horizontal;
}</pre>
<p><img class="alignnone size-full wp-image-3760" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/box-orient-h.png" alt="Horizontal Flexbox" width="343" height="171" /><br />
<span id="more-3734"></span><br />
If you switch the value for <code style="font-family: monospace;font-weight: bold">box-orient</code> (with the Webkit extension, <code style="font-family: monospace;font-weight: bold">-webkit-box-orient</code>) to <code style="font-family: monospace;font-weight: bold">vertical</code>, the children boxes are displayed vertically.</p>
<p><img class="alignnone size-full wp-image-3763" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/box-orient-v.png" alt="Vertical Flexbox" width="343" height="171" /></p>
<p>A box is not flexible by default, and it is flexible only when the property <code style="font-family: monospace;font-weight: bold">box-flex</code> has a defined value and the property defines its flexibility ratio relative to the siblings. The <code style="font-family: monospace;font-weight: bold">box-flex</code> is similar to percent sizing, except that the calculations are based on available space (not total space).</p>
<p>Let&#8217;s try the last box to be flexible, which takes up all the available space:</p>
<pre>.container &gt; div:last-child {
  -webkit-box-flex: 1;
}</pre>
<p><img class="alignnone size-full wp-image-3764" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/box-flex-h.png" alt="Horizontal Flexbox with box-flex value" width="343" height="171" /><br />
<img class="alignnone size-full wp-image-3765" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/box-flex-v.png" alt="Vertical Flexbox with box-flex value" width="343" height="171" /></p>
<p>To align a horizontally oriented boxes, use <code style="font-family: monospace;font-weight: bold">box-pack</code> to distribute space in horizontal axis (in the same direction to the orient), and <code style="font-family: monospace;font-weight: bold">box-align</code> for vertical axis (in the opposite direction to the orient).<br />
By giving the value <code style="font-family: monospace;font-weight: bold">center</code> to both properties, the children align up in the center of each box vertically and horizontally:</p>
<p>&nbsp;</p>
<pre>.container {
  -webkit-box-orient: horizontal;
  -webkit-box-pack: center;
  -webkit-box-align: center;
}</pre>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-3766" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/box-pack-align-h.png" alt="Flexbox align and pack" width="343" height="171" /></p>
<h4 style="font-size: 18px;margin-top: 1.5em">Enyo Flex Layouts</h4>
<p>&nbsp;</p>
<p>Enyo&#8217;s flex layouts are based on the CSS3 Flexible Box Model.<br />
In Enyo, the Control object may use Layout objects to enhance the rendering of their child controls. You can lay the objects out by specifying a value of the <code style="font-family: monospace;font-weight: bold">layoutKind</code> property.<br />
The <code style="font-family: monospace;font-weight: bold">VFlexBox</code> and <code style="font-family: monospace;font-weight: bold">HFlexBox</code> kinds are simply controls that have <code style="font-family: monospace;font-weight: bold">layoutKind</code> set by default (<code style="font-family: monospace;font-weight: bold">layoutKind: enyo.VFlexLayout</code> and <code style="font-family: monospace;font-weight: bold">layoutKind: enyo.HFlexLayout</code>, respectively).</p>
<p>&nbsp;</p>
<p>So creating the same example with horizontally aligned boxes (well, let&#8217;s make it with Enyo buttons!) can easily be created with Enyo as follows:</p>
<p>&nbsp;</p>
<pre>{name: "container", kind: "HFlexBox", components:[
  {kind: "Button", caption: "1"},
  {kind: "Button", caption: "2"},
  {kind: "Button", caption: "3"},
]}</pre>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-3769" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/enyo-box-orient-h.png" alt="enyo buttons with flexbox layout" width="315" height="90" /></p>
<p>If want the 3rd box to be flexible, you can simply give the property, flex the value 1.</p>
<p>&nbsp;</p>
<pre>{kind: "Button", caption: "3", flex: 1}</pre>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-3770" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/enyo-box-flex-h.png" alt="enyo buttons with flexbox, box-flex value" width="315" height="90" /></p>
<h4 style="font-size: 18px;margin-top: 1.5em">Creating App UI with Enyo FlexBox</h4>
<p>&nbsp;</p>
<p>Here are some more practical examples you might find useful in your own applications.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-3771" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/enyo-ui.jpg" alt="A basic enyo UI" width="601" height="400" /></p>
<p>This basic user-interface is created with <code style="font-family: monospace;font-weight: bold">enyo.VFlexBox</code>. And the entire UI code is shown below.</p>
<p>&nbsp;</p>
<pre>enyo.kind({
  name: "Main",
  kind: "VFlexBox",
  components: [
    {kind: "PageHeader", content: "FlexBox is awesome!", style: "text-transform: capitalize"},
      {kind: "VirtualList", flex: 1},
      {kind: "Toolbar"}
  ],

  create: function() {
    this.inherited(arguments);
  }
});</pre>
<p>&nbsp;</p>
<p>Notice that the container itself is the <code style="font-family: monospace;font-weight: bold">enyo.VFlexBox </code>kind, and the object in the middle (where the <code style="font-family: monospace;font-weight: bold">enyo.VirtualList</code> is) has the flex property value that tells the layout to take up the all available space. If you do not specify the value, the middle section and the footer section (<code style="font-family: monospace;font-weight: bold">enyo.Toolbar</code>) flow just like the regular box model &#8211; the footer is rendered just below where the middle section content ends (which is empty, in this case), instead of staying at the very bottom of the screen.</p>
<p>&nbsp;</p>
<p>The flex layout can be applied anywhere else in your UI components. Let&#8217;s say you have some list items within the <code style="font-family: monospace;font-weight: bold">VirtualList</code> and each item is composed with an avatar picture at the left, and two lines of a person&#8217;s info at the right side. You can achieve the layout using:</p>
<p>&nbsp;</p>
<pre>...
{kind: "VirtualList", flex: 1, onSetupRow: "setupRow", components:[
  {kind: "Item", layoutKind: "HFlexLayout", components: [
    {kind: "Image", className: "avatar"},
    {kind: "VFlexBox", pack: "center", flex: 1, components: [
      {name: "fullName"},
      {name: "jobTitle", className: "enyo-item-secondary"}
    ]}
]},
...</pre>
<p>&nbsp;</p>
<p>See how the horizontal and vertical flex layout are nested, and how the flex and pack properties are used.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-3772" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/enyo-ui-list-items.png" alt="Enyo Flexbox UI example" width="383" height="252" /></p>
<h4 style="font-size: 18px;margin-top: 1.5em">Performance Considerations</h4>
<p>&nbsp;</p>
<p>
You should be aware that while the flexible box model is very convenient, it should not be applied unnecessarily.  When flexible boxes are nested inside more flexible boxes, the time it takes to render goes up exponentially.  Luckily this penalty is small enough to be negligible for a few levels of nesting, but after three layers of nested flexible boxes you will start seeing your application slow down when rendering.  In these instances, try to evaluate if all your flexible boxes are absolutely necessary, or if simpler CSS attributes such as &#8220;width: 25%&#8221; would meet your goals.
</p>
<p>&nbsp;</p>
<h4 style="font-size: 18px;margin-top: 2em;margin-bottom: 1em">Conclusion</h4>
<p>&nbsp;</p>
<p>The flexbox model layout is pretty simple and easy to architect your app UI and create components, especially with Enyo. For more information of the original specs of the CSS3 flexbox model that the current WebKit supports, see <a href="http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/" >W3C spec page</a>.</p>
<p>&nbsp;</p>
<p>Happy coding!</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/C9QTWDaUXro" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/css-3-flexible-box-model-and-enyo-flex-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building world-ready webOS 3.0 applications</title>
		<link>http://www.palmpretouchphone.com/development/building-world-ready-webos-3-0-applications/</link>
		<comments>http://www.palmpretouchphone.com/development/building-world-ready-webos-3-0-applications/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 18:18:15 +0000</pubDate>
		<dc:creator>rburdick</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=3831</guid>
		<description><![CDATA[The HP TouchPad with webOS 3.0 and the Enyo application programming framework bring significant opportunities for developers to leverage web standards for building great mobile applications and services.  The growing availability of the TouchPad in countries outside North America means that developers like you will be able to bring their content to an expanding global [...]]]></description>
			<content:encoded><![CDATA[<p>The HP TouchPad with webOS 3.0 and the Enyo application programming framework bring significant opportunities for developers to leverage web standards for building great mobile applications and services.  The growing availability of the TouchPad in countries outside North America means that developers like you will be able to bring their content to an expanding global audience.  For the greatest opportunity to reach the widest consumer audience possible, it&#8217;s thus beneficial to ensure that your applications are available in the native languages of your target market countries.</p>
<p>The Enyo application programming framework makes it very easy to localize your applications.</p>
<p><span id="more-3831"></span></p>
<h4>Sample Application</h4>
<p>Included with this article is a sample Enyo application that demonstrates some of the key features and capabilities of the Enyo localization libraries.  While it doesn’t cover every single detail of the framework, this sample application should get you started with the most essential elements of building webOS 3.0 applications for the global market.  A screen shot of the application is shown below.</p>
<p><a href="http://developer.palm.com/blog/wp-content/uploads/2011/07/SampleAppSmall.png"><img class="alignnone size-full wp-image-3835" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/SampleAppSmall.png" alt="" width="384" height="512" /></a></p>
<p>The full source code for the sample application can be found here:<br />
<a href="http://developer.palm.com/blog/wp-content/uploads/2011/07/localization.zip">Sample Application Source Code</a></p>
<h4>The g11n library</h4>
<p>Enyo’s globalization support is implemented in the g11n library.  This library includes g11n-base, which defines core globalization features, including locale, Enyo kinds for formatting dates, times, numbers and the like, and resources.  g11n also contains libraries for parsing and formatting addresses, phone numbers, and names.</p>
<p>As the concepts of locale and resources are fundamental to localizing any application, let’s start with these topics.</p>
<h3>Locale</h3>
<p>Simply put, a locale is a set of information that describes the language and country that determine the user interface of a device and its applications.  A locale is primarily used to determine how textual information is to be displayed, such as which translations of text strings to use, how dates and currencies are to be formatted, and the like.  Locale can also be used for non-textual information, such as default paper sizes for printing utilities and determining standard photo sizes for imaging applications.</p>
<p>In Enyo applications, a locale is defined with a specification string in the following format:</p>
<pre>  [language][_region][_variant]</pre>
<p>The language is a two-letter language ISO 639 language code, such as en for English, es for Spanish, fr for French, and so on.  The region value is a two-letter ISO 3166 country code.  Together, the language and region codes can thus specify country or regional variants of the same primary language.  Typical cases are European vs. Canadian French (represented as “fr_fr” and “fr_ca”, respectively,) or European vs. Americas Spanish (represented as “es_es” and “es_us”, respectively.) The variant qualifier can be any ASCII string of characters (except for spaces and underscores) that further differentiates languages.  These are not used as commonly as language and variant, and generally localized applications are limited to these.</p>
<p>In Enyo, a locale is represented by an instance of the enyo.g11n.Locale kind.  You create an instance by passing a locale specification string.  For example, to create a US English locale:</p>
<p>var myLocale = new enyo.g11n.Locale(&#8220;en_us&#8221;);</p>
<h4>Current  Locale</h4>
<p>An Enyo application can read the locale currently in use by the host device by calling the currentLocale() method:</p>
<pre>var currentLocale = new enyo.g11n.currentLocale();</pre>
<p>The return value is an enyo.g11n.Locale instance that contains the details about the current locale.  The locale details can be read using value methods defined by the Locale kind.  For example, the full locale specification string can be read using the getLocale method:</p>
<pre>var locale_spec = currentLocale.getLocale();</pre>
<p>If the device’s current locale was Canadian French, locale_spec would contain the string &#8220;fr_ca.&#8221;  Other methods can be used to parse out the locale details, such as getLanguage, getRegion and getVariant.</p>
<h3>Resource Files</h3>
<p>Applications use locale to help localize their user interfaces for the language and culture of their users.  The biggest component of application localization is displaying strings in the right language, and possibly, regional dialect.  A localized application thus needs to include a set of translated strings for all user interface text in each of the languages supported by the application.</p>
<p>In Enyo, these strings are packaged with the application as one of more resource JSON files.  These files use the naming convention language_variant.json.  For example, an application might contain the file es_us.json to store Spanish strings:</p>
<pre>{
  "Hello":"Hola",
  "Goodbye":"Adios",
  "Choose A Language":"Elige un idioma"
}</pre>
<p>Each line of an Enyo resource JSON file contains an English string followed by the translated equivalent.  The files are stored in a folder named &#8220;resources&#8221; right under the application root folder.  Resource JSON files need to be saved in UTF-8 format for any special characters in the translated strings to render properly.  Also, note that the byte order marker at the beginning of UTF-8 files can confuse the g11n resource loader.  Some editors, like Notepad++, include the byte order mark when saving UTF-8 files.  Editors like Sublime Text and Eclipse do not, so you might want to use one of these for creating your resource files.</p>
<p>Resources can then be loaded for use in the application using the enyo.g11n.Resources kind:</p>
<pre>var resources = new enyo.g11n.Resources(locale);</pre>
<p>The locale argument can either be a Locale instance, or a JSON formatted locale specifier, such as:</p>
<pre>var resources = new enyo.g11n.Resources({locale: "es_us"});</pre>
<p>Now let’s take a look at where the rubber hits the road, specifically how to load individual localized strings into your Enyo application.</p>
<h3>The $L Function</h3>
<p>The Enyo g11n library defines a global function, called $L, which is used to load localized resource strings.  This function takes one string argument.  The function will load the corresponding translated resource string in the resource JSON file corresponding to the default device locale.  If there is no such resource string, $L returns the string argument unchanged.  For example, if the default locale is es_us, using the example es_us.json file above:</p>
<pre>var helloString = $L("Hello");</pre>
<p>would return the string “Hola.”</p>
<p>&nbsp;</p>
<p>In addition to the global $L function, enyo.g11n.Resources also defines a $L method.  This works the same way as the global version in that it loads the specified localized string.  However, the string that is returned is the version from the resource JSON file used to create the Resources instance.  Thus an application that lets the user change language can load the right resource strings at runtime:</p>
<pre>enyo.kind({
  name: "MyApps.MainView",
  kind: "enyo.Control",

    components: [
      {content: "Your String Here", name: "locstring"},
      {kind: "Picker", name: "languagePicker",
        label: "Device Default", value: "0", items: [
         {caption: "Device Default", value: "0"},
         {caption: "English", value: "en_us"},
         {caption: "Spanish", value: "es_us"},
         {caption: "French",  value: "fr_fr"},
         {caption: "Canadian French", value: "fr_ca"},
         {caption: "German", value: "de_de"},
         {caption: "Italian", value: "it_it"},
         {caption: "Turkish", value: "tr_tr"}
     ],
  onChange: "onLanguageSelected"
}],

onLanguageSelected: function(inSender) {
  var selectedLanguage = inSender.getValue();
  var currentLocale;
  var localizedResources;

  if (selectedLanguage === "0") {
    currentLocale = enyo.g11n.currentLocale();
  } else {
    currentLocale = new enyo.g11n.Locale(selectedLanguage);
  }

  localizedResources = new enyo.g11n.Resources(currentLocale);
  this.$.locstring.setContent(localizedResources.$L("Hello"));
  }
});</pre>
<h3>Formats</h3>
<p>Text strings are not the only things that need to get localized in a world-ready application.  Many other things like dates, numbers, currency values, and even paper sizes are dependent on locale.  Enyo provides a set of kinds for formatting such values, as well as phone numbers, addresses and names.  To introduce the concepts, we will focus next on two of these, date and number formatting.</p>
<h4>Date Formats</h4>
<p>enyo.g11n.DateFmt is the Enyo date / time formatter kind.  Instances of this kind are created by passing one argument to the constructor, either a JSON object specifying a set of date formatting properties, or a string containing the custom date / time format to use.  An example of the JSON approach is:</p>
<pre>  dateFmt = new enyo.g11n.DateFmt({
  locale: "es_us",
  date: "long",
  time: "long",
  twelveHourFormat: true,
  weekday: true
});</pre>
<p>This locale property specifies the locale to use when formatting.  If omitted, the device default will be used.  The data and time properties are set to “long”, one of the predefined formats.  The others are “short”, “medium”, and “full”, each of which renders different levels of date / time detail.  Date and time can also be custom format strings if you want to fully customize information rendered.  The full specification of allowed format strings can be found in the developer documentation here:</p>
<p><a href="https://developer.palm.com/content/api/dev-guide/enyo/globalization.html#enyo.g11n.datefmtparams" class="broken_link">https://developer.palm.com/content/api/dev-guide/enyo/globalization.html#enyo.g11n.datefmtparams</a></p>
<p>The sample application included with this article includes some controls for experimenting with the standard and custom date / time formatting options.</p>
<h4>Number Formats</h4>
<p>Number formatting is accomplished in a manner similar to date / time formatting.  The enyo.g11n.NumberFmt is the kind to use for formatting numbers, currency values, and percentages.  You specify a JSON object with the various formatting properties.  These include locale, style, currency, currencyStyle, and fractionDigits.  Not all of these are meaningful in all cases: the value of style determines what type of number is being formatted.  The style property can be one of “number”, “percent”, or “currency”.  fractionDigits specifies the number of places displayed after the decimal point.  If currency is specified as the style, currencyStyle can be set to “iso” or “common” to specify how the currency sign is rendered.  If “iso” is specified, the ISO 4217 currency code is used.  If “common”, the locale specific currency symbol is used (for example, USD versus $.)  The currency property lets you specify the ISO 4217 currency code.  So, if you wanted to format 12.50 Argentinean Pesos by specifying the ISO 4217 currency code (ARS) but display the value with the peso symbol, you could do this:</p>
<pre>  var numFmt = new enyo.g11n.NumberFmt({
  style: "currency",
  currency: "ARS",
  currencyStyle: "common"
});

  var pesosString = numFmt.format("12.50");</pre>
<h3>Next Steps</h3>
<p>With this introduction to the Enyo g11n library, you should be well prepared to dive into building your first global webOS 3.0 application.  If you haven’t already, get started by <a href="https://developer.palm.com/content/resources/develop/sdk_pdk_download.html" class="broken_link">downloading the webOS 3.0 SDK.</a></p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/rMo6GPOe52I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/building-world-ready-webos-3-0-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enyo Basics: Encapsulation</title>
		<link>http://www.palmpretouchphone.com/development/enyo-basics-encapsulation/</link>
		<comments>http://www.palmpretouchphone.com/development/enyo-basics-encapsulation/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 17:08:52 +0000</pubDate>
		<dc:creator>adahm</dc:creator>
				<category><![CDATA[Developing with the webOS SDK]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=3783</guid>
		<description><![CDATA[For developers that are just getting started with webOS 3.0 and familiarizing themselves with our Enyo framework, the concept of encapsulation &#8211; a way to break your app down into smaller, self-contained parts &#8211; can make your code easier to understand and maintain. Once an Enyo app is broken down into self-contained components, they need [...]]]></description>
			<content:encoded><![CDATA[<p>For developers that are just getting started with webOS 3.0 and familiarizing themselves with our Enyo framework, the concept of encapsulation &#8211; a way to break your app down into smaller, self-contained parts &#8211; can make your code easier to understand and maintain.</p>
<p>Once an Enyo app is broken down into self-contained components, they need to be able to interact with each other to perform actions or expose and change properties they contain. In this blog post we will explore encapsulation using Enyo components and the methods that can be used to interact with them.</p>
<p><strong>A simple example</strong></p>
<p>Here is a simple Enyo application without encapsulation. The app will be modified to encapsulate some of its functionality later. The app is a timer that will show a progress bar increasing in value from 0% to 100% over the course of 10, 30 or 60 seconds. It also has radio buttons that determine the duration of the timer and a button to start the timer.<br />
<span id="more-3783"></span><br />
<a href="http://developer.palm.com/blog/wp-content/uploads/2011/07/Simple-Timer-Example.png"><img class="alignnone size-full wp-image-3787" src="http://developer.palm.com/blog/wp-content/uploads/2011/07/Simple-Timer-Example.png" alt="" width="700" height="525" /></a></p>
<p>Here is the original code for the app without any encapsulation besides that provided by the built-in Enyo controls themselves. Even with this simple example, it&#8217;s easy to see how the code can start to get out of hand as more components are added.</p>
<pre>enyo.kind({
  name:  'SimpleTimerApp',
  kind:  'enyo.Control',
  components: [
    {name: "simpleTimer", kind: "RowGroup", caption: "Simple Timer", components: [
      {name: "animator", kind: enyo.Animator, easingFunc: enyo.easing.linear,
        duration: 30000, tick: 1000, onBegin: "beginAnimation",
        onAnimate: "stepAnimation", onEnd: "endAnimation"
      },
      {kind: "Control", layoutKind: "HFlexLayout", pack: "start", align: "center",
         components: [
           {name: 'timerProgress', kind: "ProgressBar", flex:1, minimum: 0,
             maximum: 30, position: 0}
      ]}
    ]},
    {kind: "Control", layoutKind: "HFlexLayout", pack: "center", align: "center",
      components: [
        {name: "selTimerDuration", kind: "RadioGroup", width: "360px",
           onChange: "timerDurationChanged", components: [
            {caption: "10 Sec.", value: "10"},
            {caption: "30 Sec.", value: "30"},
            {caption: "60 Sec.", value: "60"}
      ]}
    ]},
    {kind: "Control", layoutKind: "HFlexLayout", pack: "center", align: "center",
       components: [
        {name: 'startTimer', kind:'Button', caption:'Start Timer', width:'360px',
          onclick:'timerStart' }
    ]}
  ],

  constructor: function () {
    this.inherited(arguments);
    this.timerDuration = 30;
  },

  create: function () {
    this.inherited(arguments);

    this.$.selTimerDuration.setValue(this.timerDuration);

    this.$.simpleTimer.setCaption("Simple Timer (" + this.timerDuration + " seconds)");
    this.$.timerProgress.setMaximum(this.timerDuration);
    this.$.animator.setDuration(this.timerDuration * 1000);
  },

  timerStart: function () {
    this.$.animator.play(0, this.timerDuration);
  },

  stepAnimation: function(inSender, inValue) {
    this.$.timerProgress.setPosition(inValue);
  },

  beginAnimation: function(inSender, inStart, inEnd) {
    this.$.timerProgress.setPosition(0);
    this.$.startTimer.setDisabled(true);
  },

  endAnimation: function(inSender, inValue) {
    this.$.timerProgress.setPosition(0);
    this.$.startTimer.setDisabled(false);
  },

  timerDurationChanged: function(inSender, inValue, inOldValue) {
    this.timerDuration = inValue;
    this.$.simpleTimer.setCaption("Simple Timer (" + inValue + " seconds)");
    this.$.timerProgress.setMaximum(inValue);
    this.$.animator.setDuration(inValue * 1000);
  }
});</pre>
<p><strong>Creating a control</strong></p>
<p>A general programming rule of thumb is that indentation should not go more than three levels deep. Examination of the components section of the source code shows that the app can be broken down into three parts. One is the timer itself, which consists of a progress bar to provide feedback, an animator control and a few other controls. The second part contains the radio buttons for setting the duration of the timer, and the third part is the button to start the timer. All the components in the first part make up the actual timer used in the app and are related to each other, so that will become a custom control named <strong>SimpleTimer</strong> that will be broken out into its own Enyo kind at the same level as the app kind.</p>
<pre>enyo.kind({
  name:  'SimpleTimer',
  kind: "RowGroup",
  caption: "Simple Timer",
  published: {
    timerDuration: 30
  },
  events: {
    onSimpleTimerStart: "",
    onSimpleTimerEnd: ""
  },
  components: [
    {name: "animator", kind: enyo.Animator, easingFunc: enyo.easing.linear,
      duration: 30000, tick: 1000, onBegin: "beginAnimation",
     onAnimate: "stepAnimation", onEnd: "endAnimation"
    },
    {kind: "Control", layoutKind: "HFlexLayout", pack: "start", align: "center",
       components: [
        {name: 'timerProgress', kind: "ProgressBar", flex:1, minimum: 0,
           maximum: 30, position: 0
         }
    ]}
  ],

  create: function () {
    this.inherited(arguments);
    this.setCaption("Simple Timer (" + this.timerDuration + " seconds)");
    this.$.timerProgress.setMaximum(this.timerDuration);
    this.$.animator.setDuration(this.timerDuration * 1000);
  },

  start: function () {
    this.$.animator.play(0, this.timerDuration);
  },

  stepAnimation: function(inSender, inValue) {
    this.$.timerProgress.setPosition(inValue);
  },

  beginAnimation: function(inSender, inStart, inEnd) {
    this.$.timerProgress.setPosition(0);
    this.doSimpleTimerStart();
  },

  endAnimation: function(inSender, inValue) {
    this.$.timerProgress.setPosition(0);
    this.doSimpleTimerEnd();
  },

  timerDurationChanged: function() {
    this.setCaption("Simple Timer (" + this.timerDuration + " seconds)");
    this.$.timerProgress.setMaximum(this.timerDuration);
    this.$.animator.setDuration(this.timerDuration * 1000);
  }
});

enyo.kind({
  name:  'SimpleTimerApp',
  kind:  'enyo.Control',
  components: [
    {name: "simpleTimer", kind: "SimpleTimer",
       onSimpleTimerStart: 'simpleTimerStarted',
       onSimpleTimerEnd: 'simpleTimerEnded'
    },
    {kind: "Control", layoutKind: "HFlexLayout", pack: "center", align: "center",
        components: [
        {name: "timeLimit", kind: "RadioGroup", width: "360px",
           onChange: "radioButtonSelected", components: [
             {caption: "10 Sec.", value: "10"},
             {caption: "30 Sec.", value: "30"},
             {caption: "60 Sec.", value: "60"}
      ]}
    ]},
    {kind: "Control", layoutKind: "HFlexLayout", pack: "center", align: "center",
      components: [
        {name: 'startTimer', kind:'Button', caption:'Start Timer',
           width: '360px', onclick:'timerStart'
        }
    ]}
  ],

  create: function () {
    var initialDuration = 10;
    this.inherited(arguments);
    this.$.timeLimit.setValue(initialDuration);
    this.$.simpleTimer.setTimerDuration(initialDuration);
  },

  radioButtonSelected: function (inSender) {
    this.$.simpleTimer.setTimerDuration(inSender.getValue());
  },

  timerStart: function () {
    this.$.simpleTimer.start();
  },

  simpleTimerStarted: function () {
    this.$.startTimer.setDisabled(true);
  },

  simpleTimerEnded: function () {
    this.$.startTimer.setDisabled(false);
  }

});</pre>
<p><strong>Communicating with the control</strong></p>
<p>In the original sample application, code that was used by the timer was spread out throughout the application. Changing any part of the timer code meant the possibility of affecting other code in the application. But now that the code for the new SimpleTimer control is encapsulated in its own kind, how does the app communicate with the components within the control? The SimpleTimer control acts as a gateway or buffer between the application and whatever components and code are inside the control.</p>
<p><strong>Calling methods in the control</strong></p>
<p>To tell the control to do something, methods belonging to the control are called. The SimpleTimer control has a <strong>start()</strong> method that starts the timer. All the work that goes into initializing the internal controls and starting the timer happens inside the SimpleTimer control itself.</p>
<p><strong>Receiving events</strong></p>
<p>When the control needs to tell the app about something, it sends events. The SimpleTimer sends <strong>simpleTimerStart</strong> and <strong>simpleTimerEnd</strong> events to the application. In this particular implementation, the events start out as <strong>onBegin</strong> and <strong>onEnd</strong> events from the Animator control. The SimpleTimer control processes these internal events and passes them on as its own <strong>simpleTimerStart</strong> and <strong>simpleTimerEnd</strong> events to the application.</p>
<p><strong>Getting and setting properties</strong></p>
<p>Properties within the control can be published to give the application access to them. When a property is published, it automatically gets a <strong>get&lt;property name&gt;()</strong> and a <strong>set&lt;property name&gt;()</strong> method. If a <strong>&lt;property name&gt;Changed()</strong> method is created, it will get called whenever there is a change to the property. In the SimpleTimer control, the <strong>timerDuration</strong> property was published, so it has the<strong> getTimerDuration()</strong> and <strong>setTimerDuration()</strong> methods. A <strong>timerDurationChanged()</strong> method was also created to update the animator control and some UI controls whenever the <strong>timerDuration</strong> property is changed.</p>
<p><strong>Conclusion</strong></p>
<p>The overall size of the app has increased slightly, but the code is easier to maintain because everything related to the SimpleTimer component is contained within the kind. The component can be used in several places within the app and can be easily copied and used in other projects. Thanks to encapsulation, the inner workings of the component can be changed with little to no impact on the app itself &#8211; for instance, swapping out the animator control with some other sort of timer code or changing the UI from a progress bar to a numeric display.</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/-COoEA_63nY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/enyo-basics-encapsulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Major updates to the HP webOS Developer Program</title>
		<link>http://www.palmpretouchphone.com/development/major-updates-to-the-hp-webos-developer-program/</link>
		<comments>http://www.palmpretouchphone.com/development/major-updates-to-the-hp-webos-developer-program/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 16:13:42 +0000</pubDate>
		<dc:creator>Sean Lindo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[What's Happening in webOS]]></category>
		<category><![CDATA[announcements]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://developer.palm.com/blog/?p=3689</guid>
		<description><![CDATA[Around the webOS Developer Relations team, we often like to say that the developer is our customer. It drives what we do and constantly pushes us to keep asking, how can we improve the experience for every developer on our platform? Investing in your success: Device discounts, support and marketing Today, we’re excited to announce [...]]]></description>
			<content:encoded><![CDATA[<p>Around the webOS Developer Relations team, we often like to say that the developer is our customer. It drives what we do and constantly pushes us to keep asking, how can we improve the experience for every developer on our platform?</p>
<p><strong>Investing in your success: Device discounts, support and marketing</strong><br />
Today, we’re excited to announce some significant updates to the HP webOS Developer Program, to provide even more of the resources you need to create, market and sell great apps in the webOS App Catalog.</p>
<p>These updates include:</p>
<p style="padding-left: 30px;">- Larger discounts on devices, up to 60%<br />
- Loaner device program<br />
- Enhanced support<br />
- Marketing asset kits<br />
- HP co-marketing opportunities<br />
- Access to market development funds</p>
<p>Simply put, we’re investing in developers that invest in webOS. We factor in the apps you develop, your development expertise and your desire to build a thriving business around webOS.</p>
<p><a href="https://developer.palm.com/content/community/hp_webos_developer_benefits.html" class="broken_link"><strong>Read here</strong></a> to get all the details.</p>
<p><strong>Announcing HP webOS Certified Developers Program</strong><br />
Another significant update is the addition of the HP webOS Certified Developers program. This program offers certification to developers that want to make their services available to other companies looking for webOS development expertise. Developers are certified around the quantity and quality of apps they have developed, as well as training they’ve completed and other relevant experience they bring to the table.</p>
<p>One of the biggest benefits of being a webOS Certified Developer is significant promotion and referrals from HP, opening up incredible opportunities that leverage you webOS expertise.  Other benefits include:</p>
<p style="padding-left: 30px;">- Listing in the HP webOS Developer Center for third-party developers<br />
- Dedicated highlight page on the HP webOS Developer Center<br />
- Access to pre-production testing devices<br />
- “webOS Certified developer” marketing assets<br />
- Priority support access</p>
<p><a href="https://developer.palm.com/content/community/hp_webos_certified_developers.html" class="broken_link"><strong>Read here</strong></a> to learn more about the certified developer program.</p>
<p>Along with <a href="http://developer.palm.com/blog/2011/07/hp-webos-pivot-discover-apps-the-new-way/"><strong>webOS Pivot, which takes app discovery to a new level</strong></a> and our commitment to offering free membership for all our programs, webOS provides developers with an experience and set of opportunities unmatched by any platform.</p>
<img src="http://feeds.feedburner.com/~r/pdnblog/~4/bpSY4fj7EaA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.palmpretouchphone.com/development/major-updates-to-the-hp-webos-developer-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

