Changeset 440

Show
Ignore:
Timestamp:
02/29/2008 15:30:06 (6 months ago)
Author:
why
Message:
  • lib/shoes/help.rb: working on some missing docs for some elements and slot methods.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/shoes/help.rb

    r432 r440  
    279279The App itself, in slot/box terminology, is a flow.  See the ''Slots'' section for more, but this just means that any elements placed directly at the top-level will flow. 
    280280 
     281=== close() === 
     282 
     283Closes the app window.  If multiple windows are open and you want to close the entire application, use the built-in method `exit`. 
     284 
    281285=== location() » String === 
    282286 
     
    469473Shoes has a wide variety of elements, many cherry-picked from HTML.  This page describes how to create these elements in a slot.  See the Elements section of the manual for more on how to modify and use these elements after they have been placed. 
    470474 
     475=== animate(fps) { |frame| ... } » Shoes::Animation === 
     476 
     477Starts an animation timer, which runs parallel to the rest of the app.  The `fps` is a number, the frames per seconds.  This number dictates how many times per second the attached block will be called. 
     478 
     479The block is given a `frame` number.  Starting with zero, the `frame` number tells the block how many frames of the animation have been shown. 
     480 
     481{{{ 
     482 #!ruby 
     483 Shoes.app do 
     484   @counter = para "STARTING" 
     485   animate(24) do |frame| 
     486     @counter.replace "FRAME #{frame}" 
     487   end 
     488 end 
     489}}} 
     490 
     491The above animation is shown 24 times per second.  If no number is give, the `fps` defaults to 10. 
     492 
    471493=== background(pattern) » Shoes::Background === 
    472494 
     
    495517'''PLEASE NOTE:''' Like Backgrounds, Borders are actual elements, not styles.  HTML treats backgrounds and borders like styles.  Which means every box can only have one borders.  Shoes layers border and background elements, along with text blocks, images, and everything else. 
    496518 
     519=== button(text) { ... } » Shoes::Button === 
     520 
     521Adds a push button with the message `text` written across its surface.  An optional block can be attached, which is called if the button is pressed. 
     522 
    497523=== caption(text) » Shoes::Caption === 
    498524 
    499525Creates a Caption text block.  Shoes styles this text to 14 pixels high. 
    500526 
     527=== check() » Shoes::Check === 
     528 
     529Adds a check box. 
     530 
    501531=== code(text) » Shoes::Code === 
    502532 
     
    507537Creates a Del text fragment (short for "deleted") which defaults to text with a single strikethrough in its middle. 
    508538 
     539=== edit_box(text) » Shoes::EditBox === 
     540 
     541Adds a large, multi-line textarea to this slot.  The `text` is optional and should be a string that will start out the box.  An optional block can be attached here which is called any type the user changes the text in the box. 
     542 
     543{{{ 
     544 #!ruby 
     545 Shoes.app do 
     546   edit_box 
     547   edit_box "HORRAY EDIT ME" 
     548   edit_box "small one", :width => 100, :height => 160 
     549 end 
     550}}} 
     551 
     552=== edit_line(text) » Shoes::EditLine === 
     553 
     554Adds a single-line text box to this slot.  The `text` is optional and should be a string that will start out the box.  An optional block can be attached here which is called any type the user changes the text in the box. 
     555 
    509556=== em(text) » Shoes::Em === 
    510557 
    511558Creates an Em text fragment (short for "emphasized") which, by default, is styled with italics. 
    512559 
     560=== every(seconds) { |count| ... } » Shoes::Every === 
     561 
     562A timer similar to the `animation` method, but much slower.  This timer fires a given number of seconds, running the block attached.  So, for example, if you need to check a web site every five minutes, you'd call `every(300)` with a block containing the code to actually ping the web site. 
     563 
    513564=== image(path) » Shoes::Image === 
    514565 
    515566Creates an Image element for displaying a picture.  PNG, JPEG and GIF formats are allowed. 
    516567 
     568=== imagesize(path) » [width, height] ===  
     569 
     570Quickly grab the width and height of an image.  The image won't be loaded into the cache or displayed. 
     571 
    517572=== ins(text) » Shoes::Ins === 
    518573 
     
    529584The default LinkHover style is also single-underlined with a #039 (dark blue) stroke. 
    530585 
     586=== list_box(:items => [strings, ...]) » Shoes::ListBox === 
     587 
     588Adds a drop-down list box containing entries for everything in the `items` array.  An optional block may be attached, which is called if anything in the box becomes selected by the user. 
     589 
     590{{{ 
     591 #!ruby 
     592 Shoes.app do 
     593   stack :margin => 10 do 
     594     para "Pick a card:" 
     595     list_box :items => ["Jack", "Ace", "Joker"] 
     596   end 
     597 end 
     598}}} 
     599 
     600Call `ListBox#text` to get the selected string.  See the `ListBox` section under `Native` controls for more help. 
     601 
     602=== progress() » Shoes::Progress === 
     603 
     604Adds a progress bar. 
     605 
    531606=== para(text) » Shoes::Para === 
    532607 
    533608Create a Para text block (short for "paragraph") which Shoes styles at 12 pixels high. 
    534609 
     610=== radio() » Shoes::Radio === 
     611 
     612Adds a radio button. 
     613 
    535614=== strong(text) » Shoes::Strong === 
    536615 
     
    552631 
    553632Creates a Tagline text block.  Shoes styles this text to 18 pixels high. 
     633 
     634=== timer(seconds) { ... } » Shoes::Timer === 
     635 
     636A one-shot timer.  If you want to schedule to run some code in a few seconds (or minutes, hours) you can attach the code as a block here. 
     637 
     638To display an alert box five seconds from now: 
     639 
     640{{{ 
     641 #!ruby 
     642 Shoes.app do 
     643   timer(5) do 
     644     alert("Your five seconds are up.") 
     645   end 
     646 end 
     647}}} 
    554648 
    555649=== title(text) » Shoes::Title === 
     
    630724Each style setting also has a method, which can be used to grab that particular setting.  (So, 
    631725like, the `width` method returns the width of the slot in pixels.) 
     726 
     727=== gutter() » a number === 
     728 
     729The size of the scrollbar area.  When Shoes needs to show a scrollbar, the scrollbar may end up covering up some elements that touch the edge of the window.  The `gutter` tells you how many pixels to expect the scrollbar to cover. 
     730 
     731This is commonly used to pad elements on the right, like so: 
     732 
     733{{{ 
     734 #!ruby 
     735 stack :margin_right => 20 + gutter do 
     736   para "Insert fat and ratified declaration of 
     737     independence here..." 
     738 end 
     739}}} 
    632740 
    633741=== height() » a number ===