Thread Rating:
  • 384 Vote(s) - 2.78 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Started3:Top-level Applet Specifications
06-15-2011, 02:42 PM, (This post was last modified: 06-29-2011, 01:41 PM by penguin.)
#1
Getting Started3:Top-level Applet Specifications
Global Attributes
This Curl Cue describes how to set common properties for the entire applet. This includes global attributes such as backgrounds, borders, and margins. For common styles that are used many times throughout the applet, we can specify a grouping of stylistic changes using a text procedure.

Specifying Applet Styles
One of the first decisions to make when designing your Curl applet is what document style to use. In Curl, the document style refers to the top level layout structure of the applet.

There are 3 predefined document styles available:

DefaultDocument - This is the default view where the applet is enclosed with scrollbars. This style is most commonly used.

PlainDocument - This style gives you a page without scrollbars.

TocDocument - This style gives you a scrolling page with a table of contents on the left side of the page. The entries in the table of contents are nested according to the heading level of the content.


Tip: Which document style should you use?
•If you want your applet to scroll like an HTML page, use DefaultDocument.
•If you're building an application that should completely control the content of a browser window (such as in a game), use PlainDocument.
•If you are writing online documentation where navigation provided by the table of contents is valuable, you'll find the TocDocument style is the best choice.

To specify the style of the document, use document-style.

Document and Plain Styles
Let's compare the first two styles. Select each button to compare DefaultDocument and PlainDocument.

[DefaultDocument]

[PlainDocument]

In the case of PlainDocument, nothing is added to the document except what your applet adds explicitly. This style only allows one item in the document: the first result returned by your applet at the top level becomes the entire contents of the document.


In the case of DefaultDocument, Curl places the contents of the document inside a ScrollBox. Values returned at the top level of the applet are added one after another. If enough content is added to make scrolling necessary, scrollbars are automatically enabled.


Since DefaultDocument is the default behavior, nothing needs to be added to the code. However, for PlainDocument you need to specify the style by calling the document-style procedure at the top of the applet code. For example:

Code:
{curl 5.0 applet}
{applet {compiler-directives careful? = true}}
{document-style PlainDocument}
{paragraph
{heading Curl IDE}
{paragraph
font-size = 14pt,
The Curl IDE includes all of the tools you need to build rich Internet applications
using the Curl content language. The Curl Run Time Environment (RTE) is free to end users,
and includes a browser plugin so that any user who installs
the RTE can run applications on your web site simply by visiting
the url where you have deployed the applet.
}
}



Table of Contents Style
The TocDocument style constructs a user interface consisting of a navigation panel at the left and a larger panel at the right for the body of the document. The navigation panel is a tree-structured table of contents that contains collapsible sections.

When the TocDocument style is used, every time you use the {heading level = n ...} text procedure, an entry is created. For example:

Code:
{heading House}
{heading level=2, Kitchen}
{heading level=3, Sink}
{heading level=3, Stove}
{heading level=3, Refrigerator}
{heading level=3, Cabinets}
{heading level=2, Living Room}
{heading level=2, Bedroom}
{heading level=2, Bathroom}

If the heading level is greater than the level currently in effect, the table of contents entry will be indented beneath the previous entry. For example:



In most cases, you will use DefaultDocument. Since it is the default, you do not need to specify the document-style.




For more information regarding text formats, please refer to the following section in the Curl Documentation:Curl Developer's Guide > File Systems and Networking > Interacting with the Browser > Presenting Applets > The Applet's Document


Specifying Document Properties
The document style provides hooks and allows authors to control the processing of a document. For example, the TocDocument places the loaded object side by side with a table of contents computed from various levels of headings in the document. In most cases, you will want other styles carried through your entire application. These include specifications for color, font, and style preferences.

You can use set-document-properties to specify generic options, such as one might set on any container, so that the value will be inherited by the contents. (e.g., color, font-size). Although set-document-properties is technically not a text format, you use it in documents to modify the general appearance of the document. To use it, place it at the top of the applet and attach options to it. Some relevant options include: margin, background, border-width, and border-color.

Code:
{curl 5.0 applet}
{applet {compiler-directives careful? = true}}

{document-style PlainDocument}

{set-document-properties
font-weight = bold,
font-family = Tahoma,
font-size = 8pt,
color=blue
}

{paragraph
{heading Curl IDE}
{paragraph
font-style = italic,
The Curl IDE includes all of the tools you need to build rich Internet applications
using the Curl content language. The Curl Run Time Environment (RTE) is free to end users,
and includes a browser plugin so that any user who installs
the RTE can run applications on your web site simply by visiting
the url where you have deployed the applet.
}
}


Notice that the heading overrides the font size that is specified in set-document-properties. Similarly, the font-style = "italic" adds to the property list for the paragraph

For more information regarding document properties, see the following section in the Curl Documentation:Curl Developer's Guide > Text Formatting > Defining Text Procedures






Attached Files
.jpg   toc.jpg (Size: 66.72 KB / Downloads: 592)
.curl   applet-4a.curl (Size: 555 bytes / Downloads: 353)
.curl   applet-4b.curl (Size: 589 bytes / Downloads: 293)
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Getting Started1:Creating a Simple Applet: Hello World kino 2 6,321 08-15-2016, 03:50 PM
Last Post: dyoshida
  Serving Content1:Launching a Curl Applet kino 0 5,366 06-15-2011, 05:12 PM
Last Post: kino
Forum Jump:


Users browsing this thread:
1 Guest(s)