Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

CSS Menu with Highlights

// Simple CSS that will let you do away with clunky images forever! This script will create a perfect menu that highlights links when the mouse rolls over! The beauty of CSS is that this script is compact, lightweight and customizeable! This is a perfect example of the power of CSS.
DEMO
webscriptexpert.com

<HTML CODE HERE>
<table border="0" width=175>
<tr>
<td width="100%" bgcolor="#E6E6E6"><span class="style7"><b>CSS MENU<b></span></td>
<tr>
<td width="100%"><span class="style5"><a href="http://www.webscriptexpert.com" class="selector">Web Script Expert</a></span></td>
</tr>
<tr>
<td width="100%"><span class="style5"><a href="http://www.webscriptexpert.com" class="selector">Actionscript</a></span></td>
</tr>
<tr>
<td width="100%"><span class="style5"><a href="http://www.webscriptexpert.com" class="selector">PHP CSS</a></span></td>
</tr>
<tr>
<td width="100%"><span class="style5"><a href="http://www.webscriptexpert.com" class="selector">Javascript</a></span></td>
</tr>
</table>



<CSS CODE HERE>
<style>
A.selector {
display: block;
width: 198px;
text-align: left;
text-decoration: none;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;
border: solid 1px #FFFFFF;
}

A.selector:hover {
border: solid 1px #6100C1;
background-color:#F0E1FF;
}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.style7 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
</style>

Simple Rebol Menu

Here's a quick way to add menus to your Rebol scripts. It's taken from the tutorial at http://musiclessonz.com/rebol_tutorial.html. See that page for the fully commented example.


Rebol [Title: "Simple Menu Example"]

view center-face gui: layout/size [

    at 100x100 H3 "You selected:"
    display: field

    origin 2x2 space 5x5 across
    at -200x-200 file-menu: text-list "item1" "item2" "quit" [
        switch value [
            "item1" [
                face/offset: -200x-200
                show file-menu
                ; PUT YOUR CODE HERE:
                set-face display "File / item1"
            ]
            "item2" [
                face/offset: -200x-200
                show file-menu
                ; PUT YOUR CODE HERE:
                set-face display "File / item2"
            ]
            "quit" [quit]
        ]
    ]

    at 2x2
    text bold "File" [
        either (face/offset + 0x22) = file-menu/offset [
            file-menu/offset: -200x-200
            show file-menu
        ][
            file-menu/offset: (face/offset + 0x22)
            show file-menu
        ]
    ]

    text bold "Help" [
        file-menu/offset: -200x-200
        show file-menu
        ; PUT YOUR CODE HERE:
        set-face display "Help"
    ]
] 400x300

Inputing non-ascii characters

My mobile phone (6600) doesn't have a Thai input method.
(You can buy a special software to do it)
After a lot of my thought experiments, I got an easy
example from my friend on this. You do a 2-level popup menu
to let people choose from the character table.
from appuifw import *

def thai_input():
    first_list = ['  '.join(thai_char[i:i+11]) for i in range(0,77,11)]
    y = popup_menu(first_list, u'select Thai char')
    if y is not None:
        x = popup_menu(thai_char[11*y:11*(y+1)], u'select Thai char')
        if x is not None:
            t.add(thai_char[11*y + x])

thai_char = [unichr(0x0e01+i) for i in range(77)]   # 77 thai characters

app.body = t = Text()
app.menu = [(u'thai', thai_input), (u'clear screen', t.clear)] 

# wait for user to exit program
import e32      
lock = e32.Ao_lock() 
app.exit_key_handler=lock.signal
lock.wait()


For other language, you can change the unicode offset (0x0e01)
and number of characters (77) to that of your language.
One requirement for this method is that the phone must be
able to display font in your language already.
(I have previously install Thai font on my 6600)
An alternative method to implement this will be manually drawing
your text (combile character from image font file).
I may do that some day.

Using submenu

appuifw.app.menu = [(u"item 1", item1),
  (u"Submenu 1", ((u"sub item 1", subitem1),
  (u"sub item 2", subitem2) ))
]
# item1, subitem1, subitem2 are callback
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS