×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Hello World in WidSets

From Nokia Developer Wiki
Jump to: navigation, search
m
 
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix links)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Archived}}{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080529
 +
|author= [[User:Mirsilla]]
 +
}}[[Category:WidSets]][[Category:Code Snippet]]
 +
{{FNWID}}
 
== About this widget ==
 
== About this widget ==
 
This is a basic Hello World demo widget.
 
This is a basic Hello World demo widget.
Line 129: Line 152:
  
 
== See also ==
 
== See also ==
* [[WidSets SDK]]
+
* [[Archived:WidSets SDK]]
* [[WidSets Client]]
+
* [[Archived:WidSets Client]]
* [[WidSets Scripting Language]]
+
* [[Archived:WidSets Scripting Language]]
* [[Widget examples]]
+
* [[Archived:Widget examples in WidSets]]
** [[WidClock]]
+
** [[Archived:WidClock in WidSets]]
** [[Memory Game]]
+
** [[Archived:Memory Game in WidSets]]
** [[Filter test]]
+
** [[Archived:WidSets Filter test]]
** [[Hello World]]
+
** [[Archived:Hello World in WidSets]]
** [[UITest]]
+
** [[Archived:UITest in WidSets]]
  
 
[[Category:WidSets]]
 
[[Category:WidSets]]

Latest revision as of 07:25, 29 June 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Article
Created: User:Mirsilla (29 May 2008)
Last edited: hamishwillee (29 Jun 2012)
FNWID.gif

Contents

[edit] About this widget

This is a basic Hello World demo widget.

[edit] WidSets Scripting Language code: hello_world.he

class hello_world
{
  //It is recommended to store command ids to static constants
  const int CMD_BACK = 1;
  
  //MenuItems are displayed over phone's softkeys
  //Usually to go back, ok, open options menu etc
  MenuItem BACK = new MenuItem(CMD_BACK, "Back");

  //WidSets framework calls createElement() per
  //each script-element it finds from views being
  //created by createView()
  
  Component createElement(String viewName,
                         String elementName,
                         Style style,
                         Object context)
  {
    //return simple label with style defined in widget.xml,
    //in this case "text"
    if (elementName.equals("hello")) {
      //to get the label aligned in the middle of the
      //view you need to contain it inside a Flow which
      //you then return here
      return new Label(style, "Hello World");
    }                  
    return null;
  }


  void startWidget()
  {
    //instantiate minimized view in startup
    setMinimizedView(createView("viewMini", getStyle("bg")));
  }


  Shell openWidget()
  {
    //instantiate maximized view when user opens this widget
    Flow view = createView("viewMaxi", getStyle("bg"));
    return new Shell(view);
  }

  
  MenuItem getSoftKey(Shell shell, Component focused, int key)
  {
    //return the key to be displayed at position=SOFTKEY_BACK
    //this is usually the right softkey, for other key
    //positions return null

    if (key == SOFTKEY_BACK) {
      return BACK;
    }
    return null;
  }
  
  
  void actionPerformed(Shell shell, Component source, int action)
  {
    //when CMD_BACK event comes in, pop the current shell (this widget)
    if (action == CMD_BACK) {
      popShell(shell);
    }
  }
  
}

[edit] Widget.xml

<?xml version="1.0" encoding="utf-8"?>
 
<widget spec_version="2.0">

  <info>
    <name>hello_world</name>
    <version>0.1</version>
    <author>render</author>
    <clientversion>0.98</clientversion>
    <shortdescription>Very simple widget</shortdescription>
    <longdescription>Simplest possible widget saying hello to the world.</longdescription>
    <tags>test example hello world</tags>
  </info>
   
  <parameters>
    <parameter type="string" name="widgetname">Hello World</parameter>
  </parameters>
  
  <resources>
    <code src="hello_world.he"/>
    <stylesheet>
      bg {
        color-1: white;
        background: solid black;
        align: hcenter vcenter;
        border: 1 1 1 1;
        border-type: rectangle white;
      }

      text {
        color-1: white;
        padding: 2 2 2 2;
      }
    </stylesheet>
  </resources>
    
  <layout minimizedheight="65sp">
    <view id="viewMini" class="bg">
      <label class="text">${widgetname}</label>
    </view>
  
    <view id="viewMaxi" class="bg">
      <script id="hello" class="text"/>
    </view>
    
    <webview>
      <weblabel class="top: 0px; left: 10px;" style="color: black;">${widgetname}</weblabel>
    </webview>
  </layout>

</widget>

[edit] See also

This page was last modified on 29 June 2012, at 07:25.
53 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×